scip-query 0.19.5 → 0.19.8

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.
Files changed (421) hide show
  1. package/CHANGELOG.md +85 -1
  2. package/README.md +259 -53
  3. package/dist/augment-vue-worker.js +1 -1
  4. package/dist/chunk-2465DLHK.js +3 -0
  5. package/dist/{chunk-7GXM52MI.js → chunk-24GTWJ3N.js} +2 -2
  6. package/dist/{chunk-NH5ALKPW.js → chunk-2SNGN6U4.js} +2 -2
  7. package/dist/{chunk-3SVWW4PN.js → chunk-2U3OLUNJ.js} +2 -2
  8. package/dist/{chunk-XLTP42QA.js → chunk-33KUO7CG.js} +2 -2
  9. package/dist/{chunk-54HA4ZXH.js → chunk-33XTHFKR.js} +2 -2
  10. package/dist/{chunk-ZGZUZ7XE.js → chunk-3EDFLQ6A.js} +2 -2
  11. package/dist/chunk-3ZSJ3PWF.js +16 -0
  12. package/dist/{chunk-F6O7AAC3.js → chunk-43KC6EQZ.js} +2 -2
  13. package/dist/{chunk-I5RJM53C.js → chunk-464PLI5O.js} +2 -2
  14. package/dist/chunk-46XGSFNI.js +2 -0
  15. package/dist/{chunk-M7AIS73L.js → chunk-47BU5Z4T.js} +2 -2
  16. package/dist/chunk-4BV4QAZJ.js +5 -0
  17. package/dist/chunk-4YTUWQ6M.js +18 -0
  18. package/dist/{chunk-RV2FQIX3.js → chunk-5ML2BNRH.js} +2 -2
  19. package/dist/{chunk-6NSFJYRC.js → chunk-5YLUDDAF.js} +2 -2
  20. package/dist/chunk-67QRR5YC.js +6 -0
  21. package/dist/{chunk-GPBBJ5Y4.js → chunk-6GXYN7YA.js} +3 -3
  22. package/dist/{chunk-4333ETTV.js → chunk-6M7RONVB.js} +2 -2
  23. package/dist/chunk-6YTSKJJ3.js +2 -0
  24. package/dist/{chunk-QDV6RDCP.js → chunk-7FT5Y65S.js} +2 -2
  25. package/dist/{chunk-XTX6QHOF.js → chunk-7KYNAMMH.js} +2 -2
  26. package/dist/{chunk-DZ74OMG6.js → chunk-7LSVMFX7.js} +2 -2
  27. package/dist/{chunk-VTKGCT3V.js → chunk-7QHY3H7P.js} +2 -2
  28. package/dist/{chunk-MITTUCEH.js → chunk-7RAG65VK.js} +2 -2
  29. package/dist/{chunk-25LPM4DG.js → chunk-7SWJEWJF.js} +2 -2
  30. package/dist/{chunk-52ZYCAEO.js → chunk-7VCOXZH3.js} +2 -2
  31. package/dist/chunk-A2TNXAXO.js +8 -0
  32. package/dist/{chunk-IUFDSKGG.js → chunk-A3QXWFBK.js} +2 -2
  33. package/dist/{chunk-4T3LTWUS.js → chunk-AA4UWRNL.js} +2 -2
  34. package/dist/{chunk-4SALD7RU.js → chunk-ACAM6O5R.js} +2 -2
  35. package/dist/chunk-APMMR5Y2.js +2 -0
  36. package/dist/chunk-AQOFWNQJ.js +1 -0
  37. package/dist/chunk-AZFUMCQB.js +2 -0
  38. package/dist/{chunk-M7MTH5NR.js → chunk-BDOIKGDI.js} +2 -2
  39. package/dist/{chunk-BTEE5NZQ.js → chunk-BNXICU42.js} +2 -2
  40. package/dist/chunk-C5Q44Q5D.js +3 -0
  41. package/dist/{chunk-EOOJGLDU.js → chunk-CTF2GDEX.js} +2 -2
  42. package/dist/chunk-DHEQMPLW.js +2 -0
  43. package/dist/{chunk-IZKFSVBV.js → chunk-DQBCO2UY.js} +2 -2
  44. package/dist/{chunk-7B3UPBVA.js → chunk-DQGSM7RZ.js} +2 -2
  45. package/dist/chunk-E2LAW7SL.js +30 -0
  46. package/dist/chunk-E3HYEQO7.js +2 -0
  47. package/dist/chunk-E4NFOAD4.js +6 -0
  48. package/dist/chunk-E5HNT4X2.js +3 -0
  49. package/dist/{chunk-J77UIT3I.js → chunk-ELLMY7XJ.js} +2 -2
  50. package/dist/chunk-FD3HFKXR.js +5 -0
  51. package/dist/{chunk-SOAT6NLA.js → chunk-FIJCV235.js} +2 -2
  52. package/dist/{chunk-H7UKLTWJ.js → chunk-FJ5UDTQF.js} +2 -2
  53. package/dist/{chunk-HEXVUYFQ.js → chunk-GHKEJTCE.js} +2 -2
  54. package/dist/{chunk-LBMJEAEW.js → chunk-GLZTVKAB.js} +3 -3
  55. package/dist/{chunk-FWUUZTIO.js → chunk-GNC4JVAN.js} +2 -2
  56. package/dist/chunk-HIB452NU.js +949 -0
  57. package/dist/{chunk-NRCXJDHL.js → chunk-HZYDQPNY.js} +2 -2
  58. package/dist/chunk-IF6FP6B2.js +66 -0
  59. package/dist/{chunk-4RSI5EMG.js → chunk-JAY7YWS3.js} +2 -2
  60. package/dist/{chunk-STOL2BTL.js → chunk-JHF3E4YM.js} +2 -2
  61. package/dist/chunk-JORHF5AL.js +108 -0
  62. package/dist/{chunk-A2EZV2UM.js → chunk-K2WO7XY7.js} +2 -2
  63. package/dist/chunk-KFZNKUNT.js +2 -0
  64. package/dist/{chunk-YVVCVR2L.js → chunk-KJ2IIBZN.js} +2 -2
  65. package/dist/{chunk-QGXBRIM5.js → chunk-KKME5ZAI.js} +2 -2
  66. package/dist/chunk-KSGTULOS.js +9 -0
  67. package/dist/{chunk-UOAV44HR.js → chunk-KXDJAG4N.js} +3 -3
  68. package/dist/{chunk-UKZBVX4U.js → chunk-L4S2A7BV.js} +2 -2
  69. package/dist/chunk-LP3ARJKF.js +8 -0
  70. package/dist/chunk-LSOR3LQG.js +3 -0
  71. package/dist/{chunk-Q4IIEGXJ.js → chunk-MLFZP76A.js} +2 -2
  72. package/dist/{chunk-WQTAC523.js → chunk-MNSTUIDD.js} +2 -2
  73. package/dist/{chunk-VXQNNXJE.js → chunk-MSBDMFER.js} +2 -2
  74. package/dist/{chunk-X6D5IC6I.js → chunk-MZZBAITE.js} +5 -5
  75. package/dist/{chunk-I5AWSI2G.js → chunk-NE3TZUCI.js} +2 -2
  76. package/dist/{chunk-6E7UTQY7.js → chunk-NTUMF2X3.js} +2 -2
  77. package/dist/{chunk-S44IULR6.js → chunk-O23I56NA.js} +2 -2
  78. package/dist/{chunk-CFMXJPHH.js → chunk-O3O4XXO6.js} +2 -2
  79. package/dist/{chunk-IG7N5ZIK.js → chunk-OUBAF226.js} +2 -2
  80. package/dist/chunk-P3UO3EH3.js +2 -0
  81. package/dist/{chunk-YNRNA5LK.js → chunk-QGGLL3UH.js} +2 -2
  82. package/dist/chunk-QIQ63BHW.js +16 -0
  83. package/dist/{chunk-VGRICIQI.js → chunk-QJIVBYEK.js} +2 -2
  84. package/dist/chunk-QOXBSI6G.js +20 -0
  85. package/dist/chunk-QXK6UUSM.js +2 -0
  86. package/dist/{chunk-XYADIZHU.js → chunk-RA3AYNWP.js} +2 -2
  87. package/dist/chunk-RJMDJR3A.js +2 -0
  88. package/dist/{chunk-NSS46APD.js → chunk-RLH5VUMG.js} +2 -2
  89. package/dist/{chunk-GBQ5NYPR.js → chunk-S4S2WOIX.js} +6 -6
  90. package/dist/{chunk-YIJ7ZAA4.js → chunk-SERUIGV5.js} +2 -2
  91. package/dist/{chunk-FECYOO5O.js → chunk-SMQWE25B.js} +2 -2
  92. package/dist/{chunk-R4FQGQ4X.js → chunk-TAVELHYR.js} +2 -2
  93. package/dist/{chunk-U6WNH5GC.js → chunk-TWMJ3Y3G.js} +2 -2
  94. package/dist/chunk-VAXNI5NE.js +146 -0
  95. package/dist/chunk-VVY2G5ET.js +2 -0
  96. package/dist/{chunk-WER3B7MI.js → chunk-W3DBTGL4.js} +2 -2
  97. package/dist/{chunk-CNKAGUPL.js → chunk-WANA4KAQ.js} +2 -2
  98. package/dist/chunk-WJL2L6MV.js +60 -0
  99. package/dist/chunk-WUW7YUAH.js +11 -0
  100. package/dist/{chunk-QVWS2VWZ.js → chunk-WWKWUPSU.js} +2 -2
  101. package/dist/{chunk-ABMYA4TN.js → chunk-WY45BHKQ.js} +2 -2
  102. package/dist/chunk-X4FR5BZF.js +9 -0
  103. package/dist/chunk-X6RKPDY7.js +2 -0
  104. package/dist/{chunk-ZXJYMGD3.js → chunk-YLFORA5G.js} +2 -2
  105. package/dist/{chunk-KP6XRY5Z.js → chunk-YTVWB7YJ.js} +2 -2
  106. package/dist/{chunk-4XTA5OMB.js → chunk-ZCEJ63SP.js} +2 -2
  107. package/dist/{chunk-HKEHS2AS.js → chunk-ZJ5CBXK3.js} +2 -2
  108. package/dist/chunk-ZL2OGDCD.js +2 -0
  109. package/dist/cli.js +8 -3
  110. package/dist/command-descriptors-ZW5J4ZEM.js +631 -0
  111. package/dist/{config-types-D20KuvvZ.d.ts → config-types-B6MEoRNy.d.ts} +8 -0
  112. package/dist/{db-G_II8yXU.d.ts → db-DYLKr9Wn.d.ts} +18 -1
  113. package/dist/direct-navigation-42YHQPOI.js +3 -0
  114. package/dist/{health-oblXYgkF.d.ts → health-DgxIDXJC.d.ts} +1 -1
  115. package/dist/index.d.ts +2 -2
  116. package/dist/index.js +1 -1
  117. package/dist/postinstall.js +1 -1
  118. package/dist/queries/affected.d.ts +2 -2
  119. package/dist/queries/affected.js +1 -1
  120. package/dist/queries/architecture.d.ts +2 -2
  121. package/dist/queries/architecture.js +1 -1
  122. package/dist/queries/bottlenecks.d.ts +2 -2
  123. package/dist/queries/bottlenecks.js +1 -1
  124. package/dist/queries/by-kind.d.ts +2 -2
  125. package/dist/queries/by-kind.js +1 -1
  126. package/dist/queries/call-graph.d.ts +2 -2
  127. package/dist/queries/call-graph.js +1 -1
  128. package/dist/queries/change-surface.d.ts +2 -2
  129. package/dist/queries/change-surface.js +1 -1
  130. package/dist/queries/cleanup-plan.d.ts +2 -2
  131. package/dist/queries/cleanup-plan.js +1 -1
  132. package/dist/queries/co-change.d.ts +2 -2
  133. package/dist/queries/co-change.js +1 -1
  134. package/dist/queries/code.d.ts +2 -2
  135. package/dist/queries/code.js +1 -1
  136. package/dist/queries/complexity-hotspots.d.ts +2 -2
  137. package/dist/queries/complexity-hotspots.js +1 -1
  138. package/dist/queries/complexity.d.ts +2 -2
  139. package/dist/queries/complexity.js +1 -1
  140. package/dist/queries/convergence.d.ts +2 -2
  141. package/dist/queries/convergence.js +1 -1
  142. package/dist/queries/coupling.d.ts +2 -2
  143. package/dist/queries/coupling.js +1 -1
  144. package/dist/queries/cycles.d.ts +2 -2
  145. package/dist/queries/cycles.js +1 -1
  146. package/dist/queries/dataflow.d.ts +2 -2
  147. package/dist/queries/dataflow.js +1 -1
  148. package/dist/queries/dead.d.ts +2 -2
  149. package/dist/queries/dead.js +1 -1
  150. package/dist/queries/decorative-checkers.d.ts +3 -3
  151. package/dist/queries/decorative-checkers.js +1 -1
  152. package/dist/queries/deep-chains.d.ts +2 -2
  153. package/dist/queries/deep-chains.js +1 -1
  154. package/dist/queries/deps.d.ts +2 -2
  155. package/dist/queries/deps.js +1 -1
  156. package/dist/queries/diff-gate.d.ts +30 -2
  157. package/dist/queries/diff-gate.js +1 -1
  158. package/dist/queries/diff-impact.d.ts +2 -2
  159. package/dist/queries/diff-impact.js +1 -1
  160. package/dist/queries/doc-drift.d.ts +2 -2
  161. package/dist/queries/doc-drift.js +1 -1
  162. package/dist/queries/drift.d.ts +2 -2
  163. package/dist/queries/drift.js +1 -1
  164. package/dist/queries/duplicate-bodies.d.ts +2 -2
  165. package/dist/queries/duplicate-bodies.js +1 -1
  166. package/dist/queries/extract-candidates.d.ts +2 -2
  167. package/dist/queries/extract-candidates.js +1 -1
  168. package/dist/queries/fan.d.ts +2 -2
  169. package/dist/queries/fan.js +1 -1
  170. package/dist/queries/files.d.ts +2 -2
  171. package/dist/queries/health.d.ts +3 -3
  172. package/dist/queries/health.js +1 -1
  173. package/dist/queries/hierarchy.d.ts +2 -2
  174. package/dist/queries/hierarchy.js +1 -1
  175. package/dist/queries/hotspots.d.ts +2 -2
  176. package/dist/queries/hotspots.js +1 -1
  177. package/dist/queries/imports.d.ts +2 -2
  178. package/dist/queries/imports.js +1 -1
  179. package/dist/queries/incomplete-migration.d.ts +2 -2
  180. package/dist/queries/incomplete-migration.js +1 -1
  181. package/dist/queries/index.d.ts +17 -3
  182. package/dist/queries/index.js +1 -1
  183. package/dist/queries/isolated.d.ts +2 -2
  184. package/dist/queries/isolated.js +1 -1
  185. package/dist/queries/locality-candidates.d.ts +2 -2
  186. package/dist/queries/locality-candidates.js +1 -1
  187. package/dist/queries/members.d.ts +2 -2
  188. package/dist/queries/members.js +1 -1
  189. package/dist/queries/methods.d.ts +2 -2
  190. package/dist/queries/methods.js +1 -1
  191. package/dist/queries/not-implemented.d.ts +3 -3
  192. package/dist/queries/not-implemented.js +1 -1
  193. package/dist/queries/outline.d.ts +2 -2
  194. package/dist/queries/outline.js +1 -1
  195. package/dist/queries/passthrough-candidates.d.ts +2 -2
  196. package/dist/queries/passthrough-candidates.js +1 -1
  197. package/dist/queries/plan-context.d.ts +2 -2
  198. package/dist/queries/plan-context.js +1 -1
  199. package/dist/queries/react-component-duplicates.d.ts +2 -2
  200. package/dist/queries/react-component-duplicates.js +1 -1
  201. package/dist/queries/react-hook-candidates.d.ts +2 -2
  202. package/dist/queries/react-hook-candidates.js +1 -1
  203. package/dist/queries/react-large-component-pressure.d.ts +2 -2
  204. package/dist/queries/react-large-component-pressure.js +1 -1
  205. package/dist/queries/recent-duplicates.d.ts +2 -2
  206. package/dist/queries/recent-duplicates.js +1 -1
  207. package/dist/queries/redundant-reexports.d.ts +2 -2
  208. package/dist/queries/redundant-reexports.js +1 -1
  209. package/dist/queries/refs.d.ts +2 -2
  210. package/dist/queries/refs.js +1 -1
  211. package/dist/queries/self-audit.d.ts +2 -2
  212. package/dist/queries/self-audit.js +1 -1
  213. package/dist/queries/similar-chains.d.ts +2 -2
  214. package/dist/queries/similar-chains.js +1 -1
  215. package/dist/queries/similar-files.d.ts +2 -2
  216. package/dist/queries/similar-files.js +1 -1
  217. package/dist/queries/similar-signatures.d.ts +2 -2
  218. package/dist/queries/similar-signatures.js +1 -1
  219. package/dist/queries/similar.d.ts +2 -2
  220. package/dist/queries/similar.js +1 -1
  221. package/dist/queries/slice.d.ts +2 -2
  222. package/dist/queries/slice.js +1 -1
  223. package/dist/queries/stale-abstractions.d.ts +2 -2
  224. package/dist/queries/stale-abstractions.js +1 -1
  225. package/dist/queries/stats.d.ts +2 -2
  226. package/dist/queries/stats.js +1 -1
  227. package/dist/queries/surface.d.ts +2 -2
  228. package/dist/queries/surface.js +1 -1
  229. package/dist/queries/symbols.d.ts +2 -2
  230. package/dist/queries/symbols.js +1 -1
  231. package/dist/queries/system.d.ts +2 -2
  232. package/dist/queries/system.js +1 -1
  233. package/dist/queries/test-quality.d.ts +2 -2
  234. package/dist/queries/test-quality.js +1 -1
  235. package/dist/queries/trace.d.ts +2 -2
  236. package/dist/queries/trace.js +1 -1
  237. package/dist/queries/twin-ab.d.ts +3 -3
  238. package/dist/queries/twin-ab.js +1 -1
  239. package/dist/queries/twin-drift.d.ts +2 -2
  240. package/dist/queries/twin-drift.js +1 -1
  241. package/dist/queries/unused-imports.d.ts +2 -2
  242. package/dist/queries/unused-imports.js +1 -1
  243. package/dist/queries/unused-params.d.ts +2 -2
  244. package/dist/queries/unused-params.js +1 -1
  245. package/dist/queries/vue-component-duplicates.d.ts +2 -2
  246. package/dist/queries/vue-component-duplicates.js +1 -1
  247. package/dist/queries/vue-composable-candidates.d.ts +2 -2
  248. package/dist/queries/vue-composable-candidates.js +1 -1
  249. package/dist/queries/vue-large-view-pressure.d.ts +2 -2
  250. package/dist/queries/vue-large-view-pressure.js +1 -1
  251. package/dist/queries/wrapper-candidates.d.ts +2 -2
  252. package/dist/queries/wrapper-candidates.js +1 -1
  253. package/dist/reindex-worker.js +26 -26
  254. package/dist/reindex.d.ts +14 -4
  255. package/dist/reindex.js +34 -38
  256. package/dist/runtime.d.ts +167 -18
  257. package/dist/runtime.js +3 -2
  258. package/dist/rust-semantic-session-server.js +1 -1
  259. package/dist/rust-semantic-session-worker.js +1 -1
  260. package/dist/rust-semantic-worker.js +1 -1
  261. package/dist/{scip-cli-kRpaexVJ.d.ts → scip-cli-Cc6c00-a.d.ts} +6 -2
  262. package/dist/watch-server.js +5 -5
  263. package/docs/AGENT_GUIDE.md +20 -4
  264. package/docs/AI_FAILURE_MODES.md +17 -17
  265. package/docs/API_EVOLUTION.md +71 -0
  266. package/docs/CLI_JSON_OUTPUT.md +168 -0
  267. package/docs/COMMAND_REFERENCE.md +10 -6
  268. package/docs/COMMITTED_RECORD_COMPATIBILITY.md +117 -0
  269. package/docs/CONFIGURATION_WRITE_SAFETY.md +130 -0
  270. package/docs/DETECTOR_GUIDE.md +46 -46
  271. package/docs/DURABILITY.md +103 -0
  272. package/docs/INDEX_GENERATIONS.md +121 -0
  273. package/docs/LOCK_PROTOCOL.md +133 -0
  274. package/docs/MAILBOX_LIFECYCLE.md +197 -0
  275. package/docs/REINDEX_METADATA_COMPATIBILITY.md +84 -0
  276. package/docs/RUST_DURABLE_SESSION_PROTOCOL.md +126 -0
  277. package/docs/SECURITY_MODEL.md +129 -0
  278. package/docs/TELEMETRY_RETENTION.md +77 -0
  279. package/docs/TIME_SEMANTICS.md +77 -0
  280. package/docs/WATCH_REFRESH_REQUESTS.md +110 -0
  281. package/docs/WINDOWS_SIDECAR_RELEASE.md +298 -0
  282. package/docs/analyzer-validation-ledger.md +24 -23
  283. package/docs/schemas/cli-json-envelope.schema.json +53 -0
  284. package/docs/schemas/cli-output-page.schema.json +104 -0
  285. package/docs/schemas/npm-release-state.schema.json +146 -0
  286. package/docs/schemas/outcome-event-record.schema.json +39 -0
  287. package/docs/schemas/project-config.schema.json +247 -0
  288. package/docs/schemas/suppression-record.schema.json +31 -0
  289. package/docs/schemas/windows-sidecar-provenance.schema.json +137 -0
  290. package/package.json +21 -10
  291. package/scripts/build-scip-windows.mjs +180 -61
  292. package/scripts/scip-windows-provenance.mjs +364 -0
  293. package/scripts/verify-scip-windows.mjs +29 -0
  294. package/skills/_shared/SKILL.md +90 -229
  295. package/skills/_shared/agents/openai.yaml +1 -1
  296. package/skills/_shared/references/agent-contract-catalog.md +105 -0
  297. package/skills/_shared/references/command-catalog.md +118 -0
  298. package/skills/_shared/references/detector-precision-and-diffgate.md +59 -0
  299. package/skills/_shared/references/evidence-and-dead-code.md +25 -0
  300. package/skills/scip-audit/SKILL.md +77 -0
  301. package/skills/scip-audit/agents/openai.yaml +4 -0
  302. package/skills/scip-audit/references/claims.md +98 -0
  303. package/skills/scip-audit/references/cleanup.md +101 -0
  304. package/skills/scip-audit/references/directory.md +222 -0
  305. package/skills/scip-audit/references/frontend.md +130 -0
  306. package/skills/scip-audit/references/integrity.md +154 -0
  307. package/skills/scip-audit/references/maintainability.md +162 -0
  308. package/skills/scip-audit/references/twin-drift.md +104 -0
  309. package/skills/scip-diagnose/SKILL.md +52 -0
  310. package/skills/scip-diagnose/agents/openai.yaml +4 -0
  311. package/skills/scip-diagnose/references/debug.md +117 -0
  312. package/skills/{scip-probe-reachability/SKILL.md → scip-diagnose/references/probe-reachability.md} +11 -27
  313. package/skills/scip-diagnose/references/root-cause.md +145 -0
  314. package/skills/scip-diagnose/references/triage.md +119 -0
  315. package/skills/scip-explore/SKILL.md +54 -85
  316. package/skills/scip-explore/agents/openai.yaml +2 -2
  317. package/skills/scip-explore/references/diagrams.md +40 -0
  318. package/skills/scip-explore/references/language-playbook.md +49 -0
  319. package/skills/scip-improve/SKILL.md +56 -0
  320. package/skills/scip-improve/agents/openai.yaml +4 -0
  321. package/skills/scip-improve/references/cleanup-batches.md +53 -0
  322. package/skills/scip-improve/references/directory-moves.md +53 -0
  323. package/skills/scip-improve/references/doc-reconcile.md +30 -0
  324. package/skills/scip-improve/references/frontend-extraction.md +39 -0
  325. package/skills/scip-improve/references/maintainability-mechanism.md +43 -0
  326. package/skills/scip-improve/references/twin-drift.md +35 -0
  327. package/skills/scip-plan/SKILL.md +68 -0
  328. package/skills/scip-plan/agents/openai.yaml +4 -0
  329. package/skills/scip-plan/references/api-impact.md +19 -0
  330. package/skills/scip-plan/references/conductor.md +41 -0
  331. package/skills/scip-plan/references/high-assurance.md +43 -0
  332. package/skills/scip-plan/references/hyper-optimization.md +50 -0
  333. package/skills/scip-plan/references/tla-model.md +88 -0
  334. package/skills/scip-query/SKILL.md +53 -98
  335. package/skills/scip-query/agents/openai.yaml +2 -2
  336. package/skills/scip-setup/SKILL.md +69 -181
  337. package/skills/scip-setup/agents/openai.yaml +3 -3
  338. package/skills/scip-setup/references/bootstrap-workflow.md +120 -0
  339. package/skills/scip-setup/references/language-verification.md +61 -0
  340. package/skills/scip-setup/references/lifecycle-commands.md +119 -0
  341. package/skills/scip-setup/references/per-repo-triage.md +24 -0
  342. package/skills/scip-verify/SKILL.md +126 -84
  343. package/skills/scip-verify/agents/openai.yaml +2 -2
  344. package/skills/scip-verify/references/calibrate-detectors.md +170 -0
  345. package/dist/chunk-2CTX5CMX.js +0 -4
  346. package/dist/chunk-2Y373BDD.js +0 -2
  347. package/dist/chunk-2YU7I3QO.js +0 -2
  348. package/dist/chunk-3MJ5YA4Y.js +0 -16
  349. package/dist/chunk-64RFXJT5.js +0 -16
  350. package/dist/chunk-7UY7SD7D.js +0 -927
  351. package/dist/chunk-B5NLK2B3.js +0 -6
  352. package/dist/chunk-C2QSK7E7.js +0 -2
  353. package/dist/chunk-C7NIYIQ4.js +0 -67
  354. package/dist/chunk-D4U5Q3FT.js +0 -7
  355. package/dist/chunk-DGAGY7RJ.js +0 -60
  356. package/dist/chunk-DLWR3NUU.js +0 -5
  357. package/dist/chunk-K2ERX4UT.js +0 -3
  358. package/dist/chunk-KHE7J5ZN.js +0 -3
  359. package/dist/chunk-L7SPDE73.js +0 -84
  360. package/dist/chunk-LHMNRHGV.js +0 -3
  361. package/dist/chunk-LM72NQ7T.js +0 -3
  362. package/dist/chunk-MSWVMDAH.js +0 -122
  363. package/dist/chunk-NH7WNNQC.js +0 -20
  364. package/dist/chunk-NPKYOIFM.js +0 -18
  365. package/dist/chunk-NZL2DBT7.js +0 -2
  366. package/dist/chunk-OMPZHGHO.js +0 -2
  367. package/dist/chunk-P2PC2WGR.js +0 -2
  368. package/dist/chunk-Q3AFUTGB.js +0 -8
  369. package/dist/chunk-QRGV2F7L.js +0 -2
  370. package/dist/chunk-TW4OG5FC.js +0 -4
  371. package/dist/chunk-U7DSEKOM.js +0 -30
  372. package/dist/chunk-V27BEQJN.js +0 -7
  373. package/dist/chunk-XAGAZSFE.js +0 -6
  374. package/dist/chunk-XBN5VO53.js +0 -2
  375. package/dist/chunk-YGAGTIDK.js +0 -11
  376. package/dist/command-descriptors-N2TL4XM2.js +0 -613
  377. package/dist/direct-navigation-DUCZCTOE.js +0 -3
  378. package/skills/scip-api-impact/SKILL.md +0 -140
  379. package/skills/scip-api-impact/agents/openai.yaml +0 -4
  380. package/skills/scip-calibrate/SKILL.md +0 -131
  381. package/skills/scip-calibrate/agents/openai.yaml +0 -4
  382. package/skills/scip-claim-audit/SKILL.md +0 -107
  383. package/skills/scip-claim-audit/agents/openai.yaml +0 -4
  384. package/skills/scip-cleanup-audit/SKILL.md +0 -130
  385. package/skills/scip-cleanup-audit/agents/openai.yaml +0 -4
  386. package/skills/scip-cleanup-improve/SKILL.md +0 -85
  387. package/skills/scip-cleanup-improve/agents/openai.yaml +0 -4
  388. package/skills/scip-concrete-plan/HIGH_ASSURANCE.md +0 -317
  389. package/skills/scip-concrete-plan/SKILL.md +0 -105
  390. package/skills/scip-concrete-plan/agents/openai.yaml +0 -4
  391. package/skills/scip-conductor/SKILL.md +0 -133
  392. package/skills/scip-conductor/agents/openai.yaml +0 -4
  393. package/skills/scip-debug/SKILL.md +0 -130
  394. package/skills/scip-debug/agents/openai.yaml +0 -4
  395. package/skills/scip-diagram/SKILL.md +0 -110
  396. package/skills/scip-diagram/agents/openai.yaml +0 -4
  397. package/skills/scip-directory-architecture/SKILL.md +0 -266
  398. package/skills/scip-directory-architecture/agents/openai.yaml +0 -4
  399. package/skills/scip-doc-reconcile/SKILL.md +0 -89
  400. package/skills/scip-doc-reconcile/agents/openai.yaml +0 -4
  401. package/skills/scip-hyper-optimization/SKILL.md +0 -156
  402. package/skills/scip-hyper-optimization/agents/openai.yaml +0 -4
  403. package/skills/scip-integrity-audit/SKILL.md +0 -152
  404. package/skills/scip-integrity-audit/agents/openai.yaml +0 -4
  405. package/skills/scip-language-playbook/SKILL.md +0 -106
  406. package/skills/scip-language-playbook/agents/openai.yaml +0 -4
  407. package/skills/scip-maintainability/SKILL.md +0 -158
  408. package/skills/scip-maintainability/agents/openai.yaml +0 -4
  409. package/skills/scip-probe-reachability/agents/openai.yaml +0 -4
  410. package/skills/scip-react-maintainability/SKILL.md +0 -101
  411. package/skills/scip-react-maintainability/agents/openai.yaml +0 -4
  412. package/skills/scip-root-cause/SKILL.md +0 -151
  413. package/skills/scip-root-cause/agents/openai.yaml +0 -4
  414. package/skills/scip-tla-model-system/SKILL.md +0 -148
  415. package/skills/scip-tla-model-system/agents/openai.yaml +0 -4
  416. package/skills/scip-triage-issue/SKILL.md +0 -133
  417. package/skills/scip-triage-issue/agents/openai.yaml +0 -4
  418. package/skills/scip-twin-drift/SKILL.md +0 -109
  419. package/skills/scip-twin-drift/agents/openai.yaml +0 -4
  420. package/skills/scip-vue-maintainability/SKILL.md +0 -107
  421. package/skills/scip-vue-maintainability/agents/openai.yaml +0 -4
@@ -1,4 +1,4 @@
1
- import{a as te,b as ne}from"./chunk-64RFXJT5.js";import{a as Bt}from"./chunk-P5XHIJHI.js";import{$ as Et,C as mt,D as ht,F as G,H as yt,L as St,M as bt,N as Pt,O as xt,Q as Re,R as Rt,Y as vt,Z as It,_ as Ft,a as Z,aa as wt,ba as jt,ca as Dt,da as _t,ea as Tt,f as at,fa as kt,ga as U,h as st,ha as re,i as T,ia as Ot,j as $,ka as ie,l as pt,la as Mt,ma as ve,n as gt,na as At,o as ft,oa as Ie,p as ee,q as B,qa as Fe,sa as ae,ta as Nt,va as Ct,xa as Lt,ya as $t,za as Ee}from"./chunk-MSWVMDAH.js";import{a as Y,b as tt,c as K,d as ot,e as ct,f as dt,h as lt,i as ut,l as D}from"./chunk-C7NIYIQ4.js";import{a as k,b as O}from"./chunk-KHE7J5ZN.js";import{e as E,f as C}from"./chunk-HGFDYOVB.js";import{a as L,b as nt,c as rt,d as xe,e as it}from"./chunk-XBN5VO53.js";import{execFileSync as va}from"child_process";import{createHash as Ia}from"crypto";import{closeSync as Fa,copyFileSync as ye,existsSync as F,mkdirSync as he,mkdtempSync as Ea,openSync as wa,readdirSync as Xn,readFileSync as Se,renameSync as Vn,rmSync as j,statSync as ja,writeFileSync as Da}from"fs";import{basename as me,dirname as S,extname as _a,join as x,resolve as Gn}from"path";import{platform as Ta}from"os";import{execFileSync as Ut}from"child_process";import{existsSync as we,readFileSync as mr}from"fs";import{createRequire as hr}from"module";import{platform as Jt}from"os";import{dirname as Gt,join as se}from"path";var yr=hr(import.meta.url),M={language:"rust",indexerBinary:"rust-analyzer",installUrl:"https://github.com/rust-lang/rust-analyzer"};function je(e){return[e.indexerBinary,...e.binaryAliases??[]]}function oe(e){let t=je(e);return t.length===1?t[0]:t.join(" or ")}function J(e){for(let t of je(e))if(Jt()==="win32"){let n=rt(t);if(n)return n}else if(L(t))return t;return br(e)}function Ht(e){return J(e)!==null||Sr(e)}function Sr(e){return Wt(e)!==null}function br(e){let t=Wt(e);if(!t)return null;let r=JSON.parse(mr(t,"utf8")).bin;if(!r)return null;if(typeof r=="string")return se(Gt(t),r);for(let i of je(e)){let a=r[i];if(a)return se(Gt(t),a)}return null}function Wt(e){if(!e.bundledNpmPackage)return null;try{return yr.resolve(`${e.bundledNpmPackage}/package.json`)}catch{return null}}function qt(e,t){for(let n of e.projectLocalBinaries??[]){let r=se(t,n);if(we(r))return r}return null}function zt(e,t=process.env,n=e.indexerBinary){if(e.indexerBinary!=="scip-dotnet"||Xt(n,t))return t;let r=Pr(n,t);return r?{...t,DOTNET_ROOT:r}:t}function Pr(e,t){for(let n of xr(t))if(Xt(e,{...t,DOTNET_ROOT:n}))return n;return null}function xr(e){let t=[],n=e.DOTNET_ROOT;if(n&&we(n)&&t.push(n),Jt()==="darwin"&&L("brew"))try{let r=Ut("brew",["--prefix","dotnet@9"],{stdio:"pipe",env:e}).toString().trim(),i=se(r,"libexec");we(i)&&!t.includes(i)&&t.push(i)}catch{}return t}function Xt(e,t){try{return Ut(e,["--version"],{stdio:"pipe",env:t}),!0}catch{return!1}}import{readFileSync as Bs}from"fs";import{dirname as Us,join as Js}from"path";var Vt=ft({kind:"file-dependency-graph",invalidation:ee("file-dependency-graph"),serialize:e=>JSON.stringify(e),deserialize:jr}),Rr=lt("file-dep-graph",{clearGroups:["whole-project"]});function A(e,t,n={}){let r=n.scipEdges??"all-references",i=n.sourceEdges??"imports-only",a=Fr(t,r,i);return Rr.get(e,a,()=>{let s=new Set(D(e,{includeIgnored:!1})),o=pt(e),d=0,c=0,l=null,u=!1,g=0,m=0;return E("file-dep-graph.product",()=>{if(o){let f=Vt.read(e,a,o);if(f){u=!0;let h=wr(f);return d=f.sourceFileCount,c=f.sourceEdgeCount,g=f.scipEdgeCount,m=h.size,l=f.sourceDependencyFingerprint,h}}let p=E("file-dep-graph.source-imports",()=>{let f=vr(e,s,t,i);return d=f.files.length,c=f.edges.length,l=f.fingerprint,f},()=>({scope:t??null,sourceEdges:i,files:d,edges:c})),y=new Map,b=(f,h)=>kr(e,y,s,f,h);E("file-dep-graph.scip-edges",()=>{for(let f of Tr(e,t,r))g+=1,b(f.from_file,f.to_file)},()=>({scope:t??null,edges:g}));for(let f of p.edges)b(f.fromFile,f.toFile);return m=y.size,o&&Vt.write(e,a,o,{sourceDependencyFingerprint:p.fingerprint,sourceFileCount:p.files.length,sourceEdgeCount:p.edges.length,scipEdgeCount:g,graph:Er(y)}),y},()=>({scope:t??null,available:o!==null,hit:u,files:d,sourceEdges:c,sourceEdgeMode:i,scipEdges:g,graphFiles:m,sourceDependencyFingerprint:l}))})}function vr(e,t,n,r){let i=[],a=[];for(let s of t)if(!(n&&!s.includes(n))){i.push(s);for(let o of ht(e,s))o.sourcePath&&a.push({fromFile:s,toFile:o.sourcePath});if(r==="imports-and-reexports")for(let o of mt(e,s))o.sourcePath&&a.push({fromFile:s,toFile:o.sourcePath})}return{files:i,edges:a,fingerprint:Ir(i,a)}}function Ir(e,t){let n=t.map(r=>`${r.fromFile}\0${r.toFile}`).sort();return $(JSON.stringify({files:e,edges:n}))}function Fr(e,t,n){return`edge-mode-v3:${t}:${n}:${e??"<all>"}`}function Er(e){return[...e].map(([t,n])=>[t,[...n]])}function wr(e){return new Map(e.graph.map(([t,n])=>[t,new Set(n)]))}function jr(e){let t=JSON.parse(e);return Dr(t)?t:null}function Dr(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.sourceDependencyFingerprint=="string"&&typeof t.sourceFileCount=="number"&&typeof t.sourceEdgeCount=="number"&&typeof t.scipEdgeCount=="number"&&Array.isArray(t.graph)&&t.graph.every(_r)}function _r(e){return Array.isArray(e)&&e.length===2&&typeof e[0]=="string"&&Array.isArray(e[1])&&e[1].every(t=>typeof t=="string")}function Tr(e,t,n){let r=t?"AND d1.relative_path LIKE ?":"",i=t?[`%${t}%`]:[],a=n==="imports-only"?"AND m.role = 2":"AND m.role != 1";return e.all(`SELECT DISTINCT
1
+ import{a as ce,b as de}from"./chunk-3ZSJ3PWF.js";import{a as Sn}from"./chunk-P5XHIJHI.js";import{$ as Wt,A as Lt,Aa as $e,B as se,Ca as pe,Da as pn,Fa as gn,Ha as fn,Ia as Be,Ka as mn,La as hn,Ma as yn,N as Nt,Na as Ge,O as Ct,Q as z,S as $t,W as Bt,X as Gt,Y as Ut,Z as Ht,_ as Jt,b as U,ba as Le,c as ie,ca as qt,d as De,e as ke,fa as zt,ga as Xt,ha as Kt,ia as Vt,j as Me,ja as Yt,ka as Qt,l as oe,la as Zt,ma as en,na as tn,oa as nn,pa as rn,q as xt,qa as X,ra as le,s as vt,sa as an,u as k,ua as ue,v as q,va as on,wa as Ne,x as Ot,xa as sn,ya as Ce,z as At}from"./chunk-VAXNI5NE.js";import{b as kt,c as Mt,f as _}from"./chunk-IF6FP6B2.js";import{a as ne,b as ht,c as re,g as J,i as Et,j as Ft,k as jt,n as wt,o as Tt}from"./chunk-C5Q44Q5D.js";import{g as Pt,h as W,i as O,j as A,l as Rt,m as Ae,n as It,p as _t,q as Dt,s as cn,v as dn,w as ln,x as un}from"./chunk-X4FR5BZF.js";import{e as j,f as H}from"./chunk-HGFDYOVB.js";import{a as P}from"./chunk-APMMR5Y2.js";import{a as mt,c as Te,f as _e,g as te,h as T}from"./chunk-46XGSFNI.js";import{a as ae,b as yt,c as St,d as Oe,e as bt}from"./chunk-KFZNKUNT.js";import{execFileSync as so}from"child_process";import{createHash as co}from"crypto";import{copyFileSync as Fe,existsSync as F,mkdirSync as ve,mkdtempSync as lo,readdirSync as Tr,renameSync as _r,rmSync as B,statSync as uo}from"fs";import{basename as Ie,dirname as y,extname as po,join as I,resolve as xr}from"path";import{platform as go}from"os";import{execFileSync as Pn}from"child_process";import{createHash as Zr}from"crypto";import{existsSync as ge,statSync as ei}from"fs";import{createRequire as ti}from"module";import{platform as ni}from"os";import{dirname as bn,join as K}from"path";var ri=ti(import.meta.url),L={language:"rust",indexerBinary:"rust-analyzer",installUrl:"https://github.com/rust-lang/rust-analyzer"};function Ue(e){return[e.indexerBinary,...e.binaryAliases??[]]}function fe(e){let t=Ue(e);return t.length===1?t[0]:t.join(" or ")}function N(e){for(let t of Ue(e)){let n=St(t);if(n)return n}return ai(e)}function xn(e){return N(e)!==null||ii(e)}function ii(e){return Rn(e)!==null}function ai(e){let t=Rn(e);if(!t)return null;let r=JSON.parse(T(t,"indexer package manifest")).bin;if(!r)return null;if(typeof r=="string")return K(bn(t),r);for(let i of Ue(e)){let a=r[i];if(a)return K(bn(t),a)}return null}function Rn(e){if(!e.bundledNpmPackage)return null;try{return ri.resolve(`${e.bundledNpmPackage}/package.json`)}catch{return null}}function In(e,t){for(let n of e.projectLocalBinaries??[]){let r=K(t,n);if(ge(r))return r}return null}function vn(e,t){for(let n of e.projectLocalBinaries??[]){let r=K(t,n);if(ge(r))return Fn(t,n,r)}return null}function En(e,t){let n=oi(e,t);if(!n||n.canonicalPath!==t.canonicalPath||n.sha256!==t.sha256||n.size!==t.size||n.mtimeMs!==t.mtimeMs||n.device!==t.device||n.inode!==t.inode||n.executable!==t.executable)throw new Error(`refusing changed project-local indexer ${t.relativePath}; review the current file and rerun with --trust-project-tools`)}function oi(e,t){try{return Fn(e,t.relativePath,t.configuredPath)}catch{return null}}function Fn(e,t,n){let r={maxBytes:268435456,inputKind:"project-local indexer"},i=Ft(e,t,r),a=jt(e,t,r),o=ei(i.absolutePath);return{configuredPath:n,canonicalPath:i.absolutePath,relativePath:t,sha256:Zr("sha256").update(a).digest("hex"),size:i.size,mtimeMs:i.mtimeMs,device:i.device,inode:i.inode,executable:(o.mode&73)!==0}}function jn(e,t=process.env,n=e.indexerBinary){if(e.indexerBinary!=="scip-dotnet"||wn(n,t))return t;let r=si(n,t);return r?{...t,DOTNET_ROOT:r}:t}function si(e,t){for(let n of ci(t))if(wn(e,{...t,DOTNET_ROOT:n}))return n;return null}function ci(e){let t=[],n=e.DOTNET_ROOT;if(n&&ge(n)&&t.push(n),ni()==="darwin"&&ae("brew"))try{let r=Pn("brew",["--prefix","dotnet@9"],{stdio:"pipe",env:e,timeout:1e4,killSignal:"SIGKILL"}).toString().trim(),i=K(r,"libexec");ge(i)&&!t.includes(i)&&t.push(i)}catch{}return t}function wn(e,t){try{return Pn(e,["--version"],{stdio:"pipe",env:t,timeout:1e4,killSignal:"SIGKILL"}),!0}catch{return!1}}var Tn=Lt({kind:"file-dependency-graph",invalidation:se("file-dependency-graph"),serialize:e=>JSON.stringify(e),deserialize:mi}),di=kt("file-dep-graph",{clearGroups:["whole-project"]});function C(e,t,n={}){let r=n.scipEdges??"all-references",i=n.sourceEdges??"imports-only",a=pi(t,r,i);return di.get(e,a,()=>{let o=new Set(_(e,{includeIgnored:!1})),s=Ot(e),d=0,c=0,l=null,u=!1,p=0,h=0;return j("file-dep-graph.product",()=>{if(s){let f=Tn.read(e,a,s);if(f){u=!0;let S=fi(f);return d=f.sourceFileCount,c=f.sourceEdgeCount,p=f.scipEdgeCount,h=S.size,l=f.sourceDependencyFingerprint,S}}let g=j("file-dep-graph.source-imports",()=>{let f=li(e,o,t,i);return d=f.files.length,c=f.edges.length,l=f.fingerprint,f},()=>({scope:t??null,sourceEdges:i,files:d,edges:c})),m=new Map,b=(f,S)=>bi(e,m,o,f,S);j("file-dep-graph.scip-edges",()=>{for(let f of Si(e,t,r))p+=1,b(f.from_file,f.to_file)},()=>({scope:t??null,edges:p}));for(let f of g.edges)b(f.fromFile,f.toFile);return h=m.size,s&&Tn.write(e,a,s,{sourceDependencyFingerprint:g.fingerprint,sourceFileCount:g.files.length,sourceEdgeCount:g.edges.length,scipEdgeCount:p,graph:gi(m)}),m},()=>({scope:t??null,available:s!==null,hit:u,files:d,sourceEdges:c,sourceEdgeMode:i,scipEdges:p,graphFiles:h,sourceDependencyFingerprint:l}))})}function li(e,t,n,r){let i=[],a=[];for(let o of t)if(!(n&&!o.includes(n))){i.push(o);for(let s of Ct(e,o))s.sourcePath&&a.push({fromFile:o,toFile:s.sourcePath});if(r==="imports-and-reexports")for(let s of Nt(e,o))s.sourcePath&&a.push({fromFile:o,toFile:s.sourcePath})}return{files:i,edges:a,fingerprint:ui(i,a)}}function ui(e,t){let n=t.map(r=>`${r.fromFile}\0${r.toFile}`).sort();return q(JSON.stringify({files:e,edges:n}))}function pi(e,t,n){return`edge-mode-v3:${t}:${n}:${e??"<all>"}`}function gi(e){return[...e].map(([t,n])=>[t,[...n]])}function fi(e){return new Map(e.graph.map(([t,n])=>[t,new Set(n)]))}function mi(e){let t=JSON.parse(e);return hi(t)?t:null}function hi(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.sourceDependencyFingerprint=="string"&&typeof t.sourceFileCount=="number"&&typeof t.sourceEdgeCount=="number"&&typeof t.scipEdgeCount=="number"&&Array.isArray(t.graph)&&t.graph.every(yi)}function yi(e){return Array.isArray(e)&&e.length===2&&typeof e[0]=="string"&&Array.isArray(e[1])&&e[1].every(t=>typeof t=="string")}function Si(e,t,n){let r=t?"AND d1.relative_path LIKE ?":"",i=t?[`%${t}%`]:[],a=n==="imports-only"?"AND m.role = 2":"AND m.role != 1";return e.all(`SELECT DISTINCT
2
2
  d1.relative_path AS from_file,
3
3
  d2.relative_path AS to_file
4
4
  FROM mentions m
@@ -16,7 +16,7 @@ import{a as te,b as ne}from"./chunk-64RFXJT5.js";import{a as Bt}from"./chunk-P5X
16
16
  WHERE d1.id != d2.id
17
17
  ${a}
18
18
  ${e.pathExclusionsFor("d1","d2")}
19
- ${r}`,...i)}function kr(e,t,n,r,i){if(r===i||e.isIgnored(r)||e.isIgnored(i)||!n.has(i))return;let a=t.get(r);a||(a=new Set,t.set(r,a)),a.add(i)}function de(e){let t=ce(e.projectFiles),n=new Set(t),r=new Map(e.snapshot.files.map(u=>[u.path,u])),i=e.snapshot.files.filter(u=>{let g=Y(u.path,["typescript"]);return g==="config"||g==="ambient"}).map(u=>u.path),a=ce([...t,...i]),s=a.find(u=>!r.has(u)),o=new Set(e.snapshot.files.map(u=>u.path)).size!==e.snapshot.files.length,d=!s&&a.some(u=>Qt(r.get(u))),c=$(JSON.stringify({pnpmWorkspaces:e.snapshot.pnpmWorkspaces,typescriptProjectMode:e.snapshot.typescriptProjectMode,typescriptProjects:ce(e.snapshot.typescriptProjects),membership:t})),l=new Map;return{identityFor(u,g){if(!n.has(u))return N("target-outside-project");if(o)return N("duplicate-input-path");if(s)return N("missing-input-fingerprint");if(d)return N("unreadable-input");let m=[],p,y;if(e.graph===null)m.push("dependency-graph-unavailable"),y="whole-project",p=a;else{let h=Mr(u,e.graph,l);if(h.find(P=>!r.has(P)))return N("missing-input-fingerprint");if(p=ce([...h,...i]),p.some(P=>Qt(r.get(P))))return N("unreadable-input");y="dependency-closure"}let b=p.map(h=>Ar(r.get(h)));return{version:1,key:$(JSON.stringify({version:1,engineIdentity:e.engineIdentity,schemaVersion:g,projectIdentity:c,inputs:b})),mode:y,inputFiles:p,reasons:m}}}}function Or(e,t){let n=new Set,r=[e];for(let i=0;i<r.length;i+=1){let a=r[i];if(!(a===void 0||n.has(a))){n.add(a);for(let s of[...t.get(a)??[]].sort())n.has(s)||r.push(s)}}return[...n].sort()}function Mr(e,t,n){let r=n.get(e);if(r)return r;let i=Or(e,t);return n.set(e,i),i}function Ar(e){return{path:e.path,size:e.size,hash:e.hash}}function Qt(e){return e.size<0||e.hash==="unreadable"}function N(e){return{version:1,key:null,mode:"unkeyed",inputFiles:[],reasons:[e]}}function ce(e){return[...new Set(e)].sort()}var zs=ut("typescript-semantic-identity-context",{clearGroups:["whole-project"]});function Yt(e){return D(e,{includeIgnored:!1}).filter(G).sort()}var Nr="typescript-reference-fragment-v2",Cr=gt({kind:"typescript-reference-fragments",invalidation:ee("typescript-reference-fragments"),serialize:e=>JSON.stringify(e),deserialize:Lr});function Kt(e,t,n,r=e){let i=Yt(e),a=de({projectFiles:i,snapshot:t,graph:A(e),engineIdentity:yt()}),s=[...n].map(([o,d])=>({relativePath:o,contentHash:a.identityFor(o,Nr).key,value:[...d]}));if(s.some(o=>o.contentHash===null))throw new Error("TypeScript reference fragment identity is unavailable for an affected document.");return Cr.writeBatch(r,s.map(o=>({...o,contentHash:o.contentHash}))),s.length}function Lr(e){try{let t=JSON.parse(e);return!Array.isArray(t)||!t.every($r)?null:t}catch{return null}}function $r(e){if(!e||typeof e!="object")return!1;let t=e,n=t.location;return typeof t.targetSymbol=="string"&&!!n&&typeof n.file=="string"&&typeof n.line=="number"&&typeof n.column=="number"}import{createHash as Gr}from"crypto";import{appendFileSync as Ur,existsSync as nn,mkdirSync as Jr,readFileSync as ao,renameSync as Hr,rmSync as _e,statSync as Wr}from"fs";import{dirname as rn,join as en}from"path";function De(e){let t=new Set;for(let n of e.uncertainty)t.add(n);e.projectIdentityChanged&&t.add("project-identity-changed");for(let n of e.changes)n.kind==="added"&&t.add("file-added"),n.kind==="deleted"&&t.add("file-deleted"),n.inputKind==="config"&&t.add("configuration-changed"),n.inputKind==="ambient"&&t.add("ambient-declaration-changed"),n.inputKind==="other"&&t.add("unclassified-input");return{fullProject:t.size>0,reasons:[...t].sort()}}function le(e,t,n){let r=e.changes.map(o=>o.path).sort();if(r.length===0&&!e.projectIdentityChanged&&e.uncertainty.length===0)return{mode:"none",changedFiles:r,affectedFiles:[],reasons:[]};let i=new Set(n),a=De(e),s=new Set(a.reasons);return r.some(o=>!i.has(o))&&s.add("changed-file-outside-project"),t===null?(s.add("dependency-graph-unavailable"),Zt(r,i,s)):s.size>0?Zt(r,i,s):{mode:"closure",changedFiles:r,affectedFiles:Br(r,t,i),reasons:[]}}function Zt(e,t,n){return{mode:"full-project",changedFiles:e,affectedFiles:[...t].sort(),reasons:[...n].sort()}}function Br(e,t,n){let r=new Map;for(let[s,o]of t)if(n.has(s))for(let d of o){if(!n.has(d))continue;let c=r.get(d)??new Set;c.add(s),r.set(d,c)}let i=new Set(e),a=[...e];for(let s=0;s<a.length;s+=1){let o=a[s];if(o!==void 0)for(let d of r.get(o)??[])i.has(d)||(i.add(d),a.push(d))}return[...i].sort()}var qr="<global-symbols>";function zr(e){let t=[];for(let n of e.all(`
19
+ ${r}`,...i)}function bi(e,t,n,r,i){if(r===i||e.isIgnored(r)||e.isIgnored(i)||!n.has(i))return;let a=t.get(r);a||(a=new Set,t.set(r,a)),a.add(i)}function he(e){let t=me(e.projectFiles),n=new Set(t),r=new Map(e.snapshot.files.map(u=>[u.path,u])),i=e.snapshot.files.filter(u=>{let p=ne(u.path,["typescript"]);return p==="config"||p==="ambient"}).map(u=>u.path),a=me([...t,...i]),o=a.find(u=>!r.has(u)),s=new Set(e.snapshot.files.map(u=>u.path)).size!==e.snapshot.files.length,d=!o&&a.some(u=>_n(r.get(u))),c=q(JSON.stringify({pnpmWorkspaces:e.snapshot.pnpmWorkspaces,typescriptProjectMode:e.snapshot.typescriptProjectMode,typescriptProjects:me(e.snapshot.typescriptProjects),membership:t})),l=new Map;return{identityFor(u,p){if(!n.has(u))return $("target-outside-project");if(s)return $("duplicate-input-path");if(o)return $("missing-input-fingerprint");if(d)return $("unreadable-input");let h=[],g,m;if(e.graph===null)h.push("dependency-graph-unavailable"),m="whole-project",g=a;else{let S=xi(u,e.graph,l);if(S.find(R=>!r.has(R)))return $("missing-input-fingerprint");if(g=me([...S,...i]),g.some(R=>_n(r.get(R))))return $("unreadable-input");m="dependency-closure"}let b=g.map(S=>Ri(r.get(S)));return{version:1,key:q(JSON.stringify({version:1,engineIdentity:e.engineIdentity,schemaVersion:p,projectIdentity:c,inputs:b})),mode:m,inputFiles:g,reasons:h}}}}function Pi(e,t){let n=new Set,r=[e];for(let i=0;i<r.length;i+=1){let a=r[i];if(!(a===void 0||n.has(a))){n.add(a);for(let o of[...t.get(a)??[]].sort())n.has(o)||r.push(o)}}return[...n].sort()}function xi(e,t,n){let r=n.get(e);if(r)return r;let i=Pi(e,t);return n.set(e,i),i}function Ri(e){return{path:e.path,size:e.size,hash:e.hash}}function _n(e){return e.size<0||e.hash==="unreadable"}function $(e){return{version:1,key:null,mode:"unkeyed",inputFiles:[],reasons:[e]}}function me(e){return[...new Set(e)].sort()}var Fs=Mt("typescript-semantic-identity-context",{clearGroups:["whole-project"]});function Dn(e){return _(e,{includeIgnored:!1}).filter(z).sort()}var Ii="typescript-reference-fragment-v2",vi=At({kind:"typescript-reference-fragments",invalidation:se("typescript-reference-fragments"),serialize:e=>JSON.stringify(e),deserialize:Ei});function kn(e,t,n,r=e){let i=Dn(e),a=he({projectFiles:i,snapshot:t,graph:C(e),engineIdentity:$t()}),o=[...n].map(([s,d])=>({relativePath:s,contentHash:a.identityFor(s,Ii).key,value:[...d]}));if(o.some(s=>s.contentHash===null))throw new Error("TypeScript reference fragment identity is unavailable for an affected document.");return vi.writeBatch(r,o.map(s=>({...s,contentHash:s.contentHash}))),o.length}function Ei(e){try{let t=JSON.parse(e);return!Array.isArray(t)||!t.every(Fi)?null:t}catch{return null}}function Fi(e){if(!e||typeof e!="object")return!1;let t=e,n=t.location;return typeof t.targetSymbol=="string"&&!!n&&typeof n.file=="string"&&typeof n.line=="number"&&typeof n.column=="number"}import{createHash as wi}from"crypto";import{existsSync as Ti}from"fs";import{dirname as _i,join as On}from"path";function He(e){let t=new Set;for(let n of e.uncertainty)t.add(n);e.projectIdentityChanged&&t.add("project-identity-changed");for(let n of e.changes)n.kind==="added"&&t.add("file-added"),n.kind==="deleted"&&t.add("file-deleted"),n.inputKind==="config"&&t.add("configuration-changed"),n.inputKind==="ambient"&&t.add("ambient-declaration-changed"),n.inputKind==="other"&&t.add("unclassified-input");return{fullProject:t.size>0,reasons:[...t].sort()}}function ye(e,t,n){let r=e.changes.map(s=>s.path).sort();if(r.length===0&&!e.projectIdentityChanged&&e.uncertainty.length===0)return{mode:"none",changedFiles:r,affectedFiles:[],reasons:[]};let i=new Set(n),a=He(e),o=new Set(a.reasons);return r.some(s=>!i.has(s))&&o.add("changed-file-outside-project"),t===null?(o.add("dependency-graph-unavailable"),Mn(r,i,o)):o.size>0?Mn(r,i,o):{mode:"closure",changedFiles:r,affectedFiles:ji(r,t,i),reasons:[]}}function Mn(e,t,n){return{mode:"full-project",changedFiles:e,affectedFiles:[...t].sort(),reasons:[...n].sort()}}function ji(e,t,n){let r=new Map;for(let[o,s]of t)if(n.has(o))for(let d of s){if(!n.has(d))continue;let c=r.get(d)??new Set;c.add(o),r.set(d,c)}let i=new Set(e),a=[...e];for(let o=0;o<a.length;o+=1){let s=a[o];if(s!==void 0)for(let d of r.get(s)??[])i.has(d)||(i.add(d),a.push(d))}return[...i].sort()}var Di="<global-symbols>";function ki(e){let t=[];for(let n of e.all(`
20
20
  SELECT relative_path, language, position_encoding, text
21
21
  FROM documents
22
22
  `))t.push({relativePath:n.relative_path,kind:"document",values:[n.language,n.position_encoding,n.text]});for(let n of e.all(`
@@ -43,7 +43,7 @@ import{a as te,b as ne}from"./chunk-64RFXJT5.js";import{a as Bt}from"./chunk-P5X
43
43
  FROM defn_enclosing_ranges r
44
44
  JOIN documents d ON d.id = r.document_id
45
45
  JOIN global_symbols g ON g.id = r.symbol_id
46
- `))t.push({relativePath:n.relative_path,kind:"definition",values:Te(n,[n.start_line,n.start_char,n.end_line,n.end_char])});for(let n of e.all(`
46
+ `))t.push({relativePath:n.relative_path,kind:"definition",values:Je(n,[n.start_line,n.start_char,n.end_line,n.end_char])});for(let n of e.all(`
47
47
  SELECT d.relative_path,
48
48
  c.chunk_index,
49
49
  m.role,
@@ -58,7 +58,7 @@ import{a as te,b as ne}from"./chunk-64RFXJT5.js";import{a as Bt}from"./chunk-P5X
58
58
  JOIN chunks c ON c.id = m.chunk_id
59
59
  JOIN documents d ON d.id = c.document_id
60
60
  JOIN global_symbols g ON g.id = m.symbol_id
61
- `))t.push({relativePath:n.relative_path,kind:"mention",values:Te(n,[n.chunk_index,n.role])});for(let n of e.all(`
61
+ `))t.push({relativePath:n.relative_path,kind:"mention",values:Je(n,[n.chunk_index,n.role])});for(let n of e.all(`
62
62
  SELECT g.symbol,
63
63
  g.display_name,
64
64
  g.kind,
@@ -72,9 +72,8 @@ import{a as te,b as ne}from"./chunk-64RFXJT5.js";import{a as Bt}from"./chunk-P5X
72
72
  ) AND NOT EXISTS (
73
73
  SELECT 1 FROM mentions m WHERE m.symbol_id = g.id
74
74
  )
75
- `))t.push({relativePath:qr,kind:"global-symbol",values:Te(n)});return Xr(t)}function Xr(e){let t=new Map;for(let r of e){let i=JSON.stringify([r.kind,r.values]),a=t.get(r.relativePath)??[];a.push(i),t.set(r.relativePath,a)}let n=new Map;for(let[r,i]of[...t].sort(([a],[s])=>a.localeCompare(s))){let a=Gr("sha256");for(let s of i.sort())a.update(String(Buffer.byteLength(s))),a.update(":"),a.update(s),a.update(`
76
- `);n.set(r,a.digest("hex"))}return n}function Vr(e,t){let n=[],r=[],i=[],a=[],s=new Set([...e.keys(),...t.keys()]);for(let o of[...s].sort()){let d=e.get(o),c=t.get(o);d===void 0?n.push(o):c===void 0?i.push(o):d!==c?r.push(o):a.push(o)}return{addedFiles:n,modifiedFiles:r,deletedFiles:i,changedFiles:[...n,...r,...i].sort(),unchangedFiles:a}}function ke(e,t,n){let r=new Set(e.affectedFiles),i=new Set(t.changedFiles),a=e.mode==="full-project"?[]:t.changedFiles.filter(d=>!r.has(d)),s=e.affectedFiles.filter(d=>!i.has(d)).sort(),o=t.changedFiles.length-a.length;return{passed:a.length===0,recall:t.changedFiles.length===0?1:o/t.changedFiles.length,affectedRatio:n===0?0:e.affectedFiles.length/n,predictedFiles:[...e.affectedFiles].sort(),actualFiles:[...t.changedFiles],missingFiles:a,extraFiles:s}}function Oe(e,t=ti){let n=t.now();if(!t.databaseExists(e.previousDbPath))return ue(e.refreshResult,"prior-index-unavailable",n,t.now());if(!t.databaseExists(e.candidateDbPath))return ue(e.refreshResult,"candidate-index-unavailable",n,t.now());let r=null,i=null;try{r=t.openDatabase(e.projectRoot,e.previousDbPath,e.previousIndexPath),i=t.openDatabase(e.projectRoot,e.candidateDbPath,e.candidateIndexPath);let a=[...new Set([...t.indexedPaths(r),...t.indexedPaths(i)])].sort(),s=K(e.previousSnapshot,e.currentSnapshot),o=new Set(a),d=s.changes.length>0&&!De(s).fullProject&&s.changes.every(g=>o.has(g.path)),c=le(s,d?t.dependencyGraph(r):new Map,a),l=Vr(t.factDigests(r),t.factDigests(i)),u=t.now();return{version:1,status:"evaluated",refreshResult:e.refreshResult,recordedAt:new Date(u).toISOString(),durationMs:Math.max(0,u-n),manifest:s,plan:c,comparison:l,evaluation:ke(c,l,a.length)}}catch(a){return ue(e.refreshResult,"oracle-error",n,t.now(),a instanceof Error?a.message:String(a))}finally{tn(r),tn(i)}}function an(e,t,n,r=Date.now()){return ue(e,t,r,r,n)}function Qr(e){let t=rn(e);return{latestPath:en(t,"affected-shadow-latest.json"),historyPath:en(t,"affected-shadow.jsonl")}}function sn(e,t,n=ni){let r=Qr(e);return n.appendHistory(r.historyPath,t),n.writeLatest(r.latestPath,t),r}var Yr=8*1024*1024,Kr=".previous";function Zr(e){let t={historyVersion:1,sourceVersion:e.version,refreshResult:e.refreshResult,recordedAt:e.recordedAt,durationMs:e.durationMs};return e.status==="unavailable"?{...t,status:"unavailable",reason:e.reason,...e.error?{error:e.error}:{}}:{...t,status:"evaluated",mode:e.plan.mode,passed:e.evaluation.passed,recall:e.evaluation.recall,affectedRatio:e.evaluation.affectedRatio,predictedFileCount:e.evaluation.predictedFiles.length,actualFileCount:e.evaluation.actualFiles.length,missingFileCount:e.evaluation.missingFiles.length,fallbackReasons:[...e.plan.reasons]}}function ei(e,t,n=Yr){let r=`${JSON.stringify(Zr(t))}
77
- `,i=Math.max(1,Math.floor(n)),a=`${e}${Kr}`;if(Jr(rn(e),{recursive:!0}),nn(e)){let s=Wr(e).size;s>i?(_e(e,{force:!0}),_e(a,{force:!0})):s+Buffer.byteLength(r)>i&&(_e(a,{force:!0}),Hr(e,a))}Ur(e,r)}function Te(e,t=[]){let n=[];for(let r of t)n.push(r);return n.push(e.symbol,e.display_name,e.kind,e.documentation,e.signature_hex,e.enclosing_symbol,e.relationships_hex),n}var ti={now:()=>Date.now(),databaseExists:e=>nn(e),openDatabase:(e,t,n)=>new T({projectRoot:e,dbPath:t,indexPath:n}),indexedPaths:e=>D(e),dependencyGraph:e=>A(e),factDigests:e=>zr(e)},ni={appendHistory:ei,writeLatest:(e,t)=>O(e,t,{spacing:2,trailingNewline:!0})};function ue(e,t,n,r,i){return{version:1,status:"unavailable",refreshResult:e,recordedAt:new Date(r).toISOString(),durationMs:Math.max(0,r-n),reason:t,...i?{error:i}:{}}}function tn(e){try{e?.close()}catch{}}import{existsSync as on,readdirSync as ri}from"fs";import{isAbsolute as ii,join as Me,resolve as ai}from"path";var si={typescript:{language:"typescript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,pnpmWorkspaces:t,indexerBinary:n,projectPath:r})=>{let i=r?["index","--output",e,"--no-progress-bar",r]:["index","--infer-tsconfig","--output",e,"--no-progress-bar"];return t&&!r&&i.splice(1,0,"--pnpm-workspaces"),{binary:n,args:i}},markerFiles:["tsconfig.json"],installMethods:[{label:"npm",prerequisite:"npm",binary:"npm",args:["install","-g","@sourcegraph/scip-typescript"]}],installUrl:"https://github.com/sourcegraph/scip-typescript",bundledNpmPackage:"@sourcegraph/scip-typescript"},javascript:{language:"javascript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,indexerBinary:t})=>({binary:t,args:["index","--infer-tsconfig","--output",e,"--no-progress-bar"]}),markerFiles:["package.json"],installMethods:[{label:"npm",prerequisite:"npm",binary:"npm",args:["install","-g","@sourcegraph/scip-typescript"]}],installUrl:"https://github.com/sourcegraph/scip-typescript",bundledNpmPackage:"@sourcegraph/scip-typescript"},java:{language:"java",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:["pom.xml","build.gradle"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},scala:{language:"scala",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:["build.sbt"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},kotlin:{language:"kotlin",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:["build.gradle.kts"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},rust:{language:M.language,indexerBinary:M.indexerBinary,checkCommand:`${M.indexerBinary} --version`,indexArgs:({outputPath:e})=>({binary:M.indexerBinary,args:["scip",".","--output",e]}),markerFiles:["Cargo.toml"],installMethods:[{label:"rustup",prerequisite:"rustup",binary:"rustup",args:["component","add","rust-analyzer"]}],installUrl:M.installUrl},python:{language:"python",indexerBinary:"scip-python-plus",binaryAliases:["scip-python"],checkCommand:"scip-python-plus --version",indexArgs:({outputPath:e,indexerBinary:t})=>({binary:t,args:["index","--output",e,"--project-name","project"]}),markerFiles:["pyproject.toml","setup.py"],installMethods:[{label:"npm",prerequisite:"npm",binary:"npm",args:["install","-g","scip-python-plus"]}],installUrl:"https://github.com/PlunderStruck/scip-python",bundledNpmPackage:"scip-python-plus"},clojure:{language:"clojure",indexerBinary:"scip-clojure",projectLocalBinaries:["node_modules/.bin/scip-clojure"],checkCommand:"scip-clojure -h",indexArgs:({projectRoot:e,outputPath:t,indexerBinary:n,configPath:r})=>{let i=["-root",e,"-output",t];return r&&i.push("-config",ii(r)?r:ai(e,r)),{binary:n,args:i}},markerFiles:["deps.edn","project.clj","bb.edn","shadow-cljs.edn"],installMethods:[],installUrl:"https://github.com/PlunderStruck/scip-clojure"},ruby:{language:"ruby",indexerBinary:"scip-ruby",checkCommand:"scip-ruby --version",indexArgs:({indexerBinary:e})=>({binary:e,args:["--dir","."]}),defaultOutputPath:"index.scip",markerFiles:["Gemfile"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-ruby/releases"},go:{language:"go",indexerBinary:"scip-go",checkCommand:"scip-go --version",indexArgs:({outputPath:e})=>({binary:"scip-go",args:["--output",e]}),markerFiles:["go.mod"],installMethods:[{label:"go install",prerequisite:"go",binary:"go",args:["install","github.com/sourcegraph/scip-go@latest"]}],installUrl:"https://github.com/sourcegraph/scip-go"},cpp:{language:"cpp",indexerBinary:"scip-clang",checkCommand:"scip-clang --version",indexArgs:({outputPath:e})=>({binary:"scip-clang",args:["--compdb-path","compile_commands.json","--index-output-path",e]}),markerFiles:["CMakeLists.txt","Makefile"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-clang/releases"},c:{language:"c",indexerBinary:"scip-clang",checkCommand:"scip-clang --version",indexArgs:({outputPath:e})=>({binary:"scip-clang",args:["--compdb-path","compile_commands.json","--index-output-path",e]}),markerFiles:["CMakeLists.txt","Makefile"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-clang/releases"},csharp:{language:"csharp",indexerBinary:"scip-dotnet",checkCommand:"scip-dotnet --version",indexArgs:({projectRoot:e,outputPath:t})=>({binary:"scip-dotnet",args:["index",cn(e,[".sln",".csproj"])??e,"--output",t,"--working-directory",e]}),markerFiles:["*.csproj","*.sln"],installMethods:[{label:"dotnet",prerequisite:"dotnet",binary:"dotnet",args:["tool","install","--global","scip-dotnet"]}],installUrl:"https://github.com/sourcegraph/scip-dotnet/releases"},vb:{language:"vb",indexerBinary:"scip-dotnet",checkCommand:"scip-dotnet --version",indexArgs:({projectRoot:e,outputPath:t})=>({binary:"scip-dotnet",args:["index",cn(e,[".sln",".vbproj"])??e,"--output",t,"--working-directory",e]}),markerFiles:["*.vbproj","*.sln"],installMethods:[{label:"dotnet",prerequisite:"dotnet",binary:"dotnet",args:["tool","install","--global","scip-dotnet"]}],installUrl:"https://github.com/sourcegraph/scip-dotnet/releases"},dart:{language:"dart",indexerBinary:"scip-dart",checkCommand:"scip-dart --version",indexArgs:({indexerBinary:e,outputPath:t})=>({binary:e,args:["--output",t]}),markerFiles:["pubspec.yaml"],installMethods:[{label:"dart pub",prerequisite:"dart",binary:"dart",args:["pub","global","activate","scip_dart"]}],installUrl:"https://github.com/Workiva/scip-dart/releases"},php:{language:"php",indexerBinary:"scip-php",projectLocalBinaries:["vendor/davidrjenni/scip-php/bin/scip-php","vendor/bin/scip-php"],checkCommand:"scip-php --version",indexArgs:({projectRoot:e,indexerBinary:t})=>{let n=Me(e,"vendor","bin","scip-php"),r=Me(e,"vendor","davidrjenni","scip-php","bin","scip-php");return{binary:"php",args:["-d","error_reporting=E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED",on(r)?r:on(n)?n:t]}},defaultOutputPath:"index.scip",markerFiles:["composer.json"],installMethods:[],installUrl:"https://github.com/davidrjenni/scip-php/releases"}};function Ae(e){return si[e]}function cn(e,t){let n;try{n=ri(e)}catch{return null}for(let r of t)for(let i of n)if(i.endsWith(r))return Me(e,i);return null}import{createHash as oi}from"crypto";import{copyFileSync as ci,existsSync as dn,rmSync as ln}from"fs";import{resolve as di}from"path";import gn from"better-sqlite3";var li={documents:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"language",type:"TEXT",notnull:0,pk:0},{name:"relative_path",type:"TEXT",notnull:1,pk:0},{name:"position_encoding",type:"TEXT",notnull:0,pk:0},{name:"text",type:"TEXT",notnull:0,pk:0}],chunks:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"document_id",type:"INTEGER",notnull:1,pk:0},{name:"chunk_index",type:"INTEGER",notnull:1,pk:0},{name:"start_line",type:"INTEGER",notnull:1,pk:0},{name:"end_line",type:"INTEGER",notnull:1,pk:0},{name:"occurrences",type:"BLOB",notnull:1,pk:0}],global_symbols:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"symbol",type:"TEXT",notnull:1,pk:0},{name:"display_name",type:"TEXT",notnull:0,pk:0},{name:"kind",type:"INTEGER",notnull:0,pk:0},{name:"documentation",type:"TEXT",notnull:0,pk:0},{name:"signature",type:"BLOB",notnull:0,pk:0},{name:"enclosing_symbol",type:"TEXT",notnull:0,pk:0},{name:"relationships",type:"BLOB",notnull:0,pk:0}],mentions:[{name:"chunk_id",type:"INTEGER",notnull:1,pk:1},{name:"symbol_id",type:"INTEGER",notnull:1,pk:2},{name:"role",type:"INTEGER",notnull:1,pk:3}],defn_enclosing_ranges:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"document_id",type:"INTEGER",notnull:1,pk:0},{name:"symbol_id",type:"INTEGER",notnull:1,pk:0},{name:"start_line",type:"INTEGER",notnull:1,pk:0},{name:"start_char",type:"INTEGER",notnull:1,pk:0},{name:"end_line",type:"INTEGER",notnull:1,pk:0},{name:"end_char",type:"INTEGER",notnull:1,pk:0}]},ui={idx_chunks_doc_id:{table:"chunks",columns:["document_id"]},idx_chunks_line_range:{table:"chunks",columns:["document_id","start_line","end_line"]},idx_defn_enclosing_ranges_document:{table:"defn_enclosing_ranges",columns:["document_id","start_line","end_line"]},idx_defn_enclosing_ranges_symbol_id:{table:"defn_enclosing_ranges",columns:["symbol_id"]},idx_global_symbols_symbol:{table:"global_symbols",columns:["symbol"]},idx_mentions_symbol_id_role:{table:"mentions",columns:["symbol_id","role"]}};function fn(e){let t=Date.now(),n=pi(e.affectedFiles);if(gi(e.previousDbPath,e.miniDbPath,e.candidateDbPath),ln(e.candidateDbPath,{force:!0}),!dn(e.previousDbPath))throw new Error("previous SQLite generation is unavailable");if(!dn(e.miniDbPath))throw new Error("incremental SQLite mini database is unavailable");un(e.previousDbPath,"previous SQLite generation",!1),un(e.miniDbPath,"incremental SQLite mini database"),ci(e.previousDbPath,e.candidateDbPath);let r=null;try{r=new gn(e.candidateDbPath,{fileMustExist:!0}),r.pragma("busy_timeout = 5000"),r.pragma("foreign_keys = ON"),r.prepare("ATTACH DATABASE ? AS incremental").run(e.miniDbPath),Ne(r,"main","candidate SQLite generation"),Ne(r,"incremental","incremental SQLite mini database"),fi(r,n),mi(r,n.length);let i=Ce(r,"main",!0),a=_(r,"SELECT COUNT(*) AS value FROM main.documents");r.transaction(()=>{hi(r),yi(r),Si(r),e.onStage?.("after-delete"),bi(r),e.onStage?.("after-symbol-reconciliation"),Pi(r),e.onStage?.("after-insert"),xi(r),Ri(r,n.length,a),e.onStage?.("before-commit")}).immediate(),mn(r,"main","candidate SQLite generation");let d=[...vi(r)].filter(([c,l])=>i.get(c)!==l).map(([c])=>c).sort();return r.exec("DETACH DATABASE incremental"),r.close(),r=null,{candidateDbPath:e.candidateDbPath,affectedDocumentCount:n.length,changedDocumentPaths:d,durationMs:Date.now()-t}}catch(i){try{r?.close()}finally{ln(e.candidateDbPath,{force:!0})}throw new Error(`Incremental SQLite publication rejected: ${i instanceof Error?i.message:String(i)}`,{cause:i})}}function pi(e){if(e.length===0)throw new Error("incremental SQLite publication requires affected documents");let t=[...e].sort();for(let n of t)if(!n||n.startsWith("/")||n.includes("\\")||n.split("/").includes(".."))throw new Error(`invalid affected document path: ${n}`);if(new Set(t).size!==t.length)throw new Error("incremental SQLite publication contains duplicate affected documents");return t}function gi(e,t,n){let r=[e,t,n].map(i=>di(i));if(new Set(r).size!==r.length)throw new Error("previous, mini, and candidate SQLite paths must be distinct")}function un(e,t,n=!0){let r=new gn(e,{readonly:!0,fileMustExist:!0});try{Ne(r,"main",t),n&&mn(r,"main",t)}finally{r.close()}}function Ne(e,t,n){for(let[r,i]of Object.entries(li)){let s=e.prepare(`PRAGMA ${t}.table_info('${r}')`).all().map(({name:o,type:d,notnull:c,pk:l})=>({name:o,type:d.toUpperCase(),notnull:c,pk:l}));if(JSON.stringify(s)!==JSON.stringify(i))throw new Error(`${n} schema changed for table ${r}`)}for(let[r,i]of Object.entries(ui)){let a=e.prepare(`SELECT tbl_name FROM ${t}.sqlite_master WHERE type = 'index' AND name = ?`).get(r),s=e.prepare(`PRAGMA ${t}.index_info('${r}')`).all().map(o=>o.name);if(a?.tbl_name!==i.table||JSON.stringify(s)!==JSON.stringify(i.columns))throw new Error(`${n} schema changed for index ${r}`)}pn(e,t,"documents",["relative_path"],n),pn(e,t,"global_symbols",["symbol"],n)}function pn(e,t,n,r,i){if(!e.prepare(`PRAGMA ${t}.index_list('${n}')`).all().some(o=>{if(o.unique!==1)return!1;let d=e.prepare(`PRAGMA ${t}.index_info('${o.name}')`).all().map(c=>c.name);return JSON.stringify(d)===JSON.stringify(r)}))throw new Error(`${i} lost the unique ${n}(${r.join(", ")}) constraint`)}function mn(e,t,n){let r=e.prepare(`PRAGMA ${t}.integrity_check`).pluck().get();if(r!=="ok")throw new Error(`${n} failed integrity_check: ${String(r)}`);if(e.prepare(`PRAGMA ${t}.foreign_key_check`).all().length>0)throw new Error(`${n} failed foreign_key_check`)}function fi(e,t){e.exec("CREATE TEMP TABLE incremental_affected_paths (relative_path TEXT PRIMARY KEY) WITHOUT ROWID");let n=e.prepare("INSERT INTO temp.incremental_affected_paths(relative_path) VALUES (?)");e.transaction(i=>{for(let a of i)n.run(a)})(t)}function mi(e,t){let n=_(e,"SELECT COUNT(*) AS value FROM incremental.documents"),r=_(e,`SELECT COUNT(*) AS value
75
+ `))t.push({relativePath:Di,kind:"global-symbol",values:Je(n)});return Mi(t)}function Mi(e){let t=new Map;for(let r of e){let i=JSON.stringify([r.kind,r.values]),a=t.get(r.relativePath)??[];a.push(i),t.set(r.relativePath,a)}let n=new Map;for(let[r,i]of[...t].sort(([a],[o])=>a.localeCompare(o))){let a=wi("sha256");for(let o of i.sort())a.update(String(Buffer.byteLength(o))),a.update(":"),a.update(o),a.update(`
76
+ `);n.set(r,a.digest("hex"))}return n}function Oi(e,t){let n=[],r=[],i=[],a=[],o=new Set([...e.keys(),...t.keys()]);for(let s of[...o].sort()){let d=e.get(s),c=t.get(s);d===void 0?n.push(s):c===void 0?i.push(s):d!==c?r.push(s):a.push(s)}return{addedFiles:n,modifiedFiles:r,deletedFiles:i,changedFiles:[...n,...r,...i].sort(),unchangedFiles:a}}function We(e,t,n){let r=new Set(e.affectedFiles),i=new Set(t.changedFiles),a=e.mode==="full-project"?[]:t.changedFiles.filter(d=>!r.has(d)),o=e.affectedFiles.filter(d=>!i.has(d)).sort(),s=t.changedFiles.length-a.length;return{passed:a.length===0,recall:t.changedFiles.length===0?1:s/t.changedFiles.length,affectedRatio:n===0?0:e.affectedFiles.length/n,predictedFiles:[...e.affectedFiles].sort(),actualFiles:[...t.changedFiles],missingFiles:a,extraFiles:o}}function qe(e,t=Bi){let n=t.wallNow===void 0&&t.monotonicNow===void 0,r=t.monotonicNow??t.now,i=t.wallNow??t.now,a=r(),o=(c,l)=>{let u=r();return Cn(e.refreshResult,c,n?u:i(),Math.max(0,u-a),l)};if(!t.databaseExists(e.previousDbPath))return o("prior-index-unavailable");if(!t.databaseExists(e.candidateDbPath))return o("candidate-index-unavailable");let s=null,d=null;try{s=t.openDatabase(e.projectRoot,e.previousDbPath,e.previousIndexPath),d=t.openDatabase(e.projectRoot,e.candidateDbPath,e.candidateIndexPath);let c=[...new Set([...t.indexedPaths(s),...t.indexedPaths(d)])].sort(),l=re(e.previousSnapshot,e.currentSnapshot),u=new Set(c),p=l.changes.length>0&&!He(l).fullProject&&l.changes.every(b=>u.has(b.path)),h=ye(l,p?t.dependencyGraph(s):new Map,c),g=Oi(t.factDigests(s),t.factDigests(d)),m=r();return{version:1,status:"evaluated",refreshResult:e.refreshResult,recordedAt:new Date(n?m:i()).toISOString(),durationMs:Math.max(0,m-a),manifest:l,plan:h,comparison:g,evaluation:We(h,g,c.length)}}catch(c){return o("oracle-error",c instanceof Error?c.message:String(c))}finally{An(s),An(d)}}function Ln(e,t,n,r=Date.now()){return Cn(e,t,r,0,n)}function Ai(e){let t=_i(e);return{latestPath:On(t,"affected-shadow-latest.json"),historyPath:On(t,"affected-shadow.jsonl")}}function Nn(e,t,n=Gi){let r=Ai(e);return n.appendHistory(r.historyPath,t),n.writeLatest(r.latestPath,t),r}var Li=8*1024*1024,Ni=Bt;function Ci(e){let t={historyVersion:1,sourceVersion:e.version,refreshResult:e.refreshResult,recordedAt:e.recordedAt,durationMs:e.durationMs};return e.status==="unavailable"?{...t,status:"unavailable",reason:e.reason,...e.error?{error:e.error}:{}}:{...t,status:"evaluated",mode:e.plan.mode,passed:e.evaluation.passed,recall:e.evaluation.recall,affectedRatio:e.evaluation.affectedRatio,predictedFileCount:e.evaluation.predictedFiles.length,actualFileCount:e.evaluation.actualFiles.length,missingFileCount:e.evaluation.missingFiles.length,fallbackReasons:[...e.plan.reasons]}}function $i(e,t,n=Li){Gt(e,Ci(t),{maxSegmentBytes:n,previousSuffix:Ni})}function Je(e,t=[]){let n=[];for(let r of t)n.push(r);return n.push(e.symbol,e.display_name,e.kind,e.documentation,e.signature_hex,e.enclosing_symbol,e.relationships_hex),n}var Bi={now:()=>Date.now(),wallNow:()=>Date.now(),monotonicNow:P,databaseExists:e=>Ti(e),openDatabase:(e,t,n)=>new k({projectRoot:e,dbPath:t,indexPath:n}),indexedPaths:e=>_(e),dependencyGraph:e=>C(e),factDigests:e=>ki(e)},Gi={appendHistory:$i,writeLatest:(e,t)=>_t(e,t,{spacing:2,trailingNewline:!0})};function Cn(e,t,n,r,i){return{version:1,status:"unavailable",refreshResult:e,recordedAt:new Date(n).toISOString(),durationMs:r,reason:t,...i?{error:i}:{}}}function An(e){try{e?.close()}catch{}}import{readdirSync as Ui}from"fs";import{isAbsolute as $n,join as Hi,resolve as Ji}from"path";var Se="@sourcegraph/scip-typescript@0.4.0",Bn="scip-python-plus@0.7.5",Gn="github.com/sourcegraph/scip-go@v0.2.7",Un="scip-dotnet@0.2.14",Wi="scip_dart@1.6.2",qi={typescript:{language:"typescript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,pnpmWorkspaces:t,indexerBinary:n,projectPath:r})=>{let i=r?["index","--output",e,"--no-progress-bar",r]:["index","--infer-tsconfig","--output",e,"--no-progress-bar"];return t&&!r&&i.splice(1,0,"--pnpm-workspaces"),{binary:n,args:i}},markerFiles:["tsconfig.json"],installMethods:[{label:"npm",identity:Se,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",Se]}],installUrl:"https://github.com/sourcegraph/scip-typescript",bundledNpmPackage:"@sourcegraph/scip-typescript"},javascript:{language:"javascript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,indexerBinary:t})=>({binary:t,args:["index","--infer-tsconfig","--output",e,"--no-progress-bar"]}),markerFiles:["package.json"],installMethods:[{label:"npm",identity:Se,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",Se]}],installUrl:"https://github.com/sourcegraph/scip-typescript",bundledNpmPackage:"@sourcegraph/scip-typescript"},java:{language:"java",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:["pom.xml","build.gradle"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},scala:{language:"scala",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:["build.sbt"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},kotlin:{language:"kotlin",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:["build.gradle.kts"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},rust:{language:L.language,indexerBinary:L.indexerBinary,checkCommand:`${L.indexerBinary} --version`,indexArgs:({outputPath:e})=>({binary:L.indexerBinary,args:["scip",".","--output",e]}),markerFiles:["Cargo.toml"],installMethods:[],installUrl:L.installUrl},python:{language:"python",indexerBinary:"scip-python-plus",binaryAliases:["scip-python"],checkCommand:"scip-python-plus --version",indexArgs:({outputPath:e,indexerBinary:t})=>({binary:t,args:["index","--output",e,"--project-name","project"]}),markerFiles:["pyproject.toml","setup.py"],installMethods:[{label:"npm",identity:Bn,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",Bn]}],installUrl:"https://github.com/PlunderStruck/scip-python",bundledNpmPackage:"scip-python-plus"},clojure:{language:"clojure",indexerBinary:"scip-clojure",projectLocalBinaries:["node_modules/.bin/scip-clojure"],checkCommand:"scip-clojure -h",indexArgs:({projectRoot:e,outputPath:t,indexerBinary:n,configPath:r})=>{let i=["-root",e,"-output",t];return r&&i.push("-config",$n(r)?r:Ji(e,r)),{binary:n,args:i}},markerFiles:["deps.edn","project.clj","bb.edn","shadow-cljs.edn"],installMethods:[],installUrl:"https://github.com/PlunderStruck/scip-clojure"},ruby:{language:"ruby",indexerBinary:"scip-ruby",checkCommand:"scip-ruby --version",indexArgs:({indexerBinary:e})=>({binary:e,args:["--dir","."]}),defaultOutputPath:"index.scip",markerFiles:["Gemfile"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-ruby/releases"},go:{language:"go",indexerBinary:"scip-go",checkCommand:"scip-go --version",indexArgs:({outputPath:e})=>({binary:"scip-go",args:["--output",e]}),markerFiles:["go.mod"],installMethods:[{label:"go install",identity:Gn,destination:"Go bin directory (GOBIN or GOPATH/bin)",prerequisite:"go",binary:"go",args:["install",Gn]}],installUrl:"https://github.com/sourcegraph/scip-go"},cpp:{language:"cpp",indexerBinary:"scip-clang",checkCommand:"scip-clang --version",indexArgs:({outputPath:e})=>({binary:"scip-clang",args:["--compdb-path","compile_commands.json","--index-output-path",e]}),markerFiles:["CMakeLists.txt","Makefile"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-clang/releases"},c:{language:"c",indexerBinary:"scip-clang",checkCommand:"scip-clang --version",indexArgs:({outputPath:e})=>({binary:"scip-clang",args:["--compdb-path","compile_commands.json","--index-output-path",e]}),markerFiles:["CMakeLists.txt","Makefile"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-clang/releases"},csharp:{language:"csharp",indexerBinary:"scip-dotnet",checkCommand:"scip-dotnet --version",indexArgs:({projectRoot:e,outputPath:t})=>({binary:"scip-dotnet",args:["index",Hn(e,[".sln",".csproj"])??e,"--output",t,"--working-directory",e]}),markerFiles:["*.csproj","*.sln"],installMethods:[{label:"dotnet",identity:Un,destination:"dotnet global tool directory",prerequisite:"dotnet",binary:"dotnet",args:["tool","install","--global","scip-dotnet","--version","0.2.14"]}],installUrl:"https://github.com/sourcegraph/scip-dotnet/releases"},vb:{language:"vb",indexerBinary:"scip-dotnet",checkCommand:"scip-dotnet --version",indexArgs:({projectRoot:e,outputPath:t})=>({binary:"scip-dotnet",args:["index",Hn(e,[".sln",".vbproj"])??e,"--output",t,"--working-directory",e]}),markerFiles:["*.vbproj","*.sln"],installMethods:[{label:"dotnet",identity:Un,destination:"dotnet global tool directory",prerequisite:"dotnet",binary:"dotnet",args:["tool","install","--global","scip-dotnet","--version","0.2.14"]}],installUrl:"https://github.com/sourcegraph/scip-dotnet/releases"},dart:{language:"dart",indexerBinary:"scip-dart",checkCommand:"scip-dart --version",indexArgs:({indexerBinary:e,outputPath:t})=>({binary:e,args:["--output",t]}),markerFiles:["pubspec.yaml"],installMethods:[{label:"dart pub",identity:Wi,destination:"Dart pub global cache",prerequisite:"dart",binary:"dart",args:["pub","global","activate","scip_dart","1.6.2"]}],installUrl:"https://github.com/Workiva/scip-dart/releases"},php:{language:"php",indexerBinary:"scip-php",projectLocalBinaries:["vendor/davidrjenni/scip-php/bin/scip-php","vendor/bin/scip-php"],checkCommand:"scip-php --version",indexArgs:({indexerBinary:e})=>$n(e)?{binary:"php",args:["-d","error_reporting=E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED",e]}:{binary:e,args:[]},defaultOutputPath:"index.scip",markerFiles:["composer.json"],installMethods:[],installUrl:"https://github.com/davidrjenni/scip-php/releases"}};function ze(e){return qi[e]}function Hn(e,t){let n;try{n=Ui(e)}catch{return null}for(let r of t)for(let i of n)if(i.endsWith(r))return Hi(e,i);return null}import{createHash as zi}from"crypto";import{copyFileSync as Xi,existsSync as Jn,rmSync as Wn}from"fs";import{resolve as Ki}from"path";import Xn from"better-sqlite3";var Vi={documents:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"language",type:"TEXT",notnull:0,pk:0},{name:"relative_path",type:"TEXT",notnull:1,pk:0},{name:"position_encoding",type:"TEXT",notnull:0,pk:0},{name:"text",type:"TEXT",notnull:0,pk:0}],chunks:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"document_id",type:"INTEGER",notnull:1,pk:0},{name:"chunk_index",type:"INTEGER",notnull:1,pk:0},{name:"start_line",type:"INTEGER",notnull:1,pk:0},{name:"end_line",type:"INTEGER",notnull:1,pk:0},{name:"occurrences",type:"BLOB",notnull:1,pk:0}],global_symbols:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"symbol",type:"TEXT",notnull:1,pk:0},{name:"display_name",type:"TEXT",notnull:0,pk:0},{name:"kind",type:"INTEGER",notnull:0,pk:0},{name:"documentation",type:"TEXT",notnull:0,pk:0},{name:"signature",type:"BLOB",notnull:0,pk:0},{name:"enclosing_symbol",type:"TEXT",notnull:0,pk:0},{name:"relationships",type:"BLOB",notnull:0,pk:0}],mentions:[{name:"chunk_id",type:"INTEGER",notnull:1,pk:1},{name:"symbol_id",type:"INTEGER",notnull:1,pk:2},{name:"role",type:"INTEGER",notnull:1,pk:3}],defn_enclosing_ranges:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"document_id",type:"INTEGER",notnull:1,pk:0},{name:"symbol_id",type:"INTEGER",notnull:1,pk:0},{name:"start_line",type:"INTEGER",notnull:1,pk:0},{name:"start_char",type:"INTEGER",notnull:1,pk:0},{name:"end_line",type:"INTEGER",notnull:1,pk:0},{name:"end_char",type:"INTEGER",notnull:1,pk:0}]},Yi={idx_chunks_doc_id:{table:"chunks",columns:["document_id"]},idx_chunks_line_range:{table:"chunks",columns:["document_id","start_line","end_line"]},idx_defn_enclosing_ranges_document:{table:"defn_enclosing_ranges",columns:["document_id","start_line","end_line"]},idx_defn_enclosing_ranges_symbol_id:{table:"defn_enclosing_ranges",columns:["symbol_id"]},idx_global_symbols_symbol:{table:"global_symbols",columns:["symbol"]},idx_mentions_symbol_id_role:{table:"mentions",columns:["symbol_id","role"]}};function Kn(e){let t=P(),n=Qi(e.affectedFiles);if(Zi(e.previousDbPath,e.miniDbPath,e.candidateDbPath),Wn(e.candidateDbPath,{force:!0}),!Jn(e.previousDbPath))throw new Error("previous SQLite generation is unavailable");if(!Jn(e.miniDbPath))throw new Error("incremental SQLite mini database is unavailable");qn(e.previousDbPath,"previous SQLite generation",!1),qn(e.miniDbPath,"incremental SQLite mini database"),Xi(e.previousDbPath,e.candidateDbPath);let r=null;try{r=new Xn(e.candidateDbPath,{fileMustExist:!0}),r.pragma("busy_timeout = 5000"),r.pragma("foreign_keys = ON"),r.prepare("ATTACH DATABASE ? AS incremental").run(e.miniDbPath),Xe(r,"main","candidate SQLite generation"),Xe(r,"incremental","incremental SQLite mini database"),ea(r,n),ta(r,n.length);let i=Ke(r,"main",!0),a=D(r,"SELECT COUNT(*) AS value FROM main.documents");r.transaction(()=>{na(r),ra(r),ia(r),e.onStage?.("after-delete"),aa(r),e.onStage?.("after-symbol-reconciliation"),oa(r),e.onStage?.("after-insert"),sa(r),ca(r,n.length,a),e.onStage?.("before-commit")}).immediate(),Vn(r,"main","candidate SQLite generation");let d=[...da(r)].filter(([c,l])=>i.get(c)!==l).map(([c])=>c).sort();return r.exec("DETACH DATABASE incremental"),r.close(),r=null,{candidateDbPath:e.candidateDbPath,affectedDocumentCount:n.length,changedDocumentPaths:d,durationMs:P()-t}}catch(i){try{r?.close()}finally{Wn(e.candidateDbPath,{force:!0})}throw new Error(`Incremental SQLite publication rejected: ${i instanceof Error?i.message:String(i)}`,{cause:i})}}function Qi(e){if(e.length===0)throw new Error("incremental SQLite publication requires affected documents");let t=[...e].sort();for(let n of t)if(!n||n.startsWith("/")||n.includes("\\")||n.split("/").includes(".."))throw new Error(`invalid affected document path: ${n}`);if(new Set(t).size!==t.length)throw new Error("incremental SQLite publication contains duplicate affected documents");return t}function Zi(e,t,n){let r=[e,t,n].map(i=>Ki(i));if(new Set(r).size!==r.length)throw new Error("previous, mini, and candidate SQLite paths must be distinct")}function qn(e,t,n=!0){let r=new Xn(e,{readonly:!0,fileMustExist:!0});try{Xe(r,"main",t),n&&Vn(r,"main",t)}finally{r.close()}}function Xe(e,t,n){for(let[r,i]of Object.entries(Vi)){let o=e.prepare(`PRAGMA ${t}.table_info('${r}')`).all().map(({name:s,type:d,notnull:c,pk:l})=>({name:s,type:d.toUpperCase(),notnull:c,pk:l}));if(JSON.stringify(o)!==JSON.stringify(i))throw new Error(`${n} schema changed for table ${r}`)}for(let[r,i]of Object.entries(Yi)){let a=e.prepare(`SELECT tbl_name FROM ${t}.sqlite_master WHERE type = 'index' AND name = ?`).get(r),o=e.prepare(`PRAGMA ${t}.index_info('${r}')`).all().map(s=>s.name);if(a?.tbl_name!==i.table||JSON.stringify(o)!==JSON.stringify(i.columns))throw new Error(`${n} schema changed for index ${r}`)}zn(e,t,"documents",["relative_path"],n),zn(e,t,"global_symbols",["symbol"],n)}function zn(e,t,n,r,i){if(!e.prepare(`PRAGMA ${t}.index_list('${n}')`).all().some(s=>{if(s.unique!==1)return!1;let d=e.prepare(`PRAGMA ${t}.index_info('${s.name}')`).all().map(c=>c.name);return JSON.stringify(d)===JSON.stringify(r)}))throw new Error(`${i} lost the unique ${n}(${r.join(", ")}) constraint`)}function Vn(e,t,n){let r=e.prepare(`PRAGMA ${t}.integrity_check`).pluck().get();if(r!=="ok")throw new Error(`${n} failed integrity_check: ${String(r)}`);if(e.prepare(`PRAGMA ${t}.foreign_key_check`).all().length>0)throw new Error(`${n} failed foreign_key_check`)}function ea(e,t){e.exec("CREATE TEMP TABLE incremental_affected_paths (relative_path TEXT PRIMARY KEY) WITHOUT ROWID");let n=e.prepare("INSERT INTO temp.incremental_affected_paths(relative_path) VALUES (?)");e.transaction(i=>{for(let a of i)n.run(a)})(t)}function ta(e,t){let n=D(e,"SELECT COUNT(*) AS value FROM incremental.documents"),r=D(e,`SELECT COUNT(*) AS value
78
77
  FROM main.documents d
79
78
  JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path`),i=e.prepare(`SELECT p.relative_path
80
79
  FROM temp.incremental_affected_paths p
@@ -84,7 +83,7 @@ import{a as te,b as ne}from"./chunk-64RFXJT5.js";import{a as Bt}from"./chunk-P5X
84
83
  FROM incremental.documents d
85
84
  LEFT JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path
86
85
  WHERE p.relative_path IS NULL
87
- LIMIT 1`).pluck().get();if(n!==t||r!==t||i!==void 0||a!==void 0)throw new Error("incremental SQLite mini database does not exactly match the affected document set")}function hi(e){e.exec(`
86
+ LIMIT 1`).pluck().get();if(n!==t||r!==t||i!==void 0||a!==void 0)throw new Error("incremental SQLite mini database does not exactly match the affected document set")}function na(e){e.exec(`
88
87
  CREATE TEMP TABLE incremental_old_defined_symbols (symbol TEXT PRIMARY KEY) WITHOUT ROWID;
89
88
  INSERT OR IGNORE INTO temp.incremental_old_defined_symbols(symbol)
90
89
  SELECT g.symbol
@@ -111,7 +110,7 @@ import{a as te,b as ne}from"./chunk-64RFXJT5.js";import{a as Bt}from"./chunk-P5X
111
110
  FROM incremental.mentions m
112
111
  JOIN incremental.global_symbols g ON g.id = m.symbol_id
113
112
  WHERE m.role = 1;
114
- `)}function yi(e){let t=e.prepare(`WITH changed_symbols AS (
113
+ `)}function ra(e){let t=e.prepare(`WITH changed_symbols AS (
115
114
  SELECT symbol FROM temp.incremental_old_defined_symbols
116
115
  UNION
117
116
  SELECT symbol FROM temp.incremental_new_defined_symbols
@@ -134,7 +133,7 @@ import{a as te,b as ne}from"./chunk-64RFXJT5.js";import{a as Bt}from"./chunk-P5X
134
133
  SELECT u.symbol
135
134
  FROM unaffected_definitions u
136
135
  JOIN changed_symbols c ON c.symbol = u.symbol
137
- LIMIT 1`).pluck().get();if(typeof t=="string")throw new Error(`symbol definition is shared by affected and unaffected documents: ${t}`)}function Si(e){e.exec(`
136
+ LIMIT 1`).pluck().get();if(typeof t=="string")throw new Error(`symbol definition is shared by affected and unaffected documents: ${t}`)}function ia(e){e.exec(`
138
137
  DELETE FROM main.mentions
139
138
  WHERE chunk_id IN (
140
139
  SELECT c.id
@@ -156,7 +155,7 @@ import{a as te,b as ne}from"./chunk-64RFXJT5.js";import{a as Bt}from"./chunk-P5X
156
155
  );
157
156
  DELETE FROM main.documents
158
157
  WHERE relative_path IN (SELECT relative_path FROM temp.incremental_affected_paths);
159
- `)}function bi(e){e.exec(`
158
+ `)}function aa(e){e.exec(`
160
159
  UPDATE main.global_symbols
161
160
  SET display_name = NULL,
162
161
  kind = NULL,
@@ -198,7 +197,7 @@ import{a as te,b as ne}from"./chunk-64RFXJT5.js";import{a as Bt}from"./chunk-P5X
198
197
  WHERE source.symbol = main.global_symbols.symbol
199
198
  )
200
199
  WHERE symbol IN (SELECT symbol FROM temp.incremental_new_defined_symbols);
201
- `)}function Pi(e){let t=_(e,"SELECT COALESCE(MAX(id), 0) AS value FROM main.documents"),n=_(e,"SELECT COALESCE(MAX(id), 0) AS value FROM main.chunks"),r=_(e,"SELECT COALESCE(MAX(id), 0) AS value FROM main.defn_enclosing_ranges");e.prepare(`INSERT INTO main.documents(id, language, relative_path, position_encoding, text)
200
+ `)}function oa(e){let t=D(e,"SELECT COALESCE(MAX(id), 0) AS value FROM main.documents"),n=D(e,"SELECT COALESCE(MAX(id), 0) AS value FROM main.chunks"),r=D(e,"SELECT COALESCE(MAX(id), 0) AS value FROM main.defn_enclosing_ranges");e.prepare(`INSERT INTO main.documents(id, language, relative_path, position_encoding, text)
202
201
  SELECT id + ?, language, relative_path, position_encoding, text
203
202
  FROM incremental.documents`).run(t),e.prepare(`INSERT INTO main.chunks(id, document_id, chunk_index, start_line, end_line, occurrences)
204
203
  SELECT id + ?, document_id + ?, chunk_index, start_line, end_line, occurrences
@@ -213,22 +212,22 @@ import{a as te,b as ne}from"./chunk-64RFXJT5.js";import{a as Bt}from"./chunk-P5X
213
212
  r.start_line, r.start_char, r.end_line, r.end_char
214
213
  FROM incremental.defn_enclosing_ranges r
215
214
  JOIN incremental.global_symbols source ON source.id = r.symbol_id
216
- JOIN main.global_symbols target ON target.symbol = source.symbol`).run(r,t)}function xi(e){e.exec(`
215
+ JOIN main.global_symbols target ON target.symbol = source.symbol`).run(r,t)}function sa(e){e.exec(`
217
216
  DELETE FROM main.global_symbols
218
217
  WHERE NOT EXISTS (SELECT 1 FROM main.mentions m WHERE m.symbol_id = main.global_symbols.id)
219
218
  AND NOT EXISTS (
220
219
  SELECT 1 FROM main.defn_enclosing_ranges r WHERE r.symbol_id = main.global_symbols.id
221
220
  );
222
- `)}function Ri(e,t,n){let r=_(e,"SELECT COUNT(*) AS value FROM main.documents"),i=_(e,`SELECT COUNT(*) AS value
221
+ `)}function ca(e,t,n){let r=D(e,"SELECT COUNT(*) AS value FROM main.documents"),i=D(e,`SELECT COUNT(*) AS value
223
222
  FROM main.documents d
224
- JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path`);if(r!==n||i!==t)throw new Error("candidate SQLite document counts changed unexpectedly");let a=e.prepare("SELECT relative_path FROM main.documents GROUP BY relative_path HAVING COUNT(*) > 1 LIMIT 1").pluck().get(),s=e.prepare("SELECT symbol FROM main.global_symbols GROUP BY symbol HAVING COUNT(*) > 1 LIMIT 1").pluck().get();if(a!==void 0||s!==void 0)throw new Error("candidate SQLite generation contains duplicate document paths or symbols")}function vi(e){let t=Ce(e,"main",!0),n=Ce(e,"incremental",!1);if(JSON.stringify([...t])!==JSON.stringify([...n]))throw new Error("candidate SQLite affected document facts differ from the mini database");return t}function Ce(e,t,n){let r=n?"JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path":"",i=e.prepare(`SELECT d.relative_path, d.language, d.position_encoding, d.text
223
+ JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path`);if(r!==n||i!==t)throw new Error("candidate SQLite document counts changed unexpectedly");let a=e.prepare("SELECT relative_path FROM main.documents GROUP BY relative_path HAVING COUNT(*) > 1 LIMIT 1").pluck().get(),o=e.prepare("SELECT symbol FROM main.global_symbols GROUP BY symbol HAVING COUNT(*) > 1 LIMIT 1").pluck().get();if(a!==void 0||o!==void 0)throw new Error("candidate SQLite generation contains duplicate document paths or symbols")}function da(e){let t=Ke(e,"main",!0),n=Ke(e,"incremental",!1);if(JSON.stringify([...t])!==JSON.stringify([...n]))throw new Error("candidate SQLite affected document facts differ from the mini database");return t}function Ke(e,t,n){let r=n?"JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path":"",i=e.prepare(`SELECT d.relative_path, d.language, d.position_encoding, d.text
225
224
  FROM ${t}.documents d
226
225
  ${r}
227
226
  ORDER BY d.relative_path`).all(),a=e.prepare(`SELECT d.relative_path, c.chunk_index, c.start_line, c.end_line, hex(c.occurrences) AS occurrences
228
227
  FROM ${t}.chunks c
229
228
  JOIN ${t}.documents d ON d.id = c.document_id
230
229
  ${r}
231
- ORDER BY d.relative_path, c.chunk_index, c.start_line, c.end_line, c.id`).all(),s=e.prepare(`SELECT d.relative_path, r.start_line, r.start_char, r.end_line, r.end_char,
230
+ ORDER BY d.relative_path, c.chunk_index, c.start_line, c.end_line, c.id`).all(),o=e.prepare(`SELECT d.relative_path, r.start_line, r.start_char, r.end_line, r.end_char,
232
231
  g.symbol, g.display_name, g.kind, g.documentation,
233
232
  CASE WHEN g.signature IS NULL THEN NULL ELSE hex(g.signature) END AS signature,
234
233
  g.enclosing_symbol,
@@ -237,22 +236,23 @@ import{a as te,b as ne}from"./chunk-64RFXJT5.js";import{a as Bt}from"./chunk-P5X
237
236
  JOIN ${t}.documents d ON d.id = r.document_id
238
237
  JOIN ${t}.global_symbols g ON g.id = r.symbol_id
239
238
  ${r}
240
- ORDER BY d.relative_path, r.start_line, r.start_char, r.end_line, r.end_char, g.symbol`).all(),o=e.prepare(`SELECT d.relative_path, c.chunk_index, m.role, g.symbol
239
+ ORDER BY d.relative_path, r.start_line, r.start_char, r.end_line, r.end_char, g.symbol`).all(),s=e.prepare(`SELECT d.relative_path, c.chunk_index, m.role, g.symbol
241
240
  FROM ${t}.mentions m
242
241
  JOIN ${t}.chunks c ON c.id = m.chunk_id
243
242
  JOIN ${t}.documents d ON d.id = c.document_id
244
243
  JOIN ${t}.global_symbols g ON g.id = m.symbol_id
245
244
  ${r}
246
- ORDER BY d.relative_path, c.chunk_index, m.role, g.symbol`).all(),d=new Map;for(let[l,u]of Object.entries({documents:i,chunks:a,definitions:s,mentions:o}))for(let g of u){let m=JSON.stringify([l,g]),p=d.get(g.relative_path)??[];p.push(m),d.set(g.relative_path,p)}let c=new Map;for(let[l,u]of[...d].sort(([g],[m])=>g.localeCompare(m))){let g=oi("sha256");for(let m of u.sort())g.update(m).update(`
247
- `);c.set(l,g.digest("hex"))}return c}function _(e,t){return e.prepare(t).get().value}import{createHash as Ii}from"crypto";import{existsSync as Le,readFileSync as Fi,readdirSync as Ei}from"fs";import{dirname as $e,join as pe,relative as wi,resolve as Be,sep as hn}from"path";function yn(e,t){let n=t.includes("."),r={};for(let a of t)r[a]=[];let i=[];for(let a of e){let s=xn(a.path,t);s?r[s].push(a):n?r["."].push(a):i.push(a)}return{files:r,shared:i}}function Sn(e,t){let n=new Map;for(let i of e){let a=t[i]?.packageName;a&&n.set(a,i)}let r=new Map;for(let i of e)r.set(i,new Set);for(let i of e){let a=t[i],s=r.get(i);if(!a||a.parseFailed){for(let o of e)o!==i&&s.add(o);continue}for(let o of a.dependencyNames){let d=n.get(o);d&&d!==i&&s.add(d)}for(let o of[...a.pathsTargets,...a.referencesPaths]){let d=xn(o,e);d&&d!==i&&s.add(d)}}return ji(e,r)}function bn(e,t,n){let r={};for(let i of e){let a=new Map;for(let s of t.files[i]??[])a.set(s.path,s);for(let s of n[i]??[])for(let o of t.files[s]??[])a.set(o.path,o);for(let s of t.shared)a.set(s.path,s);r[i]={files:[...a.values()].sort((s,o)=>s.path.localeCompare(o.path))}}return r}function Ge(e){if(e===".")return"root";let t=Ii("sha256").update(e).digest("hex").slice(0,8);return`${e.split("/").join("__")}-${t}`}function Pn(e,t){let n=Be(e),r={};for(let i of t)r[i]=Di(n,i);return r}function xn(e,t){let n;for(let r of t)r!=="."&&(e===r||e.startsWith(`${r}/`))&&(!n||r.length>n.length)&&(n=r);return n}function ji(e,t){let n={};for(let r of e){let i=new Set,a=[...t.get(r)??[]];for(;a.length>0;){let s=a.pop();if(!(s===r||i.has(s))){i.add(s);for(let o of t.get(s)??[])o!==r&&!i.has(o)&&a.push(o)}}n[r]=[...i].sort((s,o)=>s.localeCompare(o))}return n}function Di(e,t){let n=t==="."?e:pe(e,t),r=_i(n),i=Ti(n),a=i?ki(i,e):{pathsTargets:[],referencesPaths:[],failed:!1};return{packageName:r.name,dependencyNames:r.dependencyNames,pathsTargets:a.pathsTargets,referencesPaths:a.referencesPaths,parseFailed:r.failed||a.failed}}function _i(e){let t=pe(e,"package.json");if(!Le(t))return{name:void 0,dependencyNames:[],failed:!1};let n=Ue(t);if(!n.ok)return{name:void 0,dependencyNames:[],failed:!0};let r=typeof n.value.name=="string"?n.value.name:void 0,i=new Set;for(let a of["dependencies","devDependencies","peerDependencies"]){let s=n.value[a];if(s&&typeof s=="object"&&!Array.isArray(s))for(let o of Object.keys(s))i.add(o)}return{name:r,dependencyNames:[...i],failed:!1}}function Ti(e){let t=pe(e,"tsconfig.json");if(Le(t))return t;let n;try{n=Ei(e).filter(r=>/^tsconfig.*\.json$/.test(r))}catch{return}return n.sort((r,i)=>r.localeCompare(i)),n.length>0?pe(e,n[0]):void 0}function ki(e,t){let n=Ue(e);if(!n.ok)return{pathsTargets:[],referencesPaths:[],failed:!0};let r=Oi(n.value,e,t),i=Rn(e,n.value,t,0);return{pathsTargets:i.pathsTargets,referencesPaths:r,failed:i.failed}}function Oi(e,t,n){let r=e.references;if(!Array.isArray(r))return[];let i=$e(t),a=new Set;for(let s of r){if(!s||typeof s!="object")continue;let o=s.path;if(typeof o!="string"||o.trim()==="")continue;let d=vn(o,i,n);d&&a.add(d)}return[...a]}function Rn(e,t,n,r){let i=Mi(t);if(i)return{pathsTargets:Ai(i,$e(e),n),failed:!1};if(r>=5)return{pathsTargets:[],failed:!1};let a=Ni(t.extends,e,n);if(!a)return{pathsTargets:[],failed:!1};let s=Ue(a);return s.ok?Rn(a,s.value,n,r+1):{pathsTargets:[],failed:!0}}function Mi(e){let t=e.compilerOptions;if(!t||typeof t!="object"||Array.isArray(t))return;let n=t.paths;return n&&typeof n=="object"&&!Array.isArray(n)?n:void 0}function Ai(e,t,n){let r=new Set;for(let i of Object.values(e))if(Array.isArray(i))for(let a of i){if(typeof a!="string")continue;let s=vn(a,t,n);s&&r.add(s)}return[...r]}function Ni(e,t,n){let r=Array.isArray(e)?e.at(-1):e;if(typeof r!="string"||r.trim()===""||!r.startsWith(".")&&!r.startsWith("/"))return;let i=Be($e(t),r);if(i.endsWith(".json")||(i=`${i}.json`),!i.split(hn).includes("node_modules")&&B(n,i)&&Le(i))return i}function vn(e,t,n){let r=e.replace(/\/?\*+$/,""),i=Be(t,r===""?".":r);if(!B(n,i))return;let s=wi(n,i).split(hn).join("/");return s===""?".":s}function Ci(e){let t="",n=0,r=!1,i=e.length;for(;n<i;){let a=e[n];if(r){if(t+=a,a==="\\"&&n+1<i){t+=e[n+1],n+=2;continue}a==='"'&&(r=!1),n+=1;continue}if(a==='"'){r=!0,t+=a,n+=1;continue}if(a==="/"&&e[n+1]==="/"){for(n+=2;n<i&&e[n]!==`
248
- `;)n+=1;continue}if(a==="/"&&e[n+1]==="*"){for(n+=2;n<i&&!(e[n]==="*"&&e[n+1]==="/");)n+=1;n+=2;continue}t+=a,n+=1}return t}function Ue(e){try{let t=Fi(e,"utf-8"),n=JSON.parse(Ci(t));return n&&typeof n=="object"&&!Array.isArray(n)?{ok:!0,value:n}:{ok:!1}}catch{return{ok:!1}}}import{existsSync as Li,readFileSync as $i,readdirSync as Bi,statSync as Gi}from"fs";import v from"path";var Ui=new Set([".cache",".git",".next",".nuxt",".turbo",".nx","build","coverage","dist","node_modules","tmp","vendor"]);function H(e,t=[]){let n=v.resolve(e),r=t.flatMap(d=>Hi(n,d));if(r.length>0)return In(n,Fn(r));let i=Ji(n),a=Fn(i),s=qi(n,a)?[n,...a]:a,o=s.length>0?s:[n];return In(n,o)}function In(e,t){return[...new Set(t.map(n=>Xi(e,n)))].sort((n,r)=>n.localeCompare(r))}function Ji(e){let t=[],n=[e];for(;n.length>0;){let r=n.pop(),i;try{i=Bi(r,{withFileTypes:!0})}catch{continue}for(let a of i){let s=v.join(r,a.name);if(a.isDirectory()){!Ui.has(a.name)&&!a.name.startsWith(".")&&n.push(s);continue}a.isFile()&&Wi(s)&&t.push(v.dirname(s))}}return t}function Hi(e,t){let n=t.trim();if(!n)return[];let r=v.resolve(e,n);if(!B(e,r))return[];try{let i=Gi(r);if(i.isDirectory())return[r];if(i.isFile()&&En(v.basename(r)))return[v.dirname(r)]}catch{return[]}return[]}function Wi(e){if(!En(v.basename(e)))return!1;let t=wn(e);return t?v.basename(e)==="tsconfig.json"||"include"in t||"files"in t||"references"in t:!1}function En(e){return e.startsWith("tsconfig")&&e.endsWith(".json")}function Fn(e){let t=[...new Set(e.map(n=>v.resolve(n)))].sort((n,r)=>n.localeCompare(r));return t.length<=1?t:t.filter(n=>!t.some(r=>r!==n&&Vi(n,r)))}function qi(e,t){if(t.length===0||t.some(r=>v.resolve(r)===e))return!1;let n=v.join(e,"tsconfig.json");return Li(n)&&zi(n)}function zi(e){let n=wn(e)?.include;return Array.isArray(n)?n.some(r=>typeof r=="string"&&r.trim()!==""&&!r.startsWith("!")&&(r.includes("/")||r.includes("**")||!v.extname(r))):!1}function wn(e){try{let t=JSON.parse($i(e,"utf-8"));return t&&typeof t=="object"&&!Array.isArray(t)?t:null}catch{return null}}function Xi(e,t){let n=v.relative(e,t);return n?n.split(v.sep).join("/"):"."}function Vi(e,t){let n=v.relative(e,t);return!!n&&!n.startsWith("..")&&!v.isAbsolute(n)}import{createHash as oa}from"crypto";import{existsSync as Je,readFileSync as An,statSync as ca,writeFileSync as He}from"fs";import{join as da}from"path";import{randomUUID as Qi}from"crypto";import{existsSync as Yi,mkdirSync as jn,readFileSync as Ki,rmSync as Dn}from"fs";import{resolve as _n}from"path";var Zi=12e4,ea=5,ge=class{projectRoot;cacheDir;baseGeneration;timeoutMs;runtime;constructor(t,n={}){this.projectRoot=at(t.projectRoot),this.cacheDir=t.cacheDir,this.baseGeneration=t.baseGeneration,this.timeoutMs=n.timeoutMs??aa(),this.runtime=n.runtime??sa}request(t){let n=$t(this.cacheDir),r=Nt(this.cacheDir),i=Ee(n.statePath);if(!Tn(i,this.projectRoot,this.runtime))throw new Error("Compatible TypeScript index service is not running.");let a=this.runtime.randomId(),s=_n(r.requestDir,`${a}.json`),o=_n(r.responseDir,`${a}.json`),d=this.runtime.now()+this.timeoutMs;jn(r.requestDir,{recursive:!0}),jn(r.responseDir,{recursive:!0}),O(s,{protocolVersion:ae,id:a,baseGeneration:this.baseGeneration,deadlineAtMs:d,request:t});try{for(;this.runtime.now()<=d;){if(Yi(o))return ta(Ki(o,"utf8"),a,this.baseGeneration,t.producerIdentity,t.affectedFiles);let c=Ee(n.statePath);if(!Tn(c,this.projectRoot,this.runtime))throw new Error("TypeScript index service stopped while processing a request.");this.runtime.sleep(ea)}throw new Error(`TypeScript index service timed out after ${this.timeoutMs}ms.`)}finally{Dn(s,{force:!0}),Dn(o,{force:!0})}}};function Tn(e,t,n){let r=e!==null&&n.now()-Date.parse(e.heartbeatAt)<=Lt,i=e?.typescriptIndex?.busyUntil!==void 0&&n.now()<=Date.parse(e.typescriptIndex.busyUntil);return e!==null&&e.projectRoot===t&&e.typescriptIndex?.protocolVersion===ae&&n.isProcessAlive(e.pid)&&(r||i)}function ta(e,t,n,r,i){let a=JSON.parse(e);if(a.protocolVersion!==ae||a.id!==t||a.ok===!0&&a.baseGeneration!==n)throw new Error("TypeScript index service wrote an incompatible response.");if(a.ok!==!0)throw new Error(typeof a.error=="string"?a.error:"TypeScript index service request failed.");let s=na(a.response,r),o=[...new Set(i)].sort(),d=s.fragments.map(c=>c.relativePath).sort();if(JSON.stringify(d)!==JSON.stringify(o))throw new Error("TypeScript index service omitted or added an affected document.");return s}function na(e,t){if(!e||typeof e!="object")throw new Error("TypeScript index service wrote an invalid response.");let n=e;if(n.producerIdentity!==t||typeof n.cold!="boolean"||typeof n.durationMs!="number"||!Number.isFinite(n.durationMs)||!Array.isArray(n.fragments))throw new Error("TypeScript index service wrote an invalid response.");let r=new Set,i=n.fragments.map(a=>{if(!a||typeof a.relativePath!="string"||a.bytesBase64!==null&&typeof a.bytesBase64!="string"||typeof a.occurrences!="number"||!Number.isInteger(a.occurrences)||a.occurrences<0||typeof a.symbols!="number"||!Number.isInteger(a.symbols)||a.symbols<0||!Array.isArray(a.referenceFragments)||!a.referenceFragments.every(ra)||r.has(a.relativePath))throw new Error("TypeScript index service wrote an invalid fragment.");r.add(a.relativePath);let s=a.bytesBase64===null?null:ia(a.bytesBase64);return{relativePath:a.relativePath,bytes:s,occurrences:a.occurrences,symbols:a.symbols,referenceFragments:a.referenceFragments}});return{producerIdentity:n.producerIdentity,cold:n.cold,durationMs:n.durationMs,fragments:i}}function ra(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.targetSymbol=="string"&&!!t.location&&typeof t.location.file=="string"&&Number.isInteger(t.location.line)&&Number.isInteger(t.location.column)}function ia(e){let t=Buffer.from(e,"base64");if(t.toString("base64")!==e)throw new Error("TypeScript index service wrote invalid base64.");return t}function aa(){let e=Number(process.env.SCIP_TYPESCRIPT_INDEX_TIMEOUT_MS);return Number.isInteger(e)&&e>0?e:Zi}var sa={now:Date.now,randomId:Qi,sleep(e){let t=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(t,0,0,e)},isProcessAlive:k};function la(e){let t=e.projectMode==="workspace"?e.workspaceProjects??[]:["."];if(t.length===0)return{eligible:!1,reason:"workspace project roots unavailable"};if(t.length===1&&t[0]==="."&&!e.rootTsconfigExists)return{eligible:!1,reason:"root tsconfig unavailable"};if(!e.previousSnapshot)return{eligible:!1,reason:"prior project snapshot unavailable"};if(e.graph===null)return{eligible:!1,reason:"dependency graph unavailable"};if(e.projectFiles.length===0)return{eligible:!1,reason:"prior TypeScript documents unavailable"};let n=K(e.previousSnapshot,e.currentSnapshot);if(n.changes.length===0)return{eligible:!1,reason:"no changed project inputs"};if(n.changes.some(c=>c.kind!=="modified"||c.inputKind!=="source"||!G(c.path)))return{eligible:!1,reason:"change is not a modified TypeScript source file"};let r=le(n,e.graph,e.projectFiles);if(r.mode!=="closure"||r.affectedFiles.length===0)return{eligible:!1,reason:r.reasons.length>0?`affected set widened: ${r.reasons.join(", ")}`:"empty affected set"};let i=ua([...r.changedFiles,...r.affectedFiles],t);if(!i)return{eligible:!1,reason:"affected files cross or ambiguously match TypeScript projects"};let a=kn(e.currentSnapshot,e.projectFiles,e.producerIdentity),s=kn(e.previousSnapshot,e.projectFiles,e.producerIdentity);if(a!==s)return{eligible:!1,reason:"TypeScript fragment project identity changed"};let o=Mn(e.previousSnapshot,e.projectFiles,e.graph,e.producerIdentity,e.projectFiles);if(!o)return{eligible:!1,reason:"prior document identity unavailable"};let d=Mn(e.currentSnapshot,e.projectFiles,e.graph,e.producerIdentity,r.affectedFiles);return d?{eligible:!0,manifest:n,plan:r,projectIdentity:a,previousFragmentGeneration:On(e.previousSnapshot,e.producerIdentity),nextFragmentGeneration:On(e.currentSnapshot,e.producerIdentity),previousDocumentIdentities:o,nextDocumentIdentities:d,tsconfigPath:i==="."?"tsconfig.json":`${i}/tsconfig.json`,projectArgument:i}:{eligible:!1,reason:"next document identity unavailable"}}function ua(e,t){let n=null;for(let r of e){let i=t.filter(a=>a==="."||r===a||r.startsWith(`${a}/`));if(i.length!==1||n!==null&&n!==i[0])return null;n=i[0]}return n}function Nn(e){let t=Date.now();try{if(!Je(e.previousDbPath)||!Je(e.previousShardPath))throw new Error("prior TypeScript graph or language shard unavailable");let n=performance.now(),r=Fe();if(!r.available)throw new Error(r.reason);let i=performance.now()-n;n=performance.now();let a=new T({projectRoot:e.projectRoot,dbPath:e.previousDbPath,indexPath:e.previousIndexPath}),s,o;try{s=D(a,{includeIgnored:!1}).filter(G).sort(),o=A(a)}finally{a.close()}let d=performance.now()-n,c=la({projectMode:e.projectMode,workspaceProjects:e.projectMode==="workspace"?H(e.projectRoot,e.currentSnapshot.typescriptProjects):void 0,previousSnapshot:e.previousSnapshot,currentSnapshot:e.currentSnapshot,projectFiles:s,graph:o,producerIdentity:r.producerIdentity,rootTsconfigExists:Je(da(e.projectRoot,"tsconfig.json"))});if(!c.eligible)throw new Error(c.reason);let l=Ct(e.previousDbPath);if(!l)throw new Error("published TypeScript base generation unavailable");n=performance.now();let g=new ge({projectRoot:e.projectRoot,cacheDir:e.cacheDir,baseGeneration:l}).request({kind:"emit-documents",tsconfigPath:c.tsconfigPath,projectArgument:c.projectArgument,projectIdentity:c.projectIdentity,producerIdentity:r.producerIdentity,modifiedFiles:c.plan.changedFiles,affectedFiles:c.plan.affectedFiles}),m=performance.now()-n,p=ca(e.previousShardPath).size>=wt;n=performance.now();let y=p?null:An(e.previousShardPath),b=p?{completeIndexBytes:null,affectedIndexBytes:vt(g.fragments)}:Et({packageVersion:r.packageVersion,baseIndexBytes:y,fragments:g.fragments}),f=performance.now()-n;n=performance.now(),p?jt({cacheDir:e.cacheDir,previousGenerationIdentity:c.previousFragmentGeneration,nextGenerationIdentity:c.nextFragmentGeneration,producerIdentity:r.producerIdentity,projectIdentity:c.projectIdentity,baseShardCurrent:e.baseShardCurrent,fragments:g.fragments}):(It({cacheDir:e.cacheDir,packageVersion:r.packageVersion,indexBytes:y,producerIdentity:r.producerIdentity,projectIdentity:c.projectIdentity,generationIdentity:c.previousFragmentGeneration,documentIdentities:c.previousDocumentIdentities,allowUntrackedDocuments:!0}),Ft({cacheDir:e.cacheDir,previousGenerationIdentity:c.previousFragmentGeneration,producerIdentity:r.producerIdentity,projectIdentity:c.projectIdentity,generationIdentity:c.nextFragmentGeneration,fragments:g.fragments,documentIdentities:c.nextDocumentIdentities}));let h=performance.now()-n;n=performance.now(),b.completeIndexBytes&&He(e.candidateShardPath,b.completeIndexBytes),He(e.candidateAffectedScipPath,b.affectedIndexBytes);let R=performance.now()-n,P={scipPath:p?e.previousShardPath:e.candidateShardPath,candidateScipPath:e.candidateShardPath,affectedScipPath:e.candidateAffectedScipPath,completeScipUpdated:!p,durationMs:Date.now()-t,cold:g.cold,changedFiles:c.plan.changedFiles,affectedFiles:c.plan.affectedFiles,producerIdentity:r.producerIdentity,previousFragmentGeneration:c.previousFragmentGeneration,nextFragmentGeneration:c.nextFragmentGeneration,manifest:c.manifest,plan:c.plan,projectFileCount:s.length,referenceFragmentsByFile:new Map(g.fragments.map(Q=>[Q.relativePath,Q.referenceFragments])),timings:{runtimeMs:i,graphMs:d,requestMs:m,serviceMs:g.durationMs,assemblyMs:f,fragmentStoreMs:h,writeMs:R}};return e.onStatus(`Incremental TypeScript index emitted ${P.affectedFiles.length} affected document(s) in ${(P.durationMs/1e3).toFixed(3)}s (${P.cold?"cold":"warm"} service; ${p?"whole SCIP deferred":"whole SCIP current"}; runtime ${i.toFixed(0)}ms, graph ${d.toFixed(0)}ms, request ${m.toFixed(0)}ms, assembly ${f.toFixed(0)}ms, fragments ${h.toFixed(0)}ms, write ${R.toFixed(0)}ms).`),P}catch(n){return e.onStatus(`Incremental TypeScript index unavailable: ${n instanceof Error?n.message:String(n)}. Falling back to the whole-project indexer.`),null}}function Cn(e){let t=Fe();if(!t.available)throw new Error(t.reason);let n=Dt({cacheDir:e.cacheDir,generationIdentity:e.generationIdentity,baseIndexBytes:An(e.baseShardPath),packageVersion:t.packageVersion});He(e.candidateShardPath,n)}function kn(e,t,n){let r=e.files.filter(i=>Y(i.path,e.languages)!=="source").map(i=>({path:i.path,size:i.size,hash:i.hash})).sort((i,a)=>i.path.localeCompare(a.path));return We(JSON.stringify({version:1,producerIdentity:n,pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:[...e.typescriptProjects].sort(),projectFiles:[...t].sort(),nonSourceInputs:r}))}function On(e,t){return We(JSON.stringify({version:1,producerIdentity:t,snapshot:e}))}function Mn(e,t,n,r,i){let a=new Set(e.files.map(d=>d.path)),s=de({projectFiles:t.filter(d=>a.has(d)),snapshot:e,graph:n,engineIdentity:r}),o=new Map;for(let d of i){let c=s.identityFor(d,"typescript-scip-document-v1");if(c.key){o.set(d,c.key);continue}if(a.has(d))return null;o.set(d,We(JSON.stringify({version:1,producerIdentity:r,generatedDocument:d})))}return o}function We(e){return oa("sha256").update(e).digest("hex")}import{execFile as pa}from"child_process";import{existsSync as fe,renameSync as ze,rmSync as Xe,statSync as ga}from"fs";import{cpus as fa}from"os";import{join as Ln}from"path";function ma(e,t,n){if(!e.defaultOutputPath)return;let r=Ln(t,e.defaultOutputPath);n!==r&&fe(r)&&ze(r,n)}function ha(e,t,n){if(!e.defaultOutputPath)return null;let r=Ln(t,e.defaultOutputPath);if(r===n)return null;let i=`${n}.default-output-backup`;return Xe(i,{force:!0}),fe(r)?(ze(r,i),{defaultOutputPath:r,backupPath:i}):{defaultOutputPath:r,backupPath:null}}function ya(e){e&&(Xe(e.defaultOutputPath,{force:!0}),e.backupPath&&fe(e.backupPath)&&ze(e.backupPath,e.defaultOutputPath))}function Sa(e,t){if(e<=1)return 1;let n=Number(process.env.SCIP_QUERY_INDEXER_CONCURRENCY??0),r=Number.isFinite(t)&&t&&t>0?t:Number.isFinite(n)&&n>0?n:Math.min(8,Math.max(1,fa().length));return Math.max(1,Math.min(e,Math.floor(r)))}async function $n(e,t,n,r){let i=e.filter(c=>c.config.defaultOutputPath),a=e.filter(c=>!c.config.defaultOutputPath),s=[],o=Sa(a.length,r),d=await Pa(a,o,c=>qe(c,t,n));if(o>1){let c=new Map;for(let l of d.filter(u=>u.skipped)){let u=a.find(g=>g.id===l.id);u&&(n(`Retrying ${u.label} indexer serially after parallel failure...`),c.set(u.id,await qe(u,t,n)))}s.push(...d.map(l=>c.get(l.id)??l))}else s.push(...d);for(let c of i)s.push(await qe(c,t,n));return s.sort((c,l)=>e.findIndex(u=>u.id===c.id)-e.findIndex(u=>u.id===l.id))}async function qe(e,t,n){n(`Indexing ${e.label} with ${e.resolvedBinary}...`),Xe(e.scipPath,{force:!0});let r=ha(e.config,t,e.scipPath),i=[e.binary,...e.args].join(" "),a=Date.now();try{let o=nt(e.binary,e.args);await ba(o.binary,o.args,{cwd:t,env:e.env,maxBuffer:50*1024*1024}),ma(e.config,t,e.scipPath)}catch(o){let d=o instanceof Error?o.message:String(o),c=`${e.resolvedBinary} indexer failed: ${d.split(`
249
- `)[0]}`,l=e.label===e.language?c:`${e.label}: ${c}`;return n(`Skipping ${e.label}: ${c}`),{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:Date.now()-a,command:i,skipped:{language:e.language,reason:l}}}finally{ya(r)}if(!fe(e.scipPath)){let o=`${e.resolvedBinary} indexer completed but did not produce ${e.scipPath}`,d=e.label===e.language?o:`${e.label}: ${o}`;return n(`Skipping ${e.label}: ${o}`),{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:Date.now()-a,command:i,skipped:{language:e.language,reason:d}}}let s;try{s=ga(e.scipPath).size}catch{s=void 0}return{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:Date.now()-a,command:i,outputBytes:s}}function ba(e,t,n){return new Promise((r,i)=>{pa(e,[...t],n,a=>{a?i(a):r()})})}async function Pa(e,t,n){if(e.length===0)return[];let r=new Array(e.length),i=0,a=Math.max(1,Math.min(e.length,t)),s=Array.from({length:a},async()=>{for(;i<e.length;){let o=i++;r[o]=await n(e[o])}});return await Promise.all(s),r}import{execFileSync as xa}from"child_process";import{platform as Ra}from"os";function Bn(e,t){let n=e.installMethods,r=oe(e);if(!n?.length)return t(`No auto-install method available for ${r}.`),e.installUrl&&t(`Install manually from: ${e.installUrl}`),!1;for(let i of n)if(L(i.prerequisite)){t(`Installing ${r} via ${i.label}...`);try{xa(i.binary,i.args,{stdio:"inherit",timeout:3e5,env:process.env,shell:Ra()==="win32"});let a=J(e);if(a){let s=a===e.indexerBinary?"":` (using ${a})`;return t(`Successfully installed ${r} via ${i.label}${s}`),!0}t(`${i.label} command completed but ${r} was not found on PATH`)}catch(a){let s=a instanceof Error?a.message:String(a);t(`${i.label} install failed: ${s}`)}}return t(`Could not auto-install ${r}.`),e.installUrl&&t(`Install manually from: ${e.installUrl}`),!1}async function Qn(e){let{projectRoot:t,maxHeapMb:n=8192,onStatus:r=console.log,skipAutoInstall:i=!1}=e,a=Oa(e),s=Date.now();he(S(a.outputScip),{recursive:!0}),he(S(a.outputDb),{recursive:!0});let o=e.languages??St(t);if(o.length===0)throw new Error("No supported languages detected in this project. Looked for: tsconfig.json, Cargo.toml, go.mod, pyproject.toml, etc.");r(`Detected languages: ${o.join(", ")}`);let d=E("reindex.fingerprint",()=>dt(t,o,{pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:e.typescriptProjects,clojureConfigPath:e.clojureConfigPath}),{languages:o.length}),c,l;if(e.skipIfUnchanged!==!1&&!Ot(t,a.outputDb)&&Gn(a.outputScip)===Gn(x(S(a.outputDb),"index.scip"))){let p=Z(t);if(c=p?re(p,d):void 0,c){let y=ie(c);if(y){if(!ka(a,d))try{ve({snapshot:c,manifest:y,targetCacheDir:S(a.outputDb),targetProjectRoot:t}),r(`Attached shared generation ${c.generationId.slice(0,12)}`)}catch(b){r(`Shared generation attach failed; continuing locally: ${q(b)}`)}}else{let b=await At(c);if(b.kind==="owner")l=b.release;else if(b.kind==="generation-ready"){let f=ie(c);if(f)try{ve({snapshot:c,manifest:f,targetCacheDir:S(a.outputDb),targetProjectRoot:t,action:"waited"}),r(`Attached shared generation ${c.generationId.slice(0,12)} after waiting`)}catch(h){r(`Shared generation attach failed after waiting; continuing locally: ${q(h)}`)}}else r("Shared generation build lock timed out; continuing with an isolated local reindex")}}}let u=st(x(S(a.outputDb),"cache-lifecycle.lock"),{waitMs:3e4});if(!u)throw l?.(),new Error(`Could not acquire scip-query cache lifecycle lock for ${S(a.outputDb)}.`);let g;try{g=await C("reindex.lock",()=>ss(x(S(a.outputDb),"index.lock"),{projectRoot:t,trigger:e.trigger,onStatus:r}),{languages:o.length})}catch(p){throw u.release(),l?.(),p}let m=null;try{let p=Ca(S(a.outputDb));p.removed>0&&r(`Removed ${p.removed} abandoned reindex workspace(s)`);for(let P of p.errors)r(`Could not remove abandoned reindex workspace: ${P}`);let y=null,b=E("reindex.reuse-check",()=>(y=Ma({opts:e,paths:a,languages:o,fingerprint:d,start:s,onStatus:r}),y),()=>({languages:o.length,reused:y!==null}));if(b)return Un({snapshot:c,paths:a,projectRoot:t,fingerprint:d,onStatus:r}),Re(a.outputDb,b),b;await C("reindex.scip-cli-ready",()=>Ka(i,r));let f=Na(a);m=f.runDir;let h,R=await C("reindex.fresh",async()=>(h=await La({opts:e,languages:o,projectRoot:t,paths:a,tempPaths:f,fingerprint:d,start:s,maxHeapMb:n,skipAutoInstall:i,onStatus:r}),h),()=>({languages:o.length,reused:h?.reused,skipped:h?.skipped.length}));return Un({snapshot:c,paths:a,projectRoot:t,fingerprint:d,onStatus:r}),Re(a.outputDb,R),R}catch(p){let y=Pe({trigger:e.trigger,result:"failed",start:s,error:p instanceof Error?p.message:String(p)});throw sr(a.metaPath,y),Rt(a.outputDb,y),p}finally{m&&j(m,{recursive:!0,force:!0}),g(),u.release(),l?.()}}function Un(e){if(e.snapshot){if(ie(e.snapshot)){Ie(e.snapshot,S(e.paths.outputDb),"local-fresh");return}try{let t=Z(e.projectRoot),n=t?re(t,e.fingerprint):void 0;if(!n||n.generationId!==e.snapshot.generationId){e.onStatus("Skipped shared generation publication because the worktree changed during indexing");return}Mt({snapshot:e.snapshot,sourceCacheDir:S(e.paths.outputDb),sourceProjectRoot:e.projectRoot,sourceStillValid:()=>{let r=Z(e.projectRoot);return(r?re(r,e.fingerprint):void 0)?.generationId===e.snapshot?.generationId}}),Ie(e.snapshot,S(e.paths.outputDb),"built"),e.onStatus(`Published shared generation ${e.snapshot.generationId.slice(0,12)}`)}catch(t){e.onStatus(`Shared generation publication failed; local index remains valid: ${q(t)}`)}}}function ka(e,t){if(!F(e.outputScip)||!F(e.outputDb)||!ar(e.metaPath,t))return!1;let n=U(e.outputDb,e.metaPath);return n.state!=="invalid"&&n.state!=="drifted"}function q(e){return e instanceof Error?e.message:String(e)}function Oa(e){let t=e.outputScip??x(e.projectRoot,"index.scip"),n=e.outputDb??x(e.projectRoot,"index.db");return{outputScip:t,outputDb:n,metaPath:x(S(n),"meta.json")}}function Ma(e){let t=U(e.paths.outputDb,e.paths.metaPath);if(e.opts.skipIfUnchanged===!1||!F(e.paths.outputScip)||!F(e.paths.outputDb)||!ar(e.paths.metaPath,e.fingerprint)||t.state==="invalid"||t.state==="drifted")return null;ne(te(),{projectRoot:e.opts.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus});let n=Date.now()-e.start,r=Pe({trigger:e.opts.trigger,result:"reused",start:e.start,languages:e.languages,skipped:[]});return sr(e.paths.metaPath,r),e.onStatus(`Index unchanged; reused existing SQLite index in ${(n/1e3).toFixed(1)}s`),{languages:e.languages,indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:n,reused:!0,skipped:[],lastRefresh:r,shards:Aa(e.paths,e.opts.projectRoot,e.languages,e.opts)}}function Aa(e,t,n,r){let i=rr(t,n,r);return n.map(a=>({id:a,language:a,reused:!0,fingerprint:W(i[a]),outputBytes:z(Ye(e.outputDb,a)),durationMs:0}))}function Na(e){let t=Ea(x(S(e.outputDb),"reindex-"));return{runDir:t,tempOutputScip:x(t,me(e.outputScip)),tempOutputDb:x(t,me(e.outputDb)),tempMetaPath:x(t,me(e.metaPath))}}function Ca(e){let t=[],n;try{n=Xn(e,{withFileTypes:!0})}catch(i){return{removed:0,errors:[q(i)]}}let r=0;for(let i of n)if(!(!i.name.startsWith("reindex-")||!i.isDirectory()))try{j(x(e,i.name),{recursive:!0,force:!0}),r+=1}catch(a){t.push(`${i.name}: ${q(a)}`)}return{removed:r,errors:t}}async function La(e){let t={...process.env,NODE_OPTIONS:`--max-old-space-size=${e.maxHeapMb}`},n,r=await C("reindex.language-indexers",async()=>(n=await Ba(e,t),n),()=>({languages:e.languages.length,indexed:n?.indexedOutputs.length,reused:n?.reusedLanguages.length,skipped:n?.skippedLanguages.length})),{indexedOutputs:i,skippedLanguages:a,reusedLanguages:s,languageFingerprints:o,shards:d,typescriptProjectShardContext:c,incrementalTypeScript:l}=r;if(s.length>0&&e.onStatus(`Reused ${s.length} cached language shard(s): ${s.join(", ")}`),$a({run:e,indexedOutputs:i,skippedLanguages:a,reusedLanguages:s})){let m=E("reindex.publish",()=>Va(e,i,a,s,o,c),{mode:"metadata-only",languages:i.length,reused:s.length}),p=m.durationMs;return e.onStatus(`All language shards unchanged; reused existing SQLite index in ${(p/1e3).toFixed(1)}s`),{languages:i.map(y=>y.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:p,reused:!0,skipped:a,lastRefresh:m,shards:d}}let u=E("reindex.publish",()=>Xa(e,t,i,a,s,o,c,l),{mode:l?"incremental-or-fallback":"full",languages:i.length,reused:s.length,skipped:a.length}),g=u.durationMs;return e.onStatus(`Done in ${(g/1e3).toFixed(1)}s`),{languages:i.map(m=>m.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:g,reused:!1,skipped:a,lastRefresh:u,shards:d}}function $a(e){if(e.run.opts.skipIfUnchanged===!1||e.skippedLanguages.length>0||!F(e.run.paths.outputScip)||!F(e.run.paths.outputDb))return!1;let t=U(e.run.paths.outputDb,e.run.paths.metaPath);if(t.state==="invalid"||t.state==="drifted")return!1;let n=new Set(e.reusedLanguages),r=new Set(e.indexedOutputs.map(i=>i.language));return e.run.languages.length>0&&r.size===e.run.languages.length&&e.indexedOutputs.length===e.run.languages.length&&e.run.languages.every(i=>n.has(i)&&r.has(i))}async function Ba(e,t){let n=Wa({paths:e.paths,projectRoot:e.projectRoot,languages:e.languages,pnpmWorkspaces:e.opts.pnpmWorkspaces,typescriptProjectMode:e.opts.typescriptProjectMode,typescriptProjects:e.opts.typescriptProjects,clojureConfigPath:e.opts.clojureConfigPath}),r=[],i=new Set;for(let[I,et]of n)et.reused&&(r.push({language:I,scipPath:et.scipPath}),i.add(I));for(let I of i)e.onStatus(`Reusing cached ${I} SCIP shard (language inputs unchanged).`);let a=n.get("typescript"),s=U(e.paths.outputDb,e.paths.metaPath),o=V(e.paths.metaPath),d=s.state==="legacy"||s.state==="current",c=o?.scipCompanion!=="deferred"&&(s.state!=="current"||s.generation.publication?.scipCompanion!=="deferred"),l=a&&!a.reused&&d?Nn({projectRoot:e.projectRoot,cacheDir:S(e.paths.outputDb),previousDbPath:e.paths.outputDb,previousIndexPath:e.paths.outputScip,previousShardPath:a.scipPath,candidateShardPath:X(e.tempPaths.tempOutputScip,"typescript-incremental",0),candidateAffectedScipPath:X(e.tempPaths.tempOutputScip,"typescript-affected",0),baseShardCurrent:c,previousSnapshot:Qe(e.paths.metaPath),currentSnapshot:e.fingerprint,projectMode:e.opts.typescriptProjectMode,onStatus:e.onStatus}):null,u=new Set(l?["typescript"]:[]),g=l?void 0:Ga(e,n),{preparedRuns:m,skippedLanguages:p,languageOutputScipPaths:y}=Za({languages:e.languages.filter(I=>!i.has(I)&&!u.has(I)),tempOutputScip:e.tempPaths.tempOutputScip,projectRoot:e.projectRoot,env:t,skipAutoInstall:e.skipAutoInstall,pnpmWorkspaces:e.opts.pnpmWorkspaces,typescriptProjectMode:e.opts.typescriptProjectMode,typescriptProjects:e.opts.typescriptProjects,preDiscoveredTypeScriptProjects:g?.allProjects,clojureConfigPath:e.opts.clojureConfigPath,onStatus:e.onStatus}),b=g?m.filter(I=>I.language!=="typescript"||g.missedProjectIds.has(I.id)):m,f=await $n(b,e.projectRoot,e.onStatus,e.opts.indexerConcurrency),h=[];if(g){Ja(e.paths.outputDb,f);let I=y.typescript??e.tempPaths.tempOutputScip;h=Ha({outputDb:e.paths.outputDb,tempOutputScip:e.tempPaths.tempOutputScip,outputScipPath:I,reusedProjects:g.reusedProjects})}let R=[...f,...h],{indexedOutputs:P}=ts(R,p),Q=l?[{language:"typescript",scipPath:l.scipPath}]:[],Ze=[...r,...Q,...P];ns(Ze,p,e.languages,e.opts.allowPartial,e.onStatus);let gr=l?[{id:"typescript",language:"typescript",label:"typescript (incremental documents)",scipPath:l.scipPath,outputScipPath:l.scipPath,durationMs:l.durationMs,command:"watch-service:typescript-index",outputBytes:z(l.scipPath)??void 0}]:[],fr=qa(n,[...f,...gr],g?{outputDb:e.paths.outputDb,classification:g.classification}:void 0);return{indexedOutputs:Ze,skippedLanguages:p,reusedLanguages:[...i],languageFingerprints:za(n,e.languages),shards:fr,typescriptProjectShardContext:g?{projects:g.allProjects,fingerprints:g.fingerprints}:void 0,incrementalTypeScript:l??void 0}}function Ga(e,t){let n=t.get("typescript");if(!n||n.reused||e.opts.typescriptProjectMode!=="workspace")return;let r=H(e.projectRoot,e.opts.typescriptProjects);if(r.length===0)return;let i=Pn(e.projectRoot,r),a=yn(n.fingerprint.files,r),s=Sn(r,i),o=bn(r,a,s),d=V(e.paths.metaPath),l=Ua(d,o,p=>F(be(e.paths.outputDb,p))),u=[...l.entries()].filter(([,p])=>p.reused).map(([p])=>p),g=new Set(u),m=new Set(r.filter(p=>!g.has(p)).map(p=>`typescript:${p}`));return{allProjects:r,fingerprints:o,classification:l,reusedProjects:u,missedProjectIds:m}}function Ua(e,t,n){let r=new Map;for(let i of Object.keys(t)){let a=t[i];if(!e){r.set(i,{reused:!1,reason:"no reindex metadata found",fingerprint:a});continue}let s=e.typescriptProjectShards?.[i];if(!s){r.set(i,{reused:!1,reason:"no cached fingerprint for this project",fingerprint:a});continue}if(!n(i)){r.set(i,{reused:!1,reason:"cached shard file missing on disk",fingerprint:a});continue}if(w(s)!==w(a)){r.set(i,{reused:!1,reason:"project inputs changed since last index",fingerprint:a});continue}r.set(i,{reused:!0,fingerprint:a})}return r}function Ja(e,t){for(let n of t){if(n.skipped||!n.id.startsWith("typescript:"))continue;let r=n.id.slice(11),i=be(e,r);he(S(i),{recursive:!0}),ye(n.scipPath,i)}}function Ha(e){return e.reusedProjects.map((t,n)=>{let r=be(e.outputDb,t),i=X(e.tempOutputScip,"typescript-project-cached",n);return ye(r,i),{id:`typescript:${t}`,language:"typescript",label:`typescript (${t})`,scipPath:i,outputScipPath:e.outputScipPath,durationMs:0,command:"cached",outputBytes:z(i)??void 0}})}function Wa(e){let t=V(e.paths.metaPath),n=rr(e.projectRoot,e.languages,e),r=new Map;for(let i of e.languages){let a=Ye(e.paths.outputDb,i),s=n[i];if(!t){r.set(i,{reused:!1,reason:"no reindex metadata found",fingerprint:s,scipPath:a});continue}if(t.version!==3){r.set(i,{reused:!1,reason:`metadata version ${String(t.version??"unknown")} predates per-language shard caching`,fingerprint:s,scipPath:a});continue}if(i==="typescript"&&t.scipCompanion==="deferred"){r.set(i,{reused:!1,reason:"whole TypeScript SCIP companion is deferred behind changed-document overlays",fingerprint:s,scipPath:a});continue}if(!t.languageFingerprints){r.set(i,{reused:!1,reason:"no per-language fingerprints recorded in metadata",fingerprint:s,scipPath:a});continue}let o=t.languageFingerprints[i];if(!o){r.set(i,{reused:!1,reason:"no cached fingerprint for this language",fingerprint:s,scipPath:a});continue}if(!F(a)){r.set(i,{reused:!1,reason:"cached shard file missing on disk",fingerprint:s,scipPath:a});continue}if(w(o)!==w(s)){r.set(i,{reused:!1,reason:"language inputs changed since last index",fingerprint:s,scipPath:a});continue}r.set(i,{reused:!0,fingerprint:s,scipPath:a})}return r}function qa(e,t,n){let r=[];for(let[i,a]of e)a.reused&&r.push({id:i,language:i,reused:!0,fingerprint:W(a.fingerprint),outputBytes:z(a.scipPath),durationMs:0});for(let i of t){let a=e.get(i.language),s=n&&i.id.startsWith("typescript:")?i.id.slice(11):null,o=s?n.classification.get(s):void 0;r.push({id:i.id,language:i.language,reused:!1,missReason:o?.reason??a?.reason??i.skipped?.reason,fingerprint:o?W(o.fingerprint):a?W(a.fingerprint):"unknown",outputBytes:i.outputBytes??null,durationMs:i.durationMs,command:i.command})}if(n)for(let[i,a]of n.classification)a.reused&&r.push({id:`typescript:${i}`,language:"typescript",reused:!0,fingerprint:W(a.fingerprint),outputBytes:z(be(n.outputDb,i)),durationMs:0});return r}function W(e){return Ia("sha256").update(w(e)).digest("hex").slice(0,16)}function z(e){try{return ja(e).size}catch{return null}}function za(e,t){let n={};for(let r of t){let i=e.get(r);i&&(n[r]=i.fingerprint)}return n}function Xa(e,t,n,r,i,a,s,o){let d=!o||o.completeScipUpdated,c=!1;d&&(Jn(e.paths.outputDb,n),c=Hn(n,e.tempPaths.tempOutputScip,e.onStatus));let l=rs({run:e,env:t,indexedOutputs:n,skippedLanguages:r,reusedLanguages:i,incrementalTypeScript:o,completeScipAvailable:d,completeScipSanitized:c,materializeFullFallback:()=>{if(!o||o.completeScipUpdated)return c;e.onStatus("Materializing the deferred whole TypeScript SCIP companion for full conversion..."),Cn({cacheDir:S(e.paths.outputDb),generationIdentity:o.nextFragmentGeneration,baseShardPath:o.scipPath,candidateShardPath:o.candidateScipPath});let h=n.map(R=>R.language==="typescript"?{language:R.language,scipPath:o.candidateScipPath}:R);return Jn(e.paths.outputDb,h),c=Hn(h,e.tempPaths.tempOutputScip,e.onStatus),c}});if(ne(te(),{projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,onStatus:e.onStatus}),l.mode==="incremental"&&o){let h=null,R=null;try{h=new T({projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,indexPath:e.tempPaths.tempOutputScip}),R=new T({projectRoot:e.projectRoot,dbPath:e.paths.outputDb,indexPath:e.paths.outputScip});let P=Kt(h,e.fingerprint,o.referenceFragmentsByFile,R);e.onStatus(`Cached exact TypeScript reference fragments for ${P} affected document(s).`)}catch(P){e.onStatus(`Exact TypeScript reference fragment prefill unavailable: ${P instanceof Error?P.message:String(P)}.`)}finally{h?.close(),R?.close()}}let u=Qe(e.paths.metaPath),g=l.mode==="incremental"&&o?as(o,l.changedDocumentPaths):Oe({projectRoot:e.projectRoot,previousDbPath:e.paths.outputDb,previousIndexPath:e.paths.outputScip,candidateDbPath:e.tempPaths.tempOutputDb,candidateIndexPath:e.tempPaths.tempOutputScip,previousSnapshot:u,currentSnapshot:e.fingerprint,refreshResult:"rebuilt"}),m=Pe({trigger:e.opts.trigger,result:"rebuilt",start:e.start,languages:n.map(h=>h.language),skipped:[...r]}),p=l.mode==="incremental"&&l.scipCompanion==="deferred",y={...a};p&&delete y.typescript;let{metadata:b,pruneProjects:f}=Kn({run:e,indexedOutputs:n,skippedLanguages:r,reusedLanguages:i,languageFingerprints:y,typescriptProjectShardContext:s,lastRefresh:m});return b.scipCompanion=p?"deferred":"current",Zn(e.paths.outputDb,f),Ke(e.tempPaths.tempMetaPath,b),Tt({tempOutputScip:e.tempPaths.tempOutputScip,tempOutputDb:e.tempPaths.tempOutputDb,tempMetaPath:e.tempPaths.tempMetaPath,outputScip:e.paths.outputScip,outputDb:e.paths.outputDb,metaPath:e.paths.metaPath,preserveOutputScip:l.mode==="incremental"&&l.scipCompanion==="deferred",publication:l.mode==="incremental"?{mode:"incremental",validation:"passed",converterDurationMs:l.converterDurationMs,affectedDocumentCount:o?.affectedFiles.length,changedDocumentCount:l.changedDocumentPaths.length,producerDurationMs:o?.timings.serviceMs,materializationDurationMs:o?.durationMs,patchDurationMs:l.patchDurationMs,scipCompanion:l.scipCompanion,...l.scipCompanion==="deferred"&&o?{typescriptOverlayGeneration:o.nextFragmentGeneration}:{}}:{mode:"full",validation:"passed",converterDurationMs:l.converterDurationMs,scipCompanion:"current",...l.fallbackReason?{fallbackReason:l.fallbackReason}:{}}}),_t(S(e.paths.outputDb),l.mode==="incremental"&&l.scipCompanion==="deferred"?[o.nextFragmentGeneration]:[]),Yn(e.paths.outputDb,g,e.onStatus),m}function Va(e,t,n,r,i,a){let s=Qe(e.paths.metaPath),o=null;try{ye(e.paths.outputDb,e.tempPaths.tempOutputDb)}catch(u){o=an("reused","oracle-error",`Could not snapshot the prior database: ${u instanceof Error?u.message:String(u)}`)}ne(te(),{projectRoot:e.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus}),o??=Oe({projectRoot:e.projectRoot,previousDbPath:e.tempPaths.tempOutputDb,previousIndexPath:e.paths.outputScip,candidateDbPath:e.paths.outputDb,candidateIndexPath:e.paths.outputScip,previousSnapshot:s,currentSnapshot:e.fingerprint,refreshResult:"reused"});let d=Pe({trigger:e.opts.trigger,result:"reused",start:e.start,languages:t.map(u=>u.language),skipped:[...n]}),{metadata:c,pruneProjects:l}=Kn({run:e,indexedOutputs:t,skippedLanguages:n,reusedLanguages:r,languageFingerprints:i,typescriptProjectShardContext:a,lastRefresh:d});return Zn(e.paths.outputDb,l),Ke(e.paths.metaPath,c),kt(e.paths.outputDb,e.paths.metaPath),Yn(e.paths.outputDb,o,e.onStatus),d}function Qe(e){return tt(V(e)?.fingerprint)}function Yn(e,t,n){try{sn(e,t),t.status==="evaluated"?n(`Affected-set shadow: ${(t.evaluation.recall*100).toFixed(1)}% recall; ${t.plan.affectedFiles.length} predicted, ${t.comparison.changedFiles.length} changed.`):n(`Affected-set shadow unavailable: ${t.reason}.`)}catch(r){n(`Affected-set shadow telemetry unavailable: ${r instanceof Error?r.message:String(r)}`)}}function Kn(e){let t=Qa({mode:e.run.opts.typescriptProjectMode,skippedLanguages:e.skippedLanguages,reusedLanguages:e.reusedLanguages,context:e.typescriptProjectShardContext,metaPath:e.run.paths.metaPath});return{metadata:{version:3,status:e.skippedLanguages.length===0?"complete":"partial",updatedAt:new Date().toISOString(),fingerprint:e.run.fingerprint,languageFingerprints:e.languageFingerprints,typescriptProjectShards:t.field,requestedLanguages:e.run.languages,indexedLanguages:e.indexedOutputs.map(n=>n.language),skipped:[...e.skippedLanguages],lastRefresh:e.lastRefresh},pruneProjects:t.pruneProjects}}function Qa(e){if(e.mode!=="workspace")return{field:void 0,pruneProjects:null};if(e.skippedLanguages.some(t=>t.language==="typescript"))return{field:void 0,pruneProjects:null};if(e.reusedLanguages.includes("typescript")){let t=V(e.metaPath)?.typescriptProjectShards;return{field:t,pruneProjects:t?Object.keys(t):[]}}return e.context?{field:e.context.fingerprints,pruneProjects:e.context.projects}:{field:void 0,pruneProjects:[]}}function Zn(e,t){let n=ir(e);if(t===null){j(n,{recursive:!0,force:!0});return}let r;try{r=Xn(n)}catch{return}for(let i of Ya(r,t))j(x(n,i),{force:!0})}function Ya(e,t){let n=new Set(t.map(r=>`${Ge(r)}.scip`));return e.filter(r=>!n.has(r))}function Jn(e,t){for(let n of t){let r=Ye(e,n.language);he(S(r),{recursive:!0}),n.scipPath!==r&&ye(n.scipPath,r)}}async function Ka(e,t){if(!xe()){if(e)throw new Error(`The scip CLI is required but not found on PATH.
250
- Install from: https://github.com/sourcegraph/scip/releases`);if(Ta()==="win32")throw new Error("The scip CLI was not found. On Windows it ships via the npm sidecar package scip-query-scip-windows (installed automatically with scip-query). Reinstall with optional dependencies enabled, run 'npm install -g scip-query-scip-windows', or set SCIP_QUERY_SCIP_BIN to a local scip.exe path.");if(t("scip CLI not found on PATH. Attempting auto-install..."),!it(t))throw new Error(`The scip CLI is required but could not be installed.
251
- Install manually from: https://github.com/sourcegraph/scip/releases`)}}function Za(e){let t=[],n=[],r=e.languages.map((a,s)=>({language:a,scipPath:e.languages.length>1?X(e.tempOutputScip,a,s):e.tempOutputScip})),i=Object.fromEntries(r.map(({language:a,scipPath:s})=>[a,s]));for(let{language:a,scipPath:s}of r){let o=es({...e,language:a,scipPath:s});for(let d of o)"skipped"in d?er(n,d.skipped):t.push(d.prepared)}return{preparedRuns:t,skippedLanguages:n,languageOutputScipPaths:i}}function es(e){if(e.language!=="typescript"||e.typescriptProjectMode!=="workspace")return[Ve({...e,id:e.language,label:e.language,outputScipPath:e.scipPath})];let t=e.preDiscoveredTypeScriptProjects??H(e.projectRoot,e.typescriptProjects);return t.length===0?[Ve({...e,id:e.language,label:e.language,outputScipPath:e.scipPath})]:(e.onStatus(`Indexing TypeScript workspace as ${t.length} project shard(s).`),t.map((n,r)=>Ve({...e,id:`typescript:${n}`,label:`typescript (${n})`,scipPath:X(e.tempOutputScip,"typescript-project",r),outputScipPath:e.scipPath,pnpmWorkspaces:!1,projectPath:n})))}function Ve(e){let t=Ae(e.language),n=oe(t),r=qt(t,e.projectRoot);if(!r&&!Ht(t)){if(e.skipAutoInstall){let o=`${n} not found on PATH (auto-install disabled). ${t.installUrl??""}`.trim();return e.onStatus(`Skipping ${e.language}: ${o}`),{skipped:{language:e.language,reason:o}}}if(e.onStatus(`${n} not found. Attempting auto-install...`),!Bn(t,e.onStatus)){let o=`${n} could not be auto-installed. ${t.installUrl?`Install manually from ${t.installUrl}`:`Install ${n} and put it on PATH.`}`;return e.onStatus(`Skipping ${e.language}: ${o}`),{skipped:{language:e.language,reason:o}}}}let i=r??J(t);if(!i){let o=`${n} was not found after installation checks.`;return e.onStatus(`Skipping ${e.language}: ${o}`),{skipped:{language:e.language,reason:o}}}let{binary:a,args:s}=t.indexArgs({projectRoot:e.projectRoot,outputPath:e.scipPath,pnpmWorkspaces:e.pnpmWorkspaces,indexerBinary:i,projectPath:e.projectPath,configPath:e.language==="clojure"?e.clojureConfigPath:void 0});return{prepared:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,config:t,resolvedBinary:i,binary:a,args:s,env:zt(t,e.env,i)}}}function ts(e,t){let n=new Map;for(let i of e)if(i.skipped)er(t,i.skipped);else{let a=`${i.language}\0${i.outputScipPath}`,s=n.get(a)??{language:i.language,outputScipPath:i.outputScipPath,scipPaths:[]};s.scipPaths.push(i.scipPath),n.set(a,s)}let r=[];for(let i of n.values())if(i.scipPaths.length>1)Pt(i.scipPaths,i.outputScipPath),r.push({language:i.language,scipPath:i.outputScipPath});else{let a=i.scipPaths[0];a!==i.outputScipPath&&Vn(a,i.outputScipPath),r.push({language:i.language,scipPath:i.outputScipPath})}return{indexedOutputs:r}}function er(e,t){let n=e.find(r=>r.language===t.language);if(!n){e.push(t);return}n.reason.includes(t.reason)||(n.reason=`${n.reason}; ${t.reason}`)}function ns(e,t,n,r,i){if(e.length===0){let a=t.map(s=>` - ${s.language}: ${s.reason}`).join(`
245
+ ORDER BY d.relative_path, c.chunk_index, m.role, g.symbol`).all(),d=new Map;for(let[l,u]of Object.entries({documents:i,chunks:a,definitions:o,mentions:s}))for(let p of u){let h=JSON.stringify([l,p]),g=d.get(p.relative_path)??[];g.push(h),d.set(p.relative_path,g)}let c=new Map;for(let[l,u]of[...d].sort(([p],[h])=>p.localeCompare(h))){let p=zi("sha256");for(let h of u.sort())p.update(h).update(`
246
+ `);c.set(l,p.digest("hex"))}return c}function D(e,t){return e.prepare(t).get().value}import{createHash as la}from"crypto";import{existsSync as Ve,readdirSync as ua}from"fs";import{dirname as Ye,join as be,relative as pa,resolve as Qe,sep as Yn}from"path";function Qn(e,t){let n=t.includes("."),r={};for(let a of t)r[a]=[];let i=[];for(let a of e){let o=nr(a.path,t);o?r[o].push(a):n?r["."].push(a):i.push(a)}return{files:r,shared:i}}function Zn(e,t){let n=new Map;for(let i of e){let a=t[i]?.packageName;a&&n.set(a,i)}let r=new Map;for(let i of e)r.set(i,new Set);for(let i of e){let a=t[i],o=r.get(i);if(!a||a.parseFailed){for(let s of e)s!==i&&o.add(s);continue}for(let s of a.dependencyNames){let d=n.get(s);d&&d!==i&&o.add(d)}for(let s of[...a.pathsTargets,...a.referencesPaths]){let d=nr(s,e);d&&d!==i&&o.add(d)}}return ga(e,r)}function er(e,t,n){let r={};for(let i of e){let a=new Map;for(let o of t.files[i]??[])a.set(o.path,o);for(let o of n[i]??[])for(let s of t.files[o]??[])a.set(s.path,s);for(let o of t.shared)a.set(o.path,o);r[i]={files:[...a.values()].sort((o,s)=>o.path.localeCompare(s.path))}}return r}function Ze(e){if(e===".")return"root";let t=la("sha256").update(e).digest("hex").slice(0,8);return`${e.split("/").join("__")}-${t}`}function tr(e,t){let n=Qe(e),r={};for(let i of t)r[i]=fa(n,i);return r}function nr(e,t){let n;for(let r of t)r!=="."&&(e===r||e.startsWith(`${r}/`))&&(!n||r.length>n.length)&&(n=r);return n}function ga(e,t){let n={};for(let r of e){let i=new Set,a=[...t.get(r)??[]];for(;a.length>0;){let o=a.pop();if(!(o===r||i.has(o))){i.add(o);for(let s of t.get(o)??[])s!==r&&!i.has(s)&&a.push(s)}}n[r]=[...i].sort((o,s)=>o.localeCompare(s))}return n}function fa(e,t){let n=t==="."?e:be(e,t),r=ma(n),i=ha(n),a=i?ya(i,e):{pathsTargets:[],referencesPaths:[],failed:!1};return{packageName:r.name,dependencyNames:r.dependencyNames,pathsTargets:a.pathsTargets,referencesPaths:a.referencesPaths,parseFailed:r.failed||a.failed}}function ma(e){let t=be(e,"package.json");if(!Ve(t))return{name:void 0,dependencyNames:[],failed:!1};let n=et(t);if(!n.ok)return{name:void 0,dependencyNames:[],failed:!0};let r=typeof n.value.name=="string"?n.value.name:void 0,i=new Set;for(let a of["dependencies","devDependencies","peerDependencies"]){let o=n.value[a];if(o&&typeof o=="object"&&!Array.isArray(o))for(let s of Object.keys(o))i.add(s)}return{name:r,dependencyNames:[...i],failed:!1}}function ha(e){let t=be(e,"tsconfig.json");if(Ve(t))return t;let n;try{n=ua(e).filter(r=>/^tsconfig.*\.json$/.test(r))}catch{return}return n.sort((r,i)=>r.localeCompare(i)),n.length>0?be(e,n[0]):void 0}function ya(e,t){let n=et(e);if(!n.ok)return{pathsTargets:[],referencesPaths:[],failed:!0};let r=Sa(n.value,e,t),i=rr(e,n.value,t,0);return{pathsTargets:i.pathsTargets,referencesPaths:r,failed:i.failed}}function Sa(e,t,n){let r=e.references;if(!Array.isArray(r))return[];let i=Ye(t),a=new Set;for(let o of r){if(!o||typeof o!="object")continue;let s=o.path;if(typeof s!="string"||s.trim()==="")continue;let d=ir(s,i,n);d&&a.add(d)}return[...a]}function rr(e,t,n,r){let i=ba(t);if(i)return{pathsTargets:Pa(i,Ye(e),n),failed:!1};if(r>=5)return{pathsTargets:[],failed:!1};let a=xa(t.extends,e,n);if(!a)return{pathsTargets:[],failed:!1};let o=et(a);return o.ok?rr(a,o.value,n,r+1):{pathsTargets:[],failed:!0}}function ba(e){let t=e.compilerOptions;if(!t||typeof t!="object"||Array.isArray(t))return;let n=t.paths;return n&&typeof n=="object"&&!Array.isArray(n)?n:void 0}function Pa(e,t,n){let r=new Set;for(let i of Object.values(e))if(Array.isArray(i))for(let a of i){if(typeof a!="string")continue;let o=ir(a,t,n);o&&r.add(o)}return[...r]}function xa(e,t,n){let r=Array.isArray(e)?e.at(-1):e;if(typeof r!="string"||r.trim()===""||!r.startsWith(".")&&!r.startsWith("/"))return;let i=Qe(Ye(t),r);if(i.endsWith(".json")||(i=`${i}.json`),!i.split(Yn).includes("node_modules")&&J(n,i)&&Ve(i))return i}function ir(e,t,n){let r=e.replace(/\/?\*+$/,""),i=Qe(t,r===""?".":r);if(!J(n,i))return;let o=pa(n,i).split(Yn).join("/");return o===""?".":o}function Ra(e){let t="",n=0,r=!1,i=e.length;for(;n<i;){let a=e[n];if(r){if(t+=a,a==="\\"&&n+1<i){t+=e[n+1],n+=2;continue}a==='"'&&(r=!1),n+=1;continue}if(a==='"'){r=!0,t+=a,n+=1;continue}if(a==="/"&&e[n+1]==="/"){for(n+=2;n<i&&e[n]!==`
247
+ `;)n+=1;continue}if(a==="/"&&e[n+1]==="*"){for(n+=2;n<i&&!(e[n]==="*"&&e[n+1]==="/");)n+=1;n+=2;continue}t+=a,n+=1}return t}function et(e){try{let t=te(e,{maxBytes:mt,inputKind:"TypeScript project manifest"}),n=JSON.parse(Ra(t));return n&&typeof n=="object"&&!Array.isArray(n)?{ok:!0,value:n}:{ok:!1}}catch{return{ok:!1}}}import{existsSync as Ia,readdirSync as va,statSync as Ea}from"fs";import v from"path";var Fa=new Set([".cache",".git",".next",".nuxt",".turbo",".nx","build","coverage","dist","node_modules","tmp","vendor"]);function V(e,t=[]){let n=v.resolve(e),r=t.flatMap(d=>wa(n,d));if(r.length>0)return ar(n,or(r));let i=ja(n),a=or(i),o=_a(n,a)?[n,...a]:a,s=o.length>0?o:[n];return ar(n,s)}function ar(e,t){return[...new Set(t.map(n=>ka(e,n)))].sort((n,r)=>n.localeCompare(r))}function ja(e){let t=[],n=[e];for(;n.length>0;){let r=n.pop(),i;try{i=va(r,{withFileTypes:!0})}catch{continue}for(let a of i){let o=v.join(r,a.name);if(a.isDirectory()){!Fa.has(a.name)&&!a.name.startsWith(".")&&n.push(o);continue}a.isFile()&&Ta(o)&&t.push(v.dirname(o))}}return t}function wa(e,t){let n=t.trim();if(!n)return[];let r=v.resolve(e,n);if(!J(e,r))return[];try{let i=Ea(r);if(i.isDirectory())return[r];if(i.isFile()&&sr(v.basename(r)))return[v.dirname(r)]}catch{return[]}return[]}function Ta(e){if(!sr(v.basename(e)))return!1;let t=cr(e);return t?v.basename(e)==="tsconfig.json"||"include"in t||"files"in t||"references"in t:!1}function sr(e){return e.startsWith("tsconfig")&&e.endsWith(".json")}function or(e){let t=[...new Set(e.map(n=>v.resolve(n)))].sort((n,r)=>n.localeCompare(r));return t.length<=1?t:t.filter(n=>!t.some(r=>r!==n&&Ma(n,r)))}function _a(e,t){if(t.length===0||t.some(r=>v.resolve(r)===e))return!1;let n=v.join(e,"tsconfig.json");return Ia(n)&&Da(n)}function Da(e){let n=cr(e)?.include;return Array.isArray(n)?n.some(r=>typeof r=="string"&&r.trim()!==""&&!r.startsWith("!")&&(r.includes("/")||r.includes("**")||!v.extname(r))):!1}function cr(e){try{let t=JSON.parse(T(e,"TypeScript project config"));return t&&typeof t=="object"&&!Array.isArray(t)?t:null}catch{return null}}function ka(e,t){let n=v.relative(e,t);return n?n.split(v.sep).join("/"):"."}function Ma(e,t){let n=v.relative(e,t);return!!n&&!n.startsWith("..")&&!v.isAbsolute(n)}import{createHash as Ja}from"crypto";import{existsSync as tt,statSync as Wa,writeFileSync as nt}from"fs";import{join as qa}from"path";import{randomUUID as Oa}from"crypto";import{existsSync as Aa}from"fs";var La=12e4,Na=5,Pe=class{projectRoot;cacheDir;baseGeneration;timeoutMs;runtime;mailboxLimits;constructor(t,n={}){this.projectRoot=xt(t.projectRoot),this.cacheDir=t.cacheDir,this.baseGeneration=t.baseGeneration,this.timeoutMs=n.timeoutMs??Ua(),this.runtime=n.runtime??Ha,this.mailboxLimits=n.mailboxLimits??{}}request(t){let n=fn(this.cacheDir),r=pn(this.cacheDir),i=Be(n.statePath);if(!dr(i,this.projectRoot,this.runtime))throw new Error("Compatible TypeScript index service is not running.");let a=this.runtime.now(),o=a+this.timeoutMs,s=(this.runtime.monotonicNow??P)()+this.timeoutMs,d=dn("typescript-index-v3",{baseGeneration:this.baseGeneration,request:t}),c=ln(d),l=un(r,{mailboxVersion:cn,operationKey:d,clientId:this.runtime.randomId(),enqueuedAtMs:a,deadlineAtMs:o,protocolVersion:pe,id:c,baseGeneration:this.baseGeneration,request:t},{nowMs:a,limits:this.mailboxLimits});for(;(this.runtime.monotonicNow??P)()<=s;){if(Aa(l.responsePath))return Ca(te(l.responsePath,{maxBytes:this.mailboxLimits.maxItemBytes??64*1024*1024,inputKind:"TypeScript index mailbox response"}),c,d,this.baseGeneration,t.producerIdentity,t.affectedFiles);let u=Be(n.statePath);if(!dr(u,this.projectRoot,this.runtime))throw new Error("TypeScript index service stopped while processing a request.");this.runtime.sleep(Na)}throw new Error(`TypeScript index service timed out after ${this.timeoutMs}ms.`)}};function dr(e,t,n){let r=e?.processIdentity?n.readProcessIdentity?.(e.pid):null;return e!==null&&e.projectRoot===t&&e.typescriptIndex?.protocolVersion===pe&&n.isProcessAlive(e.pid)&&(!e.processIdentity||r!=null&&W(e.processIdentity,r))}function Ca(e,t,n,r,i,a){let o=JSON.parse(e);if(o.protocolVersion!==pe||o.id!==t||o.operationKey!==n||o.ok===!0&&o.baseGeneration!==r)throw new Error("TypeScript index service wrote an incompatible response.");if(o.ok!==!0)throw new Error(typeof o.error=="string"?o.error:"TypeScript index service request failed.");let s=$a(o.response,i),d=[...new Set(a)].sort(),c=s.fragments.map(l=>l.relativePath).sort();if(JSON.stringify(c)!==JSON.stringify(d))throw new Error("TypeScript index service omitted or added an affected document.");return s}function $a(e,t){if(!e||typeof e!="object")throw new Error("TypeScript index service wrote an invalid response.");let n=e;if(n.producerIdentity!==t||typeof n.cold!="boolean"||typeof n.durationMs!="number"||!Number.isFinite(n.durationMs)||!Array.isArray(n.fragments))throw new Error("TypeScript index service wrote an invalid response.");let r=new Set,i=n.fragments.map(a=>{if(!a||typeof a.relativePath!="string"||a.bytesBase64!==null&&typeof a.bytesBase64!="string"||typeof a.occurrences!="number"||!Number.isInteger(a.occurrences)||a.occurrences<0||typeof a.symbols!="number"||!Number.isInteger(a.symbols)||a.symbols<0||!Array.isArray(a.referenceFragments)||!a.referenceFragments.every(Ba)||r.has(a.relativePath))throw new Error("TypeScript index service wrote an invalid fragment.");r.add(a.relativePath);let o=a.bytesBase64===null?null:Ga(a.bytesBase64);return{relativePath:a.relativePath,bytes:o,occurrences:a.occurrences,symbols:a.symbols,referenceFragments:a.referenceFragments}});return{producerIdentity:n.producerIdentity,cold:n.cold,durationMs:n.durationMs,fragments:i}}function Ba(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.targetSymbol=="string"&&!!t.location&&typeof t.location.file=="string"&&Number.isInteger(t.location.line)&&Number.isInteger(t.location.column)}function Ga(e){let t=Buffer.from(e,"base64");if(t.toString("base64")!==e)throw new Error("TypeScript index service wrote invalid base64.");return t}function Ua(){let e=Number(process.env.SCIP_TYPESCRIPT_INDEX_TIMEOUT_MS);return Number.isInteger(e)&&e>0?e:La}var Ha={now:Date.now,monotonicNow:P,randomId:Oa,sleep(e){let t=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(t,0,0,e)},isProcessAlive:A,readProcessIdentity:O};function za(e){let t=e.projectMode==="workspace"?e.workspaceProjects??[]:["."];if(t.length===0)return{eligible:!1,reason:"workspace project roots unavailable"};if(t.length===1&&t[0]==="."&&!e.rootTsconfigExists)return{eligible:!1,reason:"root tsconfig unavailable"};if(!e.previousSnapshot)return{eligible:!1,reason:"prior project snapshot unavailable"};if(e.graph===null)return{eligible:!1,reason:"dependency graph unavailable"};if(e.projectFiles.length===0)return{eligible:!1,reason:"prior TypeScript documents unavailable"};let n=re(e.previousSnapshot,e.currentSnapshot);if(n.changes.length===0)return{eligible:!1,reason:"no changed project inputs"};if(n.changes.some(c=>c.kind!=="modified"||c.inputKind!=="source"||!z(c.path)))return{eligible:!1,reason:"change is not a modified TypeScript source file"};let r=ye(n,e.graph,e.projectFiles);if(r.mode!=="closure"||r.affectedFiles.length===0)return{eligible:!1,reason:r.reasons.length>0?`affected set widened: ${r.reasons.join(", ")}`:"empty affected set"};let i=Xa([...r.changedFiles,...r.affectedFiles],t);if(!i)return{eligible:!1,reason:"affected files cross or ambiguously match TypeScript projects"};let a=lr(e.currentSnapshot,e.projectFiles,e.producerIdentity),o=lr(e.previousSnapshot,e.projectFiles,e.producerIdentity);if(a!==o)return{eligible:!1,reason:"TypeScript fragment project identity changed"};let s=pr(e.previousSnapshot,e.projectFiles,e.graph,e.producerIdentity,e.projectFiles);if(!s)return{eligible:!1,reason:"prior document identity unavailable"};let d=pr(e.currentSnapshot,e.projectFiles,e.graph,e.producerIdentity,r.affectedFiles);return d?{eligible:!0,manifest:n,plan:r,projectIdentity:a,previousFragmentGeneration:ur(e.previousSnapshot,e.producerIdentity),nextFragmentGeneration:ur(e.currentSnapshot,e.producerIdentity),previousDocumentIdentities:s,nextDocumentIdentities:d,tsconfigPath:i==="."?"tsconfig.json":`${i}/tsconfig.json`,projectArgument:i}:{eligible:!1,reason:"next document identity unavailable"}}function Xa(e,t){let n=null;for(let r of e){let i=t.filter(a=>a==="."||r===a||r.startsWith(`${a}/`));if(i.length!==1||n!==null&&n!==i[0])return null;n=i[0]}return n}function gr(e){let t=P();try{if(!tt(e.previousDbPath)||!tt(e.previousShardPath))throw new Error("prior TypeScript graph or language shard unavailable");let n=performance.now(),r=$e();if(!r.available)throw new Error(r.reason);let i=performance.now()-n;n=performance.now();let a=new k({projectRoot:e.projectRoot,dbPath:e.previousDbPath,indexPath:e.previousIndexPath}),o,s;try{o=_(a,{includeIgnored:!1}).filter(z).sort(),s=C(a)}finally{a.close()}let d=performance.now()-n,c=za({projectMode:e.projectMode,workspaceProjects:e.projectMode==="workspace"?V(e.projectRoot,e.currentSnapshot.typescriptProjects):void 0,previousSnapshot:e.previousSnapshot,currentSnapshot:e.currentSnapshot,projectFiles:o,graph:s,producerIdentity:r.producerIdentity,rootTsconfigExists:tt(qa(e.projectRoot,"tsconfig.json"))});if(!c.eligible)throw new Error(c.reason);let l=gn(e.previousDbPath);if(!l)throw new Error("published TypeScript base generation unavailable");n=performance.now();let p=new Pe({projectRoot:e.projectRoot,cacheDir:e.cacheDir,baseGeneration:l}).request({kind:"emit-documents",tsconfigPath:c.tsconfigPath,projectArgument:c.projectArgument,projectIdentity:c.projectIdentity,producerIdentity:r.producerIdentity,modifiedFiles:c.plan.changedFiles,affectedFiles:c.plan.affectedFiles}),h=performance.now()-n,g=Wa(e.previousShardPath).size>=Yt;n=performance.now();let m=g?null:_e(e.previousShardPath,{inputKind:"TypeScript base SCIP shard",maxBytes:Te}),b=g?{completeIndexBytes:null,affectedIndexBytes:zt(p.fragments)}:Vt({packageVersion:r.packageVersion,baseIndexBytes:m,fragments:p.fragments}),f=performance.now()-n;n=performance.now(),g?Qt({cacheDir:e.cacheDir,previousGenerationIdentity:c.previousFragmentGeneration,nextGenerationIdentity:c.nextFragmentGeneration,producerIdentity:r.producerIdentity,projectIdentity:c.projectIdentity,baseShardCurrent:e.baseShardCurrent,fragments:p.fragments}):(Xt({cacheDir:e.cacheDir,packageVersion:r.packageVersion,indexBytes:m,producerIdentity:r.producerIdentity,projectIdentity:c.projectIdentity,generationIdentity:c.previousFragmentGeneration,documentIdentities:c.previousDocumentIdentities,allowUntrackedDocuments:!0}),Kt({cacheDir:e.cacheDir,previousGenerationIdentity:c.previousFragmentGeneration,producerIdentity:r.producerIdentity,projectIdentity:c.projectIdentity,generationIdentity:c.nextFragmentGeneration,fragments:p.fragments,documentIdentities:c.nextDocumentIdentities}));let S=performance.now()-n;n=performance.now(),b.completeIndexBytes&&nt(e.candidateShardPath,b.completeIndexBytes),nt(e.candidateAffectedScipPath,b.affectedIndexBytes);let x=performance.now()-n,R={scipPath:g?e.previousShardPath:e.candidateShardPath,candidateScipPath:e.candidateShardPath,affectedScipPath:e.candidateAffectedScipPath,completeScipUpdated:!g,durationMs:P()-t,cold:p.cold,changedFiles:c.plan.changedFiles,affectedFiles:c.plan.affectedFiles,producerIdentity:r.producerIdentity,previousFragmentGeneration:c.previousFragmentGeneration,nextFragmentGeneration:c.nextFragmentGeneration,manifest:c.manifest,plan:c.plan,projectFileCount:o.length,referenceFragmentsByFile:new Map(p.fragments.map(M=>[M.relativePath,M.referenceFragments])),timings:{runtimeMs:i,graphMs:d,requestMs:h,serviceMs:p.durationMs,assemblyMs:f,fragmentStoreMs:S,writeMs:x}};return e.onStatus(`Incremental TypeScript index emitted ${R.affectedFiles.length} affected document(s) in ${(R.durationMs/1e3).toFixed(3)}s (${R.cold?"cold":"warm"} service; ${g?"whole SCIP deferred":"whole SCIP current"}; runtime ${i.toFixed(0)}ms, graph ${d.toFixed(0)}ms, request ${h.toFixed(0)}ms, assembly ${f.toFixed(0)}ms, fragments ${S.toFixed(0)}ms, write ${x.toFixed(0)}ms).`),R}catch(n){return e.onStatus(`Incremental TypeScript index unavailable: ${n instanceof Error?n.message:String(n)}. Falling back to the whole-project indexer.`),null}}function fr(e){let t=$e();if(!t.available)throw new Error(t.reason);let n=Zt({cacheDir:e.cacheDir,generationIdentity:e.generationIdentity,baseIndexBytes:_e(e.baseShardPath,{inputKind:"TypeScript base SCIP shard",maxBytes:Te}),packageVersion:t.packageVersion});nt(e.candidateShardPath,n)}function lr(e,t,n){let r=e.files.filter(i=>ne(i.path,e.languages)!=="source").map(i=>({path:i.path,size:i.size,hash:i.hash})).sort((i,a)=>i.path.localeCompare(a.path));return rt(JSON.stringify({version:1,producerIdentity:n,pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:[...e.typescriptProjects].sort(),projectFiles:[...t].sort(),nonSourceInputs:r}))}function ur(e,t){return rt(JSON.stringify({version:1,producerIdentity:t,snapshot:e}))}function pr(e,t,n,r,i){let a=new Set(e.files.map(d=>d.path)),o=he({projectFiles:t.filter(d=>a.has(d)),snapshot:e,graph:n,engineIdentity:r}),s=new Map;for(let d of i){let c=o.identityFor(d,"typescript-scip-document-v1");if(c.key){s.set(d,c.key);continue}if(a.has(d))return null;s.set(d,rt(JSON.stringify({version:1,producerIdentity:r,generatedDocument:d})))}return s}function rt(e){return Ja("sha256").update(e).digest("hex")}import{existsSync as xe,renameSync as at,rmSync as ot,statSync as Ka}from"fs";import{cpus as Va}from"os";import{join as hr}from"path";function Ya(e,t,n){if(!e.defaultOutputPath)return;let r=hr(t,e.defaultOutputPath);n!==r&&xe(r)&&at(r,n)}function Qa(e,t,n){if(!e.defaultOutputPath)return null;let r=hr(t,e.defaultOutputPath);if(r===n)return null;let i=`${n}.default-output-backup`;return ot(i,{force:!0}),xe(r)?(at(r,i),{defaultOutputPath:r,backupPath:i}):{defaultOutputPath:r,backupPath:null}}function Za(e){e&&(ot(e.defaultOutputPath,{force:!0}),e.backupPath&&xe(e.backupPath)&&at(e.backupPath,e.defaultOutputPath))}function eo(e,t){if(e<=1)return 1;let n=Number(process.env.SCIP_QUERY_INDEXER_CONCURRENCY??0),r=Number.isFinite(t)&&t&&t>0?t:Number.isFinite(n)&&n>0?n:Math.min(8,Math.max(1,Va().length));return Math.max(1,Math.min(e,Math.floor(r)))}async function yr(e,t,n,r){let i=e.filter(c=>c.config.defaultOutputPath),a=e.filter(c=>!c.config.defaultOutputPath),o=[],s=eo(a.length,r),d=await ro(a,s,c=>it(c,t,n));if(s>1){let c=new Map;for(let l of d.filter(u=>u.result.skipped&&u.retryable)){let u=a.find(p=>p.id===l.result.id);u&&(n(`Retrying ${u.label} indexer serially after parallel failure...`),c.set(u.id,(await it(u,t,n)).result))}o.push(...d.map(({result:l})=>c.get(l.id)??l))}else o.push(...d.map(({result:c})=>c));for(let c of i)o.push((await it(c,t,n)).result);return o.sort((c,l)=>e.findIndex(u=>u.id===c.id)-e.findIndex(u=>u.id===l.id))}async function it(e,t,n){n(`Indexing ${e.label} with ${e.resolvedBinary}...`),ot(e.scipPath,{force:!0});let r=Qa(e.config,t,e.scipPath),i=[e.binary,...e.args].join(" "),a=P();try{e.trustedProjectTool&&En(t,e.trustedProjectTool);let s=yt(e.binary,e.args),d=await yn({command:s.binary,args:s.args,label:`${e.label} indexer`,cwd:t,env:e.env,timeoutMs:to(),maxStdoutBytes:50*1024*1024,maxStderrBytes:50*1024*1024});if(d.status!==0){let c=d.stderr.trim();throw new Error(`${e.resolvedBinary} exited with status ${d.status}${c?`:
248
+ ${c}`:""}`)}Ya(e.config,t,e.scipPath)}catch(s){let d=s instanceof Error?s.message:String(s),c=`${e.resolvedBinary} indexer failed: ${d.split(`
249
+ `)[0]}`,l=e.label===e.language?c:`${e.label}: ${c}`;return n(`Skipping ${e.label}: ${c}`),{result:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:P()-a,command:i,skipped:{language:e.language,reason:l}},retryable:no(s)}}finally{Za(r)}if(!xe(e.scipPath)){let s=`${e.resolvedBinary} indexer completed but did not produce ${e.scipPath}`,d=e.label===e.language?s:`${e.label}: ${s}`;return n(`Skipping ${e.label}: ${s}`),{result:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:P()-a,command:i,skipped:{language:e.language,reason:d}},retryable:!1}}let o;try{o=Ka(e.scipPath).size}catch{o=void 0}return{result:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:P()-a,command:i,outputBytes:o},retryable:!1}}function to(){let e=Number(process.env.SCIP_QUERY_INDEXER_TIMEOUT_MS);return Number.isFinite(e)&&e>0?Math.floor(e):mn.indexer}function no(e){return e instanceof hn?e.kind==="spawn"&&mr(e.cause):mr(e)}function mr(e){let t=e?.code;return t==="EAGAIN"||t==="ENOMEM"||t==="EMFILE"||t==="ENFILE"||t==="ETXTBSY"}async function ro(e,t,n){if(e.length===0)return[];let r=new Array(e.length),i=0,a=Math.max(1,Math.min(e.length,t)),o=Array.from({length:a},async()=>{for(;i<e.length;){let s=i++;r[s]=await n(e[s])}});return await Promise.all(o),r}import{execFileSync as br}from"child_process";import{homedir as Sr,platform as io}from"os";import{delimiter as ao,join as Re}from"path";function Pr(e,t){let n=e.installMethods,r=fe(e);if(!n?.length)return t(`No auto-install method available for ${r}.`),e.installUrl&&t(`Install manually from: ${e.installUrl}`),!1;for(let i of n){if(!i.identity||!i.destination){t(`Refusing ${i.label} installation for ${r}: the installer descriptor lacks an immutable identity or destination.`);continue}if(!ae(i.prerequisite))continue;let a=oo(i);t(`Installing immutable ${i.identity} via ${i.label} into ${a}; expected executable: ${r}.`);try{br(i.binary,i.args,{stdio:"inherit",timeout:3e5,env:process.env,shell:io()==="win32"});let o=N(e);if(o){let s=o===e.indexerBinary?"":` (using ${o})`;return t(`Successfully installed ${i.identity} via ${i.label}${s}; resolved executable: ${o}.`),!0}t(`${i.label} command completed but ${r} was not found on PATH`)}catch(o){let s=o instanceof Error?o.message:String(o);t(`${i.label} install failed: ${s}`)}}return t(`Could not auto-install ${r}.`),e.installUrl&&t(`Install manually from: ${e.installUrl}`),!1}function oo(e){if(e.binary==="npm")return st("npm",["root","-g"])??e.destination;if(e.binary==="go"){let t=st("go",["env","GOBIN"]);if(t)return t;let n=st("go",["env","GOPATH"]);if(n)return Re(n.split(ao)[0],"bin")}return e.binary==="dotnet"?Re(process.env.DOTNET_CLI_HOME??Sr(),".dotnet","tools"):e.binary==="dart"?Re(process.env.PUB_CACHE??Re(Sr(),".pub-cache"),"bin"):e.destination}function st(e,t){try{return br(e,t,{stdio:["ignore","pipe","ignore"],encoding:"utf8",timeout:1e4,killSignal:"SIGKILL",env:process.env}).trim()||null}catch{return null}}async function Dr(e){let{projectRoot:t,maxHeapMb:n=8192,onStatus:r=console.log}=e,i=e.skipAutoInstall===!0||e.installMissing!==!0,a=mo(e),o=Date.now(),s=P();ve(y(a.outputScip),{recursive:!0}),ve(y(a.outputDb),{recursive:!0});let d=e.languages??Ut(t);if(d.length===0)throw new Error("No supported languages detected in this project. Looked for: tsconfig.json, Cargo.toml, go.mod, pyproject.toml, etc.");r(`Detected languages: ${d.join(", ")}`);let c=j("reindex.fingerprint",()=>Tt(t,d,{pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:e.typescriptProjects,clojureConfigPath:e.clojureConfigPath}),{languages:d.length}),l,u;if(e.skipIfUnchanged!==!1&&!an(t,a.outputDb)&&xr(a.outputScip)===xr(I(y(a.outputDb),"index.scip"))){let m=oe(t);if(l=m?le(m,c):void 0,l){let b=ue(l);if(b){if(!fo(a,c))try{Ne({snapshot:l,manifest:b,targetCacheDir:y(a.outputDb),targetProjectRoot:t}),r(`Attached shared generation ${l.generationId.slice(0,12)}`)}catch(f){r(`Shared generation attach failed; continuing locally: ${G(f)}`)}}else{let f=await sn(l);if(f.kind==="owner")u=f.release;else if(f.kind==="generation-ready"){let S=ue(l);if(S)try{Ne({snapshot:l,manifest:S,targetCacheDir:y(a.outputDb),targetProjectRoot:t,action:"waited"}),r(`Attached shared generation ${l.generationId.slice(0,12)} after waiting`)}catch(x){r(`Shared generation attach failed after waiting; continuing locally: ${G(x)}`)}}else r("Shared generation build lock timed out; continuing with an isolated local reindex")}}}let p=vt(I(y(a.outputDb),"cache-lifecycle.lock"),{waitMs:3e4});if(!p)throw u?.(),new Error(`Could not acquire scip-query cache lifecycle lock for ${y(a.outputDb)}.`);let h;try{h=await H("reindex.lock",()=>Uo(I(y(a.outputDb),"index.lock"),{projectRoot:t,trigger:e.trigger,onStatus:r}),{languages:d.length})}catch(m){throw p.release(),u?.(),m}let g=null;try{nn(a.outputDb,a.outputScip,a.metaPath);let m=bo(y(a.outputDb));m.removed>0&&r(`Removed ${m.removed} abandoned reindex workspace(s)`);for(let M of m.errors)r(`Could not remove abandoned reindex workspace: ${M}`);let b=null,f=j("reindex.reuse-check",()=>(b=ho({opts:e,paths:a,languages:d,fingerprint:c,start:o,monotonicStart:s,onStatus:r}),b),()=>({languages:d.length,reused:b!==null}));if(f)return Rr({snapshot:l,paths:a,projectRoot:t,fingerprint:c,onStatus:r}),Le(a.outputDb,f),Me(t,y(a.outputDb)),f;await H("reindex.scip-cli-ready",()=>Oo(i,r));let S=So(a);g=S.runDir;let x,R=await H("reindex.fresh",async()=>(x=await Po({opts:e,languages:d,projectRoot:t,paths:a,tempPaths:S,fingerprint:c,start:o,monotonicStart:s,maxHeapMb:n,skipAutoInstall:i,onStatus:r}),x),()=>({languages:d.length,reused:x?.reused,skipped:x?.skipped.length}));return Rr({snapshot:l,paths:a,projectRoot:t,fingerprint:c,onStatus:r}),Le(a.outputDb,R),Me(t,y(a.outputDb)),R}catch(m){let b=we({trigger:e.trigger,result:"failed",start:o,monotonicStart:s,error:m instanceof Error?m.message:String(m)});throw Jr(a.metaPath,b),qt(a.outputDb,b),m}finally{g&&B(g,{recursive:!0,force:!0}),h(),p.release(),u?.()}}function Rr(e){if(e.snapshot){if(ue(e.snapshot)){Ce(e.snapshot,y(e.paths.outputDb),"local-fresh");return}try{let t=oe(e.projectRoot),n=t?le(t,e.fingerprint):void 0;if(!n||n.generationId!==e.snapshot.generationId){e.onStatus("Skipped shared generation publication because the worktree changed during indexing");return}on({snapshot:e.snapshot,sourceCacheDir:y(e.paths.outputDb),sourceProjectRoot:e.projectRoot,sourceStillValid:()=>{let r=oe(e.projectRoot);return(r?le(r,e.fingerprint):void 0)?.generationId===e.snapshot?.generationId}}),Ce(e.snapshot,y(e.paths.outputDb),"built"),e.onStatus(`Published shared generation ${e.snapshot.generationId.slice(0,12)}`)}catch(t){e.onStatus(`Shared generation publication failed; local index remains valid: ${G(t)}`)}}}function fo(e,t){if(!F(e.outputScip)||!F(e.outputDb)||!Hr(e.metaPath,t))return!1;let n=X(e.outputDb,e.metaPath);return n.state!=="invalid"&&n.state!=="drifted"}function G(e){return e instanceof Error?e.message:String(e)}function mo(e){let t=e.outputScip??I(e.projectRoot,"index.scip"),n=e.outputDb??I(e.projectRoot,"index.db");return{outputScip:t,outputDb:n,metaPath:I(y(n),"meta.json")}}function ho(e){let t=X(e.paths.outputDb,e.paths.metaPath);if(e.opts.skipIfUnchanged===!1||!F(e.paths.outputScip)||!F(e.paths.outputDb)||!Hr(e.paths.metaPath,e.fingerprint)||t.state==="invalid"||t.state==="drifted")return null;de(ce(),{projectRoot:e.opts.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus});let n=P()-e.monotonicStart,r=we({trigger:e.opts.trigger,result:"reused",start:e.start,monotonicStart:e.monotonicStart,languages:e.languages,skipped:[]});return Jr(e.paths.metaPath,r),e.onStatus(`Index unchanged; reused existing SQLite index in ${(n/1e3).toFixed(1)}s`),{languages:e.languages,indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:n,reused:!0,skipped:[],lastRefresh:r,shards:yo(e.paths,e.opts.projectRoot,e.languages,e.opts)}}function yo(e,t,n,r){let i=Gr(t,n,r);return n.map(a=>({id:a,language:a,reused:!0,fingerprint:Y(i[a]),outputBytes:Q(ut(e.outputDb,a)),durationMs:0}))}function So(e){let t=lo(I(y(e.outputDb),"reindex-"));return{runDir:t,tempOutputScip:I(t,Ie(e.outputScip)),tempOutputDb:I(t,Ie(e.outputDb)),tempMetaPath:I(t,Ie(e.metaPath))}}function bo(e){let t=[],n;try{n=Tr(e,{withFileTypes:!0})}catch(i){return{removed:0,errors:[G(i)]}}let r=0;for(let i of n)if(!(!i.name.startsWith("reindex-")||!i.isDirectory()))try{B(I(e,i.name),{recursive:!0,force:!0}),r+=1}catch(a){t.push(`${i.name}: ${G(a)}`)}return{removed:r,errors:t}}async function Po(e){let t={...process.env,NODE_OPTIONS:`--max-old-space-size=${e.maxHeapMb}`},n,r=await H("reindex.language-indexers",async()=>(n=await Ro(e,t),n),()=>({languages:e.languages.length,indexed:n?.indexedOutputs.length,reused:n?.reusedLanguages.length,skipped:n?.skippedLanguages.length})),{indexedOutputs:i,skippedLanguages:a,reusedLanguages:o,languageFingerprints:s,shards:d,typescriptProjectShardContext:c,incrementalTypeScript:l}=r;if(o.length>0&&e.onStatus(`Reused ${o.length} cached language shard(s): ${o.join(", ")}`),xo({run:e,indexedOutputs:i,skippedLanguages:a,reusedLanguages:o})){let h=j("reindex.publish",()=>Do(e,i,a,o,s,c),{mode:"metadata-only",languages:i.length,reused:o.length}),g=h.durationMs;return e.onStatus(`All language shards unchanged; reused existing SQLite index in ${(g/1e3).toFixed(1)}s`),{languages:i.map(m=>m.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:g,reused:!0,skipped:a,lastRefresh:h,shards:d}}let u=j("reindex.publish",()=>_o(e,t,i,a,o,s,c,l),{mode:l?"incremental-or-fallback":"full",languages:i.length,reused:o.length,skipped:a.length}),p=u.durationMs;return e.onStatus(`Done in ${(p/1e3).toFixed(1)}s`),{languages:i.map(h=>h.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:p,reused:!1,skipped:a,lastRefresh:u,shards:d}}function xo(e){if(e.run.opts.skipIfUnchanged===!1||e.skippedLanguages.length>0||!F(e.run.paths.outputScip)||!F(e.run.paths.outputDb))return!1;let t=X(e.run.paths.outputDb,e.run.paths.metaPath);if(t.state==="invalid"||t.state==="drifted")return!1;let n=new Set(e.reusedLanguages),r=new Set(e.indexedOutputs.map(i=>i.language));return e.run.languages.length>0&&r.size===e.run.languages.length&&e.indexedOutputs.length===e.run.languages.length&&e.run.languages.every(i=>n.has(i)&&r.has(i))}async function Ro(e,t){let n=jo({paths:e.paths,projectRoot:e.projectRoot,languages:e.languages,pnpmWorkspaces:e.opts.pnpmWorkspaces,typescriptProjectMode:e.opts.typescriptProjectMode,typescriptProjects:e.opts.typescriptProjects,clojureConfigPath:e.opts.clojureConfigPath}),r=[],i=new Set;for(let[E,ft]of n)ft.reused&&(r.push({language:E,scipPath:ft.scipPath}),i.add(E));for(let E of i)e.onStatus(`Reusing cached ${E} SCIP shard (language inputs unchanged).`);let a=n.get("typescript"),o=X(e.paths.outputDb,e.paths.metaPath),s=ee(e.paths.metaPath),d=o.state==="legacy"||o.state==="current",c=s?.scipCompanion!=="deferred"&&(o.state!=="current"||o.generation.publication?.scipCompanion!=="deferred"),l=a&&!a.reused&&d?gr({projectRoot:e.projectRoot,cacheDir:y(e.paths.outputDb),previousDbPath:e.paths.outputDb,previousIndexPath:e.paths.outputScip,previousShardPath:a.scipPath,candidateShardPath:Z(e.tempPaths.tempOutputScip,"typescript-incremental",0),candidateAffectedScipPath:Z(e.tempPaths.tempOutputScip,"typescript-affected",0),baseShardCurrent:c,previousSnapshot:lt(e.paths.metaPath),currentSnapshot:e.fingerprint,projectMode:e.opts.typescriptProjectMode,onStatus:e.onStatus}):null,u=new Set(l?["typescript"]:[]),p=l?void 0:Io(e,n),{preparedRuns:h,skippedLanguages:g,languageOutputScipPaths:m}=Ao({languages:e.languages.filter(E=>!i.has(E)&&!u.has(E)),tempOutputScip:e.tempPaths.tempOutputScip,projectRoot:e.projectRoot,env:t,skipAutoInstall:e.skipAutoInstall,trustProjectTools:e.opts.trustProjectTools===!0,pnpmWorkspaces:e.opts.pnpmWorkspaces,typescriptProjectMode:e.opts.typescriptProjectMode,typescriptProjects:e.opts.typescriptProjects,preDiscoveredTypeScriptProjects:p?.allProjects,clojureConfigPath:e.opts.clojureConfigPath,onStatus:e.onStatus}),b=p?h.filter(E=>E.language!=="typescript"||p.missedProjectIds.has(E.id)):h,f=await yr(b,e.projectRoot,e.onStatus,e.opts.indexerConcurrency),S=[];if(p){Eo(e.paths.outputDb,f);let E=m.typescript??e.tempPaths.tempOutputScip;S=Fo({outputDb:e.paths.outputDb,tempOutputScip:e.tempPaths.tempOutputScip,outputScipPath:E,reusedProjects:p.reusedProjects})}let x=[...f,...S],{indexedOutputs:R}=No(x,g),M=l?[{language:"typescript",scipPath:l.scipPath}]:[],gt=[...r,...M,...R];Co(gt,g,e.languages,e.opts.allowPartial,e.onStatus);let Yr=l?[{id:"typescript",language:"typescript",label:"typescript (incremental documents)",scipPath:l.scipPath,outputScipPath:l.scipPath,durationMs:l.durationMs,command:"watch-service:typescript-index",outputBytes:Q(l.scipPath)??void 0}]:[],Qr=wo(n,[...f,...Yr],p?{outputDb:e.paths.outputDb,classification:p.classification}:void 0);return{indexedOutputs:gt,skippedLanguages:g,reusedLanguages:[...i],languageFingerprints:To(n,e.languages),shards:Qr,typescriptProjectShardContext:p?{projects:p.allProjects,fingerprints:p.fingerprints}:void 0,incrementalTypeScript:l??void 0}}function Io(e,t){let n=t.get("typescript");if(!n||n.reused||e.opts.typescriptProjectMode!=="workspace")return;let r=V(e.projectRoot,e.opts.typescriptProjects);if(r.length===0)return;let i=tr(e.projectRoot,r),a=Qn(n.fingerprint.files,r),o=Zn(r,i),s=er(r,a,o),d=ee(e.paths.metaPath),l=vo(d,s,g=>F(je(e.paths.outputDb,g))),u=[...l.entries()].filter(([,g])=>g.reused).map(([g])=>g),p=new Set(u),h=new Set(r.filter(g=>!p.has(g)).map(g=>`typescript:${g}`));return{allProjects:r,fingerprints:s,classification:l,reusedProjects:u,missedProjectIds:h}}function vo(e,t,n){let r=new Map;for(let i of Object.keys(t)){let a=t[i];if(!e){r.set(i,{reused:!1,reason:"no reindex metadata found",fingerprint:a});continue}let o=e.version===U&&ke(e).typescriptProjectShardReuse?e.typescriptProjectShards?.[i]:void 0;if(!o){r.set(i,{reused:!1,reason:"no cached fingerprint for this project",fingerprint:a});continue}if(!n(i)){r.set(i,{reused:!1,reason:"cached shard file missing on disk",fingerprint:a});continue}if(w(o)!==w(a)){r.set(i,{reused:!1,reason:"project inputs changed since last index",fingerprint:a});continue}r.set(i,{reused:!0,fingerprint:a})}return r}function Eo(e,t){for(let n of t){if(n.skipped||!n.id.startsWith("typescript:"))continue;let r=n.id.slice(11),i=je(e,r);ve(y(i),{recursive:!0}),Fe(n.scipPath,i)}}function Fo(e){return e.reusedProjects.map((t,n)=>{let r=je(e.outputDb,t),i=Z(e.tempOutputScip,"typescript-project-cached",n);return Fe(r,i),{id:`typescript:${t}`,language:"typescript",label:`typescript (${t})`,scipPath:i,outputScipPath:e.outputScipPath,durationMs:0,command:"cached",outputBytes:Q(i)??void 0}})}function jo(e){let t=ee(e.paths.metaPath),n=Gr(e.projectRoot,e.languages,e),r=new Map;for(let i of e.languages){let a=ut(e.paths.outputDb,i),o=n[i];if(!t){r.set(i,{reused:!1,reason:"no reindex metadata found",fingerprint:o,scipPath:a});continue}if(t.version!==U){r.set(i,{reused:!1,reason:`metadata version ${String(t.version??"unknown")} predates per-language shard caching`,fingerprint:o,scipPath:a});continue}if(i==="typescript"&&t.scipCompanion==="deferred"){r.set(i,{reused:!1,reason:"whole TypeScript SCIP companion is deferred behind changed-document overlays",fingerprint:o,scipPath:a});continue}if(!ke(t).languageShardReuse||!t.languageFingerprints){r.set(i,{reused:!1,reason:"no per-language fingerprints recorded in metadata",fingerprint:o,scipPath:a});continue}let s=t.languageFingerprints[i];if(!s){r.set(i,{reused:!1,reason:"no cached fingerprint for this language",fingerprint:o,scipPath:a});continue}if(!F(a)){r.set(i,{reused:!1,reason:"cached shard file missing on disk",fingerprint:o,scipPath:a});continue}if(w(s)!==w(o)){r.set(i,{reused:!1,reason:"language inputs changed since last index",fingerprint:o,scipPath:a});continue}r.set(i,{reused:!0,fingerprint:o,scipPath:a})}return r}function wo(e,t,n){let r=[];for(let[i,a]of e)a.reused&&r.push({id:i,language:i,reused:!0,fingerprint:Y(a.fingerprint),outputBytes:Q(a.scipPath),durationMs:0});for(let i of t){let a=e.get(i.language),o=n&&i.id.startsWith("typescript:")?i.id.slice(11):null,s=o?n.classification.get(o):void 0;r.push({id:i.id,language:i.language,reused:!1,missReason:s?.reason??a?.reason??i.skipped?.reason,fingerprint:s?Y(s.fingerprint):a?Y(a.fingerprint):"unknown",outputBytes:i.outputBytes??null,durationMs:i.durationMs,command:i.command})}if(n)for(let[i,a]of n.classification)a.reused&&r.push({id:`typescript:${i}`,language:"typescript",reused:!0,fingerprint:Y(a.fingerprint),outputBytes:Q(je(n.outputDb,i)),durationMs:0});return r}function Y(e){return co("sha256").update(w(e)).digest("hex").slice(0,16)}function Q(e){try{return uo(e).size}catch{return null}}function To(e,t){let n={};for(let r of t){let i=e.get(r);i&&(n[r]=i.fingerprint)}return n}function _o(e,t,n,r,i,a,o,s){let d=!s||s.completeScipUpdated,c=!1;d&&(Ir(e.paths.outputDb,n),c=vr(n,e.tempPaths.tempOutputScip,e.onStatus));let l=$o({run:e,env:t,indexedOutputs:n,skippedLanguages:r,reusedLanguages:i,incrementalTypeScript:s,completeScipAvailable:d,completeScipSanitized:c,materializeFullFallback:()=>{if(!s||s.completeScipUpdated)return c;e.onStatus("Materializing the deferred whole TypeScript SCIP companion for full conversion..."),fr({cacheDir:y(e.paths.outputDb),generationIdentity:s.nextFragmentGeneration,baseShardPath:s.scipPath,candidateShardPath:s.candidateScipPath});let S=n.map(x=>x.language==="typescript"?{language:x.language,scipPath:s.candidateScipPath}:x);return Ir(e.paths.outputDb,S),c=vr(S,e.tempPaths.tempOutputScip,e.onStatus),c}});if(de(ce(),{projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,onStatus:e.onStatus}),l.mode==="incremental"&&s){let S=null,x=null;try{S=new k({projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,indexPath:e.tempPaths.tempOutputScip}),x=new k({projectRoot:e.projectRoot,dbPath:e.paths.outputDb,indexPath:e.paths.outputScip});let R=kn(S,e.fingerprint,s.referenceFragmentsByFile,x);e.onStatus(`Cached exact TypeScript reference fragments for ${R} affected document(s).`)}catch(R){e.onStatus(`Exact TypeScript reference fragment prefill unavailable: ${R instanceof Error?R.message:String(R)}.`)}finally{S?.close(),x?.close()}}let u=lt(e.paths.metaPath),p=l.mode==="incremental"&&s?Go(s,l.changedDocumentPaths):qe({projectRoot:e.projectRoot,previousDbPath:e.paths.outputDb,previousIndexPath:e.paths.outputScip,candidateDbPath:e.tempPaths.tempOutputDb,candidateIndexPath:e.tempPaths.tempOutputScip,previousSnapshot:u,currentSnapshot:e.fingerprint,refreshResult:"rebuilt"}),h=we({trigger:e.opts.trigger,result:"rebuilt",start:e.start,monotonicStart:e.monotonicStart,languages:n.map(S=>S.language),skipped:[...r]}),g=l.mode==="incremental"&&l.scipCompanion==="deferred",m={...a};g&&delete m.typescript;let{metadata:b,pruneProjects:f}=Mr({run:e,indexedOutputs:n,skippedLanguages:r,reusedLanguages:i,languageFingerprints:m,typescriptProjectShardContext:o,lastRefresh:h});return b.scipCompanion=g?"deferred":"current",Or(e.paths.outputDb,f),pt(e.tempPaths.tempMetaPath,b),tn({tempOutputScip:e.tempPaths.tempOutputScip,tempOutputDb:e.tempPaths.tempOutputDb,tempMetaPath:e.tempPaths.tempMetaPath,outputScip:e.paths.outputScip,outputDb:e.paths.outputDb,metaPath:e.paths.metaPath,preserveOutputScip:l.mode==="incremental"&&l.scipCompanion==="deferred",publication:l.mode==="incremental"?{mode:"incremental",validation:"passed",converterDurationMs:l.converterDurationMs,affectedDocumentCount:s?.affectedFiles.length,changedDocumentCount:l.changedDocumentPaths.length,producerDurationMs:s?.timings.serviceMs,materializationDurationMs:s?.durationMs,patchDurationMs:l.patchDurationMs,scipCompanion:l.scipCompanion,...l.scipCompanion==="deferred"&&s?{typescriptOverlayGeneration:s.nextFragmentGeneration}:{}}:{mode:"full",validation:"passed",converterDurationMs:l.converterDurationMs,scipCompanion:"current",...l.fallbackReason?{fallbackReason:l.fallbackReason}:{}}}),en(y(e.paths.outputDb),l.mode==="incremental"&&l.scipCompanion==="deferred"?[s.nextFragmentGeneration]:[]),kr(e.paths.outputDb,p,e.onStatus),h}function Do(e,t,n,r,i,a){let o=lt(e.paths.metaPath),s=null;try{Fe(e.paths.outputDb,e.tempPaths.tempOutputDb)}catch(u){s=Ln("reused","oracle-error",`Could not snapshot the prior database: ${u instanceof Error?u.message:String(u)}`)}de(ce(),{projectRoot:e.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus}),s??=qe({projectRoot:e.projectRoot,previousDbPath:e.tempPaths.tempOutputDb,previousIndexPath:e.paths.outputScip,candidateDbPath:e.paths.outputDb,candidateIndexPath:e.paths.outputScip,previousSnapshot:o,currentSnapshot:e.fingerprint,refreshResult:"reused"});let d=we({trigger:e.opts.trigger,result:"reused",start:e.start,monotonicStart:e.monotonicStart,languages:t.map(u=>u.language),skipped:[...n]}),{metadata:c,pruneProjects:l}=Mr({run:e,indexedOutputs:t,skippedLanguages:n,reusedLanguages:r,languageFingerprints:i,typescriptProjectShardContext:a,lastRefresh:d});return Or(e.paths.outputDb,l),pt(e.paths.metaPath,c),rn(e.paths.outputDb,e.paths.metaPath),kr(e.paths.outputDb,s,e.onStatus),d}function lt(e){return ht(ee(e)?.fingerprint)}function kr(e,t,n){try{Nn(e,t),t.status==="evaluated"?n(`Affected-set shadow: ${(t.evaluation.recall*100).toFixed(1)}% recall; ${t.plan.affectedFiles.length} predicted, ${t.comparison.changedFiles.length} changed.`):n(`Affected-set shadow unavailable: ${t.reason}.`)}catch(r){n(`Affected-set shadow telemetry unavailable: ${r instanceof Error?r.message:String(r)}`)}}function Mr(e){let t=ko({mode:e.run.opts.typescriptProjectMode,skippedLanguages:e.skippedLanguages,reusedLanguages:e.reusedLanguages,context:e.typescriptProjectShardContext,metaPath:e.run.paths.metaPath});return{metadata:{version:U,status:e.skippedLanguages.length===0?"complete":"partial",updatedAt:new Date().toISOString(),fingerprint:e.run.fingerprint,languageFingerprints:e.languageFingerprints,typescriptProjectShards:t.field,requestedLanguages:e.run.languages,indexedLanguages:e.indexedOutputs.map(n=>n.language),skipped:[...e.skippedLanguages],lastRefresh:e.lastRefresh},pruneProjects:t.pruneProjects}}function ko(e){if(e.mode!=="workspace")return{field:void 0,pruneProjects:null};if(e.skippedLanguages.some(t=>t.language==="typescript"))return{field:void 0,pruneProjects:null};if(e.reusedLanguages.includes("typescript")){let t=ee(e.metaPath),n=t?.version===U?t.typescriptProjectShards:void 0;return{field:n,pruneProjects:n?Object.keys(n):[]}}return e.context?{field:e.context.fingerprints,pruneProjects:e.context.projects}:{field:void 0,pruneProjects:[]}}function Or(e,t){let n=Ur(e);if(t===null){B(n,{recursive:!0,force:!0});return}let r;try{r=Tr(n)}catch{return}for(let i of Mo(r,t))B(I(n,i),{force:!0})}function Mo(e,t){let n=new Set(t.map(r=>`${Ze(r)}.scip`));return e.filter(r=>!n.has(r))}function Ir(e,t){for(let n of t){let r=ut(e,n.language);ve(y(r),{recursive:!0}),n.scipPath!==r&&Fe(n.scipPath,r)}}async function Oo(e,t){if(!Oe()){if(go()==="win32")throw new Error("The scip CLI was not found. On Windows it ships via the npm sidecar package scip-query-scip-windows (installed automatically with scip-query). Reinstall scip-query with optional dependencies enabled, or follow 'scip-query setup' guidance for the exact sidecar package version, or set SCIP_QUERY_SCIP_BIN to a local scip.exe path.");if(e)throw new Error(`The scip CLI is required but not found on PATH.
250
+ To install the reviewed version, run: scip-query reindex --install-missing
251
+ Or install manually from: https://github.com/sourcegraph/scip/releases`);if(t("scip CLI not found on PATH. Attempting auto-install..."),!bt(t))throw new Error(`The scip CLI is required but could not be installed.
252
+ Install manually from: https://github.com/sourcegraph/scip/releases`)}}function Ao(e){let t=[],n=[],r=e.languages.map((a,o)=>({language:a,scipPath:e.languages.length>1?Z(e.tempOutputScip,a,o):e.tempOutputScip})),i=Object.fromEntries(r.map(({language:a,scipPath:o})=>[a,o]));for(let{language:a,scipPath:o}of r){let s=Lo({...e,language:a,scipPath:o});for(let d of s)"skipped"in d?Ar(n,d.skipped):t.push(d.prepared)}return{preparedRuns:t,skippedLanguages:n,languageOutputScipPaths:i}}function Lo(e){if(e.language!=="typescript"||e.typescriptProjectMode!=="workspace")return[ct({...e,id:e.language,label:e.language,outputScipPath:e.scipPath})];let t=e.preDiscoveredTypeScriptProjects??V(e.projectRoot,e.typescriptProjects);return t.length===0?[ct({...e,id:e.language,label:e.language,outputScipPath:e.scipPath})]:(e.onStatus(`Indexing TypeScript workspace as ${t.length} project shard(s).`),t.map((n,r)=>ct({...e,id:`typescript:${n}`,label:`typescript (${n})`,scipPath:Z(e.tempOutputScip,"typescript-project",r),outputScipPath:e.scipPath,pnpmWorkspaces:!1,projectPath:n})))}function ct(e){let t=ze(e.language),n=fe(t),r=In(t,e.projectRoot),i=e.trustProjectTools&&r?vn(t,e.projectRoot):null,a=N(t);if(!i&&!a&&r){let c=`${n} is available only as repository-local code at ${r}. Review that exact tool and rerun with --trust-project-tools.`;return e.onStatus(`Skipping ${e.language}: ${c}`),{skipped:{language:e.language,reason:c}}}if(!i&&!a&&!xn(t)){if(e.skipAutoInstall){let c=`${n} not found on PATH. To install the reviewed version, run: scip-query reindex --install-missing${t.installUrl?` (manual source: ${t.installUrl})`:""}`;return e.onStatus(`Skipping ${e.language}: ${c}`),{skipped:{language:e.language,reason:c}}}if(e.onStatus(`${n} not found. Attempting auto-install...`),!Pr(t,e.onStatus)){let c=`${n} could not be auto-installed. ${t.installUrl?`Install manually from ${t.installUrl}`:`Install ${n} and put it on PATH.`}`;return e.onStatus(`Skipping ${e.language}: ${c}`),{skipped:{language:e.language,reason:c}}}}let o=i?.canonicalPath??N(t);if(!o){let c=`${n} was not found after installation checks.`;return e.onStatus(`Skipping ${e.language}: ${c}`),{skipped:{language:e.language,reason:c}}}let{binary:s,args:d}=t.indexArgs({projectRoot:e.projectRoot,outputPath:e.scipPath,pnpmWorkspaces:e.pnpmWorkspaces,indexerBinary:o,projectPath:e.projectPath,configPath:e.language==="clojure"?e.clojureConfigPath:void 0});if(i&&!i.executable){let c=`${i.relativePath} is not executable; refusing project-local indexer.`;return e.onStatus(`Skipping ${e.language}: ${c}`),{skipped:{language:e.language,reason:c}}}return i&&e.onStatus(`Trusted project-local ${e.language} indexer ${i.relativePath} (${i.sha256.slice(0,12)}\u2026, ${i.canonicalPath}).`),{prepared:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,config:t,resolvedBinary:o,binary:s,args:d,env:jn(t,e.env,o),...i?{trustedProjectTool:i}:{}}}}function No(e,t){let n=new Map;for(let i of e)if(i.skipped)Ar(t,i.skipped);else{let a=`${i.language}\0${i.outputScipPath}`,o=n.get(a)??{language:i.language,outputScipPath:i.outputScipPath,scipPaths:[]};o.scipPaths.push(i.scipPath),n.set(a,o)}let r=[];for(let i of n.values())if(i.scipPaths.length>1)Jt(i.scipPaths,i.outputScipPath),r.push({language:i.language,scipPath:i.outputScipPath});else{let a=i.scipPaths[0];a!==i.outputScipPath&&_r(a,i.outputScipPath),r.push({language:i.language,scipPath:i.outputScipPath})}return{indexedOutputs:r}}function Ar(e,t){let n=e.find(r=>r.language===t.language);if(!n){e.push(t);return}n.reason.includes(t.reason)||(n.reason=`${n.reason}; ${t.reason}`)}function Co(e,t,n,r,i){if(e.length===0){let a=t.map(o=>` - ${o.language}: ${o.reason}`).join(`
252
253
  `);throw new Error(`No language indexers ran successfully. Install at least one indexer for the languages in this project.
253
254
  `+a)}if(t.length!==0&&(i(`Indexed ${e.length} language output(s); skipped or incomplete: ${t.map(a=>a.language).join(", ")}.`),!r))throw new Error(`Failed to index all required languages; preserving the previous index. Pass --allow-partial to intentionally write an incomplete index.
254
255
  `+t.map(a=>` - ${a.language}: ${a.reason}`).join(`
255
- `))}function Hn(e,t,n){if(e.length>1){n(`Merging ${e.length} language indexes...`);let r=performance.now(),i=xt(e.map(a=>a.scipPath),t);return nr(i,n),n(`Merged and sanitized SCIP indexes in ${(performance.now()-r).toFixed(0)}ms.`),!0}else e[0].scipPath!==t&&Vn(e[0].scipPath,t);return!1}function rs(e){let t;if(is(e)){let i=x(e.run.tempPaths.runDir,"typescript-affected.db");try{tr(e.incrementalTypeScript.affectedScipPath,e.run.onStatus),e.run.onStatus(`Converting ${e.incrementalTypeScript.affectedFiles.length} affected TypeScript document(s) to SQLite...`);let a=performance.now();Wn(e.incrementalTypeScript.affectedScipPath,i,e.env,e.run.onStatus),e.run.onStatus(`Converted affected SCIP documents in ${(performance.now()-a).toFixed(0)}ms.`);let s=fn({previousDbPath:e.run.paths.outputDb,miniDbPath:i,candidateDbPath:e.run.tempPaths.tempOutputDb,affectedFiles:e.incrementalTypeScript.affectedFiles});return e.run.onStatus(`Patched ${s.affectedDocumentCount} SQLite document(s) in ${(s.durationMs/1e3).toFixed(3)}s.`),{mode:"incremental",changedDocumentPaths:s.changedDocumentPaths,patchDurationMs:s.durationMs,converterDurationMs:performance.now()-a,scipCompanion:e.incrementalTypeScript.completeScipUpdated?"current":"deferred"}}catch(a){t=a instanceof Error?a.message:String(a),j(i,{force:!0}),j(e.run.tempPaths.tempOutputDb,{force:!0}),e.run.onStatus(`Incremental SQLite publication unavailable: ${t}. Falling back to complete conversion.`)}}let n=e.completeScipSanitized;e.completeScipAvailable||(n=e.materializeFullFallback());let r=performance.now();return Wn(e.run.tempPaths.tempOutputScip,e.run.tempPaths.tempOutputDb,e.env,e.run.onStatus,n),{mode:"full",converterDurationMs:performance.now()-r,...t?{fallbackReason:t}:{}}}function is(e){if(!e.incrementalTypeScript||e.skippedLanguages.length>0||!F(e.run.paths.outputDb)||!F(e.run.paths.outputScip))return!1;let t=new Set(e.reusedLanguages);return e.indexedOutputs.length===e.run.languages.length&&e.run.languages.every(n=>n==="typescript"||t.has(n))}function as(e,t){let n=Date.now(),r=[...t].sort(),i=new Set(r),a={addedFiles:[],modifiedFiles:r,deletedFiles:[],changedFiles:r,unchangedFiles:e.affectedFiles.filter(s=>!i.has(s)).sort()};return{version:1,status:"evaluated",refreshResult:"rebuilt",recordedAt:new Date().toISOString(),durationMs:Date.now()-n,manifest:e.manifest,plan:e.plan,comparison:a,evaluation:ke(e.plan,a,e.projectFileCount)}}function Wn(e,t,n,r,i=!1){if(r("Converting to SQLite..."),!F(e))throw new Error(`SCIP index not found at ${e} after indexing`);try{i||tr(e,r);let a=xe();if(!a)throw new Error("scip CLI is not available");va(a,["expt-convert","--output",t,e],{env:n,stdio:"pipe",maxBuffer:50*1024*1024})}catch(a){let s=a instanceof Error?a.message:String(a);throw new Error(`Failed to convert SCIP index to SQLite: ${s}`,{cause:a})}}function tr(e,t){let n=bt(e);nr(n,t)}function nr(e,t){e.removedDefinitionOccurrences!==0&&t(`Sanitized ${e.removedDefinitionOccurrences} invalid definition occurrences across ${e.touchedDocuments} documents before SQLite conversion.`)}function X(e,t,n){let r=_a(e)||".scip",i=me(e,r);return x(S(e),`${i}.${n+1}.${t}${r}`)}async function ss(e,t){for(let n=0;n<2;n++){let r=os(e,t);if(r)return r;let i=cs(e);if(i&&ds(t.trigger,i)){if(t.onStatus(`Manual reindex preempting watcher refresh started at ${i.startedAt}.`),!await us(i.pid))throw new Error(`Could not confirm the watcher's in-progress reindex (pid ${i.pid}) terminated for ${S(e)}; refusing to steal an active lock.`);j(e,{force:!0});continue}if(i&&!k(i.pid)){j(e,{force:!0});continue}throw new Error(`Another scip-query reindex is already running for ${S(e)}.`)}throw new Error(`Could not acquire scip-query reindex lock for ${S(e)}.`)}function os(e,t){let n;try{n=wa(e,"wx")}catch(i){if((typeof i=="object"&&i&&"code"in i?i.code:void 0)==="EEXIST")return null;throw i}let r={version:1,pid:process.pid,projectRoot:t.projectRoot,startedAt:new Date().toISOString(),trigger:t.trigger};return Da(n,JSON.stringify(r)+`
256
- `),()=>{try{Fa(n)}finally{j(e,{force:!0})}}}function cs(e){try{let t=JSON.parse(Se(e,"utf-8"));return typeof t.pid!="number"||!Number.isInteger(t.pid)||t.pid<=0?null:{version:1,pid:t.pid,projectRoot:typeof t.projectRoot=="string"?t.projectRoot:S(e),startedAt:typeof t.startedAt=="string"?t.startedAt:"unknown",trigger:t.trigger}}catch{return null}}function ds(e,t){return e?.kind==="manual-cli"&&ls(t?.trigger)}function ls(e){return e?.kind==="watch-source"||e?.kind==="watch-git-head"||e?.kind==="watch-git-index"||e?.kind==="watch-git-state"}async function us(e){return qn(e,"SIGTERM"),await zn(e,2e3)?!0:(qn(e,"SIGKILL"),zn(e,1e3))}function qn(e,t){try{process.kill(-e,t)}catch{try{process.kill(e,t)}catch{}}}async function zn(e,t){let n=Date.now()+t;for(;Date.now()<n;){if(!k(e))return!0;await ps(50)}return!k(e)}function ps(e){return new Promise(t=>setTimeout(t,e))}function rr(e,t,n){return Object.fromEntries(t.map(r=>{let i=Ae(r).markerFiles,a=r==="typescript"?{typescriptProjectMode:n.typescriptProjectMode??"single",typescriptProjects:ot(n.typescriptProjects)}:{typescriptProjectMode:"single",typescriptProjects:[]},s=r==="clojure"?gs(n.clojureConfigPath):void 0;return[r,{version:2,languages:[r],pnpmWorkspaces:r==="typescript"&&fs(n),...a,clojureConfigPath:s,files:ct(e,{language:r,markerFiles:i})}]}))}function gs(e){return e?.trim()||void 0}function fs(e){return e.typescriptProjectMode!=="workspace"&&e.pnpmWorkspaces===!0}function Ye(e,t){return x(S(e),"language-indexes",`${t}.scip`)}function ir(e){return x(S(e),"language-indexes","typescript-projects")}function be(e,t){return x(ir(e),`${Ge(t)}.scip`)}function V(e){try{return JSON.parse(Se(e,"utf-8"))}catch{return null}}function ar(e,t){try{let n=JSON.parse(Se(e,"utf-8"));return(n.version===2||n.version===3)&&n.status==="complete"&&w(n.fingerprint)===w(t)&&w([...n.indexedLanguages??[]].sort())===w(t.languages)}catch{return!1}}function Ke(e,t){O(e,t,{spacing:2,trailingNewline:!0})}function sr(e,t){try{let n=JSON.parse(Se(e,"utf-8"));if(n.version!==2&&n.version!==3)return;Ke(e,{...n,lastRefresh:t})}catch{}}function Pe(e){return{trigger:e.trigger??{kind:"unknown"},result:e.result,startedAt:new Date(e.start).toISOString(),completedAt:new Date().toISOString(),durationMs:Date.now()-e.start,indexedLanguages:e.languages?[...e.languages]:void 0,skipped:e.skipped?[...e.skipped]:void 0,error:e.error}}function w(e){return JSON.stringify(e)}var lr=process.env.SCIP_REINDEX_PROJECT_ROOT,ur=process.env.SCIP_REINDEX_OUTPUT_SCIP,pr=process.env.SCIP_REINDEX_OUTPUT_DB,or=process.env.SCIP_REINDEX_LANGUAGES,ms=Bt(process.env.SCIP_REINDEX_INDEXER_CONCURRENCY),hs=process.env.SCIP_REINDEX_PNPM_WORKSPACES==="1",cr=xs(process.env.SCIP_REINDEX_TYPESCRIPT_CONFIG),ys=process.env.SCIP_REINDEX_CLOJURE_CONFIG_PATH||void 0,Ss=Ps(process.env.SCIP_REINDEX_TRIGGER_KIND),bs=process.env.SCIP_REINDEX_TRIGGER_DETAIL;(!lr||!ur||!pr)&&(console.error("reindex-worker: missing required env vars"),process.exit(1));var dr=or?or.split(",").filter(Boolean):void 0;Qn({projectRoot:lr,outputScip:ur,outputDb:pr,languages:dr?.length?dr:void 0,pnpmWorkspaces:hs,typescriptProjectMode:cr.projectMode,typescriptProjects:cr.projects,clojureConfigPath:ys,indexerConcurrency:ms,trigger:{kind:Ss,detail:bs||void 0},onStatus:e=>process.stderr.write(`[reindex] ${e}
257
- `)}).then(()=>{process.exit(0)}).catch(e=>{console.error(`reindex-worker error: ${e}`),process.exit(1)});function Ps(e){switch(e){case"manual-cli":case"setup":case"watch-source":case"watch-git-head":case"watch-git-index":case"watch-git-state":return e;default:return"unknown"}}function xs(e){if(!e)return{};try{let t=JSON.parse(e);if(!t||typeof t!="object"||Array.isArray(t))return{};let n=t,r=n.projectMode==="single"||n.projectMode==="workspace"?n.projectMode:void 0,i=Array.isArray(n.projects)?n.projects.filter(a=>typeof a=="string"&&a.trim()!==""):void 0;return{projectMode:r,projects:i&&i.length>0?i:void 0}}catch{return{}}}
256
+ `))}function vr(e,t,n){if(e.length>1){n(`Merging ${e.length} language indexes...`);let r=performance.now(),i=Wt(e.map(a=>a.scipPath),t);return Nr(i,n),n(`Merged and sanitized SCIP indexes in ${(performance.now()-r).toFixed(0)}ms.`),!0}else e[0].scipPath!==t&&_r(e[0].scipPath,t);return!1}function $o(e){let t;if(Bo(e)){let i=I(e.run.tempPaths.runDir,"typescript-affected.db");try{Lr(e.incrementalTypeScript.affectedScipPath,e.run.onStatus),e.run.onStatus(`Converting ${e.incrementalTypeScript.affectedFiles.length} affected TypeScript document(s) to SQLite...`);let a=performance.now();Er(e.incrementalTypeScript.affectedScipPath,i,e.env,e.run.onStatus),e.run.onStatus(`Converted affected SCIP documents in ${(performance.now()-a).toFixed(0)}ms.`);let o=Kn({previousDbPath:e.run.paths.outputDb,miniDbPath:i,candidateDbPath:e.run.tempPaths.tempOutputDb,affectedFiles:e.incrementalTypeScript.affectedFiles});return e.run.onStatus(`Patched ${o.affectedDocumentCount} SQLite document(s) in ${(o.durationMs/1e3).toFixed(3)}s.`),{mode:"incremental",changedDocumentPaths:o.changedDocumentPaths,patchDurationMs:o.durationMs,converterDurationMs:performance.now()-a,scipCompanion:e.incrementalTypeScript.completeScipUpdated?"current":"deferred"}}catch(a){t=a instanceof Error?a.message:String(a),B(i,{force:!0}),B(e.run.tempPaths.tempOutputDb,{force:!0}),e.run.onStatus(`Incremental SQLite publication unavailable: ${t}. Falling back to complete conversion.`)}}let n=e.completeScipSanitized;e.completeScipAvailable||(n=e.materializeFullFallback());let r=performance.now();return Er(e.run.tempPaths.tempOutputScip,e.run.tempPaths.tempOutputDb,e.env,e.run.onStatus,n),{mode:"full",converterDurationMs:performance.now()-r,...t?{fallbackReason:t}:{}}}function Bo(e){if(!e.incrementalTypeScript||e.skippedLanguages.length>0||!F(e.run.paths.outputDb)||!F(e.run.paths.outputScip))return!1;let t=new Set(e.reusedLanguages);return e.indexedOutputs.length===e.run.languages.length&&e.run.languages.every(n=>n==="typescript"||t.has(n))}function Go(e,t){let n=P(),r=[...t].sort(),i=new Set(r),a={addedFiles:[],modifiedFiles:r,deletedFiles:[],changedFiles:r,unchangedFiles:e.affectedFiles.filter(o=>!i.has(o)).sort()};return{version:1,status:"evaluated",refreshResult:"rebuilt",recordedAt:new Date().toISOString(),durationMs:P()-n,manifest:e.manifest,plan:e.plan,comparison:a,evaluation:We(e.plan,a,e.projectFileCount)}}function Er(e,t,n,r,i=!1){if(r("Converting to SQLite..."),!F(e))throw new Error(`SCIP index not found at ${e} after indexing`);try{i||Lr(e,r);let a=Oe();if(!a)throw new Error("scip CLI is not available");so(a,["expt-convert","--output",t,e],{env:n,stdio:"pipe",maxBuffer:50*1024*1024,timeout:3e5,killSignal:"SIGKILL"})}catch(a){let o=a instanceof Error?a.message:String(a);throw new Error(`Failed to convert SCIP index to SQLite: ${o}`,{cause:a})}}function Lr(e,t){let n=Ht(e);Nr(n,t)}function Nr(e,t){e.removedDefinitionOccurrences!==0&&t(`Sanitized ${e.removedDefinitionOccurrences} invalid definition occurrences across ${e.touchedDocuments} documents before SQLite conversion.`)}function Z(e,t,n){let r=po(e)||".scip",i=Ie(e,r);return I(y(e),`${i}.${n+1}.${t}${r}`)}async function Uo(e,t){for(let n=0;n<2;n++){let r=Ho(e,t);if(r)return r;let i=Jo(e);if(i&&Br(t.trigger,i)){t.onStatus(`Manual reindex preempting watcher refresh started at ${i.startedAt}.`);let a;try{a=await qo(i)}catch(s){throw new Error(`Could not verify the watcher's in-progress reindex owner (pid ${i.pid}); refusing to steal an active lock: ${G(s)}`,{cause:s})}if(!a)throw new Error(`Could not confirm the watcher's in-progress reindex (pid ${i.pid}) terminated for ${y(e)}; refusing to steal an active lock.`);let o=Ae(e,{parseLegacy:Ee});if(!It(e,o,{parseLegacy:Ee}))throw new Error(`Reindex lock ownership changed before preemption completed for ${y(e)}.`);continue}throw new Error(`Another scip-query reindex is already running for ${y(e)}.`)}throw new Error(`Could not acquire scip-query reindex lock for ${y(e)}.`)}function Ho(e,t){let n=O(process.pid),r=Rt(e,{kind:"reindex",processIdentity:n,detail:{projectRoot:t.projectRoot,...process.env.SCIP_REINDEX_PROCESS_GROUP_LEADER==="1"?{processGroupLeader:!0}:{},...t.trigger?{trigger:t.trigger}:{}},parseLegacy:Ee});if(r.kind==="acquired"&&r.reclaimed){let i=Cr(r.reclaimed,e);i&&Br(t.trigger,i)?t.onStatus(`Manual reindex preempting watcher refresh started at ${i.startedAt}; its prior owner was already stale.`):t.onStatus(`Recovered an abandoned or incomplete reindex lock for ${y(e)}.`)}return r.kind==="acquired"?()=>{r.lock.release()}:null}function Jo(e){return Cr(Ae(e,{parseLegacy:Ee}),e)}var Ee=e=>{let t=$r(e,"");return t?{pid:t.pid,...t.processIdentity?{processIdentity:t.processIdentity}:{}}:null};function Cr(e,t){if(e.state==="valid"&&e.record?.kind==="reindex"){let n=e.record.detail??{};return{version:2,pid:e.record.pid,...e.record.processIdentity?{processIdentity:e.record.processIdentity}:{},...n.processGroupLeader===!0?{processGroupLeader:!0}:{},projectRoot:typeof n.projectRoot=="string"?n.projectRoot:y(t),startedAt:e.record.startedAt,trigger:n.trigger}}return $r(e.parsed,t)}function $r(e,t){try{let n=e;return typeof n.pid!="number"||!Number.isInteger(n.pid)||n.pid<=0?null:{version:n.version===2?2:1,pid:n.pid,...n.processIdentity===void 0?{}:(()=>{let r=Pt(n.processIdentity);return r?.pid===n.pid?{processIdentity:r}:{}})(),...n.processGroupLeader===!0?{processGroupLeader:!0}:{},projectRoot:typeof n.projectRoot=="string"?n.projectRoot:y(t),startedAt:typeof n.startedAt=="string"?n.startedAt:"unknown",trigger:n.trigger}}catch{return null}}function Br(e,t){return e?.kind==="manual-cli"&&Wo(t?.trigger)}function Wo(e){return e?.kind==="watch-source"||e?.kind==="watch-git-head"||e?.kind==="watch-git-index"||e?.kind==="watch-git-state"}async function qo(e){return!A(e.pid)||(dt(e),Fr(e,"SIGTERM"),await jr(e,2e3))?!0:(dt(e),Fr(e,"SIGKILL"),jr(e,1e3))}function Fr(e,t){if(e.processGroupLeader)try{process.kill(-e.pid,t);return}catch{if(!A(e.pid))return;dt(e)}try{process.kill(e.pid,t)}catch{}}async function jr(e,t){let n=P()+t;for(;P()<n;){if(wr(e))return!0;await zo(50)}return wr(e)}function dt(e){if(!e.processIdentity)throw new Error(`Refusing to signal reindex pid ${e.pid}: its ownership record has no process identity.`);let t=O(e.pid);if(!t)throw new Error(`Refusing to signal reindex pid ${e.pid}: its process identity is unavailable.`);if(!W(e.processIdentity,t))throw new Error(`Refusing to signal reindex pid ${e.pid}: its process identity does not match the ownership record.`)}function wr(e){if(!A(e.pid))return!0;if(!e.processIdentity)return!1;let t=O(e.pid);return t!==null&&!W(e.processIdentity,t)}function zo(e){return new Promise(t=>setTimeout(t,e))}function Gr(e,t,n){return Object.fromEntries(t.map(r=>{let i=ze(r).markerFiles,a=r==="typescript"?{typescriptProjectMode:n.typescriptProjectMode??"single",typescriptProjects:Et(n.typescriptProjects)}:{typescriptProjectMode:"single",typescriptProjects:[]},o=r==="clojure"?Xo(n.clojureConfigPath):void 0;return[r,{version:2,languages:[r],pnpmWorkspaces:r==="typescript"&&Ko(n),...a,clojureConfigPath:o,files:wt(e,{language:r,markerFiles:i})}]}))}function Xo(e){return e?.trim()||void 0}function Ko(e){return e.typescriptProjectMode!=="workspace"&&e.pnpmWorkspaces===!0}function ut(e,t){return I(y(e),"language-indexes",`${t}.scip`)}function Ur(e){return I(y(e),"language-indexes","typescript-projects")}function je(e,t){return I(Ur(e),`${Ze(t)}.scip`)}function ee(e){try{return De(ie(T(e,"reindex metadata")))}catch{return null}}function Hr(e,t){try{let n=ie(T(e,"reindex metadata"));if(n.kind!=="legacy"&&n.kind!=="supported")return!1;let r=n.metadata;return n.capabilities.publishableGeneration&&w(r.fingerprint)===w(t)&&w([...r.indexedLanguages??[]].sort())===w(t.languages)}catch{return!1}}function pt(e,t){Dt(e,t,{spacing:2,trailingNewline:!0})}function Jr(e,t){try{let n=De(ie(T(e,"reindex metadata")));if(!n)return;pt(e,{...n,lastRefresh:t})}catch{}}function we(e){return{trigger:e.trigger??{kind:"unknown"},result:e.result,startedAt:new Date(e.start).toISOString(),completedAt:new Date().toISOString(),durationMs:P()-e.monotonicStart,indexedLanguages:e.languages?[...e.languages]:void 0,skipped:e.skipped?[...e.skipped]:void 0,error:e.error}}function w(e){return JSON.stringify(e)}var Xr=process.env.SCIP_REINDEX_PROJECT_ROOT,Kr=process.env.SCIP_REINDEX_OUTPUT_SCIP,Vr=process.env.SCIP_REINDEX_OUTPUT_DB,Wr=process.env.SCIP_REINDEX_LANGUAGES,Vo=Sn(process.env.SCIP_REINDEX_INDEXER_CONCURRENCY),Yo=process.env.SCIP_REINDEX_PNPM_WORKSPACES==="1",qr=ns(process.env.SCIP_REINDEX_TYPESCRIPT_CONFIG),Qo=process.env.SCIP_REINDEX_CLOJURE_CONFIG_PATH||void 0,Zo=ts(process.env.SCIP_REINDEX_TRIGGER_KIND),es=process.env.SCIP_REINDEX_TRIGGER_DETAIL;(!Xr||!Kr||!Vr)&&(console.error("reindex-worker: missing required env vars"),process.exit(1));var zr=Wr?Wr.split(",").filter(Boolean):void 0;Dr({projectRoot:Xr,outputScip:Kr,outputDb:Vr,languages:zr?.length?zr:void 0,pnpmWorkspaces:Yo,typescriptProjectMode:qr.projectMode,typescriptProjects:qr.projects,clojureConfigPath:Qo,indexerConcurrency:Vo,trigger:{kind:Zo,detail:es||void 0},onStatus:e=>process.stderr.write(`[reindex] ${Ge(e)}
257
+ `)}).then(()=>{process.exit(0)}).catch(e=>{console.error(`reindex-worker error: ${Ge(String(e))}`),process.exit(1)});function ts(e){switch(e){case"manual-cli":case"setup":case"watch-source":case"watch-git-head":case"watch-git-index":case"watch-git-state":return e;default:return"unknown"}}function ns(e){if(!e)return{};try{let t=JSON.parse(e);if(!t||typeof t!="object"||Array.isArray(t))return{};let n=t,r=n.projectMode==="single"||n.projectMode==="workspace"?n.projectMode:void 0,i=Array.isArray(n.projects)?n.projects.filter(a=>typeof a=="string"&&a.trim()!==""):void 0;return{projectMode:r,projects:i&&i.length>0?i:void 0}}catch{return{}}}
258
258
  //# sourceMappingURL=reindex-worker.js.map