scip-query 0.24.0 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +247 -1
- package/README.md +111 -124
- package/dist/augment-vue-worker.js +1 -1
- package/dist/by-kind-PRVFAGTQ.js +2 -0
- package/dist/call-graph-DVPAQV2F.js +2 -0
- package/dist/{call-graph-evidence-BociKRpF.d.ts → call-graph-evidence-CUtj8V2I.d.ts} +1 -1
- package/dist/chunk-2FSBGL5P.js +2 -0
- package/dist/chunk-2HLAFUCY.js +2 -0
- package/dist/chunk-2IWUT6CJ.js +3 -0
- package/dist/chunk-2KNN7GTQ.js +2 -0
- package/dist/chunk-2LHXRE2B.js +8 -0
- package/dist/{chunk-E65ELFKU.js → chunk-2YXE77TJ.js} +2 -2
- package/dist/chunk-36SGVCGX.js +2 -0
- package/dist/chunk-3ABBFPTP.js +2 -0
- package/dist/chunk-3IVFU4FD.js +3 -0
- package/dist/chunk-3JIQS44J.js +7 -0
- package/dist/chunk-3ZRB6DNK.js +7 -0
- package/dist/{chunk-6YTSKJJ3.js → chunk-42EOW5VI.js} +1 -1
- package/dist/{chunk-BHKK5RJY.js → chunk-4BHGBMNO.js} +2 -2
- package/dist/chunk-4BP3UBDG.js +2 -0
- package/dist/chunk-4D6RO7G4.js +2 -0
- package/dist/chunk-4FEWQ6RH.js +2 -0
- package/dist/chunk-4IGEOBG7.js +2 -0
- package/dist/chunk-4QZXBUKC.js +2 -0
- package/dist/chunk-4WBDEVX2.js +4 -0
- package/dist/chunk-4WCUBZU3.js +8 -0
- package/dist/chunk-4WTUBQ36.js +40 -0
- package/dist/chunk-4XQ4O6IM.js +3 -0
- package/dist/chunk-55UQAMZO.js +4 -0
- package/dist/chunk-5D2LVK7O.js +125 -0
- package/dist/chunk-5IYJ56TT.js +2 -0
- package/dist/chunk-5PLMJC7Q.js +2 -0
- package/dist/chunk-5TNQJUR2.js +5 -0
- package/dist/chunk-62BDNPMI.js +2 -0
- package/dist/chunk-64DZ5TXR.js +7 -0
- package/dist/chunk-65245JCM.js +2 -0
- package/dist/chunk-6FFVZZL4.js +2 -0
- package/dist/chunk-6KO5JHAR.js +2 -0
- package/dist/chunk-6LRXOOSX.js +2 -0
- package/dist/chunk-6LSEIIF7.js +2 -0
- package/dist/chunk-6YMNWD3H.js +6 -0
- package/dist/chunk-72AD6ZRR.js +5 -0
- package/dist/chunk-73AAKPUC.js +4 -0
- package/dist/chunk-76CZ77DF.js +2 -0
- package/dist/chunk-7VPEEAAG.js +2 -0
- package/dist/chunk-7WTPQ4NX.js +14 -0
- package/dist/chunk-7Y5T6XDP.js +2 -0
- package/dist/chunk-A2IIGFMJ.js +5 -0
- package/dist/chunk-AB5KCTEV.js +2 -0
- package/dist/chunk-AC566WBP.js +6 -0
- package/dist/chunk-AGWFSTXC.js +3 -0
- package/dist/chunk-AOSIYPTA.js +2 -0
- package/dist/chunk-AUVEWPIF.js +2 -0
- package/dist/chunk-B56T42J3.js +25 -0
- package/dist/chunk-BIQEF5NE.js +2 -0
- package/dist/chunk-BL6XJKTA.js +3 -0
- package/dist/chunk-BMKOQJRI.js +2 -0
- package/dist/chunk-BOZ4EXBB.js +3 -0
- package/dist/chunk-BUTWYEPH.js +2 -0
- package/dist/chunk-BZB4QPIP.js +2 -0
- package/dist/{chunk-6ILKOOGH.js → chunk-CE357GEE.js} +4 -4
- package/dist/chunk-CFN45HFP.js +2 -0
- package/dist/chunk-CFYMZFXT.js +368 -0
- package/dist/chunk-CN5EH7O3.js +2 -0
- package/dist/chunk-D254DNNQ.js +4 -0
- package/dist/chunk-D3FDISIC.js +2 -0
- package/dist/chunk-D3NX5XIE.js +3 -0
- package/dist/chunk-DA7RPPDF.js +3 -0
- package/dist/chunk-DDMC3FON.js +3 -0
- package/dist/chunk-DIO3FUSG.js +2 -0
- package/dist/chunk-DJ2NNSUK.js +3 -0
- package/dist/chunk-DKYQIM3C.js +18 -0
- package/dist/{chunk-OHIV323X.js → chunk-DOOEL2IV.js} +2 -2
- package/dist/chunk-DVFP6PZI.js +2 -0
- package/dist/chunk-E3FDPXZK.js +2 -0
- package/dist/chunk-E7YNJLCB.js +2 -0
- package/dist/chunk-EFGW5JPH.js +2 -0
- package/dist/chunk-EJVTR244.js +13 -0
- package/dist/chunk-EOV7RTRZ.js +2 -0
- package/dist/chunk-ETOIKRHO.js +2 -0
- package/dist/chunk-EYK3ZAO2.js +3 -0
- package/dist/chunk-F2V2LPET.js +52 -0
- package/dist/chunk-F4LUHJTF.js +2 -0
- package/dist/chunk-F4PUT6IT.js +2 -0
- package/dist/chunk-F56GCXXS.js +5 -0
- package/dist/chunk-FC2EVQRM.js +2 -0
- package/dist/chunk-FL7NBMHP.js +3 -0
- package/dist/chunk-FMRN2TRL.js +3 -0
- package/dist/chunk-FVULPZDF.js +20 -0
- package/dist/chunk-GCKCF5FL.js +43 -0
- package/dist/chunk-GH2PYF46.js +2 -0
- package/dist/chunk-GHJAGXIP.js +2 -0
- package/dist/{chunk-2GJSD5GY.js → chunk-GMVSHUKZ.js} +2 -2
- package/dist/chunk-GS6KDO4R.js +2 -0
- package/dist/chunk-GUUBXNN7.js +2 -0
- package/dist/chunk-GVWX5T43.js +80 -0
- package/dist/chunk-GZKFETP5.js +2 -0
- package/dist/chunk-H4EQHO6J.js +9 -0
- package/dist/chunk-H73WY2RM.js +2 -0
- package/dist/chunk-H75GSPRV.js +60 -0
- package/dist/chunk-HDR3AHSV.js +61 -0
- package/dist/chunk-HQBSL74Y.js +2 -0
- package/dist/chunk-HRRFKWPZ.js +2 -0
- package/dist/chunk-HXENDJC6.js +2 -0
- package/dist/chunk-IIBAZNSW.js +21 -0
- package/dist/chunk-INLMWEUU.js +12 -0
- package/dist/chunk-IWQPAF4F.js +2 -0
- package/dist/chunk-IZJ6YUKP.js +35 -0
- package/dist/chunk-J2TMAIN5.js +60 -0
- package/dist/chunk-J5FJMODQ.js +142 -0
- package/dist/chunk-J7HZPIO3.js +2 -0
- package/dist/chunk-JEVRKFRL.js +2 -0
- package/dist/chunk-JFXSGAEB.js +30 -0
- package/dist/chunk-JVRTHGFS.js +3 -0
- package/dist/chunk-JYWEX7RR.js +360 -0
- package/dist/chunk-K3YL22N6.js +2 -0
- package/dist/chunk-K4CN7GXK.js +12 -0
- package/dist/chunk-K5TBVXU4.js +30 -0
- package/dist/chunk-KDDIE2DP.js +9 -0
- package/dist/chunk-KHWRRPV4.js +2 -0
- package/dist/chunk-KI6NBKDY.js +14 -0
- package/dist/chunk-KU3QRSTH.js +2 -0
- package/dist/chunk-KZBJWZJB.js +2 -0
- package/dist/chunk-L7GFM3NP.js +3 -0
- package/dist/chunk-LMO6PK3V.js +35 -0
- package/dist/chunk-LN4YXJJU.js +2 -0
- package/dist/chunk-LOVIZBJ4.js +43 -0
- package/dist/chunk-LPCRK4A2.js +11 -0
- package/dist/chunk-MMHZKBFA.js +2 -0
- package/dist/{chunk-A4WEAK35.js → chunk-MOQQBQRD.js} +2 -2
- package/dist/chunk-N2WN6I3L.js +2 -0
- package/dist/chunk-N3ORQT7L.js +2 -0
- package/dist/chunk-NAZ3RAIW.js +2 -0
- package/dist/chunk-NDUNO5JQ.js +2 -0
- package/dist/chunk-NEIWRNAZ.js +4 -0
- package/dist/chunk-NJJMVD65.js +2 -0
- package/dist/chunk-NLOQOBXI.js +20 -0
- package/dist/chunk-NOLZOVCU.js +2 -0
- package/dist/chunk-NOWINRRN.js +2 -0
- package/dist/chunk-NZAXKGRL.js +16 -0
- package/dist/chunk-O2C4UILI.js +2 -0
- package/dist/chunk-O3RHA6ZT.js +3 -0
- package/dist/chunk-O4UZSPPI.js +3 -0
- package/dist/chunk-OGFV2BUX.js +2 -0
- package/dist/chunk-OZCJXZK6.js +499 -0
- package/dist/chunk-P6ODM7BY.js +2 -0
- package/dist/{chunk-GHNPACNP.js → chunk-PAVGPRHJ.js} +2 -2
- package/dist/chunk-PH52RA7D.js +2 -0
- package/dist/chunk-PKN354TH.js +3 -0
- package/dist/chunk-PWOASWEG.js +11 -0
- package/dist/chunk-QIWXRW72.js +2 -0
- package/dist/chunk-QJRMOK5N.js +2 -0
- package/dist/{chunk-YXPUP5G2.js → chunk-QOIXNWQR.js} +2 -2
- package/dist/chunk-QXEUDXBT.js +3 -0
- package/dist/chunk-QYUVVBMR.js +6 -0
- package/dist/chunk-QZ7KQZRN.js +2 -0
- package/dist/chunk-R6LQBUDH.js +2 -0
- package/dist/chunk-RBS42E55.js +20 -0
- package/dist/chunk-RSJKPCFX.js +26 -0
- package/dist/chunk-S6CZA3MV.js +2 -0
- package/dist/chunk-STMVAHJP.js +2 -0
- package/dist/chunk-SYVPTTVW.js +2 -0
- package/dist/chunk-T6DK3ZP7.js +2 -0
- package/dist/chunk-TKD34PHN.js +4 -0
- package/dist/chunk-TNNQFH7W.js +2 -0
- package/dist/chunk-TNV7SSUF.js +2 -0
- package/dist/chunk-TO7ZR3EH.js +8 -0
- package/dist/chunk-TOU3CHK4.js +2 -0
- package/dist/chunk-TRBI4UKT.js +2 -0
- package/dist/chunk-TZCVNCAN.js +4 -0
- package/dist/chunk-U4LZA5LL.js +3 -0
- package/dist/chunk-U5RIG3JP.js +3 -0
- package/dist/chunk-UP5KXN2I.js +2 -0
- package/dist/chunk-UQFR3NDH.js +5 -0
- package/dist/chunk-UXYXF7GV.js +2 -0
- package/dist/chunk-VB3GOKOS.js +2 -0
- package/dist/{chunk-4FR6GQIT.js → chunk-VF5JZICY.js} +2 -2
- package/dist/chunk-VTY3VK6E.js +2 -0
- package/dist/chunk-VX2O4RIS.js +2 -0
- package/dist/chunk-WKPV2TDZ.js +2 -0
- package/dist/chunk-WOFQ5DTB.js +2 -0
- package/dist/chunk-WS4C6TCK.js +2 -0
- package/dist/chunk-WXU3DGPU.js +2 -0
- package/dist/{chunk-ATXPTSEI.js → chunk-X6RMKHJQ.js} +7 -7
- package/dist/{chunk-44IETFOU.js → chunk-XHMN6ZX7.js} +2 -2
- package/dist/chunk-XHTVFLWW.js +2 -0
- package/dist/chunk-XKIDJCIK.js +2 -0
- package/dist/chunk-XTYTYZPT.js +2 -0
- package/dist/chunk-Y2JHHTTA.js +2 -0
- package/dist/chunk-YGVRMGYN.js +4 -0
- package/dist/chunk-YNQCGEQE.js +2 -0
- package/dist/chunk-YOQVEXVE.js +14 -0
- package/dist/chunk-YRT2WLYY.js +2 -0
- package/dist/chunk-YTAP5Y2G.js +2 -0
- package/dist/chunk-YTYWI7VB.js +2 -0
- package/dist/chunk-YULZRALL.js +2 -0
- package/dist/chunk-Z33WQG4Q.js +2 -0
- package/dist/chunk-ZGTYGDMF.js +16 -0
- package/dist/chunk-ZHMRSZFD.js +43 -0
- package/dist/chunk-ZHSP366W.js +10 -0
- package/dist/chunk-ZIBYCYKK.js +7 -0
- package/dist/chunk-ZLADLUE6.js +3 -0
- package/dist/chunk-ZO4YXUT6.js +4 -0
- package/dist/{chunk-MZPXPSUJ.js → chunk-ZR4HBC2H.js} +2 -2
- package/dist/cli-main.js +6 -6
- package/dist/cli.js +1 -1
- package/dist/{code-B17qEMbt.d.ts → code-BNyrCF3_.d.ts} +3 -2
- package/dist/code-IL5WH3NZ.js +2 -0
- package/dist/code-result-json-ANTBEDFP.js +4 -0
- package/dist/command-descriptors-HEEMDHTU.js +222 -0
- package/dist/deps-EOWFC6FD.js +2 -0
- package/dist/direct-navigation-Y5B6OSIQ.js +3 -0
- package/dist/{exploration-topology-BG4v30HZ.d.ts → exploration-topology-CSgEyAz-.d.ts} +3 -1
- package/dist/files-K4AI3JUM.js +2 -0
- package/dist/{health-BI2a9WPy.d.ts → health-BtfmNrfa.d.ts} +5 -79
- package/dist/hierarchy-6W5NDIFI.js +2 -0
- package/dist/imports-WH365QY4.js +2 -0
- package/dist/index.d.ts +13 -1
- package/dist/index.js +1 -1
- package/dist/members-K3PHMF5S.js +2 -0
- package/dist/methods-E7KVMBX4.js +2 -0
- package/dist/output-continuation-command-BJSY67SN.js +3 -0
- package/dist/output-pagination-UZJ5ACIX.js +24 -0
- package/dist/postinstall.js +1 -1
- package/dist/project-reindex-EP24WT4X.js +3 -0
- package/dist/queries/affected.js +1 -1
- package/dist/queries/architecture.d.ts +15 -4
- package/dist/queries/architecture.js +1 -1
- package/dist/queries/bottlenecks.js +1 -1
- package/dist/queries/by-kind.js +1 -1
- package/dist/queries/call-graph.d.ts +1 -1
- package/dist/queries/call-graph.js +1 -1
- package/dist/queries/change-surface.d.ts +1 -0
- package/dist/queries/change-surface.js +1 -1
- package/dist/queries/cleanup-plan.d.ts +3 -3
- package/dist/queries/cleanup-plan.js +1 -1
- package/dist/queries/co-change.js +1 -1
- package/dist/queries/code.d.ts +1 -1
- package/dist/queries/code.js +1 -1
- package/dist/queries/complexity.d.ts +6 -3
- package/dist/queries/complexity.js +1 -1
- package/dist/queries/context.d.ts +1 -7
- package/dist/queries/context.js +1 -1
- package/dist/queries/coupling.js +1 -1
- package/dist/queries/cycles.js +1 -1
- package/dist/queries/dead.js +1 -1
- package/dist/queries/decorative-checkers.js +1 -1
- package/dist/queries/dependence-slice.d.ts +46 -22
- package/dist/queries/dependence-slice.js +1 -1
- package/dist/queries/dependency-depth.d.ts +1 -7
- package/dist/queries/dependency-depth.js +1 -1
- package/dist/queries/deps.js +1 -1
- package/dist/queries/diff-impact.d.ts +3 -1
- package/dist/queries/diff-impact.js +1 -1
- package/dist/queries/doc-drift.js +1 -1
- package/dist/queries/drift.d.ts +1 -1
- package/dist/queries/drift.js +1 -1
- package/dist/queries/duplicate-bodies.d.ts +1 -1
- package/dist/queries/duplicate-bodies.js +1 -1
- package/dist/queries/entry-map.d.ts +2 -4
- package/dist/queries/entry-map.js +1 -1
- package/dist/queries/evidence.d.ts +121 -61
- package/dist/queries/evidence.js +1 -1
- package/dist/queries/fan.js +1 -1
- package/dist/queries/files.js +1 -1
- package/dist/queries/health.d.ts +1 -1
- 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 +1 -1
- package/dist/queries/hotspots.js +1 -1
- package/dist/queries/imports.d.ts +1 -0
- package/dist/queries/imports.js +1 -1
- package/dist/queries/incomplete-migration.d.ts +3 -3
- package/dist/queries/incomplete-migration.js +1 -1
- package/dist/queries/index.d.ts +15 -64
- package/dist/queries/index.js +1 -1
- package/dist/queries/locality-candidates.d.ts +4 -4
- 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.js +1 -1
- package/dist/queries/not-implemented.d.ts +2 -6
- package/dist/queries/not-implemented.js +1 -1
- package/dist/queries/outline.js +1 -1
- package/dist/queries/passthrough-candidates.js +1 -1
- package/dist/queries/react-component-duplicates.js +1 -1
- package/dist/queries/react-hook-candidates.js +1 -1
- package/dist/queries/react-large-component-pressure.js +1 -1
- package/dist/queries/recent-duplicates.js +1 -1
- package/dist/queries/redundant-reexports.d.ts +4 -14
- package/dist/queries/redundant-reexports.js +1 -1
- package/dist/queries/refs.d.ts +4 -1
- package/dist/queries/refs.js +1 -1
- package/dist/queries/review.d.ts +188 -0
- package/dist/queries/review.js +2 -0
- package/dist/queries/similar-files.d.ts +7 -10
- package/dist/queries/similar-files.js +1 -1
- package/dist/queries/similar-signatures.js +1 -1
- package/dist/queries/similar.d.ts +19 -1
- package/dist/queries/similar.js +1 -1
- package/dist/queries/slice-cohesion.d.ts +205 -0
- package/dist/queries/slice-cohesion.js +2 -0
- package/dist/queries/source-inspection.d.ts +6 -202
- package/dist/queries/source-inspection.js +1 -1
- package/dist/queries/source-search.d.ts +2 -3
- package/dist/queries/source-search.js +1 -1
- package/dist/queries/stats.d.ts +1 -0
- package/dist/queries/stats.js +1 -1
- package/dist/queries/surface.js +1 -1
- package/dist/queries/symbols.js +1 -1
- package/dist/queries/system.d.ts +4 -2
- package/dist/queries/system.js +1 -1
- package/dist/queries/test-quality.d.ts +1 -1
- package/dist/queries/test-quality.js +1 -1
- package/dist/queries/twin-drift.d.ts +1 -1
- package/dist/queries/twin-drift.js +1 -1
- package/dist/queries/unused-imports.js +1 -1
- package/dist/queries/unused-params.d.ts +3 -15
- package/dist/queries/unused-params.js +1 -1
- package/dist/queries/vue-component-duplicates.js +1 -1
- package/dist/queries/vue-composable-candidates.js +1 -1
- package/dist/queries/vue-large-view-pressure.js +1 -1
- package/dist/query-service-fastpath.js +5 -5
- package/dist/query-service-server.js +4 -4
- package/dist/refs-CCBJG7WK.js +2 -0
- package/dist/refs-pagination-DRNLVU4S.js +2 -0
- package/dist/reindex-worker.js +79 -29
- package/dist/reindex.js +45 -45
- package/dist/repository-cache-worker.js +2 -0
- package/dist/runtime.d.ts +8 -8
- package/dist/runtime.js +3 -4
- 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/service-queries-2WAJI7R6.js +6 -0
- package/dist/source-inspection-91U9zdO3.d.ts +341 -0
- package/dist/{source-search-types-Dwz8KeuW.d.ts → source-search-types-DWGYNg8M.d.ts} +15 -2
- package/dist/stats-G7DIV6VU.js +2 -0
- package/dist/surface-IO55UALI.js +2 -0
- package/dist/system-ZBMSHJXU.js +2 -0
- package/dist/{queries/trace.d.ts → trace-BMjw3prn.d.ts} +1 -18
- package/dist/typescript-indexer.js +2 -0
- package/dist/typescript-mailbox-worker.js +1 -1
- package/dist/watch-server.js +3 -3
- package/docs/AGENT_GUIDE.md +19 -128
- package/docs/CLI_JSON_OUTPUT.md +21 -17
- package/docs/COMMAND_REFERENCE.md +34 -49
- package/docs/CURRENT_COMMANDS.md +123 -0
- package/docs/DETECTOR_EVIDENCE_CONTRACTS.md +0 -40
- package/docs/DETECTOR_GUIDE.md +27 -23
- package/docs/PRODUCT_VISION.md +135 -0
- package/docs/PROPERTY_TESTING.md +73 -0
- package/docs/REVIEW.md +76 -0
- package/docs/SKILLS.md +51 -0
- package/docs/WINDOWS_SIDECAR_RELEASE.md +12 -3
- package/docs/accuracy-audit-checklist.md +34 -0
- package/docs/analyzer-inventory.md +2 -2
- package/package.json +18 -80
- package/scripts/evidence-product-contract.mjs +7 -3
- package/scripts/record-review-coverage.mjs +118 -0
- package/scripts/scip-windows-provenance.mjs +29 -19
- package/skills/scip-architecture-review/SKILL.md +57 -0
- package/skills/scip-architecture-review/agents/openai.yaml +4 -0
- package/skills/scip-architecture-review/references/design-checks.md +17 -0
- package/skills/scip-explore/SKILL.md +15 -59
- package/skills/scip-explore/agents/openai.yaml +3 -3
- package/skills/scip-explore/references/external-evidence.md +2 -2
- package/skills/scip-explore/references/information-model.md +26 -29
- package/skills/scip-explore/scripts/capture-evidence.mjs +68 -34
- package/skills/scip-integrity-audit/SKILL.md +53 -181
- package/skills/scip-integrity-audit/agents/openai.yaml +3 -3
- package/skills/scip-integrity-audit/references/integrity-probes.md +27 -0
- package/skills/scip-plan/SKILL.md +39 -65
- package/skills/scip-plan/agents/openai.yaml +2 -2
- package/skills/scip-query/SKILL.md +28 -81
- package/skills/scip-query/agents/openai.yaml +2 -2
- package/skills/scip-query/references/command-guide.md +169 -0
- package/skills/scip-setup/SKILL.md +4 -2
- package/skills/scip-setup/agents/openai.yaml +3 -3
- package/dist/by-kind-H3P6BR5G.js +0 -2
- package/dist/call-graph-VTG2CUOQ.js +0 -2
- package/dist/chunk-26CT72HM.js +0 -2
- package/dist/chunk-2BMSSRBH.js +0 -2
- package/dist/chunk-2M2LSIMY.js +0 -7
- package/dist/chunk-2N6WBNDC.js +0 -29
- package/dist/chunk-2OOY75BW.js +0 -2
- package/dist/chunk-2USA3S3P.js +0 -3
- package/dist/chunk-2VAHDDLM.js +0 -133
- package/dist/chunk-2XWIUW5Z.js +0 -455
- package/dist/chunk-35NLDRZC.js +0 -2
- package/dist/chunk-3AF4TUFK.js +0 -3
- package/dist/chunk-3D4BOXW6.js +0 -20
- package/dist/chunk-3LO4FST5.js +0 -16
- package/dist/chunk-3WTY4LP2.js +0 -3
- package/dist/chunk-3Z5AMSK6.js +0 -29
- package/dist/chunk-4KBTHJLP.js +0 -2
- package/dist/chunk-5BIKR67W.js +0 -2
- package/dist/chunk-5PROPLHI.js +0 -2
- package/dist/chunk-5V7EPTII.js +0 -2
- package/dist/chunk-62LPZCBQ.js +0 -3
- package/dist/chunk-64O2JHQA.js +0 -2
- package/dist/chunk-6D4F5VWG.js +0 -10
- package/dist/chunk-6ERFBC3X.js +0 -3
- package/dist/chunk-6MFXCMZC.js +0 -2
- package/dist/chunk-6O7FACKB.js +0 -2
- package/dist/chunk-6TS3KOXR.js +0 -2
- package/dist/chunk-76QOU4PK.js +0 -3
- package/dist/chunk-7DUI77BN.js +0 -2
- package/dist/chunk-7F45LJKI.js +0 -2
- package/dist/chunk-7F7T6DCR.js +0 -2
- package/dist/chunk-7H6VHWWJ.js +0 -2
- package/dist/chunk-7HXT6YLU.js +0 -5
- package/dist/chunk-7KCZELVM.js +0 -2
- package/dist/chunk-7R4V5ES6.js +0 -6
- package/dist/chunk-7RIRIADH.js +0 -7
- package/dist/chunk-7ZLWLOGT.js +0 -2
- package/dist/chunk-AADQLOQ4.js +0 -38
- package/dist/chunk-AN76MGUE.js +0 -2
- package/dist/chunk-ANLNLY66.js +0 -2
- package/dist/chunk-AX7IDVFT.js +0 -2
- package/dist/chunk-B3X6KU75.js +0 -2
- package/dist/chunk-B7MPDEAK.js +0 -3
- package/dist/chunk-BBB5FBX4.js +0 -2
- package/dist/chunk-BJT7LSPK.js +0 -3
- package/dist/chunk-BJWFVAA5.js +0 -2
- package/dist/chunk-BKVWUP7Y.js +0 -2
- package/dist/chunk-BKZYTLGE.js +0 -35
- package/dist/chunk-BL6DCHQP.js +0 -2
- package/dist/chunk-BOW7SSQH.js +0 -43
- package/dist/chunk-C4RHHCKL.js +0 -7
- package/dist/chunk-C7C6AKAT.js +0 -117
- package/dist/chunk-CD6M6LS2.js +0 -16
- package/dist/chunk-CFE6PSG6.js +0 -2
- package/dist/chunk-CFNIGQMT.js +0 -2
- package/dist/chunk-CKBUBRYD.js +0 -2
- package/dist/chunk-CZW5MZ5B.js +0 -2
- package/dist/chunk-DBBZ63ZX.js +0 -2
- package/dist/chunk-DBN7DMJB.js +0 -18
- package/dist/chunk-DUULLZHZ.js +0 -3
- package/dist/chunk-DV5Y5NOS.js +0 -2
- package/dist/chunk-DZOIKCTM.js +0 -3
- package/dist/chunk-E4PKTOL3.js +0 -2
- package/dist/chunk-E7QR35ST.js +0 -2
- package/dist/chunk-EFSXAINW.js +0 -2
- package/dist/chunk-EHVEIEQN.js +0 -18
- package/dist/chunk-EHYDXE3Z.js +0 -2
- package/dist/chunk-EP63Y6LD.js +0 -2
- package/dist/chunk-EPX6NQN6.js +0 -4
- package/dist/chunk-ETC674NS.js +0 -5
- package/dist/chunk-F5GSBHC6.js +0 -3
- package/dist/chunk-FH3DGXC6.js +0 -2
- package/dist/chunk-FI7VGOR4.js +0 -16
- package/dist/chunk-FJF6VO2P.js +0 -2
- package/dist/chunk-FLMTCX5R.js +0 -2
- package/dist/chunk-FVFDOIM3.js +0 -2
- package/dist/chunk-G2HU5WRN.js +0 -2
- package/dist/chunk-G4ALYS4J.js +0 -2
- package/dist/chunk-G56I7K4W.js +0 -26
- package/dist/chunk-GC4DG2V5.js +0 -2
- package/dist/chunk-GG45PK4S.js +0 -4
- package/dist/chunk-GINH3YQU.js +0 -20
- package/dist/chunk-GTZZVLKJ.js +0 -2
- package/dist/chunk-GXXW5ZHH.js +0 -2
- package/dist/chunk-H5EXS3HM.js +0 -2
- package/dist/chunk-HAXXKRTD.js +0 -4
- package/dist/chunk-HEZWBAZY.js +0 -2
- package/dist/chunk-HMEWLMML.js +0 -2
- package/dist/chunk-HOBOVYPO.js +0 -11
- package/dist/chunk-HRFQ6GW5.js +0 -8
- package/dist/chunk-HX4X7KG3.js +0 -2
- package/dist/chunk-HYT2R7LX.js +0 -4
- package/dist/chunk-IKQVBVQL.js +0 -40
- package/dist/chunk-IW5XQG5G.js +0 -2
- package/dist/chunk-J6GLBBRK.js +0 -4
- package/dist/chunk-J7A4PWFX.js +0 -3
- package/dist/chunk-JCSAZ35V.js +0 -2
- package/dist/chunk-JDU2IV3A.js +0 -2
- package/dist/chunk-JFMEXGFE.js +0 -2
- package/dist/chunk-JFMI5SGB.js +0 -4
- package/dist/chunk-JJP37RGX.js +0 -57
- package/dist/chunk-JZ2A7LDM.js +0 -5
- package/dist/chunk-KMVGRIO2.js +0 -2
- package/dist/chunk-KNLQGXVH.js +0 -80
- package/dist/chunk-KVQCECPR.js +0 -2
- package/dist/chunk-KXXORBZ2.js +0 -4
- package/dist/chunk-L5KYH6U3.js +0 -35
- package/dist/chunk-L6XHYJPZ.js +0 -21
- package/dist/chunk-L7KTFEAV.js +0 -43
- package/dist/chunk-LDXHR5EL.js +0 -23
- package/dist/chunk-LEECKFCJ.js +0 -2
- package/dist/chunk-MHGDSBFX.js +0 -2
- package/dist/chunk-MLQVVDG3.js +0 -74
- package/dist/chunk-MOKUWRHO.js +0 -3
- package/dist/chunk-MPYAPMNE.js +0 -2
- package/dist/chunk-MTDBHTSF.js +0 -2
- package/dist/chunk-MV6SPXCR.js +0 -7
- package/dist/chunk-MWN53KRN.js +0 -60
- package/dist/chunk-MXNGIEPU.js +0 -3
- package/dist/chunk-N55KIE46.js +0 -2
- package/dist/chunk-NB4D3BNM.js +0 -2
- package/dist/chunk-NGKBOT6G.js +0 -23
- package/dist/chunk-NJGKXKQF.js +0 -2
- package/dist/chunk-NJQISBL4.js +0 -8
- package/dist/chunk-NJT3ZEKY.js +0 -16
- package/dist/chunk-NKMKZP6A.js +0 -2
- package/dist/chunk-NODFZ6ED.js +0 -2
- package/dist/chunk-NSM5IEVW.js +0 -2
- package/dist/chunk-NTGUVNR2.js +0 -3
- package/dist/chunk-NU3KFF2O.js +0 -57
- package/dist/chunk-NWLVNU66.js +0 -557
- package/dist/chunk-NYKZMCRC.js +0 -4
- package/dist/chunk-O6BUXZEH.js +0 -6
- package/dist/chunk-ODPDP7A4.js +0 -3
- package/dist/chunk-OIAPEKMT.js +0 -3
- package/dist/chunk-OIOC5EHF.js +0 -3
- package/dist/chunk-ONPPQM4G.js +0 -2
- package/dist/chunk-OUHEZBYI.js +0 -2
- package/dist/chunk-OVGYW7UD.js +0 -29
- package/dist/chunk-OYKU4B3Y.js +0 -2
- package/dist/chunk-POBJ6FR2.js +0 -5
- package/dist/chunk-PSZPMMWN.js +0 -2
- package/dist/chunk-PXTRBKRK.js +0 -3
- package/dist/chunk-Q5JRIHT3.js +0 -4
- package/dist/chunk-Q7ATHARX.js +0 -2
- package/dist/chunk-Q7CSKIDM.js +0 -5
- package/dist/chunk-QBQE7ZJ5.js +0 -3
- package/dist/chunk-QH22UIXP.js +0 -5
- package/dist/chunk-QXCKQTKR.js +0 -60
- package/dist/chunk-RBAD4GJ2.js +0 -13
- package/dist/chunk-RMDPFPNW.js +0 -2
- package/dist/chunk-ROPJDEJZ.js +0 -4
- package/dist/chunk-RVZC6TJE.js +0 -2
- package/dist/chunk-S4QZBKSR.js +0 -3
- package/dist/chunk-SCPMZ73U.js +0 -2
- package/dist/chunk-SIAP5RGI.js +0 -73
- package/dist/chunk-SIX4RFR3.js +0 -3
- package/dist/chunk-SKKXTABJ.js +0 -16
- package/dist/chunk-SSRFUQBD.js +0 -2
- package/dist/chunk-SYVJEEUJ.js +0 -3
- package/dist/chunk-T3CZAZSI.js +0 -8
- package/dist/chunk-T6DWDI5E.js +0 -3
- package/dist/chunk-T6HRIROJ.js +0 -7
- package/dist/chunk-TAA7HXHE.js +0 -2
- package/dist/chunk-TJ2JQYT3.js +0 -2
- package/dist/chunk-TULNMD5T.js +0 -368
- package/dist/chunk-U2FPY5XA.js +0 -3
- package/dist/chunk-U3SXIMII.js +0 -38
- package/dist/chunk-U6KCHXJ4.js +0 -2
- package/dist/chunk-UH3XSKS5.js +0 -9
- package/dist/chunk-UIFUZVCC.js +0 -2
- package/dist/chunk-UXKURIVI.js +0 -2
- package/dist/chunk-V2RBODHL.js +0 -2
- package/dist/chunk-VBKUWB6N.js +0 -2
- package/dist/chunk-VBV6ALJE.js +0 -2
- package/dist/chunk-VDGFWCQV.js +0 -2
- package/dist/chunk-VDSDOEWF.js +0 -2
- package/dist/chunk-VZPWVCLN.js +0 -20
- package/dist/chunk-WDSFQDPN.js +0 -2
- package/dist/chunk-WFA35BGR.js +0 -7
- package/dist/chunk-WLMP3OCW.js +0 -2
- package/dist/chunk-WSA52GOR.js +0 -2
- package/dist/chunk-WYPL7GF7.js +0 -2
- package/dist/chunk-X3YVZAKZ.js +0 -5
- package/dist/chunk-X6OGVFIT.js +0 -2
- package/dist/chunk-XDAUYDFT.js +0 -2
- package/dist/chunk-XKXTR6ZI.js +0 -9
- package/dist/chunk-Y5DFAW5W.js +0 -4
- package/dist/chunk-YSYPDRD5.js +0 -3
- package/dist/chunk-ZFVPWH62.js +0 -5
- package/dist/chunk-ZGIHTH27.js +0 -2
- package/dist/chunk-ZGIQN2SX.js +0 -2
- package/dist/chunk-ZHG4WAHR.js +0 -12
- package/dist/chunk-ZKB2XUEN.js +0 -4
- package/dist/chunk-ZLMXIQLC.js +0 -21
- package/dist/chunk-ZMCQIHI4.js +0 -2
- package/dist/code-TAVIKWJI.js +0 -2
- package/dist/code-result-json-5FEFQCAQ.js +0 -2
- package/dist/command-descriptors-7BKH53Y3.js +0 -343
- package/dist/dataflow-GFBTVDH3.js +0 -2
- package/dist/dependence-slice-GWGQCODG.js +0 -2
- package/dist/deps-4QHVDPYA.js +0 -2
- package/dist/direct-navigation-4UBC6HNW.js +0 -3
- package/dist/entry-map-QCTF4RVY.js +0 -2
- package/dist/files-M2UBF5HJ.js +0 -2
- package/dist/graph-evidence-Bjyky2V4.d.ts +0 -126
- package/dist/hierarchy-2UIHRLW4.js +0 -2
- package/dist/imports-WIE3YZOB.js +0 -2
- package/dist/members-YKD636DA.js +0 -2
- package/dist/methods-VDF4IMYG.js +0 -2
- package/dist/next-anchor-candidates-BwMczMvX.d.ts +0 -90
- package/dist/output-continuation-command-4UMDOOLO.js +0 -3
- package/dist/output-pagination-2GME6OPY.js +0 -19
- package/dist/project-reindex-XEQTRCV5.js +0 -3
- package/dist/queries/anchors.d.ts +0 -123
- package/dist/queries/anchors.js +0 -2
- package/dist/queries/complexity-hotspots.d.ts +0 -40
- package/dist/queries/complexity-hotspots.js +0 -2
- package/dist/queries/convergence.d.ts +0 -33
- package/dist/queries/convergence.js +0 -2
- package/dist/queries/dataflow.d.ts +0 -77
- package/dist/queries/dataflow.js +0 -2
- package/dist/queries/deep-chains.d.ts +0 -5
- package/dist/queries/deep-chains.js +0 -2
- package/dist/queries/extract-candidates.d.ts +0 -79
- package/dist/queries/extract-candidates.js +0 -2
- package/dist/queries/isolated.d.ts +0 -24
- package/dist/queries/isolated.js +0 -2
- package/dist/queries/plan-context.d.ts +0 -33
- package/dist/queries/plan-context.js +0 -2
- package/dist/queries/reference-neighborhood.d.ts +0 -4
- package/dist/queries/reference-neighborhood.js +0 -2
- package/dist/queries/reference-reachability.d.ts +0 -48
- package/dist/queries/reference-reachability.js +0 -2
- package/dist/queries/self-audit.d.ts +0 -69
- package/dist/queries/self-audit.js +0 -2
- package/dist/queries/similar-chains.d.ts +0 -48
- package/dist/queries/similar-chains.js +0 -2
- package/dist/queries/slice.d.ts +0 -4
- package/dist/queries/slice.js +0 -2
- package/dist/queries/stale-abstractions.d.ts +0 -72
- package/dist/queries/stale-abstractions.js +0 -2
- package/dist/queries/system-map.d.ts +0 -449
- package/dist/queries/system-map.js +0 -2
- package/dist/queries/trace.js +0 -2
- package/dist/queries/twin-ab.d.ts +0 -66
- package/dist/queries/twin-ab.js +0 -2
- package/dist/queries/value-flow.d.ts +0 -43
- package/dist/queries/value-flow.js +0 -2
- package/dist/queries/wrapper-candidates.d.ts +0 -49
- package/dist/queries/wrapper-candidates.js +0 -2
- package/dist/refs-JNK5CLM7.js +0 -2
- package/dist/refs-pagination-6BLRYGMV.js +0 -2
- package/dist/slice-PHPVNCWX.js +0 -2
- package/dist/source-snippet-_wrcgmZc.d.ts +0 -15
- package/dist/stats-OOJ74B32.js +0 -2
- package/dist/surface-MQX5MPIV.js +0 -2
- package/dist/symbol-resolution-DBLVXLBC.js +0 -2
- package/dist/system-JOPKV4OG.js +0 -2
- package/dist/trace-I2P2YFH4.js +0 -2
- package/dist/value-flow-JJVMF7NP.js +0 -2
- package/skills/concrete-plan/SKILL.md +0 -8
- package/skills/concrete-plan/agents/openai.yaml +0 -4
- package/skills/conductor/SKILL.md +0 -110
- package/skills/conductor/agents/openai.yaml +0 -4
- package/skills/principal-maintainability-review/SKILL.md +0 -273
- package/skills/principal-maintainability-review/agents/openai.yaml +0 -4
- package/skills/scip-calibrate/SKILL.md +0 -102
- package/skills/scip-calibrate/agents/openai.yaml +0 -4
- package/skills/scip-claim-audit/SKILL.md +0 -113
- package/skills/scip-claim-audit/agents/openai.yaml +0 -4
- package/skills/scip-probe-reachability/SKILL.md +0 -93
- package/skills/scip-probe-reachability/agents/openai.yaml +0 -4
- package/skills/scip-root-cause/SKILL.md +0 -160
- package/skills/scip-root-cause/agents/openai.yaml +0 -4
- package/skills/scip-system-compression/SKILL.md +0 -252
- package/skills/scip-system-compression/agents/openai.yaml +0 -4
- package/skills/scip-system-compression/references/compression-atlas.md +0 -116
- package/skills/scip-system-compression/references/compression-patterns.md +0 -87
- package/skills/scip-twin-drift/SKILL.md +0 -109
- package/skills/scip-twin-drift/agents/openai.yaml +0 -4
package/dist/chunk-TULNMD5T.js
DELETED
|
@@ -1,368 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{$b as Or,$d as Kr,$e as li,Ad as Vr,Af as Ei,Ba as Zt,Bf as Ii,C as Ze,Cd as Ur,Cf as wi,Ed as Ee,Ef as Ti,Fa as Q,Fd as Gr,Fe as ni,Ff as ki,Ga as en,Gd as Wr,Gf as gt,Hd as Ie,Ia as Pe,Id as ot,Ja as ce,Jd as Ne,Ka as tt,Kd as qr,Ke as ri,La as Tr,Ld as Hr,Le as V,M as hr,Ma as tn,Md as Jr,N as se,Na as kr,Nd as zr,Ne as ct,O as xe,Od as Yr,Oe as on,P as ve,Pe as ii,Q as yr,Qd as we,R as br,Rd as Xr,Re as oi,S as Xt,Sd as je,Se as ai,Ta as _r,Td as Z,U as et,Ud as C,Ue as an,V as Sr,Ve as si,W as Kt,Wa as nn,We as ci,Xe as G,Ya as Cr,Ye as ui,Ze as sn,_b as Lr,_d as at,_e as ut,a as Ye,ae as Be,af as di,b as gr,bb as nt,bf as pi,c as Ht,ce as Qr,cf as fi,d as mr,df as gi,ee as $e,ef as de,f as X,fe as st,ff as pe,g as N,ge as Zr,gf as lt,ha as Qt,hf as mi,ib as ue,if as hi,jb as le,jf as yi,ka as Rr,kb as Ar,kf as bi,l as Jt,lf as Si,mc as Dr,mf as Ri,n as Re,nc as rt,nf as dt,o as zt,oc as it,p as Xe,pa as xr,pc as Mr,pe as ei,pf as q,q as Ke,qb as w,qc as Nr,qe as ti,qf as pt,r as Yt,rb as W,rc as jr,re as rn,s as K,sb as Fr,sf as xi,t as $,ta as vr,u as U,ua as Pr,ue as Te,uf as cn,v as Qe,va as Er,vf as vi,wa as Ir,wf as Pi,xf as ft,yd as Br,za as wr,zd as $r}from"./chunk-2XWIUW5Z.js";import{createHash as _f}from"crypto";import{existsSync as B,mkdirSync as Bt,mkdtempSync as Cf,readdirSync as Es,renameSync as Is,rmSync as he,statSync as sr}from"fs";import{basename as Nt,dirname as I,extname as Af,join as O,resolve as ps}from"path";import{platform as fs}from"os";import{execFileSync as yt}from"child_process";import{createRequire as dc}from"module";import{chmodSync as pc,existsSync as Mi}from"fs";import{platform as ee,arch as bt}from"os";import{dirname as fc,join as Ni}from"path";import{createHash as Ai,randomUUID as Js}from"crypto";import{closeSync as mt,createReadStream as zs,existsSync as Ys,fsyncSync as Xs,mkdirSync as Ks,openSync as ln,renameSync as Qs,unlinkSync as Zs,writeSync as ec}from"fs";import{homedir as tc}from"os";import{dirname as Fi,join as un}from"path";var nc=3e5,rc=256*1024*1024;function Li(e,t=process.env){let n=t.SCIP_QUERY_CACHE_DIR??(t.XDG_CACHE_HOME?un(t.XDG_CACHE_HOME,"scip-query"):un(tc(),".cache","scip-query"));return un(n,e)}var L=class extends Error{constructor(n,r,i={}){super(r,i.cause===void 0?void 0:{cause:i.cause});this.kind=n;this.name="VerifiedBinaryFetchError"}kind};async function Oi(e){let{cachePath:t,url:n,expectedSha256:r}=e,i=e.timeoutMs??nc,o=e.maxBytes??rc,a=e.lockWaitMs??i;ic(i,o,a);let s=oc(n,i,e.signal);try{let c=await _i(t,r,o,s.controller.signal);if(c)return{status:"cached",path:t,sha256:c};Ks(Fi(t),{recursive:!0});let u=await ai(`${t}.fetch.lock`,{waitMs:a,pollMs:25,signal:s.controller.signal});if(!u)throw new L("lock-timeout",`timed out waiting ${a}ms for verified binary cache ownership at ${t}`);try{let l=await _i(t,r,o,s.controller.signal);return l?{status:"cached",path:t,sha256:l}:await ac(e,s.controller,o)}finally{u.release()}}catch(c){throw s.controller.signal.aborted?ke(s.controller.signal,n):c instanceof L?c:new L("stream",`failed to download ${n}: ${Di(c)}`,{cause:c})}finally{clearTimeout(s.timeout),s.detachExternalAbort(),s.controller.signal.aborted||s.controller.abort()}}function ic(e,t,n){if(!Number.isFinite(e)||e<=0)throw new TypeError("timeoutMs must be a positive finite number.");if(!Number.isSafeInteger(t)||t<=0)throw new TypeError("maxBytes must be a positive safe integer.");if(!Number.isFinite(n)||n<0)throw new TypeError("lockWaitMs must be a non-negative finite number.")}function oc(e,t,n){let r=new AbortController,i=()=>{r.abort(new L("aborted",`download of ${e} was aborted`,{cause:n?.reason}))};n?.addEventListener("abort",i,{once:!0}),n?.aborted&&i();let o=setTimeout(()=>{r.abort(new L("timeout",`download of ${e} timed out after ${t}ms`))},t);return o.unref(),{controller:r,timeout:o,detachExternalAbort:()=>n?.removeEventListener("abort",i)}}async function _i(e,t,n,r){if(!Ys(e))return null;let i=Ai("sha256"),o=0;try{for await(let s of zs(e,{signal:r})){let c=Buffer.isBuffer(s)?s:Buffer.from(s);if(o+=c.length,o>n)return null;i.update(c)}}catch{if(r.aborted)throw ke(r,e);return null}let a=i.digest("hex");return a===t?a:null}async function ac(e,t,n){let r=e.fetchImpl??fetch,i;try{i=await Ci(r(e.url,{signal:t.signal}),t.signal)}catch(u){throw t.signal.aborted?ke(t.signal,e.url):new L("stream",`failed to download ${e.url}: ${Di(u)}`,{cause:u})}if(!i.ok){let u=new L("http",`failed to download ${e.url}: HTTP ${i.status}`);throw t.abort(u),u}let o=sc(i,n,e.url);if(!i.body)throw new L("stream",`downloaded ${e.url} response has no readable body`);let a=`${e.cachePath}.tmp-${process.pid}-${Js()}`,s,c=!1;try{s=ln(a,"wx",384),c=!0;let u=i.body.getReader(),l=Ai("sha256"),p=0;for(;;){let{done:f,value:m}=await Ci(u.read(),t.signal);if(f)break;if(!(m instanceof Uint8Array))throw new L("stream",`downloaded ${e.url} produced a non-byte stream chunk`);if(p+=m.byteLength,p>n||o!==void 0&&p>o){let E=new L("length",`downloaded ${e.url} exceeded its ${o??n} byte limit`);throw t.abort(E),E}let y=Buffer.from(m.buffer,m.byteOffset,m.byteLength);l.update(y),Sr(s,y,{writeFile:e.writeImpl??ec},"verified binary staging")}if(o!==void 0&&p!==o)throw new L("length",`downloaded ${e.url} length mismatch: declared ${o} bytes, received ${p}`);let d=l.digest("hex");if(d!==e.expectedSha256)throw new L("checksum",`downloaded ${e.url} checksum mismatch: expected ${e.expectedSha256}, got ${d}`);mt(s),s=void 0;try{cc(a,e.cachePath,e.renameImpl??Qs,e.syncImpl??Xs)}catch(f){throw new L("install",`failed to install verified binary at ${e.cachePath}`,{cause:f})}return c=!1,{status:"downloaded",path:e.cachePath,sha256:d}}catch(u){throw t.signal.aborted?ke(t.signal,e.url):u instanceof L?u:new L("install",`failed to stage verified binary at ${e.cachePath}`,{cause:u})}finally{if(s!==void 0)try{mt(s)}catch{}if(c)try{Zs(a)}catch{}}}function sc(e,t,n){let r=e.headers?.get("content-length");if(r==null)return;if(!/^\d+$/.test(r))throw new L("length",`downloaded ${n} has an invalid Content-Length header`);let i=Number(r);if(!Number.isSafeInteger(i)||i<0)throw new L("length",`downloaded ${n} has an invalid Content-Length header`);if(i>t)throw new L("length",`downloaded ${n} declares ${i} bytes, above the ${t} byte limit`);return i}function cc(e,t,n,r){uc(e,r),n(e,t),lc(Fi(t),r)}function uc(e,t){let n=ln(e,"r");try{t(n)}finally{mt(n)}}function lc(e,t){let n;try{n=ln(e,"r")}catch(r){if(Kt(r,process.platform))return;throw r}try{t(n)}catch(r){if(!Kt(r,process.platform))throw r}finally{mt(n)}}function Ci(e,t){return t.aborted?Promise.reject(ke(t,"operation")):new Promise((n,r)=>{let i=()=>{t.removeEventListener("abort",i),r(ke(t,"operation"))};t.addEventListener("abort",i,{once:!0}),e.then(o=>{t.removeEventListener("abort",i),n(o)},o=>{t.removeEventListener("abort",i),r(o)})})}function ke(e,t){return e.reason instanceof Error?e.reason:new L("aborted",`verified binary operation for ${t} was aborted`)}function Di(e){return e instanceof Error?e.message:String(e)}var M="v0.8.1",dn="https://github.com/sourcegraph/scip",ht=`github.com/sourcegraph/scip/cmd/scip@${M}`,ji=dc(import.meta.url),gc={"scip-darwin-amd64.tar.gz":"39f18be957d350bcd9ed5cb12d7781b0e237a5cb2429a107feaf9ce2d1dcd5d5","scip-darwin-arm64.tar.gz":"5b3f4a2fb1dc10c599cb3422ed0406a739060e4ac0b1222c0f43630dd0dd8221","scip-linux-amd64.tar.gz":"16b79ed98f893abd530cfa63f333527f1351008b4a23e02b9e522e34d1da6596","scip-linux-arm64.tar.gz":"876dfb680119dd6e5713077c49b27701102d598bdeba94c809173276d399c7e2"},Bi="SCIP_QUERY_SCIP_BIN";function $i(e=process.env){return e.SCIP_QUERY_SQLITE_CONVERTER==="scip-cli"}function mc(e){let t=e.env[Bi];if(t&&e.fileExists(t))return{source:"env",path:t};let n=e.resolveCached?.()??null;if(n)return{source:"cache",path:n};if(e.isOnPath("scip"))return{source:"path",path:"scip"};if(e.platform==="win32"){let r=e.resolveSidecar(e.arch);if(r&&e.fileExists(r))return{source:"sidecar",path:r}}return null}function hc(e){for(let t of e==="arm64"?["arm64","x64"]:[e])try{return ji.resolve(`scip-query-scip-windows/scip-win32-${t}.exe`)}catch{}return null}function Ve(e=process.env){return pn(e)?.path??null}function pn(e=process.env){let t=mc({platform:ee(),arch:bt(),env:e,isOnPath:Ee,fileExists:Mi,resolveSidecar:hc,resolveCached:()=>yc(e)});return t?.source==="path"?{source:"path",path:Wr("scip")??t.path}:t}function Vi(e=process.env){return Li(Ni("scip",M,"scip"),e)}function yc(e){let t=Vi(e);return Mi(t)?t:null}function fn(e){return e!==null&&e.includes(M.replace(/^v/,""))}function Dg(){return Ve()!==null}function gn(){let e=Ve();if(!e)return null;try{return yt(e,["--version"],{stdio:"pipe",timeout:1e4,killSignal:"SIGKILL"}).toString().trim()}catch{return null}}function bc(e=ee(),t=bt()){let n=Ui(e,t);if(!n)return null;let r=gc[n.filename];return r?{...n,sha256:r}:null}function Ui(e=ee(),t=bt()){let n,r,i;switch(e){case"darwin":n="darwin",i="tar.gz";break;case"linux":n="linux",i="tar.gz";break;default:return null}switch(t){case"arm64":r="arm64";break;case"x64":r="amd64";break;default:return null}let o=`scip-${n}-${r}.${i}`;return{url:`${dn}/releases/download/${M}/${o}`,filename:o}}function Mg(){let e=Ui();if(console.log("\nThe `scip` CLI is required but not found on PATH.\n"),ee()==="darwin"||ee()==="linux")console.log(`Let scip-query install the reviewed release (${M}, digest-verified) into its cache:`),console.log(` scip-query setup --install-missing
|
|
3
|
-
`),console.log("Or install it with Go:"),console.log(` go install ${ht}
|
|
4
|
-
`),console.log("Or download that exact release manually:");else if(ee()==="win32"){let t=Sc();console.log("On Windows the scip binary ships via the npm sidecar package scip-query-scip-windows,"),console.log("installed automatically with scip-query. If it is missing:"),console.log(` npm install -g ${t}`),console.log(`Or set ${Bi} to a local scip.exe path.
|
|
5
|
-
`),console.log("Upstream release page:")}else console.log("Download from:");console.log(e?` ${e.url}
|
|
6
|
-
`:` ${dn}/releases/tag/${M}
|
|
7
|
-
`),console.log("After installing, ensure `scip` is on your PATH and run `scip-query reindex`.")}function Sc(){let t=ji("../../package.json").optionalDependencies?.["scip-query-scip-windows"];if(!t||!/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/.test(t))throw new Error("scip-query package metadata does not declare an exact Windows sidecar version.");return`scip-query-scip-windows@${t}`}var Rc={fetch:Oi,extract:(e,t)=>{yt("tar",["-xzf",e,"-C",t,"scip"],{stdio:"pipe",timeout:12e4,killSignal:"SIGKILL"})},markExecutable:e=>pc(e,493),probeVersion:e=>xc(e),env:process.env};async function mn(e,t={}){let n={...Rc,...t},r=bc();if(!r)return e(`No reviewed scip ${M} release archive is published for ${ee()}/${bt()}.`),null;let i=Vi(n.env),o=fc(i),a=Ni(o,r.filename);e(`Downloading reviewed scip ${M} (${r.filename}, sha256 ${r.sha256.slice(0,12)}\u2026).`);try{let c=await n.fetch({cachePath:a,url:r.url,expectedSha256:r.sha256});n.extract(c.path,o),n.markExecutable(i)}catch(c){return e(`Could not install scip ${M}: ${c instanceof Error?c.message:String(c)}`),null}let s=n.probeVersion(i);return fn(s)?(e(`Installed reviewed scip ${M} at ${i}.`),i):(e(`Installed scip at ${i} did not report ${M} (reported: ${s??"unavailable"}).`),null)}function xc(e){try{return yt(e,["--version"],{stdio:"pipe",timeout:1e4,killSignal:"SIGKILL"}).toString().trim()}catch{return null}}async function Gi(e,t={}){if(ee()!=="win32"&&await mn(e,t)!==null)return!0;if(Ee("go")){e(`Installing immutable ${ht} via go install into the Go bin directory (GOBIN or GOPATH/bin); expected executable: scip.`);try{if(yt("go",["install",ht],{stdio:"inherit",timeout:3e5,env:process.env}),Ee("scip")){let n=Ve(),r=gn();if(n&&r&&r.includes(M))return e(`Successfully installed ${ht}; resolved executable: ${n}; reported version: ${r}.`),!0;e(`go install completed, but the resolved scip executable did not report ${M} (executable: ${n??"unresolved"}; version: ${r??"unavailable"}).`)}}catch(n){let r=n instanceof Error?n.message:String(n);e(`go install failed: ${r}`)}}return e("Could not auto-install scip CLI."),e(`Install manually from: ${dn}/releases/tag/${M}`),!1}var _e=class extends Error{constructor(t){super(t),this.name="ReindexLockUnavailableError"}};import{execFileSync as vc}from"child_process";import{constants as Pc,copyFileSync as Wi,linkSync as Ec,rmSync as Ic,statSync as wc}from"fs";import{platform as Tc}from"os";var kc=Object.freeze({size:e=>wc(e).size,clone:Fc,copy:(e,t)=>Wi(e,t),link:(e,t)=>Ec(e,t),remove:e=>Ic(e,{force:!0})}),_c=new Set(["EXDEV","EPERM","EMLINK","ENOTSUP","EOPNOTSUPP","ENOSYS","EINVAL"]),Cc=new Set(["ENOSYS","ENOTSUP","EOPNOTSUPP","EINVAL","EXDEV","ENOTTY"]);function fe(e,t,n=kc,r={}){let i=n.size(e);n.remove?.(t);try{return n.clone(e,t),{method:"reflink",bytes:i}}catch(o){if(!Oc(o))throw o}if(r.shareImmutable&&n.link)try{return n.link(e,t),{method:"link",bytes:i}}catch(o){if(!Ac(o))throw o}return n.copy(e,t),{method:"copy",bytes:i}}function Ac(e){let t=e?.code;return typeof t=="string"&&_c.has(t)}function Fc(e,t){if(Tc()!=="darwin"){Wi(e,t,Pc.COPYFILE_FICLONE_FORCE);return}try{vc("/bin/cp",["-c",e,t],{timeout:6e4,maxBuffer:64*1024,stdio:["ignore","ignore","pipe"]})}catch(n){throw Lc(n)}}function Lc(e){let t=e?.stderr,n=Buffer.isBuffer(t)?t.toString("utf8"):t??"";return/operation not supported|not supported/i.test(n)?Object.assign(e instanceof Error?e:new Error(String(e)),{code:"ENOTSUP"}):/cross-device link/i.test(n)?Object.assign(e instanceof Error?e:new Error(String(e)),{code:"EXDEV"}):e}function Oc(e){let t=e?.code;return t!==void 0&&Cc.has(t)}function qi(){return{reflinkedBytes:0,fallbackCopiedBytes:0,incrementalWrittenBytes:0}}function ge(e,t){t.method==="reflink"||t.method==="link"?e.reflinkedBytes+=t.bytes:e.fallbackCopiedBytes+=t.bytes}function St(e,t){if(!Number.isSafeInteger(t)||t<0)throw new Error("incremental write bytes must be a non-negative integer");e.incrementalWrittenBytes=(e.incrementalWrittenBytes??0)+t}import Dc from"better-sqlite3";import{execFileSync as Mc}from"child_process";import{existsSync as Nc,readdirSync as jc}from"fs";import{extname as Rt,join as Bc}from"path";function me(e={}){return{id:"auxiliary-documents",facts:["auxiliary-document"],run:t=>Hi({projectRoot:t.projectRoot,dbPath:t.dbPath,extensions:e.extensions,onStatus:t.onStatus})}}function Hi(e){let t=new Set((e.extensions??Lr).map(o=>o.toLowerCase()));if(t.size===0)return{scanned:0,inserted:0,existing:0};if(!Nc(e.dbPath))throw new Error(`SCIP SQLite database not found at ${e.dbPath}`);let n=ui(e.projectRoot),r=$c(e.projectRoot,t).filter(o=>!n.isIgnored(o)),i=new Dc(e.dbPath);try{let o=Uc(i,r),a=i.prepare(`INSERT OR IGNORE INTO documents (language, relative_path, position_encoding, text)
|
|
8
|
-
VALUES (?, ?, NULL, ?)`),c=i.transaction(l=>{let p=0;for(let d of l){if(o.has(d))continue;let f=xr(e.projectRoot,d,{inputKind:"auxiliary source file"}),m=a.run(Gc(d),d,f);p+=Number(m.changes)}return p})(r),u={scanned:r.length,inserted:c,existing:r.length-c};return e.onStatus?.(`Augmented SQLite documents with ${c} auxiliary source file${c===1?"":"s"} (${u.existing} already present).`),u}finally{i.close()}}function $c(e,t){let n=Vc(e,t);if(n)return n;let r=[],i=o=>{let a=o?Bc(e,o):e,s;try{s=jc(a,{withFileTypes:!0})}catch{return}for(let c of s){if(Or.has(c.name))continue;let u=o?`${o}/${c.name}`:c.name;if(c.isDirectory()){i(u);continue}t.has(Rt(c.name).toLowerCase())&&r.push(u)}};return i(""),r.sort()}function Vc(e,t){try{return Mc("git",["-C",e,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:26214400,stdio:["ignore","pipe","ignore"],timeout:3e4,killSignal:"SIGKILL"}).split(`
|
|
9
|
-
`).filter(r=>r&&t.has(Rt(r).toLowerCase())).sort()}catch{return null}}function Uc(e,t){let n=new Set,r=500;for(let i=0;i<t.length;i+=r){let o=t.slice(i,i+r),a=e.prepare(`SELECT relative_path FROM documents WHERE relative_path IN (${o.map(()=>"?").join(",")})`).all(...o);for(let s of a)n.add(s.relative_path)}return n}function Gc(e){return Rt(e).toLowerCase()===".vue"?"vue":Rt(e).replace(/^\./,"").toLowerCase()||"source"}import{dirname as Wc,join as qc}from"path";function Ji(e={}){return{id:"runtime-boundaries",facts:["runtime-boundary-observation","runtime-boundary-link"],run:async({projectRoot:t,dbPath:n,onStatus:r})=>{let i=new G({projectRoot:t,dbPath:n,indexPath:e.indexPath??qc(Wc(n),"index.scip"),...e.evidenceDbPath?{evidenceDbPath:e.evidenceDbPath}:{}}),o,a=!1,s=!1;try{let u=e.reuseExisting||e.affectedFiles?Ur(i):null;e.reuseExisting&&u?.extractorVersion===Br?(o=u,a=!0):(o=await $r(i,{...u?{previousGraph:u}:{},...e.affectedFiles?{affectedFiles:e.affectedFiles}:{},...e.forceDerivedRebuild?{forceDerivedRebuild:!0}:{},profileSpan:w}),s=(o.coverage.filesReused??0)>0)}finally{i.close()}a||Vr(n,o);let c={reused:a,incrementallyUpdated:s,observations:o.observations.length,links:o.links.length,frontiers:o.frontiers.length,filesScanned:o.coverage.filesScanned,errors:o.coverage.extractionErrors.length,phases:o.coverage.phases};return r?.(c.reused?`Reused ${c.observations} cached runtime-boundary observation(s) and ${c.links} link(s).`:c.incrementallyUpdated?`Incrementally refreshed runtime-boundary observations (${c.filesScanned-(o.coverage.filesReused??0)} file(s) extracted, ${o.coverage.filesReused??0} reused) and rebuilt ${c.links} link(s).`:`Extracted ${c.observations} runtime-boundary observation(s), ${c.links} link(s), and ${c.frontiers} unresolved frontier(s).`),!a&&o.coverage.phases&&r?.(`Runtime-boundary phases: ${o.coverage.phases.map(u=>`${u.id} ${u.durationMs.toFixed(0)}ms`).join(", ")}.`),c}}}function Ue(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 Ge(e,t,n){let r=e.changes.map(s=>s.path).sort();if(r.length===0&&!e.projectIdentityChanged&&e.uncertainty.length===0)return{mode:"none",changedFiles:r,affectedFiles:[],reasons:[]};let i=new Set(n),o=Ue(e),a=new Set(o.reasons);return r.some(s=>!i.has(s))&&a.add("changed-file-outside-project"),t===null?(a.add("dependency-graph-unavailable"),zi(r,i,a)):a.size>0?zi(r,i,a):{mode:"closure",changedFiles:r,affectedFiles:Hc(r,t,i),reasons:[]}}function zi(e,t,n){return{mode:"full-project",changedFiles:e,affectedFiles:[...t].sort(),reasons:[...n].sort()}}function Hc(e,t,n){let r=new Map;for(let[a,s]of t)if(n.has(a))for(let c of s){if(!n.has(c))continue;let u=r.get(c)??new Set;u.add(a),r.set(c,u)}let i=new Set(e),o=[...e];for(let a=0;a<o.length;a+=1){let s=o[a];if(s!==void 0)for(let c of r.get(s)??[])i.has(c)||(i.add(c),o.push(c))}return[...i].sort()}import{createHash as su}from"crypto";import{existsSync as cu}from"fs";import{dirname as uu,join as Zi}from"path";import{appendFileSync as Jc,existsSync as zc,mkdirSync as Yc,renameSync as Xc,rmSync as Kc,statSync as Qc,truncateSync as Zc}from"fs";import{basename as eu,dirname as tu}from"path";var Ce=".previous",nu=".rotation.lock",ru=2e3,hn=class extends Error{constructor(n,r){super(`Timed out after ${r}ms waiting for rotating JSONL lock: ${n}`);this.lockPath=n;this.timeoutMs=r;this.name="RotatingJsonlLockTimeoutError"}lockPath;timeoutMs;code="ROTATING_JSONL_LOCK_TIMEOUT"},yn=class extends Error{constructor(n){super(`Rotating JSONL lock ownership changed before release: ${n}`);this.lockPath=n;this.name="RotatingJsonlLockReleaseError"}lockPath;code="ROTATING_JSONL_LOCK_RELEASE_FAILED"},Yi=Object.freeze({monotonicNow:C,wait(e){Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,e)},tryAcquireLock(e,t){let n=ct(e,{kind:"rotating-jsonl",detail:{target:eu(t)}});return n.kind==="acquired"?{kind:"acquired",lock:n.lock}:{kind:"contended"}},makeDirectory(e){Yc(e,{recursive:!0})},exists:zc,readBytes(e){return K(e,{maxBytes:Ke,inputKind:"rotating JSONL segment"})},size(e){return Qc(e).size},truncate:Zc,remove(e){Kc(e,{force:!0})},rename:Xc,append:Jc});function xt(e,t,n){let r=n.runtime??Yi,i=JSON.stringify(t);if(i===void 0)throw new TypeError("Rotating JSONL records must be JSON-serializable values.");let o=Buffer.from(`${i}
|
|
10
|
-
`),a=Math.max(1,Math.floor(n.maxSegmentBytes),o.length);return Ki(e,n.lockTimeoutMs,r,()=>{r.makeDirectory(tu(e));let s=iu(e,Ke,r);n.onPhase?.("tail-repaired");let c=`${e}${n.previousSuffix??Ce}`,u=!1,l=!1;return r.exists(e)&&r.size(e)+o.length>a&&(r.exists(c)&&(r.remove(c),l=!0),n.onPhase?.("previous-pruned"),r.rename(e,c),u=!0,n.onPhase?.("current-rotated")),r.append(e,o),n.onPhase?.("record-appended"),{lineBytes:o.length,segmentLimitBytes:a,repairedTailBytes:s,rotated:u,prunedPrevious:l}})}function Xi(e,t={}){let n=t.runtime??Yi,r=ou(t.maxSegmentBytes);return Ki(e,t.lockTimeoutMs,n,()=>{let i=[],o=0,a=`${e}${t.previousSuffix??Ce}`;for(let s of[a,e]){if(!n.exists(s))continue;let c=au(Qi(s,r,n));i.push(...c.lines),o+=c.partialTailBytes}return{lines:i,ignoredPartialTailBytes:o}})}function Ki(e,t,n,r){let i=`${e}${nu}`,o=Math.max(0,t??ru),a=n.monotonicNow()+o,s;for(;;){let d=n.tryAcquireLock(i,e);if(d.kind==="acquired"){s=d.lock;break}let f=a-n.monotonicNow();if(f<=0)throw new hn(i,o);n.wait(Math.min(5,f))}let c=!1,u,l;try{l=r()}catch(d){c=!0,u=d}let p=!1;try{p=s.release()}catch(d){if(!c)throw d}if(c)throw u;if(!p)throw new yn(i);return l}function iu(e,t,n){if(!n.exists(e))return 0;let r=Qi(e,t,n);if(r.length===0||r[r.length-1]===10)return 0;let i=r.lastIndexOf(10),o=i<0?0:i+1;return n.truncate(e,o),r.length-o}function ou(e){let t=e??Ke;if(!Number.isSafeInteger(t)||t<=0)throw new RangeError(`maxSegmentBytes must be a positive safe integer; received ${t}`);return t}function Qi(e,t,n){let r=n.size(e);if(r>t)throw new Yt("rotating JSONL segment",e,"too-large",r,t);let i=n.readBytes(e),o=n.size(e);if(o!==r||i.byteLength!==r)throw new Yt("rotating JSONL segment",e,"changed-during-read",o,t);return i}function au(e){let t=e.lastIndexOf(10),n=t<0?0:t+1;return{lines:e.subarray(0,n).toString("utf8").split(`
|
|
11
|
-
`).filter(i=>i.length>0),partialTailBytes:e.length-n}}var lu="<global-symbols>";function du(e){let t=[];for(let n of e.all(`
|
|
12
|
-
SELECT relative_path, language, position_encoding, text
|
|
13
|
-
FROM documents
|
|
14
|
-
`))t.push({relativePath:n.relative_path,kind:"document",values:[n.language,n.position_encoding,n.text]});for(let n of e.all(`
|
|
15
|
-
SELECT d.relative_path,
|
|
16
|
-
c.chunk_index,
|
|
17
|
-
c.start_line,
|
|
18
|
-
c.end_line,
|
|
19
|
-
hex(c.occurrences) AS occurrences_hex
|
|
20
|
-
FROM chunks c
|
|
21
|
-
JOIN documents d ON d.id = c.document_id
|
|
22
|
-
`))t.push({relativePath:n.relative_path,kind:"chunk",values:[n.chunk_index,n.start_line,n.end_line,n.occurrences_hex]});for(let n of e.all(`
|
|
23
|
-
SELECT d.relative_path,
|
|
24
|
-
r.start_line,
|
|
25
|
-
r.start_char,
|
|
26
|
-
r.end_line,
|
|
27
|
-
r.end_char,
|
|
28
|
-
g.symbol,
|
|
29
|
-
g.display_name,
|
|
30
|
-
g.kind,
|
|
31
|
-
g.documentation,
|
|
32
|
-
CASE WHEN g.signature IS NULL THEN NULL ELSE hex(g.signature) END AS signature_hex,
|
|
33
|
-
g.enclosing_symbol,
|
|
34
|
-
CASE WHEN g.relationships IS NULL THEN NULL ELSE hex(g.relationships) END AS relationships_hex
|
|
35
|
-
FROM defn_enclosing_ranges r
|
|
36
|
-
JOIN documents d ON d.id = r.document_id
|
|
37
|
-
JOIN global_symbols g ON g.id = r.symbol_id
|
|
38
|
-
`))t.push({relativePath:n.relative_path,kind:"definition",values:bn(n,[n.start_line,n.start_char,n.end_line,n.end_char])});for(let n of e.all(`
|
|
39
|
-
SELECT d.relative_path,
|
|
40
|
-
c.chunk_index,
|
|
41
|
-
m.role,
|
|
42
|
-
g.symbol,
|
|
43
|
-
g.display_name,
|
|
44
|
-
g.kind,
|
|
45
|
-
g.documentation,
|
|
46
|
-
CASE WHEN g.signature IS NULL THEN NULL ELSE hex(g.signature) END AS signature_hex,
|
|
47
|
-
g.enclosing_symbol,
|
|
48
|
-
CASE WHEN g.relationships IS NULL THEN NULL ELSE hex(g.relationships) END AS relationships_hex
|
|
49
|
-
FROM mentions m
|
|
50
|
-
JOIN chunks c ON c.id = m.chunk_id
|
|
51
|
-
JOIN documents d ON d.id = c.document_id
|
|
52
|
-
JOIN global_symbols g ON g.id = m.symbol_id
|
|
53
|
-
`))t.push({relativePath:n.relative_path,kind:"mention",values:bn(n,[n.chunk_index,n.role])});for(let n of e.all(`
|
|
54
|
-
SELECT g.symbol,
|
|
55
|
-
g.display_name,
|
|
56
|
-
g.kind,
|
|
57
|
-
g.documentation,
|
|
58
|
-
CASE WHEN g.signature IS NULL THEN NULL ELSE hex(g.signature) END AS signature_hex,
|
|
59
|
-
g.enclosing_symbol,
|
|
60
|
-
CASE WHEN g.relationships IS NULL THEN NULL ELSE hex(g.relationships) END AS relationships_hex
|
|
61
|
-
FROM global_symbols g
|
|
62
|
-
WHERE NOT EXISTS (
|
|
63
|
-
SELECT 1 FROM defn_enclosing_ranges r WHERE r.symbol_id = g.id
|
|
64
|
-
) AND NOT EXISTS (
|
|
65
|
-
SELECT 1 FROM mentions m WHERE m.symbol_id = g.id
|
|
66
|
-
)
|
|
67
|
-
`))t.push({relativePath:lu,kind:"global-symbol",values:bn(n)});return pu(t)}function pu(e){let t=new Map;for(let r of e){let i=JSON.stringify([r.kind,r.values]),o=t.get(r.relativePath)??[];o.push(i),t.set(r.relativePath,o)}let n=new Map;for(let[r,i]of[...t].sort(([o],[a])=>o.localeCompare(a))){let o=su("sha256");for(let a of i.sort())o.update(String(Buffer.byteLength(a))),o.update(":"),o.update(a),o.update(`
|
|
68
|
-
`);n.set(r,o.digest("hex"))}return n}function fu(e,t){let n=[],r=[],i=[],o=[],a=new Set([...e.keys(),...t.keys()]);for(let s of[...a].sort()){let c=e.get(s),u=t.get(s);c===void 0?n.push(s):u===void 0?i.push(s):c!==u?r.push(s):o.push(s)}return{addedFiles:n,modifiedFiles:r,deletedFiles:i,changedFiles:[...n,...r,...i].sort(),unchangedFiles:o}}function Sn(e,t,n){let r=new Set(e.affectedFiles),i=new Set(t.changedFiles),o=e.mode==="full-project"?[]:t.changedFiles.filter(c=>!r.has(c)),a=e.affectedFiles.filter(c=>!i.has(c)).sort(),s=t.changedFiles.length-o.length;return{passed:o.length===0,recall:t.changedFiles.length===0?1:s/t.changedFiles.length,affectedRatio:n===0?0:e.affectedFiles.length/n,predictedFiles:[...e.affectedFiles].sort(),actualFiles:[...t.changedFiles],missingFiles:o,extraFiles:a}}function Rn(e,t=bu){let n=t.wallNow===void 0&&t.monotonicNow===void 0,r=t.monotonicNow??t.now,i=t.wallNow??t.now,o=r(),a=(u,l)=>{let p=r();return ao(e.refreshResult,u,n?p:i(),Math.max(0,p-o),l)};if(!t.databaseExists(e.previousDbPath))return a("prior-index-unavailable");if(!t.databaseExists(e.candidateDbPath))return a("candidate-index-unavailable");if(e.refreshResult==="rebuilt"&&X(e.previousSnapshot,e.currentSnapshot).changes.length===0)return a("no-input-changes");let s=null,c=null;try{s=t.openDatabase(e.projectRoot,e.previousDbPath,e.previousIndexPath),c=t.openDatabase(e.projectRoot,e.candidateDbPath,e.candidateIndexPath);let u=[...new Set([...t.indexedPaths(s),...t.indexedPaths(c)])].sort(),l=X(e.previousSnapshot,e.currentSnapshot),p=new Set(u),d=l.changes.length>0&&!Ue(l).fullProject&&l.changes.every(E=>p.has(E.path)),f=Ge(l,d?t.dependencyGraph(s):new Map,u),m=fu(t.factDigests(s),t.factDigests(c)),y=r();return{version:1,status:"evaluated",refreshResult:e.refreshResult,recordedAt:new Date(n?y:i()).toISOString(),durationMs:Math.max(0,y-o),manifest:l,plan:f,comparison:m,evaluation:Sn(f,m,u.length)}}catch(u){return a("oracle-error",u instanceof Error?u.message:String(u))}finally{eo(s),eo(c)}}function ro(e,t,n,r=Date.now()){return ao(e,t,r,0,n)}function io(e){let t=uu(e);return{latestPath:Zi(t,"affected-shadow-latest.json"),historyPath:Zi(t,"affected-shadow.jsonl")}}function vm(e,t=n=>Qe(n,"affected-shadow source file")){let n=io(e),r;try{r=JSON.parse(t(n.latestPath))}catch(T){let v=Pu(T),F=v?"telemetry-missing":vu(T);return te(n,F,v?void 0:T instanceof Error?T.message:String(T))}if(ue(r)&&typeof r.version=="number"&&r.version!==1)return te(n,"unsupported-record-version",`Unsupported version ${r.version}.`);if(!Ru(r))return te(n,"telemetry-malformed");if(r.status==="unavailable")return xu(r.reason)?{state:"unavailable",...n,reason:r.reason,recordedAt:r.recordedAt,refreshResult:r.refreshResult,durationMs:r.durationMs,...typeof r.error=="string"?{error:r.error}:{}}:te(n,"telemetry-malformed");if(r.status!=="evaluated")return te(n,"telemetry-malformed");let i=r.plan,o=r.comparison,a=r.evaluation;if(!ue(r.manifest)||!ue(i)||!ue(o)||!ue(a))return te(n,"telemetry-malformed");let s=i.mode,c=le(i.affectedFiles),u=le(i.reasons),l=le(o.changedFiles),p=le(a.predictedFiles),d=le(a.actualFiles),f=le(a.missingFiles),m=a.recall,y=a.affectedRatio;if(s!=="none"&&s!=="closure"&&s!=="full-project"||c===null||u===null||l===null||p===null||d===null||f===null||typeof a.passed!="boolean"||!to(m)||!to(y))return te(n,"telemetry-malformed");let E=d.length===0?1:(d.length-f.length)/d.length;return!no(c,p)||!no(l,d)||a.passed!==(f.length===0)||Math.abs(m-E)>Number.EPSILON||f.some(T=>!d.includes(T)||p.includes(T))?te(n,"telemetry-malformed"):{state:a.passed?"passing":"failing",...n,recordedAt:r.recordedAt,refreshResult:r.refreshResult,durationMs:r.durationMs,mode:s,recall:m,affectedRatio:y,predictedFiles:p,actualFiles:d,missingFiles:f,fallbackReasons:u}}function Pm(e){if(e.state==="unavailable")return`unavailable (${e.reason})`;let t=e.missingFiles.length>0?`, ${e.missingFiles.length} missed`:"",n=e.fallbackReasons.length>0?`; fallback: ${e.fallbackReasons.join(", ")}`:"";return`${e.state}, ${(e.recall*100).toFixed(1)}% recall, ${e.predictedFiles.length} predicted / ${e.actualFiles.length} changed, ${(e.affectedRatio*100).toFixed(1)}% of project${t}${n}`}function oo(e,t,n=Su){let r=io(e);return n.appendHistory(r.historyPath,t),n.writeLatest(r.latestPath,t),r}var gu=8*1024*1024,mu=Ce;function hu(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 yu(e,t,n=gu){xt(e,hu(t),{maxSegmentBytes:n,previousSuffix:mu})}function bn(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 bu={now:()=>Date.now(),wallNow:()=>Date.now(),monotonicNow:C,databaseExists:e=>cu(e),openDatabase:(e,t,n)=>new G({projectRoot:e,dbPath:t,indexPath:n}),indexedPaths:e=>nt(e),dependencyGraph:e=>Dr(e),factDigests:e=>du(e)},Su={appendHistory:yu,writeLatest:(e,t)=>at(e,t,{spacing:2,trailingNewline:!0})};function ao(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 eo(e){try{e?.close()}catch{}}function Ru(e){return ue(e)&&e.version===1&&typeof e.recordedAt=="string"&&(e.refreshResult==="rebuilt"||e.refreshResult==="reused")&&typeof e.durationMs=="number"&&Number.isFinite(e.durationMs)&&e.durationMs>=0}function xu(e){return e==="prior-index-unavailable"||e==="candidate-index-unavailable"||e==="no-input-changes"||e==="oracle-error"}function to(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=1}function no(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function te(e,t,n){return{state:"unavailable",...e,reason:t,...n?{error:n}:{}}}function vu(e){return e instanceof SyntaxError?"telemetry-malformed":"telemetry-unreadable"}function Pu(e){return e instanceof Error&&e.code==="ENOENT"}import{readdirSync as Eu}from"fs";import{isAbsolute as so,join as Iu,resolve as wu}from"path";var vt="@sourcegraph/scip-typescript@0.4.0",co="scip-python-plus@0.7.5",uo="github.com/sourcegraph/scip-go@v0.2.7",lo="scip-dotnet@0.2.14",Tu="scip_dart@1.6.2",ku={typescript:{language:"typescript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,pnpmWorkspaces:t,indexerBinary:n,projectPath:r})=>r?{binary:n,args:["index","--output",e,"--no-progress-bar","--no-global-caches",r]}:t?{binary:n,args:["index","--pnpm-workspaces","--output",e,"--no-progress-bar","--no-global-caches"]}:{binary:n,args:["index","--output",e,"--no-progress-bar","--no-global-caches"]},markerFiles:[...N.typescript],installMethods:[{label:"npm",identity:vt,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",vt]}],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","--output",e,"--no-progress-bar","--no-global-caches"]}),markerFiles:[...N.javascript],installMethods:[{label:"npm",identity:vt,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",vt]}],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:[...N.java],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:[...N.scala],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:[...N.kotlin],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},rust:{language:Ie.language,indexerBinary:Ie.indexerBinary,checkCommand:`${Ie.indexerBinary} --version`,indexArgs:({outputPath:e})=>({binary:Ie.indexerBinary,args:["scip",".","--output",e]}),markerFiles:[...N.rust],installMethods:[],installUrl:Ie.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:[...N.python],installMethods:[{label:"npm",identity:co,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",co]}],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",so(r)?r:wu(e,r)),{binary:n,args:i}},markerFiles:[...N.clojure],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:[...N.ruby],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:[...N.go],installMethods:[{label:"go install",identity:uo,destination:"Go bin directory (GOBIN or GOPATH/bin)",prerequisite:"go",binary:"go",args:["install",uo]}],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:[...N.cpp],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:[...N.c],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",po(e,[".sln",".csproj"])??e,"--output",t,"--working-directory",e]}),markerFiles:[...N.csharp],installMethods:[{label:"dotnet",identity:lo,destination:"dotnet global tool directory",prerequisite:"dotnet",binary:"dotnet",args:["tool","install","--global","scip-dotnet","--version","0.2.14"]}],installUrl:"https://github.com/sourcegraph/scip-dotnet/releases"},vb:{language:"vb",indexerBinary:"scip-dotnet",checkCommand:"scip-dotnet --version",indexArgs:({projectRoot:e,outputPath:t})=>({binary:"scip-dotnet",args:["index",po(e,[".sln",".vbproj"])??e,"--output",t,"--working-directory",e]}),markerFiles:[...N.vb],installMethods:[{label:"dotnet",identity:lo,destination:"dotnet global tool directory",prerequisite:"dotnet",binary:"dotnet",args:["tool","install","--global","scip-dotnet","--version","0.2.14"]}],installUrl:"https://github.com/sourcegraph/scip-dotnet/releases"},dart:{language:"dart",indexerBinary:"scip-dart",checkCommand:"scip-dart --version",indexArgs:({indexerBinary:e,outputPath:t})=>({binary:e,args:["--output",t]}),markerFiles:[...N.dart],installMethods:[{label:"dart pub",identity:Tu,destination:"Dart pub global cache",prerequisite:"dart",binary:"dart",args:["pub","global","activate","scip_dart","1.6.2"]}],installUrl:"https://github.com/Workiva/scip-dart/releases"},php:{language:"php",indexerBinary:"scip-php",projectLocalBinaries:["vendor/davidrjenni/scip-php/bin/scip-php","vendor/bin/scip-php"],checkCommand:"scip-php --version",indexArgs:({indexerBinary:e})=>so(e)?{binary:"php",args:["-d","error_reporting=E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED",e]}:{binary:e,args:[]},defaultOutputPath:"index.scip",markerFiles:[...N.php],installMethods:[],installUrl:"https://github.com/davidrjenni/scip-php/releases"}};function fo(e){if(!(e.projectPath||e.pnpmWorkspaces)){if(e.language==="typescript")return"{}";if(e.language==="javascript")return'{"compilerOptions":{"allowJs":true}}'}}function xn(e){return ku[e]}function po(e,t){let n;try{n=Eu(e)}catch{return null}for(let r of t)for(let i of n)if(i.endsWith(r))return Iu(e,i);return null}import{createHash as _u}from"crypto";import{existsSync as Pn,rmSync as go,statSync as Cu}from"fs";import{resolve as Au}from"path";import yo from"better-sqlite3";var Fu={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}]},Lu={idx_chunks_line_range:{table:"chunks",columns:["document_id","start_line","end_line"]},idx_defn_enclosing_ranges_document:{table:"defn_enclosing_ranges",columns:["document_id","start_line","end_line"]},idx_defn_enclosing_ranges_symbol_id:{table:"defn_enclosing_ranges",columns:["symbol_id"]},idx_mentions_symbol_id_role:{table:"mentions",columns:["symbol_id","role"]}};function bo(e){let t=C(),n=mo(e.affectedFiles),r=mo(e.deletedFiles??[],!0),i=new Set(n);if(r.some(s=>!i.has(s)))throw new Error("deleted incremental documents must be included in the affected document set");let o=n.length-r.length;if(Du(e.previousDbPath,e.miniDbPath,e.candidateDbPath),!Pn(e.previousDbPath))throw new Error("previous SQLite generation is unavailable");if(!Pn(e.miniDbPath))throw new Error("incremental SQLite mini database is unavailable");w("reindex.publish.sqlite-patch.validate-inputs",()=>{vn(e.previousDbPath,"previous SQLite generation",!1),vn(e.miniDbPath,"incremental SQLite mini database")}),e.reuseCandidate?w("reindex.publish.sqlite-patch.reuse-candidate",()=>vn(e.candidateDbPath,"incremental SQLite candidate",!1)):w("reindex.publish.sqlite-patch.clone",()=>{go(e.candidateDbPath,{force:!0});let s=fe(e.previousDbPath,e.candidateDbPath);e.writeTelemetry&&ge(e.writeTelemetry,s)});let a=null;try{a=w("reindex.publish.sqlite-patch.open",()=>{let f=new yo(e.candidateDbPath,{fileMustExist:!0});return f.pragma("busy_timeout = 5000"),f.pragma("foreign_keys = ON"),f.prepare("ATTACH DATABASE ? AS incremental").run(e.miniDbPath),En(f,"main","candidate SQLite generation"),En(f,"incremental","incremental SQLite mini database"),f});let{priorAffectedCount:s,previousFactDigests:c}=w("reindex.publish.sqlite-patch.prepare",()=>(ju(a,n,r),{...Bu(a,n.length,r.length),previousFactDigests:In(a,"main",!0)})),u=ne(a,"SELECT COUNT(*) AS value FROM main.documents"),l=a.transaction(()=>{w("reindex.publish.sqlite-patch.transaction.symbol-ownership",()=>$u(a)),w("reindex.publish.sqlite-patch.transaction.shared-definitions",()=>Vu(a)),w("reindex.publish.sqlite-patch.transaction.delete",()=>Uu(a)),e.onStage?.("after-delete"),w("reindex.publish.sqlite-patch.transaction.reconcile-symbols",()=>Gu(a)),e.onStage?.("after-symbol-reconciliation"),w("reindex.publish.sqlite-patch.transaction.insert",()=>Wu(a)),e.onStage?.("after-insert"),w("reindex.publish.sqlite-patch.transaction.prune-symbols",()=>qu(a,e.trustedPriorGeneration===!0)),w("reindex.publish.sqlite-patch.transaction.validate",()=>Hu(a,o,u,s)),e.onStage?.("before-commit")});w("reindex.publish.sqlite-patch.transaction",()=>l.immediate()),e.writeTelemetry&&St(e.writeTelemetry,2*Ou(e.candidateDbPath)),w("reindex.publish.sqlite-patch.integrity",()=>Nu(a,"candidate SQLite generation",!e.deferIntegrity&&e.trustedPriorGeneration!==!0));let p=w("reindex.publish.sqlite-patch.validate-facts",()=>Ju(a)),d=[...new Set([...c.keys(),...p.keys()])].filter(f=>c.get(f)!==p.get(f)).sort();return a.exec("DETACH DATABASE incremental"),a.close(),a=null,{candidateDbPath:e.candidateDbPath,affectedDocumentCount:n.length,changedDocumentPaths:d,durationMs:C()-t}}catch(s){try{a?.close()}finally{go(e.candidateDbPath,{force:!0})}throw new Error(`Incremental SQLite publication rejected: ${s instanceof Error?s.message:String(s)}`,{cause:s})}}function Ou(e){let t=0;for(let n of["-wal","-journal"]){let r=`${e}${n}`;Pn(r)&&(t+=Cu(r).size)}return t}function mo(e,t=!1){if(!t&&e.length===0)throw new Error("incremental SQLite publication requires affected documents");let n=[...e].sort();for(let r of n)if(!r||r.startsWith("/")||r.includes("\\")||r.split("/").includes(".."))throw new Error(`invalid affected document path: ${r}`);if(new Set(n).size!==n.length)throw new Error("incremental SQLite publication contains duplicate affected documents");return n}function Du(e,t,n){let r=[e,t,n].map(i=>Au(i));if(new Set(r).size!==r.length)throw new Error("previous, mini, and candidate SQLite paths must be distinct")}function vn(e,t,n=!0){let r=new yo(e,{readonly:!0,fileMustExist:!0});try{En(r,"main",t),n&&Mu(r,"main",t)}finally{r.close()}}function En(e,t,n){for(let[r,i]of Object.entries(Fu)){let a=e.prepare(`PRAGMA ${t}.table_info('${r}')`).all().map(({name:s,type:c,notnull:u,pk:l})=>({name:s,type:c.toUpperCase(),notnull:u,pk:l}));if(JSON.stringify(a)!==JSON.stringify(i))throw new Error(`${n} schema changed for table ${r}`)}for(let[r,i]of Object.entries(Lu)){let o=e.prepare(`SELECT tbl_name FROM ${t}.sqlite_master WHERE type = 'index' AND name = ?`).get(r),a=e.prepare(`PRAGMA ${t}.index_info('${r}')`).all().map(s=>s.name);if(o?.tbl_name!==i.table||JSON.stringify(a)!==JSON.stringify(i.columns))throw new Error(`${n} schema changed for index ${r}`)}ho(e,t,"documents",["relative_path"],n),ho(e,t,"global_symbols",["symbol"],n)}function ho(e,t,n,r,i){if(!e.prepare(`PRAGMA ${t}.index_list('${n}')`).all().some(s=>{if(s.unique!==1)return!1;let c=e.prepare(`PRAGMA ${t}.index_info('${s.name}')`).all().map(u=>u.name);return JSON.stringify(c)===JSON.stringify(r)}))throw new Error(`${i} lost the unique ${n}(${r.join(", ")}) constraint`)}function Mu(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 Nu(e,t,n){if(e.pragma("foreign_keys",{simple:!0})!==1)throw new Error(`${t} lost foreign-key enforcement`);if(!n)return;let r=e.prepare("PRAGMA main.quick_check").pluck().get();if(r!=="ok")throw new Error(`${t} failed quick_check: ${String(r)}`)}function ju(e,t,n){e.exec("CREATE TEMP TABLE incremental_affected_paths (relative_path TEXT PRIMARY KEY) WITHOUT ROWID"),e.exec("CREATE TEMP TABLE incremental_deleted_paths (relative_path TEXT PRIMARY KEY) WITHOUT ROWID");let r=e.prepare("INSERT INTO temp.incremental_affected_paths(relative_path) VALUES (?)"),i=e.prepare("INSERT INTO temp.incremental_deleted_paths(relative_path) VALUES (?)");e.transaction(a=>{for(let s of a)r.run(s);for(let s of n)i.run(s)})(t)}function Bu(e,t,n){let r=ne(e,"SELECT COUNT(*) AS value FROM incremental.documents"),i=ne(e,`SELECT COUNT(*) AS value
|
|
69
|
-
FROM main.documents d
|
|
70
|
-
JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path`),o=e.prepare(`SELECT p.relative_path
|
|
71
|
-
FROM temp.incremental_affected_paths p
|
|
72
|
-
LEFT JOIN incremental.documents d ON d.relative_path = p.relative_path
|
|
73
|
-
LEFT JOIN temp.incremental_deleted_paths deleted ON deleted.relative_path = p.relative_path
|
|
74
|
-
WHERE d.id IS NULL AND deleted.relative_path IS NULL
|
|
75
|
-
LIMIT 1`).pluck().get(),a=e.prepare(`SELECT d.relative_path
|
|
76
|
-
FROM incremental.documents d
|
|
77
|
-
LEFT JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path
|
|
78
|
-
WHERE p.relative_path IS NULL
|
|
79
|
-
LIMIT 1`).pluck().get(),s=e.prepare(`SELECT d.relative_path
|
|
80
|
-
FROM incremental.documents d
|
|
81
|
-
JOIN temp.incremental_deleted_paths deleted ON deleted.relative_path = d.relative_path
|
|
82
|
-
LIMIT 1`).pluck().get();if(r!==t-n||o!==void 0||a!==void 0||s!==void 0)throw new Error("incremental SQLite mini database does not exactly match the affected document set");return{priorAffectedCount:i}}function $u(e){e.exec(`
|
|
83
|
-
CREATE TEMP TABLE incremental_old_defined_symbols (symbol TEXT PRIMARY KEY) WITHOUT ROWID;
|
|
84
|
-
INSERT OR IGNORE INTO temp.incremental_old_defined_symbols(symbol)
|
|
85
|
-
SELECT g.symbol
|
|
86
|
-
FROM temp.incremental_affected_paths p
|
|
87
|
-
CROSS JOIN main.documents d ON d.relative_path = p.relative_path
|
|
88
|
-
CROSS JOIN main.defn_enclosing_ranges r ON r.document_id = d.id
|
|
89
|
-
CROSS JOIN main.global_symbols g ON g.id = r.symbol_id;
|
|
90
|
-
INSERT OR IGNORE INTO temp.incremental_old_defined_symbols(symbol)
|
|
91
|
-
SELECT g.symbol
|
|
92
|
-
FROM temp.incremental_affected_paths p
|
|
93
|
-
CROSS JOIN main.documents d ON d.relative_path = p.relative_path
|
|
94
|
-
CROSS JOIN main.chunks c ON c.document_id = d.id
|
|
95
|
-
CROSS JOIN main.mentions m ON m.chunk_id = c.id
|
|
96
|
-
CROSS JOIN main.global_symbols g ON g.id = m.symbol_id
|
|
97
|
-
WHERE m.role = 1;
|
|
98
|
-
|
|
99
|
-
CREATE TEMP TABLE incremental_new_defined_symbols (symbol TEXT PRIMARY KEY) WITHOUT ROWID;
|
|
100
|
-
INSERT OR IGNORE INTO temp.incremental_new_defined_symbols(symbol)
|
|
101
|
-
SELECT g.symbol
|
|
102
|
-
FROM incremental.defn_enclosing_ranges r
|
|
103
|
-
JOIN incremental.global_symbols g ON g.id = r.symbol_id;
|
|
104
|
-
INSERT OR IGNORE INTO temp.incremental_new_defined_symbols(symbol)
|
|
105
|
-
SELECT g.symbol
|
|
106
|
-
FROM incremental.mentions m
|
|
107
|
-
JOIN incremental.global_symbols g ON g.id = m.symbol_id
|
|
108
|
-
WHERE m.role = 1;
|
|
109
|
-
|
|
110
|
-
CREATE TEMP TABLE incremental_touched_symbols (symbol TEXT PRIMARY KEY) WITHOUT ROWID;
|
|
111
|
-
INSERT OR IGNORE INTO temp.incremental_touched_symbols(symbol)
|
|
112
|
-
SELECT symbol FROM temp.incremental_old_defined_symbols;
|
|
113
|
-
INSERT OR IGNORE INTO temp.incremental_touched_symbols(symbol)
|
|
114
|
-
SELECT g.symbol
|
|
115
|
-
FROM temp.incremental_affected_paths p
|
|
116
|
-
CROSS JOIN main.documents d ON d.relative_path = p.relative_path
|
|
117
|
-
CROSS JOIN main.chunks c ON c.document_id = d.id
|
|
118
|
-
CROSS JOIN main.mentions m ON m.chunk_id = c.id
|
|
119
|
-
CROSS JOIN main.global_symbols g ON g.id = m.symbol_id;
|
|
120
|
-
INSERT OR IGNORE INTO temp.incremental_touched_symbols(symbol)
|
|
121
|
-
SELECT symbol FROM incremental.global_symbols;
|
|
122
|
-
`)}function Vu(e){let t=e.prepare(`WITH changed_symbols AS (
|
|
123
|
-
SELECT symbol FROM temp.incremental_old_defined_symbols
|
|
124
|
-
UNION
|
|
125
|
-
SELECT symbol FROM temp.incremental_new_defined_symbols
|
|
126
|
-
)
|
|
127
|
-
SELECT c.symbol
|
|
128
|
-
FROM changed_symbols c
|
|
129
|
-
CROSS JOIN main.global_symbols g ON g.symbol = c.symbol
|
|
130
|
-
WHERE EXISTS (
|
|
131
|
-
SELECT 1
|
|
132
|
-
FROM main.defn_enclosing_ranges r
|
|
133
|
-
JOIN main.documents d ON d.id = r.document_id
|
|
134
|
-
LEFT JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path
|
|
135
|
-
WHERE r.symbol_id = g.id AND p.relative_path IS NULL
|
|
136
|
-
) OR EXISTS (
|
|
137
|
-
SELECT 1
|
|
138
|
-
FROM main.mentions m
|
|
139
|
-
JOIN main.chunks chunk ON chunk.id = m.chunk_id
|
|
140
|
-
JOIN main.documents d ON d.id = chunk.document_id
|
|
141
|
-
LEFT JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path
|
|
142
|
-
WHERE m.symbol_id = g.id AND m.role = 1 AND p.relative_path IS NULL
|
|
143
|
-
)
|
|
144
|
-
LIMIT 1`).pluck().get();if(typeof t=="string")throw new Error(`symbol definition is shared by affected and unaffected documents: ${t}`)}function Uu(e){e.exec(`
|
|
145
|
-
DELETE FROM main.mentions
|
|
146
|
-
WHERE chunk_id IN (
|
|
147
|
-
SELECT c.id
|
|
148
|
-
FROM main.chunks c
|
|
149
|
-
JOIN main.documents d ON d.id = c.document_id
|
|
150
|
-
JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path
|
|
151
|
-
);
|
|
152
|
-
DELETE FROM main.chunks
|
|
153
|
-
WHERE document_id IN (
|
|
154
|
-
SELECT d.id
|
|
155
|
-
FROM main.documents d
|
|
156
|
-
JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path
|
|
157
|
-
);
|
|
158
|
-
DELETE FROM main.defn_enclosing_ranges
|
|
159
|
-
WHERE document_id IN (
|
|
160
|
-
SELECT d.id
|
|
161
|
-
FROM main.documents d
|
|
162
|
-
JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path
|
|
163
|
-
);
|
|
164
|
-
DELETE FROM main.documents
|
|
165
|
-
WHERE relative_path IN (SELECT relative_path FROM temp.incremental_affected_paths);
|
|
166
|
-
`)}function Gu(e){e.exec(`
|
|
167
|
-
UPDATE main.global_symbols
|
|
168
|
-
SET display_name = NULL,
|
|
169
|
-
kind = NULL,
|
|
170
|
-
documentation = NULL,
|
|
171
|
-
signature = NULL,
|
|
172
|
-
enclosing_symbol = NULL,
|
|
173
|
-
relationships = NULL
|
|
174
|
-
WHERE symbol IN (SELECT symbol FROM temp.incremental_old_defined_symbols);
|
|
175
|
-
|
|
176
|
-
INSERT OR IGNORE INTO main.global_symbols(
|
|
177
|
-
symbol, display_name, kind, documentation, signature, enclosing_symbol, relationships
|
|
178
|
-
)
|
|
179
|
-
SELECT symbol, display_name, kind, documentation, signature, enclosing_symbol, relationships
|
|
180
|
-
FROM incremental.global_symbols;
|
|
181
|
-
|
|
182
|
-
UPDATE main.global_symbols
|
|
183
|
-
SET display_name = (
|
|
184
|
-
SELECT source.display_name FROM incremental.global_symbols source
|
|
185
|
-
WHERE source.symbol = main.global_symbols.symbol
|
|
186
|
-
),
|
|
187
|
-
kind = (
|
|
188
|
-
SELECT source.kind FROM incremental.global_symbols source
|
|
189
|
-
WHERE source.symbol = main.global_symbols.symbol
|
|
190
|
-
),
|
|
191
|
-
documentation = (
|
|
192
|
-
SELECT source.documentation FROM incremental.global_symbols source
|
|
193
|
-
WHERE source.symbol = main.global_symbols.symbol
|
|
194
|
-
),
|
|
195
|
-
signature = (
|
|
196
|
-
SELECT source.signature FROM incremental.global_symbols source
|
|
197
|
-
WHERE source.symbol = main.global_symbols.symbol
|
|
198
|
-
),
|
|
199
|
-
enclosing_symbol = (
|
|
200
|
-
SELECT source.enclosing_symbol FROM incremental.global_symbols source
|
|
201
|
-
WHERE source.symbol = main.global_symbols.symbol
|
|
202
|
-
),
|
|
203
|
-
relationships = (
|
|
204
|
-
SELECT source.relationships FROM incremental.global_symbols source
|
|
205
|
-
WHERE source.symbol = main.global_symbols.symbol
|
|
206
|
-
)
|
|
207
|
-
WHERE symbol IN (SELECT symbol FROM temp.incremental_new_defined_symbols);
|
|
208
|
-
`)}function Wu(e){let t=ne(e,"SELECT COALESCE(MAX(id), 0) AS value FROM main.documents"),n=ne(e,"SELECT COALESCE(MAX(id), 0) AS value FROM main.chunks"),r=ne(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)
|
|
209
|
-
SELECT id + ?, language, relative_path, position_encoding, text
|
|
210
|
-
FROM incremental.documents`).run(t),e.prepare(`INSERT INTO main.chunks(id, document_id, chunk_index, start_line, end_line, occurrences)
|
|
211
|
-
SELECT id + ?, document_id + ?, chunk_index, start_line, end_line, occurrences
|
|
212
|
-
FROM incremental.chunks`).run(n,t),e.prepare(`INSERT INTO main.mentions(chunk_id, symbol_id, role)
|
|
213
|
-
SELECT m.chunk_id + ?, target.id, m.role
|
|
214
|
-
FROM incremental.mentions m
|
|
215
|
-
CROSS JOIN incremental.global_symbols source ON source.id = m.symbol_id
|
|
216
|
-
CROSS JOIN main.global_symbols target ON target.symbol = source.symbol`).run(n),e.prepare(`INSERT INTO main.defn_enclosing_ranges(
|
|
217
|
-
id, document_id, symbol_id, start_line, start_char, end_line, end_char
|
|
218
|
-
)
|
|
219
|
-
SELECT r.id + ?, r.document_id + ?, target.id,
|
|
220
|
-
r.start_line, r.start_char, r.end_line, r.end_char
|
|
221
|
-
FROM incremental.defn_enclosing_ranges r
|
|
222
|
-
CROSS JOIN incremental.global_symbols source ON source.id = r.symbol_id
|
|
223
|
-
CROSS JOIN main.global_symbols target ON target.symbol = source.symbol`).run(r,t)}function qu(e,t){let n=t?"symbol IN (SELECT symbol FROM temp.incremental_touched_symbols) AND":"";e.exec(`
|
|
224
|
-
DELETE FROM main.global_symbols
|
|
225
|
-
WHERE ${n}
|
|
226
|
-
NOT EXISTS (SELECT 1 FROM main.mentions m WHERE m.symbol_id = main.global_symbols.id)
|
|
227
|
-
AND NOT EXISTS (
|
|
228
|
-
SELECT 1 FROM main.defn_enclosing_ranges r WHERE r.symbol_id = main.global_symbols.id
|
|
229
|
-
);
|
|
230
|
-
`)}function Hu(e,t,n,r){let i=ne(e,"SELECT COUNT(*) AS value FROM main.documents"),o=ne(e,`SELECT COUNT(*) AS value
|
|
231
|
-
FROM main.documents d
|
|
232
|
-
JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path`),a=n-r+t;if(i!==a||o!==t)throw new Error("candidate SQLite document counts changed unexpectedly")}function Ju(e){let t=In(e,"main",!0),n=In(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 In(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
|
|
233
|
-
FROM ${t}.documents d
|
|
234
|
-
${r}
|
|
235
|
-
ORDER BY d.relative_path`).all(),o=e.prepare(`SELECT d.relative_path, c.chunk_index, c.start_line, c.end_line, hex(c.occurrences) AS occurrences
|
|
236
|
-
FROM ${t}.chunks c
|
|
237
|
-
JOIN ${t}.documents d ON d.id = c.document_id
|
|
238
|
-
${r}
|
|
239
|
-
ORDER BY d.relative_path, c.chunk_index, c.start_line, c.end_line, c.id`).all(),a=e.prepare(`SELECT d.relative_path, r.start_line, r.start_char, r.end_line, r.end_char,
|
|
240
|
-
g.symbol, g.display_name, g.kind, g.documentation,
|
|
241
|
-
CASE WHEN g.signature IS NULL THEN NULL ELSE hex(g.signature) END AS signature,
|
|
242
|
-
g.enclosing_symbol,
|
|
243
|
-
CASE WHEN g.relationships IS NULL THEN NULL ELSE hex(g.relationships) END AS relationships
|
|
244
|
-
FROM ${t}.defn_enclosing_ranges r
|
|
245
|
-
JOIN ${t}.documents d ON d.id = r.document_id
|
|
246
|
-
JOIN ${t}.global_symbols g ON g.id = r.symbol_id
|
|
247
|
-
${r}
|
|
248
|
-
ORDER BY d.relative_path, r.start_line, r.start_char, r.end_line, r.end_char, g.symbol`).all(),s=e.prepare(`SELECT d.relative_path, c.chunk_index, m.role, g.symbol
|
|
249
|
-
FROM ${t}.mentions m
|
|
250
|
-
JOIN ${t}.chunks c ON c.id = m.chunk_id
|
|
251
|
-
JOIN ${t}.documents d ON d.id = c.document_id
|
|
252
|
-
JOIN ${t}.global_symbols g ON g.id = m.symbol_id
|
|
253
|
-
${r}
|
|
254
|
-
ORDER BY d.relative_path, c.chunk_index, m.role, g.symbol`).all(),c=new Map;for(let[l,p]of Object.entries({documents:i,chunks:o,definitions:a,mentions:s}))for(let d of p){let f=JSON.stringify([l,d]),m=c.get(d.relative_path)??[];m.push(f),c.set(d.relative_path,m)}let u=new Map;for(let[l,p]of[...c].sort(([d],[f])=>d.localeCompare(f))){let d=_u("sha256");for(let f of p.sort())d.update(f).update(`
|
|
255
|
-
`);u.set(l,d.digest("hex"))}return u}function ne(e,t){return e.prepare(t).get().value}import zu from"better-sqlite3";var Pt="idx_mentions_definitions",Yu=["symbol_id","chunk_id"];function wn(e,t={}){let n=new zu(e),r=[],i=[],o=[];try{return n.transaction(()=>{Xu(n,r),Et(n,"idx_global_symbols_symbol")?.join("\0")==="symbol"&&So(n,"global_symbols").some(c=>c.name!=="idx_global_symbols_symbol"&&c.unique&&c.columns.join("\0")==="symbol")?(n.exec('DROP INDEX "idx_global_symbols_symbol"'),i.push("idx_global_symbols_symbol")):Et(n,"idx_global_symbols_symbol")&&o.push("idx_global_symbols_symbol");let a=Et(n,"idx_chunks_doc_id"),s=So(n,"chunks").some(c=>c.name!=="idx_chunks_doc_id"&&c.columns.length>1&&c.columns[0]==="document_id");a?.join("\0")==="document_id"&&s?(n.exec('DROP INDEX "idx_chunks_doc_id"'),i.push("idx_chunks_doc_id")):a&&o.push("idx_chunks_doc_id"),t.analyze!==!1&&n.exec("ANALYZE")})(),{added:r,removed:i,retained:o,analyzed:t.analyze!==!1}}catch(a){if(a.code==="SQLITE_NOTADB")return{added:[],removed:[],retained:[],analyzed:!1,skippedReason:"not-a-sqlite-database"};throw a}finally{n.close()}}function Xu(e,t){let n=Ro(e,Pt);if(n){let r=n.columns.join("\0")===Yu.join("\0"),i=/\bWHERE\s+role\s*=\s*1\b/iu.test(n.sql??"");if(!r||!i||n.table!=="mentions")throw new Error(`${Pt} exists with an incompatible definition`);return}e.exec(`CREATE INDEX "${Pt}" ON mentions(symbol_id, chunk_id) WHERE role = 1`),t.push(Pt)}function So(e,t){return e.prepare(`PRAGMA index_list('${t.replaceAll("'","''")}')`).all().map(n=>({name:n.name,unique:n.unique===1,columns:Et(e,n.name)??[]}))}function Et(e,t){return Ro(e,t)?.columns??null}function Ro(e,t){let n=e.prepare("SELECT tbl_name, sql FROM sqlite_master WHERE type = 'index' AND name = ?").get(t);if(!n)return null;let r=e.prepare(`PRAGMA index_info('${t.replaceAll("'","''")}')`).all().map(i=>i.name);return{table:n.tbl_name,sql:n.sql,columns:r}}import{writeFileSync as Ku}from"fs";function Ae(e,t){let n=performance.now(),r=e.run(t);return{stageId:e.id,facts:e.facts,durationMs:performance.now()-n,result:r}}async function vo(e,t){let n=performance.now(),r=await e.run(t);return{stageId:e.id,facts:e.facts,durationMs:performance.now()-n,result:r}}async function Po(e){let t=e.readFingerprint(),n=Qu(e.cachePath,t);if(n)return e.onCacheHit?.(n.result),n.result;let r=await e.compute();return Zu(e.cachePath,e.readFingerprint(),r),r}function Qu(e,t){try{let n=JSON.parse($(e,{maxBytes:Re,inputKind:"post-index augmentation cache"}));return xo(n.fingerprint)===xo(t)?{result:n.result}:null}catch{return null}}function Zu(e,t,n){Ku(e,`${JSON.stringify({updatedAt:new Date().toISOString(),fingerprint:t,result:n},null,2)}
|
|
256
|
-
`)}function xo(e){return JSON.stringify(e)}import{existsSync as Eo,statSync as el}from"fs";import{dirname as To,join as ko}from"path";var tl="reindex-activity.jsonl",It=Ce,nl=1024*1024,rl=1440*60*1e3,Io=e=>U(e,"reindex activity segment");function wt(e){return ko(To(e),tl)}function _o(e){if(e.reused)return 0;let n=(e.shards?.some(r=>!r.reused&&r.strategy==="incremental")??!1?0:Tn(e.indexPath))+Tn(e.dbPath);for(let r of e.shards??[]){if(r.reused)continue;let i=r.producedOutputBytes??r.outputBytes;i!==null&&(n+=i)}return n}function il(e){let t=_o(e),n=e.writeTelemetry;return n?Math.max(0,t-n.reflinkedBytes)+n.fallbackCopiedBytes+(n.incrementalWrittenBytes??0):t}function kn(e,t){let n=t.lastRefresh;if(!n)return{state:"failed",reason:"reindex result has no refresh metadata"};let r=_o(t);return _n(wt(e),{version:1,event:"run",recordedAt:n.completedAt,trigger:n.trigger,result:n.result,durationMs:n.durationMs,estimatedLogicalOutputBytes:r,estimatedWriteBytes:il(t),reflinkedBytes:t.writeTelemetry?.reflinkedBytes??0,fallbackCopiedBytes:t.writeTelemetry?.fallbackCopiedBytes??0,incrementalWrittenBytes:t.writeTelemetry?.incrementalWrittenBytes??0,byLanguage:fl(t)})}function Co(e,t){return _n(wt(e),{version:1,event:"run",recordedAt:t.completedAt,trigger:t.trigger,result:"failed",durationMs:t.durationMs,estimatedLogicalOutputBytes:0})}function Ym(e,t,n=new Date){return _n(wt(e),{version:1,event:"suppressed",recordedAt:n.toISOString(),trigger:t,reason:"completed-index-is-fresh"})}function ol(e,t,n=nl,r){xt(e,t,{maxSegmentBytes:n,previousSuffix:It,...r?{runtime:r}:{}})}function al(e,t=new Date,n=rl,r=Io){let i=t.getTime(),o=i-n,a={confidence:"complete",recordsRead:0,invalidRecords:0,skippedRecords:0,readErrors:0,ignoredPartialTailBytes:0,windowStartedAt:new Date(o).toISOString(),windowEndedAt:t.toISOString(),runs:0,rebuilt:0,fullRebuilds:0,reused:0,failed:0,suppressed:0,estimatedLogicalOutputBytes:0,estimatedWriteBytes:0,reflinkedBytes:0,fallbackCopiedBytes:0,languageAttribution:"complete",attributedRuns:0,unattributedRuns:0,invalidLanguageDetails:0,byLanguage:{},byTrigger:{},automatic:{runs:0,rebuilt:0,fullRebuilds:0,estimatedWriteBytes:0}},s=a.automatic,c=wt(e),u=[];if(r===Io){if(!Eo(c)&&!Eo(`${c}${It}`))return a;try{let l=Xi(c,{previousSuffix:It});u=l.lines,a.ignoredPartialTailBytes=l.ignoredPartialTailBytes}catch{a.readErrors+=1,a.confidence="unavailable"}}else{let l=0;for(let p of[`${c}${It}`,c])try{u.push(...Sl(r(p))),l+=1}catch{a.readErrors+=1}l===0?a.confidence="unavailable":a.readErrors>0&&(a.confidence="partial")}for(let l of u){a.recordsRead+=1;let p=sl(l);if(!p){a.invalidRecords+=1,a.confidence!=="unavailable"&&(a.confidence="partial");continue}let{record:d}=p,f=Date.parse(d.recordedAt);if(f<o||f>i){a.skippedRecords+=1;continue}if(a.invalidLanguageDetails=(a.invalidLanguageDetails??0)+p.invalidLanguageDetails,a.byTrigger[d.trigger.kind]=(a.byTrigger[d.trigger.kind]??0)+1,d.event==="suppressed"){a.suppressed+=1;continue}a.runs+=1,a[d.result]+=1,a.estimatedLogicalOutputBytes+=d.estimatedLogicalOutputBytes;let m=cl(d);a.estimatedWriteBytes=(a.estimatedWriteBytes??0)+m,a.reflinkedBytes=(a.reflinkedBytes??0)+(d.reflinkedBytes??0),a.fallbackCopiedBytes=(a.fallbackCopiedBytes??0)+(d.fallbackCopiedBytes??0),d.result!=="failed"&&(p.hasLanguageDetails?a.attributedRuns=(a.attributedRuns??0)+1:a.unattributedRuns=(a.unattributedRuns??0)+1);for(let[E,T]of Ao(d.byLanguage)){let v=(a.byLanguage??={})[E]??=yl();v.runs+=1,v[T.result]+=1,v.producedOutputBytes+=T.producedOutputBytes,v.durationMs+=T.durationMs}let y=dl(d);y&&a.oldestRebuildAt===void 0&&(a.oldestRebuildAt=d.recordedAt),y&&(a.fullRebuilds=(a.fullRebuilds??0)+1),m>0&&a.oldestWriteAt===void 0&&(a.oldestWriteAt=d.recordedAt),ul(d.trigger)&&(s.runs+=1,d.result==="rebuilt"&&(s.rebuilt+=1),y&&(s.fullRebuilds+=1,s.oldestRebuildAt??=d.recordedAt),s.estimatedWriteBytes+=m,m>0&&(s.oldestWriteAt??=d.recordedAt))}return a.ignoredPartialTailBytes>0&&a.confidence!=="unavailable"&&(a.confidence="partial"),a.languageAttribution=bl(a),a}function _n(e,t){try{return ol(e,t),{state:"recorded"}}catch(n){return{state:"failed",reason:n instanceof Error?n.message:String(n)}}}function sl(e){try{let t=JSON.parse(e);if(!t||typeof t!="object")return null;let n=t;if(n.version!==1||!wr(n.recordedAt)||!n.trigger||!pl(n.trigger.kind))return null;if(n.event==="suppressed")return n.reason==="completed-index-is-fresh"?{record:n,hasLanguageDetails:!1,invalidLanguageDetails:0}:null;if(n.event!=="run"||n.result!=="rebuilt"&&n.result!=="reused"&&n.result!=="failed"||!Q(n.durationMs)||!Q(n.estimatedLogicalOutputBytes)||n.estimatedWriteBytes!==void 0&&!Q(n.estimatedWriteBytes)||n.reflinkedBytes!==void 0&&!Q(n.reflinkedBytes)||n.fallbackCopiedBytes!==void 0&&!Q(n.fallbackCopiedBytes)||n.incrementalWrittenBytes!==void 0&&!Q(n.incrementalWrittenBytes))return null;let r=n,{byLanguage:i,...o}=r,a=gl(i);return{record:{...o,...a.byLanguage?{byLanguage:a.byLanguage}:{}},hasLanguageDetails:a.hasLanguageDetails,invalidLanguageDetails:a.invalidLanguageDetails}}catch{return null}}function cl(e){return e.reflinkedBytes===void 0?e.estimatedWriteBytes??e.estimatedLogicalOutputBytes:Math.max(0,e.estimatedLogicalOutputBytes-e.reflinkedBytes)+(e.fallbackCopiedBytes??0)+(e.incrementalWrittenBytes??0)}function Xm(e,t,n=new Date){return t.enabled?ll(al(e,n,t.windowMs),t,n.getTime()):{state:"allowed",rebuilt:0,estimatedWriteBytes:0}}function ul(e){return e.kind.startsWith("watch-")}function ll(e,t,n){let r=e.automatic??{fullRebuilds:e.fullRebuilds??e.rebuilt,estimatedWriteBytes:e.estimatedWriteBytes??e.estimatedLogicalOutputBytes,oldestRebuildAt:e.oldestRebuildAt,oldestWriteAt:e.oldestWriteAt},i=r.estimatedWriteBytes,o=r.fullRebuilds,a={rebuilt:o,estimatedWriteBytes:i};return t.enabled?e.confidence!==void 0&&e.confidence!=="complete"?{state:"paused",reason:"activity-evidence",until:n+t.windowMs,...a,detail:`reindex activity evidence is ${e.confidence}`}:o>=t.maxRebuilds?{state:"paused",reason:"rebuild-count",until:wo(r.oldestRebuildAt,t.windowMs,n),...a,detail:`${o}/${t.maxRebuilds} expensive full rebuild slots consumed by automatic refreshes`}:i>=t.maxEstimatedWriteBytes?{state:"paused",reason:"estimated-write-bytes",until:wo(r.oldestWriteAt,t.windowMs,n),...a,detail:`${i}/${t.maxEstimatedWriteBytes} estimated write bytes consumed by automatic refreshes`}:{state:"allowed",...a}:{state:"allowed",...a}}function dl(e){if(e.result!=="rebuilt")return!1;let t=Ao(e.byLanguage);return t.length===0?!0:t.some(([,n])=>n.result==="rebuilt"&&n.strategy!=="incremental"&&n.strategy!=="reused")}function wo(e,t,n){let r=e?Date.parse(e):Number.NaN;return Number.isFinite(r)&&r+t>n?r+t:n+t}function pl(e){return e==="manual-cli"||e==="setup"||e==="watch-source"||e==="watch-startup"||e==="watch-demand"||e==="watch-git-head"||e==="watch-git-index"||e==="watch-git-state"||e==="unknown"}function Tn(e){try{return el(e).size}catch{return 0}}function fl(e){let t={};for(let n of e.languages){let r=(e.shards??[]).filter(u=>u.language===n),i=r.find(u=>u.id===n),o=e.reused||(i?i.reused:r.length>0&&r.every(u=>u.reused)),a=Tn(ko(To(e.dbPath),"language-indexes",`${n}.scip`)),s=a>0?a:i?.outputBytes??a,c=o?0:i?.durationMs??r.filter(u=>!u.reused).reduce((u,l)=>u+l.durationMs,0);t[n]={result:o?"reused":"rebuilt",strategy:o?"reused":i?.strategy??"full",...i?.strategy==="full"&&(i.fallbackReason??i.missReason)?{fallbackReason:i.fallbackReason??i.missReason}:{},outputBytes:s,producedOutputBytes:o?0:i?.producedOutputBytes??s,durationMs:c}}return t}function gl(e){if(e===void 0)return{hasLanguageDetails:!1,invalidLanguageDetails:0};if(!e||typeof e!="object"||Array.isArray(e))return{hasLanguageDetails:!1,invalidLanguageDetails:1};let t={},n=0;for(let[i,o]of Object.entries(e)){if(!hl(i)||!ml(o)){n+=1;continue}t[i]=o}let r=Object.keys(t).length>0;return{...r?{byLanguage:t}:{},hasLanguageDetails:r,invalidLanguageDetails:n}}function ml(e){if(!e||typeof e!="object")return!1;let t=e;return(t.result==="rebuilt"||t.result==="reused")&&(t.strategy===void 0||t.strategy==="reused"||t.strategy==="incremental"||t.strategy==="full")&&(t.fallbackReason===void 0||typeof t.fallbackReason=="string")&&Zt(t.outputBytes)&&Zt(t.producedOutputBytes)&&Q(t.durationMs)&&(t.result!=="reused"||t.producedOutputBytes===0&&t.durationMs===0)&&t.producedOutputBytes<=t.outputBytes}function hl(e){return en.includes(e)}function Ao(e){return e?en.flatMap(t=>{let n=e[t];return n?[[t,n]]:[]}):[]}function yl(){return{runs:0,rebuilt:0,reused:0,producedOutputBytes:0,durationMs:0}}function bl(e){let t=e.invalidLanguageDetails??0,n=e.attributedRuns??0;return(e.unattributedRuns??0)===0&&t===0?"complete":n===0?"unavailable":"partial"}function Sl(e){return e.endsWith(`
|
|
257
|
-
`)||(e=e.slice(0,Math.max(0,e.lastIndexOf(`
|
|
258
|
-
`)+1))),e.split(`
|
|
259
|
-
`).filter(t=>t.length>0)}import{createHash as Rl}from"crypto";import{existsSync as Cn,readdirSync as xl}from"fs";import{dirname as An,join as Tt,relative as vl,resolve as Fn,sep as Fo}from"path";function Lo(e,t){let n=t.includes("."),r={};for(let o of t)r[o]=[];let i=[];for(let o of e){let a=No(o.path,t);a?r[a].push(o):n?r["."].push(o):i.push(o)}return{files:r,shared:i}}function Oo(e,t){let n=new Map;for(let i of e){let o=t[i]?.packageName;o&&n.set(o,i)}let r=new Map;for(let i of e)r.set(i,new Set);for(let i of e){let o=t[i],a=r.get(i);if(!o||o.parseFailed){for(let s of e)s!==i&&a.add(s);continue}for(let s of o.dependencyNames){let c=n.get(s);c&&c!==i&&a.add(c)}for(let s of[...o.pathsTargets,...o.referencesPaths]){let c=No(s,e);c&&c!==i&&a.add(c)}}return Pl(e,r)}function Do(e,t,n){let r={};for(let i of e){let o=new Map;for(let a of t.files[i]??[])o.set(a.path,a);for(let a of n[i]??[])for(let s of t.files[a]??[])o.set(s.path,s);for(let a of t.shared)o.set(a.path,a);r[i]={files:[...o.values()].sort((a,s)=>a.path.localeCompare(s.path))}}return r}function Ln(e){if(e===".")return"root";let t=Rl("sha256").update(e).digest("hex").slice(0,8);return`${e.split("/").join("__")}-${t}`}function Mo(e,t){let n=Fn(e),r={};for(let i of t)r[i]=El(n,i);return r}function No(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 Pl(e,t){let n={};for(let r of e){let i=new Set,o=[...t.get(r)??[]];for(;o.length>0;){let a=o.pop();if(!(a===r||i.has(a))){i.add(a);for(let s of t.get(a)??[])s!==r&&!i.has(s)&&o.push(s)}}n[r]=[...i].sort((a,s)=>a.localeCompare(s))}return n}function El(e,t){let n=t==="."?e:Tt(e,t),r=Il(n),i=wl(n),o=i?Tl(i,e):{pathsTargets:[],referencesPaths:[],failed:!1};return{packageName:r.name,dependencyNames:r.dependencyNames,pathsTargets:o.pathsTargets,referencesPaths:o.referencesPaths,parseFailed:r.failed||o.failed}}function Il(e){let t=Tt(e,"package.json");if(!Cn(t))return{name:void 0,dependencyNames:[],failed:!1};let n=On(t);if(!n.ok)return{name:void 0,dependencyNames:[],failed:!0};let r=typeof n.value.name=="string"?n.value.name:void 0,i=new Set;for(let o of["dependencies","devDependencies","peerDependencies"]){let a=n.value[o];if(a&&typeof a=="object"&&!Array.isArray(a))for(let s of Object.keys(a))i.add(s)}return{name:r,dependencyNames:[...i],failed:!1}}function wl(e){let t=Tt(e,"tsconfig.json");if(Cn(t))return t;let n;try{n=xl(e).filter(r=>/^tsconfig.*\.json$/.test(r))}catch{return}return n.sort((r,i)=>r.localeCompare(i)),n.length>0?Tt(e,n[0]):void 0}function Tl(e,t){let n=On(e);if(!n.ok)return{pathsTargets:[],referencesPaths:[],failed:!0};let r=kl(n.value,e,t),i=jo(e,n.value,t,0);return{pathsTargets:i.pathsTargets,referencesPaths:r,failed:i.failed}}function kl(e,t,n){let r=e.references;if(!Array.isArray(r))return[];let i=An(t),o=new Set;for(let a of r){if(!a||typeof a!="object")continue;let s=a.path;if(typeof s!="string"||s.trim()==="")continue;let c=Bo(s,i,n);c&&o.add(c)}return[...o]}function jo(e,t,n,r){let i=_l(t);if(i)return{pathsTargets:Cl(i,An(e),n),failed:!1};if(r>=5)return{pathsTargets:[],failed:!1};let o=Al(t.extends,e,n);if(!o)return{pathsTargets:[],failed:!1};let a=On(o);return a.ok?jo(o,a.value,n,r+1):{pathsTargets:[],failed:!0}}function _l(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 Cl(e,t,n){let r=new Set;for(let i of Object.values(e))if(Array.isArray(i))for(let o of i){if(typeof o!="string")continue;let a=Bo(o,t,n);a&&r.add(a)}return[...r]}function Al(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=Fn(An(t),r);if(i.endsWith(".json")||(i=`${i}.json`),!i.split(Fo).includes("node_modules")&&Jt(n,i)&&Cn(i))return i}function Bo(e,t,n){let r=e.replace(/\/?\*+$/,""),i=Fn(t,r===""?".":r);if(!Jt(n,i))return;let a=vl(n,i).split(Fo).join("/");return a===""?".":a}function Fl(e){let t="",n=0,r=!1,i=e.length;for(;n<i;){let o=e[n];if(r){if(t+=o,o==="\\"&&n+1<i){t+=e[n+1],n+=2;continue}o==='"'&&(r=!1),n+=1;continue}if(o==='"'){r=!0,t+=o,n+=1;continue}if(o==="/"&&e[n+1]==="/"){for(n+=2;n<i&&e[n]!==`
|
|
260
|
-
`;)n+=1;continue}if(o==="/"&&e[n+1]==="*"){for(n+=2;n<i&&!(e[n]==="*"&&e[n+1]==="/");)n+=1;n+=2;continue}t+=o,n+=1}return t}function On(e){try{let t=$(e,{maxBytes:Re,inputKind:"TypeScript project manifest"}),n=JSON.parse(Fl(t));return n&&typeof n=="object"&&!Array.isArray(n)?{ok:!0,value:n}:{ok:!1}}catch{return{ok:!1}}}import Ll from"better-sqlite3";import{zstdCompressSync as Ol}from"zlib";import{setImmediate as $o}from"timers/promises";var re=class extends Error{},Dl=200,Mn=2,Vo=1,Ml=2,Nl=3,jl=4,Bl=5,$l=6,Ho=1,Jo=2,zo=3,Vl=7,Ul=1,Gl=3,Wl=5,ql=6,Hl=8,Jl=1,Uo=64,zl=[`CREATE TABLE documents (
|
|
261
|
-
id INTEGER PRIMARY KEY,
|
|
262
|
-
language TEXT,
|
|
263
|
-
relative_path TEXT NOT NULL UNIQUE,
|
|
264
|
-
position_encoding TEXT,
|
|
265
|
-
text TEXT
|
|
266
|
-
)`,`CREATE TABLE chunks (
|
|
267
|
-
id INTEGER PRIMARY KEY,
|
|
268
|
-
document_id INTEGER NOT NULL,
|
|
269
|
-
chunk_index INTEGER NOT NULL,
|
|
270
|
-
start_line INTEGER NOT NULL,
|
|
271
|
-
end_line INTEGER NOT NULL,
|
|
272
|
-
occurrences BLOB NOT NULL,
|
|
273
|
-
FOREIGN KEY (document_id) REFERENCES documents(id)
|
|
274
|
-
)`,`CREATE TABLE global_symbols (
|
|
275
|
-
id INTEGER PRIMARY KEY,
|
|
276
|
-
symbol TEXT NOT NULL UNIQUE,
|
|
277
|
-
display_name TEXT,
|
|
278
|
-
kind INTEGER,
|
|
279
|
-
documentation TEXT,
|
|
280
|
-
signature BLOB,
|
|
281
|
-
enclosing_symbol TEXT,
|
|
282
|
-
relationships BLOB
|
|
283
|
-
)`,`CREATE TABLE mentions (
|
|
284
|
-
chunk_id INTEGER NOT NULL,
|
|
285
|
-
symbol_id INTEGER NOT NULL,
|
|
286
|
-
role INTEGER NOT NULL,
|
|
287
|
-
PRIMARY KEY (chunk_id, symbol_id, role),
|
|
288
|
-
FOREIGN KEY (chunk_id) REFERENCES chunks(id),
|
|
289
|
-
FOREIGN KEY (symbol_id) REFERENCES global_symbols(id)
|
|
290
|
-
)`,`CREATE TABLE defn_enclosing_ranges (
|
|
291
|
-
id INTEGER PRIMARY KEY,
|
|
292
|
-
document_id INTEGER NOT NULL,
|
|
293
|
-
symbol_id INTEGER NOT NULL,
|
|
294
|
-
start_line INTEGER NOT NULL,
|
|
295
|
-
start_char INTEGER NOT NULL,
|
|
296
|
-
end_line INTEGER NOT NULL,
|
|
297
|
-
end_char INTEGER NOT NULL,
|
|
298
|
-
FOREIGN KEY (document_id) REFERENCES documents(id),
|
|
299
|
-
FOREIGN KEY (symbol_id) REFERENCES global_symbols(id)
|
|
300
|
-
)`],Yl=["CREATE INDEX idx_chunks_line_range ON chunks(document_id, start_line, end_line)","CREATE INDEX idx_mentions_symbol_id_role ON mentions(symbol_id, role)","CREATE INDEX idx_defn_enclosing_ranges_symbol_id ON defn_enclosing_ranges(symbol_id)","CREATE INDEX idx_defn_enclosing_ranges_document ON defn_enclosing_ranges(document_id, start_line, end_line)","CREATE INDEX idx_chunks_doc_id ON chunks(document_id)","CREATE INDEX idx_global_symbols_symbol ON global_symbols(symbol)"];function Dn(e){return e.startsWith("local ")}function Go(e,t,n,r){let i=t,o=0,a=0;for(;i<n;){let s=e[i];i+=1,a<53&&(o+=(s&127)*2**a),(s&128)===0?(r.push(o),o=0,a=0):a+=7}}function Wo(e){return e.length===3?[e[0],e[1],e[0],e[2]]:e.length===4?[e[0],e[1],e[2],e[3]]:null}function Xl(e,t){return e.startLine!==t.startLine?e.startLine-t.startLine:e.startChar!==t.startChar?e.startChar-t.startChar:e.endLine!==t.endLine?e.endLine-t.endLine:e.endChar!==t.endChar?e.endChar-t.endChar:e.symbol<t.symbol?-1:e.symbol>t.symbol?1:0}function Kl(e,t,n,r){let i=[],o=[],a="",s=0;for(let u of de(e,n,r))u.fieldNumber===Ho?u.wireType===2?Go(e,u.valueStart,u.valueEnd,i):u.wireType===0&&i.push(u.varint):u.fieldNumber===Jo&&u.wireType===2?a=Fe.decode(e.subarray(u.valueStart,u.valueEnd)):u.fieldNumber===zo&&u.wireType===0?s=u.varint:u.fieldNumber===Vl&&(u.wireType===2?Go(e,u.valueStart,u.valueEnd,o):u.wireType===0&&o.push(u.varint));let c=Wo(i);return c?{startLine:c[0],startChar:c[1],endLine:c[2],endChar:c[3],symbol:a,roles:s,frameStart:t,frameEnd:r,merged:!1,enclosing:Wo(o)}:null}function Ql(e,t,n){let r={symbol:"",displayName:null,kind:null,documentation:[],enclosingSymbol:null};for(let i of de(e,t,n))if(i.wireType===2){let o=()=>Fe.decode(e.subarray(i.valueStart,i.valueEnd));i.fieldNumber===Ul?r.symbol=o():i.fieldNumber===Gl?r.documentation.push(o()):i.fieldNumber===ql?r.displayName=o():i.fieldNumber===Hl&&(r.enclosingSymbol=o())}else i.fieldNumber===Wl&&i.wireType===0&&(r.kind=i.varint);return r}var Fe=new TextDecoder;function Zl(e,t){if(e.length===0)return[];let n=[],r=Math.min(e.length,t);for(let i=0;i<r&&r<=e.length;){for(;r<=e.length-1&&e[r-1].startLine===e[r].startLine;)r+=1;n.push(e.slice(i,r)),i=r,r=Math.min(e.length,r+t)}return n}function ed(e){let t=e.startLine===e.endLine?[e.startLine,e.startChar,e.endChar]:[e.startLine,e.startChar,e.endLine,e.endChar],n=[],r=Buffer.concat(t.map(a=>pe(a)));n.push(lt(Ho),pe(r.length),r);let i=Buffer.from(e.symbol,"utf8");n.push(lt(Jo),pe(i.length),i),e.roles!==0&&n.push(pe(zo*8),pe(e.roles));let o=Buffer.concat(n);return Buffer.concat([lt(Mn),pe(o.length),o])}function td(e,t){let n=[];for(let r of t)r.merged?n.push(ed(r)):n.push(e.subarray(r.frameStart,r.frameEnd));return Ol(Buffer.concat(n))}async function Yo(e,t,n={}){let r=n.chunkSize??Dl,i={documents:0,duplicateDocumentsSkipped:0,occurrences:0,illegalOccurrencesDropped:0,mergedOccurrences:0,chunks:0,mentions:0,globalSymbols:0,enclosingRanges:0},o=new Ll(t);try{o.pragma("synchronous = normal"),o.pragma("temp_store = memory"),o.pragma("foreign_keys = ON"),o.pragma("journal_mode = WAL");for(let v of zl)o.exec(v);let a=o.prepare("INSERT INTO documents (id, language, relative_path, position_encoding, text) VALUES (?, ?, ?, ?, ?)"),s=o.prepare("INSERT INTO chunks (id, document_id, chunk_index, start_line, end_line, occurrences) VALUES (?, ?, ?, ?, ?, ?)"),c=o.prepare("INSERT INTO defn_enclosing_ranges (document_id, symbol_id, start_line, start_char, end_line, end_char) VALUES (?, ?, ?, ?, ?, ?)"),u=o.prepare("INSERT INTO global_symbols (id, symbol, display_name, kind, documentation, enclosing_symbol) VALUES (?, ?, ?, ?, ?, ?)"),l=o.prepare("INSERT INTO mentions (chunk_id, symbol_id, role) VALUES (?, ?, ?)"),p=new Map,d=new Map,f=1,m=1,y=1,E=(v,F,_,b,S)=>{let h=y;return y+=1,d.set(v,h),u.run(h,v,F,_,b,S),i.globalSymbols+=1,h};o.exec("BEGIN IMMEDIATE");let T=!1;try{let v=0;for(let _ of de(e)){if(_.fieldNumber!==Mn||_.wireType!==2)continue;qo(n.signal),v+=1,v>=Uo&&(v=0,await $o());let b="",S=null,h=null,A=null,R=[];for(let g of de(e,_.valueStart,_.valueEnd))g.wireType===2?g.fieldNumber===Vo?b=Fe.decode(e.subarray(g.valueStart,g.valueEnd)):g.fieldNumber===Nl?R.push(Ql(e,g.valueStart,g.valueEnd)):g.fieldNumber===jl?S=Fe.decode(e.subarray(g.valueStart,g.valueEnd)):g.fieldNumber===Bl&&(h=Fe.decode(e.subarray(g.valueStart,g.valueEnd))):g.fieldNumber===$l&&g.wireType===0&&(A=nd(g.varint));if(b==="")throw new re("relative path must not be empty");if(p.has(b)){i.duplicateDocumentsSkipped+=1;continue}let P=f;f+=1,a.run(P,S===""?null:S,b,A,h===""?null:h),p.set(b,P),i.documents+=1;let k=new Map;for(let g of R){if(g.symbol==="")throw new re(`empty symbol in SymbolInformation for document ${b}`);let x=k.get(g.symbol);if(!x){k.set(g.symbol,g);continue}for(let D of g.documentation)x.documentation.includes(D)||x.documentation.push(D)}for(let g of[...k.values()].sort((x,D)=>x.symbol<D.symbol?-1:x.symbol>D.symbol?1:0))Dn(g.symbol)||d.has(g.symbol)||E(g.symbol,g.displayName===""?null:g.displayName,g.kind===0?null:g.kind,g.documentation.length===0?null:g.documentation.join(`
|
|
301
|
-
`),g.enclosingSymbol===""?null:g.enclosingSymbol)}let F=new Set;v=0;for(let _ of de(e)){if(_.fieldNumber!==Mn||_.wireType!==2)continue;qo(n.signal),v+=1,v>=Uo&&(v=0,await $o());let b="",S=[];for(let R of de(e,_.valueStart,_.valueEnd))if(R.wireType===2){if(R.fieldNumber===Vo)b=Fe.decode(e.subarray(R.valueStart,R.valueEnd));else if(R.fieldNumber===Ml){let P=Kl(e,R.fieldStart,R.valueStart,R.valueEnd);P?S.push(P):i.illegalOccurrencesDropped+=1}}if(F.has(b))continue;F.add(b);let h=p.get(b);if(h===void 0)continue;S.sort(Xl);let A=[];for(let R of S){let P=A[A.length-1];if(P&&P.startLine===R.startLine&&P.startChar===R.startChar&&P.endLine===R.endLine&&P.endChar===R.endChar&&P.symbol===R.symbol){P.roles|=R.roles,P.merged=!0,i.mergedOccurrences+=1;continue}A.push(R)}i.occurrences+=A.length;for(let R of A){if((R.roles&Jl)===0||Dn(R.symbol)||!R.enclosing)continue;let[P,k,g,x]=R.enclosing;if(P<0||k<0||g<P||g===P&&x<k)throw new re(`bad enclosing range for symbol ${R.symbol} in ${b}`);let D=d.get(R.symbol);if(D===void 0)throw new re(`symbol ${R.symbol} has definition occurrence, but no SymbolInformation`);c.run(h,D,P,k,g,x),i.enclosingRanges+=1}for(let[R,P]of Zl(A,r).entries()){let k=m;m+=1,s.run(k,h,R,P[0].startLine,P[P.length-1].startLine,td(e,P)),i.chunks+=1;let g=new Map;for(let x of P){if(Dn(x.symbol))continue;let D=g.get(x.symbol);D||g.set(x.symbol,D=new Set),D.add(x.roles),d.has(x.symbol)||E(x.symbol,null,null,null,null)}for(let[x,D]of g){let Y=d.get(x);for(let qt of D)l.run(k,Y,qt),i.mentions+=1}}}o.exec("COMMIT"),T=!0}finally{if(!T)try{o.exec("ROLLBACK")}catch{}}o.exec("BEGIN IMMEDIATE");for(let v of Yl)o.exec(v);o.exec("COMMIT"),o.pragma("wal_checkpoint(TRUNCATE)")}finally{o.close()}return i}function nd(e){if(e===0)return null;if(e===1)return"UTF-8";if(e===2)return"UTF-16";if(e===3)return"UTF-32";throw new re(`unknown position encoding ${e}`)}function qo(e){if(e?.aborted)throw new re("SCIP SQLite conversion aborted")}import{readdirSync as rd,rmSync as id}from"fs";import{cpus as od,totalmem as ad}from"os";import{join as kt}from"path";var sd=2048,cd=6*1024**3,ud=4;function Nn(e=process.env){let t=Number.parseInt(e.SCIP_QUERY_TS_COMPILER_SHARD_FILES??"",10);return Number.isSafeInteger(t)&&t>0?t:sd}function Ko(e,t){return e>Math.floor(t*1.5)}var ld=1.25;function Qo(e,t,n){if(!Number.isSafeInteger(t)||t<1)throw new Error(`TypeScript compiler shard targetFiles must be a positive safe integer; received ${t}.`);let r=Math.max(1,Math.ceil(e/t));if(r<=1||n<=1)return r;let i=Math.floor(t*ld),o=new Set([r,n*Math.floor(r/n),n*Math.ceil(r/n)]),a=c=>Math.ceil(c/n)*Math.ceil(e/c),s=r;for(let c of o)c<1||Math.ceil(e/c)>i||(a(c)<a(s)||a(c)===a(s)&&c<s)&&(s=c);return s}function dd(e,t,n=()=>1){if(!Number.isSafeInteger(t)||t<1)throw new Error(`TypeScript compiler shard count must be a positive safe integer; received ${t}.`);let r=[...new Set(e)].sort((u,l)=>u.localeCompare(l));if(t===1||r.length<=t)return r.length<=t&&t>1?r.map(u=>[u]):r.length>0?[r]:[];let i=r.map(u=>Math.max(1,n(u))),o=i.reduce((u,l)=>u+l,0),a=[],s=[],c=0;for(let u=0;u<r.length;u+=1){s.push(r[u]),c+=i[u];let l=t-a.length-1,p=r.length-u-1;l>0&&p>=l&&(c>=o*(a.length+1)/t||p===l)&&(a.push(s),s=[])}return s.length>0&&a.push(s),a}function Zo(e){let t=e.targetFiles??Nn(),n=e.shardCount??Math.max(1,Math.ceil(new Set(e.inputPaths).size/Math.max(1,t)));return dd(e.inputPaths,n,e.weightOf).map((r,i)=>{let o=kt(e.projectRoot,yr(i)),a=`${JSON.stringify({extends:`./${e.rootConfigPath}`,compilerOptions:{incremental:!1},files:r.map(s=>`./${s}`),include:[],exclude:[]},null,2)}
|
|
302
|
-
`;return{configPath:o,content:a,inputPaths:r}})}var ea="typescript-shard-costs.json",Xo=4;function ta(e){let t;try{t=JSON.parse(Qe(kt(e,ea),"shard cost model"))}catch{return null}if(typeof t!="object"||t===null||t.version!==1)return null;let n=t.samples;return Array.isArray(n)&&n.every(i=>typeof i=="object"&&i!==null&&typeof i.firstPath=="string"&&typeof i.lastPath=="string"&&Number.isFinite(i.totalBytes)&&i.totalBytes>0&&Number.isFinite(i.durationMs)&&i.durationMs>0)?{version:1,samples:n}:null}function na(e,t){at(kt(e,ea),t)}function ra(e){let t=(e?.samples??[]).filter(o=>o.totalBytes>0&&o.durationMs>0);if(t.length<2)return(o,a)=>a;let n=t.map(o=>o.durationMs/o.totalBytes).sort((o,a)=>o-a),r=n[Math.floor(n.length/2)];if(!(r>0))return(o,a)=>a;let i=[...t].sort((o,a)=>o.firstPath.localeCompare(a.firstPath));return(o,a)=>{for(let s of i){if(o.localeCompare(s.firstPath)<0)break;if(o.localeCompare(s.lastPath)>0)continue;let c=s.durationMs/s.totalBytes/r;return a*Math.min(Xo,Math.max(1/Xo,c))}return a}}function ia(e,t){let n=[];for(let r of e){let i=r.inputPaths[0],o=r.inputPaths[r.inputPaths.length-1];if(i===void 0||o===void 0||!(r.durationMs>0))return null;let a=r.inputPaths.reduce((s,c)=>s+Math.max(1,t(c)),0);n.push({firstPath:i,lastPath:o,totalBytes:a,durationMs:r.durationMs})}return n.length>0?{version:1,samples:n}:null}function oa(e=process.env,t={totalmemBytes:ad(),cpuCount:od().length}){let n=Number.parseInt(e.SCIP_QUERY_TS_COMPILER_SHARD_CONCURRENCY??"",10);if(Number.isSafeInteger(n)&&n>0)return n;let r=Math.floor(t.totalmemBytes/2/cd),i=Math.floor(t.cpuCount/2);return Math.max(1,Math.min(ud,r,i))}function aa(e){let t;try{t=rd(e)}catch{return}for(let n of t)if(br(n))try{id(kt(e,n))}catch{}}import{createHash as Yn}from"crypto";import{existsSync as zn,writeFileSync as Ea}from"fs";import{join as jd}from"path";import{createRequire as pd}from"module";import{dirname as Un,isAbsolute as fd,relative as ua,resolve as oe,sep as Bn}from"path";var ie=pd(import.meta.url),gd=1,sa="0.4.0";function md(){try{let e=la();if(!e.available)return e;let{packageRoot:t}=e,n=ie.resolve("typescript",{paths:[t]}),r=ie(n),{FileIndexer:i}=ie(oe(t,"dist/src/FileIndexer.js")),{Input:o}=ie(oe(t,"dist/src/Input.js")),{Packages:a}=ie(oe(t,"dist/src/Packages.js")),s=ie(oe(t,"dist/src/scip.js"));if(!i||!o||!a||!s.scip?.Document||!s.scip.Index)return{available:!1,reason:"scip-typescript document runtime has an unsupported module shape"};let c={packageVersion:e.packageVersion,typescript:r,Document:s.scip.Document,Index:s.scip.Index,FileIndexer:i,Input:o,Packages:a};return{available:!0,runtime:c,producerIdentity:Wn(c)}}catch(e){return{available:!1,reason:`scip-typescript document runtime unavailable: ${e instanceof Error?e.message:String(e)}`}}}function Gn(){let e=la();return e.available?{available:!0,packageVersion:e.packageVersion,typescriptVersion:e.typescriptVersion,producerIdentity:e.producerIdentity}:e}function la(){try{let e=ie.resolve("@sourcegraph/scip-typescript/package.json"),t=JSON.parse(U(e,"scip-typescript package manifest"));if(t.version!==sa)return{available:!1,reason:`unsupported scip-typescript version ${String(t.version??"unknown")}; expected ${sa}`};let n=Un(e),r=ie.resolve("typescript/package.json",{paths:[n]}),i=JSON.parse(U(r,"TypeScript package manifest"));return typeof i.version!="string"||!i.version?{available:!1,reason:"scip-typescript TypeScript compiler version is unavailable"}:{available:!0,packageRoot:n,packageVersion:t.version,typescriptVersion:i.version,producerIdentity:pa(t.version,i.version)}}catch(e){return{available:!1,reason:`scip-typescript document producer unavailable: ${e instanceof Error?e.message:String(e)}`}}}function da(e){let t=e.runtime===void 0?md():e.runtime===null?{available:!1,reason:"scip-typescript document runtime unavailable"}:{available:!0,runtime:e.runtime,producerIdentity:Wn(e.runtime)};return t.available?{available:!0,emitter:new $n(e,t.runtime)}:t}var $n=class{producerIdentity;workspaceRoot;tsconfigPath;projectRoot;maxFileByteSize;runtime;host;config=null;includedFiles=new Set;program=null;checker=null;symbolTable=new Map;constructorTable=new Map;packages;fragments=new Map;stats={initializations:0,programUpdates:0,documentsEmitted:0,documentsRemoved:0,sourceNodesReused:0,sourceNodesReplaced:0,symbolEntriesPruned:0};constructor(t,n){this.workspaceRoot=oe(t.workspaceRoot),this.tsconfigPath=oe(this.workspaceRoot,t.tsconfigPath),this.projectRoot=t.projectRoot??yd(this.workspaceRoot,Un(this.tsconfigPath)),this.maxFileByteSize=t.maxFileByteSize??1024*1024,this.runtime=n,this.producerIdentity=Wn(n);let r=jn(n.typescript,this.tsconfigPath);this.config=r,this.host=new Vn(n.typescript,r.options,this.workspaceRoot),this.packages=new n.Packages(this.projectRoot)}initialize(){let t=performance.now();this.initializeProgram();let n=[];for(let r of this.program.getSourceFiles())this.includedFiles.has(De(r.fileName))&&n.push(this.emitSourceFile(r));return this.result(n,t)}advance(t){if(!this.program||!this.checker||!this.config)return this.initializeAndAdvance(t);let n=performance.now(),r=Oe(t.modifiedFiles),i=Oe(t.removedFiles??[]),o=Oe(t.affectedFiles);if(this.fragments.clear(),r.length===0&&i.length===0)return this.validateAffectedPaths(o),this.result(this.emitAffectedFiles(o),n);let a=jn(this.runtime.typescript,this.tsconfigPath);this.config=a,this.includedFiles=new Set(a.fileNames.map(De));let s=this.program,c=new Map;for(let u of[...r,...i]){let l=Le(this.workspaceRoot,u),p=s.getSourceFile(l);p&&(c.set(u,p),this.stats.symbolEntriesPruned+=ca(this.symbolTable,p),this.stats.symbolEntriesPruned+=ca(this.constructorTable,p)),this.host.invalidate(l)}this.program=this.runtime.typescript.createProgram(a.fileNames,a.options,this.host.compilerHost,s),this.checker=this.program.getTypeChecker(),this.stats.programUpdates+=1,this.validateIncrementalPaths(r,i,o),this.stats.documentsRemoved+=i.length;for(let[u,l]of c)this.program.getSourceFile(Le(this.workspaceRoot,u))===l?this.stats.sourceNodesReused+=1:this.stats.sourceNodesReplaced+=1;return this.result(this.emitAffectedFiles(o),n)}fragment(t){return this.fragments.get(_t(t))??null}snapshotStats(){return{...this.stats}}initializeAndAdvance(t){let n=performance.now();this.initializeProgram();let r=Oe(t.modifiedFiles),i=Oe(t.removedFiles??[]),o=Oe(t.affectedFiles);return this.fragments.clear(),this.validateIncrementalPaths(r,i,o,!0),this.stats.documentsRemoved+=i.length,this.result(this.emitAffectedFiles(o),n)}initializeProgram(){let t=this.config??jn(this.runtime.typescript,this.tsconfigPath);this.includedFiles=new Set(t.fileNames.map(De)),this.program=this.runtime.typescript.createProgram(t.fileNames,t.options,this.host.compilerHost),this.checker=this.program.getTypeChecker(),this.stats.initializations+=1}validateIncrementalPaths(t,n,r,i=!1){if(!i&&t.length===0&&n.length===0)throw new Error("incremental TypeScript document update requires a modified or removed file");if(r.length===0&&n.length===0)throw new Error("incremental TypeScript document update requires an affected or removed file");for(let o of t){let a=Le(this.workspaceRoot,o);if(!this.program?.getSourceFile(a))throw new Error(`modified TypeScript dependency is unavailable to the configured project: ${o}`)}for(let o of n){let a=Le(this.workspaceRoot,o);if(this.program?.getSourceFile(a))throw new Error(`removed TypeScript source is still present in the configured project: ${o}`)}this.validateAffectedPaths(r)}validateAffectedPaths(t){for(let n of t){let r=Le(this.workspaceRoot,n);if(!this.includedFiles.has(De(r)))throw new Error(`affected TypeScript file is outside the configured project: ${n}`)}}emitAffectedFiles(t){return t.map(n=>{let r=this.program.getSourceFile(Le(this.workspaceRoot,n));if(!r)throw new Error(`affected TypeScript source is unavailable: ${n}`);return this.emitSourceFile(r)})}emitSourceFile(t){if(!this.checker)throw new Error("TypeScript document emitter is not initialized");let n=_t(ua(this.workspaceRoot,t.fileName)),r=new this.runtime.Document({relative_path:n,occurrences:[]});if(new this.runtime.FileIndexer(this.checker,{cwd:this.workspaceRoot,projectRoot:this.projectRoot,projectDisplayName:this.projectRoot,maxFileByteSizeNumber:this.maxFileByteSize},new this.runtime.Input(t.fileName,t.getText()),r,this.symbolTable,this.constructorTable,this.packages,t).index(),this.stats.documentsEmitted+=1,r.occurrences.length===0)return this.fragments.delete(n),this.stats.documentsRemoved+=1,{relativePath:n,bytes:null,occurrences:0,symbols:r.symbols.length,referenceFragments:[]};let o=r.serializeBinary();return this.fragments.set(n,o),{relativePath:n,bytes:o,occurrences:r.occurrences.length,symbols:r.symbols.length,referenceFragments:hd(n,r)}}result(t,n){return{producerIdentity:this.producerIdentity,fragments:t,durationMs:performance.now()-n,stats:this.snapshotStats()}}};function hd(e,t){let n=new Map;for(let r of t.occurrences){if(!r.symbol||(r.symbol_roles&1)!==0||r.range.length<3)continue;let i=r.range[0],o=r.range[1];if(!Number.isInteger(i)||!Number.isInteger(o))continue;let a={targetSymbol:r.symbol,location:{file:e,line:i,column:o}};n.set(`${r.symbol}\0${i}\0${o}`,a)}return[...n.values()].sort((r,i)=>r.targetSymbol.localeCompare(i.targetSymbol)||r.location.line-i.location.line||r.location.column-i.location.column)}var Vn=class{compilerHost;sourceFiles=new Map;constructor(t,n,r){let i=t.createCompilerHost(n),o=i.getSourceFile.bind(i);this.compilerHost={...i,getCurrentDirectory:()=>r,getSourceFile:(a,s,c,u)=>{let l=De(a);if(this.sourceFiles.has(l))return this.sourceFiles.get(l);let p=o(a,s,c,u);return this.sourceFiles.set(l,p),p}}}invalidate(t){this.sourceFiles.delete(De(t))}};function jn(e,t){let n=e.readConfigFile(t,e.sys.readFile);if(n.error)throw new Error(e.formatDiagnostics([n.error],e.createCompilerHost({})));let r=e.parseJsonConfigFileContent(n.config,e.sys,Un(t)),i=r.errors.filter(o=>o.code!==18003);if(i.length>0)throw new Error(e.formatDiagnostics(i,e.createCompilerHost({})));return r}function Wn(e){return pa(e.packageVersion,e.typescript.version)}function pa(e,t){return`scip-typescript:${e}:typescript:${t}:document-adapter:${gd}`}function yd(e,t){return _t(ua(e,t))||"."}function Le(e,t){if(fd(t))throw new Error(`expected a project-relative path: ${t}`);let n=oe(e,t),r=e.endsWith(Bn)?e:`${e}${Bn}`;if(n!==e&&!n.startsWith(r))throw new Error(`path escapes the project root: ${t}`);return n}function Oe(e){return[...new Set(e.map(_t))].sort()}function _t(e){return e.split(Bn).join("/").replace(/^\.\//,"")}function De(e){return oe(e)}function ca(e,t){let n=0;for(let r of e.keys())if(bd(r)){try{if(r.getSourceFile()!==t)continue}catch{continue}e.delete(r),n+=1}return n}function bd(e){return!!(e&&typeof e=="object"&&"kind"in e&&"getSourceFile"in e)}import{createHash as Sd}from"crypto";import{dirname as Rd,join as fa}from"path";var H=5,xd=4,vd=2,Pd="typescript-index";function ga(e){let t=fa(e,Pd),n=Qr(t);return{...n,requestDir:n.legacyRequestDir}}function Ed(e){let t=JSON.parse(e),n=t.protocolVersion,r=n===vd,i=n===xd,o=t.request,a=(r||i)&&o&&typeof o=="object"&&!Array.isArray(o)?{...o,removedFiles:o.removedFiles??[]}:o;if(!r&&!i&&n!==H||typeof t.id!="string"||!t.id||typeof t.baseGeneration!="string"||!t.baseGeneration||typeof t.deadlineAtMs!="number"||!Number.isFinite(t.deadlineAtMs)||!Id(a)||!r&&(t.mailboxVersion!==Be||typeof t.operationKey!="string"||!/^[a-f0-9]{64}$/.test(t.operationKey)||t.id!==st(t.operationKey)||typeof t.clientId!="string"||!t.clientId||typeof t.enqueuedAtMs!="number"||!Number.isFinite(t.enqueuedAtMs)||t.deadlineAtMs<t.enqueuedAtMs))throw new Error("TypeScript index service received an invalid mailbox request.");if(!r){let c=t,u=$e(i?"typescript-index-v4":"typescript-index-v5",{baseGeneration:c.baseGeneration,request:o});if(c.operationKey!==u)throw new Error("TypeScript index service received a mismatched mailbox operation identity.");return{...c,protocolVersion:H,request:a}}let s=$e("typescript-index-v2",{id:t.id,baseGeneration:t.baseGeneration,request:o});return{protocolVersion:H,mailboxVersion:Be,id:t.id,operationKey:s,clientId:"legacy-v2",enqueuedAtMs:t.deadlineAtMs,deadlineAtMs:t.deadlineAtMs,baseGeneration:t.baseGeneration,request:a}}function ma(e){try{let t=Tr(ce(U(fa(Rd(e),"meta.json"),"reindex metadata")));return t?Sd("sha256").update(t).digest("hex"):null}catch{return null}}function Id(e){if(!e||typeof e!="object")return!1;let t=e,n=qn(t.modifiedFiles)?t.modifiedFiles:null,r=qn(t.removedFiles)?t.removedFiles:null,i=qn(t.affectedFiles)?t.affectedFiles:null;return t.kind==="emit-documents"&&typeof t.tsconfigPath=="string"&&!!t.tsconfigPath&&typeof t.projectArgument=="string"&&!!t.projectArgument&&typeof t.projectIdentity=="string"&&!!t.projectIdentity&&typeof t.producerIdentity=="string"&&!!t.producerIdentity&&n!==null&&new Set(n).size===n.length&&r!==null&&new Set(r).size===r.length&&i!==null&&(i.length>0||r.length>0)&&new Set(i).size===i.length}function qn(e){return Array.isArray(e)&&e.every(t=>typeof t=="string"&&t.length>0)}import{randomUUID as _d}from"crypto";import{existsSync as ya,rmSync as Hn}from"fs";import{join as Cd}from"path";import{randomUUID as wd}from"crypto";import{getHeapStatistics as Td}from"v8";import{resolve as kd}from"path";var Ct=class{projectRoot;currentGeneration;createEmitter;wallNow;monotonicNow;maxActiveSessions;softMemoryLimitBytes;memoryUsage;active=new Map;requests=0;sessionsCreated=0;sessionsReplaced=0;sessionsEvicted=0;lastRequestAtMs=null;lastDurationMs=null;lastError=null;unavailable=!1;constructor(t){if(this.projectRoot=kd(t.projectRoot),this.currentGeneration=t.currentGeneration,this.createEmitter=t.createEmitter??da,this.wallNow=t.wallNow??t.now??Date.now,this.monotonicNow=t.monotonicNow??t.now??C,t.maxActiveSessions!==void 0&&(!Number.isInteger(t.maxActiveSessions)||t.maxActiveSessions<1))throw new Error("TypeScript index maxActiveSessions must be a positive integer.");if(this.maxActiveSessions=t.maxActiveSessions??8,t.softMemoryLimitMb!==void 0&&(!Number.isInteger(t.softMemoryLimitMb)||t.softMemoryLimitMb<1))throw new Error("TypeScript index softMemoryLimitMb must be a positive integer.");this.softMemoryLimitBytes=t.softMemoryLimitMb===void 0?null:t.softMemoryLimitMb*1024*1024,this.memoryUsage=t.memoryUsage??(()=>({heapUsedBytes:process.memoryUsage().heapUsed,heapLimitBytes:Td().heap_size_limit}))}handle(t,n){let r=this.monotonicNow();try{if(this.currentGeneration()!==t)throw new Error("TypeScript index request does not match the currently published generation.");let i=this.emitterFor(n);if(i.emitter.producerIdentity!==n.producerIdentity)throw new Error("TypeScript index producer identity changed.");let o=i.emitter.snapshotStats(),a=i.emitter.advance({modifiedFiles:n.modifiedFiles,removedFiles:n.removedFiles,affectedFiles:n.affectedFiles}),s=this.monotonicNow()-r;return this.requests+=1,this.lastRequestAtMs=this.wallNow(),this.lastDurationMs=s,this.lastError=null,this.unavailable=!1,{producerIdentity:a.producerIdentity,cold:a.stats.initializations>o.initializations,durationMs:s,fragments:a.fragments.map(c=>({relativePath:c.relativePath,bytesBase64:c.bytes===null?null:Buffer.from(c.bytes).toString("base64"),occurrences:c.occurrences,symbols:c.symbols,referenceFragments:c.referenceFragments}))}}catch(i){throw this.lastError=i instanceof Error?i.message:String(i),i}}status(t){let n=[...this.active.values()].map(a=>a.emitter.snapshotStats()),r=a=>n.reduce((s,c)=>s+c[a],0),i=this.memoryUsage(),o=this.softMemoryLimitBytes!==null&&i.heapUsedBytes>=this.softMemoryLimitBytes;return{protocolVersion:H,state:this.unavailable?"unavailable":this.lastError?"error":this.active.size>0?"ready":"idle",requests:this.requests,sessionsCreated:this.sessionsCreated,sessionsReplaced:this.sessionsReplaced,sessionsEvicted:this.sessionsEvicted,activeSessions:this.active.size,maxActiveSessions:this.maxActiveSessions,heapUsedBytes:i.heapUsedBytes,heapLimitBytes:i.heapLimitBytes,...this.softMemoryLimitBytes===null?{}:{softMemoryLimitBytes:this.softMemoryLimitBytes},retireRequested:o,initializations:r("initializations"),programUpdates:r("programUpdates"),documentsEmitted:r("documentsEmitted"),documentsRemoved:r("documentsRemoved"),...this.lastRequestAtMs===null?{}:{lastRequestAt:new Date(this.lastRequestAtMs).toISOString()},...this.lastDurationMs===null?{}:{lastDurationMs:this.lastDurationMs},...this.lastError?{lastError:this.lastError}:{},...t?{mailbox:t}:{}}}close(){this.active.clear()}emitterFor(t){let n=`${t.tsconfigPath}\0${t.projectArgument}`,r=this.active.get(n);if(r?.projectIdentity===t.projectIdentity)return this.active.delete(n),this.active.set(n,r),r;if(r)this.active.delete(n);else if(this.active.size>=this.maxActiveSessions){let a=this.active.keys().next().value;a!==void 0&&(this.active.delete(a),this.sessionsEvicted+=1)}let i=this.createEmitter({workspaceRoot:this.projectRoot,tsconfigPath:t.tsconfigPath,projectRoot:t.projectArgument});if(!i.available)throw this.unavailable=!0,new Error(i.reason);r&&(this.sessionsReplaced+=1);let o={projectIdentity:t.projectIdentity,emitter:i.emitter};return this.active.set(n,o),this.sessionsCreated+=1,o}};var Dh=`typescript-index-${process.pid}-${wd()}`,ha=Z(process.pid),Mh={pid:process.pid,...ha?{processIdentity:ha}:{}};var Ad=12e4,Fd=5,We=class extends Error{name="TypeScriptIndexMemoryPressureError"},At=class{projectRoot;cacheDir;baseGeneration;timeoutMs;runtime;mailboxLimits;emitLocally;requireService;localHost=null;constructor(t,n={}){this.projectRoot=hr(t.projectRoot),this.cacheDir=t.cacheDir,this.baseGeneration=t.baseGeneration,this.timeoutMs=n.timeoutMs??Md(),this.runtime=n.runtime??Nd,this.mailboxLimits=n.mailboxLimits??{},this.emitLocally=n.emitLocally,this.requireService=n.requireService===!0}request(t){let n=ti(this.cacheDir),r=ga(this.cacheDir),i=rn(n.statePath);if(!ba(i,this.projectRoot,this.runtime))return this.requestLocally(t);let o=this.runtime.now(),a=o+this.timeoutMs,s=(this.runtime.monotonicNow??C)()+this.timeoutMs,c=$e("typescript-index-v5",{baseGeneration:this.baseGeneration,request:t}),u=st(c),l=Zr(r,{mailboxVersion:Be,operationKey:c,clientId:this.runtime.randomId(),enqueuedAtMs:o,deadlineAtMs:a,protocolVersion:H,id:u,baseGeneration:this.baseGeneration,request:t},{nowMs:o,limits:this.mailboxLimits});for(;(this.runtime.monotonicNow??C)()<=s;){if(ya(l.responsePath))try{return Sa($(l.responsePath,{maxBytes:this.mailboxLimits.maxItemBytes??64*1024*1024,inputKind:"TypeScript index mailbox response"}),u,c,this.baseGeneration,t.producerIdentity,t.affectedFiles)}finally{Hn(l.responsePath,{force:!0})}let p=rn(n.statePath);if(!ba(p,this.projectRoot,this.runtime))return this.abandonPendingRequest(r,u),this.requestLocally(t);this.runtime.sleep(Fd)}if(ya(l.responsePath))try{return Sa($(l.responsePath,{maxBytes:this.mailboxLimits.maxItemBytes??64*1024*1024,inputKind:"TypeScript index mailbox response"}),u,c,this.baseGeneration,t.producerIdentity,t.affectedFiles)}finally{Hn(l.responsePath,{force:!0})}return this.abandonPendingRequest(r,u),this.requestLocally(t)}abandonPendingRequest(t,n){try{Hn(Cd(t.pendingDir,`${n}.json`),{force:!0})}catch{}}requestLocally(t){if(this.requireService)throw new Error("TypeScript incremental index service unavailable; refusing to load the whole compiler graph inside the reindex process");return this.emitLocally?Jn(this.emitLocally(t),t.producerIdentity,t.affectedFiles):(this.localHost??=new Ct({projectRoot:this.projectRoot,currentGeneration:()=>this.baseGeneration}),Jn(Ra(this.localHost.handle(this.baseGeneration,t),t.producerIdentity),t.producerIdentity,t.affectedFiles))}};function ba(e,t,n){let r=e?.processIdentity?n.readProcessIdentity?.(e.pid):null,i=e?Date.parse(e.heartbeatAt):Number.NaN;return e!==null&&e.projectRoot===t&&e.typescriptIndex?.protocolVersion===H&&n.isProcessAlive(e.pid)&&Number.isFinite(i)&&n.now()-i<=ei&&(!e.processIdentity||r!=null&&je(e.processIdentity,r))}function Sa(e,t,n,r,i,o){let a=JSON.parse(e);if(a.protocolVersion!==H||a.id!==t||a.operationKey!==n||a.ok===!0&&a.baseGeneration!==r)throw new Error("TypeScript index service wrote an incompatible response.");if(a.ok!==!0){let s=typeof a.error=="string"?a.error:"TypeScript index service request failed.";throw Ld(s)?new We(s):new Error(s)}return Jn(Ra(a.response,i),i,o)}function Ld(e){let t=e.toLowerCase();return t.includes("out of memory")||t.includes("memory limit")||t.includes("allocation failed")||t.includes("err_worker_out_of_memory")}function Jn(e,t,n){if(e.producerIdentity!==t)throw new Error("TypeScript index service wrote an invalid response.");let r=[...new Set(n)].sort(),i=e.fragments.map(o=>o.relativePath).sort();if(JSON.stringify(i)!==JSON.stringify(r))throw new Error("TypeScript index service omitted or added an affected document.");return e}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(o=>{if(!o||typeof o.relativePath!="string"||o.bytesBase64!==null&&typeof o.bytesBase64!="string"||typeof o.occurrences!="number"||!Number.isInteger(o.occurrences)||o.occurrences<0||typeof o.symbols!="number"||!Number.isInteger(o.symbols)||o.symbols<0||!Array.isArray(o.referenceFragments)||!o.referenceFragments.every(Od)||r.has(o.relativePath))throw new Error("TypeScript index service wrote an invalid fragment.");r.add(o.relativePath);let a=o.bytesBase64===null?null:Dd(o.bytesBase64);return{relativePath:o.relativePath,bytes:a,occurrences:o.occurrences,symbols:o.symbols,referenceFragments:o.referenceFragments}});return{producerIdentity:n.producerIdentity,cold:n.cold,durationMs:n.durationMs,fragments:i}}function Od(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 Dd(e){let t=Buffer.from(e,"base64");if(t.toString("base64")!==e)throw new Error("TypeScript index service wrote invalid base64.");return t}function Md(){let e=Number(process.env.SCIP_TYPESCRIPT_INDEX_TIMEOUT_MS);return Number.isInteger(e)&&e>0?e:Ad}var Nd={now:Date.now,monotonicNow:C,randomId:_d,sleep(e){let t=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(t,0,0,e)},isProcessAlive:we,readProcessIdentity:Z};var Bd=128,$d=256;function Vd(e){let t=e.projectMode==="workspace"?e.workspaceProjects??[]:["."],n=xe(t);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 r=X(e.previousSnapshot,e.currentSnapshot);if(r.changes.length===0)return{eligible:!1,reason:"no changed project inputs"};let i=r.changes.filter(h=>h.inputKind==="source"&&Te(h.path)),o=Ia(r,n),a={...r,changes:o},s=i.filter(h=>h.kind==="added").map(h=>h.path),c=i.filter(h=>h.kind==="deleted").map(h=>h.path),u=i.filter(h=>h.kind==="modified"),l=Lt(e.currentSnapshot,e.producerIdentity,n),p=Lt(e.previousSnapshot,e.producerIdentity,n),d=wa(r,o,l,p),f=!d&&ka(r);if(i.length===0&&!d)return{eligible:!1,reason:"change does not affect the configured TypeScript project"};let m=e.currentSnapshot.files.filter(h=>Ye(h.path,e.currentSnapshot.languages)==="source"&&Te(h.path)).map(h=>h.path).sort(),y=new Set(m),E=d?e.projectFiles.filter(h=>!y.has(h)).sort():[...c].sort(),T=d?a:{...r,changes:i},v=d?{eligible:!0,plan:{...Ge(a,e.graph,[...new Set([...m,...E])]),mode:"full-project"}}:Gd(u,s,E,e.graph,e.projectFiles);if(!v.eligible)return v;let F=v.plan,_=new Set(E),b=Wd(F,t,e.graph,_);if(!b)return{eligible:!1,reason:"affected files cross or ambiguously match TypeScript projects"};let S=b.length===1?b[0]:void 0;return{eligible:!0,manifest:T,plan:F,projectIdentity:l,previousFragmentGeneration:e.previousOverlayGeneration??Pa(e.previousSnapshot,e.producerIdentity),nextFragmentGeneration:Pa(e.currentSnapshot,e.producerIdentity),projects:b,deletedFiles:E,replaceProject:d,dependencyGraphUnchanged:f,...S?{tsconfigPath:S.tsconfigPath,projectArgument:S.projectArgument}:{}}}function Ia(e,t){return e.changes.filter(n=>n.inputKind==="source"&&Te(n.path)||n.inputKind==="config"&&(!ve(n.path)||t.has(n.path))&&Ud(n)||n.inputKind==="ambient")}function Ud(e){return e.kind!=="modified"||e.before.semanticHash===void 0||e.after.semanticHash===void 0||e.before.semanticHash!==e.after.semanticHash}function wa(e,t,n,r){return n!==r||e.projectIdentityChanged||e.uncertainty.length>0||t.length>$d||t.some(i=>i.inputKind==="config"||i.inputKind==="ambient")}function Gd(e,t,n,r,i){if(e.length===0)return t.length===0&&n.length===0?{eligible:!1,reason:"empty affected set"}:{eligible:!0,plan:{mode:"closure",changedFiles:[...new Set([...t,...n])].sort(),affectedFiles:[...new Set([...t,...xa(n,r,i)])].sort(),reasons:[]}};let o=Ge({version:1,changes:e.filter(Ta),projectIdentityChanged:!1,uncertainty:[]},r,i);return o.mode==="full-project"?{eligible:!1,reason:o.reasons.length>0?`affected set widened: ${o.reasons.join(", ")}`:"empty affected set"}:{eligible:!0,plan:{mode:"closure",changedFiles:[...new Set([...e.map(a=>a.path),...t,...n])].sort(),affectedFiles:[...new Set([...o.affectedFiles,...e.map(a=>a.path),...t,...xa(n,r,i)])].sort(),reasons:[]}}}function Ta(e){return e.kind!=="modified"?!0:e.before.semanticHash===void 0||e.after.semanticHash===void 0||e.before.semanticHash!==e.after.semanticHash}function ka(e){let t=e.changes.filter(n=>n.inputKind==="source"&&Te(n.path));return t.length>0&&t.every(n=>n.kind==="modified"&&!Ta(n))}function Wd(e,t,n,r){let i=new Map;for(let a of e.affectedFiles){let s=qd(a,t);if(!s)return null;let c=i.get(s)??[];c.push(a),i.set(s,c)}let o=[];for(let[a,s]of[...i].sort(([c],[u])=>c.localeCompare(u))){let c=new Set(s),u=e.changedFiles.filter(d=>!r.has(d)&&(c.has(d)||s.some(f=>va(f,d,n)))),l=e.changedFiles.filter(d=>r.has(d)&&(c.has(d)||s.some(f=>va(f,d,n)))),p=s.filter(d=>!r.has(d));if(u.length===0&&l.length===0&&p.length===0)return null;o.push({projectArgument:a,tsconfigPath:a==="."?"tsconfig.json":`${a}/tsconfig.json`,modifiedFiles:u,removedFiles:l,affectedFiles:[...p].sort()})}return o}function xa(e,t,n){let r=new Set(n),i=new Map;for(let[s,c]of t)if(r.has(s))for(let u of c){let l=i.get(u)??new Set;l.add(s),i.set(u,l)}let o=new Set(e),a=[...e];for(let s=0;s<a.length;s+=1){let c=a[s];if(c)for(let u of i.get(c)??[])o.has(u)||(o.add(u),a.push(u))}return[...o].sort()}function qd(e,t){let n=t.filter(o=>o==="."||e===o||e.startsWith(`${o}/`));if(n.length===0)return null;let r=[...new Set(n)].sort((o,a)=>Ft(a)-Ft(o)||o.localeCompare(a)),i=r[0];return r[1]&&Ft(r[1])===Ft(i)?null:i}function Ft(e){return e==="."?0:e.split("/").filter(Boolean).length}function va(e,t,n){let r=new Set,i=[e];for(let o=0;o<i.length;o+=1){let a=i[o];if(!(!a||r.has(a))){r.add(a);for(let s of n.get(a)??[]){if(s===t)return!0;r.has(s)||i.push(s)}}}return!1}function _a(e){let t=C();try{if(!zn(e.previousDbPath)||!zn(e.previousShardPath))throw new Error("prior TypeScript graph or language shard unavailable");let n=performance.now(),r=Gn();if(!r.available)throw new Error(r.reason);let i=performance.now()-n;n=performance.now();let o=new G({projectRoot:e.projectRoot,dbPath:e.previousDbPath,indexPath:e.previousIndexPath}),a=Jd(e.projectRoot,e.previousSnapshot,e.currentSnapshot),s=e.projectMode==="workspace"?se(e.projectRoot,e.currentSnapshot.typescriptProjects):["."],c=xe(s),u,l,p;try{u=nt(o,{includeIgnored:!1}).filter(Te).sort();let k=a?X(a,e.currentSnapshot):null,g=k&&a&&wa(k,Ia(k,c),Lt(e.currentSnapshot,r.producerIdentity,c),Lt(a,r.producerIdentity,c)),x=k!==null&&!g&&ka(k);g?(p=it(o,"none")??void 0,l=new Map):x?l=new Map:(p=rt(o),l=p.graph)}finally{o.close()}let d=performance.now()-n,f=Vd({projectMode:e.projectMode,workspaceProjects:e.projectMode==="workspace"?s:void 0,previousSnapshot:a,currentSnapshot:e.currentSnapshot,projectFiles:u,graph:l,producerIdentity:r.producerIdentity,rootTsconfigExists:zn(jd(e.projectRoot,"tsconfig.json")),...e.previousOverlayGeneration===void 0?{}:{previousOverlayGeneration:e.previousOverlayGeneration}});if(!f.eligible)throw new Error(f.reason);let m=ma(e.previousDbPath);if(!m)throw new Error("published TypeScript base generation unavailable");n=performance.now();let y=new At({projectRoot:e.projectRoot,cacheDir:e.cacheDir,baseGeneration:m},{requireService:!0}),E=f.projects.flatMap(k=>{let g=Hd(k.affectedFiles,Bd);return(g.length>0?g:[[]]).map((D,Y)=>({project:k,affectedFiles:D,removedFiles:Y===0?k.removedFiles:[],firstForProject:Y===0}))}),T=[],v=new Map,F=[],_=!1,b=0,S=0,h=0,A=f.previousFragmentGeneration;for(let[k,g]of E.entries()){let x=y.request({kind:"emit-documents",tsconfigPath:g.project.tsconfigPath,projectArgument:g.project.projectArgument,projectIdentity:f.projectIdentity,producerIdentity:r.producerIdentity,modifiedFiles:g.firstForProject?g.project.modifiedFiles:[],removedFiles:g.firstForProject?g.project.removedFiles:[],affectedFiles:g.affectedFiles});_||=x.cold,F.push(x.durationMs);let D=g.removedFiles.map(ze=>({relativePath:ze,bytes:null,occurrences:0,symbols:0,referenceFragments:[]})),Y=[...x.fragments,...D];if(!f.replaceProject)for(let ze of Y)v.set(ze.relativePath,ze.referenceFragments);let qt=performance.now(),Ws=li(x.fragments);b+=performance.now()-qt;let pr=k===0?e.candidateAffectedScipPath:`${e.candidateAffectedScipPath}.batch-${k}.scip`,qs=performance.now();Ea(pr,Ws),h+=performance.now()-qs;let Hs=performance.now(),fr=k===E.length-1?f.nextFragmentGeneration:zd({previousGenerationIdentity:A,targetGenerationIdentity:f.nextFragmentGeneration,fragments:Y});pi({cacheDir:e.cacheDir,previousGenerationIdentity:A,nextGenerationIdentity:fr,producerIdentity:r.producerIdentity,projectIdentity:f.projectIdentity,baseShardCurrent:k===0?e.baseShardCurrent:!1,fragments:Y,allowProjectIdentityChange:f.replaceProject&&k===0,allowLegacyProjectIdentityMigration:!0}),S+=performance.now()-Hs,A=fr,T.push({scipPath:pr,affectedFiles:[...g.affectedFiles,...g.removedFiles].sort(),deletedFiles:[...g.removedFiles].sort()})}let R=performance.now()-n,P={scipPath:e.previousShardPath,candidateScipPath:e.candidateShardPath,affectedScipPath:e.candidateAffectedScipPath,affectedBatches:T,completeScipUpdated:!1,durationMs:C()-t,cold:_,changedFiles:f.plan.changedFiles,affectedFiles:f.plan.affectedFiles,deletedFiles:f.deletedFiles,producerIdentity:r.producerIdentity,previousFragmentGeneration:f.previousFragmentGeneration,nextFragmentGeneration:f.nextFragmentGeneration,manifest:f.manifest,plan:f.plan,projectFileCount:u.length,dependencyGraphSnapshot:p,dependencyGraphUnchanged:f.dependencyGraphUnchanged,referenceFragmentsByFile:v,timings:{runtimeMs:i,graphMs:d,requestMs:R,serviceMs:F.reduce((k,g)=>k+g,0),assemblyMs:b,fragmentStoreMs:S,writeMs:h}};return e.onStatus(`${f.replaceProject?"Bounded TypeScript project refresh":"Incremental TypeScript index"} emitted ${P.affectedFiles.length-P.deletedFiles.length} document(s), removed ${P.deletedFiles.length}, and produced ${T.length} bounded batch(es) across ${f.projects.length} project(s) in ${(P.durationMs/1e3).toFixed(3)}s (${P.cold?"cold":"warm"} service; whole SCIP deferred; runtime ${i.toFixed(0)}ms, graph ${d.toFixed(0)}ms, request ${R.toFixed(0)}ms, assembly ${b.toFixed(0)}ms, fragments ${S.toFixed(0)}ms, write ${h.toFixed(0)}ms).`),P}catch(n){let r=n instanceof Error?n.message:String(n);if(e.onUnavailable?.(r),n instanceof We)throw e.onStatus(`Incremental TypeScript index stopped after memory pressure survived one cold Worker retry: ${r}. Preserving the accepted index instead of starting a memory-heavier whole-project rebuild.`),n;return e.onStatus(`Incremental TypeScript index unavailable: ${r}.`),null}}function Hd(e,t){let n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return n}function Jd(e,t,n){if(!t)return null;let r=new Map(n.files.map(a=>[a.path,a])),i=!1,o=t.files.map(a=>{let s=r.get(a.path);if(a.semanticHash!==void 0||s?.semanticHash===void 0)return a;let c=et(e,a.path,a.hash);return c===void 0?a:(i=!0,{...a,semanticHash:c})});return i?{...t,files:o}:t}function zd(e){let t=Yn("sha256");t.update("typescript-overlay-batch-v1\0"),t.update(e.previousGenerationIdentity),t.update("\0"),t.update(e.targetGenerationIdentity);for(let n of[...e.fragments].sort((r,i)=>r.relativePath.localeCompare(i.relativePath)))t.update("\0path\0"),t.update(n.relativePath),n.bytes===null?t.update("\0deleted"):(t.update("\0bytes\0"),t.update(Yn("sha256").update(n.bytes).digest()));return t.digest("hex")}function Xn(e){let t=Gn();if(!t.available)throw new Error(t.reason);let n=fi({cacheDir:e.cacheDir,generationIdentity:e.generationIdentity,baseIndexBytes:K(e.baseShardPath,{inputKind:"TypeScript base SCIP shard",maxBytes:Xe}),packageVersion:t.packageVersion});Ea(e.candidateShardPath,n)}function Lt(e,t,n){let r=e.files.filter(i=>{let o=Ye(i.path,e.languages);return o==="ambient"||o==="config"&&(!ve(i.path)||n.has(i.path))}).map(i=>{let a=Ye(i.path,e.languages)==="config"?i.semanticHash:void 0;return{path:i.path,size:a===void 0?i.size:0,hash:a??i.hash}}).sort((i,o)=>i.path.localeCompare(o.path));return`typescript-project-v3:${Ca(JSON.stringify({version:3,producerIdentity:t,pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:[...e.typescriptProjects].sort(),nonSourceInputs:r}))}`}function Pa(e,t){return Ca(JSON.stringify({version:1,producerIdentity:t,snapshot:mr(e)}))}function Ca(e){return Yn("sha256").update(e).digest("hex")}import{closeSync as Yd,existsSync as Ot,fstatSync as Xd,lstatSync as Kd,openSync as Qd,renameSync as Zn,rmSync as qe,statSync as Zd,writeSync as ep}from"fs";import{cpus as tp}from"os";import{join as er}from"path";var Kn=Symbol("no-error");async function Aa(e,t,n){if(e.length===0)return[];let r=new Array(e.length),i=Number.isFinite(t)?Math.max(1,Math.floor(t)):1,o=Math.min(e.length,i),a=0,s=Kn,c=!0,u=Array.from({length:o},async()=>{for(;c&&a<e.length;){let l=a++;try{r[l]=await n(e[l])}catch(p){s===Kn&&(s=p),c=!1}}});if(await Promise.all(u),s!==Kn)throw s;return r}var Fa=8*1024;function La(e,t,n){let r=Buffer.from(t,"utf8"),i=()=>Qd(e,"wx",384),o;try{o=i()}catch(a){if(a.code!=="EEXIST")throw a;if(n==="skip")return null;qe(e,{force:!0}),o=i()}try{ep(o,r);let a=Xd(o);return{path:e,content:r,device:a.dev,inode:a.ino}}finally{Yd(o)}}function np(e,t){let n=[];try{if(e.temporaryRootConfigContent!==void 0){let r=La(er(t,"tsconfig.json"),e.temporaryRootConfigContent,"skip");r&&n.push(r)}for(let r of e.temporaryProjectConfigs??[]){let i=La(r.path,r.content,"replace");i&&n.push(i)}return n}catch(r){for(let i of n.reverse())Ma(i);throw r}}function Ma(e){if(e)try{let t=Kd(e.path);if(!t.isFile()||t.dev!==e.device||t.ino!==e.inode||t.size!==e.content.byteLength)return;let n;try{n=K(e.path,{maxBytes:e.content.byteLength,inputKind:"temporary TypeScript index configuration"})}catch{return}if(!n.equals(e.content))return;qe(e.path)}catch(t){if(t.code!=="ENOENT")throw t}}function rp(e,t,n){if(!e.defaultOutputPath)return;let r=er(t,e.defaultOutputPath);n!==r&&Ot(r)&&Zn(r,n)}function ip(e,t,n){if(!e.defaultOutputPath)return null;let r=er(t,e.defaultOutputPath);if(r===n)return null;let i=`${n}.default-output-backup`;return qe(i,{force:!0}),Ot(r)?(Zn(r,i),{defaultOutputPath:r,backupPath:i}):{defaultOutputPath:r,backupPath:null}}function op(e){e&&(qe(e.defaultOutputPath,{force:!0}),e.backupPath&&Ot(e.backupPath)&&Zn(e.backupPath,e.defaultOutputPath))}function ap(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,tp().length));return Math.max(1,Math.min(e,Math.floor(r)))}async function Na(e,t,n,r,i){V(i,"Reindex cancelled by its owner.");let o=e.filter(u=>u.config.defaultOutputPath),a=e.filter(u=>!u.config.defaultOutputPath&&u.boundedConcurrency!==void 0),s=e.filter(u=>!u.config.defaultOutputPath&&u.boundedConcurrency===void 0),c=[];if(c.push(...await Oa(s,ap(s.length,r),t,n,i)),a.length>0){let u=Math.max(1,Math.min(...a.map(l=>l.boundedConcurrency)));c.push(...await Oa(a,u,t,n,i))}for(let u of o)V(i,"Reindex cancelled by its owner."),c.push((await Qn(u,t,n,i)).result);return c.sort((u,l)=>e.findIndex(p=>p.id===u.id)-e.findIndex(p=>p.id===l.id))}async function Oa(e,t,n,r,i){let o=await Aa(e,Math.max(1,t),s=>Qn(s,n,r,i));if(t<=1)return o.map(({result:s})=>s);let a=new Map;for(let s of o.filter(c=>c.result.skipped&&c.retryable)){let c=e.find(u=>u.id===s.result.id);c&&(r(`Retrying ${c.label} indexer serially after parallel failure...`),V(i,"Reindex cancelled by its owner."),a.set(c.id,(await Qn(c,n,r,i)).result))}return o.map(({result:s})=>a.get(s.id)??s)}async function Qn(e,t,n,r){V(r,"Reindex cancelled by its owner."),n(`Indexing ${e.label} with ${e.resolvedBinary}...`),qe(e.scipPath,{force:!0});let i=ip(e.config,t,e.scipPath),o=[],a=[e.binary,...e.args].join(" "),s=C();try{o=np(e,t),e.trustedProjectTool&&zr(t,e.trustedProjectTool);let u=Gr(e.binary,e.args),l=await gt({command:u.binary,args:u.args,label:`${e.label} indexer`,cwd:t,env:e.env,timeoutMs:sp(),maxStdoutBytes:50*1024*1024,maxStderrBytes:50*1024*1024,signal:r});if(l.status!==0){let p=l.stderr.trim();throw new Error(`${e.resolvedBinary} exited with status ${l.status}${p?`:
|
|
303
|
-
${p}`:""}`)}rp(e.config,t,e.scipPath)}catch(u){if(r?.aborted)throw ri(r,"Reindex cancelled by its owner.");let l=u instanceof Error?u.message:String(u),p=l.length<=Fa?l:`${l.slice(0,Fa)}
|
|
304
|
-
[indexer failure detail truncated]`,d=`${e.resolvedBinary} indexer failed: ${p}`,f=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:C()-s,command:a,...e.outputComposition?{outputComposition:e.outputComposition}:{},skipped:{language:e.language,reason:f}},retryable:cp(u)}}finally{op(i);for(let u of o.reverse())Ma(u)}if(!Ot(e.scipPath)){let u=`${e.resolvedBinary} indexer completed but did not produce ${e.scipPath}`,l=e.label===e.language?u:`${e.label}: ${u}`;return n(`Skipping ${e.label}: ${u}`),{result:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:C()-s,command:a,...e.outputComposition?{outputComposition:e.outputComposition}:{},skipped:{language:e.language,reason:l}},retryable:!1}}let c;try{c=Zd(e.scipPath).size}catch{c=void 0}return{result:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:C()-s,command:a,...e.outputComposition?{outputComposition:e.outputComposition}:{},outputBytes:c},retryable:!1}}function sp(){let e=Number(process.env.SCIP_QUERY_INDEXER_TIMEOUT_MS);return Number.isFinite(e)&&e>0?Math.floor(e):Ti.indexer}function cp(e){return e instanceof ki?e.kind==="spawn"&&Da(e.cause):Da(e)}function Da(e){let t=e?.code;return t==="EAGAIN"||t==="ENOMEM"||t==="EMFILE"||t==="ENFILE"||t==="ETXTBSY"}import{execFileSync as Ba}from"child_process";import{homedir as ja,platform as up}from"os";import{delimiter as lp,join as Dt}from"path";function $a(e,t){let n=e.installMethods,r=ot(e);if(!n?.length)return t(`No auto-install method available for ${r}.`),e.installUrl&&t(`Install manually from: ${e.installUrl}`),!1;for(let i of n){if(!i.identity||!i.destination){t(`Refusing ${i.label} installation for ${r}: the installer descriptor lacks an immutable identity or destination.`);continue}if(!Ee(i.prerequisite))continue;let o=dp(i);t(`Installing immutable ${i.identity} via ${i.label} into ${o}; expected executable: ${r}.`);try{Ba(i.binary,i.args,{stdio:"inherit",timeout:3e5,env:process.env,shell:up()==="win32"});let a=Ne(e);if(a){let s=a===e.indexerBinary?"":` (using ${a})`;return t(`Successfully installed ${i.identity} via ${i.label}${s}; resolved executable: ${a}.`),!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}function dp(e){if(e.binary==="npm")return tr("npm",["root","-g"])??e.destination;if(e.binary==="go"){let t=tr("go",["env","GOBIN"]);if(t)return t;let n=tr("go",["env","GOPATH"]);if(n)return Dt(n.split(lp)[0],"bin")}return e.binary==="dotnet"?Dt(process.env.DOTNET_CLI_HOME??ja(),".dotnet","tools"):e.binary==="dart"?Dt(process.env.PUB_CACHE??Dt(ja(),".pub-cache"),"bin"):e.destination}function tr(e,t){try{return Ba(e,t,{stdio:["ignore","pipe","ignore"],encoding:"utf8",timeout:1e4,killSignal:"SIGKILL",env:process.env}).trim()||null}catch{return null}}import of from"better-sqlite3";import{existsSync as af}from"fs";import{dirname as sf,join as cf,resolve as uf}from"path";import{randomUUID as fp}from"crypto";import{mkdtempSync as gp,rmSync as mp,statSync as Ua}from"fs";import{tmpdir as hp}from"os";import{join as Ga}from"path";import{Worker as yp}from"worker_threads";function pp(){return{"missing-source-file":0,"missing-service-script":0,"no-definition":0,"same-file-definition":0,"unindexed-definition":0}}function Me(){return{skippedReferences:0,skippedReferenceReasons:pp(),skippedReferenceSamples:[]}}function Mt(e,t){e.skippedReferences+=t.skippedReferences;for(let n of Object.keys(e.skippedReferenceReasons)){e.skippedReferenceReasons[n]+=t.skippedReferenceReasons[n];for(let r of t.skippedReferenceSamples.filter(i=>i.reason===n))e.skippedReferenceSamples.filter(o=>o.reason===n&&o.sourceFile===r.sourceFile).length<2&&e.skippedReferenceSamples.push(r)}}var bp=3e5,Wa=64*1024*1024,Sp={createResultDirectory:()=>gp(Ga(hp(),"scip-query-vue-workers-")),spawn:(e,t)=>new yp(e,{workerData:t}),resultSize:e=>Ua(e).size,readResult:e=>$(e,{maxBytes:Wa,inputKind:"Vue worker result"}),removeResultDirectory:e=>mp(e,{recursive:!0,force:!0})};function qa(e){return e.length>=8&&Ja(e.length)>1}async function Ha(e,t=Sp){let n=Ja(e.vueFiles.length),r=Fp(e.vueFiles),i=Op(r,n),o=new URL("./augment-vue-worker.js",import.meta.url),a=e.timeoutMs??Cp(),s=e.maxResultBytes??Ap();Va("timeoutMs",a),Va("maxResultBytes",s);let c=fp(),u=t.createResultDirectory(),l=[],p,d,f;try{for(let y=0;y<i.length;y++){let E=y,T=i[y]??[],v=T.map(b=>b.taskId),F=Ga(u,`${E}.json`),_=t.spawn(o,{projectRoot:e.projectRoot,dbPath:e.dbPath,tsconfig:e.tsconfig,tasks:T,resultPath:F,runId:c,workerId:E,taskIds:v});l.push({workerId:E,taskIds:v,resultPath:F,handle:_,completion:Rp(_,E)})}await xp(l,a);let m=l.sort((y,E)=>y.workerId-E.workerId).map(y=>Pp(y,c,s,t));f={occurrences:m.flatMap(y=>y.occurrences),...Me()};for(let y of m)Mt(f,y)}catch(m){p=m}finally{let m=await vp(l);if(m.length===0)try{t.removeResultDirectory(u)}catch(y){m.push(y)}if(m.length>0){let y=p===void 0?m:[p,...m];d=new AggregateError(y,`Vue worker cleanup failed: ${_p(y[0])}`)}}if(d)throw d;if(p!==void 0)throw p;if(!f)throw new Error("Vue workers completed without producing a merged result.");return f}function Rp(e,t){return new Promise((n,r)=>{let i=!1,o=c=>{i||(i=!0,e.off("error",a),e.off("exit",s),c?r(c):n())},a=c=>{o(new Error(`Vue reference worker ${t} failed: ${c.message}`,{cause:c}))},s=c=>{o(c===0?void 0:new Error(`Vue reference worker ${t} exited with code ${c}`))};e.once("error",a),e.once("exit",s)})}async function xp(e,t){let n;try{await Promise.race([Promise.all(e.map(r=>r.completion)),new Promise((r,i)=>{n=setTimeout(()=>i(new Error(`Vue reference workers timed out after ${(t/1e3).toFixed(3)}s`)),t),n.unref()})])}finally{n&&clearTimeout(n)}}async function vp(e){return(await Promise.allSettled(e.map(async n=>n.handle.terminate()))).flatMap(n=>n.status==="rejected"?[n.reason]:[])}function Pp(e,t,n,r){let i=r.resultSize(e.resultPath);if(!Number.isSafeInteger(i)||i<0||i>n)throw new Error(`Vue reference worker ${e.workerId} result is ${i} bytes; limit is ${n} bytes`);let o;try{o=JSON.parse(r.readResult(e.resultPath))}catch(a){throw new Error(`Vue reference worker ${e.workerId} produced invalid JSON`,{cause:a})}if(!He(o)||o.version!==1||o.runId!==t||o.workerId!==e.workerId)throw new Error(`Vue reference worker ${e.workerId} result identity does not match its assignment`);if(!kp(o.taskIds,e.taskIds))throw new Error(`Vue reference worker ${e.workerId} result task identities do not match its assignment`);if(o.ok===!1)throw typeof o.error!="string"?new Error(`Vue reference worker ${e.workerId} failure payload is malformed`):new Error(`Vue reference worker ${e.workerId} failed: ${o.error}`);if(o.ok!==!0||!Ep(o.result))throw new Error(`Vue reference worker ${e.workerId} success payload is malformed`);return o.result}function Ep(e){if(!He(e)||!Array.isArray(e.occurrences)||!e.occurrences.every(Ip)||!J(e.skippedReferences)||!He(e.skippedReferenceReasons))return!1;for(let t of["missing-source-file","missing-service-script","no-definition","same-file-definition","unindexed-definition"])if(!J(e.skippedReferenceReasons[t]))return!1;return Array.isArray(e.skippedReferenceSamples)&&e.skippedReferenceSamples.every(wp)}function Ip(e){return He(e)&&typeof e.sourceFile=="string"&&J(e.sourceLine)&&J(e.sourceStartChar)&&J(e.sourceEndChar)&&typeof e.sourceToken=="string"&&typeof e.definitionFile=="string"&&J(e.symbolId)}function wp(e){return He(e)&&typeof e.sourceFile=="string"&&J(e.sourceLine)&&J(e.sourceStartChar)&&J(e.sourceEndChar)&&typeof e.token=="string"&&Tp(e.reason)}function Tp(e){return e==="missing-source-file"||e==="missing-service-script"||e==="no-definition"||e==="same-file-definition"||e==="unindexed-definition"}function J(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>=0}function He(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function kp(e,t){return Array.isArray(e)&&e.length===t.length&&e.every((n,r)=>typeof n=="string"&&n===t[r])}function Va(e,t){if(!Number.isSafeInteger(t)||t<=0)throw new TypeError(`${e} must be a positive safe integer.`)}function _p(e){return e instanceof Error?e.message:String(e)}function Ja(e){let t=Number(process.env.SCIP_QUERY_AUGMENT_VUE_WORKERS??0),n=Number.isFinite(t)&&t>0?t:1;return Math.max(1,Math.min(e,n))}function Cp(){let e=Number(process.env.SCIP_QUERY_AUGMENT_VUE_WORKER_TIMEOUT_MS??0);return Number.isFinite(e)&&e>0?e:bp}function Ap(){let e=Number(process.env.SCIP_QUERY_AUGMENT_VUE_WORKER_RESULT_MAX_BYTES??0);return Number.isSafeInteger(e)&&e>0?e:Wa}function Fp(e){let t=Lp(),n=[];for(let r of e){let i=za(r),o=Math.max(1,Math.ceil(i/t));for(let a=0;a<o;a++)n.push({taskId:`${n.length}:${r}:${a}`,fileName:r,startOffset:Math.floor(i*a/o),endOffset:a===o-1?Number.POSITIVE_INFINITY:Math.floor(i*(a+1)/o),countFileSkip:a===0})}return n}function Lp(){return Number.POSITIVE_INFINITY}function Op(e,t){let n=Array.from({length:t},()=>({tasks:[],weight:0})),r=e.map(i=>({task:i,weight:Dp(i)})).sort((i,o)=>o.weight-i.weight);for(let i of r){let o=n.reduce((a,s)=>s.weight<a.weight?s:a);o.tasks.push(i.task),o.weight+=i.weight}return n.map(i=>i.tasks).filter(i=>i.length>0)}function Dp(e){return Number.isFinite(e.endOffset)?Math.max(1,e.endOffset-e.startOffset):Math.max(1,za(e.fileName)-e.startOffset)}function za(e){try{return Ua(e).size}catch{return 1}}import{createRequire as Mp}from"module";import{existsSync as Np}from"fs";import{dirname as Ya,extname as jp,join as Xa,relative as Bp,resolve as $p}from"path";import{pathToFileURL as Vp}from"url";function Up(e){e.transaction(()=>{e.prepare(`
|
|
305
|
-
DELETE FROM mentions
|
|
306
|
-
WHERE chunk_id IN (
|
|
307
|
-
SELECT c.id
|
|
308
|
-
FROM chunks c
|
|
309
|
-
JOIN documents d ON d.id = c.document_id
|
|
310
|
-
WHERE d.language = 'vue' OR d.relative_path LIKE '%.vue'
|
|
311
|
-
)
|
|
312
|
-
`).run(),e.prepare(`
|
|
313
|
-
DELETE FROM chunks
|
|
314
|
-
WHERE document_id IN (
|
|
315
|
-
SELECT id
|
|
316
|
-
FROM documents
|
|
317
|
-
WHERE language = 'vue' OR relative_path LIKE '%.vue'
|
|
318
|
-
)
|
|
319
|
-
`).run()})()}function Ka(e,t){return e.prepare(`
|
|
320
|
-
SELECT relative_path AS relativePath
|
|
321
|
-
FROM documents
|
|
322
|
-
WHERE language = 'vue' OR relative_path LIKE '%.vue'
|
|
323
|
-
ORDER BY relative_path
|
|
324
|
-
`).all().map(r=>$p(t,r.relativePath))}function Qa(e,t){let{vueCore:n,ts:r,volarTs:i}=Gp(e),{parsed:o,vueOptions:a}=Wp(n,r,t),s=Ya(t),c=n.createVueLanguagePlugin(r,o.options,a,f=>f),u=qp(n,r,c),l=Hp(s,o),{languageServiceHost:p}=i.createLanguageServiceHost(r,r.sys,u,f=>f,l),d=r.createLanguageService(p);return{ts:r,language:u,languageService:d,fileNames:o.fileNames,configDir:s}}function Gp(e){let t=Mp(Vp(Xa(e,"package.json")).href);return{vueCore:nr(t,"@vue/language-core",e),ts:nr(t,"typescript",e),volarTs:nr(t,"@volar/typescript",e)}}function Wp(e,t,n){let r=t.readConfigFile(n,t.sys.readFile);if(r.error||!r.config)throw new Error(`Failed to read ${n}`);let o=e.createParsedCommandLine(t,t.sys,n).vueOptions;return typeof e.createGlobalTypesWriter=="function"&&(o.globalTypesPath=e.createGlobalTypesWriter(o,t.sys.writeFile)),{parsed:t.parseJsonConfigFileContent(r.config,t.sys,Ya(n),void 0,n,void 0,e.getAllExtensions(o).map(a=>({extension:a.slice(1),isMixedContent:!0,scriptKind:t.ScriptKind.Deferred}))),vueOptions:o}}function qp(e,t,n){let r={},i=e.createLanguage([n],new Map,o=>{if(!Np(o))return;let a=$(o,{maxBytes:zt,inputKind:"Vue language-service source file"});r.current?.scripts.set(o,t.ScriptSnapshot.fromString(a),n.getLanguageId(o)??Qp(o))});return r.current=i,i}function Hp(e,t){return{getCurrentDirectory:()=>e,getCompilationSettings:()=>t.options,getScriptFileNames:()=>t.fileNames,getProjectReferences:()=>t.projectReferences,getProjectVersion:()=>"0"}}function nr(e,t,n){try{return e(t)}catch(r){throw(typeof r=="object"&&r!==null&&"code"in r?r.code:null)==="MODULE_NOT_FOUND"?new Error(`Vue augmentation requires ${t} to be installed in ${n}. Install Vue/Volar dependencies for that project, then rerun augment-vue.`,{cause:r}):r}}function Za(e,t,n){let r=Jp(e);return i=>{if(!i.name)return null;let o=z(t,i.fileName),a=n.get(i.fileName);if(!a)return null;let s=n.positionAt(a,i.textSpan.start),c=r.get(o);if(!c)return null;let u=c.starts.find(p=>p.line===s.line&&p.displayName===i.name);if(u)return u.symbolId;let l=c.containingByLine.get(s.line);return l&&l.displayName===i.name?l.symbolId:zp(c.starts,s.line,2,i.name)}}function Jp(e){let t=e.prepare(`
|
|
325
|
-
SELECT
|
|
326
|
-
d.relative_path AS relativePath,
|
|
327
|
-
der.start_line AS startLine,
|
|
328
|
-
der.end_line AS endLine,
|
|
329
|
-
der.symbol_id AS symbolId,
|
|
330
|
-
gs.display_name AS displayName
|
|
331
|
-
FROM defn_enclosing_ranges der
|
|
332
|
-
JOIN documents d ON d.id = der.document_id
|
|
333
|
-
JOIN global_symbols gs ON gs.id = der.symbol_id
|
|
334
|
-
ORDER BY d.relative_path, (der.end_line - der.start_line) DESC
|
|
335
|
-
`).all(),n=new Map;for(let r of t){let i=n.get(r.relativePath);i||(i={containingByLine:new Map,starts:[]},n.set(r.relativePath,i)),i.starts.push({line:r.startLine,symbolId:r.symbolId,displayName:r.displayName});for(let o=r.startLine;o<=r.endLine;o++)i.containingByLine.set(o,{symbolId:r.symbolId,displayName:r.displayName})}for(let r of n.values())r.starts.sort((i,o)=>i.line-o.line);return n}function zp(e,t,n,r){let i=0,o=e.length-1;for(;i<=o;){let s=Math.floor((i+o)/2);e[s].line<t?i=s+1:o=s-1}let a=null;for(let s of[o,i]){let c=e[s];if(!c||c.displayName!==r)continue;let u=Math.abs(c.line-t);u>n||(!a||u<a.distance)&&(a={distance:u,symbolId:c.symbolId})}return a?.symbolId??null}function es(e,t,n){let r=tf(t),i=e.prepare("SELECT id FROM global_symbols WHERE symbol = ?"),o=e.prepare(`
|
|
336
|
-
INSERT OR IGNORE INTO global_symbols (symbol, display_name, kind, documentation)
|
|
337
|
-
VALUES (?, ?, ?, ?)
|
|
338
|
-
`),a=0,s=new Map;return e.transaction(()=>{for(let u of n){let l=z(t,u),p=us(r.name,r.version,l);o.run(p,"default",7,`Vue component|${l}`);let d=nf(i,r,t,u);d&&(a++,s.set(u,d))}})(),{get(u){return s.get(u)??null},syntheticSymbols:a}}function ts(e,t,n,r,i){return e.transaction(()=>(Up(e),Yp(e,t,n,r),Xp(e,i)))()}function Yp(e,t,n,r){let i=e.prepare("SELECT id FROM documents WHERE relative_path = ?"),o=e.prepare(`
|
|
339
|
-
INSERT INTO chunks (document_id, chunk_index, start_line, end_line, occurrences)
|
|
340
|
-
VALUES (?, ?, ?, ?, X'00')
|
|
341
|
-
`),a=e.prepare(`
|
|
342
|
-
INSERT OR IGNORE INTO mentions (chunk_id, symbol_id, role)
|
|
343
|
-
VALUES (?, ?, 1)
|
|
344
|
-
`);for(let s of n){let c=r.get(s);if(!c)continue;let u=z(t,s),l=i.get(u);if(!l)continue;let p=o.run(l.id,-1,0,0);a.run(Number(p.lastInsertRowid),c)}}function ns(e,t,n,r,i){if(e.fileName.endsWith(".vue")){let o=r.language.scripts.get(e.fileName),a=o?.generated?.languagePlugin.typescript?.getServiceScript(o.generated.root)?.code;if(o&&a){let s=r.language.maps.get(a,o);if(rr(s,e.textSpan.start)!==null)return n.get(e.fileName)}return e.fileName.startsWith(i)?n.get(e.fileName):null}return t(e)}function rs(e){let t=new Set,n=[];for(let r of e){let i=is(r);t.has(i)||(t.add(i),n.push(r))}return n}function is(e){return[e.sourceFile,e.sourceLine,e.sourceStartChar,e.sourceEndChar,e.symbolId].join(":")}function Xp(e,t){let n=ef(e,[...new Set(t.map(c=>c.sourceFile))]),r=e.prepare(`
|
|
345
|
-
INSERT INTO chunks (document_id, chunk_index, start_line, end_line, occurrences)
|
|
346
|
-
VALUES (?, ?, ?, ?, X'00')
|
|
347
|
-
`),i=e.prepare(`
|
|
348
|
-
INSERT OR IGNORE INTO mentions (chunk_id, symbol_id, role)
|
|
349
|
-
VALUES (?, ?, 0)
|
|
350
|
-
`),o=new Set,a=0,s=0;for(let c of t){let u=is(c);if(o.has(u))continue;o.add(u);let l=n.get(c.sourceFile);if(!l)continue;let p=r.run(l,s++,c.sourceLine,c.sourceLine),d=i.run(Number(p.lastInsertRowid),c.symbolId);a+=Number(d.changes)}return a}function*os(e){let t=/\b[A-Za-z_$][A-Za-z0-9_$]*\b/g,n=new Set(["script","setup","template","style","lang","scoped","true","false","null","undefined","const","let","var","import","from","export","return","if","else","for","while","function","class","type","interface","as","await","async"]),r;for(;r=t.exec(e);){let i=r[0];n.has(i)||(yield{text:i,start:r.index,end:r.index+i.length})}}function as(e,t){for(let[n]of e.toGeneratedLocation(t,r=>!!r.navigation))return n;return null}function rr(e,t){let n=e;for(let[r]of n.toSourceLocation(t,i=>!!i.navigation))return r;return null}function Kp(e,t){let n=0,r=e.lineStarts.length-1;for(;n<=r;){let o=Math.floor((n+r)/2);e.lineStarts[o]<=t?n=o+1:r=o-1}let i=Math.max(0,r);return{line:i,character:t-e.lineStarts[i]}}function ss(e,t){return z(e,t).startsWith("node_modules/")}function z(e,t){return Bp(e,t).replaceAll("\\","/")}function Qp(e){switch(jp(e)){case".vue":return"vue";case".tsx":return"typescriptreact";case".ts":case".mts":case".cts":return"typescript";case".jsx":return"javascriptreact";case".js":case".mjs":case".cjs":return"javascript";case".json":return"json";default:return"typescript"}}function cs(){let e=new Map;return{get(t){if(e.has(t))return e.get(t)??null;try{let n=$(t,{maxBytes:zt,inputKind:"Vue source file"}),r={text:n,lineStarts:Zp(n)};return e.set(t,r),r}catch{return e.set(t,null),null}},positionAt:Kp}}function Zp(e){let t=[0];for(let n=0;n<e.length;n++)e.charCodeAt(n)===10&&t.push(n+1);return t}function ef(e,t){let n=new Map,r=500;for(let i=0;i<t.length;i+=r){let o=t.slice(i,i+r),a=e.prepare(`SELECT id, relative_path AS relativePath FROM documents WHERE relative_path IN (${o.map(()=>"?").join(",")})`).all(...o);for(let s of a)n.set(s.relativePath,s.id)}return n}function tf(e){try{let t=JSON.parse($(Xa(e,"package.json"),{maxBytes:Re,inputKind:"project package manifest"}));return{name:t.name??"workspace",version:t.version??"0.0.0"}}catch{return{name:"workspace",version:"0.0.0"}}}function nf(e,t,n,r){let i=z(n,r),o=us(t.name,t.version,i);return e.get(o)?.id??null}function us(e,t,n){let r=n.split("/").map(i=>`\`${i.replaceAll("`","")}\``).join("/");return`scip-vue npm ${e} ${t} ${r}/default.`}async function lf(e){return Ae(me(),{projectRoot:e.projectRoot,dbPath:e.dbPath}),df(e)}async function df(e){let t=uf(e.projectRoot,e.tsconfig);if(!af(t))throw new Error(`Vue tsconfig not found at ${t}`);let n=new of(e.dbPath);try{let r=Ka(n,e.projectRoot),i=cf(sf(e.dbPath),"augment-vue-meta.json");return await Po({cachePath:i,readFingerprint:()=>mf(n,e.projectRoot,e.tsconfig),compute:()=>pf({db:n,projectRoot:e.projectRoot,dbPath:e.dbPath,tsconfig:e.tsconfig,configPath:t,vueFiles:r,onStatus:e.onStatus}),onCacheHit:o=>e.onStatus?.(`Vue references unchanged; reused ${o.resolvedReferences} cached resolved references.`)})}finally{n.close()}}async function pf(e){let t=es(e.db,e.projectRoot,e.vueFiles),n=qa(e.vueFiles)?await Ha({projectRoot:e.projectRoot,dbPath:e.dbPath,tsconfig:e.tsconfig,vueFiles:e.vueFiles}):gf(e,t);return ff(e,t,n)}function ff(e,t,n){let r=rs(n.occurrences),i=ts(e.db,e.projectRoot,e.vueFiles,t,r),o={vueFiles:e.vueFiles.length,resolvedReferences:r.length,resolvedReferenceSamples:Ef(e.db,r,20),insertedMentions:i,skippedReferences:n.skippedReferences,skippedReferenceReasons:n.skippedReferenceReasons,skippedReferenceSamples:Pf(n.skippedReferenceSamples,20),syntheticSymbols:t.syntheticSymbols};return e.onStatus?.(`Resolved ${o.resolvedReferences} Vue references with Volar; inserted ${o.insertedMentions} mentions.`),o}function gf(e,t){let n=hf({db:e.db,projectRoot:e.projectRoot,configPath:e.configPath,vueSymbolLookup:t});return yf({...n,vueFiles:n.context.fileNames.filter(r=>r.endsWith(".vue"))})}function mf(e,t,n){let r=e.prepare(`
|
|
351
|
-
SELECT
|
|
352
|
-
(SELECT COUNT(*) FROM documents) AS documents,
|
|
353
|
-
(SELECT COUNT(*) FROM global_symbols) AS symbols,
|
|
354
|
-
(SELECT COUNT(*) FROM chunks) AS chunks,
|
|
355
|
-
(SELECT COUNT(*) FROM mentions) AS mentions,
|
|
356
|
-
(SELECT COUNT(*) FROM defn_enclosing_ranges) AS ranges,
|
|
357
|
-
(SELECT MAX(id) FROM chunks) AS maxChunkId,
|
|
358
|
-
(SELECT MAX(id) FROM global_symbols) AS maxSymbolId
|
|
359
|
-
`).get();return{version:3,tsconfig:n,files:vr(t),db:r}}function hf(e){let t=cs();return{projectRoot:e.projectRoot,context:Qa(e.projectRoot,e.configPath),symbolLookup:Za(e.db,e.projectRoot,t),vueSymbolLookup:e.vueSymbolLookup,sourceReader:t}}function yf(e){let t=[],n=Me(),r=e.tasks??e.vueFiles.map(i=>({fileName:i,startOffset:0,endOffset:Number.POSITIVE_INFINITY,countFileSkip:!0}));for(let i of r){let o=bf(e,i);t.push(...o.occurrences),Mt(n,o)}return{occurrences:t,...n}}function bf(e,t){let n=e.sourceReader.get(t.fileName);if(!n)return ls(e.projectRoot,t,"missing-source-file");let r=e.context.language.scripts.get(t.fileName),i=r?.generated?.languagePlugin.typescript?.getServiceScript(r.generated.root)?.code;if(!r||!i)return ls(e.projectRoot,t,"missing-service-script");let o=e.context.language.maps.get(i,r),a=z(e.projectRoot,t.fileName),s=[...os(n.text)],c={tokens:s.filter(u=>u.start>=t.startOffset&&u.start<t.endOffset),tokenByStart:new Map(s.map(u=>[u.start,u])),tokenTextCounts:wf(s),processedStarts:new Set};return Sf({...e,fileName:t.fileName,sourceInfo:n,sourceFile:a,map:o,tokenContext:c})}function Sf(e){let t=[],n=Me();for(let r of e.tokenContext.tokens){if(e.tokenContext.processedStarts.has(r.start)||Rf(e.sourceInfo.text,r.start))continue;let i=as(e.map,r.start);if(i===null)continue;let a=(e.context.languageService.getDefinitionAtPosition(e.fileName,i+1)??[]).find(l=>!ss(e.projectRoot,l.fileName));if(!a){ir(n,e.sourceReader,e.sourceInfo,e.sourceFile,r,"no-definition");continue}let s=z(e.projectRoot,a.fileName),c=xf(e.sourceFile,r.text,s);if(c){ir(n,e.sourceReader,e.sourceInfo,e.sourceFile,r,c);continue}let u=ns(a,e.symbolLookup,e.vueSymbolLookup,e.context,e.projectRoot);if(u===null){ir(n,e.sourceReader,e.sourceInfo,e.sourceFile,r,"unindexed-definition");continue}ds(t,e.sourceReader,e.sourceInfo,e.sourceFile,r,s,u),e.tokenContext.processedStarts.add(r.start),If(t,e,r,i,s,u)}return{occurrences:t,...n}}function Rf(e,t){let n=e.lastIndexOf(`
|
|
360
|
-
`,t-1)+1,r=e.slice(n,t);return/\bfrom\s+['"][^'"]*$/.test(r)||/\bimport\s*\(\s*['"][^'"]*$/.test(r)}function xf(e,t,n){return n===e?"same-file-definition":n.endsWith(".vue")&&t!==n.split("/").at(-1)?.replace(/\.vue$/,"")?"unindexed-definition":null}function ls(e,t,n){let r=Me();return t.countFileSkip&&(r.skippedReferences=1,r.skippedReferenceReasons[n]=1,r.skippedReferenceSamples.push({sourceFile:z(e,t.fileName),sourceLine:0,sourceStartChar:0,sourceEndChar:0,token:"",reason:n})),{occurrences:[],...r}}function ir(e,t,n,r,i,o){if(e.skippedReferences++,e.skippedReferenceReasons[o]++,e.skippedReferenceSamples.filter(s=>s.reason===o&&s.sourceFile===r).length>=2)return;let a=t.positionAt(n,i.start);e.skippedReferenceSamples.push({sourceFile:r,sourceLine:a.line,sourceStartChar:a.character,sourceEndChar:a.character+i.text.length,token:i.text,reason:o})}function or(e,t){let n=new Map;for(let o of e){let a=n.get(o.sourceFile)??[];a.push(o),n.set(o.sourceFile,a)}let r=[...n.keys()].sort(),i=[];for(let o=0;i.length<t;o++){let a=!1;for(let s of r){let c=n.get(s)?.[o];if(c&&(i.push(c),a=!0,i.length===t))break}if(!a)break}return i}function vf(e,t){let n=or(e.filter(o=>o.sourceFile!==o.definitionFile),Math.ceil(t/2)),r=new Set(n.map(o=>`${o.sourceFile}:${o.sourceLine}:${o.sourceStartChar}:${o.sourceEndChar}:${o.symbolId}`)),i=or(e.filter(o=>!r.has(`${o.sourceFile}:${o.sourceLine}:${o.sourceStartChar}:${o.sourceEndChar}:${o.symbolId}`)),t-n.length);return[...n,...i]}function Pf(e,t){let n=[...new Set(e.map(i=>i.reason))].sort(),r=[];for(let[i,o]of n.entries()){let a=n.length-i,s=Math.ceil((t-r.length)/a);r.push(...or(e.filter(c=>c.reason===o),s))}return r.slice(0,t)}function Ef(e,t,n){let r=e.prepare("SELECT symbol FROM global_symbols WHERE id = ?");return vf(t,n).map(({symbolId:i,...o})=>({...o,definitionSymbol:r.get(i)?.symbol??`symbol-id:${i}`}))}function If(e,t,n,r,i,o){if(!((t.tokenContext.tokenTextCounts.get(n.text)??0)<=1))for(let a of Tf(t.context.languageService,t.fileName,r+1,t.map,n,t.tokenContext.tokenByStart)){if(t.tokenContext.processedStarts.has(a))continue;let s=t.tokenContext.tokenByStart.get(a);s&&(ds(e,t.sourceReader,t.sourceInfo,t.sourceFile,s,i,o),t.tokenContext.processedStarts.add(a))}}function ds(e,t,n,r,i,o,a){let s=t.positionAt(n,i.start);e.push({sourceFile:r,sourceLine:s.line,sourceStartChar:s.character,sourceEndChar:s.character+i.text.length,sourceToken:i.text,definitionFile:o,symbolId:a})}function wf(e){let t=new Map;for(let n of e)t.set(n.text,(t.get(n.text)??0)+1);return t}function Tf(e,t,n,r,i,o){let a=e.getDocumentHighlights?.(t,n,[t])??[],s=[];for(let c of a)if(c.fileName===t)for(let u of c.highlightSpans){let l=kf(r,u.textSpan.start,o,i.text);l!==null&&s.push(l)}return s}function kf(e,t,n,r){let i=n.get(t);if(i?.text===r)return i.start;let o=rr(e,t);if(o===null)return null;let a=n.get(o);return a?.text===r?a.start:null}async function ws(e){let{projectRoot:t,onStatus:n=console.log}=e,r=e.maxHeapMb??si(process.env.NODE_OPTIONS)??8192,i=e.skipAutoInstall===!0||e.installMissing!==!0,o=Of(e),a=Date.now(),s=C();Bt(I(o.outputScip),{recursive:!0}),Bt(I(o.outputDb),{recursive:!0});let c=e.languages??sn(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.");n(`Detected languages: ${c.join(", ")}`);let u=Vt(o.metaPath),l=w("reindex.fingerprint",()=>Ir(t,c,{pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:e.typescriptProjects,clojureConfigPath:e.clojureConfigPath},u,e.changeJournal,an(o.outputDb)),{languages:c.length}),p=l.fingerprint,d=l.mode==="delta"?e.changeJournal?.entries.filter(S=>S.kind!=="add").length??0:0,f=Math.max(0,(u?.files.length??0)-d);n(l.mode==="delta"?`Project fingerprint revalidated ${l.changedPaths.length} changed path(s), reused ${f} accepted file fingerprint(s), and accepted ${p.files.length} input(s)`:`Project fingerprint used full scan: ${l.reason}`);let m=await Ff({opts:e,paths:o,languages:c,fingerprint:p,onStatus:n}),y=m.snapshot,E=m.releaseBuildLock,T=Bs(e.trigger),v=oi(O(I(o.outputDb),"cache-lifecycle.lock"),{waitMs:T?1e3:3e4});if(!v)throw E?.(),new _e(T?`Could not acquire scip-query cache lifecycle lock for ${I(o.outputDb)}; another refresh is publishing, so the watcher will retry.`:`Could not acquire scip-query cache lifecycle lock for ${I(o.outputDb)}. A watch daemon or another reindex may hold it. Run "scip-query watch --stop", retry the reindex, then restart with "scip-query watch --daemon".`);let F;try{F=await W("reindex.lock",()=>pg(O(I(o.outputDb),"index.lock"),{projectRoot:t,trigger:e.trigger,onStatus:n}),{languages:c.length})}catch(S){throw v.release(),E?.(),S}let _=null,b=qi();try{l.mode==="delta"&&an(o.outputDb)!==e.changeJournal?.baseGeneration&&(p=Pr(t,c,{pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:e.typescriptProjects,clojureConfigPath:e.clojureConfigPath}),l={mode:"full",fingerprint:p,reason:"accepted-generation-changed-before-lock"},y=void 0,E?.(),E=void 0,n("Project fingerprint used full scan: accepted-generation-changed-before-lock")),Ri(o.outputDb,o.outputScip,o.metaPath);let S=jf(I(o.outputDb));S.removed>0&&n(`Removed ${S.removed} abandoned reindex workspace(s)`);for(let x of S.errors)n(`Could not remove abandoned reindex workspace: ${x}`);let h=null,A=await W("reindex.reuse-check",async()=>(h=await Df({opts:e,paths:o,languages:c,fingerprint:p,start:a,monotonicStart:s,onStatus:n}),h),()=>({languages:c.length,reused:h!==null}));if(A){ms({snapshot:y,paths:o,projectRoot:t,fingerprint:p,onStatus:n});let x=kn(o.outputDb,A);return x.state==="failed"&&n(`Warning: reindex succeeded, but activity telemetry was not recorded: ${x.reason}`),Qt(t,I(o.outputDb)),A}$i()&&await W("reindex.scip-cli-ready",()=>ng(i,n));let R=Nf(o);_=R.runDir;let P,k=await W("reindex.fresh",async()=>(P=await Bf({opts:e,languages:c,projectRoot:t,paths:o,tempPaths:R,fingerprint:p,start:a,monotonicStart:s,maxHeapMb:r,skipAutoInstall:i,onStatus:n,writeTelemetry:b}),P),()=>({languages:c.length,reused:P?.reused,skipped:P?.skipped.length}));ms({snapshot:y,paths:o,projectRoot:t,fingerprint:p,onStatus:n});let g=kn(o.outputDb,k);return g.state==="failed"&&n(`Warning: reindex succeeded, but activity telemetry was not recorded: ${g.reason}`),Qt(t,I(o.outputDb)),k}catch(S){let h=Wt({trigger:e.trigger,result:"failed",start:a,monotonicStart:s,error:S instanceof Error?S.message:String(S)});Gs(o.metaPath,h);let A=Co(o.outputDb,h);throw A.state==="failed"&&n(`Warning: failed reindex activity telemetry was not recorded: ${A.reason}`),S}finally{_&&he(_,{recursive:!0,force:!0}),F(),v.release(),E?.()}}async function Ff(e){let{opts:t,paths:n,languages:r,fingerprint:i,onStatus:o}=e,a=t.projectRoot;if(!(t.skipIfUnchanged!==!1&&!xi(a,n.outputDb)&&ps(n.outputScip)===ps(O(I(n.outputDb),"index.scip"))))return{snapshot:void 0,releaseBuildLock:void 0};let c=Ze(a),u=c?.clean?pt(c,i):void 0;if(c&&!c.clean&&!hs(n))return gs({context:c,languages:r,opts:t,paths:n,fingerprint:i,projectRoot:a,onStatus:o,successMessage:"dirty worktree reindex",failurePrefix:"Shared baseline fork failed"}),{snapshot:u,releaseBuildLock:void 0};if(!u)return{snapshot:void 0,releaseBuildLock:void 0};let l=cn(u);if(l){if(!Lf(n,i))try{ft({snapshot:u,manifest:l,targetCacheDir:I(n.outputDb),targetProjectRoot:a}),o(`Attached shared generation ${u.generationId.slice(0,12)}`)}catch(d){o(`Shared generation attach failed; continuing locally: ${ye(d)}`)}return{snapshot:u,releaseBuildLock:void 0}}c&&!hs(n)&&gs({context:c,languages:r,opts:t,paths:n,fingerprint:i,projectRoot:a,onStatus:o,successMessage:"cold worktree reindex",failurePrefix:"Compatible shared baseline fork failed",compatible:!0});let p=await Ei(u);if(p.kind==="owner")return{snapshot:u,releaseBuildLock:p.release};if(p.kind==="generation-ready"){let d=cn(u);if(d)try{ft({snapshot:u,manifest:d,targetCacheDir:I(n.outputDb),targetProjectRoot:a,action:"waited"}),o(`Attached shared generation ${u.generationId.slice(0,12)} after waiting`)}catch(f){o(`Shared generation attach failed after waiting; continuing locally: ${ye(f)}`)}}else o("Shared generation build lock timed out; continuing with an isolated local reindex");return{snapshot:u,releaseBuildLock:void 0}}function gs(e){let t=vi(e.context,e.languages,{pnpmWorkspaces:e.opts.pnpmWorkspaces,typescriptProjectMode:e.opts.typescriptProjectMode,typescriptProjects:e.opts.typescriptProjects,clojureConfigPath:e.opts.clojureConfigPath},e.fingerprint);if(t)try{ft({snapshot:t.snapshot,manifest:t.manifest,targetCacheDir:I(e.paths.outputDb),targetProjectRoot:e.projectRoot,persistLease:!1}),wi(t.snapshot,I(e.paths.outputDb)),e.onStatus(`Forked ${e.compatible?"compatible ":""}shared baseline ${t.snapshot.generationId.slice(0,12)} for ${e.successMessage}`)}catch(n){e.onStatus(`${e.failurePrefix}; continuing locally: ${ye(n)}`)}}function ms(e){if(e.snapshot)try{let t=Ze(e.projectRoot),n=t?pt(t,e.fingerprint):void 0;if(!n||n.generationId!==e.snapshot.generationId){e.onStatus("Skipped shared generation publication because the worktree changed during indexing");return}let r=Pi({snapshot:e.snapshot,sourceCacheDir:I(e.paths.outputDb),sourceProjectRoot:e.projectRoot,sourceStillValid:()=>{let i=Ze(e.projectRoot);return(i?pt(i,e.fingerprint):void 0)?.generationId===e.snapshot?.generationId}});Ii(e.snapshot,I(e.paths.outputDb),"built"),e.onStatus(r.kind==="published"?`Published shared generation ${e.snapshot.generationId.slice(0,12)} (${r.achievedDurability})`:`Shared generation ${e.snapshot.generationId.slice(0,12)} was already available (${r.achievedDurability})`)}catch(t){e.onStatus(`Shared generation publication failed; local index remains valid: ${ye(t)}`)}}function Lf(e,t){if(!B(e.outputScip)||!B(e.outputDb)||Us(e.metaPath,t)===null)return!1;let n=q(e.outputDb,e.metaPath);return n.state!=="invalid"&&n.state!=="drifted"}function hs(e){if(!B(e.outputScip)||!B(e.outputDb)||!ae(e.metaPath))return!1;let t=q(e.outputDb,e.metaPath);return t.state!=="invalid"&&t.state!=="drifted"}function ye(e){return e instanceof Error?e.message:String(e)}async function cr(e,t,n,r,i,o,a,s=!1){try{await vo(Ji({indexPath:n,evidenceDbPath:a,reuseExisting:i,affectedFiles:o,forceDerivedRebuild:s}),{projectRoot:e,dbPath:t,onStatus:r})}catch(c){r(`Runtime-boundary extraction unavailable: ${c instanceof Error?c.message:String(c)}.`)}}function Of(e){let t=e.outputScip??O(e.projectRoot,"index.scip"),n=e.outputDb??O(e.projectRoot,"index.db");return{outputScip:t,outputDb:n,metaPath:O(I(n),"meta.json")}}async function Df(e){let t=q(e.paths.outputDb,e.paths.metaPath),n=Us(e.paths.metaPath,e.fingerprint);if(e.opts.skipIfUnchanged===!1||!B(e.paths.outputScip)||!B(e.paths.outputDb)||n===null||t.state==="invalid"||t.state==="drifted")return null;let r=ut(e.paths.outputDb,e.fingerprint,e.languages);if(r.state!=="complete")return e.onStatus(ur("Accepted SQLite index",r)),null;Ae(me(),{projectRoot:e.opts.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus}),await cr(e.opts.projectRoot,e.paths.outputDb,e.paths.outputScip,e.onStatus,!0),q(e.paths.outputDb,e.paths.metaPath).state==="drifted"&&(dt(e.paths.outputDb,e.paths.metaPath),e.onStatus("Published refreshed SQLite generation after post-index augmentation")),n==="operational-config-compatible"&&(Rg(e.paths.metaPath,e.fingerprint,e.languages,e.opts),dt(e.paths.outputDb,e.paths.metaPath),e.onStatus("Migrated operational .scipquery.json metadata without rerunning language indexers."));let i=C()-e.monotonicStart,o=Wt({trigger:e.opts.trigger,result:"reused",start:e.start,monotonicStart:e.monotonicStart,languages:e.languages,skipped:[]});return Gs(e.paths.metaPath,o),e.onStatus(`Index unchanged; reused existing SQLite index in ${(i/1e3).toFixed(1)}s`),{languages:e.languages,indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:i,reused:!0,skipped:[],lastRefresh:o,shards:Mf(e.paths,e.languages,e.opts,e.fingerprint)}}function Mf(e,t,n,r){let i=lr(r,t,n);return t.map(o=>({id:o,language:o,reused:!0,strategy:"reused",fingerprint:Je(i[o]),outputBytes:be(dr(e.outputDb,o)),durationMs:0}))}function Nf(e){let t=Cf(O(I(e.outputDb),"reindex-"));return{runDir:t,tempOutputScip:O(t,Nt(e.outputScip)),tempOutputDb:O(t,Nt(e.outputDb)),tempMetaPath:O(t,Nt(e.metaPath))}}function jf(e){let t=[],n;try{n=Es(e,{withFileTypes:!0})}catch(i){return{removed:0,errors:[ye(i)]}}let r=0;for(let i of n)if(!(!i.name.startsWith("reindex-")||!i.isDirectory()))try{he(O(e,i.name),{recursive:!0,force:!0}),r+=1}catch(o){t.push(`${i.name}: ${ye(o)}`)}return{removed:r,errors:t}}async function Bf(e){let t={...process.env,NODE_OPTIONS:ci(process.env.NODE_OPTIONS,e.maxHeapMb)},n,r=await W("reindex.language-indexers",async()=>(n=await Vf(e,t),n),()=>({languages:e.languages.length,indexed:n?.indexedOutputs.length,reused:n?.reusedLanguages.length,skipped:n?.skippedLanguages.length})),{indexedOutputs:i,skippedLanguages:o,reusedLanguages:a,languageFingerprints:s,shards:c,typescriptProjectShardContext:u,incrementalTypeScript:l}=r;if(a.length>0&&e.onStatus(`Reused ${a.length} cached language shard(s): ${a.join(", ")}`),$f({run:e,indexedOutputs:i,skippedLanguages:o,reusedLanguages:a})){let f=await W("reindex.publish",()=>Kf(e,i,o,a,s,u),{mode:"metadata-only",languages:i.length,reused:a.length}),m=f.durationMs;return e.onStatus(`All language shards unchanged; reused existing SQLite index in ${(m/1e3).toFixed(1)}s`),{languages:i.map(y=>y.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:m,reused:!0,skipped:o,lastRefresh:f,shards:c,writeTelemetry:e.writeTelemetry}}let p=await W("reindex.publish",()=>Yf(e,t,i,o,a,s,u,l),{mode:l?"incremental-or-fallback":"full",languages:i.length,reused:a.length,skipped:o.length}),d=p.durationMs;return e.onStatus(`Done in ${(d/1e3).toFixed(1)}s`),{languages:i.map(f=>f.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:d,reused:!1,skipped:o,lastRefresh:p,shards:c,writeTelemetry:e.writeTelemetry}}function $f(e){if(e.run.opts.skipIfUnchanged===!1||e.skippedLanguages.length>0||!B(e.run.paths.outputScip)||!B(e.run.paths.outputDb))return!1;let t=q(e.run.paths.outputDb,e.run.paths.metaPath);if(t.state==="invalid"||t.state==="drifted")return!1;let n=new Set(e.reusedLanguages),r=new Set(e.indexedOutputs.map(i=>i.language));return e.run.languages.length>0&&r.size===e.run.languages.length&&e.indexedOutputs.length===e.run.languages.length&&e.run.languages.every(i=>n.has(i)&&r.has(i))}async function Vf(e,t){let n=e.opts.skipIfUnchanged===!1,r=Hf({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,projectFingerprint:e.fingerprint});if(n)for(let[g,x]of r)x.reused&&r.set(g,{...x,reused:!1,reason:"forced reindex requested"});let i=[],o=new Set;for(let[g,x]of r)x.reused&&(i.push({language:g,scipPath:x.scipPath}),o.add(g));for(let g of o)e.onStatus(`Reusing cached ${g} SCIP shard (language inputs unchanged).`);let a=r.get("typescript"),s=q(e.paths.outputDb,e.paths.metaPath),c=ae(e.paths.metaPath),u=s.state==="legacy"||s.state==="current",l=c?.scipCompanion!=="deferred"&&(s.state!=="current"||s.generation.publication?.scipCompanion!=="deferred"),p;n&&a&&!a.reused&&(p="forced reindex rebuilds from the compilers");let d=!n&&a&&!a.reused&&u?_a({projectRoot:e.projectRoot,cacheDir:I(e.paths.outputDb),previousDbPath:e.paths.outputDb,previousIndexPath:e.paths.outputScip,previousShardPath:a.scipPath,candidateShardPath:Se(e.tempPaths.tempOutputScip,"typescript-incremental",0),candidateAffectedScipPath:Se(e.tempPaths.tempOutputScip,"typescript-affected",0),baseShardCurrent:l,previousSnapshot:Vt(e.paths.metaPath),currentSnapshot:e.fingerprint,projectMode:e.opts.typescriptProjectMode,...s.state==="current"&&s.generation.publication?.scipCompanion==="deferred"&&s.generation.publication.typescriptOverlayGeneration?{previousOverlayGeneration:s.generation.publication.typescriptOverlayGeneration}:{},onStatus:e.onStatus,onUnavailable:g=>{p=g}}):null,f=new Set(d?["typescript"]:[]);if(e.opts.allowExpensiveRebuild===!1){let g=e.languages.filter(x=>!o.has(x)&&!f.has(x));if(g.length>0){let x=g.length===1&&g[0]==="typescript"&&p?`: ${p}`:"";throw new Error(`Incremental indexing is unavailable for ${g.join(", ")}${x}. The accepted index was preserved because whole-project rebuilds are disabled; run scip-query reindex --allow-expensive-rebuild only when you explicitly want that fallback.`)}}let m=d||o.has("typescript")?void 0:Uf(e,r),y=m&&n?{...m,classification:new Map([...m.classification].map(([g,x])=>[g,x.reused?{...x,reused:!1,reason:"forced reindex requested"}:x])),reusedProjects:[],missedProjectIds:new Set(m.allProjects.map(g=>`typescript:${g}`))}:m,{preparedRuns:E,skippedLanguages:T,languageOutputScipPaths:v}=rg({languages:e.languages.filter(g=>!o.has(g)&&!f.has(g)),tempOutputScip:e.tempPaths.tempOutputScip,projectRoot:e.projectRoot,env:t,skipAutoInstall:e.skipAutoInstall,trustProjectTools:e.opts.trustProjectTools===!0,pnpmWorkspaces:e.opts.pnpmWorkspaces,typescriptProjectMode:e.opts.typescriptProjectMode,typescriptProjects:e.opts.typescriptProjects,preDiscoveredTypeScriptProjects:y?.allProjects,typescriptShardCostDir:I(e.paths.outputDb),clojureConfigPath:e.opts.clojureConfigPath,onStatus:e.onStatus}),F=y?E.filter(g=>g.language!=="typescript"||y.missedProjectIds.has(g.id)):E,_=await Na(F,e.projectRoot,e.onStatus,e.opts.indexerConcurrency,e.opts.signal);if(Ar())for(let g of _)Fr({type:"span",name:`reindex.language-indexer.${g.id}`,durationMs:Math.round(g.durationMs),ok:!g.skipped,language:g.language,indexerCommand:g.command,outputBytes:g.outputBytes,measurement:"indexer-run-result"});og(I(e.paths.outputDb),e.projectRoot,F,_);let b=[];if(y){Wf(e.paths.outputDb,_,e.writeTelemetry);let g=v.typescript??e.tempPaths.tempOutputScip;b=qf({outputDb:e.paths.outputDb,tempOutputScip:e.tempPaths.tempOutputScip,outputScipPath:g,reusedProjects:y.reusedProjects,writeTelemetry:e.writeTelemetry})}let S=[..._,...b],{indexedOutputs:h}=sg(S,T),A=d?[{language:"typescript",scipPath:d.scipPath}]:[],R=[...i,...A,...h];cg(R,T,e.languages,e.opts.allowPartial,e.onStatus);let P=d?[{id:"typescript",language:"typescript",label:"typescript (incremental documents)",scipPath:d.scipPath,outputScipPath:d.scipPath,durationMs:d.durationMs,command:"watch-service:typescript-index",outputBytes:be(d.scipPath)??void 0,producedOutputBytes:be(d.affectedScipPath)??void 0}]:[],k=Jf(r,[..._,...P],y?{outputDb:e.paths.outputDb,classification:y.classification}:void 0,p);return{indexedOutputs:R,skippedLanguages:T,reusedLanguages:[...o],languageFingerprints:zf(r,e.languages),shards:k,typescriptProjectShardContext:y?{projects:y.allProjects,fingerprints:y.fingerprints}:void 0,incrementalTypeScript:d??void 0}}function Uf(e,t){let n=t.get("typescript");if(!n||n.reused||n.cacheIntegrityFailed||e.opts.typescriptProjectMode!=="workspace")return;let r=se(e.projectRoot,e.opts.typescriptProjects);if(r.length===0)return;let i=Mo(e.projectRoot,r),o=Lo(n.fingerprint.files,r),a=Oo(r,i),s=Do(r,o,a),c=ae(e.paths.metaPath),l=Gf(c,s,m=>B(Ut(e.paths.outputDb,m))),p=[...l.entries()].filter(([,m])=>m.reused).map(([m])=>m),d=new Set(p),f=new Set(r.filter(m=>!d.has(m)).map(m=>`typescript:${m}`));return{allProjects:r,fingerprints:s,classification:l,reusedProjects:p,missedProjectIds:f}}function Gf(e,t,n){let r=new Map;for(let i of Object.keys(t)){let o=t[i];if(!e){r.set(i,{reused:!1,reason:"no reindex metadata found",fingerprint:o});continue}let a=e.version===Pe&&tn(e).typescriptProjectShardReuse?e.typescriptProjectShards?.[i]:void 0;if(!a){r.set(i,{reused:!1,reason:"no cached fingerprint for this project",fingerprint:o});continue}if(!n(i)){r.set(i,{reused:!1,reason:"cached shard file missing on disk",fingerprint:o});continue}if(j(a)!==j(o)){r.set(i,{reused:!1,reason:"project inputs changed since last index",fingerprint:o});continue}r.set(i,{reused:!0,fingerprint:o})}return r}function Wf(e,t,n){for(let r of t){if(r.skipped||!r.id.startsWith("typescript:"))continue;let i=r.id.slice(11),o=Ut(e,i);Bt(I(o),{recursive:!0}),ge(n,fe(r.scipPath,o,void 0,{shareImmutable:!0}))}}function qf(e){return e.reusedProjects.map((t,n)=>{let r=Ut(e.outputDb,t),i=Se(e.tempOutputScip,"typescript-project-cached",n);return ge(e.writeTelemetry,fe(r,i,void 0,{shareImmutable:!0})),{id:`typescript:${t}`,language:"typescript",label:`typescript (${t})`,scipPath:i,outputScipPath:e.outputScipPath,durationMs:0,command:"cached",outputBytes:be(i)??void 0}})}function Hf(e){let t=ae(e.paths.metaPath),n=lr(e.projectFingerprint,e.languages,e),r=t&&B(e.paths.outputDb)?ut(e.paths.outputDb,e.projectFingerprint,e.languages):null,i=new Map;for(let o of e.languages){let a=dr(e.paths.outputDb,o),s=n[o];if(!t){i.set(o,{reused:!1,reason:"no reindex metadata found",fingerprint:s,scipPath:a});continue}if(t.version!==Pe){i.set(o,{reused:!1,reason:`metadata version ${String(t.version??"unknown")} predates per-language shard caching`,fingerprint:s,scipPath:a});continue}if(!tn(t).languageShardReuse||!t.languageFingerprints){i.set(o,{reused:!1,reason:"no per-language fingerprints recorded in metadata",fingerprint:s,scipPath:a});continue}let c=t.languageFingerprints[o];if(!c){i.set(o,{reused:!1,reason:"no cached fingerprint for this language",fingerprint:s,scipPath:a});continue}if(!B(a)){i.set(o,{reused:!1,reason:"cached shard file missing on disk",fingerprint:s,scipPath:a});continue}let u=o==="typescript"?yg(e.projectRoot,c):c;if(j(u)!==j(s)){i.set(o,{reused:!1,reason:"language inputs changed since last index",fingerprint:s,scipPath:a});continue}if(r?.state==="unavailable"||r?.state==="incomplete"&&r.affectedLanguages.includes(o)){i.set(o,{reused:!1,reason:ur("accepted SQLite index",r),cacheIntegrityFailed:!0,fingerprint:s,scipPath:a});continue}i.set(o,{reused:!0,fingerprint:s,scipPath:a})}return i}function Jf(e,t,n,r){let i=[];for(let[o,a]of e)a.reused&&i.push({id:o,language:o,reused:!0,strategy:"reused",fingerprint:Je(a.fingerprint),outputBytes:be(a.scipPath),durationMs:0});for(let o of t){let a=e.get(o.language),s=n&&o.id.startsWith("typescript:")?o.id.slice(11):null,c=s?n.classification.get(s):void 0;i.push({id:o.id,language:o.language,reused:!1,strategy:o.command==="watch-service:typescript-index"?"incremental":"full",missReason:c?.reason??a?.reason??o.skipped?.reason,fallbackReason:o.language==="typescript"?r:void 0,fingerprint:c?Je(c.fingerprint):a?Je(a.fingerprint):"unknown",outputBytes:o.outputBytes??null,producedOutputBytes:o.producedOutputBytes,durationMs:o.durationMs,command:o.command})}if(n)for(let[o,a]of n.classification)a.reused&&i.push({id:`typescript:${o}`,language:"typescript",reused:!0,strategy:"reused",fingerprint:Je(a.fingerprint),outputBytes:be(Ut(n.outputDb,o)),durationMs:0});return i}function Je(e){return _f("sha256").update(j(e)).digest("hex").slice(0,16)}function be(e){try{return sr(e).size}catch{return null}}function zf(e,t){let n={};for(let r of t){let i=e.get(r);i&&(n[r]=i.fingerprint)}return n}async function Yf(e,t,n,r,i,o,a,s){V(e.opts.signal,"Reindex cancelled by its owner.");let c=!s||s.completeScipUpdated,u=!1;c&&(u=w("reindex.publish.scip-output",()=>{let b=tg({run:e,indexedOutputs:n,incrementalTypeScript:s,typescriptReused:i.includes("typescript")});return ys(e.paths.outputDb,b,e.writeTelemetry),bs(b,e.tempPaths.tempOutputScip,e.onStatus)}));let l=await W("reindex.publish.sqlite-output",()=>ug({run:e,env:t,indexedOutputs:n,skippedLanguages:r,reusedLanguages:i,incrementalTypeScript:s,completeScipAvailable:c,completeScipSanitized:u,materializeFullFallback:async()=>{if(V(e.opts.signal,"Reindex cancelled by its owner."),!s||s.completeScipUpdated)return u;e.onStatus("Materializing the deferred whole TypeScript SCIP companion for full conversion..."),Xn({cacheDir:I(e.paths.outputDb),generationIdentity:s.nextFragmentGeneration,baseShardPath:s.scipPath,candidateShardPath:s.candidateScipPath});let b=n.map(S=>S.language==="typescript"?{language:S.language,scipPath:s.candidateScipPath}:S);return ys(e.paths.outputDb,b,e.writeTelemetry),u=bs(b,e.tempPaths.tempOutputScip,e.onStatus),u}}));V(e.opts.signal,"Reindex cancelled by its owner."),w("reindex.publish.auxiliary-documents",()=>{Ae(me(),{projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,onStatus:e.onStatus})}),await W("reindex.publish.runtime-boundaries",async()=>{let b=s?.plan.mode==="full-project",S=s?.dependencyGraphUnchanged===!0;b?e.onStatus("Rebuilding compiler-derived runtime-boundary relationships while retaining unchanged per-file extraction facts."):S&&e.onStatus("Reusing runtime-boundary relationships because TypeScript semantics are unchanged."),await cr(e.projectRoot,e.tempPaths.tempOutputDb,e.tempPaths.tempOutputScip,e.onStatus,S,S?void 0:b?s?.changedFiles:s?.affectedFiles,O(I(e.paths.outputDb),_r),b)});let p=w("reindex.publish.sqlite-layout",()=>wn(e.tempPaths.tempOutputDb,{analyze:Xf(s,l.mode)}));p.added.length>0&&e.onStatus(`Added SQLite query indexes: ${p.added.join(", ")}`),p.removed.length>0&&e.onStatus(`Removed redundant SQLite indexes: ${p.removed.join(", ")}`),w("reindex.publish.coverage",()=>As(e,e.tempPaths.tempOutputDb,n.map(b=>b.language)));let d,f=null;l.mode==="incremental"&&s&&w("reindex.publish.reference-fragments",()=>{if(s.dependencyGraphUnchanged){let h=new G({projectRoot:e.projectRoot,dbPath:e.paths.outputDb,indexPath:e.paths.outputScip});try{f=nn(h),e.onStatus("Preserved exact TypeScript reference fragments and dependency relationships because only trivia changed.")}finally{h.close()}return}let b=null,S=null;try{b=w("reindex.publish.reference-fragments.open-candidate",()=>new G({projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,indexPath:e.tempPaths.tempOutputScip})),S=w("reindex.publish.reference-fragments.open-evidence",()=>new G({projectRoot:e.projectRoot,dbPath:e.paths.outputDb,indexPath:e.paths.outputScip})),d=s.dependencyGraphSnapshot?w("reindex.publish.reference-fragments.dependency-graph",()=>Nr(b,s.dependencyGraphSnapshot,s.affectedFiles,s.deletedFiles))??void 0:void 0;let h=new Set(s.deletedFiles),A=h.size===0?s.referenceFragmentsByFile:new Map([...s.referenceFragmentsByFile].filter(([P])=>!h.has(P))),R=w("reindex.publish.reference-fragments.seed",()=>ni(b,e.fingerprint,A,S,d,new Set(s.affectedFiles)));e.onStatus(`Cached exact TypeScript reference fragments for ${R.affectedFiles} affected document(s) and carried ${R.carriedFiles} unaffected document(s) forward.`),R.skippedAffectedFiles>0&&e.onStatus(`Skipped exact TypeScript reference fragment prefill for ${R.skippedAffectedFiles} affected document(s) whose semantic identity was unavailable.`)}catch(h){e.onStatus(`Exact TypeScript reference fragment prefill unavailable: ${h instanceof Error?h.message:String(h)}.`)}finally{b?.close(),S?.close()}});let m=Vt(e.paths.metaPath);l.mode==="incremental"&&s||await Ts({projectRoot:e.projectRoot,previousDbPath:e.paths.outputDb,previousIndexPath:e.paths.outputScip,previousSnapshot:m,currentSnapshot:e.fingerprint,onStatus:e.onStatus});let y=w("reindex.publish.affected-shadow",()=>l.mode==="incremental"&&s?dg(s,l.changedDocumentPaths):Rn({projectRoot:e.projectRoot,previousDbPath:e.paths.outputDb,previousIndexPath:e.paths.outputScip,candidateDbPath:e.tempPaths.tempOutputDb,candidateIndexPath:e.tempPaths.tempOutputScip,previousSnapshot:m,currentSnapshot:e.fingerprint,refreshResult:"rebuilt"})),E=Wt({trigger:e.opts.trigger,result:"rebuilt",start:e.start,monotonicStart:e.monotonicStart,languages:n.map(b=>b.language),skipped:[...r]}),T=l.mode==="incremental"&&l.scipCompanion==="deferred",{metadata:v,pruneProjects:F}=_s({run:e,indexedOutputs:n,skippedLanguages:r,reusedLanguages:i,languageFingerprints:o,typescriptProjectShardContext:a,lastRefresh:E});v.scipCompanion=T?"deferred":"current",w("reindex.publish.metadata",()=>{Cs(e),Fs(e.paths.outputDb,F),Gt(e.tempPaths.tempMetaPath,v)});let _=w("reindex.publish.generation-handoff",()=>Si({tempOutputScip:e.tempPaths.tempOutputScip,tempOutputDb:e.tempPaths.tempOutputDb,tempMetaPath:e.tempPaths.tempMetaPath,outputScip:e.paths.outputScip,outputDb:e.paths.outputDb,metaPath:e.paths.metaPath,preserveOutputScip:l.mode==="incremental"&&l.scipCompanion==="deferred",publication:l.mode==="incremental"?{mode:"incremental",validation:"passed",converterDurationMs:l.converterDurationMs,affectedDocumentCount:s?.affectedFiles.length,changedDocumentCount:l.changedDocumentPaths.length,producerDurationMs:s?.timings.serviceMs,materializationDurationMs:s?.durationMs,patchDurationMs:l.patchDurationMs,scipCompanion:l.scipCompanion,...l.scipCompanion==="deferred"&&s?{typescriptOverlayGeneration:s.nextFragmentGeneration}:{}}:{mode:"full",validation:"passed",converterDurationMs:l.converterDurationMs,scipCompanion:"current",...l.fallbackReason?{fallbackReason:l.fallbackReason}:{}}}));return _.achievedDurability==="file-flushed"&&e.onStatus(`Published local generation ${_.currentGeneration.slice(0,12)} (file-flushed; directory sync unsupported)`),l.mode==="incremental"&&s&&w("reindex.publish.dependency-graph",()=>{let b=null;try{b=new G({projectRoot:e.projectRoot,dbPath:e.paths.outputDb,indexPath:e.paths.outputScip});let S=s.plan.mode==="full-project"&&s.plan.reasons.length===0?s.changedFiles:s.affectedFiles,h=!1;if(s.dependencyGraphUnchanged){let A=nn(b),R=f&&A?Cr(b,"file-dependency-graph",f,A):0;h=R>0,e.onStatus(h?`Carried ${R} unchanged dependency graph product(s) forward without rebuilding them.`:"No persisted dependency graph product required rekeying; the next graph consumer can materialize it.")}else s.dependencyGraphSnapshot?h=Mr(b,s.dependencyGraphSnapshot,S,d):rt(b);s.dependencyGraphUnchanged||e.onStatus(h?`Carried the dependency graph forward by replacing ${S.length} changed dependency owner(s).`:"Materialized a fresh dependency graph for the accepted generation because no compatible prior graph was available.")}catch(S){e.onStatus(`Dependency graph carry-forward unavailable: ${S instanceof Error?S.message:String(S)}. The next graph consumer will rebuild it.`)}finally{b?.close()}}),w("reindex.publish.cleanup",()=>{gi(I(e.paths.outputDb),l.mode==="incremental"&&l.scipCompanion==="deferred"?[s.nextFragmentGeneration]:[]),di(I(e.paths.outputDb),s?.completeScipUpdated?[s.nextFragmentGeneration]:[])}),w("reindex.publish.shadow-telemetry",()=>ks(e.paths.outputDb,y,e.onStatus)),E}function Xf(e,t){return t!=="incremental"||!e||e.plan.mode==="full-project"?!0:e.affectedFiles.length*20>=e.projectFileCount}async function Kf(e,t,n,r,i,o){let a=Vt(e.paths.metaPath),s=null;try{ge(e.writeTelemetry,fe(e.paths.outputDb,e.tempPaths.tempOutputDb))}catch(d){s=ro("reused","oracle-error",`Could not snapshot the prior database: ${d instanceof Error?d.message:String(d)}`)}Ae(me(),{projectRoot:e.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus}),await cr(e.projectRoot,e.paths.outputDb,e.paths.outputScip,e.onStatus,!0);let c=wn(e.paths.outputDb);c.added.length>0&&e.onStatus(`Added SQLite query indexes: ${c.added.join(", ")}`),c.removed.length>0&&e.onStatus(`Removed redundant SQLite indexes: ${c.removed.join(", ")}`),As(e,e.paths.outputDb,t.map(d=>d.language)),s==null&&await Ts({projectRoot:e.projectRoot,previousDbPath:e.tempPaths.tempOutputDb,previousIndexPath:e.paths.outputScip,previousSnapshot:a,currentSnapshot:e.fingerprint,onStatus:e.onStatus}),s??=Rn({projectRoot:e.projectRoot,previousDbPath:e.tempPaths.tempOutputDb,previousIndexPath:e.paths.outputScip,candidateDbPath:e.paths.outputDb,candidateIndexPath:e.paths.outputScip,previousSnapshot:a,currentSnapshot:e.fingerprint,refreshResult:"reused"});let u=Wt({trigger:e.opts.trigger,result:"reused",start:e.start,monotonicStart:e.monotonicStart,languages:t.map(d=>d.language),skipped:[...n]}),{metadata:l,pruneProjects:p}=_s({run:e,indexedOutputs:t,skippedLanguages:n,reusedLanguages:r,languageFingerprints:i,typescriptProjectShardContext:o,lastRefresh:u});return l.scipCompanion=Qf(e.paths),Cs(e),Fs(e.paths.outputDb,p),Gt(e.paths.metaPath,l),dt(e.paths.outputDb,e.paths.metaPath),ks(e.paths.outputDb,s,e.onStatus),u}function Qf(e){let t=ae(e.metaPath)?.scipCompanion;if(t)return t;let n=q(e.outputDb,e.metaPath);return n.state==="current"&&n.generation.publication?.scipCompanion==="deferred"?"deferred":"current"}async function Ts(e){if(!B(e.previousDbPath))return;let t=X(e.previousSnapshot,e.currentSnapshot);if(t.changes.length===0||Ue(t).fullProject)return;let n=null;try{if(n=new G({projectRoot:e.projectRoot,dbPath:e.previousDbPath,indexPath:e.previousIndexPath}),it(n))return;let r=await W("reindex.publish.affected-shadow.warm-sources",()=>jr(n,{yieldToEventLoop:()=>new Promise(i=>setImmediate(i))}));e.onStatus(`Persisted import products for ${r.files} document(s) before the affected-set shadow.`)}catch(r){e.onStatus(`Affected-set shadow import warm-up unavailable: ${r instanceof Error?r.message:String(r)}.`)}finally{n?.close()}}function Vt(e){return Ht(ae(e)?.fingerprint)}function ks(e,t,n){try{oo(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 _s(e){let t=Zf({mode:e.run.opts.typescriptProjectMode,skippedLanguages:e.skippedLanguages,reusedLanguages:e.reusedLanguages,context:e.typescriptProjectShardContext,metaPath:e.run.paths.metaPath});return{metadata:{version:Pe,status:e.skippedLanguages.length===0?"complete":"partial",updatedAt:new Date().toISOString(),fingerprint:e.run.fingerprint,sqliteLayoutVersion:1,languageFingerprints:e.languageFingerprints,typescriptProjectShards:t.field,requestedLanguages:e.run.languages,indexedLanguages:e.indexedOutputs.map(n=>n.language),skipped:[...e.skippedLanguages],lastRefresh:e.lastRefresh},pruneProjects:t.pruneProjects}}function Cs(e){V(e.opts.signal,"Reindex cancelled by its owner.");let t=Er(e.projectRoot,e.fingerprint);if(j(t)===j(e.fingerprint))return;let n=new Map(e.fingerprint.files.map(o=>[o.path,o])),r=new Map(t.files.map(o=>[o.path,o])),i=[...new Set([...n.keys(),...r.keys()])].filter(o=>j(n.get(o))!==j(r.get(o))).slice(0,5);throw new Error(`Project inputs changed during reindex (${i.join(", ")||"unknown path"}); refusing to publish artifacts built from a different filesystem snapshot.`)}function As(e,t,n){let r=ut(t,e.fingerprint,n);if(r.state!=="complete")throw new Error(`${ur("Candidate SQLite index",r)} Refusing to publish it.`)}function ur(e,t){if(t.state==="unavailable")return`${e} document coverage could not be verified (${t.reason}); rebuilding cached language shards.`;let n=t.missingPaths.length>0?` First missing path: ${t.missingPaths[0]}.`:"";return`${e} is missing ${t.missingDocumentCount} fingerprinted source document${t.missingDocumentCount===1?"":"s"}; rebuilding affected language shards.${n}`}function Zf(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=ae(e.metaPath),n=t?.version===Pe?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 Fs(e,t){let n=Vs(e);if(t===null){he(n,{recursive:!0,force:!0});return}let r;try{r=Es(n)}catch{return}for(let i of eg(r,t))he(O(n,i),{force:!0})}function eg(e,t){let n=new Set(t.map(r=>`${Ln(r)}.scip`));return e.filter(r=>!n.has(r))}function tg(e){if(e.incrementalTypeScript?.completeScipUpdated)return[...e.indexedOutputs];let t=e.indexedOutputs.find(a=>a.language==="typescript");if(!t)return[...e.indexedOutputs];if(!e.typescriptReused)return[...e.indexedOutputs];let n=q(e.run.paths.outputDb,e.run.paths.metaPath),r=n.state==="current"?n.generation.publication?.typescriptOverlayGeneration:void 0;if(!(n.state==="current"?n.generation.publication?.scipCompanion==="deferred":ae(e.run.paths.metaPath)?.scipCompanion==="deferred")||!r)return[...e.indexedOutputs];let o=Se(e.run.tempPaths.tempOutputScip,"typescript-deferred",0);return e.run.onStatus("Materializing the deferred whole TypeScript SCIP companion for complete publication..."),Xn({cacheDir:I(e.run.paths.outputDb),generationIdentity:r,baseShardPath:t.scipPath,candidateShardPath:o}),e.indexedOutputs.map(a=>a.language==="typescript"?{language:a.language,scipPath:o}:a)}function ys(e,t,n){for(let r of t){let i=dr(e,r.language);Bt(I(i),{recursive:!0}),r.scipPath!==i&&ge(n,fe(r.scipPath,i,void 0,{shareImmutable:!0}))}}async function ng(e,t){let n=pn();if(n){if(n.source==="path"&&fs()!=="win32"){let r=gn();fn(r)||(e?t(`scip on PATH reports ${r??"an unknown version"}; the reviewed version is ${M} and compatibility is unverified. Run scip-query setup --install-missing to install the reviewed release.`):(t(`scip on PATH reports ${r??"an unknown version"}; installing the reviewed ${M}.`),await mn(t)))}return}if(fs()==="win32")throw new Error("The scip CLI was not found. On Windows it ships via the npm sidecar package scip-query-scip-windows (installed automatically with scip-query). Reinstall scip-query with optional dependencies enabled, or follow 'scip-query setup' guidance for the exact sidecar package version, or set SCIP_QUERY_SCIP_BIN to a local scip.exe path.");if(e)throw new Error(`The scip CLI is required but not found on PATH.
|
|
361
|
-
To install the reviewed version, run: scip-query reindex --install-missing
|
|
362
|
-
Or install manually from: https://github.com/sourcegraph/scip/releases`);if(t("scip CLI not found on PATH. Attempting auto-install..."),!await Gi(t))throw new Error(`The scip CLI is required but could not be installed.
|
|
363
|
-
Install manually from: https://github.com/sourcegraph/scip/releases/tag/${M}`)}function rg(e){let t=[],n=[],r=e.languages.map((o,a)=>({language:o,scipPath:e.languages.length>1?Se(e.tempOutputScip,o,a):e.tempOutputScip})),i=Object.fromEntries(r.map(({language:o,scipPath:a})=>[o,a]));for(let{language:o,scipPath:a}of r){let s=ig({...e,language:o,scipPath:a});for(let c of s)"skipped"in c?Ls(n,c.skipped):t.push(c.prepared)}return{preparedRuns:t,skippedLanguages:n,languageOutputScipPaths:i}}function ig(e){if(e.language!=="typescript")return[jt({...e,id:e.language,label:e.language,outputScipPath:e.scipPath})];let t=e.typescriptProjectMode==="workspace",n=t?e.preDiscoveredTypeScriptProjects??se(e.projectRoot,e.typescriptProjects):["."];return n.length===0?[jt({...e,id:e.language,label:e.language,outputScipPath:e.scipPath})]:(t&&e.onStatus(`Indexing TypeScript workspace as ${n.length} project shard(s).`),n.flatMap((r,i)=>{let o=t?`typescript:${r}`:"typescript",a=t?`typescript (${r})`:"typescript",s=t?Se(e.tempOutputScip,"typescript-project",i):e.scipPath,c={...e,id:o,label:a,scipPath:s,outputScipPath:e.scipPath,pnpmWorkspaces:!1};if(!t&&r==="."&&!e.pnpmWorkspaces){let u=ag(e,c);if(u)return u}return[jt({...c,...t?{projectPath:r}:{}})]}))}function og(e,t,n,r){let i=n.filter(s=>s.shardInputPaths!==void 0);if(i.length===0)return;let o=new Map(r.filter(s=>!s.skipped).map(s=>[s.id,s.durationMs])),a=[];for(let s of i){let c=o.get(s.id);if(c===void 0||!(c>0))return;a.push({inputPaths:s.shardInputPaths,durationMs:c})}try{let s=ia(a,c=>{try{return sr(O(t,c)).size}catch{return 1}});s&&na(e,s)}catch{}}function ag(e,t){let n=Nn(),r=Xt(e.projectRoot,"single");if(!r||!Ko(r.size,n))return null;aa(e.projectRoot);let i=oa(),o=Qo(r.size,n,i),a=e.typescriptShardCostDir?ta(e.typescriptShardCostDir):null,s=ra(a),c=Zo({projectRoot:e.projectRoot,rootConfigPath:"tsconfig.json",inputPaths:[...r],targetFiles:n,shardCount:o,weightOf:l=>{let p=1;try{p=sr(O(e.projectRoot,l)).size}catch{}return s(l,p)}}),u=Math.min(i,c.length);return e.onStatus(`Indexing ${r.size} TypeScript inputs as ${c.length} ${a?"cost-balanced":"byte-balanced"} compiler shard(s), ${u} at a time.`),c.map((l,p)=>jt({...t,id:`typescript-compiler-shard:${p}`,label:`typescript compiler shard ${p+1}/${c.length}`,scipPath:Se(e.tempOutputScip,"typescript-compiler-shard",p),projectPath:l.configPath,temporaryProjectConfigs:[{path:l.configPath,content:l.content}],boundedConcurrency:u,outputComposition:"protobuf-concatenate",shardInputPaths:l.inputPaths}))}function jt(e){let t=xn(e.language),n=ot(t),r=Hr(t,e.projectRoot),i=e.trustProjectTools&&r?Jr(t,e.projectRoot):null,o=Ne(t);if(!i&&!o&&r){let l=`${n} is available only as repository-local code at ${r}. Review that exact tool and rerun with --trust-project-tools.`;return e.onStatus(`Skipping ${e.language}: ${l}`),{skipped:{language:e.language,reason:l}}}if(!i&&!o&&!qr(t)){if(e.skipAutoInstall){let l=`${n} not found on PATH. To install the reviewed version, run: scip-query reindex --install-missing${t.installUrl?` (manual source: ${t.installUrl})`:""}`;return e.onStatus(`Skipping ${e.language}: ${l}`),{skipped:{language:e.language,reason:l}}}if(e.onStatus(`${n} not found. Attempting auto-install...`),!$a(t,e.onStatus)){let l=`${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}: ${l}`),{skipped:{language:e.language,reason:l}}}}let a=i?.canonicalPath??Ne(t);if(!a){let l=`${n} was not found after installation checks.`;return e.onStatus(`Skipping ${e.language}: ${l}`),{skipped:{language:e.language,reason:l}}}let{binary:s,args:c}=t.indexArgs({projectRoot:e.projectRoot,outputPath:e.scipPath,pnpmWorkspaces:e.pnpmWorkspaces,indexerBinary:a,projectPath:e.projectPath,configPath:e.language==="clojure"?e.clojureConfigPath:void 0}),u=fo({language:e.language,projectPath:e.projectPath,pnpmWorkspaces:e.pnpmWorkspaces});if(i&&!i.executable){let l=`${i.relativePath} is not executable; refusing project-local indexer.`;return e.onStatus(`Skipping ${e.language}: ${l}`),{skipped:{language:e.language,reason:l}}}return i&&e.onStatus(`Trusted project-local ${e.language} indexer ${i.relativePath} (${i.sha256.slice(0,12)}\u2026, ${i.canonicalPath}).`),{prepared:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,config:t,resolvedBinary:a,binary:s,args:c,env:Yr(t,e.env,a),...u===void 0?{}:{temporaryRootConfigContent:u},...e.temporaryProjectConfigs===void 0?{}:{temporaryProjectConfigs:e.temporaryProjectConfigs},...e.boundedConcurrency===void 0?{}:{boundedConcurrency:e.boundedConcurrency},...e.outputComposition?{outputComposition:e.outputComposition}:{},...e.shardInputPaths===void 0?{}:{shardInputPaths:e.shardInputPaths},...i?{trustedProjectTool:i}:{}}}}function sg(e,t){let n=new Set(e.filter(o=>o.skipped&&o.outputComposition).map(o=>`${o.language}\0${o.outputScipPath}`)),r=new Map;for(let o of e)if(o.skipped)Ls(t,o.skipped);else{let a=`${o.language}\0${o.outputScipPath}`;if(n.has(a))continue;let s=r.get(a)??{language:o.language,outputScipPath:o.outputScipPath,scipPaths:[],concatenate:!0};s.scipPaths.push(o.scipPath),o.outputComposition!=="protobuf-concatenate"&&(s.concatenate=!1),r.set(a,s)}let i=[];for(let o of r.values())if(o.scipPaths.length>1)o.concatenate?yi(o.scipPaths,o.outputScipPath):hi(o.scipPaths,o.outputScipPath),i.push({language:o.language,scipPath:o.outputScipPath});else{let a=o.scipPaths[0];a!==o.outputScipPath&&Is(a,o.outputScipPath),i.push({language:o.language,scipPath:o.outputScipPath})}return{indexedOutputs:i}}function Ls(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 cg(e,t,n,r,i){if(e.length===0){let o=t.map(a=>` - ${a.language}: ${a.reason}`).join(`
|
|
364
|
-
`);throw new Error(`No language indexers ran successfully. Install at least one indexer for the languages in this project.
|
|
365
|
-
`+o)}if(t.length!==0&&(i(`Indexed ${e.length} language output(s); skipped or incomplete: ${t.map(o=>o.language).join(", ")}.`),!r))throw new Error(`Failed to index all required languages; preserving the previous index. Pass --allow-partial to intentionally write an incomplete index.
|
|
366
|
-
`+t.map(o=>` - ${o.language}: ${o.reason}`).join(`
|
|
367
|
-
`))}function bs(e,t,n){if(e.length>1){n(`Merging ${e.length} language indexes...`);let r=performance.now(),i=bi(e.map(o=>o.scipPath),t);return Ds(i,n),n(`Merged and sanitized SCIP indexes in ${(performance.now()-r).toFixed(0)}ms.`),!0}else e[0].scipPath!==t&&Is(e[0].scipPath,t);return!1}async function ug(e){let t;if(lg(e))try{let i=e.incrementalTypeScript.affectedBatches.length>0?e.incrementalTypeScript.affectedBatches:[{scipPath:e.incrementalTypeScript.affectedScipPath,affectedFiles:e.incrementalTypeScript.affectedFiles,deletedFiles:e.incrementalTypeScript.deletedFiles}],o=new Set,a=0,s=0;for(let[c,u]of i.entries()){let l=O(e.run.tempPaths.runDir,`typescript-affected-${c}.db`);Os(u.scipPath,e.run.onStatus),e.run.onStatus(`Converting bounded TypeScript batch ${c+1}/${i.length} (${u.affectedFiles.length-u.deletedFiles.length} emitted, ${u.deletedFiles.length} removed) to SQLite...`);let p=performance.now();await Ss(u.scipPath,l,e.env,e.run.onStatus,!0,e.run.opts.signal),a+=performance.now()-p,St(e.run.writeTelemetry,be(l)??0);let d=bo({previousDbPath:e.run.paths.outputDb,miniDbPath:l,candidateDbPath:e.run.tempPaths.tempOutputDb,affectedFiles:u.affectedFiles,deletedFiles:u.deletedFiles,reuseCandidate:c>0,deferIntegrity:c<i.length-1,trustedPriorGeneration:!0,writeTelemetry:e.run.writeTelemetry});s+=d.durationMs;for(let f of d.changedDocumentPaths)o.add(f);he(l,{force:!0})}return e.run.onStatus(`Patched ${e.incrementalTypeScript.affectedFiles.length} SQLite document path(s) across ${i.length} bounded batch(es) in ${(s/1e3).toFixed(3)}s.`),{mode:"incremental",changedDocumentPaths:[...o].sort(),patchDurationMs:s,converterDurationMs:a,scipCompanion:e.incrementalTypeScript.completeScipUpdated?"current":"deferred"}}catch(i){if(V(e.run.opts.signal,"Reindex cancelled by its owner."),t=i instanceof Error?i.message:String(i),he(e.run.tempPaths.tempOutputDb,{force:!0}),e.run.opts.allowExpensiveRebuild===!1)throw new Error(`Bounded incremental SQLite publication failed and the whole-project fallback is disabled: ${t}`,{cause:i});e.run.onStatus(`Incremental SQLite publication unavailable: ${t}. Falling back to complete conversion.`)}let n=e.completeScipSanitized;e.completeScipAvailable||(n=await e.materializeFullFallback());let r=performance.now();return await Ss(e.run.tempPaths.tempOutputScip,e.run.tempPaths.tempOutputDb,e.env,e.run.onStatus,n,e.run.opts.signal),{mode:"full",converterDurationMs:performance.now()-r,...t?{fallbackReason:t}:{}}}function lg(e){if(!e.incrementalTypeScript||e.skippedLanguages.length>0||!B(e.run.paths.outputDb)||!B(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 dg(e,t){let n=C(),r=[...t].sort(),i=new Set(r),o={addedFiles:[],modifiedFiles:r,deletedFiles:[],changedFiles:r,unchangedFiles:e.affectedFiles.filter(a=>!i.has(a)).sort()};return{version:1,status:"evaluated",refreshResult:"rebuilt",recordedAt:new Date().toISOString(),durationMs:C()-n,manifest:e.manifest,plan:e.plan,comparison:o,evaluation:Sn(e.plan,o,e.projectFileCount)}}async function Ss(e,t,n,r,i=!1,o){if(V(o,"Reindex cancelled by its owner."),r("Converting to SQLite..."),!B(e))throw new Error(`SCIP index not found at ${e} after indexing`);try{if(i||Os(e,r),n.SCIP_QUERY_SQLITE_CONVERTER==="scip-cli"){let a=Ve();if(!a)throw new Error("scip CLI is not available");let s=await gt({command:a,args:["expt-convert","--output",t,e],label:"SCIP SQLite conversion",env:n,maxStdoutBytes:50*1024*1024,maxStderrBytes:50*1024*1024,timeoutMs:3e5,signal:o});if(s.status!==0)throw new Error(`scip expt-convert exited with ${s.status}${s.stderr.trim()?`: ${s.stderr.trim()}`:""}`)}else he(t,{force:!0}),await Yo(K(e,{maxBytes:Xe,inputKind:"SCIP index"}),t,{signal:o})}catch(a){V(o,"Reindex cancelled by its owner.");let s=a instanceof Error?a.message:String(a);throw new Error(`Failed to convert SCIP index to SQLite: ${s}`,{cause:a})}}function Os(e,t){let n=mi(e);Ds(n,t)}function Ds(e,t){e.removedDefinitionOccurrences!==0&&t(`Sanitized ${e.removedDefinitionOccurrences} invalid definition occurrences across ${e.touchedDocuments} documents before SQLite conversion.`)}function Se(e,t,n){let r=Af(e)||".scip",i=Nt(e,r);return O(I(e),`${i}.${n+1}.${t}${r}`)}async function pg(e,t){for(let n=0;n<2;n++){let r=fg(e,t);if(r)return r;let i=gg(e);if(i&&js(t.trigger,i)){t.onStatus(`Manual reindex preempting watcher refresh started at ${i.startedAt}.`);let o;try{o=await mg(i)}catch(s){throw new Error(`Could not verify the watcher's in-progress reindex owner (pid ${i.pid}); refusing to steal an active lock: ${ye(s)}`,{cause:s})}if(!o)throw new Error(`Could not confirm the watcher's in-progress reindex (pid ${i.pid}) terminated for ${I(e)}; refusing to steal an active lock.`);let a=on(e,{parseLegacy:$t});if(!ii(e,a,{parseLegacy:$t}))throw new Error(`Reindex lock ownership changed before preemption completed for ${I(e)}.`);continue}throw new _e(`Another scip-query reindex is already running for ${I(e)}.`)}throw new _e(`Could not acquire scip-query reindex lock for ${I(e)}.`)}function fg(e,t){let n=Z(process.pid),r=ct(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:$t});if(r.kind==="acquired"&&r.reclaimed){let i=Ms(r.reclaimed,e);i&&js(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 ${I(e)}.`)}return r.kind==="acquired"?()=>{r.lock.release()}:null}function gg(e){return Ms(on(e,{parseLegacy:$t}),e)}var $t=e=>{let t=Ns(e,"");return t?{pid:t.pid,...t.processIdentity?{processIdentity:t.processIdentity}:{}}:null};function Ms(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:I(t),startedAt:e.record.startedAt,trigger:n.trigger}}return Ns(e.parsed,t)}function Ns(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=Xr(n.processIdentity);return r?.pid===n.pid?{processIdentity:r}:{}})(),...n.processGroupLeader===!0?{processGroupLeader:!0}:{},projectRoot:typeof n.projectRoot=="string"?n.projectRoot:I(t),startedAt:typeof n.startedAt=="string"?n.startedAt:"unknown",trigger:n.trigger}}catch{return null}}function js(e,t){return e?.kind==="manual-cli"&&Bs(t?.trigger)}function Bs(e){return e?.kind==="watch-source"||e?.kind==="watch-git-head"||e?.kind==="watch-git-index"||e?.kind==="watch-git-state"}async function mg(e){return!we(e.pid)||(ar(e),Rs(e,"SIGTERM"),await xs(e,2e3))?!0:(ar(e),Rs(e,"SIGKILL"),xs(e,1e3))}function Rs(e,t){if(e.processGroupLeader)try{process.kill(-e.pid,t);return}catch{if(!we(e.pid))return;ar(e)}try{process.kill(e.pid,t)}catch{}}async function xs(e,t){let n=C()+t;for(;C()<n;){if(vs(e))return!0;await hg(50)}return vs(e)}function ar(e){if(!e.processIdentity)throw new Error(`Refusing to signal reindex pid ${e.pid}: its ownership record has no process identity.`);let t=Z(e.pid);if(!t)throw new Error(`Refusing to signal reindex pid ${e.pid}: its process identity is unavailable.`);if(!je(e.processIdentity,t))throw new Error(`Refusing to signal reindex pid ${e.pid}: its process identity does not match the ownership record.`)}function vs(e){if(!we(e.pid))return!0;if(!e.processIdentity)return!1;let t=Z(e.pid);return t!==null&&!je(e.processIdentity,t)}function hg(e){return new Promise(t=>setTimeout(t,e))}function lr(e,t,n){return Object.fromEntries(t.map(r=>{let i=r==="typescript"?Rr(n.typescriptProjects):[],o=r==="clojure"?bg(n.clojureConfigPath):void 0,a=[...xn(r).markerFiles,...i,...o?[o]:[]],s=r==="typescript"?{typescriptProjectMode:n.typescriptProjectMode??"single",typescriptProjects:i}:{typescriptProjectMode:"single",typescriptProjects:[]};return[r,{version:2,languages:[r],pnpmWorkspaces:r==="typescript"&&Sg(n),...s,clojureConfigPath:o,files:e.files.filter(c=>gr(c.path,r,a)).map(c=>$s(c,r))}]}))}function $s(e,t){let n=t==="typescript"&&/(?:^|\/)package\.json$/iu.test(e.path)?e.semanticHash:void 0;return{path:e.path,size:n===void 0?e.size:0,hash:n??e.hash}}function yg(e,t){let n=Ht(t);if(!n)return t;let r=n.typescriptProjectMode==="workspace"?se(e,n.typescriptProjects):["."],i=xe(r);return{...n,files:n.files.filter(o=>!ve(o.path)||i.has(o.path)).map(o=>{let a=o.semanticHash??et(e,o.path,o.hash);return $s(a===void 0?o:{...o,semanticHash:a},"typescript")})}}function bg(e){return e?.trim()||void 0}function Sg(e){return e.typescriptProjectMode!=="workspace"&&e.pnpmWorkspaces===!0}function dr(e,t){return O(I(e),"language-indexes",`${t}.scip`)}function Vs(e){return O(I(e),"language-indexes","typescript-projects")}function Ut(e,t){return O(Vs(e),`${Ln(t)}.scip`)}function ae(e){try{return tt(ce(U(e,"reindex metadata")))}catch{return null}}function Us(e,t){try{let n=ce(U(e,"reindex metadata"));if(n.kind!=="legacy"&&n.kind!=="supported")return null;let r=n.metadata;return!n.capabilities.publishableGeneration||!kr(r)||j([...r.indexedLanguages??[]].sort())!==j(t.languages)?null:j(r.fingerprint)===j(t)?"exact":j(Ps(r.fingerprint))===j(Ps(t))?"operational-config-compatible":null}catch{return null}}function Ps(e){if(typeof e!="object"||e===null||Array.isArray(e))return e;let t=e;return Array.isArray(t.files)?{...t,files:t.files.filter(n=>typeof n!="object"||n===null||Array.isArray(n)||n.path!==".scipquery.json")}:e}function Rg(e,t,n,r){let i=tt(ce(U(e,"reindex metadata")));i&&Gt(e,{...i,fingerprint:t,...i.version===Pe?{languageFingerprints:lr(t,n,r)}:{}})}function Gt(e,t){Kr(e,t,{spacing:2,trailingNewline:!0})}function Gs(e,t){try{let n=tt(ce(U(e,"reindex metadata")));if(!n)return;Gt(e,{...n,lastRefresh:t})}catch{}}function Wt(e){return{trigger:e.trigger??{kind:"unknown"},result:e.result,startedAt:new Date(e.start).toISOString(),completedAt:new Date().toISOString(),durationMs:C()-e.monotonicStart,indexedLanguages:e.languages?[...e.languages]:void 0,skipped:e.skipped?[...e.skipped]:void 0,error:e.error}}function j(e){return JSON.stringify(e)}function hS(e,t,n,r){return ws({projectRoot:e,languages:r.languages?.length?r.languages:t.languages,outputScip:n.indexPath,outputDb:n.dbPath,pnpmWorkspaces:t.indexer?.typescript?.pnpmWorkspaces,typescriptProjectMode:t.indexer?.typescript?.projectMode,typescriptProjects:t.indexer?.typescript?.projects,maxHeapMb:t.indexer?.typescript?.maxHeapMb,clojureConfigPath:t.indexer?.clojure?.configPath,skipIfUnchanged:r.force!==!0,allowPartial:r.allowPartial===!0,allowExpensiveRebuild:r.allowExpensiveRebuild===!0||r.force===!0,skipAutoInstall:r.skipAutoInstall===!0,installMissing:r.installMissing===!0,trustProjectTools:r.trustProjectTools===!0,indexerConcurrency:r.indexerConcurrency??t.indexerConcurrency,trigger:r.trigger,...r.onStatus?{onStatus:r.onStatus}:{}})}export{Li as a,Oi as b,$i as c,Dg as d,Mg as e,Hi as f,vm as g,Pm as h,xn as i,tl as j,Ym as k,al as l,Xm as m,H as n,ga as o,Ed as p,$a as q,lf as r,ws as s,hS as t};
|
|
368
|
-
//# sourceMappingURL=chunk-TULNMD5T.js.map
|