scip-query 0.23.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 +491 -2
- package/README.md +111 -122
- 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-CUtj8V2I.d.ts +19 -0
- 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-EG2CPZMJ.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-6I6L7Z62.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-ILTDAWEF.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-JTQVMR42.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-WIWY3CRX.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-M2O5NY6W.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-XBGWL66K.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-T3I6NHBH.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-VF5JZICY.js +2 -0
- 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-X6RMKHJQ.js +81 -0
- package/dist/{chunk-4ILJCCXV.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-GAS2LJMP.js → chunk-ZLADLUE6.js} +3 -3
- package/dist/chunk-ZO4YXUT6.js +4 -0
- package/dist/{chunk-HYO3NP5Q.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/frontend-profile-roles-D7eCum8P.d.ts +10 -0
- package/dist/{health-CPp2Jf1Z.d.ts → health-BtfmNrfa.d.ts} +58 -74
- 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 +3 -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.d.ts +20 -2
- 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.d.ts +2 -0
- 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 +29 -2
- 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 +17 -65
- 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.d.ts +9 -1
- package/dist/queries/passthrough-candidates.js +1 -1
- package/dist/queries/react-component-duplicates.d.ts +19 -3
- package/dist/queries/react-component-duplicates.js +1 -1
- package/dist/queries/react-hook-candidates.d.ts +22 -3
- package/dist/queries/react-hook-candidates.js +1 -1
- package/dist/queries/react-large-component-pressure.d.ts +17 -3
- 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 +23 -7
- 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 +55 -12
- 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 +70 -13
- package/docs/analyzer-inventory.md +2 -2
- package/docs/locality-analyzer-design.md +9 -9
- 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-XI2CSWEY.js +0 -2
- package/dist/call-graph-UONR6JR5.js +0 -2
- package/dist/call-graph-evidence-lZa2dwQA.d.ts +0 -11
- package/dist/chunk-26CT72HM.js +0 -2
- package/dist/chunk-2E7CX53V.js +0 -2
- package/dist/chunk-2GRUZAQF.js +0 -43
- package/dist/chunk-2LDBDR6J.js +0 -29
- package/dist/chunk-2OOY75BW.js +0 -2
- package/dist/chunk-2R3V3PSD.js +0 -4
- package/dist/chunk-2WC2OEDO.js +0 -4
- package/dist/chunk-35NLDRZC.js +0 -2
- package/dist/chunk-3AF4TUFK.js +0 -3
- package/dist/chunk-3D3QG236.js +0 -2
- package/dist/chunk-3FHOF22C.js +0 -21
- package/dist/chunk-3JKSW6LJ.js +0 -2
- package/dist/chunk-3L2ZBPEX.js +0 -133
- package/dist/chunk-3PJABJSU.js +0 -2
- package/dist/chunk-3SVF22I5.js +0 -2
- package/dist/chunk-3WR4E3A3.js +0 -3
- package/dist/chunk-4FTZ4P5G.js +0 -2
- package/dist/chunk-4UX2F3JX.js +0 -2
- package/dist/chunk-4WNW27SX.js +0 -2
- package/dist/chunk-5ENOG4VP.js +0 -61
- package/dist/chunk-64BFSI5I.js +0 -2
- package/dist/chunk-66DVSJQG.js +0 -455
- package/dist/chunk-6HFCYNYE.js +0 -9
- package/dist/chunk-6PQNKL3G.js +0 -3
- package/dist/chunk-6V5CNXL6.js +0 -2
- package/dist/chunk-6VVV4WRR.js +0 -4
- package/dist/chunk-7BWFZPPZ.js +0 -2
- package/dist/chunk-7CYG22FH.js +0 -2
- package/dist/chunk-7F45LJKI.js +0 -2
- package/dist/chunk-7IWV2EG3.js +0 -3
- package/dist/chunk-7KCZELVM.js +0 -2
- package/dist/chunk-AFHTBORT.js +0 -2
- package/dist/chunk-AVRYW5OZ.js +0 -2
- package/dist/chunk-B3X6KU75.js +0 -2
- package/dist/chunk-B5D7QPBE.js +0 -4
- package/dist/chunk-BBCIS4DX.js +0 -16
- package/dist/chunk-BDUVI7TO.js +0 -3
- package/dist/chunk-BE7ZZTMC.js +0 -2
- package/dist/chunk-BHVUJOCQ.js +0 -3
- package/dist/chunk-BJT7LSPK.js +0 -3
- package/dist/chunk-BKVWUP7Y.js +0 -2
- package/dist/chunk-BQGB4HBD.js +0 -2
- package/dist/chunk-BRV7PIFF.js +0 -2
- package/dist/chunk-CEEZJXEF.js +0 -2
- package/dist/chunk-CIYLO6SI.js +0 -7
- package/dist/chunk-CJZXN4NU.js +0 -2
- package/dist/chunk-CNO7TOKL.js +0 -2
- package/dist/chunk-COF23M5F.js +0 -2
- package/dist/chunk-CWFP7GM5.js +0 -2
- package/dist/chunk-D2DHWI3D.js +0 -2
- package/dist/chunk-D4N5SQ2M.js +0 -4
- package/dist/chunk-DBRSYFXR.js +0 -2
- package/dist/chunk-DHUIOLDT.js +0 -2
- package/dist/chunk-DIRJWYBM.js +0 -6
- package/dist/chunk-DIUFNHRJ.js +0 -35
- package/dist/chunk-DRENNWRG.js +0 -2
- package/dist/chunk-DTZCKZEU.js +0 -4
- package/dist/chunk-DULC3QFP.js +0 -5
- package/dist/chunk-DYGHBZ2N.js +0 -16
- package/dist/chunk-E5R6AQ73.js +0 -40
- package/dist/chunk-E73UNJTF.js +0 -38
- package/dist/chunk-EKV5HX33.js +0 -2
- package/dist/chunk-EQHFIL6T.js +0 -3
- package/dist/chunk-ESIQ66Z7.js +0 -2
- package/dist/chunk-EVFUMY4R.js +0 -3
- package/dist/chunk-F7DY272B.js +0 -2
- package/dist/chunk-FBN2FGXG.js +0 -2
- package/dist/chunk-FDLOBR6P.js +0 -4
- package/dist/chunk-FESCRNVV.js +0 -5
- package/dist/chunk-FFRKR4EQ.js +0 -2
- package/dist/chunk-FGA2U4OR.js +0 -8
- package/dist/chunk-FIQRSHVM.js +0 -2
- package/dist/chunk-FPYLNQPT.js +0 -2
- package/dist/chunk-FRUSVINH.js +0 -2
- package/dist/chunk-GSP44ENC.js +0 -2
- package/dist/chunk-GUFSG5TX.js +0 -2
- package/dist/chunk-GYIZ4NXB.js +0 -2
- package/dist/chunk-GZIUDL6G.js +0 -2
- package/dist/chunk-H5EXS3HM.js +0 -2
- package/dist/chunk-HCXEQRFF.js +0 -18
- package/dist/chunk-HEHOQQKH.js +0 -2
- package/dist/chunk-HKGFPJ4T.js +0 -4
- package/dist/chunk-HLZTEXRA.js +0 -2
- package/dist/chunk-HOENASQM.js +0 -3
- package/dist/chunk-HVF5VBG6.js +0 -2
- package/dist/chunk-I55I7XXP.js +0 -2
- package/dist/chunk-IDFEUFKS.js +0 -2
- package/dist/chunk-IHGQTTVW.js +0 -2
- package/dist/chunk-IICPE7B2.js +0 -20
- package/dist/chunk-IL676XCC.js +0 -18
- package/dist/chunk-IW5XQG5G.js +0 -2
- package/dist/chunk-IZDPJ2QI.js +0 -2
- package/dist/chunk-J66VOFW6.js +0 -5
- package/dist/chunk-JFMEXGFE.js +0 -2
- package/dist/chunk-JGKUET5J.js +0 -3
- package/dist/chunk-JS4PGXMV.js +0 -3
- package/dist/chunk-JWTGMPIT.js +0 -80
- package/dist/chunk-JYR66JN5.js +0 -5
- package/dist/chunk-KFOYCQAJ.js +0 -9
- package/dist/chunk-KLFEXGQA.js +0 -2
- package/dist/chunk-KMVGRIO2.js +0 -2
- package/dist/chunk-KYSDI3GE.js +0 -5
- package/dist/chunk-L6PJPETJ.js +0 -29
- package/dist/chunk-LDVT66YM.js +0 -2
- package/dist/chunk-LEECKFCJ.js +0 -2
- package/dist/chunk-LMZ5PRUV.js +0 -2
- package/dist/chunk-LQRQN2XA.js +0 -2
- package/dist/chunk-LXABEJX3.js +0 -2
- package/dist/chunk-MNV5FSBW.js +0 -3
- package/dist/chunk-MPQ4OTBM.js +0 -2
- package/dist/chunk-MTDBHTSF.js +0 -2
- package/dist/chunk-MV3CDXPI.js +0 -38
- package/dist/chunk-MWN53KRN.js +0 -60
- package/dist/chunk-MXNGIEPU.js +0 -3
- package/dist/chunk-N2ZSIIGR.js +0 -117
- package/dist/chunk-N5B2NILC.js +0 -5
- package/dist/chunk-NJITK2GP.js +0 -2
- package/dist/chunk-NOGJXYFO.js +0 -2
- package/dist/chunk-NOYBFVJA.js +0 -554
- package/dist/chunk-NWQXSFFU.js +0 -3
- package/dist/chunk-ODDUPDP7.js +0 -13
- package/dist/chunk-OLIWTZI3.js +0 -3
- package/dist/chunk-OLNV6I6U.js +0 -2
- package/dist/chunk-OR2E3AGZ.js +0 -2
- package/dist/chunk-OSR2GEHQ.js +0 -2
- package/dist/chunk-OSSESPDX.js +0 -3
- package/dist/chunk-OWOOWNJ5.js +0 -7
- package/dist/chunk-P42EIXTA.js +0 -2
- package/dist/chunk-PJFGPYTU.js +0 -2
- package/dist/chunk-PP7KNN7L.js +0 -2
- package/dist/chunk-PU7T5QYQ.js +0 -2
- package/dist/chunk-PWWAJSKV.js +0 -74
- package/dist/chunk-PZL5T7SU.js +0 -73
- package/dist/chunk-QBE3YX64.js +0 -23
- package/dist/chunk-QGVTFRY2.js +0 -7
- package/dist/chunk-QOJONDS7.js +0 -2
- package/dist/chunk-QU5XRYB5.js +0 -4
- package/dist/chunk-QUU5OBVK.js +0 -11
- package/dist/chunk-RBLQNW26.js +0 -20
- package/dist/chunk-RTQ7NEKG.js +0 -81
- package/dist/chunk-SQXRS7BG.js +0 -4
- package/dist/chunk-SSK6LDPC.js +0 -2
- package/dist/chunk-SZHGTCPP.js +0 -7
- package/dist/chunk-T4N4P2K5.js +0 -16
- package/dist/chunk-TA3QKLLU.js +0 -2
- package/dist/chunk-TEBQMNVI.js +0 -43
- package/dist/chunk-TPFHAQ2G.js +0 -2
- package/dist/chunk-TQPCBMWT.js +0 -5
- package/dist/chunk-TQZV7KV4.js +0 -2
- package/dist/chunk-TRNAEQ6P.js +0 -3
- package/dist/chunk-TY7CRN3Z.js +0 -2
- package/dist/chunk-UHFYCMZO.js +0 -35
- package/dist/chunk-UICY4GTQ.js +0 -7
- package/dist/chunk-UVGEWT4Y.js +0 -26
- package/dist/chunk-UXW33INU.js +0 -29
- package/dist/chunk-VMPRET3I.js +0 -5
- package/dist/chunk-VNLGKHS6.js +0 -6
- package/dist/chunk-VQILFTEH.js +0 -2
- package/dist/chunk-VUPHCS7Y.js +0 -57
- package/dist/chunk-VVZSBTSU.js +0 -23
- package/dist/chunk-VZRNID6A.js +0 -2
- package/dist/chunk-W5OXRYGE.js +0 -7
- package/dist/chunk-W6STWDQI.js +0 -57
- package/dist/chunk-W7CXK74K.js +0 -2
- package/dist/chunk-WB3WYIRE.js +0 -4
- package/dist/chunk-WDNVY4E7.js +0 -20
- package/dist/chunk-WK46TNUM.js +0 -3
- package/dist/chunk-WNTFFKAX.js +0 -12
- package/dist/chunk-WOIKCX6A.js +0 -2
- package/dist/chunk-WUN6KBHV.js +0 -2
- package/dist/chunk-WYCTJDVR.js +0 -2
- package/dist/chunk-WYPL7GF7.js +0 -2
- package/dist/chunk-XDAUYDFT.js +0 -2
- package/dist/chunk-XDQMU3BT.js +0 -2
- package/dist/chunk-XFA4SSO3.js +0 -3
- package/dist/chunk-XGZEP6GR.js +0 -8
- package/dist/chunk-XPDPNWTQ.js +0 -368
- package/dist/chunk-XRYABF57.js +0 -8
- package/dist/chunk-YBGKCQIS.js +0 -2
- package/dist/chunk-YEN6CYC7.js +0 -16
- package/dist/chunk-YF5IB2LF.js +0 -2
- package/dist/chunk-YI2AWIHC.js +0 -3
- package/dist/chunk-YPWBKGFU.js +0 -2
- package/dist/chunk-YPWHBBIS.js +0 -2
- package/dist/chunk-YSH6U3L4.js +0 -3
- package/dist/chunk-YU5DZUZI.js +0 -10
- package/dist/chunk-YWO5DDRC.js +0 -16
- package/dist/chunk-Z4CDXYNQ.js +0 -2
- package/dist/chunk-ZF5KHH7C.js +0 -2
- package/dist/chunk-ZOHS7AQV.js +0 -21
- package/dist/chunk-ZTI4SBFV.js +0 -3
- package/dist/code-MI6F2TTU.js +0 -2
- package/dist/code-result-json-FXALY4HE.js +0 -2
- package/dist/command-descriptors-P34VABY5.js +0 -343
- package/dist/dataflow-4KEMJPC6.js +0 -2
- package/dist/dependence-slice-R7FPWD5M.js +0 -2
- package/dist/deps-7EMQUYUT.js +0 -2
- package/dist/direct-navigation-6YO234F2.js +0 -3
- package/dist/entry-map-KOOLR26E.js +0 -2
- package/dist/files-OPIPJIGZ.js +0 -2
- package/dist/graph-evidence-Bjyky2V4.d.ts +0 -126
- package/dist/hierarchy-QPD2CAER.js +0 -2
- package/dist/imports-M6HUXRXC.js +0 -2
- package/dist/members-I5MEFOCT.js +0 -2
- package/dist/methods-5JYGGHXA.js +0 -2
- package/dist/next-anchor-candidates-BwMczMvX.d.ts +0 -90
- package/dist/output-continuation-command-UPQAAKBP.js +0 -3
- package/dist/output-pagination-3OFL2MJV.js +0 -19
- package/dist/project-reindex-UKKQ5PLS.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 -52
- 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 -63
- 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 -34
- package/dist/queries/wrapper-candidates.js +0 -2
- package/dist/refs-PSU4JZZW.js +0 -2
- package/dist/refs-pagination-JG6CJMRC.js +0 -2
- package/dist/slice-HYRATV64.js +0 -2
- package/dist/source-snippet-_wrcgmZc.d.ts +0 -15
- package/dist/stats-OOJ74B32.js +0 -2
- package/dist/surface-VTGDYWF5.js +0 -2
- package/dist/symbol-resolution-WD5EU5JE.js +0 -2
- package/dist/system-LRQNFOR2.js +0 -2
- package/dist/trace-F4B6OLL4.js +0 -2
- package/dist/value-flow-VRPZY72V.js +0 -2
- package/skills/concrete-plan/SKILL.md +0 -8
- package/skills/concrete-plan/agents/openai.yaml +0 -4
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as d}from"./chunk-7VPEEAAG.js";import{o as u}from"./chunk-ZGTYGDMF.js";import{a as m}from"./chunk-QXEUDXBT.js";import{W as f}from"./chunk-J5FJMODQ.js";import{g as a}from"./chunk-YULZRALL.js";function x(n,r,t={}){let e=m(n,r);if(!e)return[];let l=!a(e.symbol)&&!n.isIgnored(e.relativePath)?[{relativePath:e.relativePath,line:e.startLine,evidence:"indexed-definition"}]:[],p=u(n,e,{semantic:t.semantic,semanticEvidence:d}).map(i=>S(n,e.symbol,i.file,i.line)),o=new Set,c=[];for(let i of[...l,...p]){let s=`${i.relativePath}:${i.line}`;o.has(s)||(o.add(s),c.push(i))}return c}function S(n,r,t,e){return{relativePath:t,line:e,evidence:f(n,t,r)?.includes(e)?"indexed-occurrence":"source-or-chunk-candidate"}}export{x as a,S as b};
|
|
2
|
+
//# sourceMappingURL=chunk-K3YL22N6.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import{c as un,d as Ee,g as fn,h as ne,i as dt,j as J,k as pn,l as Le,m as lt,n as L,o as gn,q as mn,r as ie,s as oe,t as De,w as W,x as ae}from"./chunk-PKN354TH.js";import{c as cn,d as dn,e as we,f as Ae,i as Te,j as k,k as ke,m as En,n as Pn,o as An,p as Tn}from"./chunk-DA7RPPDF.js";import{c as P,t as se}from"./chunk-GVWX5T43.js";import{b as on,d as ot,h as ee,j as at,m as an}from"./chunk-T6DK3ZP7.js";import{A as ln,B as ct,D as Pe,E as _,F as re,G as yn,H as hn,I as Sn,T as bn,_ as vn,b as rt,ca as In,da as Rn,ea as xn,f as it,fa as wn,g as Z,i as rn,ia as ut,j as ve,k as Ie,o as w,p as te,q as v,r as Re,s as st,t as b,u as E,v as B,y as sn,ya as ft,z as xe}from"./chunk-5TNQJUR2.js";import{existsSync as kn,readdirSync as Cn,rmSync as Gn}from"fs";import{join as H}from"path";import{create as Bn,fromBinary as Mn,toBinary as sd}from"@bufbuild/protobuf";import{deserializeSCIP as pt,DocumentSchema as _n,IndexSchema as Fn,serializeSCIP as Nn}from"@c4312/scip";import{existsSync as Ii,mkdirSync as Ri,renameSync as xi,writeFileSync as wi}from"fs";import{join as Ei}from"path";import{deflateRawSync as Pi,inflateRawSync as Ai}from"zlib";function Dn(e){Ri(e.blobDir,{recursive:!0});let t=Ei(e.blobDir,`${e.blobHash}.scipdoc`);if(Ii(t)){let r=b(t,{maxBytes:te,inputKind:e.inputKind});if(r.byteLength!==e.bytes.byteLength||P(r)!==e.blobHash)throw new Error(`existing ${e.inputKind} is corrupt: ${e.relativePath}`);return}let n=`${t}.${process.pid}.${Date.now()}.tmp`;wi(n,e.bytes),xi(n,t)}var Ln=class{constructor(t=64*1024*1024,n=2e4){this.maxBytes=t;this.maxEntries=n}maxBytes;maxEntries;values=new Map;pending=new Map;bytes=0;get(t){return this.lookup(t)?.read()}lookup(t){let n=this.values.get(t)??this.pending.get(t);if(n!==void 0)return this.pending.delete(t),this.values.delete(t),this.values.set(t,n),{blobHash:n.blobHash,byteLength:n.length,read:()=>n.load?n.load():n.compressed?Ai(n.bytes,{maxOutputLength:n.length}):n.bytes===null?null:Uint8Array.from(n.bytes)}}protectForGeneration(){for(let[t,n]of this.values)this.pending.set(t,n);this.values.clear()}set(t,n){if(this.delete(t),(n?.byteLength??0)>this.maxBytes)return;let i=Ti(n),o=i.bytes?.byteLength??0;for(;this.bytes+o>this.maxBytes||this.values.size+this.pending.size>=this.maxEntries;){let a=this.values.keys().next().value;if(a===void 0)return;this.delete(a)}this.values.set(t,i),this.bytes+=o}setReference(t,n){this.delete(t.relativePath),!(this.values.size+this.pending.size>=this.maxEntries)&&this.values.set(t.relativePath,{blobHash:t.blobHash,length:t.byteLength,bytes:null,compressed:!1,load:n})}delete(t){let n=this.values.get(t)??this.pending.get(t);this.bytes-=n?.bytes?.byteLength??0,this.values.delete(t),this.pending.delete(t)}};function Ti(e){let t=e===null?null:P(e),n=e?.byteLength??0,r=e&&n>=1024?Pi(e,{level:1}):null;return r&&r.byteLength<n?{bytes:r,length:n,compressed:!0,blobHash:t}:{bytes:e===null?null:Uint8Array.from(e),length:n,compressed:!1,blobHash:t}}var gt=1,ce="typescript-scip-fragments";function ud(e){let t=new Set,n=[];for(let o of e){let a=Ce(o.relativePath);if(t.has(a))throw new Error(`duplicate TypeScript fragment replacement: ${a}`);if(t.add(a),o.bytes===null)throw new Error(`affected TypeScript mini index cannot contain a deleted document: ${a}`);let s=Mn(_n,o.bytes);if(s.relativePath!==a)throw new Error(`TypeScript fragment path mismatch: expected ${a}, got ${s.relativePath}`);n.push(s)}let r=Nn(Bn(Fn,{documents:n,externalSymbols:[]})),i=pt(r);if(i.documents.length!==n.length||i.externalSymbols.length!==0)throw new Error("affected TypeScript SCIP index failed structural verification");return r}function Li(e){let t=H(e,ce);return{rootDir:t,blobDir:H(t,"blobs"),generationDir:H(t,"generations")}}function jn(e){let t=Di(e);return ki(t.baseIndex,t.completeDocuments,"assembled")}function Di(e){let t=pt(e.baseIndexBytes);mt(t.metadata,_i(e)),Mi(t.externalSymbols);let n=Fi(e),r=new Set,i=[],o=[],a=[];for(let s of t.documents){let c=Ce(s.relativePath);if(r.has(c))throw new Error(`duplicate TypeScript SCIP document path: ${c}`);r.add(c);let d=n.get(c);if(!d){i.push(s);continue}if(n.delete(c),d.bytes===null){a.push(c);continue}let l=On(c,d.bytes);i.push(l),o.push(l)}for(let s of[...n.keys()].sort()){let c=n.get(s);if(c.bytes===null)continue;if(r.has(s))throw new Error(`duplicate TypeScript SCIP document path: ${s}`);r.add(s);let d=On(s,c.bytes);i.push(d),o.push(d)}return{baseIndex:t,completeDocuments:i,affectedDocuments:o,deletedAffectedPaths:a}}function On(e,t){let n=Mn(_n,t);if(n.relativePath!==e)throw new Error(`TypeScript fragment path mismatch: expected ${e}, got ${n.relativePath}`);return n}function ki(e,t,n){let r=Nn(Bn(Fn,{metadata:e.metadata,documents:t,externalSymbols:[]})),i=pt(r);if(i.documents.length!==t.length||i.externalSymbols.length!==0)throw new Error(`${n} TypeScript SCIP index failed structural verification`);return r}function fd(e,t){let n=Li(e);if(!kn(n.generationDir))return;let r=new Set(t.map(a=>Bi(a))),i=Cn(n.generationDir).filter(a=>a.endsWith(".json")),o=new Set;for(let a of i.filter(s=>r.has(s))){let s=Ci(E(H(n.generationDir,a),{maxBytes:w,inputKind:"TypeScript fragment manifest"}));for(let c of s.documents)o.add(`${c.blobHash}.scipdoc`)}for(let a of i)r.has(a)||Gn(H(n.generationDir,a),{force:!0});if(kn(n.blobDir))for(let a of Cn(n.blobDir))o.has(a)||Gn(H(n.blobDir,a),{force:!0})}function Ci(e){let t=JSON.parse(e);Gi(t);let n=new Set;for(let r of t.documents){if(Oi(r),Ce(r.relativePath),n.has(r.relativePath))throw new Error("duplicate TypeScript fragment record");n.add(r.relativePath)}return t}function Gi(e){if(e.version!==gt||typeof e.producerIdentity!="string"||typeof e.projectIdentity!="string"||typeof e.generationIdentity!="string"||typeof e.createdAt!="string"||!Number.isFinite(Date.parse(e.createdAt))||!Array.isArray(e.documents))throw new Error("invalid TypeScript fragment generation manifest")}function Oi(e){if(!e||typeof e.relativePath!="string"||typeof e.blobHash!="string"||!/^[a-f0-9]{64}$/.test(e.blobHash)||typeof e.byteLength!="number"||!Number.isInteger(e.byteLength)||e.byteLength<0||typeof e.documentIdentity!="string"||!e.documentIdentity)throw new Error("invalid TypeScript fragment record")}function Bi(e){if(!e)throw new Error("TypeScript fragment generation identity must be non-empty");return`${P(e)}.json`}function Mi(e){if(e.length>0)throw new Error("scip-typescript emitted external symbols; incremental document assembly is unsupported")}function mt(e,t){if(!e||typeof e!="object")throw new Error("TypeScript SCIP shard has no producer metadata");let n=e,r=n.toolInfo??n.tool_info;if(!r||typeof r!="object")throw new Error("TypeScript SCIP shard has no producer tool identity");let i=r;if(i.name!=="scip-typescript"||i.version!==yn(t))throw new Error("TypeScript SCIP shard producer identity changed")}function _i(e){let t=e.packageVersion??e.runtime?.packageVersion;if(!t)throw new Error("scip-typescript package version is unavailable");return t}function Ce(e){if(!e||e.startsWith("/")||e.startsWith("\\")||e.includes("\\"))throw new Error(`invalid TypeScript SCIP document path: ${e}`);let t=e.split("/");if(t.includes("")||t.includes(".")||t.includes(".."))throw new Error(`invalid TypeScript SCIP document path: ${e}`);return e}function Fi(e){let t=new Map;for(let n of e.fragments){let r=Ce(n.relativePath);if(t.has(r))throw new Error(`duplicate TypeScript fragment replacement: ${r}`);t.set(r,n)}if(t.size===0)throw new Error("TypeScript index assembly requires at least one replacement");return t}function pd(e,t,n){let r=e.files.filter(i=>{let o=Z(i.path,e.languages);return o==="ambient"||o==="config"&&(!bn(i.path)||n.has(i.path))}).map(i=>{let a=Z(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:${P(JSON.stringify({version:3,producerIdentity:t,pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:[...e.typescriptProjects].sort(),nonSourceInputs:r}))}`}function gd(e,t){return P(JSON.stringify({version:1,producerIdentity:t,snapshot:ve(e)}))}import{fromBinary as zi}from"@bufbuild/protobuf";import{MetadataSchema as Ui}from"@c4312/scip";var A=class extends Error{},Ni=0,ji=1,$n=2,$i=5;function yt(e,t,n){let r=0,i=0;for(;t<n;){let o=e[t];if(t+=1,i<53)r+=(o&127)*2**i;else if((o&127)!==0)throw new A("varint exceeds the safe integer range");if((o&128)===0)return{value:r,pos:t};if(i+=7,i>63)throw new A("varint is longer than 64 bits")}throw new A("varint runs past the end of the buffer")}function*I(e,t=0,n=e.length){let r=t;for(;r<n;){let i=r,o=yt(e,r,n);r=o.pos;let a=Math.floor(o.value/8),s=o.value%8;if(a===0)throw new A("field number 0 is invalid");let c=r,d=0;if(s===Ni){let l=yt(e,r,n);d=l.value,r=l.pos}else if(s===$n){let l=yt(e,r,n);if(c=l.pos,r=l.pos+l.value,r>n)throw new A("length-delimited field runs past the end of the buffer")}else if(s===ji)r+=8;else if(s===$i)r+=4;else throw new A(`unsupported wire type ${s}`);if(r>n)throw new A("field value runs past the end of the buffer");yield{fieldNumber:a,wireType:s,fieldStart:i,valueStart:c,valueEnd:r,fieldEnd:r,varint:d}}}function de(e){if(!Number.isSafeInteger(e)||e<0)throw new A(`cannot encode varint ${e}`);let t=[],n=e;do{let r=n%128;n=Math.floor(n/128),n>0&&(r|=128),t.push(r)}while(n>0);return Uint8Array.from(t)}function Ge(e){return de(e*8+$n)}var Wi=1,qi=3;function le(e){let t=new TextDecoder,n;for(let r of I(e))if(!(r.fieldNumber!==Wi||r.wireType!==2))for(let i of I(e,r.valueStart,r.valueEnd)){if(i.fieldNumber!==qi||i.wireType!==2)continue;let o=t.decode(e.subarray(i.valueStart,i.valueEnd));o&&(n=o)}return n}import{existsSync as Be,readdirSync as ht,rmSync as Wn}from"fs";import{join as C}from"path";var Me=1,ue="typescript-scip-overlays",qn="typescript-project-v3:";function Vi(e){let t=Vn(e.cacheDir,e.previousGenerationIdentity);Yi(e,t);let n=new Map((t?.overlays??[]).map(o=>[o.relativePath,o])),r=new Set;for(let o of e.fragments){let a=_e(o.relativePath);if(r.has(a))throw new Error(`duplicate TypeScript overlay: ${a}`);r.add(a),n.set(a,Xi(e.cacheDir,o))}if(Hi(e,n,r),r.size===0)throw new Error("TypeScript overlay generation requires affected documents");let i={version:Me,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,baseGenerationIdentity:t?.baseGenerationIdentity??e.previousGenerationIdentity,generationIdentity:e.nextGenerationIdentity,createdAt:(e.now??(()=>new Date))().toISOString(),overlays:[...n.values()].sort((o,a)=>o.relativePath.localeCompare(a.relativePath))};return Qi(e.cacheDir,i),i}function Ad(e){let t=[],n=!1,r=new TextDecoder("utf-8",{fatal:!0});for(let i of I(e.indexBytes)){if(i.wireType!==2)continue;let o=e.indexBytes.subarray(i.valueStart,i.valueEnd);if(i.fieldNumber===1)mt(zi(Ui,o),e.packageVersion),n=!0;else{if(i.fieldNumber===3)throw new Error("TypeScript overlay seed cannot contain external symbols");if(i.fieldNumber===2){let a=Ji(o,r);t.push({relativePath:a,bytes:o,occurrences:0,symbols:0,referenceFragments:[]})}}}if(!n)throw new Error("TypeScript overlay seed has no producer identity");return Vi({...e,previousGenerationIdentity:e.generationIdentity,nextGenerationIdentity:e.generationIdentity,baseShardCurrent:!0,fragments:t})}function Ji(e,t){let n;for(let r of I(e))r.fieldNumber===1&&r.wireType===2&&(n=t.decode(e.subarray(r.valueStart,r.valueEnd)));if(!n)throw new Error("TypeScript overlay seed document has no path");return n}function Hi(e,t,n){for(let r of e.retainedDocuments??[]){Jn(r);let i=_e(r.relativePath);if(n.has(i))throw new Error(`duplicate TypeScript overlay: ${i}`);let o=t.get(i);if(!r.blobHash||!o||o.blobHash!==r.blobHash||o.byteLength!==r.byteLength)throw new Error(`retained TypeScript overlay does not match its accepted blob: ${i}`);Un(e.cacheDir,r),n.add(i)}}function Yi(e,t){if(!t&&!e.baseShardCurrent)throw new Error("deferred TypeScript SCIP base has no matching overlay generation");if(t?.producerIdentity!==void 0&&t.producerIdentity!==e.producerIdentity)throw new Error("TypeScript overlay producer identity changed");let n=Ki(e,t);if(t&&t.projectIdentity!==e.projectIdentity&&!e.allowProjectIdentityChange&&!n)throw new Error("TypeScript overlay project identity changed")}function Ki(e,t){return e.allowLegacyProjectIdentityMigration===!0&&t!==null&&!t.projectIdentity.startsWith(qn)&&e.projectIdentity.startsWith(qn)}function Td(e){let t=Vn(e.cacheDir,e.generationIdentity);if(!t)throw new Error("TypeScript overlay generation is unavailable");let n=t.overlays.map(r=>{if(r.blobHash===null)return{relativePath:r.relativePath,bytes:null,occurrences:0,symbols:0,referenceFragments:[]};let i=Un(e.cacheDir,r);return{relativePath:r.relativePath,bytes:i,occurrences:0,symbols:0,referenceFragments:[]}});return jn({packageVersion:e.packageVersion,baseIndexBytes:e.baseIndexBytes,fragments:n})}function Un(e,t){let n=b(C(fe(e),"blobs",`${t.blobHash}.scipdoc`),{maxBytes:te,inputKind:"TypeScript overlay blob"});if(n.byteLength!==t.byteLength||P(n)!==t.blobHash)throw new Error(`TypeScript overlay blob is corrupt: ${t.relativePath}`);return n}function Ld(e,t){let n=fe(e),r=C(n,"generations");if(!Be(r))return;let i=new Set(t.map(bt)),o=new Set;for(let s of ht(r).filter(c=>i.has(c))){let c=St(E(C(r,s),{maxBytes:w,inputKind:"TypeScript overlay manifest"}));for(let d of c.overlays)d.blobHash&&o.add(`${d.blobHash}.scipdoc`)}for(let s of ht(r))i.has(s)||Wn(C(r,s),{force:!0});let a=C(n,"blobs");if(Be(a))for(let s of ht(a))o.has(s)||Wn(C(a,s),{force:!0})}function Vn(e,t){let n=C(fe(e),"generations",bt(t));if(!Be(n))return null;let r=St(E(n,{maxBytes:w,inputKind:"TypeScript overlay manifest"}));if(r.generationIdentity!==t)throw new Error("TypeScript overlay generation identity does not match its path");return r}function Xi(e,t){let n=_e(t.relativePath);if(t.bytes===null)return{relativePath:n,blobHash:null,byteLength:0};let r=Buffer.from(t.bytes),i=P(r);return Dn({blobDir:C(fe(e),"blobs"),blobHash:i,bytes:r,relativePath:n,inputKind:"TypeScript overlay blob"}),{relativePath:n,blobHash:i,byteLength:r.byteLength}}function Qi(e,t){let n=C(fe(e),"generations",bt(t.generationIdentity));if(Be(n)){let r=St(E(n,{maxBytes:w,inputKind:"TypeScript overlay manifest"}));if(zn(r)!==zn(t))throw new Error(`TypeScript overlay generation is immutable: ${t.generationIdentity}`);return}Te(n,t,{spacing:2,trailingNewline:!0})}function St(e){let t=JSON.parse(e);Zi(t);let n=new Set;for(let r of t.overlays){if(Jn(r),_e(r.relativePath),n.has(r.relativePath))throw new Error("duplicate TypeScript overlay record");n.add(r.relativePath)}return t}function Zi(e){if(e.version!==Me||!Oe(e.producerIdentity)||!Oe(e.projectIdentity)||!Oe(e.baseGenerationIdentity)||!Oe(e.generationIdentity)||typeof e.createdAt!="string"||!Number.isFinite(Date.parse(e.createdAt))||!Array.isArray(e.overlays))throw new Error("invalid TypeScript overlay manifest")}function Oe(e){return typeof e=="string"&&e!==""}function Jn(e){let t=e;if(!t||typeof t.relativePath!="string"||t.blobHash!==null&&(typeof t.blobHash!="string"||!/^[a-f0-9]{64}$/.test(t.blobHash))||!Number.isInteger(t.byteLength)||t.byteLength<0||t.blobHash===null&&t.byteLength!==0)throw new Error("invalid TypeScript overlay record")}function fe(e){return C(e,ue)}function bt(e){if(!e)throw new Error("TypeScript overlay generation identity must be non-empty");return`${P(e)}.json`}function zn(e){return P(JSON.stringify({version:e.version,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,baseGenerationIdentity:e.baseGenerationIdentity,generationIdentity:e.generationIdentity,overlays:e.overlays}))}function _e(e){if(!e||e.startsWith("/")||e.includes("\\")||e.split("/").some(t=>!t||t==="."))throw new Error(`invalid TypeScript overlay path: ${e}`);if(e.split("/").includes(".."))throw new Error(`invalid TypeScript overlay path: ${e}`);return e}import{spawn as eo}from"child_process";import{platform as Hn}from"os";import{performance as Yn}from"perf_hooks";var Bd={probe:1e4,git:3e4,analysis:18e4,install:3e5,indexer:6e5},ge=class extends Error{constructor(n,r,i,o={}){super(i,o.cause===void 0?void 0:{cause:o.cause});this.kind=n;this.label=r;this.name="BoundedProcessError",this.timedOut=o.timedOut??!1,this.reaped=o.reaped??!1,this.stdout=o.stdout??"",this.stderr=o.stderr??"",this.stdoutTruncated=o.stdoutTruncated??!1,this.stderrTruncated=o.stderrTruncated??!1}kind;label;timedOut;reaped;stdout;stderr;stdoutTruncated;stderrTruncated};function pe(e,t){if(!Number.isFinite(e)||e<=0)throw new TypeError(`${t} must be a positive finite number.`)}function Kn(e,t,n,r){let i=Math.max(0,r-n);i>0&&e.push(t.subarray(0,i))}function Xn(e,t,n){let r=Buffer.concat([...e,t]);e.length=0,e.push(r.subarray(Math.max(0,r.length-n)))}function Md(e){pe(e.timeoutMs,"timeoutMs"),pe(e.maxStdoutBytes,"maxStdoutBytes"),pe(e.maxStderrBytes,"maxStderrBytes");let t=e.terminationGraceMs??1e3;pe(t,"terminationGraceMs");let n=e.terminationForceMs??t;return pe(n,"terminationForceMs"),new Promise((r,i)=>{let o=Yn.now(),a=Hn()!=="win32"&&process.env.SCIP_REINDEX_PROCESS_GROUP_LEADER==="1",s=Hn()!=="win32"&&!a,c;try{c=eo(e.command,[...e.args??[]],{cwd:e.cwd,env:e.env,detached:s?!0:e.detached,stdio:["pipe","pipe","pipe"]})}catch(m){let S=m instanceof Error?m.message:String(m);i(new ge("spawn",e.label,`${e.label} could not start: ${S}`,{cause:m,reaped:!0}));return}let d=[],l=[],f=0,g=0,x=!1,D=!1,M=null,$=!1,tn=c.pid===void 0?null:Pn(c.pid,s),Qe=()=>{clearTimeout(nn),e.signal?.removeEventListener("abort",et)},Ze=m=>{if($||!M)return;$=!0,Qe();let S=Buffer.concat(d).toString("utf8"),tt=Buffer.concat(l).toString("utf8"),nt=m.reaped||!m.detail?"":` Process-tree cleanup failed: ${m.detail}`;i(new ge(M.kind,e.label,`${M.message}${nt}`,{timedOut:M.timedOut,reaped:m.reaped,stdout:S,stderr:tt,stdoutTruncated:x,stderrTruncated:D}))},Q=m=>{if(!(M||$)){if(M=m,!tn){Ze({reaped:c.pid===void 0,reason:c.pid===void 0?"terminated":"identity-unavailable"});return}An(tn,{gracefulMs:t,forceMs:n}).then(Ze,S=>{Ze({reaped:!1,reason:"signal-failed",detail:S instanceof Error?S.message:String(S)})})}},nn=setTimeout(()=>{Q({kind:"timeout",timedOut:!0,message:`${e.label} timed out after ${e.timeoutMs}ms.`})},e.timeoutMs);nn.unref();let et=()=>{Q({kind:"aborted",timedOut:!1,message:`${e.label} was cancelled.`})};e.signal?.addEventListener("abort",et,{once:!0}),e.signal?.aborted&&et(),c.stdout.on("data",m=>{let S=Buffer.isBuffer(m)?m:Buffer.from(m);e.outputLimitBehavior==="truncate-tail"?Xn(d,S,e.maxStdoutBytes):Kn(d,S,f,e.maxStdoutBytes),f+=S.length,f>e.maxStdoutBytes&&(x=!0,e.outputLimitBehavior!=="truncate-tail"&&Q({kind:"stdout-limit",timedOut:!1,message:`${e.label} exceeded stdout limit (${e.maxStdoutBytes} bytes).`}))}),c.stderr.on("data",m=>{let S=Buffer.isBuffer(m)?m:Buffer.from(m);e.outputLimitBehavior==="truncate-tail"?Xn(l,S,e.maxStderrBytes):Kn(l,S,g,e.maxStderrBytes),g+=S.length,g>e.maxStderrBytes&&(D=!0,e.outputLimitBehavior!=="truncate-tail"&&Q({kind:"stderr-limit",timedOut:!1,message:`${e.label} exceeded stderr limit (${e.maxStderrBytes} bytes).`}))}),c.on("error",m=>{if(!$&&!M){if(c.pid===void 0){Qe(),$=!0,i(new ge("spawn",e.label,`${e.label} could not start: ${m.message}`,{cause:m,reaped:!0}));return}Q({kind:"spawn",timedOut:!1,message:`${e.label} failed after start: ${m.message}`})}}),c.on("close",(m,S)=>{if($||M)return;$=!0,Qe();let tt=Buffer.concat(d).toString("utf8"),nt=Buffer.concat(l).toString("utf8");r({status:m,signal:S,stdout:tt,stderr:nt,timedOut:!1,durationMs:Yn.now()-o,stdoutTruncated:x,stderrTruncated:D})}),e.input===void 0?c.stdin.end():c.stdin.end(e.input)})}import{execFileSync as je}from"child_process";import{createRequire as Eo}from"module";import{chmodSync as Po,existsSync as or}from"fs";import{platform as F,arch as $e}from"os";import{dirname as Ao,join as ar}from"path";import{createHash as Zn,randomUUID as to}from"crypto";import{closeSync as Fe,createReadStream as no,existsSync as ro,fsyncSync as io,mkdirSync as oo,openSync as It,renameSync as ao,unlinkSync as so,writeSync as co}from"fs";import{homedir as lo}from"os";import{dirname as er,join as vt}from"path";var uo=3e5,fo=256*1024*1024;function tr(e,t=process.env){let n=t.SCIP_QUERY_CACHE_DIR??(t.XDG_CACHE_HOME?vt(t.XDG_CACHE_HOME,"scip-query"):vt(lo(),".cache","scip-query"));return vt(n,e)}var h=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 nr(e){let{cachePath:t,url:n,expectedSha256:r}=e,i=e.timeoutMs??uo,o=e.maxBytes??fo,a=e.lockWaitMs??i;po(i,o,a);let s=go(n,i,e.signal);try{let c=await Qn(t,r,o,s.controller.signal);if(c)return{status:"cached",path:t,sha256:c};oo(er(t),{recursive:!0});let d=await dt(`${t}.fetch.lock`,{waitMs:a,pollMs:25,signal:s.controller.signal});if(!d)throw new h("lock-timeout",`timed out waiting ${a}ms for verified binary cache ownership at ${t}`);try{let l=await Qn(t,r,o,s.controller.signal);return l?{status:"cached",path:t,sha256:l}:await mo(e,s.controller,o)}finally{d.release()}}catch(c){return wo(c,s.controller.signal,n)}finally{clearTimeout(s.timeout),s.detachExternalAbort(),s.controller.signal.aborted||s.controller.abort()}}function po(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 go(e,t,n){let r=new AbortController,i=()=>{r.abort(new h("aborted",`download of ${e} was aborted`,{cause:n?.reason}))};n?.addEventListener("abort",i,{once:!0}),n?.aborted&&i();let o=setTimeout(()=>{r.abort(new h("timeout",`download of ${e} timed out after ${t}ms`))},t);return o.unref(),{controller:r,timeout:o,detachExternalAbort:()=>n?.removeEventListener("abort",i)}}async function Qn(e,t,n,r){if(!ro(e))return null;let i=Zn("sha256"),o=0;try{for await(let s of no(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 Y(r,e);return null}let a=i.digest("hex");return a===t?a:null}async function mo(e,t,n){let r=await yo(e,t),i=vo(r,n,e.url);if(!r.body)throw new h("stream",`downloaded ${e.url} response has no readable body`);let o=`${e.cachePath}.tmp-${process.pid}-${to()}`,a,s=!1;try{a=It(o,"wx",384),s=!0;let c=await So(r.body,a,e,t,n,i);Fe(a),a=void 0;try{Io(o,e.cachePath,e.renameImpl??ao,e.syncImpl??io)}catch(d){throw new h("install",`failed to install verified binary at ${e.cachePath}`,{cause:d})}return s=!1,{status:"downloaded",path:e.cachePath,sha256:c}}catch(c){throw t.signal.aborted?Y(t.signal,e.url):c instanceof h?c:new h("install",`failed to stage verified binary at ${e.cachePath}`,{cause:c})}finally{bo(a,o,s)}}async function yo(e,t){let n=e.fetchImpl??fetch,r;try{r=await rr(n(e.url,{signal:t.signal}),t.signal)}catch(i){throw t.signal.aborted?Y(t.signal,e.url):new h("stream",`failed to download ${e.url}: ${ir(i)}`,{cause:i})}if(!r.ok){let i=new h("http",`failed to download ${e.url}: HTTP ${r.status}`);throw t.abort(i),i}return r}function ho(e,t,n,r,i){if(e>n||t!==void 0&&e>t){let o=new h("length",`downloaded ${r} exceeded its ${t??n} byte limit`);throw i.abort(o),o}}async function So(e,t,n,r,i,o){let a=e.getReader(),s=Zn("sha256"),c=0;for(;;){let{done:l,value:f}=await rr(a.read(),r.signal);if(l)break;if(!(f instanceof Uint8Array))throw new h("stream",`downloaded ${n.url} produced a non-byte stream chunk`);c+=f.byteLength,ho(c,o,i,n.url,r);let g=Buffer.from(f.buffer,f.byteOffset,f.byteLength);s.update(g),ln(t,g,{writeFile:n.writeImpl??co},"verified binary staging")}if(o!==void 0&&c!==o)throw new h("length",`downloaded ${n.url} length mismatch: declared ${o} bytes, received ${c}`);let d=s.digest("hex");if(d!==n.expectedSha256)throw new h("checksum",`downloaded ${n.url} checksum mismatch: expected ${n.expectedSha256}, got ${d}`);return d}function bo(e,t,n){if(e!==void 0)try{Fe(e)}catch{}if(n)try{so(t)}catch{}}function vo(e,t,n){let r=e.headers?.get("content-length");if(r==null)return;if(!/^\d+$/.test(r))throw new h("length",`downloaded ${n} has an invalid Content-Length header`);let i=Number(r);if(!Number.isSafeInteger(i)||i<0)throw new h("length",`downloaded ${n} has an invalid Content-Length header`);if(i>t)throw new h("length",`downloaded ${n} declares ${i} bytes, above the ${t} byte limit`);return i}function Io(e,t,n,r){Ro(e,r),n(e,t),xo(er(t),r)}function Ro(e,t){let n=It(e,"r");try{t(n)}finally{Fe(n)}}function xo(e,t){let n;try{n=It(e,"r")}catch(r){if(ct(r,process.platform))return;throw r}try{t(n)}catch(r){if(!ct(r,process.platform))throw r}finally{Fe(n)}}function rr(e,t){return t.aborted?Promise.reject(Y(t,"operation")):new Promise((n,r)=>{let i=()=>{t.removeEventListener("abort",i),r(Y(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 Y(e,t){return e.reason instanceof Error?e.reason:new h("aborted",`verified binary operation for ${t} was aborted`)}function ir(e){return e instanceof Error?e.message:String(e)}function wo(e,t,n){throw t.aborted?Y(t,n):e instanceof h?e:new h("stream",`failed to download ${n}: ${ir(e)}`,{cause:e})}var R="v0.8.1",Rt="https://github.com/sourcegraph/scip",Ne=`github.com/sourcegraph/scip/cmd/scip@${R}`,sr=Eo(import.meta.url),To={"scip-darwin-amd64.tar.gz":"39f18be957d350bcd9ed5cb12d7781b0e237a5cb2429a107feaf9ce2d1dcd5d5","scip-darwin-arm64.tar.gz":"5b3f4a2fb1dc10c599cb3422ed0406a739060e4ac0b1222c0f43630dd0dd8221","scip-linux-amd64.tar.gz":"16b79ed98f893abd530cfa63f333527f1351008b4a23e02b9e522e34d1da6596","scip-linux-arm64.tar.gz":"876dfb680119dd6e5713077c49b27701102d598bdeba94c809173276d399c7e2"},cr="SCIP_QUERY_SCIP_BIN";function Qd(e=process.env){return e.SCIP_QUERY_SQLITE_CONVERTER==="scip-cli"}function Lo(e){let t=e.env[cr];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 Do(e){for(let t of e==="arm64"?["arm64","x64"]:[e])try{return sr.resolve(`scip-query-scip-windows/scip-win32-${t}.exe`)}catch{}return null}function xt(e=process.env){return ko(e)?.path??null}function ko(e=process.env){let t=Lo({platform:F(),arch:$e(),env:e,isOnPath:ke,fileExists:or,resolveSidecar:Do,resolveCached:()=>Co(e)});return t?.source==="path"?{source:"path",path:En("scip")??t.path}:t}function dr(e=process.env){return tr(ar("scip",R,"scip"),e)}function Co(e){let t=dr(e);return or(t)?t:null}function Go(e){return e!==null&&e.includes(R.replace(/^v/,""))}function Zd(){return xt()!==null}function Oo(){let e=xt();if(!e)return null;try{return je(e,["--version"],{stdio:"pipe",timeout:1e4,killSignal:"SIGKILL"}).toString().trim()}catch{return null}}function Bo(e=F(),t=$e()){let n=lr(e,t);if(!n)return null;let r=To[n.filename];return r?{...n,sha256:r}:null}function lr(e=F(),t=$e()){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:`${Rt}/releases/download/${R}/${o}`,filename:o}}function el(){let e=lr();if(console.log("\nThe `scip` CLI is required but not found on PATH.\n"),F()==="darwin"||F()==="linux")console.log(`Let scip-query install the reviewed release (${R}, digest-verified) into its cache:`),console.log(` scip-query setup --install-missing
|
|
2
|
+
`),console.log("Or install it with Go:"),console.log(` go install ${Ne}
|
|
3
|
+
`),console.log("Or download that exact release manually:");else if(F()==="win32"){let t=Mo();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 ${cr} to a local scip.exe path.
|
|
4
|
+
`),console.log("Upstream release page:")}else console.log("Download from:");console.log(e?` ${e.url}
|
|
5
|
+
`:` ${Rt}/releases/tag/${R}
|
|
6
|
+
`),console.log("After installing, ensure `scip` is on your PATH and run `scip-query reindex`.")}function Mo(){let t=sr("../../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 _o={fetch:nr,extract:(e,t)=>{je("tar",["-xzf",e,"-C",t,"scip"],{stdio:"pipe",timeout:12e4,killSignal:"SIGKILL"})},markExecutable:e=>Po(e,493),probeVersion:e=>No(e),env:process.env};async function Fo(e,t={}){let n={..._o,...t},r=Bo();if(!r)return e(`No reviewed scip ${R} release archive is published for ${F()}/${$e()}.`),null;let i=dr(n.env),o=Ao(i),a=ar(o,r.filename);e(`Downloading reviewed scip ${R} (${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 ${R}: ${c instanceof Error?c.message:String(c)}`),null}let s=n.probeVersion(i);return Go(s)?(e(`Installed reviewed scip ${R} at ${i}.`),i):(e(`Installed scip at ${i} did not report ${R} (reported: ${s??"unavailable"}).`),null)}function No(e){try{return je(e,["--version"],{stdio:"pipe",timeout:1e4,killSignal:"SIGKILL"}).toString().trim()}catch{return null}}async function tl(e,t={}){if(F()!=="win32"&&await Fo(e,t)!==null)return!0;if(ke("go")){e(`Installing immutable ${Ne} via go install into the Go bin directory (GOBIN or GOPATH/bin); expected executable: scip.`);try{if(je("go",["install",Ne],{stdio:"inherit",timeout:3e5,env:process.env}),jo(e))return!0}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: ${Rt}/releases/tag/${R}`),!1}function jo(e){if(ke("scip")){let t=xt(),n=Oo();if(t&&n&&n.includes(R))return e(`Successfully installed ${Ne}; resolved executable: ${t}; reported version: ${n}.`),!0;e(`go install completed, but the resolved scip executable did not report ${R} (executable: ${t??"unresolved"}; version: ${n??"unavailable"}).`)}return!1}var ur=class extends Error{constructor(t){super(t),this.name="ReindexLockUnavailableError"}};import{execFileSync as $o}from"child_process";import{existsSync as Wo,readdirSync as fr}from"fs";import{extname as pr,join as gr}from"path";var mr=new Set([".git",".hg",".svn",".idea",".vscode","node_modules","vendor","dist","build","target","bin","obj",".dart_tool",".gradle",".next",".venv","venv","__pycache__"]),qo=[{language:"typescript",files:["tsconfig.json","tsconfig.base.json"],extensions:[".ts",".tsx",".mts",".cts"]},{language:"rust",files:["Cargo.toml"],extensions:[".rs"]},{language:"go",files:["go.mod"],extensions:[".go"]},{language:"java",files:["pom.xml","build.gradle","build.gradle.kts"],extensions:[".java"]},{language:"kotlin",files:["build.gradle.kts"],extensions:[".kt",".kts"]},{language:"scala",files:["build.sbt"],extensions:[".scala"]},{language:"clojure",files:["deps.edn","project.clj","bb.edn","shadow-cljs.edn"],extensions:[".clj",".cljs",".cljc"]},{language:"python",files:["pyproject.toml","setup.py","setup.cfg","Pipfile"],extensions:[".py",".pyi"]},{language:"ruby",files:["Gemfile"],extensions:[".rb"]},{language:"cpp",files:["compile_commands.json","CMakeLists.txt","Makefile"],extensions:[".cc",".cpp",".cxx",".hpp",".hh",".hxx"]},{language:"c",files:["compile_commands.json","CMakeLists.txt","Makefile"],extensions:[".c",".h"]},{language:"csharp",globs:["*.csproj","*.sln"],extensions:[".cs"]},{language:"vb",globs:["*.vbproj"],extensions:[".vb"]},{language:"dart",files:["pubspec.yaml"],extensions:[".dart"]},{language:"php",files:["composer.json"],extensions:[".php"]},{language:"javascript",files:["package.json"],extensions:[".js",".jsx",".mjs",".cjs"]}];function cl(e){let t=[],n=zo(e),r=Ho(e);for(let i of qo){if(Uo(e,i.files)){t.push(i.language);continue}if(Vo(n,i.globs)){t.push(i.language);continue}Xo(r,i.extensions)&&t.push(i.language)}return t.includes("typescript")&&wt(t,"javascript"),Qo(t,r),t}function zo(e){try{return fr(e)}catch{return[]}}function Uo(e,t){return t?.length?t.some(n=>Wo(gr(e,n))):!1}function Vo(e,t){return t?.length?e.some(n=>t.some(r=>Jo(n,r))):!1}function Jo(e,t){if(t==="*")return!0;if(!t.includes("*"))return e===t;let[n,r]=t.split("*");return e.startsWith(n??"")&&e.endsWith(r??"")}function Ho(e){let t=Ko(e);if(t)return t;let n=new Set,r=[e];for(;r.length>0;){let i=r.pop();if(!i)continue;let o;try{o=fr(i,{withFileTypes:!0})}catch{continue}Yo(i,o,r,n)}return n}function Yo(e,t,n,r){for(let i of t){if(i.name.startsWith(".")&&!i.name.endsWith("proj")&&!i.name.endsWith("sln")&&i.isDirectory())continue;let o=gr(e,i.name);if(i.isDirectory()){mr.has(i.name)||n.push(o);continue}let a=pr(i.name).toLowerCase();a&&r.add(a)}}function Ko(e){try{let t=hn(e,26214400,()=>$o("git",["-C",e,"ls-files","-co","-v","-z","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:52428800,stdio:["ignore","pipe","ignore"],timeout:3e4,killSignal:"SIGKILL"})),n=new Set;for(let r of Sn(t)){if(r.split("/").some(o=>mr.has(o)))continue;let i=pr(r).toLowerCase();i&&n.add(i)}return n}catch{return null}}function Xo(e,t){return t?.length?t.some(n=>e.has(n)):!1}function wt(e,t){let n=e.indexOf(t);n!==-1&&e.splice(n,1)}function Qo(e,t){if(e.includes("cpp")&&e.includes("c")){let n=t.has(".c"),r=[".cc",".cpp",".cxx"].some(i=>t.has(i));n&&!r?wt(e,"cpp"):n||wt(e,"c")}}import{writeSync as Zo}from"fs";function T(e,t,n="File"){let r=0;for(;r<t.byteLength;){let i=Zo(e,t,r,t.byteLength-r);if(i<=0)throw new Error(`${n} write made no forward progress.`);r+=i}}import{closeSync as yr,openSync as ea,renameSync as ta,rmSync as na}from"fs";import{create as We,fromBinary as hr,toBinary as ra}from"@bufbuild/protobuf";import{DocumentSchema as qe,IndexSchema as ia,MetadataSchema as oa,PositionEncoding as Et,SymbolInformationSchema as aa,SymbolRole as Sr}from"@c4312/scip";var Pt=2,sa=3,ca=1,da=2,la=3,ua=4,fa=6,pa=1,ga=2,ma=3;function bl(e){let t;try{t=b(e,{inputKind:"SCIP sanitization input",maxBytes:v})}catch{return{removedDefinitionOccurrences:0,touchedDocuments:0}}try{return ya(t,e)}catch(n){if(n instanceof A)return{removedDefinitionOccurrences:0,touchedDocuments:0};throw n}}function ya(e,t){let n=new TextDecoder,r=new Set;ha(e,n,r);let i=0,o=0,a=[],s=Ia(e);for(let c of I(e)){if(c.wireType!==2||c.fieldNumber!==Pt)continue;let d=ba(e,c,n,r,s);wr(d)&&(i+=d.removed,o+=d.symbols.length,a.push({field:c,repair:d}))}return a.length>0&&va(e,t,a),Ir(i,a.length,o)}function br(e,t,n,r){if((t&Sr.Definition)!==0){if(!e){r.removed++;return}e.startsWith("local ")||n.has(e)||(n.add(e),r.symbols.push(e))}}function vr(e,t){return wr(t)?We(qe,{...e,positionEncoding:t.positionEncoding??e.positionEncoding,occurrences:e.occurrences.filter(n=>n.symbol||(n.symbolRoles&Sr.Definition)===0),symbols:[...e.symbols,...t.symbols.map(n=>We(aa,{symbol:n}))]}):e}function Ir(e,t,n){return{removedDefinitionOccurrences:e,touchedDocuments:t,...n>0?{recoveredDefinitionSymbols:n}:{}}}function ha(e,t,n){for(let r of I(e))r.wireType===2&&(r.fieldNumber===Pt?Sa(e,r,t,n):r.fieldNumber===sa&&Rr(e,r,t,n))}function Sa(e,t,n,r){for(let i of I(e,t.valueStart,t.valueEnd))i.wireType===2&&(i.fieldNumber===ca?it(n.decode(e.subarray(i.valueStart,i.valueEnd))):i.fieldNumber===la&&Rr(e,i,n,r))}function Rr(e,t,n,r){for(let i of I(e,t.valueStart,t.valueEnd)){if(i.wireType!==2||i.fieldNumber!==pa)continue;let o=n.decode(e.subarray(i.valueStart,i.valueEnd));o&&r.add(o)}}function ba(e,t,n,r,i){let o={removed:0,symbols:[]},a="",s=Et.UnspecifiedPositionEncoding;for(let c of I(e,t.valueStart,t.valueEnd)){if(c.fieldNumber===ua&&c.wireType===2&&(a=n.decode(e.subarray(c.valueStart,c.valueEnd))),c.fieldNumber===fa&&c.wireType===0&&(s=c.varint),c.wireType!==2||c.fieldNumber!==da)continue;let{symbol:d,symbolRoles:l}=Ra(e,c,n);br(d,l,r,o)}return o.positionEncoding=At(a,s,i),o}function va(e,t,n){let r=`${t}.sanitize-tmp`,i=ea(r,"w",384);try{let o=0;for(let{field:a,repair:s}of n){T(i,e.subarray(o,a.fieldStart));let c=vr(hr(qe,e.subarray(a.valueStart,a.valueEnd)),s),d=ra(qe,c);T(i,Ge(Pt)),T(i,de(d.byteLength)),T(i,d),o=a.fieldEnd}T(i,e.subarray(o))}catch(o){throw yr(i),na(r,{force:!0}),o}yr(i),ta(r,t)}function xr(e){let t=new Set;for(let a of e.documents){it(a.relativePath);for(let s of a.symbols)s.symbol&&t.add(s.symbol)}for(let a of e.externalSymbols)a.symbol&&t.add(a.symbol);let n=0,r=0,i=0,o=e.documents.map(a=>{let s={removed:0,symbols:[]};for(let d of a.occurrences)br(d.symbol,d.symbolRoles,t,s);s.positionEncoding=At(a.language,a.positionEncoding,e.metadata);let c=vr(a,s);return c!==a&&i++,n+=s.removed,r+=s.symbols.length,c});return{index:i===0?e:We(ia,{...e,documents:o}),...Ir(n,i,r)}}function wr(e){return e.removed>0||e.symbols.length>0||e.positionEncoding!==void 0}function At(e,t,n){if(t===Et.UnspecifiedPositionEncoding&&!(e!==""&&e!=="python")&&!(n?.toolInfo?.name!=="scip-python"||!["0.7.4","0.7.5"].includes(n.toolInfo.version)))return Et.UTF16CodeUnitOffsetFromLineStart}function Tt(e,t){let n=At(e.language,e.positionEncoding,t);return n===void 0?e:We(qe,{...e,positionEncoding:n})}function Ia(e){let t;for(let n of I(e)){if(n.fieldNumber!==1||n.wireType!==2)continue;let r=hr(oa,e.subarray(n.valueStart,n.valueEnd));if(!r.toolInfo||t&&JSON.stringify(t.toolInfo)!==JSON.stringify(r.toolInfo))return;t=r}return t}function Ra(e,t,n){let r="",i=0;for(let o of I(e,t.valueStart,t.valueEnd))o.fieldNumber===ga&&o.wireType===2?r=n.decode(e.subarray(o.valueStart,o.valueEnd)):o.fieldNumber===ma&&o.wireType===0&&(i=o.varint);return{symbol:r,symbolRoles:i}}import{writeSync as xa,closeSync as me,openSync as Lt,readSync as wa,renameSync as Ea,rmSync as Tr,statSync as Pa,writeFileSync as Lr}from"fs";import{create as ye,fromBinary as Aa,toBinary as Ta}from"@bufbuild/protobuf";import{deserializeSCIP as Dr,serializeSCIP as kr,DocumentSchema as La,IndexSchema as Er,MetadataSchema as Dt,SymbolInformationSchema as Da,SymbolRole as ka}from"@c4312/scip";function Cr(e){if(e.length===0)throw new Error("Cannot merge zero SCIP indexes");if(e.length===1){let i=e[0];return ye(Er,{...i,documents:i.documents.map(o=>Tt(o,i.metadata))})}let t=Ca(e),n=Ga(e.flatMap(i=>i.documents.map(o=>Tt(o,i.metadata)))),r=Or(e.flatMap(i=>i.externalSymbols??[]));return ye(Er,{metadata:t,documents:n,externalSymbols:r})}function Ll(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let n=e.map(i=>Dr(b(i,{inputKind:"SCIP merge input",maxBytes:v}))),r=Cr(n);return Lr(t,kr(r)),{documentCount:r.documents.length,externalSymbolCount:r.externalSymbols.length,inputCount:e.length}}function Dl(e,t){if(e.length===0)throw new Error("Cannot concatenate zero SCIP files");let n=0;for(let o of e)if(n+=Pa(o).size,n>v)throw new Error(`Concatenated SCIP output exceeds the ${v}-byte artifact limit. Reduce the indexed project scope or use compatible cached generations.`);let r=Buffer.allocUnsafe(1024*1024),i=Lt(t,"w",384);try{for(let o of e){let a=Lt(o,"r");try{let s=0;for(;(s=wa(a,r,0,r.byteLength,null))>0;){let c=0;for(;c<s;)c+=xa(i,r,c,s-c)}}finally{me(a)}}}catch(o){throw me(i),Tr(t,{force:!0}),o}me(i)}function kl(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let n=se("reindex.publish.scip-output.deserialize",()=>e.map(o=>Dr(b(o,{inputKind:"SCIP merge input",maxBytes:v})))),r=se("reindex.publish.scip-output.merge",()=>Cr(n)),i=se("reindex.publish.scip-output.sanitize",()=>xr(r));return se("reindex.publish.scip-output.serialize",()=>Lr(t,kr(i.index))),{documentCount:i.index.documents.length,externalSymbolCount:i.index.externalSymbols.length,inputCount:e.length,removedDefinitionOccurrences:i.removedDefinitionOccurrences,...i.recoveredDefinitionSymbols?{recoveredDefinitionSymbols:i.recoveredDefinitionSymbols}:{},touchedDocuments:i.touchedDocuments}}var Pr=1;function Gr(e,t,n){let r=b(e,{inputKind:"SCIP normalization input",maxBytes:v}),i=le(r),o=[];for(let c of I(r))c.fieldNumber===Pr&&c.wireType===2&&o.push(c);if(o.length===0)throw new Error("Cannot rebase a SCIP index without metadata");if((i??"")!==t)throw new Error(`Cannot rebase SCIP project root: expected ${t}, got ${i??""}`);let a=`${e}.rebase-tmp`,s=Lt(a,"w",384);try{let c=0;for(let d of o){T(s,r.subarray(c,d.fieldStart));let l=Aa(Dt,r.subarray(d.valueStart,d.valueEnd));l.projectRoot=n;let f=Ta(Dt,l);T(s,Ge(Pr)),T(s,de(f.byteLength)),T(s,f),c=d.fieldEnd}T(s,r.subarray(c))}catch(c){throw me(s),Tr(a,{force:!0}),c}me(s),Ea(a,e)}function Ca(e){let t=e[0]?.metadata;if(!t)return;let n=t.projectRoot;for(let i of e.slice(1)){let o=i.metadata?.projectRoot;if(n&&o&&o!==n)throw new Error(`Cannot merge SCIP indexes with different project roots: ${n} vs ${o}`)}return e.every(i=>JSON.stringify(i.metadata?.toolInfo)===JSON.stringify(t.toolInfo))?t:ye(Dt,{...t,toolInfo:void 0})}function Ga(e){let t=new Map;for(let n of e){let r=t.get(n.relativePath);if(!r){t.set(n.relativePath,n);continue}Oa(r,n),t.set(n.relativePath,ye(La,{language:r.language||n.language,relativePath:r.relativePath||n.relativePath,occurrences:Ba([...r.occurrences,...n.occurrences]),symbols:Or([...r.symbols,...n.symbols]),text:r.text||n.text,positionEncoding:r.occurrences.length?r.positionEncoding:n.positionEncoding}))}return[...t.values()]}function Oa(e,t){for(let i of["language","text"])if(e[i]&&t[i]&&e[i]!==t[i])throw new Error(`Cannot merge ${e.relativePath}: conflicting ${i}. Reindex one consistent source snapshot.`);if(e.occurrences.length&&t.occurrences.length&&e.positionEncoding!==t.positionEncoding)throw new Error(`Cannot merge ${e.relativePath}: incompatible column encodings.`);let n=Ar(e),r=Ar(t);for(let[i,o]of r){let a=n.get(i);if(a!==void 0&&(o.length===0||JSON.stringify(a)!==JSON.stringify(o)))throw new Error(`Cannot merge ${e.relativePath}: conflicting document-local identity ${i}.`)}}function Ar(e){let t=new Map;for(let n of e.occurrences){if(!n.symbol.startsWith("local "))continue;let r=t.get(n.symbol)??new Set;(n.symbolRoles&ka.Definition)!==0&&r.add(JSON.stringify(kt(n.range))),t.set(n.symbol,r)}return new Map([...t].map(([n,r])=>[n,[...r].sort()]))}function kt(e){return e.length===3?[e[0],e[1],e[0],e[2]]:e}function Ba(e){let t=new Set,n=[];for(let r of e){let i=JSON.stringify({...r,range:kt(r.range),enclosingRange:kt(r.enclosingRange)});t.has(i)||(t.add(i),n.push(r))}return n}function Or(e){let t=new Map;for(let n of e){let r=t.get(n.symbol);if(!r){t.set(n.symbol,n);continue}t.set(n.symbol,ye(Da,{symbol:r.symbol,documentation:_a([...r.documentation,...n.documentation]),relationships:Ma([...r.relationships,...n.relationships]),kind:r.kind||n.kind,displayName:r.displayName||n.displayName,enclosingSymbol:r.enclosingSymbol||n.enclosingSymbol,signatureDocumentation:r.signatureDocumentation??n.signatureDocumentation}))}return[...t.values()]}function Ma(e){let t=new Set,n=[];for(let r of e){let i=[r.symbol,r.isReference?"1":"0",r.isImplementation?"1":"0",r.isTypeDefinition?"1":"0",r.isDefinition?"1":"0"].join("|");t.has(i)||(t.add(i),n.push(r))}return n}function _a(e){return[...new Set(e)]}import{existsSync as jr,statSync as Qa}from"fs";import{dirname as Wr,join as qr}from"path";import{appendFileSync as Fa,existsSync as Na,mkdirSync as ja,renameSync as $a,rmSync as Wa,statSync as qa,truncateSync as za}from"fs";import{basename as Ua,dirname as Va}from"path";var ze=".previous",Ja=".rotation.lock",Ha=2e3,Ct=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"},Gt=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"},Br=Object.freeze({monotonicNow:we,wait(e){Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,e)},tryAcquireLock(e,t){let n=Ee(e,{kind:"rotating-jsonl",detail:{target:Ua(t)}});return n.kind==="acquired"?{kind:"acquired",lock:n.lock}:{kind:"contended"}},makeDirectory(e){ja(e,{recursive:!0})},exists:Na,readBytes(e){return b(e,{maxBytes:Re,inputKind:"rotating JSONL segment"})},size(e){return qa(e).size},truncate:za,remove(e){Wa(e,{force:!0})},rename:$a,append:Fa});function Mr(e,t,n){let r=n.runtime??Br,i=JSON.stringify(t);if(i===void 0)throw new TypeError("Rotating JSONL records must be JSON-serializable values.");let o=Buffer.from(`${i}
|
|
7
|
+
`),a=Math.max(1,Math.floor(n.maxSegmentBytes),o.length);return Fr(e,n.lockTimeoutMs,r,()=>{r.makeDirectory(Va(e));let s=Ya(e,Re,r);n.onPhase?.("tail-repaired");let c=`${e}${n.previousSuffix??ze}`,d=!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),d=!0,n.onPhase?.("current-rotated")),r.append(e,o),n.onPhase?.("record-appended"),{lineBytes:o.length,segmentLimitBytes:a,repairedTailBytes:s,rotated:d,prunedPrevious:l}})}function _r(e,t={}){let n=t.runtime??Br,r=Ka(t.maxSegmentBytes);return Fr(e,t.lockTimeoutMs,n,()=>{let i=[],o=0,a=`${e}${t.previousSuffix??ze}`;for(let s of[a,e]){if(!n.exists(s))continue;let c=Xa(Nr(s,r,n));i.push(...c.lines),o+=c.partialTailBytes}return{lines:i,ignoredPartialTailBytes:o}})}function Fr(e,t,n,r){let i=`${e}${Ja}`,o=Math.max(0,t??Ha),a=n.monotonicNow()+o,s;for(;;){let g=n.tryAcquireLock(i,e);if(g.kind==="acquired"){s=g.lock;break}let x=a-n.monotonicNow();if(x<=0)throw new Ct(i,o);n.wait(Math.min(5,x))}let c=!1,d,l;try{l=r()}catch(g){c=!0,d=g}let f=!1;try{f=s.release()}catch(g){if(!c)throw g}if(c)throw d;if(!f)throw new Gt(i);return l}function Ya(e,t,n){if(!n.exists(e))return 0;let r=Nr(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 Ka(e){let t=e??Re;if(!Number.isSafeInteger(t)||t<=0)throw new RangeError(`maxSegmentBytes must be a positive safe integer; received ${t}`);return t}function Nr(e,t,n){let r=n.size(e);if(r>t)throw new st("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 st("rotating JSONL segment",e,"changed-during-read",o,t);return i}function Xa(e){let t=e.lastIndexOf(10),n=t<0?0:t+1;return{lines:e.subarray(0,n).toString("utf8").split(`
|
|
8
|
+
`).filter(i=>i.length>0),partialTailBytes:e.length-n}}var Za="reindex-activity.jsonl",Ue=ze,es=1024*1024,ts=1440*60*1e3,zr=e=>B(e,"reindex activity segment");function Bt(e){return qr(Wr(e),Za)}function Ur(e){if(e.reused)return 0;let n=(e.shards?.some(r=>!r.reused&&r.strategy==="incremental")??!1?0:Ot(e.indexPath))+Ot(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 ns(e){let t=Ur(e),n=e.writeTelemetry;return n?Math.max(0,t-n.reflinkedBytes)+n.fallbackCopiedBytes+(n.incrementalWrittenBytes??0):t}function Vl(e,t){let n=t.lastRefresh;if(!n)return{state:"failed",reason:"reindex result has no refresh metadata"};let r=Ur(t);return Vr(Bt(e),{version:1,event:"run",recordedAt:n.completedAt,trigger:n.trigger,result:n.result,durationMs:n.durationMs,estimatedLogicalOutputBytes:r,estimatedWriteBytes:ns(t),reflinkedBytes:t.writeTelemetry?.reflinkedBytes??0,fallbackCopiedBytes:t.writeTelemetry?.fallbackCopiedBytes??0,incrementalWrittenBytes:t.writeTelemetry?.incrementalWrittenBytes??0,byLanguage:Ss(t)})}function Jl(e,t){return Vr(Bt(e),{version:1,event:"run",recordedAt:t.completedAt,trigger:t.trigger,result:"failed",durationMs:t.durationMs,estimatedLogicalOutputBytes:0})}function rs(e,t,n=es,r){Mr(e,t,{maxSegmentBytes:n,previousSuffix:Ue,...r?{runtime:r}:{}})}function is(e,t=new Date,n=ts,r=zr){let i=t.getTime(),o=i-n,a=os(o,t),s=as(Bt(e),r,a);if(s===null)return a;for(let c of s){let d=ss(c,o,i,a);if(!d)continue;let{record:l}=d;if(a.invalidLanguageDetails+=d.invalidLanguageDetails,a.byTrigger[l.trigger.kind]=(a.byTrigger[l.trigger.kind]??0)+1,l.event==="suppressed"){a.suppressed+=1;continue}cs(a,d,l)}return a.ignoredPartialTailBytes>0&&a.confidence!=="unavailable"&&(a.confidence="partial"),a.languageAttribution=Ls(a),a}function os(e,t){return{confidence:"complete",recordsRead:0,invalidRecords:0,skippedRecords:0,readErrors:0,ignoredPartialTailBytes:0,windowStartedAt:new Date(e).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}}}function as(e,t,n){let r=[];if(t===zr){if(!jr(e)&&!jr(`${e}${Ue}`))return null;try{let i=_r(e,{previousSuffix:Ue});r=i.lines,n.ignoredPartialTailBytes=i.ignoredPartialTailBytes}catch{n.readErrors+=1,n.confidence="unavailable"}}else{let i=0;for(let o of[`${e}${Ue}`,e])try{r.push(...Ds(t(o))),i+=1}catch{n.readErrors+=1}i===0?n.confidence="unavailable":n.readErrors>0&&(n.confidence="partial")}return r}function ss(e,t,n,r){r.recordsRead+=1;let i=us(e);if(!i)return r.invalidRecords+=1,r.confidence!=="unavailable"&&(r.confidence="partial"),null;let{record:o}=i,a=Date.parse(o.recordedAt);return a<t||a>n?(r.skippedRecords+=1,null):i}function cs(e,t,n){e.runs+=1,e[n.result]+=1,e.estimatedLogicalOutputBytes+=n.estimatedLogicalOutputBytes;let r=gs(n);e.estimatedWriteBytes+=r,e.reflinkedBytes+=n.reflinkedBytes??0,e.fallbackCopiedBytes+=n.fallbackCopiedBytes??0,ds(e,t,n);let i=hs(n);i&&e.oldestRebuildAt===void 0&&(e.oldestRebuildAt=n.recordedAt),i&&(e.fullRebuilds+=1),r>0&&e.oldestWriteAt===void 0&&(e.oldestWriteAt=n.recordedAt),ls(e.automatic,n,i,r)}function ds(e,t,n){n.result!=="failed"&&(t.hasLanguageDetails?e.attributedRuns+=1:e.unattributedRuns+=1);for(let[r,i]of Jr(n.byLanguage)){let o=e.byLanguage[r]??=Ts();o.runs+=1,o[i.result]+=1,o.producedOutputBytes+=i.producedOutputBytes,o.durationMs+=i.durationMs}}function ls(e,t,n,r){ms(t.trigger)&&(e.runs+=1,t.result==="rebuilt"&&(e.rebuilt+=1),n&&(e.fullRebuilds+=1,e.oldestRebuildAt??=t.recordedAt),e.estimatedWriteBytes+=r,r>0&&(e.oldestWriteAt??=t.recordedAt))}function Vr(e,t){try{return rs(e,t),{state:"recorded"}}catch(n){return{state:"failed",reason:n instanceof Error?n.message:String(n)}}}function us(e){try{let t=JSON.parse(e);if(!t||typeof t!="object")return null;let n=t;if(!fs(n))return null;if(n.event==="suppressed")return n.reason==="completed-index-is-fresh"?{record:n,hasLanguageDetails:!1,invalidLanguageDetails:0}:null;if(!ps(n))return null;let r=n,{byLanguage:i,...o}=r,a=xs(i);return{record:{...o,...a.byLanguage?{byLanguage:a.byLanguage}:{}},hasLanguageDetails:a.hasLanguageDetails,invalidLanguageDetails:a.invalidLanguageDetails}}catch{return null}}function fs(e){return e.version===1&&on(e.recordedAt)&&!!e.trigger&&Tn(e.trigger.kind)}function ps(e){return e.event!=="run"||e.result!=="rebuilt"&&e.result!=="reused"&&e.result!=="failed"||!ee(e.durationMs)||!ee(e.estimatedLogicalOutputBytes)?!1:[e.estimatedWriteBytes,e.reflinkedBytes,e.fallbackCopiedBytes,e.incrementalWrittenBytes].every(t=>t===void 0||ee(t))}function gs(e){return e.reflinkedBytes===void 0?e.estimatedWriteBytes??e.estimatedLogicalOutputBytes:Math.max(0,e.estimatedLogicalOutputBytes-e.reflinkedBytes)+(e.fallbackCopiedBytes??0)+(e.incrementalWrittenBytes??0)}function Hl(e,t,n=new Date){return t.enabled?ys(is(e,n,t.windowMs),t,n.getTime()):{state:"allowed",rebuilt:0,estimatedWriteBytes:0}}function ms(e){return e.kind.startsWith("watch-")}function ys(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:$r(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:$r(r.oldestWriteAt,t.windowMs,n),...a,detail:`${i}/${t.maxEstimatedWriteBytes} estimated write bytes consumed by automatic refreshes`}:{state:"allowed",...a}:{state:"allowed",...a}}function hs(e){if(e.result!=="rebuilt")return!1;let t=Jr(e.byLanguage);return t.length===0?!0:t.some(([,n])=>n.result==="rebuilt"&&n.strategy!=="incremental"&&n.strategy!=="reused")}function $r(e,t,n){let r=e?Date.parse(e):Number.NaN;return Number.isFinite(r)&&r+t>n?r+t:n+t}function Ot(e){try{return Qa(e).size}catch{return 0}}function Ss(e){let t={};for(let n of e.languages)t[n]=bs(e,n);return t}function bs(e,t){let n=(e.shards??[]).filter(c=>c.language===t),r=n.find(c=>c.id===t),i=Is(e.reused,n,r),o=Ot(qr(Wr(e.dbPath),"language-indexes",`${t}.scip`)),a=o>0?o:r?.outputBytes??o,s=Rs(i,n,r);return{result:i?"reused":"rebuilt",strategy:i?"reused":r?.strategy??"full",...vs(r),outputBytes:a,producedOutputBytes:i?0:r?.producedOutputBytes??a,durationMs:s}}function vs(e){return e?.strategy==="full"&&(e.fallbackReason??e.missReason)?{fallbackReason:e.fallbackReason??e.missReason}:{}}function Is(e,t,n){return e||(n?n.reused:t.length>0&&t.every(r=>r.reused))}function Rs(e,t,n){return e?0:n?.durationMs??t.filter(r=>!r.reused).reduce((r,i)=>r+i.durationMs,0)}function xs(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(!As(i)||!ws(o)){n+=1;continue}t[i]=o}let r=Object.keys(t).length>0;return{...r?{byLanguage:t}:{},hasLanguageDetails:r,invalidLanguageDetails:n}}function ws(e){if(!e||typeof e!="object")return!1;let t=e;return Es(t)&&Ps(t)}function Es(e){return(e.result==="rebuilt"||e.result==="reused")&&(e.strategy===void 0||e.strategy==="reused"||e.strategy==="incremental"||e.strategy==="full")&&(e.fallbackReason===void 0||typeof e.fallbackReason=="string")}function Ps(e){return ot(e.outputBytes)&&ot(e.producedOutputBytes)&&ee(e.durationMs)&&(e.result!=="reused"||e.producedOutputBytes===0&&e.durationMs===0)&&e.producedOutputBytes<=e.outputBytes}function As(e){return at.includes(e)}function Jr(e){return e?at.flatMap(t=>{let n=e[t];return n?[[t,n]]:[]}):[]}function Ts(){return{runs:0,rebuilt:0,reused:0,producedOutputBytes:0,durationMs:0}}function Ls(e){let t=e.invalidLanguageDetails??0,n=e.attributedRuns??0;return(e.unattributedRuns??0)===0&&t===0?"complete":n===0?"unavailable":"partial"}function Ds(e){return e.endsWith(`
|
|
9
|
+
`)||(e=e.slice(0,Math.max(0,e.lastIndexOf(`
|
|
10
|
+
`)+1))),e.split(`
|
|
11
|
+
`).filter(t=>t.length>0)}import ks from"better-sqlite3";var Cs=25,Gs=new Set(["typescript","javascript"]);function Zl(e,t,n){let r=null;try{r=new ks(e,{readonly:!0,fileMustExist:!0});let i=new Set(r.prepare("SELECT relative_path FROM documents").pluck().all().map(rt)),o=Os(t,n),a=new Set([...o.values()].flatMap(l=>[...l])),s=[...a].filter(l=>!i.has(l)).sort();if(s.length===0)return{state:"complete",expectedDocumentCount:a.size,actualDocumentCount:i.size};let c=new Set(s),d=n.filter(l=>[...o.get(l)??[]].some(f=>c.has(f)));return{state:"incomplete",expectedDocumentCount:a.size,actualDocumentCount:i.size,missingDocumentCount:s.length,missingPaths:s.slice(0,Cs),affectedLanguages:d}}catch(i){return{state:"unavailable",reason:i instanceof Error?i.message:String(i)}}finally{r?.close()}}function Os(e,t){let n=new Map,r=t.filter(i=>Gs.has(i));for(let i of r)n.set(i,new Set);for(let i of e.files){let o=rt(i.path);for(let a of r)Z(o,[a])==="source"&&n.get(a).add(o)}return n}import{createHash as $t,randomUUID as nu}from"crypto";import{closeSync as Bs,copyFileSync as iu,existsSync as y,mkdirSync as Ms,openSync as _s,readSync as Fs,readdirSync as Wt,renameSync as Ft,rmSync as K,statSync as q}from"fs";import{basename as Yr,dirname as G,join as p,relative as Hr}from"path";import Ns from"better-sqlite3";var js=Object.freeze({maxGenerations:2,maxLogicalBytes:2*1024*1024*1024});function Kr(e){let t=L(e.outputDb),n=Hs(e);e.onStage?.("after-recovery-retained");let r=e.preserveOutputScip?e.outputScip:e.tempOutputScip,i=Ys(e,n),o=zt({generationRoot:t,databasePath:e.tempOutputDb,indexPath:y(r)?r:void 0,verifiedIndexArtifact:i,metadataPath:y(e.tempMetaPath)?e.tempMetaPath:void 0}),a=(e.now??(()=>new Date))().toISOString(),s={version:J,currentGeneration:o.identity,artifactSet:"immutable-v1",...n?{previousGeneration:n}:{},...e.publication?{publication:e.publication}:{},publishedAt:a},c=k(p(t,"state.json"),s,{spacing:2,trailingNewline:!0});e.onStage?.("after-pointer-handoff"),e.preserveOutputScip||jt(e.tempOutputScip,e.outputScip),e.onStage?.("after-scip-handoff"),oc(e.tempOutputDb,e.outputDb),e.onStage?.("after-database-handoff"),jt(e.tempMetaPath,e.metaPath),e.onStage?.("after-metadata-handoff");let d=o.identity,l={...s,stableMirrors:qt(e.outputDb,e.outputScip)};k(p(t,"state.json"),l,{spacing:2,trailingNewline:!0});let f=Xr(e.outputDb,{now:e.now}),g=re(o.directorySync,c.directorySync);return{currentGeneration:d,...n?{previousGeneration:n}:{},retention:f,achievedDurability:g==="synced"?"directory-durable":"file-flushed",directorySync:g}}function $s(e,t,n,r=()=>new Date){if(!y(e))return null;let i=ie(e),o=p(L(e),"state.json");if(cc(e,i))return i;let a=L(e),s=!i&&y(o)?Xs(n,e,t):void 0;if(s&&!De(a,s))return null;let c=zt({generationRoot:a,databasePath:e,indexPath:y(t)?t:void 0,metadataPath:y(n)?n:void 0,forcedIdentity:i?.currentGeneration??s}),d=sc(c.identity,e,t,i,r);return k(p(a,"state.json"),d,{spacing:2,trailingNewline:!0}),d}function gu(e,t,n=()=>new Date){if(!y(e)||!y(t))throw new Error("metadata-only generation refresh requires stable database and metadata files");let r=ie(e),i=L(e),o=zt({generationRoot:i,databasePath:e,indexPath:y(p(G(e),"index.scip"))?p(G(e),"index.scip"):void 0,metadataPath:t}),a=r&&r.currentGeneration!==o.identity?ei(e,r.currentGeneration):void 0,s={version:J,currentGeneration:o.identity,artifactSet:"immutable-v1",stableMirrors:qt(e,p(G(e),"index.scip")),...a?{previousGeneration:a}:{},...r?.publication?{publication:r.publication}:{},publishedAt:n().toISOString()};return k(p(L(e),"state.json"),s,{spacing:2,trailingNewline:!0}),Xr(e,{now:n}),s}function Xr(e,t={}){let n=Us(t.limits),i=(t.now??(()=>new Date))().toISOString(),o=ne(gn(e),{waitMs:0});if(!o)return{state:"deferred",generationCount:0,logicalBytes:0,protectedGenerations:0,activeReaderLeases:0,staleReaderLeasesRemoved:0,malformedReaderLeases:0,removedGenerations:0,removedLogicalBytes:0,limits:n,at:i,reason:"another process owns local generation retention"};try{return Ws(e,t,n,i)}catch(a){let s={state:"error",generationCount:0,logicalBytes:0,protectedGenerations:0,activeReaderLeases:0,staleReaderLeasesRemoved:0,malformedReaderLeases:0,removedGenerations:0,removedLogicalBytes:0,limits:n,at:i,reason:a instanceof Error?a.message:String(a)};try{Zr(e,s)}catch{}return s}finally{o.release()}}function Ws(e,t,n,r){let i=ie(e),o=Vs(e),a=mn(e,o.map(D=>D.identity),{isProcessAlive:t.isProcessAlive??dn,readProcessIdentity:t.readProcessIdentity??cn}),s=new Set(a.protectedGenerations);i?.currentGeneration&&s.add(i.currentGeneration),i?.previousGeneration?.generationIdentity&&s.add(i.previousGeneration.generationIdentity);let{generationCount:c,logicalBytes:d,removedGenerations:l,removedLogicalBytes:f}=zs(o,s,n,t),g=c>n.maxGenerations||d>n.maxLogicalBytes,x={state:g?"protected":l>0?"collected":"within-bounds",generationCount:c,logicalBytes:d,protectedGenerations:s.size,activeReaderLeases:a.activeLeases,staleReaderLeasesRemoved:a.staleLeasesRemoved,malformedReaderLeases:a.malformedLeases,removedGenerations:l,removedLogicalBytes:f,limits:n,at:r,...g?{reason:qs(a.malformedLeases)}:{}};return Zr(e,x),x}function qs(e){return e>0?"malformed reader ownership evidence fails closed":"retention bounds cannot be met without deleting a protected generation"}function zs(e,t,n,r){let i=e.length,o=e.reduce((c,d)=>c+d.logicalBytes,0),a=0,s=0;for(let c of e){if(i<=n.maxGenerations&&o<=n.maxLogicalBytes)break;t.has(c.identity)||(r.onBeforeRemove?.(c.identity),K(c.path,{recursive:!0,force:!0}),i-=1,o-=c.logicalBytes,a+=1,s+=c.logicalBytes)}return{generationCount:i,logicalBytes:o,removedGenerations:a,removedLogicalBytes:s}}function Us(e={}){let t={...js,...e};if(!Number.isSafeInteger(t.maxGenerations)||t.maxGenerations<2)throw new Error("Local SQLite generation retention must keep at least current and previous generations.");if(!Number.isSafeInteger(t.maxLogicalBytes)||t.maxLogicalBytes<=0)throw new Error("Local SQLite generation byte retention must be a positive safe integer.");return t}function Vs(e){let t=L(e);return y(t)?Wt(t,{withFileTypes:!0}).filter(n=>n.isDirectory()&&/^[a-f0-9]{64}$/.test(n.name)).map(n=>{let r=p(t,n.name),i=De(t,n.name),o=i?i.database.size+(i.index?.size??0)+(i.metadata?.size??0):Qr(r);return{identity:n.name,path:r,logicalBytes:o,modifiedAtMs:q(r).mtimeMs}}).sort((n,r)=>n.modifiedAtMs-r.modifiedAtMs||n.identity.localeCompare(r.identity)):[]}function Qr(e){let t=0;for(let n of Wt(e,{withFileTypes:!0})){let r=p(e,n.name);n.isDirectory()?t+=Qr(r):n.isFile()&&(t+=q(r).size)}return t}function Zr(e,t){Te(p(L(e),"gc.json"),t,{spacing:2,trailingNewline:!0})}function Je(e,t=p(G(e),"meta.json")){let n=p(L(e),"state.json");if(!y(n))return{state:"legacy",statePath:n};let r=ie(e);if(!r)return{state:"invalid",statePath:n,reason:"generation state is malformed"};try{let i=oe(e,r.currentGeneration),o=i!==null,a=i?Js(e,t,i,r):!1,s=r.previousGeneration?y(p(G(e),r.previousGeneration.databasePath)):!0;return!a||!o||!s?{state:"drifted",statePath:n,currentMatches:a,recoveryExists:s,generation:r,reason:dc(o,a)}:{state:"current",statePath:n,currentMatches:a,recoveryExists:s,generation:r}}catch(i){return{state:"drifted",statePath:n,currentMatches:!1,recoveryExists:!1,generation:r,reason:i instanceof Error?i.message:String(i)}}}function Js(e,t,n,r){if(!lc(e,r)||!Nt(e,n.database))return!1;let i=p(G(e),"index.scip");if(n.index&&!Nt(i,n.index))return!1;if(!n.metadata)return!y(t);if(!y(t))return!1;let o=p(L(e),n.identity,n.metadata.file);return y(o)&&W(B(t,"reindex metadata"))===W(B(o,"immutable reindex metadata"))}function Nt(e,t){return y(e)&&q(e).isFile()&&q(e).size===t.size}function Hs(e){let t=$s(e.outputDb,e.outputScip,e.metaPath);return t?ei(e.outputDb,t.currentGeneration):void 0}function Ys(e,t){if(!e.preserveOutputScip)return;if(!t)throw new Error("deferred SCIP publication requires an accepted immutable generation");let n=Je(e.outputDb,e.metaPath);if(n.state!=="current"||n.generation.currentGeneration!==t.generationIdentity){let i=n.state==="current"?"generation identity changed":"reason"in n?n.reason:`generation state is ${n.state}`;throw new Error(`deferred SCIP publication requires a verified accepted companion: ${i}`)}let r=oe(e.outputDb,t.generationIdentity);if(!r?.index||!Nt(e.outputScip,r.index))throw new Error("deferred SCIP publication requires the verified accepted index artifact");return r.index}function qt(e,t){return{databaseFileIdentity:ae(e),...y(t)?{indexFileIdentity:ae(t)}:{}}}function ei(e,t){let n=p(L(e),t),r=oe(e,t);if(!r)throw new Error("Cannot retain recovery artifacts without a valid generation manifest.");let i=p(n,r.database.file),o=r.metadata?p(n,r.metadata.file):void 0;return{generationIdentity:t,databasePath:Hr(G(e),i),...o?{metadataPath:Hr(G(e),o)}:{}}}function Ks(e){if(y(e))for(let t of Wt(e,{withFileTypes:!0}))t.isDirectory()&&t.name.endsWith(".tmp")&&K(p(e,t.name),{recursive:!0,force:!0})}function Xs(e,t,n=p(G(t),"index.scip")){let r=$t("sha256").update("sqlite-generation-artifacts-v1\0");return r.update(Ve(t)),y(n)&&r.update(`\0${Ve(n)}`),y(e)&&r.update(`\0${W(B(e,"reindex metadata"))}`),r.digest("hex")}function zt(e){ac(e.databasePath);let t=Mt(e.databasePath),n=e.indexPath?e.verifiedIndexArtifact?tc(e.indexPath,e.verifiedIndexArtifact):Mt(e.indexPath):void 0,r=e.metadataPath?Mt(e.metadataPath):void 0,i=e.forcedIdentity??ec(t,n,e.metadataPath),o=p(e.generationRoot,i),a=p(o,lt);if(y(a))return Zs(e,i,o,t,n);let s=[Pe(e.generationRoot)];Ks(e.generationRoot);let c=`${o}.${process.pid}.${Date.now()}.tmp`;K(c,{recursive:!0,force:!0}),Ms(c,{recursive:!0});try{Qs(e,c,t,n,r,s);let d=k(p(c,lt),{version:pn,identity:i,database:t,...n?{index:n}:{},...r?{metadata:r}:{}},{spacing:2,trailingNewline:!0});d.directorySync!=="not-requested"&&s.push(d.directorySync),s.push(_(c)),Ft(c,o),s.push(_(e.generationRoot))}finally{K(c,{recursive:!0,force:!0})}return{identity:i,directorySync:re(...s)}}function Qs(e,t,n,r,i,o){o.push(_t(e.databasePath,p(t,n.file))),r&&e.indexPath&&o.push(_t(e.indexPath,p(t,r.file))),i&&e.metadataPath&&o.push(_t(e.metadataPath,p(t,i.file)))}function Zs(e,t,n,r,i){let o=De(e.generationRoot,t);if(o&&ti(n,o.database,r)&&rc(n,o.index,i)&&ic(n,o.metadata,e.metadataPath))return{identity:t,directorySync:_(e.generationRoot)};throw new Error(`SQLite generation ${t} already exists with different or corrupt artifacts.`)}function ec(e,t,n){let r=$t("sha256").update("sqlite-generation-artifacts-v1\0");return r.update(e.sha256),t&&r.update(`\0${t.sha256}`),n&&r.update(`\0${W(B(n,"reindex metadata"))}`),r.digest("hex")}function Mt(e){return{file:Yr(e),size:q(e).size,sha256:Ve(e)}}function tc(e,t){if(t.file!==Yr(e)||q(e).size!==t.size)throw new Error(`verified SQLite generation artifact changed before publication: ${e}`);return t}function Ve(e){let t=$t("sha256"),n=_s(e,"r"),r=Buffer.allocUnsafe(1024*1024);try{for(;;){let i=nc(n,r);if(i===0)break;t.update(r.subarray(0,i))}}finally{Bs(n)}return t.digest("hex")}function nc(e,t){let n=0;for(;n<t.length;){let r=Fs(e,t,n,t.length-n,null);if(n+=r,r===0)break}return n}function _t(e,t){return Ae(e,t,{mode:292})}function ti(e,t,n){let r=p(e,t.file);return t.file===n.file&&t.size===n.size&&t.sha256===n.sha256&&y(r)&&q(r).size===t.size&&Ve(r)===t.sha256}function rc(e,t,n){return!t||!n?t===n:ti(e,t,n)}function ic(e,t,n){if(!t||!n)return t===void 0&&n===void 0;let r=p(e,t.file);return y(r)&&W(B(r,"stored reindex metadata"))===W(B(n,"candidate reindex metadata"))}function oc(e,t){for(let n of["-wal","-shm","-journal"])K(`${t}${n}`,{force:!0});jt(e,t)}function ac(e){let t=new Ns(e,{fileMustExist:!0});try{if(t.pragma("wal_checkpoint(TRUNCATE)").some(i=>i.busy!==0))throw new Error(`SQLite publication has an active writer or reader: ${e}`);let r=t.pragma("quick_check");if(r.length!==1||r[0]?.quick_check!=="ok")throw new Error(`SQLite publication rejected an invalid database: ${e}`)}finally{t.close()}}function jt(e,t){K(`${t}.tmp-replace`,{force:!0}),Ft(e,`${t}.tmp-replace`),Ft(`${t}.tmp-replace`,t)}function sc(e,t,n,r,i){return{version:J,currentGeneration:e,artifactSet:"immutable-v1",stableMirrors:qt(t,n),...r?.previousGeneration?{previousGeneration:r.previousGeneration}:{},...r?.publication?{publication:r.publication}:{},publishedAt:r?.publishedAt??i().toISOString()}}function cc(e,t){return t?.artifactSet==="immutable-v1"&&!!oe(e,t.currentGeneration)}function dc(e,t){return e?t?"retained recovery database is missing":"stable database or metadata no longer matches the published generation":"published immutable generation is missing"}function lc(e,t){return!(t.stableMirrors&&(t.stableMirrors.databaseFileIdentity!==ae(e)||t.stableMirrors.indexFileIdentity!==void 0&&t.stableMirrors.indexFileIdentity!==ae(p(G(e),"index.scip"))))}import{createHash as ci,randomUUID as hc}from"crypto";import{existsSync as j,lstatSync as Ht,mkdirSync as X,mkdtempSync as di,readdirSync as li,realpathSync as ui,renameSync as U,rmSync as N,statSync as Xe}from"fs";import{dirname as Jt,join as u,resolve as z}from"path";import{setTimeout as Sc}from"timers/promises";import{pathToFileURL as oi}from"url";import bc from"better-sqlite3";import{lstatSync as uc,readdirSync as fc}from"fs";import{join as pc,relative as gc,resolve as Ut,sep as mc}from"path";var he=1,Vt="language-indexes",ni=["index.db","index.scip","meta.json"],ri=[Vt,ce,ue];function He(e){let t=[];for(let n of ni)yc(e,n),t.push(n);for(let n of ri)ii(e,n,t);return{version:he,files:t.sort()}}function Ye(e){if(!e||e.includes("\0")||e.startsWith("/")||e.includes("\\"))throw new Error(`invalid index artifact path: ${e||"<empty>"}`);let t=e.split("/");if(t.some(r=>!r||r==="."||r===".."))throw new Error(`invalid index artifact path: ${e}`);let n=t[0];if(!ni.includes(e)&&!ri.includes(n))throw new Error(`index artifact path is not shareable: ${e}`);return e}function O(e,t){let n=Ye(t),r=Ut(e),i=Ut(r,...n.split("/"));if(i!==r&&!i.startsWith(`${r}${mc}`))throw new Error(`index artifact escapes cache: ${t}`);return i}function ii(e,t,n){let r=pc(e,t),i;try{i=fc(r,{withFileTypes:!0,encoding:"utf8"})}catch{return}for(let o of i){let a=`${t}/${o.name}`;if(o.isSymbolicLink())throw new Error(`index artifact cannot be a symlink: ${a}`);o.isDirectory()?ii(e,a,n):o.isFile()&&n.push(Ye(a))}}function yc(e,t){let n=O(e,t),r;try{r=uc(n)}catch{throw new Error(`required index artifact is missing: ${t}`)}if(!r.isFile()||r.isSymbolicLink())throw new Error(`required index artifact is not a regular file: ${t}`);if(gc(Ut(e),n).startsWith(".."))throw new Error(`index artifact escapes cache: ${t}`)}var Yt=1,ai="SCIP_QUERY_SHARED_CACHE",vc=2,Ke=JSON.stringify({cliVersion:vn,typescriptSymbolIdentityVersion:6,artifactCatalogVersion:he,postIndexAugmentationSchemaVersion:vc,sqliteGenerationStoreVersion:J,typescriptFragmentStoreVersion:gt,typescriptOverlayStoreVersion:Me}),Kt="manifest.json",fi="shared-cache.json";var Xt=[Vt,ce,ue];function Ic(e,t){if(!e.clean||!e.treeOid)return;let n=vi(JSON.stringify({version:Yt,repositoryId:e.repositoryId,treeOid:e.treeOid,fingerprint:ve(t),producerIdentity:Ke}));return{repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,fingerprint:t,producerIdentity:Ke,generationId:n,repositoryCacheDir:xn(e.repositoryId)}}function Vu(e,t,n){if(!Uc(n))return!1;let r=Ic(e,n);if(!r)return!1;try{let i=jc(t);if(!i||i.repositoryId!==e.repositoryId||i.worktreeId!==e.worktreeId)return!1;let o=JSON.parse(E(u(r.repositoryCacheDir,"worktrees",`${i.worktreeId}.json`),{inputKind:"worktree cache lease",maxBytes:w}));return Rc(o,i,e,t,r)?V(r,!1)!==null:!1}catch{return!1}}function Rc(e,t,n,r,i){return!(e.version!==1||e.repositoryId!==t.repositoryId||e.worktreeId!==t.worktreeId||z(e.projectRoot)!==z(n.projectRoot)||e.treeOid!==n.treeOid||z(e.localCacheDir)!==z(r)||e.ownershipChecksum!==Qt(e)||e.baseGenerationId!==i.generationId||e.activeGenerationId!==i.generationId)}function Ju(e,t,n){if(process.env[ai]==="0")return`${ai}=0`;if(!wn(n))return"explicit cache or database override";if(ut(Jt(t))!==ut(Rn(e))||t!==u(Jt(t),"index.db"))return"index database is outside the managed worktree cache"}function V(e,t=!0){let n=Zt(e),r;try{r=gi(E(u(n,Kt),{inputKind:"shared-generation manifest",maxBytes:w}))}catch{return null}if(!Vc(r,e)||!Fc(n))return null;if(!t)return r;try{for(let i of r.artifacts){let o=O(n,i.path),a=Xe(o);if(!a.isFile()||a.size!==i.size||xe(o,{inputKind:"shared-generation artifact",maxBytes:v})!==i.sha256)return null}}catch{return null}return r}function Hu(e,t,n,r){if(!e.treeOid)return null;let i=ft(t,n),o=u(In(),"repositories",e.repositoryId),a;try{let d=Ht(o);if(!d.isDirectory()||d.isSymbolicLink())return null;a=ui(o)}catch{return null}let s=u(a,"generations"),c=[];try{xc(s,e,i,c)}catch{return null}c.sort((d,l)=>{let f=d.treeOid===e.treeOid?0:1,g=l.treeOid===e.treeOid?0:1;if(f!==g)return f-g;if(r){let D=si(d.fingerprint,r)-si(l.fingerprint,r);if(D!==0)return D}return Date.parse(l.createdAt)-Date.parse(d.createdAt)||d.generationId.localeCompare(l.generationId)});for(let d of c){let l={repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:d.treeOid,fingerprint:d.fingerprint,producerIdentity:d.producerIdentity,generationId:d.generationId,repositoryCacheDir:a},f=V(l);if(f)return{snapshot:l,manifest:f}}return null}function xc(e,t,n,r){for(let i of li(e)){if(!/^[a-f0-9]{64}$/.test(i))continue;let o=u(e,i),a;try{a=Ht(o)}catch{continue}if(!(!a.isDirectory()||a.isSymbolicLink()))try{let s=gi(E(u(o,Kt),{inputKind:"shared-generation baseline manifest",maxBytes:w}));wc(s,i,t,n)&&r.push(s)}catch{continue}}}function wc(e,t,n,r){return e.generationId===t&&e.repositoryId===n.repositoryId&&e.producerIdentity===Ke&&Nc(e.fingerprint,r)}function Yu(e){let t=ne(u(e.snapshot.repositoryCacheDir,"locks",`${e.snapshot.generationId}.publish.lock`));if(!t)throw new Error(`shared generation publication is already in progress for ${e.snapshot.generationId}`);try{return Ec(e)}finally{t.release()}}function Ec(e){let t=V(e.snapshot);if(t)return pi(e.snapshot,t);if(!bi(e.sourceCacheDir,e.sourceProjectRoot,e.snapshot.fingerprint))throw new Error("source index is incomplete, incompatible, or corrupt");let n=mi(e.sourceCacheDir);if(!n)throw new Error("source index artifacts are incomplete");let r=He(e.sourceCacheDir),i=u(e.snapshot.repositoryCacheDir,"generations"),o=[Pe(i)],a=di(u(i,`.tmp-${process.pid}-`));try{let s=Tc(e,r.files,a,o),c=Ac(e,a,n),d={version:Yt,artifactCatalogVersion:he,generationId:e.snapshot.generationId,repositoryId:e.snapshot.repositoryId,treeOid:e.snapshot.treeOid,fingerprint:e.snapshot.fingerprint,producerIdentity:e.snapshot.producerIdentity,sourceProjectRoot:e.sourceProjectRoot,scipProjectRoot:c,createdAt:(e.now??(()=>new Date))().toISOString(),artifacts:s.sort((x,D)=>x.path.localeCompare(D.path))},l=k(u(a,Kt),d,{spacing:2,trailingNewline:!0});l.directorySync!=="not-requested"&&o.push(l.directorySync),e.onPublicationStage?.("after-manifest-flushed"),o.push(_(a)),e.onPublicationStage?.("after-staging-directory-synced");let f=Pc(e.snapshot,a);if(f)return f;e.onPublicationStage?.("after-generation-renamed"),o.push(_(i)),e.onPublicationStage?.("after-generations-directory-synced");let g=re(...o);return{kind:"published",manifest:d,achievedDurability:g==="synced"?"directory-durable":"file-flushed",directorySync:g}}finally{N(a,{recursive:!0,force:!0})}}function Pc(e,t){let n=Zt(e);try{if(j(n)&&!V(e)){let r=`${n}.corrupt-${process.pid}-${Date.now()}`;U(n,r),N(r,{recursive:!0,force:!0})}U(t,n)}catch(r){let i=V(e);if(i)return pi(e,i);throw r}}function Ac(e,t,n){let r=le(b(u(t,"index.scip"),{inputKind:"staged shared SCIP index",maxBytes:v}));if(!r)throw new Error("shared SCIP generation has no project root metadata");let i=en(e.sourceProjectRoot);if(r!==i)throw new Error("shared SCIP generation root does not match its source worktree");if(mi(e.sourceCacheDir)!==n||e.sourceStillValid&&!e.sourceStillValid())throw new Error("source index changed while staging a shared generation");return r}function Tc(e,t,n,r){let i=[];for(let o of t){let a=O(e.sourceCacheDir,o),s=O(n,o);r.push(be(a,s,292)),e.onPublicationStage?.("after-artifact-flushed",o);let c=Xe(s).size;i.push({path:o,size:c,sha256:xe(s,{inputKind:"staged shared-generation artifact",maxBytes:v})})}return i}function pi(e,t){let n=_(u(e.repositoryCacheDir,"generations"));return{kind:"existing",manifest:t,achievedDurability:n==="synced"?"directory-durable":"file-flushed",directorySync:n}}function Ku(e){let t=Zt(e.snapshot);X(e.targetCacheDir,{recursive:!0});let n=ne(u(e.targetCacheDir,"cache-lifecycle.lock"),{waitMs:e.lockWaitMs??3e4});if(!n)throw new Error("timed out waiting for another cache hydration");let r,i,o=!1;try{if(r=di(u(e.targetCacheDir,".shared-hydrate-")),zc(e.manifest,e.snapshot),Dc(e.manifest,t,r),kc(e,r),!bi(r,e.targetProjectRoot,e.snapshot.fingerprint,!1))throw new Error("staged shared generation failed completeness or integrity validation");i=$c(e.targetCacheDir,r),o=!0,Wc(r,e.targetCacheDir,i),Kr({tempOutputScip:u(r,"index.scip"),tempOutputDb:u(r,"index.db"),tempMetaPath:u(r,"meta.json"),outputScip:u(e.targetCacheDir,"index.scip"),outputDb:u(e.targetCacheDir,"index.db"),metaPath:u(e.targetCacheDir,"meta.json"),now:e.now}),Lc(e.targetCacheDir),e.persistLease!==!1&&Cc(e.snapshot,e.targetCacheDir,e.action??"attached",e.now)}catch(a){throw o&&i&&qc(e.targetCacheDir,i),a}finally{r&&N(r,{recursive:!0,force:!0}),n.release()}}function Lc(e){let t=Je(u(e,"index.db"),u(e,"meta.json"));if(t.state==="invalid"||t.state==="drifted")throw new Error(`hydrated SQLite generation failed validation: ${t.reason}`)}function Dc(e,t,n){for(let r of e.artifacts){let i=O(t,r.path),o=O(n,r.path);if(be(i,o),Xe(o).size!==r.size||xe(o,{inputKind:"hydrated shared-generation artifact",maxBytes:v})!==r.sha256)throw new Error(`shared artifact is corrupt: ${r.path}`)}}function kc(e,t){let n=en(e.targetProjectRoot);if(n!==e.manifest.scipProjectRoot)for(let r of e.manifest.artifacts)r.path.endsWith(".scip")&&Gr(O(t,r.path),e.manifest.scipProjectRoot,n)}async function Xu(e,t={}){let n=t.timeoutMs??3e4,r=t.pollMs??100,i=t.now??we,o=i()+n,a=u(e.repositoryCacheDir,"locks"),s=u(a,`${e.generationId}.lock`);for(;i()<=o;){if(V(e))return{kind:"generation-ready"};let c=Ee(s,{kind:"shared-generation-build",detail:{generationId:e.generationId},parseLegacy:un});if(c.kind==="acquired")return{kind:"owner",release:()=>c.lock.release()};let d=o-i();if(d<=0)break;await Sc(Math.min(r,d))}return V(e)?{kind:"generation-ready"}:{kind:"timeout"}}function Cc(e,t,n,r=void 0){let i={version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,localCacheDir:t,baseGenerationId:e.generationId,activeGenerationId:e.generationId,lastAction:n,lastSeenAt:(r??(()=>new Date))().toISOString()},o={...i,ownershipChecksum:Qt(i)};return hi(e.repositoryCacheDir,o,!0),o}function Qu(e,t,n=void 0){let r={version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,localCacheDir:t,baseGenerationId:e.generationId,lastAction:"overlay",lastReason:`private cache forked from shared baseline ${e.generationId}`,lastSeenAt:(n??(()=>new Date))().toISOString()},i={...r,ownershipChecksum:Qt(r)};return hi(e.repositoryCacheDir,i,!0),i}function Qt(e){return vi(JSON.stringify({version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:z(e.projectRoot),localCacheDir:z(e.localCacheDir)}))}function gi(e){let t=JSON.parse(e);if(!Gc(t)||!Oc(t))throw new Error("invalid shared generation manifest");if(!Bc(t))throw new Error("invalid shared generation manifest");let n=new Set;for(let r of t.artifacts){if(Mc(r),Ye(r.path),n.has(r.path))throw new Error(`duplicate shared generation artifact: ${r.path}`);n.add(r.path)}for(let r of["index.db","index.scip","meta.json"])if(!n.has(r))throw new Error(`shared generation is missing ${r}`);return t}function Gc(e){return e.version===Yt&&e.artifactCatalogVersion===he&&typeof e.generationId=="string"&&/^[a-f0-9]{64}$/.test(e.generationId)&&typeof e.repositoryId=="string"&&/^[a-f0-9]{24}$/.test(e.repositoryId)}function Oc(e){return typeof e.treeOid=="string"&&e.treeOid!==""&&typeof e.producerIdentity=="string"&&e.producerIdentity===Ke&&typeof e.sourceProjectRoot=="string"&&typeof e.scipProjectRoot=="string"}function Bc(e){return typeof e.createdAt=="string"&&Number.isFinite(Date.parse(e.createdAt))&&!!e.fingerprint&&Array.isArray(e.artifacts)}function Mc(e){if(!e||typeof e.path!="string"||typeof e.size!="number"||e.size<0||typeof e.sha256!="string"||!/^[a-f0-9]{64}$/.test(e.sha256))throw new Error("invalid shared generation artifact")}function be(e,t,n=384){return Ae(e,t,{mode:n})}function _c(e,t,n){X(e,{recursive:!0}),k(u(e,fi),{version:1,repositoryId:t,worktreeId:n},{spacing:2,trailingNewline:!0})}function mi(e){try{let t=He(e),n=ci("sha256");for(let r of t.files){let i=O(e,r),o=Xe(i).size;n.update(r).update("\0").update(String(o)).update("\0"),sn(i,{inputKind:"source-generation artifact",maxBytes:v},a=>n.update(a)),n.update("\0")}return n.digest("hex")}catch{return null}}function yi(e){try{let t=an(E(u(e,"meta.json"),{inputKind:"reindex metadata",maxBytes:w}));return(t.kind==="legacy"||t.kind==="supported")&&t.capabilities.publishableGeneration?t.metadata:void 0}catch{return}}function Fc(e){return yi(e)?.scipCompanion!=="deferred"}function Nc(e,t){if(e.typescriptSymbolIdentityVersion!==t.typescriptSymbolIdentityVersion)return!1;let n=ft(e.languages,e);return JSON.stringify(n)===JSON.stringify(t)}function si(e,t){let n=new Map(e.files.map(o=>[o.path,`${o.size}\0${o.hash}`])),r=new Map(t.files.map(o=>[o.path,`${o.size}\0${o.hash}`])),i=0;for(let[o,a]of n)r.get(o)!==a&&(i+=1);for(let o of r.keys())n.has(o)||(i+=1);return i}function Zt(e){return u(e.repositoryCacheDir,"generations",e.generationId)}function jc(e){let t=JSON.parse(E(u(e,fi),{inputKind:"worktree cache pointer",maxBytes:w}));return t.version!==1||typeof t.repositoryId!="string"||!/^[a-f0-9]{24}$/.test(t.repositoryId)||typeof t.worktreeId!="string"||!/^[a-f0-9]{24}$/.test(t.worktreeId)?null:{version:t.version,repositoryId:t.repositoryId,worktreeId:t.worktreeId}}function hi(e,t,n){let r=fn(e,{waitMs:5e3});if(!r)throw new Error("repository cache cleanup is busy");try{if(n){let o=t.activeGenerationId??t.baseGenerationId;if(!o||!j(u(e,"generations",o)))throw new Error("shared generation disappeared before its lease was attached")}let i=u(e,"worktrees");X(i,{recursive:!0}),k(u(i,`${t.worktreeId}.json`),t,{spacing:2,trailingNewline:!0}),_c(t.localCacheDir,t.repositoryId,t.worktreeId)}finally{r.release()}}function $c(e,t){let n=u(t,".rollback"),r=new Map,i=new Map;X(n,{recursive:!0});for(let s of["index.scip","index.db","meta.json"]){let c=u(e,s),d=j(c);r.set(s,d),d&&be(c,u(n,"stable",s))}for(let s of Xt){let c=u(e,s),d=j(c);if(d){let l=Ht(c);if(!l.isDirectory()||l.isSymbolicLink())throw new Error(`managed artifact path is not a directory: ${s}`)}i.set(s,d)}let o=u(e,Le),a=j(o);return a&&Si(o,u(n,"sqlite-generations")),{root:n,stableFiles:r,managedDirectories:i,generationStoreExisted:a}}function Wc(e,t,n){for(let r of Xt){let i=u(t,r);if(n.managedDirectories.get(r)){let a=u(n.root,"managed",r);X(Jt(a),{recursive:!0}),U(i,a)}let o=u(e,r);j(o)&&U(o,i)}}function qc(e,t){for(let i of Xt){let o=u(e,i),a=u(t.root,"managed",i);t.managedDirectories.get(i)?j(a)&&(N(o,{recursive:!0,force:!0}),U(a,o)):N(o,{recursive:!0,force:!0})}for(let[i,o]of t.stableFiles){let a=u(e,i);if(!o){N(a,{force:!0});continue}let s=`${a}.shared-restore-${hc()}`;be(u(t.root,"stable",i),s),N(a,{force:!0}),U(s,a)}let n=u(e,Le);N(n,{recursive:!0,force:!0});let r=u(t.root,"sqlite-generations");t.generationStoreExisted&&j(r)&&U(r,n)}function Si(e,t){X(t,{recursive:!0});for(let n of li(e,{withFileTypes:!0})){let r=u(e,n.name),i=u(t,n.name);if(n.isSymbolicLink())throw new Error(`managed cache backup cannot contain a symlink: ${r}`);n.isDirectory()?Si(r,i):n.isFile()&&be(r,i)}}function zc(e,t){if(e.generationId!==t.generationId||e.repositoryId!==t.repositoryId||e.treeOid!==t.treeOid||e.producerIdentity!==t.producerIdentity||!Ie(e.fingerprint,t.fingerprint))throw new Error("shared generation manifest does not match the requested snapshot")}function bi(e,t,n,r=!0,i=!0){try{let o=yi(e);if(Hc(o,n))return Se("source validation rejected metadata"),!1;let a=He(e),s=Je(u(e,"index.db"),u(e,"meta.json"));if(r?s.state!=="current":s.state==="invalid"||s.state==="drifted")return Se(`source validation rejected SQLite generation state ${s.state}`),!1;if(!Jc(e,i))return!1;let c=en(t),l=(i?a.files.filter(f=>f.endsWith(".scip")):["index.scip"]).every(f=>{let g=le(b(O(e,f),{inputKind:"shared SCIP validation artifact",maxBytes:v}));return g!==c&&Se(`source validation rejected SCIP root for ${f}: ${String(g)}`),g===c});return l||Se("source validation rejected SCIP project roots"),l}catch(o){return Se(`source validation failed: ${o instanceof Error?o.message:String(o)}`),!1}}function Se(e){process.env.SCIP_QUERY_DEBUG&&console.error(`shared-cache: ${e}`)}function en(e){try{return oi(ui(e)).href}catch{return oi(z(e)).href}}function Uc(e){if(!e||typeof e!="object")return!1;let t=e;return t.version===3&&Array.isArray(t.languages)&&typeof t.pnpmWorkspaces=="boolean"&&(t.typescriptProjectMode==="single"||t.typescriptProjectMode==="workspace")&&Array.isArray(t.typescriptProjects)&&Array.isArray(t.files)&&t.files.every(n=>n!==null&&typeof n=="object"&&typeof n.path=="string"&&typeof n.size=="number"&&typeof n.hash=="string"&&(n.semanticHash===void 0||typeof n.semanticHash=="string"))}function vi(e){return ci("sha256").update(e).digest("hex")}function Vc(e,t){return!(e.generationId!==t.generationId||e.repositoryId!==t.repositoryId||e.treeOid!==t.treeOid||e.producerIdentity!==t.producerIdentity||!Ie(e.fingerprint,t.fingerprint))}function Jc(e,t){let n=new bc(u(e,"index.db"),{readonly:!0,fileMustExist:!0});try{if(t){if(n.pragma("quick_check(1)",{simple:!0})!=="ok")return!1}else n.pragma("schema_version",{simple:!0})}finally{n.close()}return!0}function Hc(e,t){return!e||e.scipCompanion==="deferred"||!Ie(rn(e.fingerprint),t)||JSON.stringify([...e.indexedLanguages??[]].sort())!==JSON.stringify([...t.languages].sort())}export{Ln as a,ud as b,fd as c,pd as d,gd as e,I as f,de as g,Ge as h,Vi as i,Ad as j,Td as k,Un as l,Ld as m,Vn as n,Bd as o,ge as p,Md as q,R as r,Qd as s,xt as t,ko as u,Go as v,Zd as w,Oo as x,el as y,Fo as z,tl as A,ur as B,ze as C,Mr as D,cl as E,bl as F,Cr as G,Ll as H,Dl as I,kl as J,Za as K,Vl as L,Jl as M,Hl as N,Zl as O,Kr as P,$s as Q,gu as R,Je as S,Ic as T,Vu as U,Ju as V,V as W,Hu as X,Yu as Y,Ku as Z,Xu as _,Cc as $,Qu as aa};
|
|
12
|
+
//# sourceMappingURL=chunk-K4CN7GXK.js.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import{d as l}from"./chunk-TZCVNCAN.js";import{b as n}from"./chunk-OGFV2BUX.js";import{c as o,f as i}from"./chunk-YULZRALL.js";function h(e,s){let t=n(e,s);return t.length===0?[]:d([...c(e,t),...m(e,t)]).filter(r=>!e.isIgnored(r.relative_path)).map(u)}function _(e,s){let t=n(e,s);return t.length===0?[]:d(c(e,t)).filter(r=>!e.isIgnored(r.relative_path)).map(r=>({...u(r),basis:"external-reference"}))}function c(e,s){return e.all(`WITH selected_paths(path) AS (SELECT value FROM json_each(?))
|
|
2
|
+
SELECT DISTINCT d1.relative_path, gs.symbol
|
|
3
|
+
FROM mentions m
|
|
4
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
5
|
+
JOIN documents d1 ON c.document_id = d1.id
|
|
6
|
+
JOIN global_symbols gs ON m.symbol_id = gs.id
|
|
7
|
+
WHERE d1.relative_path NOT IN (SELECT path FROM selected_paths)
|
|
8
|
+
AND (
|
|
9
|
+
EXISTS (
|
|
10
|
+
SELECT 1
|
|
11
|
+
FROM defn_enclosing_ranges der
|
|
12
|
+
JOIN documents d2 ON der.document_id = d2.id
|
|
13
|
+
WHERE der.symbol_id = gs.id
|
|
14
|
+
AND d2.relative_path IN (SELECT path FROM selected_paths)
|
|
15
|
+
)
|
|
16
|
+
OR EXISTS (
|
|
17
|
+
SELECT 1
|
|
18
|
+
FROM mentions def_m
|
|
19
|
+
JOIN chunks def_c ON def_m.chunk_id = def_c.id
|
|
20
|
+
JOIN documents d2 ON def_c.document_id = d2.id
|
|
21
|
+
WHERE def_m.symbol_id = gs.id
|
|
22
|
+
AND def_m.role = 1
|
|
23
|
+
AND d2.relative_path IN (SELECT path FROM selected_paths)
|
|
24
|
+
)
|
|
25
|
+
)
|
|
26
|
+
AND m.role != 1
|
|
27
|
+
AND ${e.localSymbolPredicate}
|
|
28
|
+
${e.pathExclusionsFor("d1")}
|
|
29
|
+
ORDER BY d1.relative_path, gs.symbol`,JSON.stringify(s))}function m(e,s){let t=new l(e);return s.flatMap(r=>t.definitionsForFile(r).filter(a=>i(a.symbol)).map(a=>({relative_path:r,symbol:a.symbol})))}function d(e){let s=new Set;return e.filter(t=>{let r=`${t.relative_path}|${t.symbol}`;return s.has(r)?!1:(s.add(r),!0)})}function u(e){return{consumer:e.relative_path,symbol:e.symbol,shortName:o(e.symbol)}}export{h as a,_ as b};
|
|
30
|
+
//# sourceMappingURL=chunk-K5TBVXU4.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import{a as M}from"./chunk-P5XHIJHI.js";import{g as T,i as H}from"./chunk-D3FDISIC.js";import{Da as S}from"./chunk-5TNQJUR2.js";import{execFileSync as I}from"child_process";var _=2e3,p=50,N=64,z=8,B=3,$=2160*60*60,K=/\b(?:fix(?:es|ed)?|bug|regression|hotfix)\b/i,U=3,J=/#\d+|\b[A-Z][A-Z0-9]+-\d+\b/g,Y=/^([a-z][a-z0-9-]+)(?:\([^)]+\))?!?:/i;function V(e){let t=S(e,{clearGroups:["whole-project"]});return(n,i,r)=>{let o=r??x(n.config.projectRoot);if(!o)return null;let s=t.has(n)?t.get(n,()=>({head:"",value:null})):null;return s&&s.head===o?s.value:(t.invalidate(n),t.get(n,()=>({head:o,value:i(n.config.projectRoot,o)})).value)}}function b(e){let t=S(e,{clearGroups:["whole-project"]});return(n,i,r,o)=>{let s=o??x(n.config.projectRoot);if(!s)return null;let a=t.has(n)?t.get(n,()=>({head:"",values:new Map})):null;(!a||a.head!==s)&&t.invalidate(n);let c=t.get(n,()=>({head:s,values:new Map}));if(c.values.has(i))return c.values.get(i)??null;let g=r(n.config.projectRoot,s);return c.values.set(i,g),g}}var W=b("git-commit-history");function X(e,t={}){let n=t.historyMode??"bounded",i=t.head;return{capability:r=>Z(e,r,i),commitHistory:()=>C(e,n,i),fileChurn:()=>ee(e,n,i),changeAmplification:()=>te(e,n,i),trackedFiles:()=>ie(e,i),fileAddRecords:()=>oe(e,n,i),coChangePairs:(r={})=>he(e,r,n,i),coChangePairsForFiles:(r,o={})=>D(e,r,o,n,i),directionalCoChangePairsForFiles:(r,o={})=>Ce(e,r,o,n,i)}}function C(e,t="bounded",n){return W(e,h(t),(i,r)=>Q(i,r,t),n)}function Z(e,t,n){let i=n??x(e.config.projectRoot);return i?{slot:t,available:!0,head:i}:{slot:t,available:!1,head:null,reason:"git history is unavailable for this project"}}function x(e){try{return m(e,["rev-parse","HEAD"]).trim()||null}catch{return null}}function m(e,t){return I("git",["-C",e,...t],{encoding:"utf-8",maxBuffer:64*1024*1024,stdio:["ignore","pipe","ignore"],timeout:3e4,killSignal:"SIGKILL"})}function Q(e,t,n){let i;try{i=m(e,["log","--no-merges","--name-only",...y(n),"--pretty=format:%x01%H%x00%ct%x00%s"])}catch{return null}return{head:t,...P(i,p)}}function q(e){return K.test(e.subject)}function ee(e,t,n){let i=C(e,t,n);if(!i)return null;let r=new Map;for(let o of i.commits){let s=q(o);for(let a of o.files){let c=r.get(a)??{changes:0,fixChanges:0,lastChangedAt:0};c.changes+=1,s&&(c.fixChanges+=1),o.timestamp>c.lastChangedAt&&(c.lastChangedAt=o.timestamp),r.set(a,c)}}return r}function te(e,t,n){let i=C(e,t,n);if(!i||i.commits.length===0)return null;let r=i.commits.map(o=>o.files.length).filter(o=>o>0).sort((o,s)=>o-s);return r.length===0?null:{medianFilesPerCommit:v(r,.5),p90FilesPerCommit:v(r,.9),commitsAnalyzed:r.length}}function v(e,t){let n=Math.min(e.length-1,Math.floor(e.length*t));return e[n]}var ne=V("git-tracked-files");function ie(e,t){return ne(e,n=>{try{let i=m(n,["ls-files"]);return new Set(i.split(`
|
|
2
|
+
`).map(r=>r.trim()).filter(r=>r!==""))}catch{return null}},t)}var re=b("git-file-adds"),G="__git__/file-adds",E=T({kind:"git-file-adds",invalidation:H("git-file-adds"),serialize:ae,deserialize:le});function De(e){return X(e).fileAddRecords()}function oe(e,t,n){let i=h(t);return re(e,i,(r,o)=>se(e,r,o,t),n)}function se(e,t,n,i){let r=E.read(e,w(i),n);if(r)return r;let o=ue(t,i);return o&&E.write(e,w(i),n,o),o}function ae(e){return JSON.stringify([...e.entries()])}function ce(e){let t=e;return!t||typeof t.commitsAgo!="number"||!Number.isFinite(t.commitsAgo)||typeof t.addedAt!="number"||!Number.isFinite(t.addedAt)?null:{commitsAgo:t.commitsAgo,addedAt:t.addedAt}}function le(e){if(!e)return null;try{let t=JSON.parse(e);if(!Array.isArray(t))return null;let n=new Map;for(let i of t){if(!Array.isArray(i)||i.length!==2||typeof i[0]!="string")return null;let r=ce(i[1]);if(!r)return null;n.set(i[0],{commitsAgo:r.commitsAgo,addedAt:r.addedAt})}return n}catch{return null}}function ue(e,t){let n;try{n=m(e,["log","--no-merges","--find-renames","--name-status",...y(t),"--pretty=format:%x01%H%x00%ct%x00%s"])}catch{return null}let i=new Map,r=new Map,o=-1;for(let s of n.split("")){if(s.trim()==="")continue;o+=1;let a=s.indexOf(`
|
|
3
|
+
`),c=a>=0?s.slice(0,a):s,[,g]=c.split("\0"),d=Number(g)||0;a<0||ge(s.slice(a+1),{commitsAgo:o,addedAt:d},i,r)}return i}function ge(e,t,n,i){for(let r of e.split(`
|
|
4
|
+
`)){let o=me(r);o&&de(o,t,n,i)}}function de(e,t,n,i){if(e.status==="R"&&e.from&&e.to){let o=i.get(e.to)??new Set([e.to]);i.set(e.from,o);return}if(e.status!=="A"||!e.to)return;let r={commitsAgo:t.commitsAgo,addedAt:t.addedAt};n.set(e.to,r);for(let o of i.get(e.to)??[])n.set(o,r)}function me(e){let t=e.trim().split(" "),n=t[0]??"";if(!n)return null;let i=n[0]??"";if(i==="R"){let o=t[1],s=t[2];return o&&s?{status:i,from:o,to:s}:null}let r=t[1];return r?{status:i,to:r}:null}var O=b("git-co-change-pairs"),fe=b("git-directional-co-change-pairs");function he(e,t,n,i){let r=`all\0${h(n)}\0${F(t)}`,o=O(e,r,()=>{let s=C(e,n,i);return s?R(s,t):null},i);return o&&[...o]}function D(e,t,n,i,r){if(t.size===0)return[];let o=`files\0${h(i)}\0${k(t)}\0${F(n)}`,s=O(e,o,()=>{let a=C(e,i,r);return a?R(a,n,t):null},r);return s&&[...s]}function Ce(e,t,n,i,r){if(t.size===0)return[];let o=n.maxFilesPerCommit??p;if(t.size>N)return D(e,t,n,i,r);let s=`directional\0${h(i)}\0${k(t)}\0${F({...n,maxFilesPerCommit:o})}`,a=fe(e,s,(c,g)=>{let d=Se(c,g,t,o,i);return d?R(d,n,t):null},r);return a&&[...a]}function F(e){let t=e.minTogether??4,n=e.minConfidence??.6,i=e.maxFilesPerCommit??p;return`${t}\0${n}\0${i}`}function k(e){return[...e].sort().join("\0")}function R(e,t,n){let{minTogether:i=4,minConfidence:r=.6,maxFilesPerCommit:o=p}=t,s=new Map,a=new Map,c=e.newestAnalyzedAt??0;for(let u of e.commits){let l=[...new Set(u.files)].sort();if(l.length>o)continue;e.newestAnalyzedAt===void 0&&u.timestamp>c&&(c=u.timestamp);let f=Re(l),A=n===void 0||l.some(L=>n.has(L));pe(s,l),A&&be(a,l,u,f,n)}let g=[],d=c-$;for(let[u,l]of a){let f=Ae(u,l,s,i,r,d);f&&g.push(f)}return g.sort((u,l)=>l.together-u.together||l.confidence-u.confidence||u.fileA.localeCompare(l.fileA)),g}function pe(e,t){for(let n of t)e.set(n,(e.get(n)??0)+1)}function be(e,t,n,i,r){for(let o=0;o<t.length;o++)for(let s=o+1;s<t.length;s++)r&&!r.has(t[o])&&!r.has(t[s])||ye(e,`${t[o]}\0${t[s]}`,n,i)}function ye(e,t,n,i){let r=e.get(t)??{together:0,focusedTogether:0,broadTogether:0,lastTogetherAt:0,timestamps:[],subjects:[]};r.together+=1,i?r.broadTogether+=1:r.focusedTogether+=1,n.timestamp>r.lastTogetherAt&&(r.lastTogetherAt=n.timestamp),r.timestamps.push(n.timestamp),r.subjects.push(n.subject),e.set(t,r)}function Ae(e,t,n,i,r,o){let s=t.together;if(s<i)return null;let[a,c]=e.split("\0"),g=n.get(a)??s,d=n.get(c)??s,u=Math.max(s/g,s/d);if(u<r)return null;let l=t.broadTogether/s,f=t.timestamps.filter(A=>A>=o).length;return{fileA:a,fileB:c,together:s,confidence:u,changesA:g,changesB:d,focusedTogether:t.focusedTogether,broadTogether:t.broadTogether,broadCommitRatio:l,lastTogetherAt:t.lastTogetherAt,recentTogether:f,commitScope:Te(t.broadTogether,s),recency:f>0?"recent":"stale",subjectContext:He(t.subjects)}}function Se(e,t,n,i,r){let o;try{o=xe(e,r)}catch{return null}if(o.length===0)return{head:t,commits:[],skippedBulkCommits:0,newestAnalyzedAt:0};let s;try{s=m(e,["log","--no-merges","--format=%H",...y(r),"--",...[...n].sort()])}catch{return null}let a=new Set(o.map(l=>l.hash)),c=s.split(`
|
|
5
|
+
`).map(l=>l.trim()).filter(l=>l!==""&&a.has(l)),g=Fe(e,o,i);if(c.length===0)return{head:t,commits:[],skippedBulkCommits:0,newestAnalyzedAt:g};let d;try{d=m(e,["show","--no-walk=unsorted","--name-only","--pretty=format:%x01%H%x00%ct%x00%s",...c])}catch{return null}let u=P(d,i);return{head:t,...u,newestAnalyzedAt:g}}function xe(e,t){return m(e,["log","--no-merges","--format=%H%x00%ct",...y(t)]).split(`
|
|
6
|
+
`).map(i=>i.trim()).filter(i=>i!=="").map(i=>{let[r,o]=i.split("\0");return{hash:r??"",timestamp:Number(o)||0}}).filter(i=>i.hash!=="")}function y(e){return e==="full"?[]:["-n",String(j())]}function j(){return M(process.env.SCIP_QUERY_GIT_HISTORY_MAX_COMMITS)??_}function h(e){return e==="full"?"full":`bounded:${j()}`}function w(e){let t=h(e);return t===`bounded:${_}`?G:`${G}:${t}`}function Fe(e,t,n){for(let r=0;r<t.length;r+=20){let o=t.slice(r,r+20),s;try{s=m(e,["show","--no-walk=unsorted","--name-only","--pretty=format:%x01%H%x00%ct%x00%s",...o.map(c=>c.hash)])}catch{return t[0]?.timestamp??0}let a=P(s,n);if(a.commits.length>0)return a.commits[0].timestamp}return 0}function P(e,t){let n=[],i=0;for(let r of e.split("")){if(r.trim()==="")continue;let o=r.indexOf(`
|
|
7
|
+
`),s=o>=0?r.slice(0,o):r,[a,c,g]=s.split("\0");if(!a||!c)continue;let d=o>=0?r.slice(o+1).split(`
|
|
8
|
+
`).map(u=>u.trim()).filter(u=>u!==""):[];if(d.length>t){i+=1;continue}n.push({hash:a,timestamp:Number(c)||0,subject:g??"",files:d})}return{commits:n,skippedBulkCommits:i}}function Re(e){return e.length>=z?!0:Pe(e).size>=B}function Pe(e){let t=new Set;for(let n of e){let i=n.indexOf("/");t.add(i>=0?n.slice(0,i):".")}return t}function Te(e,t){return e===0?"focused":e/t>=.5?"broad-sweep":"mixed"}function He(e){let t=new Set,n=[],i=[];for(let r of e){!i.includes(r)&&i.length<U&&i.push(r);for(let o of ve(r))t.add(o);for(let o of r.match(J)??[])n.includes(o)||n.push(o)}return{subjectLabels:[...t].sort(),issueRefs:n,sampleSubjects:i,externalIssueLabelStatus:"unavailable"}}var Me=[[/\b(?:feat|feature)\b/i,"feature"],[/\b(?:fix(?:es|ed)?|bug|regression|hotfix)\b/i,"fix"],[/\b(?:docs?|documentation|guide|readme)\b/i,"docs"],[/\brefactor(?:ing|ed)?\b/i,"refactor"],[/\btests?\b/i,"test"],[/\b(?:release|version|v\d+\.\d+)\b/i,"release"],[/\bchore\b/i,"chore"],[/\bbuild\b/i,"build"],[/\bci\b/i,"ci"],[/\bperf(?:ormance)?\b/i,"perf"]];function ve(e){let t=new Set,n=Y.exec(e)?.[1]?.toLowerCase();n&&t.add(Ge(n));for(let[i,r]of Me)i.test(e)&&t.add(r);return[...t]}function Ge(e){return e==="feat"?"feature":e}export{X as a,m as b,De as c};
|
|
9
|
+
//# sourceMappingURL=chunk-KDDIE2DP.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{e as u}from"./chunk-72AD6ZRR.js";import{ts as n}from"@ts-morph/common";function c(r,t){let i=[],s=(e,l,a)=>{if(!e)return;let p=n.isStringLiteralLike(e);i.push({specifier:p?e.text:e.getText(r),literal:p,line:r.getLineAndCharacterOfPosition(e.getStart(r)).line+1,kind:l,syntax:a})},o=e=>{if(n.isImportDeclaration(e))s(e.moduleSpecifier,m(e),"import");else if(n.isExportDeclaration(e))s(e.moduleSpecifier,y(e),"reexport");else if(n.isImportEqualsDeclaration(e)&&n.isExternalModuleReference(e.moduleReference))s(e.moduleReference.expression,e.isTypeOnly?"type":"value","require");else if(n.isImportTypeNode(e)&&n.isLiteralTypeNode(e.argument))s(e.argument.literal,"type","type-import");else if(n.isCallExpression(e)){let l=f(e,t);l&&s(e.arguments[0],"value",l)}n.forEachChild(e,o)};return o(r),i}function g(r,t){let i=u(r,t);return i.errors.length?null:c(i.sourceFile,()=>i.checker)}function f(r,t){if(r.expression.kind===n.SyntaxKind.ImportKeyword)return"dynamic-import";if(n.isIdentifier(r.expression)&&r.expression.text==="require"&&!(typeof t=="function"?t():t).getSymbolAtLocation(r.expression))return"require"}function m(r){let t=r.importClause;if(t?.isTypeOnly)return"type";let i=t?.namedBindings;return!t?.name&&i&&n.isNamedImports(i)&&i.elements.length>0&&i.elements.every(s=>s.isTypeOnly)?"type":"value"}function y(r){let t=r.exportClause;return r.isTypeOnly||t&&n.isNamedExports(t)&&t.elements.length>0&&t.elements.every(i=>i.isTypeOnly)?"type":"value"}export{c as a,g as b};
|
|
2
|
+
//# sourceMappingURL=chunk-KHWRRPV4.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
function o(e,m){return e.get(`SELECT COUNT(DISTINCT c.document_id) AS file_count
|
|
2
|
+
FROM mentions m
|
|
3
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
4
|
+
JOIN (
|
|
5
|
+
SELECT m2.symbol_id, c2.document_id
|
|
6
|
+
FROM mentions m2
|
|
7
|
+
JOIN chunks c2 ON m2.chunk_id = c2.id
|
|
8
|
+
WHERE m2.role = 1
|
|
9
|
+
GROUP BY m2.symbol_id
|
|
10
|
+
) sym_def ON sym_def.symbol_id = m.symbol_id
|
|
11
|
+
WHERE m.symbol_id = ?
|
|
12
|
+
AND m.role != 1
|
|
13
|
+
AND sym_def.document_id != c.document_id`,m)?.file_count??0}export{o as a};
|
|
14
|
+
//# sourceMappingURL=chunk-KI6NBKDY.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as c}from"./chunk-HRRFKWPZ.js";function d(e,r,n){e!==void 0&&typeof e!="boolean"&&n.push({level:"error",path:r,message:"Must be a boolean."})}function $(e,r){if(e.architecture===void 0)return;if(!c(e.architecture)){r.push({level:"error",path:"architecture",message:"Must be an object."});return}let n=e.architecture,t=n.boundaries;if(!Array.isArray(t)||t.length===0){r.push({level:"error",path:"architecture.boundaries",message:"Must be a non-empty array."});return}let o={names:new Set,paths:new Set};for(let[i,s]of t.entries())m(s,`architecture.boundaries[${i}]`,o,r);h(n.allowedDependencies,o.names,r),C(n,r),b(n,o.names,r)}function m(e,r,n,t){if(!c(e)){t.push({level:"error",path:r,message:"Architecture boundary must be an object."});return}let o=e.name;typeof o!="string"||o.trim()===""?t.push({level:"error",path:`${r}.name`,message:"Boundary name is required."}):n.names.has(o)?t.push({level:"error",path:`${r}.name`,message:`Duplicate boundary name: ${o}`}):n.names.add(o);let i=e.subUnits;i!==void 0&&i!=="directory"&&i!=="file"&&t.push({level:"error",path:`${r}.subUnits`,message:"Must be 'directory' or 'file'."}),p(e.maxFiles,`${r}.maxFiles`,t),g(e.paths,`${r}.paths`,n.paths,t)}function g(e,r,n,t){if(!Array.isArray(e)||e.length===0){t.push({level:"error",path:r,message:"Boundary paths must be a non-empty array."});return}for(let[o,i]of e.entries()){let s=`${r}[${o}]`;if(typeof i!="string"||i.trim()===""){t.push({level:"error",path:s,message:"Boundary path must be a non-empty string."});continue}P(i)||t.push({level:"error",path:s,message:"Boundary path must be project-relative and may use only one trailing /* or /** glob."}),n.has(i)?t.push({level:"error",path:s,message:`Duplicate boundary path: ${i}`}):n.add(i)}}function h(e,r,n){if(e!==void 0){if(!c(e)){n.push({level:"error",path:"architecture.allowedDependencies",message:"Must be an object keyed by boundary name."});return}for(let[t,o]of Object.entries(e))y(t,o,r,n)}}function y(e,r,n,t){let o=`architecture.allowedDependencies.${e}`;if(n.has(e)||t.push({level:"error",path:o,message:`Unknown source boundary: ${e}`}),!Array.isArray(r)){t.push({level:"error",path:o,message:"Dependency row must be an array."});return}let i=new Set;for(let[s,a]of r.entries()){let l=`${o}[${s}]`;typeof a!="string"||a.trim()===""?t.push({level:"error",path:l,message:"Target boundary name is required."}):n.has(a)?i.has(a)?t.push({level:"error",path:l,message:`Duplicate target boundary: ${a}`}):i.add(a):t.push({level:"error",path:l,message:`Unknown target boundary: ${a}`})}}function C(e,r){for(let t of["requireAcyclic","requireCompleteCoverage","requireResolvedBoundaries","requireMinimalPolicy"])d(e[t],`architecture.${t}`,r);for(let t of["maxBoundaryFanOut","maxBoundaryFiles"])p(e[t],`architecture.${t}`,r);let n=e.testPaths;n!==void 0&&(!Array.isArray(n)||n.some(t=>typeof t!="string"))&&r.push({level:"error",path:"architecture.testPaths",message:"Must be an array of strings."})}function b(e,r,n){if(d(e.requireCompletePolicy,"architecture.requireCompletePolicy",n),e.requireCompletePolicy!==!0)return;let t=c(e.allowedDependencies)?e.allowedDependencies:{};for(let o of[...r].sort())Object.hasOwn(t,o)||n.push({level:"error",path:`architecture.allowedDependencies.${o}`,message:"A dependency row is required by architecture.requireCompletePolicy."})}function p(e,r,n){e!==void 0&&(typeof e!="number"||!Number.isInteger(e)||e<0)&&n.push({level:"error",path:r,message:"Must be a non-negative integer."})}function P(e){let r=e.replace(/\\/g,"/");if(/^(?:\/|[a-z]:)/i.test(r)||r==="."||r===".."||r.split("/").includes(".."))return!1;let n=r.replace(/\/\*\*?$/,"");return n.length>0&&!/[*?[\]]/.test(n)}var u=1,f=2,v="./node_modules/scip-query/docs/schemas/project-config.schema.json";function _(e){let r=e;if(typeof e=="string")try{r=JSON.parse(e)}catch(n){return{kind:"malformed",reason:`invalid JSON: ${n instanceof Error?n.message:String(n)}`}}return c(r)?j(r):{kind:"malformed",reason:"project config must be a JSON object"}}function j(e){let r=e.schemaVersion;if(r!==void 0&&!Number.isInteger(r))return{kind:"malformed",reason:"schemaVersion must be an integer"};let n=r===void 0?u:r;return n!==u&&n!==f?{kind:"unsupported",schemaVersion:n,direction:n<u?"older":"future"}:w(e,n)}function w(e,r){let n=e.$schema;if(n!==void 0&&(typeof n!="string"||n.trim()===""))return{kind:"malformed",reason:"$schema must be a non-empty string when present"};let t=A(e),o=r!==f||typeof e.$schema!="string";return r===u?{kind:"legacy",sourceVersion:u,config:t,needsMigration:o}:{kind:"supported",sourceVersion:f,config:t,needsMigration:o}}function A(e){let r=e,{$schema:n,schemaVersion:t,...o}=r;return{$schema:typeof n=="string"&&n.trim()!==""?n:v,schemaVersion:f,...o}}export{$ as a,u as b,f as c,_ as d};
|
|
2
|
+
//# sourceMappingURL=chunk-KU3QRSTH.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var h=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"];function B(r){let e=r.toLowerCase();return h.some(t=>e.endsWith(t))}import{realpathSync as M}from"fs";import{createRequire as T}from"module";import{dirname as f,resolve as g}from"path";import{getHeapStatistics as y}from"v8";var j=2560,P=1.25;function S(r){let e=r/1048576;return Math.max(0,Math.floor((e-j)/P))}function d(){return S(y().heap_size_limit)}var m=T(import.meta.url),c,p;function E(){if(c!==void 0)return c;try{c=m("ts-morph")}catch{c=null}return c}function H(){if(p)return p;let r=E();if(!r)return"ts-morph:unavailable";let e="unknown";try{e=m("ts-morph/package.json").version??"unknown"}catch{}return p=`ts-morph:${e}:typescript:${r.ts.version}`,p}function z(r,e,t={}){return R(r,e).map(n=>_(r,n,t))}var x=3;function R(r,e){let t=[],n=new Set,s=(o,l)=>{let i=g(o);if(n.has(i))return;n.add(i);let u=l<x?F(r,i):[];if(u.length===0){t.push(i);return}for(let a of u)s(a,l+1)};for(let o of e)s(o,0);return t}function F(r,e){try{let t=r.ts,n=t.readConfigFile(e,t.sys.readFile);if(n.error||!n.config)return[];let s=t.parseJsonConfigFileContent(n.config,t.sys,f(e),void 0,e);return s.fileNames.length>0||!s.projectReferences?.length?[]:s.projectReferences.map(o=>t.resolveProjectReferencePath(o)).filter(o=>t.sys.fileExists(o))}catch{return[]}}function _(r,e,t){let n=null,s,o,l=()=>(s===void 0&&(s=v(r,e)),s),i=()=>{if(o===void 0){let u=t.fileBudget??d(),a=l();o=(a===null?0:Math.ceil(a.size/2))>u*C?"file-closure":"project"}return o};return{tsconfigPath:e,get project(){return n??=new r.Project({tsConfigFilePath:e,skipFileDependencyResolution:!0,...i()==="file-closure"?{skipAddingFilesFromTsConfig:!0}:{}}),n},get loaded(){return n!==null},get fileNames(){return l()},get scope(){return i()}}}var C=1.35,D="TypeScript project-wide semantics are unavailable: a compiler project is file-scoped because its tsconfig lists more files than the worker heap can hold.";function U(r){return r.some(e=>e.scope==="file-closure")}function v(r,e){try{let t=r.ts,n=t.readConfigFile(e,t.sys.readFile);if(n.error||!n.config)return null;let s=t.parseJsonConfigFileContent(n.config,t.sys,f(e),void 0,e),o=new Set;for(let l of s.fileNames){let i=g(l);o.add(i);try{o.add(M(i))}catch{}}return o}catch{return null}}function J(r,e,t){return{language:"typescript",availability:()=>({available:!1,reason:r,tsconfigPath:e,tsconfigPaths:t}),importUsage:()=>[],referencesFor:()=>[],calleesFor:()=>[],signatureFor:()=>null}}export{h as a,B as b,E as c,H as d,z as e,D as f,U as g,J as h};
|
|
2
|
+
//# sourceMappingURL=chunk-KZBJWZJB.js.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{v as ae,w as _e}from"./chunk-JYWEX7RR.js";import{B as Y,G as Ce,I as be,L as X,Pe as te,Qe as re,Re as g,Se as q,Te as j,X as Z,Xa as Ae,Y as I,Z as We,ba as w,ca as ke,da as Ee,ia as P,kf as ne,kg as Oe,lf as Te,lg as De,mf as ie,nf as oe,oe as m,of as xe,pe as Pe,pf as qe,qe as x,qf as se,re as ee,se as C,t as f,vg as Le,xa as T,ye as b,ze as $}from"./chunk-OZCJXZK6.js";import{spawn as Ot}from"child_process";import{existsSync as pe,rmSync as Je}from"fs";import{dirname as Dt,resolve as k}from"path";import{fileURLToPath as Lt}from"url";import{createHash as Rt,randomUUID as ce}from"crypto";import{existsSync as It,linkSync as wt,readdirSync as Ct,rmSync as W}from"fs";import{basename as bt,dirname as Wt,join as u}from"path";var v=1,kt=10*6e4,Et=10080*6e4,F="requests",_="claims",N="completions",Ge="staging";function $e(e,t,r={}){let n=r.now?.()??new Date,i=Tt(r.ttlMs),o=xt(r.idempotencyKey),a=o?`key-${Rt("sha256").update(o).digest("hex")}`:`request-${(r.randomId??ce)()}`,s={version:v,requestId:a,...o?{idempotencyKey:o}:{},createdAt:n.toISOString(),deadlineAt:new Date(n.getTime()+i).toISOString(),detail:t.trim().slice(0,2048)||"stale index observed by a command"},c=Ue(e,a),d=le(e,c,s,r.onStage);if(d.published)return{disposition:"accepted",request:s,achievedDurability:d.achievedDurability,directorySync:d.directorySync};let p=de(c);if(!p)throw new Error(`Watch refresh request identity ${a} exists but is malformed.`);return{disposition:"duplicate",request:p}}function br(e,t={}){let r=t.now?.()??new Date,n=`claim-${(t.randomId??ce)()}`,i=Math.max(1,Math.floor(t.limit??64)),o=Fe(e).sort(qt),a=[];for(let s of o){if(a.length>=i)break;if(Me(e,s.requestId))continue;if(Date.parse(s.deadlineAt)<=r.getTime()){Ne(e,{version:v,requestId:s.requestId,outcome:"expired",completedAt:r.toISOString()});continue}let c={version:v,requestId:s.requestId,claimId:n,claimedAt:r.toISOString()};if(le(e,Be(e,s.requestId),c).published){if(Me(e,s.requestId)){He(e,s.requestId,n);continue}a.push(s)}}return{claimId:n,requests:a}}function Wr(e,t,r=()=>new Date,n){let i=r().toISOString();for(let o of t.requests)Ne(e,{version:v,requestId:o.requestId,claimId:t.claimId,outcome:"completed",completedAt:i});n?.("after-completion"),At(e,t),n?.("after-claim-release")}function At(e,t){for(let r of t.requests)He(e,r.requestId,t.claimId)}function kr(e){let t=0;for(let r of S(u(e,_)))W(r,{force:!0}),t++;return t>0&&I(u(e,_)),Ve(e),t}function Er(e){let t=Fe(e),r=new Map,n=Pt(u(e,F),de);for(let c of S(u(e,N))){let d=H(c);if(!d){n++;continue}r.set(d.requestId,d)}let i=new Set;for(let c of S(u(e,_))){let d=je(c);if(!d){n++;continue}i.add(d.requestId)}let o=t.filter(c=>!r.has(c.requestId)&&!i.has(c.requestId)),a=[...r.values()].filter(c=>c.outcome==="completed").length,s=[...r.values()].filter(c=>c.outcome==="expired").length;return{pending:o.length,claimed:t.filter(c=>!r.has(c.requestId)&&i.has(c.requestId)).length,completed:a,expired:s,invalid:n,...o.length>0?{oldestPendingAt:o.map(c=>c.createdAt).reduce((c,d)=>_t(c,d))}:{}}}function Ar(e,t={}){let r=(t.now?.()??new Date).getTime(),n=Math.max(0,t.retentionMs??Et),i=0;for(let o of S(u(e,N))){let a=H(o);!a||r-Date.parse(a.completedAt)<n||(W(o,{force:!0}),W(Ue(e,a.requestId),{force:!0}),i++)}return i>0&&(I(u(e,N)),I(u(e,F))),Ve(e),i}function de(e){return ue(e,t=>{let r=t;return r.version===v&&O(r.requestId)&&(r.idempotencyKey===void 0||typeof r.idempotencyKey=="string")&&T(r.createdAt)&&T(r.deadlineAt)&&Date.parse(r.deadlineAt)>=Date.parse(r.createdAt)&&typeof r.detail=="string"&&r.detail.length>0})}function je(e){return ue(e,t=>{let r=t;return r.version===v&&O(r.requestId)&&O(r.claimId)&&T(r.claimedAt)})}function H(e){return ue(e,t=>{let r=t;return r.version===v&&O(r.requestId)&&(r.claimId===void 0||O(r.claimId))&&(r.outcome==="completed"||r.outcome==="expired")&&T(r.completedAt)})}function Ne(e,t){let r=ze(e,t.requestId);if(le(e,r,t).published)return;let n=H(r);if(!n||n.requestId!==t.requestId||n.outcome!==t.outcome)throw new Error(`Watch refresh completion ${t.requestId} conflicts with an existing record.`)}function le(e,t,r,n){let i=u(e,Ge),o=Wt(t),a=Z(i),s=Z(o),c=u(i,`${bt(t)}.${process.pid}.${ce()}.tmp`);try{let d=$(c,r,{spacing:2,trailingNewline:!0});n?.("after-staged");try{wt(c,t)}catch(R){if(R.code==="EEXIST")return{published:!1};throw R}let p=We(a,s,d.directorySync,I(o));return n?.("after-published"),{published:!0,achievedDurability:p==="synced"?"directory-durable":"file-flushed",directorySync:p}}finally{W(c,{force:!0})}}function Fe(e){let t=[];for(let r of S(u(e,F))){let n=de(r);n&&t.push(n)}return t}function He(e,t,r){let n=Be(e,t),i=je(n);!i||i.claimId!==r||(W(n,{force:!0}),I(u(e,_)))}function Ve(e){for(let t of S(u(e,Ge),".tmp"))W(t,{force:!0})}function Pt(e,t){return S(e).filter(r=>!t(r)).length}function S(e,t=".json"){return It(e)?Ct(e,{withFileTypes:!0}).filter(r=>r.isFile()&&r.name.endsWith(t)).map(r=>u(e,r.name)).sort():[]}function ue(e,t){try{let r=JSON.parse(f(e,"watch refresh request record"));return t(r)?r:null}catch{return null}}function Ue(e,t){return u(e,F,`${t}.json`)}function Be(e,t){return u(e,_,`${t}.json`)}function ze(e,t){return u(e,N,`${t}.json`)}function Me(e,t){return H(ze(e,t))!==null}function Tt(e){if(e===void 0)return kt;if(!Number.isFinite(e)||e<=0)throw new Error("Watch refresh request ttlMs must be positive.");return Math.floor(e)}function xt(e){let t=e?.trim();return t?t.slice(0,512):void 0}function O(e){return typeof e=="string"&&/^[a-z0-9][a-z0-9-]{0,127}$/i.test(e)}function qt(e,t){return Date.parse(e.createdAt)-Date.parse(t.createdAt)||e.requestId.localeCompare(t.requestId)}function _t(e,t){return Date.parse(t)<Date.parse(e)?t:e}var he=5e3,Mt=6e3,Gt=1e3,z=10,$t=new Set(["health","review","capabilities","check-deps","config-validate","continue","doctor","init","install-skills","reindex","setup","setup-agent","status","suppress","uninstall","watch"]);function Jr(e){let t=e.classification;if(t.kind!=="live")return;let{state:r}=t;return r.watcher.state==="idle"&&r.lastError===void 0?r.indexGeneration:void 0}function jt(e,t=process.env){return t.SCIP_QUERY_SKIP_WATCH_SERVICE!=="1"&&!e.startsWith("__")&&!$t.has(e)}function Kr(e){let t=e.env??process.env;if(t.SCIP_QUERY_SKIP_WATCH_SERVICE==="1")return{kind:"skipped",reason:"environment"};if(!jt(e.commandName,t))return{kind:"skipped",reason:"excluded-command"};if(e.config.watch?.enabled!==!0)return{kind:"skipped",reason:"disabled"};if(e.config.watch.autoStart===!1)return{kind:"skipped",reason:"auto-start-disabled"};try{let r=Ht({projectRoot:e.projectRoot,cacheDir:e.cacheDir,cliVersion:e.cliVersion,gitContext:e.gitContext,runtime:e.runtime});return{kind:r.disposition,state:r.state}}catch(r){return{kind:"failed",message:r instanceof Error?r.message:String(r)}}}function Ye(e,t,r){let n=X(k(e));if(r&&X(r.projectRoot)===n)return{projectRoot:n,worktreeKind:"git",worktreeId:r.worktreeId,cliVersion:t};let i=Ce(n);if(i.kind==="error")throw new Error(`Could not establish Git worktree identity for ${n}: ${i.message}`);return i.kind==="non-git"?{projectRoot:n,worktreeKind:"non-git",cliVersion:t}:{projectRoot:n,worktreeKind:"git",worktreeId:i.identity.worktreeId,cliVersion:t}}function Qr(e){return V(e,Ye(e.projectRoot,e.cliVersion,e.gitContext))}function Nt(e,t,r,n){let i=e.serverPath??Lt(new URL("./watch-server.js",import.meta.url));r.spawnServer(i,t.projectRoot,e.cliVersion,e.watchOverrides??{});let o=rt(e,t,r,e.startupTimeoutMs??he);if(!o)throw new Error(`scip-query watch service did not become ready within ${e.startupTimeoutMs??he}ms.`);return B(n,r),{disposition:"started",state:o}}function Ft(e,t,r,n,i){if(e.kind==="replace")me(e.state,r,i),D(t.paths,e.state,i);else if(e.kind==="start"){if(t.lockIsLive){let o=rt(r,n,i,Math.min(r.startupTimeoutMs??1e3,1e3));if(o)return B(t.paths.activityPath,i),{disposition:"reused",state:o};throw new Error(`scip-query watch is already running for ${k(r.projectRoot)} (pid ${t.lock?.pid}; lock: ${t.paths.lockPath}) without compatible daemon state. Stop the foreground watcher before starting the service.`)}t.classification.kind==="stale"&&D(t.paths,t.classification.state,i)}else throw new Error(`Unexpected ensure action: ${e.kind}`)}function V(e,t){let r=e.runtime??J,n=g(e.cacheDir),i=q(n.statePath),o=ge(n.lockPath);return{identity:t,classification:Vt(i,t,r.now(),r.isProcessAlive),lock:o,lockIsLive:o!==null&&r.isProcessAlive(o.pid),paths:n}}function Ht(e){let t=e.runtime??J,r=Ye(e.projectRoot,e.cliVersion,e.gitContext),n=V(e,r),i=fe("ensure",n.classification);if(i.kind==="reuse")return B(n.paths.activityPath,t),{disposition:"reused",state:i.state};if(i.kind==="refuse-replace")throw new Error(`scip-query watch service pid ${i.state.pid} is still alive but its heartbeat is old. Refusing automatic replacement because civil-clock age alone cannot authorize a process signal.`);let o=Ft(i,n,e,r,t);if(o)return o;if(n=V(e,r),i=fe("ensure",n.classification),i.kind==="reuse")return B(n.paths.activityPath,t),{disposition:"reused",state:i.state};if(i.kind==="refuse-replace")throw new Error(`scip-query watch service pid ${i.state.pid} remains alive with an old heartbeat; automatic replacement is not authorized.`);return Nt(e,r,t,n.paths.activityPath)}function Xe(e){let t=e.runtime??J,r=g(e.cacheDir),n=q(r.statePath),i=n?ye(n,t)?{kind:"live",state:n}:{kind:"stale",state:n,reason:"dead-process"}:{kind:"stopped"},o=fe("stop",i);if(o.kind==="signal-stop")return me(o.state,e,t),D(r,o.state,t),{disposition:"stopped",pid:o.state.pid};if(o.kind==="clean-stale")return D(r,o.state,t),{disposition:"stopped",pid:o.state.pid};let a=ge(r.lockPath);return o.kind==="already-stopped"&&a?(ye(a,t)&&me(a,e,t),D(r,a,t),{disposition:"stopped",pid:a.pid}):{disposition:"already-stopped"}}function Yr(e,t,r={}){let{durability:n="durable",...i}=r;n==="durable"?$(e,t,i):b(e,t,i)}function Ze(e,t=Date.now()){b(e,{version:1,at:new Date(t).toISOString()})}function Xr(e,t,r=Date.now(),n={}){$e(g(Dt(e)).refreshRequestsPath,t,{...n,now:()=>new Date(r)}),Ze(e,r)}function Zr(e){try{let t=JSON.parse(f(e,"watch activity record"));return t.version!==1||!j(t.at)||t.refreshRequestedAt!==void 0&&!j(t.refreshRequestedAt)||t.refreshDetail!==void 0&&typeof t.refreshDetail!="string"?null:{atMs:Date.parse(t.at),...t.refreshRequestedAt===void 0?{}:{refreshRequestedAtMs:Date.parse(t.refreshRequestedAt)},...t.refreshDetail===void 0?{}:{refreshDetail:t.refreshDetail}}}catch{return null}}function en(e,t,r={}){let n=r.pid??process.pid,i=r.isProcessAlive??m,o=()=>{},a=r.readProcessIdentity??ee,s=r.now??(()=>new Date),c={...ne,wallNow:()=>s().getTime(),isProcessAlive:i,readProcessIdentity:a},d=nt(e,()=>ie(e,{kind:"watch",pid:n,processIdentity:a(n),detail:{projectRoot:k(t)},parseLegacy:U,runtime:c}));if(d.kind==="contended"){let p=et(d.observation);return{acquired:!1,lockPath:e,message:Ut(e,t,p),release:o}}return{acquired:!0,lockPath:e,message:"",release:()=>{d.lock.release()}}}function ge(e){return et(oe(e,{parseLegacy:U}))}var U=e=>{let t=tt(e);return t?{pid:t.pid,...t.processIdentity?{processIdentity:t.processIdentity}:{}}:null};function et(e){if(e.state==="valid"&&e.record?.kind==="watch"){let t=e.record.detail?.projectRoot;return typeof t!="string"?null:{version:1,pid:e.record.pid,...e.record.processIdentity?{processIdentity:e.record.processIdentity}:{},projectRoot:t,startedAt:e.record.startedAt}}return tt(e.parsed)}function tt(e){try{let t=Te(e),r=e;if(!t||Object.hasOwn(r,"protocol")||r.version!==1||typeof r.projectRoot!="string"||!j(r.startedAt))return null;let n=r.processIdentity===void 0?null:Pe(r.processIdentity);return Qt(r.processIdentity,n,t.pid)?null:{version:1,pid:t.pid,...n?{processIdentity:n}:{},projectRoot:r.projectRoot,startedAt:r.startedAt}}catch{return null}}function Vt(e,t,r,n){if(!e)return{kind:"stopped"};if(e.protocolVersion!==te)return{kind:"incompatible",state:e,reason:"protocol"};if(e.projectRoot!==t.projectRoot)return{kind:"incompatible",state:e,reason:"project"};let i=t.worktreeKind==="git"?t.worktreeId:void 0;if(e.worktreeId!==i)return{kind:"incompatible",state:e,reason:"worktree"};if(e.cliVersion!==t.cliVersion)return{kind:"incompatible",state:e,reason:"cli-version"};if(!n(e.pid))return{kind:"stale",state:e,reason:"dead-process"};let o=Date.parse(e.heartbeatAt);return r-o>re?{kind:"stale",state:e,reason:"old-heartbeat"}:{kind:"live",state:e}}function fe(e,t){switch(e){case"status":return{kind:"report",classification:t};case"ensure":return zt(t);case"stop":return Jt(t);default:return ve(e)}}function tn(e){return e.idleTimeoutMs===0||e.watcher.state!=="idle"?!1:e.nowMs-e.lastActivityAtMs>=e.idleTimeoutMs}function rt(e,t,r,n){let i=r.monotonicNow??C,o=i()+n;for(;i()<=o;){let a=V(e,t).classification;if(a.kind==="live")return a.state;r.sleep(z)}return null}function me(e,t,r){let{pid:n}=e;if(!r.isProcessAlive(n))return;Qe(e,r),r.signalProcess(n);let i=t.stopTimeoutMs??Mt,o=r.monotonicNow??C,a=o()+i;for(;o()<=a;){if(!r.isProcessAlive(n))return;r.sleep(z)}if(!r.forceSignalProcess)throw new Error(`scip-query watch service pid ${n} did not stop within ${i}ms and forced termination is unavailable.`);Qe(e,r),r.forceSignalProcess(n);let s=t.forceStopTimeoutMs??Gt;if(!Kt(e,r,o,s))throw new Error(`scip-query watch service pid ${n} remained alive ${s}ms after forced termination.`)}function nt(e,t){let r=C()+he;for(;;){let n=ie(`${e}.transition`,{kind:"watch-transition"});if(n.kind==="acquired")try{return t()}finally{n.lock.release()}if(C()>=r)throw new Error(`Timed out waiting for watch ownership transition: ${e}`);J.sleep(z)}}function Ke(e,t,r){return e.pid!==t.pid||k(e.projectRoot)!==k(t.projectRoot)?!1:!e.processIdentity||!t.processIdentity?!r.isProcessAlive(e.pid):!!e.processIdentity&&!!t.processIdentity&&x(e.processIdentity,t.processIdentity)}function D(e,t,r){nt(e.lockPath,()=>{let n=ge(e.lockPath),i=q(e.statePath);if(pe(e.lockPath)&&(!n||!Ke(n,t,r))||pe(e.statePath)&&(!i||!Ke(i,t,r))||ye(t,r)||(Je(e.statePath,{force:!0}),Je(e.activityPath,{force:!0}),!n))return;let o={...ne,wallNow:r.now,isProcessAlive:r.isProcessAlive,readProcessIdentity:r.readProcessIdentity},a=oe(e.lockPath,{parseLegacy:U,runtime:o});xe(e.lockPath,a,{parseLegacy:U,runtime:o})})}function ye(e,t){if(!t.isProcessAlive(e.pid))return!1;if(!e.processIdentity)return!0;let r=t.readProcessIdentity(e.pid);return r===null||x(e.processIdentity,r)}function Ut(e,t,r){return`error: scip-query watch is already running for ${k(t)}${r?` (pid ${r.pid}, started ${r.startedAt}; lock: ${e})`:` (lock: ${e})`}. Stop that watcher before starting another.`}function B(e,t){try{(t.recordActivity??Ze)(e,t.now())}catch(r){let n=Bt(r);if(n!=="EPERM"&&n!=="EACCES"&&n!=="EROFS")throw r}}function Bt(e){return e.code}var J={now:Date.now,monotonicNow:C,isProcessAlive:m,readProcessIdentity:ee,spawnServer(e,t,r,n){if(!pe(e))throw new Error(`Watch service helper was not found at ${e}. Run npm run build first.`);Ot(process.execPath,[e,t,r,JSON.stringify(n)],{detached:!0,stdio:"ignore",env:{...process.env,SCIP_QUERY_SKIP_WATCH_SERVICE:"1"}}).unref()},signalProcess(e){process.kill(e,"SIGTERM")},forceSignalProcess(e){process.kill(e,"SIGKILL")},sleep(e){let t=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(t,0,0,e)}};function Qe(e,t){if(!e.processIdentity)throw new Error(`Refusing to signal scip-query watch pid ${e.pid}: its ownership record has no process identity.`);let r=t.readProcessIdentity(e.pid);if(!r)throw new Error(`Refusing to signal scip-query watch pid ${e.pid}: its process identity is unavailable.`);if(!x(e.processIdentity,r))throw new Error(`Refusing to signal scip-query watch pid ${e.pid}: its process identity does not match the ownership record.`)}function ve(e){throw new Error(`Unhandled watch service value: ${JSON.stringify(e)}`)}function zt(e){switch(e.kind){case"stopped":return{kind:"start"};case"stale":return e.reason==="old-heartbeat"?{kind:"refuse-replace",state:e.state,reason:"old-heartbeat"}:{kind:"start"};case"live":return{kind:"reuse",state:e.state};case"incompatible":return{kind:"replace",state:e.state};default:return ve(e)}}function Jt(e){switch(e.kind){case"stopped":return{kind:"already-stopped"};case"stale":return e.reason==="old-heartbeat"?{kind:"signal-stop",state:e.state}:{kind:"clean-stale",state:e.state};case"live":case"incompatible":return{kind:"signal-stop",state:e.state};default:return ve(e)}}function Kt(e,t,r,n){let{pid:i}=e,o=r()+n;for(;r()<=o;){if(!t.isProcessAlive(i))return!0;let a=t.readProcessIdentity(i);if(e.processIdentity&&a&&!x(e.processIdentity,a))return!0;t.sleep(z)}return!1}function Qt(e,t,r){return e!==void 0&&(!t||t.pid!==r)}import{existsSync as K,lstatSync as L,readdirSync as ot,realpathSync as it,rmSync as E,statSync as st}from"fs";import{join as l,resolve as M,sep as at}from"path";var Yt=3600*1e3,Xt=2*1024*1024*1024,ct=300*1e3,Zt="gc-state.json",er="gc.lock";function tr(e){let t=e.leases.filter(s=>s.managed&&!s.live&&!s.busy),r=dt(e.leases,e.locks),n={};for(let s of e.generations)r.has(s.generationId)||(n[s.generationId]=s.unreferencedAt??e.nowMs);let i=e.generations.filter(s=>!r.has(s.generationId)).sort((s,c)=>n[s.generationId]-n[c.generationId]||s.generationId.localeCompare(c.generationId)),o=new Set;for(let s of i)e.nowMs-n[s.generationId]>=e.policy.generationTtlMs&&o.add(s.generationId);let a=e.generations.filter(s=>!o.has(s.generationId)).reduce((s,c)=>s+c.size,0);for(let s of i){if(a<=e.policy.budgetBytes)break;o.has(s.generationId)||(o.add(s.generationId),a-=s.size)}for(let s of o)delete n[s];return{deleteWorktrees:t,deleteGenerations:e.generations.filter(s=>o.has(s.generationId)),deleteLocks:e.locks.filter(s=>!s.live),deleteTemporaries:e.temporaries.filter(s=>!s.live),protectedGenerationIds:[...r].sort(),unreferencedSince:n}}function dt(e,t){let r=new Set(e.filter(n=>n.managed&&(n.live||n.busy)).flatMap(n=>[n.lease.baseGenerationId,n.lease.activeGenerationId]).filter(n=>n!==void 0));for(let n of t)n.live&&r.add(n.generationId);return r}function gn(e,t,r={}){if(!Ee())return{kind:"disabled"};let n=r.repositoryId===void 0?Y(e)?.repositoryId:r.repositoryId;if(!n)return{kind:"unavailable"};let i=l(w(),"repositories",n),o=(r.now??Date.now)(),a=K(i)?lt(e,i,n,t,o,r):{kind:"unavailable"};return ir(e,n,t,o,r),a}function lt(e,t,r,n,i,o){let a=l(t,"gc-state.json"),s=pt(a);if(!o.force&&s&&i-Date.parse(s.lastSweepAt)<ct)return{kind:"throttled",sweptAt:s.lastSweepAt};let c=qe(t,{now:()=>i});if(!c)return{kind:"busy"};try{let d=ut(e,t,r,s?.unreferencedSince??{}),p=tr({nowMs:i,...d,policy:{generationTtlMs:o.policy?.generationTtlMs??Yt,budgetBytes:o.policy?.budgetBytes??Xt}}),{deletedBytes:R,deletedWorktrees:A}=rr(p,t,n),y={kind:"swept",sweptAt:new Date(i).toISOString(),deletedWorktrees:A,deletedGenerations:p.deleteGenerations.length,deletedBytes:R,protectedGenerations:p.protectedGenerationIds.length},h={version:1,lastSweepAt:y.sweptAt,unreferencedSince:p.unreferencedSince,lastResult:y};return b(a,h,{spacing:2,trailingNewline:!0}),y}catch(d){return{kind:"failed",error:d instanceof Error?d.message:String(d)}}finally{c.release()}}function rr(e,t,r){let n=0,i=0;for(let o of e.deleteWorktrees)nr(o,r)&&(i+=1);for(let o of e.deleteLocks)E(o.path,{force:!0});for(let o of e.deleteTemporaries)E(o.path,{recursive:!0,force:!0});for(let o of e.deleteGenerations)E(o.path,{recursive:!0,force:!0}),n+=o.size;return Ae(l(t,"evidence.db")),{deletedBytes:n,deletedWorktrees:i}}function nr(e,t){if(!Ie(e.lease))return!1;if(!K(e.lease.localCacheDir))return E(e.leasePath,{force:!0}),!0;if(!lr(e.lease))return!1;let r=se(l(e.lease.localCacheDir,"cache-lifecycle.lock"));if(!r)return!1;try{if(Se(e.lease,!0))return!1;try{Xe({projectRoot:e.lease.projectRoot,cacheDir:e.lease.localCacheDir,cliVersion:t})}catch{return!1}return Se(e.lease,!0)?!1:(E(e.lease.localCacheDir,{recursive:!0,force:!0}),E(e.leasePath,{force:!0}),!0)}finally{r.release()}}function ir(e,t,r,n,i){let o=l(w(),"repositories");if(!K(o))return;let a=l(o,Zt),s=mr(a);if(!i.force&&s!==void 0&&n-s<ct)return;let c=se(l(o,er));if(c)try{for(let d of G(o))yr(o,d,t,e,r,n,i);b(a,{version:1,lastSweepAt:new Date(n).toISOString()},{spacing:2,trailingNewline:!0})}finally{c.release()}}function vn(e,t,r){let n=Oe(e,r.dbPath,t);if(n)return{state:"bypassed",reason:n,localCacheDir:r.cacheDir,generations:0,generationBytes:0,protectedGenerations:0,unreferencedGenerations:0,unreferencedBytes:0,temporaryGenerations:0,sharedEvidence:{exists:!1,bytes:0}};let i=Y(e);if(!i)return{state:"unavailable",reason:"Git worktree identity is unavailable",localCacheDir:r.cacheDir,generations:0,generationBytes:0,protectedGenerations:0,unreferencedGenerations:0,unreferencedBytes:0,temporaryGenerations:0,sharedEvidence:{exists:!1,bytes:0}};let o=l(w(),"repositories",i.repositoryId),a=we(l(o,"worktrees",`${i.worktreeId}.json`)),s=pt(l(o,"gc-state.json")),c=ut(e,o,i.repositoryId,s?.unreferencedSince??{}),d=dt(c.leases,c.locks),p=c.generations.filter(h=>!d.has(h.generationId)),R=c.generations.reduce((h,Q)=>h+Q.size,0),A=De(e,t),y=0;return A&&(y=or(A)),{state:"managed",repositoryId:i.repositoryId,worktreeId:i.worktreeId,localCacheDir:r.cacheDir,...a?{baseGenerationId:a.baseGenerationId,activeGenerationId:a.activeGenerationId,lastAction:a.lastAction,reason:a.lastReason,lastSeenAt:a.lastSeenAt}:{},generations:c.generations.length,generationBytes:R,protectedGenerations:c.generations.filter(h=>d.has(h.generationId)).length,unreferencedGenerations:p.length,unreferencedBytes:p.reduce((h,Q)=>h+Q.size,0),temporaryGenerations:c.temporaries.length,sharedEvidence:{path:A,exists:y>0,bytes:y},cleanup:s?.lastResult}}function or(e){return[e,`${e}-wal`,`${e}-shm`].reduce((t,r)=>{try{return t+st(r).size}catch{return t}},0)}function ut(e,t,r,n){let i=sr(e,t,r),o=ar(t),{generations:a,temporaries:s}=cr(t,n);return{leases:i,generations:a,locks:o,temporaries:s}}function sr(e,t,r){let n=new Set(be(e).map(o=>M(o.path))),i=[];for(let o of G(l(t,"worktrees"))){if(!o.endsWith(".json"))continue;let a=l(t,"worktrees",o),s=we(a);if(!s)continue;let c=M(s.projectRoot);i.push({leasePath:a,lease:s,managed:s.repositoryId===r&&Ie(s),live:n.has(c)||K(c),busy:Se(s)})}return i}function ar(e){let t=[];for(let r of G(l(e,"locks"))){let n=/^([a-f0-9]{64})\.lock$/.exec(r);if(!n)continue;let i=l(e,"locks",r),o=Re(i),a=o!==void 0&&m(o),s=n[1];t.push({generationId:s,path:i,live:a})}return t}function cr(e,t){let r=[],n=[];for(let i of G(l(e,"generations"))){let o=/^\.tmp-(\d+)-/.exec(i);if(o){dr(e,i,o[1],n);continue}if(!/^[a-f0-9]{64}$/.test(i))continue;let a=l(e,"generations",i),s;try{s=L(a)}catch{continue}!s.isDirectory()||s.isSymbolicLink()||r.push({generationId:i,path:a,size:ht(a),...t[i]===void 0?{}:{unreferencedAt:t[i]}})}return{generations:r,temporaries:n}}function dr(e,t,r,n){let i=l(e,"generations",t),o=Number(r);try{n.push({path:i,size:ht(i),live:Number.isSafeInteger(o)&&m(o)})}catch{}}function Ie(e){if(e.ownershipChecksum!==Le(e)||P(e.localCacheDir)!==P(ke(e.projectRoot)))return!1;let t=P(l(w(),"projects"));return P(e.localCacheDir).startsWith(`${t}${at}`)}function lr(e){if(!Ie(e))return!1;let t=M(w()),r=M(l(t,"projects")),n=M(e.localCacheDir);try{let i=L(t),o=L(r),a=L(n);if(!i.isDirectory()||i.isSymbolicLink()||!o.isDirectory()||o.isSymbolicLink()||!a.isDirectory()||a.isSymbolicLink())return!1;let s=it(r);return it(n).startsWith(`${s}${at}`)}catch{return!1}}function ur(e){for(let t of G(l(e,"worktrees"))){if(!t.endsWith(".json"))continue;let r=we(l(e,"worktrees",t));if(r)return r.projectRoot}}function Se(e,t=!1){for(let n of t?["index.lock"]:["index.lock","cache-lifecycle.lock"]){let i=Re(l(e.localCacheDir,n));if(i!==void 0&&m(i))return!0}let r=Re(g(e.localCacheDir).lockPath);return r!==void 0&&m(r)}function pr(e){return e.version===1&&typeof e.repositoryId=="string"&&typeof e.worktreeId=="string"&&typeof e.projectRoot=="string"&&typeof e.localCacheDir=="string"&&typeof e.ownershipChecksum=="string"&&/^[a-f0-9]{64}$/.test(e.ownershipChecksum)}function hr(e){return(e.treeOid===void 0||typeof e.treeOid=="string")&&(e.baseGenerationId===void 0||typeof e.baseGenerationId=="string")&&(e.activeGenerationId===void 0||typeof e.activeGenerationId=="string")}function fr(e){return typeof e.lastAction=="string"&&(e.lastReason===void 0||typeof e.lastReason=="string")&&typeof e.lastSeenAt=="string"}function we(e){try{let t=JSON.parse(f(e,"worktree cache lease"));return!pr(t)||!hr(t)||!fr(t)?null:t}catch{return null}}function Re(e){try{let t=JSON.parse(f(e,"watch lock record"));return typeof t.pid=="number"&&Number.isSafeInteger(t.pid)&&t.pid>0?t.pid:void 0}catch{return}}function pt(e){try{let t=JSON.parse(f(e,"repository cache GC state"));return t.version!==1||typeof t.lastSweepAt!="string"||!Number.isFinite(Date.parse(t.lastSweepAt))||!t.unreferencedSince||typeof t.unreferencedSince!="object"||!t.lastResult?null:t}catch{return null}}function mr(e){try{let t=JSON.parse(f(e,"global repository cache GC state"));if(t.version!==1||typeof t.lastSweepAt!="string")return;let r=Date.parse(t.lastSweepAt);return Number.isFinite(r)?r:void 0}catch{return}}function G(e){try{return ot(e)}catch{return[]}}function ht(e){let t=0,r=[e];for(;r.length>0;){let n=r.pop();for(let i of ot(n,{withFileTypes:!0})){let o=l(n,i.name);i.isDirectory()?r.push(o):i.isFile()&&(t+=st(o).size)}}return t}function yr(e,t,r,n,i,o,a){if(t===r||!/^[a-f0-9]{24}$/.test(t))return;let s=l(e,t),c;try{c=L(s)}catch{return}if(!c.isDirectory()||c.isSymbolicLink())return;let d=ur(s)??n;lt(d,s,t,i,o,a)}var ft=[{question:"Who can call or reach this?",family:"execution",direction:"incoming"},{question:"What can this call or reach?",family:"execution",direction:"outgoing"},{question:"Where can this value come from?",family:"dataflow",direction:"incoming"},{question:"Where can this value go?",family:"dataflow",direction:"outgoing"},{question:"Which producer and consumer rendezvous?",family:"runtime",direction:"both"},{question:"What resource is observed or changed?",family:"state",direction:"both"},{question:"What occurs before or after this?",family:"temporal",direction:"both"},{question:"What interface constrains this?",family:"contract",direction:"both"},{question:"Are these observations the same entity?",family:"identity",direction:"both"},{question:"What contains or owns this?",family:"ownership",direction:"both"},{question:"What does this statically rely on?",family:"dependencies",direction:"outgoing"}],mt={execution:{establishes:"Static may-call reachability between resolved program constructs.",nonClaims:["A may-call edge does not prove that a runtime invocation occurred."]},runtime:{establishes:"A source-grounded handoff between producer and consumer participants through a runtime mechanism.",nonClaims:["An unresolved or candidate join does not prove a runtime handoff."]},dataflow:{establishes:"A value, definition, argument, parameter, return, or statically resolved value may flow to another construct.",nonClaims:["Current partial providers do not establish general interprocedural definition-use coverage."]},state:{establishes:"A construct reads, writes, creates, deletes, or otherwise changes an identified state resource.",nonClaims:["A state edge does not prove transactionality, durability, or exclusive ownership unless qualified."]},temporal:{establishes:"One observed construct is locally ordered before or after another under the reported source evidence.",nonClaims:["Source order does not imply cross-process happens-before or durability."]},contract:{establishes:"A program construct implements, constrains, or is typed by an identified contract.",nonClaims:["Contract identity does not prove runtime invocation or conformance outside reported checks."]},identity:{establishes:"Two observations refer to the same compiler-owned or source-owned program entity.",nonClaims:["Shared identity does not establish execution or value transfer."]},ownership:{establishes:"A source construct, symbol, runtime observation, or state resource is contained or owned by another program entity.",nonClaims:["Structural ownership does not establish lifetime, singleton scope, or runtime execution unless qualified."]},dependencies:{establishes:"A file, module, or symbol statically relies on another indexed entity.",nonClaims:["A dependency edge does not establish that the depended-on code executes."]}};function yt(e){return ae.flatMap(t=>t.relations.filter(r=>r.family===e).map(r=>({...r,providerId:t.id,providerLabel:t.label})))}function gt(e){return[...new Set(ae.filter(t=>t.relations.some(r=>r.family===e)).map(t=>t.label))]}var wn=_e.map(e=>({family:e,...mt[e],providers:gt(e),relations:yt(e)}));function vt(e){return{family:e,...mt[e],providers:gt(e),relations:yt(e)}}function Wn(){return ft.map(e=>{let t=vt(e.family);return{...e,establishes:t.establishes,evidenceStrengths:St(t.relations.flatMap(r=>r.evidenceStrengths)),supportCeilings:St(t.relations.map(r=>r.supportCeiling)),nonClaim:t.nonClaims.join(" ")}})}function St(e){return[...new Set(e)]}export{wn as a,$e as b,br as c,Wr as d,At as e,kr as f,Er as g,Ar as h,Jr as i,jt as j,Kr as k,Ye as l,Qr as m,Ht as n,Xe as o,Yr as p,Xr as q,Zr as r,en as s,ge as t,tn as u,ct as v,gn as w,vn as x,Wn as y};
|
|
3
|
+
//# sourceMappingURL=chunk-L7GFM3NP.js.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import{a as b}from"./chunk-AOSIYPTA.js";import{g as N}from"./chunk-AGWFSTXC.js";import{b as S}from"./chunk-FMRN2TRL.js";import{d as u,e as I,k as E}from"./chunk-5D2LVK7O.js";import{s as h}from"./chunk-7WTPQ4NX.js";import{A as g,a as x}from"./chunk-FVULPZDF.js";import{a as f}from"./chunk-A2IIGFMJ.js";import{c as p}from"./chunk-5TNQJUR2.js";import{ts as a}from"@ts-morph/common";function Q(e,t,o={}){return C(e,t,o)?.map(r=>({symbol:r.symbol,shortName:r.shortName,fromFile:r.fromFile,evidence:r.evidence}))??[]}function V(e,t){let o=S(e,t);if(o.candidates.length>0)throw new Error(`Ambiguous symbol: ${t}. Use an exact symbol.`);let r=o.match,s=r?D(e,r.symbol):[];if(!r&&!d(t))return[];let n=k(e,t,r);return d(t)&&n.length>0?n:v([...s,...n])}function ee(e,t,o={}){let r=b(e,t);if(!r)return[];let s=F(e,r),n=o.semantic===!1?null:y(e,r);return(n?_(n,s):s).filter(m=>!m.used).map(m=>({symbol:m.symbol,shortName:m.shortName,importedIn:m.importer}))}function _(e,t){let o=new Map;for(let s of t){let n=o.get(s.shortName);n?n.push(s):o.set(s.shortName,[s])}let r=e.map(s=>{let n=o.get(s.shortName),i=n?.shift();return n?.length===0&&o.delete(s.shortName),i?{...s,used:s.used||i.used}:s});return r.push(...[...o.values()].flat()),r}function D(e,t){return e.all(`SELECT DISTINCT gs.symbol, d.relative_path AS importer
|
|
2
|
+
FROM mentions m
|
|
3
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
4
|
+
JOIN documents d ON c.document_id = d.id
|
|
5
|
+
JOIN global_symbols gs ON m.symbol_id = gs.id
|
|
6
|
+
WHERE gs.symbol = ?
|
|
7
|
+
AND m.role = 2
|
|
8
|
+
ORDER BY d.relative_path`,t).filter(r=>!e.isIgnored(r.importer)).map(r=>({symbol:r.symbol,shortName:u(r.symbol),fromFile:r.importer,evidence:"indexed-import"}))}function k(e,t,o){let r=o?.relativePath??null,s=o?I(o.symbol):t.replace(/\(\)$/,""),n=o?E(o.symbol):!1,i=r?T(e,r,s):new Set([s]),m=new Set;for(let c of x(e,{includeIgnored:!1}))for(let O of h(e,c))P(O,c,{targetFile:r,targetLeaf:s,exportNames:i,targetIsModule:n,targetPattern:t})&&m.add(c);let l=d(t)?t.trim():null;return[...m].sort().map(c=>({symbol:l??o?.symbol??s,shortName:l??(o?u(o.symbol):s),fromFile:c,evidence:"source-import-candidate"}))}function v(e){let t=new Set,o=[];for(let r of e){let s=`${r.symbol}|${r.fromFile}`;t.has(s)||(t.add(s),o.push(r))}return o.sort((r,s)=>r.fromFile.localeCompare(s.fromFile)||r.shortName.localeCompare(s.shortName))}function P(e,t,o){return!e.sourcePath||o.targetFile&&p(e.sourcePath)!==p(o.targetFile)?!1:e.kind==="side-effect"?!!(o.targetFile&&o.targetIsModule):o.targetFile&&B(t)?!0:M(e,o)}function M(e,t){return e.kind==="namespace"&&L(e,t.targetPattern)||t.targetIsModule?!0:e.kind==="default"?t.exportNames.has("default"):e.kind==="named"&&t.exportNames.has(e.importedName)?!0:e.kind==="namespace"&&e.usedMembers.some(o=>t.exportNames.has(o))}function T(e,t,o){let r=new Set([o]);if(!/\.[cm]?[jt]sx?$/.test(t))return r;let s=f(e,t),n=a.createSourceFile(t,s,a.ScriptTarget.Latest,!0);for(let i of n.statements)if(A(i)===o&&r.add("default"),a.isExportDeclaration(i))for(let m of w(i))(m.propertyName??m.name).text===o&&r.add(m.name.text);return r}function A(e){if(a.isExportAssignment(e))return!e.isExportEquals&&a.isIdentifier(e.expression)?e.expression.text:void 0;if(a.isFunctionDeclaration(e)||a.isClassDeclaration(e))return e.modifiers?.some(t=>t.kind===a.SyntaxKind.DefaultKeyword)?e.name?.text:void 0}function w(e){return e.moduleSpecifier||!e.exportClause||!a.isNamedExports(e.exportClause)?[]:e.exportClause.elements}function L(e,t){let o=t.trim().replace(/\(\)$/,"");return d(o)?e.importedName===o||e.localName===o:!1}function d(e){let t=e.trim().replace(/\(\)$/,"");return t.includes(".")&&!t.includes("/")&&!t.includes(":")}function C(e,t,o={}){let r=b(e,t);if(!r)return null;let s=$(e,r,o)??[],n=F(e,r),i=o.semantic===!1?null:y(e,r),m=i?_(i,n):n;return[...s,...m.filter(l=>!s.some(c=>c.fromFile===l.fromFile&&I(c.symbol)===l.importedName))]}function $(e,t,o){let s=e.all(`SELECT DISTINCT
|
|
9
|
+
gs.symbol,
|
|
10
|
+
def_d.relative_path AS from_file,
|
|
11
|
+
imp_d.relative_path AS importer,
|
|
12
|
+
EXISTS (
|
|
13
|
+
SELECT 1
|
|
14
|
+
FROM mentions ref_m
|
|
15
|
+
JOIN chunks ref_c ON ref_m.chunk_id = ref_c.id
|
|
16
|
+
WHERE ref_m.symbol_id = gs.id
|
|
17
|
+
AND ref_m.role != 1
|
|
18
|
+
AND ref_c.document_id = imp_d.id
|
|
19
|
+
) AS used
|
|
20
|
+
FROM mentions m
|
|
21
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
22
|
+
JOIN documents imp_d ON c.document_id = imp_d.id
|
|
23
|
+
JOIN global_symbols gs ON m.symbol_id = gs.id
|
|
24
|
+
LEFT JOIN (
|
|
25
|
+
SELECT m2.symbol_id, c2.document_id
|
|
26
|
+
FROM mentions m2
|
|
27
|
+
JOIN chunks c2 ON m2.chunk_id = c2.id
|
|
28
|
+
WHERE m2.role = 1
|
|
29
|
+
GROUP BY m2.symbol_id
|
|
30
|
+
) sym_def ON sym_def.symbol_id = gs.id
|
|
31
|
+
LEFT JOIN documents def_d ON sym_def.document_id = def_d.id
|
|
32
|
+
WHERE imp_d.relative_path = ?
|
|
33
|
+
AND m.role = 2
|
|
34
|
+
ORDER BY def_d.relative_path, gs.symbol`,t).filter(n=>!e.isIgnored(n.importer));if(s.length>0){let n=o.semantic===!1?[]:N(e,t);return s.map(i=>({symbol:i.symbol,shortName:u(i.symbol),fromFile:i.from_file??"(external)",importer:i.importer,used:i.used!==0||n.some(m=>m.isUsed&&m.sourcePath===i.from_file),evidence:"indexed-import"}))}return null}function y(e,t){let o=N(e,t);return o.length>0?o.map(r=>{let s=R(r.importedName,r.localName,r.kind);return{symbol:s,shortName:s,fromFile:r.sourcePath??"(external)",importer:t,used:r.kind==="side-effect"?!0:r.isUsed,importedName:r.importedName,evidence:"semantic-import"}}):null}function F(e,t){let o=J(t,f(e,t));return h(e,t).map(r=>{let s=R(r.importedName,r.localName,r.kind),n=r.kind==="side-effect"||U(t,r)||o.has(r.localName??r.importedName)?!0:r.used;return{symbol:s,shortName:s,fromFile:r.sourcePath??"(external)",importer:t,used:n,importedName:r.importedName,evidence:"source-import-candidate"}})}function J(e,t){let o=new Set;if(g(e)!=="python")return o;let r=/(?:^|\n)\s*__all__\s*(?:\+?=)\s*[[(]([\s\S]*?)[\])]/g;for(let s of t.matchAll(r)){let n=s[1]??"";for(let i of n.matchAll(/(['"])([A-Za-z_]\w*)\1/g))o.add(i[2])}return o}function U(e,t){if(g(e)!=="rust"||t.used||t.kind==="side-effect")return!1;let o=t.localName??t.importedName;return o==="_"||/^[A-Z]/.test(o)}function R(e,t,o){return o==="namespace"&&e==="*"&&t?`* as ${t}`:o==="default"&&t?`default as ${t}`:o==="side-effect"?"(side effect import)":t&&t!==e?`${e} as ${t}`:e}function B(e){return/\.(?:c|h|cc|cpp|cxx|hpp|hh|hxx)$/i.test(e)}export{Q as a,V as b,ee as c};
|
|
35
|
+
//# sourceMappingURL=chunk-LMO6PK3V.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as p}from"./chunk-FMRN2TRL.js";import{d as m,e as y,h as L,n as g,p as h,x as a}from"./chunk-5D2LVK7O.js";import{g as u}from"./chunk-7WTPQ4NX.js";import{A as c}from"./chunk-FVULPZDF.js";function $(n,o){let r=p(n,o);if(!r)return[];let s=a(n,r.relativePath),t=new Set(s.map(e=>e.symbol)),l=h(n,r.relativePath),i=a(n,r.relativePath,{includeClassMemberFallbacks:!0}).filter(e=>e.symbol!==r.symbol).filter(e=>g(r.symbol,e.symbol)).map(e=>({symbol:e.symbol,shortName:m(e.symbol),startLine:t.has(e.symbol)?e.startLine:l.get(e.symbol)?.start_line??e.startLine,endLine:t.has(e.symbol)?e.endLine:l.get(e.symbol)?.end_line??e.endLine,kind:L(e.symbol)??"unknown"})).sort((e,b)=>e.startLine-b.startLine||e.endLine-b.endLine);return c(r.relativePath)!=="clojure"?i:M(i,f(n,r))}function f(n,o){let r=y(o.symbol);if(!r)return[];let s=m(o.symbol);return(u(n,o.relativePath)?.clojureMembers??[]).filter(t=>t.ownerName===r).map(t=>({symbol:`${o.symbol}${t.memberName}().`,shortName:`${s}:${t.memberName}()`,startLine:t.startLine,endLine:t.endLine,kind:t.memberKind}))}function M(n,o){let r=new Map;for(let s of[...n,...o])r.set(`${s.shortName}:${s.startLine}:${s.endLine}`,s);return[...r.values()].sort((s,t)=>s.startLine-t.startLine||s.endLine-t.endLine)}export{$ as a};
|
|
2
|
+
//# sourceMappingURL=chunk-LN4YXJJU.js.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import{O as _,Q as C,f as x,g as A}from"./chunk-J5FJMODQ.js";import{a as M}from"./chunk-7Y5T6XDP.js";import{c as b,e as F}from"./chunk-X6RMKHJQ.js";import{a as y}from"./chunk-QOIXNWQR.js";import{c as O}from"./chunk-GZKFETP5.js";import{e as p}from"./chunk-HGFDYOVB.js";var P=x({kind:"file-dependency-graph",invalidation:A("file-dependency-graph"),serialize:e=>JSON.stringify(e),deserialize:W}),T=O("file-dep-graph",{clearGroups:["whole-project"]});function ae(e,n,r){if(r.length===0)return[];let t=new Set(r),o=I(e),i=new Set;return n==="forward"?$(o,t,i):j(o,t,i),[...i].sort()}function $(e,n,r){for(let t of n)for(let o of e.get(t)??[])n.has(o)||r.add(o)}function j(e,n,r){for(let[t,o]of e)if(!n.has(t))for(let i of n)o.has(i)&&r.add(t)}function I(e,n,r={}){let t=r.scipEdges??"all-references",o=r.sourceEdges??"imports-and-reexports",i=m(n,t,o);return T.get(e,i,()=>{let s=new Set(y(e,{includeIgnored:!1})),c=F(e),d=0,u=0,l=null,D=!1,g=0,G=0,N=null;return p("file-dep-graph.product",()=>{if(c){let a=P.read(e,i,c);if(a){D=!0,N=a.construction;let E=k(a);return d=a.sourceFileCount,u=a.sourceEdgeCount,g=a.scipEdgeCount,G=E.size,l=a.sourceDependencyFingerprint,E}}let S=o==="none"?{files:[],edges:[],fingerprint:b("no-source-dependency-fallback")}:p("file-dep-graph.source-imports",()=>{let a=K(e,s,n,o);return d=a.files.length,u=a.edges.length,l=a.fingerprint,a},()=>({scope:n??null,sourceEdges:o,files:d,edges:u})),f=new Map,R=(a,E)=>h(e,f,s,a,E);p("file-dep-graph.scip-edges",()=>{for(let a of q(e,n,t))g=(g??0)+1,R(a.from_file,a.to_file)},()=>({scope:n??null,edges:g}));for(let a of S.edges)R(a.fromFile,a.toFile);return G=f.size,c&&(N="full",P.write(e,i,c,{version:2,construction:"full",sourceDependencyFingerprint:S.fingerprint,sourceFileCount:S.files.length,sourceEdgeCount:S.edges.length,scipEdgeCount:g,edgeCount:J(f),graph:v(f)})),f},()=>({scope:n??null,available:c!==null,hit:D,construction:N,files:d,sourceEdges:u,sourceEdgeMode:o,scipEdges:g,graphFiles:G,sourceDependencyFingerprint:l}))})}function de(e){return z(e,"none")}function le(e,n="imports-and-reexports"){let r=m(void 0,"all-references",n),t=F(e);if(!t)return null;let o=P.read(e,r,t);return o?{cacheKey:r,sourceEdges:n,graph:k(o)}:null}function z(e,n){let r=m(void 0,"all-references",n),t=I(e,void 0,{sourceEdges:n});return{cacheKey:r,sourceEdges:n,graph:t}}function pe(e,n,r,t){let o=n.sourceEdges??"imports-only",i=F(e);if(!i)return!1;let s=t??H(e,n,r);if(!s)return!1;let c=new Set(y(e,{includeIgnored:!1})),d=m(void 0,"all-references",o);return P.write(e,d,i,{version:2,construction:"carried",sourceDependencyFingerprint:null,sourceFileCount:c.size,sourceEdgeCount:null,scipEdgeCount:null,edgeCount:J(s),graph:v(s)}),!0}function H(e,n,r,t=[]){let o=n.sourceEdges??"imports-only",i=m(void 0,"all-references",o);if(n.cacheKey!==i)return null;let s=p("file-dep-graph.carry.indexed-files",()=>new Set(y(e,{includeIgnored:!1}))),c=new Set(r),d=new Map;p("file-dep-graph.carry.reuse",()=>{if(t.length===0)for(let[l,D]of n.graph)c.has(l)||d.set(l,D);else Z(e,d,s,n.graph,c)});let u=p("file-dep-graph.carry.scip-edges",()=>Q(e,c,"all-references"));for(let l of u)h(e,d,s,l.from_file,l.to_file);return p("file-dep-graph.carry.source-edges",()=>{for(let l of c)s.has(l)&&X(e,d,s,l,o)}),d}async function ue(e,n={}){let r=y(e,{includeIgnored:!1}),t=Math.max(1,Math.floor(n.batchSize??64)),o=n.collectGarbage??M,i=0;for(let s=0;s<r.length;s+=t){for(let c of r.slice(s,s+t))C(e,c),_(e,c),i+=1;n.onBatch?.({files:i,total:r.length}),o(),await n.yieldToEventLoop?.()}return{files:i}}function K(e,n,r,t){let o=[],i=[];for(let s of n)r&&!s.includes(r)||(o.push(s),ee(e,s,t,i));return{files:o,edges:i,fingerprint:L(o,i)}}function L(e,n){let r=n.map(t=>`${t.fromFile}\0${t.toFile}`).sort();return b(JSON.stringify({files:e,edges:r}))}function m(e,n,r){return`edge-mode-v4:${n}:${r}:${e??"<all>"}`}function v(e){return[...e].map(([n,r])=>[n,[...r].sort()]).sort(([n],[r])=>n.localeCompare(r))}function k(e){return new Map(e.graph.map(([n,r])=>[n,new Set(r)]))}function W(e){let n=JSON.parse(e);return B(n)?n:null}function B(e){return U(e)?Array.isArray(e.graph)&&e.graph.every(V):!1}function U(e){if(!e||typeof e!="object")return!1;let n=e;return n.version===2&&(n.construction==="full"||n.construction==="carried")&&Y(n.sourceDependencyFingerprint)&&typeof n.sourceFileCount=="number"&&w(n.sourceEdgeCount)&&w(n.scipEdgeCount)&&typeof n.edgeCount=="number"}function Y(e){return e===null||typeof e=="string"}function w(e){return e===null||typeof e=="number"}function J(e){let n=0;for(let r of e.values())n+=r.size;return n}function V(e){return Array.isArray(e)&&e.length===2&&typeof e[0]=="string"&&Array.isArray(e[1])&&e[1].every(n=>typeof n=="string")}function q(e,n,r){let t=n?"AND d1.relative_path LIKE ?":"",o=n?[`%${n}%`]:[],i=r==="imports-only"?"AND m.role = 2":"AND m.role != 1";return e.all(`SELECT DISTINCT
|
|
2
|
+
d1.relative_path AS from_file,
|
|
3
|
+
d2.relative_path AS to_file
|
|
4
|
+
FROM mentions m
|
|
5
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
6
|
+
JOIN documents d1 ON c.document_id = d1.id
|
|
7
|
+
JOIN global_symbols gs ON m.symbol_id = gs.id
|
|
8
|
+
JOIN (
|
|
9
|
+
SELECT m2.symbol_id, c2.document_id
|
|
10
|
+
FROM mentions m2
|
|
11
|
+
JOIN chunks c2 ON m2.chunk_id = c2.id
|
|
12
|
+
WHERE m2.role = 1
|
|
13
|
+
GROUP BY m2.symbol_id
|
|
14
|
+
) sym_def ON sym_def.symbol_id = gs.id
|
|
15
|
+
JOIN documents d2 ON sym_def.document_id = d2.id
|
|
16
|
+
WHERE d1.id != d2.id
|
|
17
|
+
${i}
|
|
18
|
+
${e.pathExclusionsFor("d1","d2")}
|
|
19
|
+
${t}`,...o)}function Q(e,n,r){let t=[...n].sort();if(t.length===0)return[];let o=r==="imports-only"?"AND m.role = 2":"AND m.role != 1",i=[];for(let s=0;s<t.length;s+=500){let c=t.slice(s,s+500),d=c.map(()=>"?").join(", ");i.push(...e.all(`SELECT DISTINCT
|
|
20
|
+
d1.relative_path AS from_file,
|
|
21
|
+
d2.relative_path AS to_file
|
|
22
|
+
FROM documents d1
|
|
23
|
+
CROSS JOIN chunks c
|
|
24
|
+
CROSS JOIN mentions m
|
|
25
|
+
CROSS JOIN global_symbols gs
|
|
26
|
+
CROSS JOIN chunks c2
|
|
27
|
+
CROSS JOIN documents d2
|
|
28
|
+
WHERE d1.relative_path IN (${d})
|
|
29
|
+
AND c.document_id = d1.id
|
|
30
|
+
AND m.chunk_id = c.id
|
|
31
|
+
AND gs.id = m.symbol_id
|
|
32
|
+
AND c2.id = (
|
|
33
|
+
SELECT m2.chunk_id
|
|
34
|
+
FROM mentions m2
|
|
35
|
+
WHERE m2.symbol_id = gs.id AND m2.role = 1
|
|
36
|
+
ORDER BY m2.chunk_id
|
|
37
|
+
LIMIT 1
|
|
38
|
+
)
|
|
39
|
+
AND d2.id = c2.document_id
|
|
40
|
+
AND d1.id != d2.id
|
|
41
|
+
${o}
|
|
42
|
+
${e.pathExclusionsFor("d1","d2")}`,...c))}return i}function h(e,n,r,t,o){if(t===o||e.isIgnored(t)||e.isIgnored(o)||!r.has(o))return;let i=n.get(t);i||(i=new Set,n.set(t,i)),i.add(o)}function X(e,n,r,t,o){if(o!=="none")for(let i of C(e,t))i.sourcePath&&h(e,n,r,t,i.sourcePath);if(o==="imports-and-reexports")for(let i of _(e,t))i.sourcePath&&h(e,n,r,t,i.sourcePath)}function Z(e,n,r,t,o){for(let[i,s]of t)if(!(o.has(i)||!r.has(i)))for(let c of s)h(e,n,r,i,c)}function ee(e,n,r,t){for(let o of C(e,n))o.sourcePath&&t.push({fromFile:n,toFile:o.sourcePath});if(r==="imports-and-reexports")for(let o of _(e,n))o.sourcePath&&t.push({fromFile:n,toFile:o.sourcePath})}export{ae as a,I as b,de as c,le as d,pe as e,H as f,ue as g};
|
|
43
|
+
//# sourceMappingURL=chunk-LOVIZBJ4.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import{a as O}from"./chunk-QOKYJ33H.js";import{a as A,b as _}from"./chunk-6LSEIIF7.js";import{d as j,i as k}from"./chunk-AGWFSTXC.js";import{d as T,i as R,k as N}from"./chunk-5D2LVK7O.js";import{O as E}from"./chunk-FVULPZDF.js";import{K as y,f as P,qa as M}from"./chunk-5TNQJUR2.js";import{execFileSync as b}from"child_process";import{existsSync as K}from"fs";import{basename as $}from"path";var X="Unable to compute git diff.",ee={semanticConsumers:k,sourceFallbackConsumers:A,semanticReadiness:j},L={resolveCommit:y,readBatch({projectRoot:e,resolvedBase:i,relativePaths:n}){let t=n.map(s=>`${i}:./${s}
|
|
2
|
+
`).join("");return b("git",["cat-file","--batch"],{cwd:e,input:t,maxBuffer:256*1024*1024,timeout:1e4,stdio:["pipe","pipe","ignore"]})}};function Ve(e,i={}){let n=i.plan??te(e,i);return n.note?se(n.note,n.changedFileLines):n.changedFiles.length===0?re(n.changedFileLines):ie(n.changedFiles,[ne(e,n.changedFiles,n.changedFiles,n.changedRanges)],n.changedFileLines.filter(t=>!n.changedFiles.includes(t)))}function te(e,i={}){let{base:n="HEAD"}=i;try{let t=y(e.config.projectRoot,n),s=ae(e.config.projectRoot,t),r=s.changedFileLines,a=me(e,r),o=ge(e,s.changedRanges);return{changedFileLines:r,changedFiles:a,changedRanges:o,renamedFiles:de(e.config.projectRoot,t,a,s),note:r.length===0?"No changed files found.":void 0}}catch{return{changedFileLines:[],changedFiles:[],changedRanges:[],renamedFiles:[],note:X}}}function ne(e,i,n,t=[],s={}){let r=s.evidenceRuntime??ee,a=new _(e),o=new Set(n),c=O(t),u=[],d=new Map,l=i.flatMap(m=>a.definitionsForFile(m)).filter(Ee),f=l.filter(m=>Re(m,c)),p=Se(e,l,f,c),g=Le([...f,...p.definitions]).sort((m,h)=>m.relativePath.localeCompare(h.relativePath)||m.startLine-h.startLine),V=g.map(m=>m.symbolId),Q=Pe(e,V),x=g.length>0?r.semanticReadiness?.(e)??{ready:!0}:{ready:!0},w=x.ready?G("semantic-consumers",g.length,()=>r.semanticConsumers(e,g)):{values:new Map,status:{tier:"semantic-consumers",state:"failed",attemptedSymbols:g.length,reason:x.reason}},Y=w.values,B=G("source-fallback-consumers",g.length,()=>r.sourceFallbackConsumers(e,g)),Z=B.values;for(let m of g)xe(e,m,o,u,d,Y.get(m.symbolId)??new Set,Z.get(m.symbolId)??new Set,Q.get(m.symbolId)??new Set);return{changedSymbols:u,consumerEntries:[...d.entries()].map(([m,h])=>({file:m,symbols:[...h].sort()})),attributionNotes:p.notes,evidenceTiers:[w.status,B.status]}}function ie(e,i,n=[]){let t=new Map,s=i.flatMap(c=>c.changedSymbols),r=i.flatMap(c=>c.attributionNotes??[]),a=we(i);for(let c of i)for(let u of c.consumerEntries){let d=t.get(u.file);d||(d=new Set,t.set(u.file,d));for(let l of u.symbols)d.add(l)}let o=Me(t);return{changedFiles:[...e],unindexedChangedFiles:[...n],changedSymbols:s,affectedConsumers:o,attributionNotes:r,evidenceTiers:a,summary:{totalChangedFiles:e.length,totalChangedSymbols:s.length,totalAffectedFiles:o.length,...n.length?{note:`${n.length} changed path(s) were omitted from symbol analysis because they are absent or excluded from this index. Reindex supported source or use review for current-source analysis.`}:{}}}}function se(e,i=[]){return{changedFiles:i,changedSymbols:[],affectedConsumers:[],attributionNotes:[],evidenceTiers:J(),summary:{totalChangedFiles:i.length,totalChangedSymbols:0,totalAffectedFiles:0,note:e}}}function re(e){return{changedFiles:e,unindexedChangedFiles:e,changedSymbols:[],affectedConsumers:[],attributionNotes:[],evidenceTiers:J(),summary:{totalChangedFiles:e.length,totalChangedSymbols:0,totalAffectedFiles:0,note:"Changed files are not present in the current SCIP index."}}}function ae(e,i){let n=b("git",["diff","--relative","-z","--name-status","--find-renames",i,"--"],{encoding:"utf-8",cwd:e,timeout:3e4,maxBuffer:67108864}),t=b("git",["ls-files","-z","--others","--exclude-standard"],{encoding:"utf-8",cwd:e,timeout:3e4,maxBuffer:64*1024*1024}),s=b("git",["diff","--relative","--unified=0",i,"--"],{encoding:"utf-8",cwd:e,timeout:3e4,maxBuffer:64*1024*1024}),r=ue(n);return{changedFileLines:[...new Set([...r.changedFiles,...t.split("\0").filter(Boolean)])],changedRanges:pe(s),renamedFiles:r.renamedFiles,deletedFiles:r.deletedFiles}}function oe(e,i,n){let t=typeof e=="string"?{projectRoot:e,base:i,relativePath:n}:e;if(typeof t.projectRoot!="string"||typeof t.base!="string"||typeof t.relativePath!="string")throw new TypeError("fileContentAtBase requires projectRoot, base, and relativePath.");let s={projectRoot:t.projectRoot,base:t.base,relativePath:t.relativePath},{relativePath:r}=s,a=W(s);if(a.state==="unavailable")throw new Error(`Base content unavailable for ${r}: ${a.reason}`);return a.state==="present"?a.content:null}function W(e,i=L){return q(e.relativePath),F({projectRoot:e.projectRoot,base:e.base,relativePaths:[e.relativePath]},i).get(e.relativePath)??{state:"unavailable",reason:`Base-content lookup omitted ${e.relativePath}.`}}function F(e,i=L){for(let a of e.relativePaths)q(a);let n=[...new Set(e.relativePaths)];if(n.length===0)return new Map;let t;try{t=i.resolveCommit(e.projectRoot,e.base)}catch(a){return C(n,S(a))}let s;try{s=i.readBatch({projectRoot:e.projectRoot,resolvedBase:t,relativePaths:n})}catch(a){return C(n,S(a))}let r;try{r=le(s,n)}catch(a){return C(n,`Malformed git cat-file batch output: ${S(a)}`)}return new Map(n.map(a=>{let o=r.get(a)??null;return[a,o===null?{state:"absent"}:{state:"present",content:o}]}))}function ce(e,i=L){let n=F({projectRoot:e.projectRoot,base:e.base,relativePaths:e.preloadPaths??[]},i);return t=>(n.has(t)||n.set(t,W({projectRoot:e.projectRoot,base:e.base,relativePath:t},i)),n.get(t)??{state:"unavailable",reason:`Base-content reader omitted ${t}.`})}function Qe(e,i,n=[]){let t=typeof e=="string"?{projectRoot:e,base:i,preloadPaths:n}:e;if(typeof t.projectRoot!="string"||typeof t.base!="string")throw new TypeError("createBaseContentReader requires projectRoot and base.");let s={projectRoot:t.projectRoot,base:t.base,preloadPaths:t.preloadPaths},r=ce(s);return a=>{let o=r(a);if(o.state==="unavailable")throw new Error(`Base content unavailable for ${a}: ${o.reason}`);return o.state==="present"?o.content:null}}function Ye(e,i=e.changedFiles){let n=new Map(e.renamedFiles.map(t=>[t.to,t.from]));return[...new Set(i.map(t=>n.get(t)??t))]}function Ze(e,i,n){let t=typeof e=="string"?{projectRoot:e,base:i,relativePaths:n}:e;if(typeof t.projectRoot!="string"||typeof t.base!="string"||!Array.isArray(t.relativePaths))throw new TypeError("fileContentsAtBase requires projectRoot, base, and relativePaths.");let s=F(t),r=new Map;for(let[a,o]of s){if(o.state==="unavailable")throw new Error(`Base content unavailable for ${a}: ${o.reason}`);r.set(a,o.state==="present"?o.content:null)}return r}function q(e){P(e)}function C(e,i){return new Map(e.map(n=>[n,{state:"unavailable",reason:i}]))}function S(e){let n=(e instanceof Error?e.message:String(e)).replaceAll(/\s+/g," ").trim().slice(0,500);return n===""?"Git base-content lookup failed without a reason.":n}function le(e,i){let n=new Map,t=0;for(let s of i){let r=e.indexOf(10,t);if(r<0)throw new Error("git cat-file batch output ended before object header");let a=e.subarray(t,r).toString("utf-8");if(t=r+1,a.endsWith(" missing")){n.set(s,null);continue}let{objectType:o,size:c}=Ne(a);if(t+c>e.length)throw new Error("git cat-file batch output ended before blob payload");let u=e.subarray(t,t+c);n.set(s,o==="blob"?u.toString("utf-8"):null),t+=c,e[t]===10&&(t+=1)}return n}function de(e,i,n,t){if(n.length===0)return[];let s=new Map,r=new Set;Ae(t,n,s,r);let a=t.deletedFiles;if(a.length===0)return[...s.values()].sort((o,c)=>o.to.localeCompare(c.to));for(let o of n){if(s.has(o)||!K(`${e}/${o}`))continue;let c=a.filter(l=>!r.has(l)).filter(l=>$(l)===$(o));if(c.length===0)continue;let u=M(e,o),d=c.map(l=>({from:l,to:o,similarity:fe(oe({projectRoot:e,base:i,relativePath:l})??"",u)})).sort((l,f)=>f.similarity-l.similarity)[0];d&&d.similarity>=.45&&(s.set(o,d),r.add(d.from))}return[...s.values()].sort((o,c)=>o.to.localeCompare(c.to))}function ue(e){let i=new Set,n=new Map,t=new Set,s=e.split("\0");for(let r=0;r<s.length;){let a=s[r++],o=s[r++];if(!(!a||!o)){if(a.startsWith("R")||a.startsWith("C")){let c=s[r++];if(!c)throw new Error("Incomplete Git rename/copy record.");i.add(c),a.startsWith("R")&&n.set(c,{from:o,to:c,similarity:Number(a.slice(1))/100});continue}i.add(o),a.startsWith("D")&&t.add(o)}}return{changedFiles:[...i],renamedFiles:[...n.values()],deletedFiles:[...t]}}function fe(e,i){let n=new Set(z(e)),t=new Set(z(i));if(n.size===0&&t.size===0)return 1;if(n.size===0||t.size===0)return 0;let s=0;for(let r of n)t.has(r)&&(s+=1);return 2*s/(n.size+t.size)}function z(e){return e.match(/[A-Za-z_$][\w$]*|[{}()[\].,]/g)??[]}function me(e,i){let n=U(e),t=[];for(let s of i){let r=n(s);r&&!e.isIgnored(r)&&t.push(r)}return t}function ge(e,i){let n=U(e),t=[];for(let s of i){let r=n(s.file);r&&!e.isIgnored(r)&&t.push({...s,file:r})}return ye(t)}function U(e){let i=e.all(`SELECT relative_path FROM documents
|
|
3
|
+
ORDER BY id`).map(t=>t.relative_path),n=new Map(i.map(t=>[t,t]));return t=>{let s=t.replace(/\\/g,"/"),r=n.get(s);return r||null}}function pe(e){let i=[],n=null;for(let t of e.split(`
|
|
4
|
+
`)){if(t.startsWith("+++ ")){n=he(t.slice(4).trim());continue}if(!n||!t.startsWith("@@ "))continue;let s=/@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@/.exec(t);if(!s)continue;let r=Math.max(0,Number(s[1])-1),a=s[2]===void 0?1:Number(s[2]);i.push({file:n,startLine:r,endLine:Math.max(r,r+Math.max(a,1)-1)})}return i}function he(e){return e=be(e),e==="/dev/null"?null:e.startsWith("a/")||e.startsWith("b/")?e.slice(2):e}function be(e){if(!e.startsWith('"')||!e.endsWith('"'))return e;let i={a:7,b:8,f:12,n:10,r:13,t:9,v:11,'"':34};i["\\"]=92;let n=e.slice(1,-1),t=[];for(let s=0;s<n.length;){if(n.charCodeAt(s)!==92){let o=String.fromCodePoint(n.codePointAt(s));t.push(...Buffer.from(o)),s+=o.length;continue}s+=1;let r=/^[0-7]{1,3}/u.exec(n.slice(s))?.[0];if(r){t.push(Number.parseInt(r,8)),s+=r.length;continue}let a=i[n[s++]];if(a===void 0)throw new Error("Unsupported escape in Git quoted path.");t.push(a)}return Buffer.from(t).toString("utf8")}function ye(e){let i=new Set,n=[];for(let t of e){let s=`${t.file}:${t.startLine}:${t.endLine}`;i.has(s)||(i.add(s),n.push(t))}return n}function Re(e,i){let n=i.get(e.relativePath);return!n||n.length===0?!0:n.some(t=>I(e.startLine,e.endLine,t.startLine,t.endLine))}function Ce(e,i,n){let t=new Map,s=[],r=H(e),a=Fe(n);for(let o of i){let c=r.get(o.file)??[];if(c.some(l=>I(l.startLine,l.endLine,o.startLine,o.endLine)))continue;let u=a.get(o.file)??[],d=Ie(u,o);if(d){let l=c.find(f=>f.startLine>=d.startLine&&f.startLine<=d.endLine);if(l){t.set(l.symbolId,l),s.push(v(o,"ast-widened"));continue}}if(u.length===0){let l=[...c].filter(f=>f.startLine<=o.startLine).sort((f,p)=>p.startLine-f.startLine||f.endLine-p.endLine)[0];if(l){t.set(l.symbolId,l),s.push(v(o,"nearest-preceding"));continue}}s.push(v(o,"unattributed"))}return{definitions:[...t.values()],notes:s}}function Se(e,i,n,t){let s=H(n),r=[],a=[],o=[...new Set(i.map(c=>c.relativePath))];for(let c of o){let u=t.get(c)??[];if(u.length===0)continue;let d=s.get(c)??[];for(let l of u)d.some(f=>I(f.startLine,f.endLine,l.startLine,l.endLine))||r.push(l);r.some(l=>l.file===c)&&a.push(...ve(e,c))}return Ce(i,r,a)}function ve(e,i){let n=E(e,i);return n?n.rootNode.namedChildren.filter(De).map(t=>({file:i,startLine:t.startPosition.row,endLine:t.endPosition.row})).filter(t=>t.endLine>=t.startLine):[]}function De(e){return e.endPosition.row<e.startPosition.row?!1:!new Set(["import_statement","comment"]).has(e.type)}function Le(e){let i=new Map;for(let n of e)i.set(n.symbolId,n);return[...i.values()]}function H(e){let i=new Map;for(let n of e){let t=i.get(n.relativePath)??[];t.push(n),i.set(n.relativePath,t)}return i}function Fe(e){let i=new Map;for(let n of e){let t=i.get(n.file)??[];t.push(n),i.set(n.file,t)}return i}function Ie(e,i){return e.filter(n=>n.startLine<=i.startLine&&n.endLine>=i.endLine).sort((n,t)=>n.endLine-n.startLine-(t.endLine-t.startLine))[0]}function v(e,i){return{file:e.file,startLine:e.startLine,endLine:e.endLine,method:i}}function I(e,i,n,t){return e<=t&&n<=i}function xe(e,i,n,t,s,r,a,o){let c=new Set([...o,...r,...a].filter(d=>!e.isIgnored(d))).size;if(!Te(i,c))return;let u=T(i.symbol);t.push({symbol:i.symbol,shortName:u,file:i.relativePath,startLine:i.startLine,endLine:i.endLine,fanIn:c});for(let d of o)D(e,n,s,d,u);for(let d of r)D(e,n,s,d,u);for(let d of a)D(e,n,s,d,u)}function G(e,i,n){try{return{values:n(),status:{tier:e,state:"complete",attemptedSymbols:i}}}catch(t){return{values:new Map,status:{tier:e,state:"failed",attemptedSymbols:i,reason:Be(t)}}}}function we(e){return["semantic-consumers","source-fallback-consumers"].map(i=>{let n=e.map(r=>r.evidenceTiers?.find(a=>a.tier===i)??{tier:i,state:"failed",attemptedSymbols:0,reason:"isolated diff-impact batch omitted its evidence-tier status"}),t=n.reduce((r,a)=>r+a.attemptedSymbols,0),s=[...new Set(n.filter(r=>r.state==="failed").map(r=>r.reason))];return s.length===0?{tier:i,state:"complete",attemptedSymbols:t}:{tier:i,state:"failed",attemptedSymbols:t,reason:s.join("; ").slice(0,500)}})}function J(){return[{tier:"semantic-consumers",state:"complete",attemptedSymbols:0},{tier:"source-fallback-consumers",state:"complete",attemptedSymbols:0}]}function Be(e){let n=(e instanceof Error?e.message:String(e)).replaceAll(/\s+/g," ").trim().slice(0,500);return n===""?"evidence provider failed without a reason":n}function Pe(e,i){if(i.length===0)return new Map;let n=e.all(`SELECT DISTINCT m.symbol_id, ref_d.relative_path
|
|
5
|
+
FROM mentions m
|
|
6
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
7
|
+
JOIN documents ref_d ON c.document_id = ref_d.id
|
|
8
|
+
WHERE m.symbol_id IN (${i.map(()=>"?").join(",")})
|
|
9
|
+
AND m.role != 1
|
|
10
|
+
${e.pathExclusionsFor("ref_d")}`,...i),t=new Map;for(let s of n){let r=t.get(s.symbol_id);r||(r=new Set,t.set(s.symbol_id,r)),r.add(s.relative_path)}return t}function D(e,i,n,t,s){if(e.isIgnored(t)||i.has(t))return;let r=n.get(t);r||(r=new Set,n.set(t,r)),r.add(s)}function Me(e){return[...e.entries()].map(([i,n])=>({file:i,consumedSymbols:n.size})).sort((i,n)=>n.consumedSymbols-i.consumedSymbols)}function Ee(e){return!(N(e.symbol)||e.parentTypeName!==null&&!R(e.symbol))}function Te(e,i){return R(e.symbol)||e.isTypeLike?!0:e.parentTypeName===null&&i>0}function Ne(e){let i=/^[0-9a-f]+ ([^ ]+) (\d+)$/.exec(e);if(!i)throw new Error(`unexpected git cat-file batch header: ${e}`);let[,n,t]=i,s=Number(t);if(!Number.isFinite(s)||s<0)throw new Error(`unexpected git cat-file batch size: ${e}`);return{objectType:n,size:s}}function Ae(e,i,n,t){for(let s of e.renamedFiles)i.includes(s.to)&&(n.set(s.to,s),t.add(s.from))}export{X as a,Ve as b,te as c,ne as d,ie as e,oe as f,W as g,F as h,ce as i,Qe as j,Ye as k,Ze as l,Ce as m};
|
|
11
|
+
//# sourceMappingURL=chunk-LPCRK4A2.js.map
|