scip-query 0.19.4 → 0.19.6

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