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,30 +0,0 @@
1
- import{a as J}from"./chunk-P5XHIJHI.js";import{B as Ge,C as Qe,a as Yn,g as Jn,h as ge,i as Re,n as Gn,p as Qn,q as Zn,r as Ye,s as be,t as G,u as et,v as nt,w as he,x as tt,z as Je}from"./chunk-2CTX5CMX.js";import{g as Xn}from"./chunk-LM72NQ7T.js";import{b as Kn,e as z,f as ye,h as Vn,j as re,s as q,t as Se}from"./chunk-XYADIZHU.js";import{a as te,f as de,n as Hn,p as $n}from"./chunk-X6D5IC6I.js";import{B as Wn,E as zn,e as Bn,f as jn,s as $e}from"./chunk-YGAGTIDK.js";import{a as Nn,c as An,d as Ln,g as ze,i as He,k as On,m as Un,q as A,r as qn,s as w,u as me,v as Ke,w as Ve,x as ne}from"./chunk-L7SPDE73.js";import{a as pe}from"./chunk-64MNV6AB.js";function rt(t){let e=new Map,n=Er(t),r=new Map;return i=>{let s=wr(i),o=r.get(s);if(o!==void 0)return o;if(!n.has(i.file))return r.set(s,i.symbol),i.symbol;let a=e.get(i.file);a||(a=Pr(q(t,i.file)),e.set(i.file,a));let c=Fr(a,i);return r.set(s,c),c}}function wr(t){return`${t.file}\0${t.symbol}\0${t.line}`}function Er(t){return new Set(t.all("SELECT relative_path FROM documents").map(e=>e.relative_path))}function Pr(t){let e=new Map,n=new Map;for(let r of t){let i=e.get(r.leaf);i?i.push(r):e.set(r.leaf,[r]);let s=n.get(r.startLine);s?s.push(r):n.set(r.startLine,[r])}return{definitions:t,byLeaf:e,byStartLine:n}}function Fr(t,e){if(t.definitions.length===0)return e.symbol;let n=Ar(e.symbol),r=_r(t.byLeaf,n),i=Nr(r,e.line);if(i)return i.symbol;let s=t.byStartLine.get(e.line)??[];return s.length===1?s[0].symbol:e.symbol}function _r(t,e){let n=[],r=new Set;for(let i of e)for(let s of t.get(i)??[])r.has(s.symbolId)||(r.add(s.symbolId),n.push(s));return n}function Nr(t,e){let n=null;for(let r of t)if(!(r.startLine>e||r.endLine<e)){if(r.startLine===e)return r;(!n||r.endLine-r.startLine<n.endLine-n.startLine)&&(n=r)}return n}function Ar(t){let e=new Set([t]),r=t.split(/::|\.|#/).filter(Boolean).at(-1);return r&&e.add(r),e}function it(t,e){let r=$n(t,e).map(i=>Or(e,i));return{usage:r,positions:Ur(t,e,r)}}function st(t,e){return{importUsage(n){let r=t.importUsageFacts(n);if(!e||r.positions.length===0)return r.usage;let i=e.importDefinitionsForFile(n,r.positions);return i.available?Lr(r.usage,i.sourcePaths):r.usage}}}function Lr(t,e){return t.map((n,r)=>{let i=e.get(String(r));return i?{...n,sourcePath:i}:n})}function Or(t,e){let n=e.isTypeOnly===!0,r=e.kind==="side-effect"||n||e.used;return{importer:t,sourcePath:e.sourcePath,importedName:e.importedName,localName:e.localName,kind:e.kind,isTypeOnly:n,isUsed:r,isTypeUsed:n,isValueUsed:e.kind==="side-effect"||!n&&e.used,references:[]}}function Ur(t,e,n){let r=zn(t,e);if(!r)return[];let i=Br(r.rootNode),s=new Map;for(let a of i){let c=s.get(Xe(a.importedName,a.localName));c?c.push(a.position):s.set(Xe(a.importedName,a.localName),[a.position])}let o=[];return n.forEach((a,c)=>{let l=s.get(Xe(a.importedName,a.localName??a.importedName))?.shift();l&&o.push({...l,id:String(c),file:e})}),o}function Br(t){let e=[];for(let n of t.descendantsOfType("use_declaration")){let r=n.namedChildren.find(i=>i.type!=="visibility_modifier");r&&e.push(...Ie(r,""))}return e.filter(n=>n.importedName!=="*")}function Ie(t,e){switch(t.type){case"identifier":case"super":case"self":case"crate":return[{importedName:t.text,localName:t.text,position:Ze(t,t.text)}];case"scoped_identifier":{let n=t.text.split("::").pop()??t.text;return[{importedName:n,localName:n,position:Ze(t,n)}]}case"scoped_use_list":{let n=t.namedChild(0),r=t.namedChild(1);if(!n||!r)return[];let i=Hn(e,n.text);return r.namedChildren.flatMap(s=>Ie(s,i))}case"use_list":return t.namedChildren.flatMap(n=>Ie(n,e));case"use_as_clause":{let n=t.namedChild(0),r=t.namedChild(1);return!n||!r?[]:Ie(n,e).map(i=>({...i,localName:r.text}))}case"use_wildcard":{let n=t.namedChild(0),r="*";return[{importedName:r,localName:r,position:Ze(n??t,r)}]}default:return[]}}function Ze(t,e){let n=Math.max(0,t.text.lastIndexOf(e));return{id:"",file:"",line:t.startPosition.row,column:t.startPosition.column+n+jr(e)}}function jr(t){return Math.max(0,Math.min(t.length-1,1))}function Xe(t,e){return`${t}\0${e}`}import{spawnSync as un}from"child_process";import{existsSync as fn}from"fs";import{fileURLToPath as Ei}from"url";function ve(t){let e=Jn(Yn,t),n=e.runnable;return{available:n,dependencyAvailable:n,resolvedBinary:e.resolvedBinary??void 0,reason:n?"rust-analyzer semantic reference queries are enabled.":"rust-analyzer is not runnable; Rust semantic checks will use SCIP/source evidence only."}}import{existsSync as mi,mkdtempSync as xt,readFileSync as Tt,rmSync as sn}from"fs";import{tmpdir as kt}from"os";import{join as on}from"path";import{fileURLToPath as Fe,pathToFileURL as di}from"url";import{SHARE_ENV as yi,Worker as Si}from"worker_threads";function W(t,e,n=new Set){let r=new Map;for(let i of t)n.has(i.symbolId)||r.set(i.symbolId,e.get(i.symbolId)??[]);return r}function H(t,e,n){let r=J(process.env.SCIP_RUST_SEMANTIC_BATCH_TIMEOUT_MS)??0;if(r>0)return r;let i=Math.max(1,Math.ceil(t/Math.max(1,n)));return Math.max(12e4,3e4+i*e)}import{spawn as ei}from"child_process";import{createHash as ni,randomUUID as ti}from"crypto";import{existsSync as Rt,mkdirSync as mt,readFileSync as we,realpathSync as ri,rmSync as rn}from"fs";import{tmpdir as ii}from"os";import{resolve as U}from"path";import{execFileSync as Jr}from"child_process";import{existsSync as qr,readFileSync as Wr}from"fs";import{deserializeSCIP as zr,SymbolRole as Hr}from"@c4312/scip";import{existsSync as yo,readFileSync as So}from"fs";import{relative as Ro,resolve as bo,sep as ho}from"path";import{fileURLToPath as vo,pathToFileURL as Mo}from"url";function Me(t){let e=new Map;for(let n of t)e.set(`${n.file}\0${n.line}\0${n.column}`,n);return[...e.values()].sort((n,r)=>{let i=n.file.localeCompare(r.file);return i!==0?i:n.line!==r.line?n.line-r.line:n.column-r.column})}var en=new WeakMap,$r="SCIP_RUST_SCIP_OCCURRENCE_REFERENCE_MODE";function ot(t,e){let n=new Map,r=De(),i=e.filter(o=>lt(o,r));if(i.length===0)return n;let s=ut(t);if(!s)return n;for(let o of i){let a=ct(s,o);a!==null&&n.set(o.symbolId,a)}return n}function at(t,e){if(!lt(e,De()))return null;let n=ut(t);return n?ct(n,e):null}function ct(t,e){return t.referencesBySymbol.get(e.symbol)??[]}function lt(t,e="safe"){if(!t.symbol.startsWith("rust-analyzer ")||!t.relativePath.endsWith(".rs")||re(t.symbol)||/impl#\[[^\]]+\]\[Default\]default\(\)\.$/.test(t.symbol))return!1;if(e==="all")return!0;let n=ye(t.symbol);if(n==="method")return!0;if(n!=="term")return!1;let r=Kn(t.symbol);return"kind"in r?!1:!Kr(r)}function Kr(t){for(let e=0;e<t.descriptors.length-1;e+=1)if(t.descriptors[e]?.suffix==="type")return!0;return!1}function ut(t){if(en.has(t))return en.get(t)??null;let e=Vr(t);return en.set(t,e),e}function Vr(t){if(!qr(t.config.indexPath))return null;try{let e=zr(Wr(t.config.indexPath)),n=new Map;for(let r of e.documents??[]){let i=r.relativePath;if(!(!i||t.isIgnored(i)))for(let s of r.occurrences??[]){if(!s.symbol||(s.symbolRoles&Hr.Definition)!==0)continue;let o=Yr(i,s.range);if(!o)continue;let a=n.get(s.symbol)??[];a.push(o),n.set(s.symbol,a)}}for(let[r,i]of n)n.set(r,Me(i));return{referencesBySymbol:n}}catch{return null}}function Yr(t,e){if(e.length<3)return null;let n=e[0],r=e[1];return!Number.isInteger(n)||!Number.isInteger(r)?null:{file:t,line:n,column:r}}function De(){return process.env[$r]==="all"?"all":"safe"}var ft=new Map;function nn(t){let n=ve(t).resolvedBinary??null;return{engine:"rust-analyzer",resolvedBinary:n,version:n?Gr(t,n):"unavailable"}}function tn(t){return{...nn(t),scipOccurrenceReferenceMode:De()}}function Gr(t,e){let n=`${t}\0${e}`,r=ft.get(n);if(r)return r;let i;try{i=Jr(e,["--version"],{cwd:t,encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:2e3}).trim()}catch{i="unknown"}return ft.set(n,i),i}import{createHash as Qr}from"crypto";var Zr=new Set(["Cargo.lock","Cargo.toml","rust-project.json","rust-toolchain","rust-toolchain.toml"]);function pt(t){let e=Gn(t,{includePath:Xr});return Qr("sha256").update(JSON.stringify(e)).digest("hex")}function Xr(t){let e=t.replaceAll("\\","/"),n=e.split("/").at(-1)??e;return e.endsWith(".rs")||Zr.has(n)?!0:e===".cargo/config"||e===".cargo/config.toml"||e.endsWith("/.cargo/config")||e.endsWith("/.cargo/config.toml")}var bt=2,si=5e3,oi=5e3,ht=10,ai=3e4;function dt(t,e,n,r=Ct){let i=r.engineIdentity(t),s={protocolVersion:bt,projectRoot:r.canonicalProjectRoot(t),projectFingerprint:r.projectFingerprint(t),engine:{engine:i.engine,resolvedBinary:i.resolvedBinary,version:i.version},workerFingerprint:r.fileFingerprint(e),environment:vt(r.environment())};return{key:ke(Te(s)),...s}}function Ce(t,e,n){return t.protocolVersion===bt&&(e-t.heartbeatAtMs<=si||t.busyUntilMs!==void 0&&e<=t.busyUntilMs)&&n(t.pid)}function It(t,e,n){let r;try{r=ke(we(e))}catch{r="missing"}let i=ke(Te({projectRoot:U(t),serverPath:U(e),serverFingerprint:r})).slice(0,20);return U(n,`scip-query-rust-session-${i}`)}function yt(t){let e=t===void 0?Number.NaN:Number(t);return Number.isInteger(e)&&e>=0?e:0}function vt(t){return Object.fromEntries(Object.entries(t).filter(([e])=>Dt(e)).sort(([e],[n])=>e.localeCompare(n)).map(([e,n])=>[e,n??null]))}function Mt(t,e){let n=e.runtime??pi,r=e.identityRuntime??Ct,i=It(t,e.serverPath,e.tempRoot??ii()),s=!1,o=(a,c)=>{if(s)throw new Error("Durable Rust semantic session was already disposed.");return li(i,e.serverPath,e.semanticWorkerPath,a,c,n)};return{requestSemantic(a,c){let l=dt(t,e.semanticWorkerPath,a,r),f=n.now()+Math.max(1,c-1e3);return o({kind:"semantic",identityKey:l.key,workerEnvironment:gt(),request:{...a,readinessDeadlineMs:f,referenceRetryTimeoutMs:ci(process.env.SCIP_RUST_SEMANTIC_REFERENCE_RETRY_TIMEOUT_MS,a.referenceRetryTimeoutMs),settleDelayMs:process.env.SCIP_RUST_SEMANTIC_SETTLE_MS===void 0?a.settleDelayMs:yt(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS)},timeoutMs:c},c)},requestImportDefinitions(a,c){let l=dt(t,e.semanticWorkerPath,a,r),f=n.now()+Math.max(1,c-1e3);return o({kind:"import-definitions",identityKey:l.key,workerEnvironment:gt(),request:{...a,readinessDeadlineMs:f,settleDelayMs:process.env.SCIP_RUST_SEMANTIC_SETTLE_MS===void 0?a.settleDelayMs:yt(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS)},timeoutMs:c},c)},shutdown(){s=!0}}}function ci(t,e){return e!==void 0?e:t===void 0?ai:void 0}function li(t,e,n,r,i,s){let o=s.randomId(),a=s.now(),c=U(t,"requests"),l=U(t,"responses"),f=U(c,`${o}.json`),u=U(l,`${o}.json`);mt(c,{recursive:!0}),mt(l,{recursive:!0}),Re(f,{id:o,request:r});let p=s.now()+i;try{for(St(t,e,n,p,s);s.now()<=p;){if(Rt(u)){let y=ui(we(u,"utf8"));if(!y.ok)throw new Error(y.error);return A()&&me({type:"span",name:"rust.semantic.durable-session.request",durationMs:s.now()-a,ok:!0,session:y.session,kind:r.kind}),y.response}let m=xe(t);(!m||!Ce(m,s.now(),s.isProcessAlive))&&St(t,e,n,p,s),s.sleep(ht)}throw new Error(`Durable Rust semantic session timed out after ${(i/1e3).toFixed(0)}s.`)}finally{rn(f,{force:!0}),rn(u,{force:!0})}}function St(t,e,n,r,i){let s=xe(t);if(s&&Ce(s,i.now(),i.isProcessAlive))return;rn(U(t,"server.json"),{force:!0}),i.spawnServer(e,t,n);let o=Math.min(r,i.now()+oi);for(;i.now()<=o;){let a=xe(t);if(a&&Ce(a,i.now(),i.isProcessAlive))return;i.sleep(ht)}throw new Error("Durable Rust semantic session helper did not become ready within 5s.")}function xe(t){try{let e=JSON.parse(we(U(t,"server.json"),"utf8"));return typeof e.protocolVersion!="number"||typeof e.pid!="number"||typeof e.heartbeatAtMs!="number"||e.busyUntilMs!==void 0&&typeof e.busyUntilMs!="number"?null:{protocolVersion:e.protocolVersion,pid:e.pid,heartbeatAtMs:e.heartbeatAtMs,...e.busyUntilMs===void 0?{}:{busyUntilMs:e.busyUntilMs}}}catch{return null}}function ui(t){try{let e=JSON.parse(t);return e.ok===!0&&(e.session==="created"||e.session==="reused"||e.session==="invalidated")&&e.response&&typeof e.response=="object"?{ok:!0,session:e.session,response:e.response}:{ok:!1,error:typeof e.error=="string"?e.error:"helper wrote an invalid response"}}catch(e){return{ok:!1,error:`helper wrote malformed JSON: ${e instanceof Error?e.message:String(e)}`}}}function gt(){return Object.fromEntries(Object.entries(process.env).filter(([t])=>fi(t)).sort(([t],[e])=>t.localeCompare(e)).map(([t,e])=>[t,e??null]))}function Dt(t){return t==="HOME"||t==="PATH"||t.startsWith("CARGO_")||t.startsWith("RA_")||t.startsWith("RUST")}function fi(t){return Dt(t)||t.startsWith("SCIP_RUST_")||t==="SCIP_QUERY_PROFILE"||t==="SCIP_QUERY_PROFILE_CACHE_STATE"||t==="SCIP_QUERY_PROFILE_COMMAND"||t==="SCIP_QUERY_PROFILE_OUT"||t==="SCIP_QUERY_PROFILE_RUN_ID"||t==="SCIP_QUERY_PROFILE_WORKLOAD_IDENTITY"||t==="SCIP_QUERY_PROFILE_WORKLOAD_IDENTITY_KIND"||t==="SCIP_QUERY_PROFILE_MIN_MS"}var Ct={canonicalProjectRoot(t){try{return ri(t)}catch{return U(t)}},projectFingerprint(t){return pt(t)},engineIdentity:nn,fileFingerprint(t){return ke(we(t))},environment(){return vt(process.env)}},pi={now:Date.now,randomId:ti,isProcessAlive:ge,spawnServer(t,e,n){if(!Rt(t))throw new Error(`Durable Rust semantic session helper was not found at ${t}. Run npm run build first.`);ei(process.execPath,[t,e,n],{detached:!0,stdio:"ignore"}).unref()},sleep(t){let e=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(e,0,0,t)}};function Te(t){return Array.isArray(t)?`[${t.map(Te).join(",")}]`:t&&typeof t=="object"?`{${Object.entries(t).sort(([e],[n])=>e.localeCompare(n)).map(([e,n])=>`${JSON.stringify(e)}:${Te(n)}`).join(",")}}`:JSON.stringify(t)}function ke(t){return ni("sha256").update(t).digest("hex")}var wt=15e3,Et=8,Ft=5e3,gi=64,Ri=96,cn=class{constructor(e,n,r={}){this.projectRoot=e;this.status=n;this.opts=r;this.requester=r.requester??vi(e,process.env.SCIP_RUST_SEMANTIC_DURABLE_SESSION)}projectRoot;status;opts;requester;referencesForDefinitions(e){let n=this.status(this.projectRoot);if(!n.available||!n.resolvedBinary)return{available:!1,resolvedBinary:n.resolvedBinary,reason:n.reason,references:ie(e)};try{let r=this.requestSession(n.resolvedBinary,e,{includeReferences:!0});return{available:r.available,resolvedBinary:n.resolvedBinary,reason:r.reason,references:W(e,new Map(r.references),new Set(r.incompleteReferenceSymbolIds??[]))}}catch(r){return this.opts.fallbackReferenceResolver?.referencesForDefinitions(e)??{available:!1,resolvedBinary:n.resolvedBinary,reason:r instanceof Error?r.message:String(r),references:ie(e)}}}calleesForDefinitions(e){let n=this.status(this.projectRoot);if(!n.available||!n.resolvedBinary)return{available:!1,resolvedBinary:n.resolvedBinary,reason:n.reason,callees:se(e)};try{let r=this.requestSession(n.resolvedBinary,e,{includeReferences:!1,includeCallees:!0});return{available:r.available,resolvedBinary:n.resolvedBinary,reason:r.reason,callees:an(e,new Map(r.callees??[]))}}catch(r){return this.opts.fallbackCalleeResolver?.calleesForDefinitions(e)??{available:!1,resolvedBinary:n.resolvedBinary,reason:r instanceof Error?r.message:String(r),callees:se(e)}}}referencesAndCalleesForDefinitions(e,n){let r=this.status(this.projectRoot);if(!r.available||!r.resolvedBinary)return{available:!1,resolvedBinary:r.resolvedBinary,reason:r.reason,references:ie(e),callees:se(n)};let i=[...e,...n];try{let s=this.requestSession(r.resolvedBinary,i,{includeReferences:e.length>0,includeCallees:n.length>0,referenceDefinitions:e,calleeDefinitions:n});return{available:s.available,resolvedBinary:r.resolvedBinary,reason:s.reason,references:W(e,new Map(s.references),new Set(s.incompleteReferenceSymbolIds??[])),callees:an(n,new Map(s.callees??[]))}}catch(s){return this.fallbackReferencesAndCallees(r,e,n,s)}}signaturesForDefinitions(e){let n=this.status(this.projectRoot);if(!n.available||!n.resolvedBinary)return{available:!1,resolvedBinary:n.resolvedBinary,reason:n.reason,signatures:Pt(e)};try{let r=this.requestSession(n.resolvedBinary,e,{includeReferences:!1,includeCallees:!1,includeSignatures:!0});return{available:r.available,resolvedBinary:n.resolvedBinary,reason:r.reason,signatures:Ti(e,new Map(r.signatures??[]))}}catch(r){return this.opts.fallbackSignatureResolver?.signaturesForDefinitions(e)??{available:!1,resolvedBinary:n.resolvedBinary,reason:r instanceof Error?r.message:String(r),signatures:Pt(e)}}}importDefinitionsForFile(e,n){let r=this.status(this.projectRoot);if(n.length===0)return{available:r.available,resolvedBinary:r.resolvedBinary,reason:r.reason,sourcePaths:new Map};if(!r.available||!r.resolvedBinary)return{available:!1,resolvedBinary:r.resolvedBinary,reason:r.reason,sourcePaths:new Map(n.map(i=>[i.id,null]))};try{let i=this.requestImportDefinitions(r.resolvedBinary,e,n);return{available:i.available,resolvedBinary:r.resolvedBinary,reason:i.reason,sourcePaths:new Map(i.sourcePaths)}}catch(i){return{available:!1,resolvedBinary:r.resolvedBinary,reason:i instanceof Error?i.message:String(i),sourcePaths:new Map(n.map(s=>[s.id,null]))}}}dispose(){this.requester.shutdown()}requestSession(e,n,r){let i=Ee(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,wt),s=Pe(process.env.SCIP_RUST_SEMANTIC_REFERENCE_RETRY_TIMEOUT_MS,0),o=Ee(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,Et),a=Pe(process.env.SCIP_RUST_SEMANTIC_DIAGNOSTICS_TIMEOUT_MS,Math.min(i,1e4)),c=r.referenceDefinitions?[...r.referenceDefinitions]:void 0,l=r.calleeDefinitions?[...r.calleeDefinitions]:void 0,f=r.signatureDefinitions?[...r.signatureDefinitions]:void 0,u=oe(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS,{definitionCount:n.length,...r}),p={projectRoot:this.projectRoot,rustAnalyzerBinary:e,definitions:[...n],...c?{referenceDefinitions:c}:{},...l?{calleeDefinitions:l}:{},...f?{signatureDefinitions:f}:{},requestTimeoutMs:i,...r.includeReferences!==!1&&s>0?{referenceRetryTimeoutMs:s}:{},diagnosticsTimeoutMs:a,settleDelayMs:u,concurrency:o,includeReferences:r.includeReferences,includeCallees:r.includeCallees,includeSignatures:r.includeSignatures},m=ki(p);return w("rust.semantic.session.request",()=>this.requester.requestSemantic(p,H(m,ln(i,p.referenceRetryTimeoutMs),o)),()=>({definitions:n.length,operationDefinitions:m,referenceDefinitions:p.referenceDefinitions?.length,calleeDefinitions:p.calleeDefinitions?.length,signatureDefinitions:p.signatureDefinitions?.length,references:p.includeReferences!==!1,callees:p.includeCallees===!0,signatures:p.includeSignatures===!0,referenceRetryTimeoutMs:p.referenceRetryTimeoutMs}))}fallbackReferencesAndCallees(e,n,r,i){let s=n.length===0?{available:!0,references:ie(n)}:this.opts.fallbackReferenceResolver?.referencesForDefinitions(n),o=r.length===0?{available:!0,callees:se(r)}:this.opts.fallbackCalleeResolver?.calleesForDefinitions(r);return s&&o?{available:s.available&&o.available,resolvedBinary:s.resolvedBinary??o.resolvedBinary??e.resolvedBinary,reason:s.reason??o.reason,references:W(n,s.references),callees:an(r,o.callees)}:{available:!1,resolvedBinary:e.resolvedBinary,reason:i instanceof Error?i.message:String(i),references:ie(n),callees:se(r)}}requestImportDefinitions(e,n,r){let i=Ee(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,wt),s=Ee(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,Et),o=Pe(process.env.SCIP_RUST_SEMANTIC_DIAGNOSTICS_TIMEOUT_MS,Math.min(i,1e4)),a=Pe(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS,Ft),c={projectRoot:this.projectRoot,rustAnalyzerBinary:e,file:n,positions:[...r],requestTimeoutMs:i,diagnosticsTimeoutMs:o,settleDelayMs:a,concurrency:s};return w("rust.semantic.import-definitions.session.request",()=>this.requester.requestImportDefinitions(c,H(r.length,i,s)),()=>({file:n,positions:r.length}))}};function _t(t,e,n={}){return new cn(t,e,n)}function oe(t,e){let n=At(t);if(n!==null)return n;let r=e.includeReferences!==!1;return r&&e.includeCallees!==!0&&e.includeSignatures!==!0&&e.definitionCount<=gi||r&&e.includeCallees===!0&&e.includeSignatures!==!0&&e.definitionCount<=Ri?0:Ft}function bi(t){let e=t?.trim().toLowerCase(),n=e==="0"||e==="false"||e==="off"||e==="worker",r=e==="1"||e==="true"||e==="on"||e==="durable",i=e===void 0||e==="";return{transport:n||!i&&!r?"worker":"durable",source:i?"default":"environment",fallback:"worker",valid:i||n||r,optOut:"SCIP_RUST_SEMANTIC_DURABLE_SESSION=0"}}function hi(t){return bi(t).transport}function Ii(t,e){let n=null,r=!1,i=!1,s=!1,o=()=>n??=e(),a=()=>{i||(t.shutdown(),i=!0)},c=(f,u,p)=>{let m=xi(f);r=!0;try{a()}catch{}A()&&me({type:"span",name:"rust.semantic.durable-session.request",durationMs:p,ok:!1,kind:u,session:"worker-fallback",reason:m})},l=(f,u,p)=>{if(s)throw new Error("Rust semantic failover session was already disposed.");if(r)return p(o());let m=Date.now();try{return u(t)}catch(y){c(y,f,Date.now()-m)}return p(o())};return{requestSemantic(f,u){return l("semantic",p=>p.requestSemantic(f,u),p=>p.requestSemantic(f,u))},requestImportDefinitions(f,u){return l("import-definitions",p=>p.requestImportDefinitions(f,u),p=>p.requestImportDefinitions(f,u))},shutdown(){if(s)return;s=!0;let f=[];try{a()}catch(u){f.push(u)}try{n?.shutdown()}catch(u){f.push(u)}if(f.length>0)throw f[0]}}}function vi(t,e,n={worker:()=>Mi(),durable:()=>Mt(t,{serverPath:Fe(wi()),semanticWorkerPath:Fe(Nt())})}){return hi(e)==="durable"?Ii(n.durable(),n.worker):n.worker()}function Mi(t={}){let e=null,n=null,r=1,i=!1,s=()=>{n&&(sn(n,{recursive:!0,force:!0}),n=null)},o=()=>{let l=e;e=null,l&&l.terminate(),s()},a=()=>{if(e)return e;let l=t.semanticWorkerPath?di(t.semanticWorkerPath):Nt();if(!mi(Fe(l)))throw new Error(`Rust semantic session worker was not found at ${Fe(l)}. Run npm run build before using built semantic Rust queries.`);return n=xt(on(kt(),"scip-query-rust-session-")),e=new Si(l,t.shareEnvironment?{env:yi}:void 0),e.unref(),e},c=()=>{let l=n??xt(on(kt(),"scip-query-rust-session-"));return n=l,on(l,`${r++}.json`)};return{requestSemantic(l,f){if(i)throw new Error("Rust semantic session was already disposed.");let u=a(),p=c(),m=new SharedArrayBuffer(4),y=new Int32Array(m);if(u.postMessage({kind:"semantic",request:l,responsePath:p,sharedBuffer:m}),Atomics.wait(y,0,0,f)==="timed-out")throw o(),new Error(`Rust semantic session worker timed out after ${(f/1e3).toFixed(0)}s`);try{let b=Di(Tt(p,"utf8"));if(!b.ok)throw new Error(b.error);return b.response}finally{sn(p,{force:!0})}},requestImportDefinitions(l,f){if(i)throw new Error("Rust semantic session was already disposed.");let u=a(),p=c(),m=new SharedArrayBuffer(4),y=new Int32Array(m);if(u.postMessage({kind:"import-definitions",request:l,responsePath:p,sharedBuffer:m}),Atomics.wait(y,0,0,f)==="timed-out")throw o(),new Error(`Rust semantic import-definition session worker timed out after ${(f/1e3).toFixed(0)}s`);try{let b=Ci(Tt(p,"utf8"));if(!b.ok)throw new Error(b.error);return b.response}finally{sn(p,{force:!0})}},shutdown(){if(i)return;if(i=!0,!e){s();return}let l=c(),f=new SharedArrayBuffer(4),u=new Int32Array(f);e.postMessage({kind:"shutdown",responsePath:l,sharedBuffer:f}),Atomics.wait(u,0,0,5e3),o()}}}function Di(t){let e=JSON.parse(t);if(!e||typeof e!="object")return{ok:!1,error:"Rust semantic session worker wrote a non-object response."};let n=e;return n.ok===!0&&"response"in n?{ok:!0,response:n.response}:{ok:!1,error:typeof e.error=="string"?e.error:"Rust semantic session worker failed."}}function Ci(t){let e=JSON.parse(t);if(!e||typeof e!="object")return{ok:!1,error:"Rust semantic session worker wrote a non-object response."};let n=e;return n.ok===!0&&"response"in n?{ok:!0,response:n.response}:{ok:!1,error:typeof e.error=="string"?e.error:"Rust semantic session worker failed."}}function xi(t){let e=t instanceof Error?`${t.name} ${t.message}`.toLowerCase():String(t).toLowerCase();return e.includes("readiness")?"readiness":e.includes("timeout")||e.includes("timed out")?"timeout":e.includes("helper")?"helper":"request"}function ie(t){return new Map(t.map(e=>[e.symbolId,[]]))}function se(t){return new Map(t.map(e=>[e.symbolId,[]]))}function Pt(t){return new Map(t.map(e=>[e.symbolId,null]))}function an(t,e){return new Map(t.map(n=>[n.symbolId,e.get(n.symbolId)??[]]))}function Ti(t,e){return new Map(t.map(n=>[n.symbolId,e.get(n.symbolId)??null]))}function ki(t){let e=0;return t.includeReferences!==!1&&(e+=(t.referenceDefinitions??t.definitions).length),t.includeCallees===!0&&(e+=(t.calleeDefinitions??t.definitions).length),t.includeSignatures===!0&&(e+=(t.signatureDefinitions??t.definitions).length),Math.max(1,e)}function ln(t,e){return e&&e>0?Math.max(t,e):t}function Nt(){return new URL("./rust-semantic-session-worker.js",import.meta.url)}function wi(){return new URL("./rust-semantic-session-server.js",import.meta.url)}function Ee(t,e){return J(t)??e}function Pe(t,e){return At(t)??e}function At(t){if(!t)return null;let e=Number(t);return Number.isInteger(e)&&e>=0?e:null}var pn=15e3,mn=8;function Bt(t,e={}){let n=e.status??ve,r=_i(t,n),i=Ni(t,n),s=Ai(t,n),o=e.referenceResolver||e.calleeResolver||e.signatureResolver||!Pi(e)?null:_t(t,n,{fallbackReferenceResolver:r,fallbackCalleeResolver:i,fallbackSignatureResolver:s}),a=e.referenceResolver??o??r,c=e.calleeResolver??o??i,l=e.signatureResolver??o??s,f=e.importUsageResolver??st(e.sourceImportUsageResolver??Fi(),e.importDefinitionResolver??o),u=e.calleeSymbolResolver,p=e.sourceZeroCalleeOracle,m=e.scipOccurrenceCalleeOracle,y=new Map,I=new Map,b=null,g=null,k=()=>(b??=n(t),b),P=()=>{let S=k();return S.dependencyAvailable?g??S:S},h=S=>{if(S.length===0)return new Map;let d=ae(S);try{let R=a.referencesForDefinitions(d),T=k();return g={...T,available:R.available,resolvedBinary:R.resolvedBinary??T.resolvedBinary,reason:R.reason??T.reason},R.available?new Map(R.references):W(d,R.references)}catch(R){return g={...k(),available:!1,reason:R instanceof Error?R.message:String(R)},$(d)}},x=S=>{if(S.length===0)return new Map;let d=ae(S),R=d.filter(Lt);if(R.length===0)return K(d);let T=new Map,j=Ut(R,m),_=[];for(let M of R)I.has(M.symbolId)?T.set(M.symbolId,I.get(M.symbolId)??[]):j.has(M.symbolId)?T.set(M.symbolId,j.get(M.symbolId)??[]):Ot(M,p)?T.set(M.symbolId,[]):_.push(M);if(_.length===0)return Q(d,T,void 0);try{let M=c.calleesForDefinitions(_),N=k();g={...N,available:M.available,resolvedBinary:M.resolvedBinary??N.resolvedBinary,reason:M.reason??N.reason};let E=Q(_,M.callees,u);for(let[Y,je]of E)T.set(Y,je);return Q(d,T,void 0)}catch(M){return g={...k(),available:!1,reason:M instanceof Error?M.message:String(M)},K(d)}},C=(S,d)=>{let R=ae(S),T=ae(d),j=T.filter(Lt),_=new Map,M=Ut(j,m),N=[];for(let E of j)M.has(E.symbolId)?_.set(E.symbolId,M.get(E.symbolId)??[]):Ot(E,p)?_.set(E.symbolId,[]):N.push(E);if(R.length===0&&N.length===0)return{references:$(R),callees:Q(T,_,void 0)};try{let E=o?o.referencesAndCalleesForDefinitions(R,N):Bi(a,c,{referenceDefinitions:R,calleeDefinitions:N}),Y=k();g={...Y,available:E.available,resolvedBinary:E.resolvedBinary??Y.resolvedBinary,reason:E.reason??Y.reason};let je=E.available?new Map(E.references):W(R,E.references);for(let[qe,We]of E.callees)_.set(qe,We);let _n=Q(T,_,u);for(let[qe,We]of _n)I.set(qe,We);return{references:je,callees:_n}}catch(E){return g={...k(),available:!1,reason:E instanceof Error?E.message:String(E)},{references:$(R),callees:K(T)}}},v=S=>{if(S.length===0)return new Map;let d=ae(S);try{let R=l.signaturesForDefinitions(d),T=k();return g={...T,available:R.available,resolvedBinary:R.resolvedBinary??T.resolvedBinary,reason:R.reason??T.reason},jt(d,R.signatures)}catch(R){return g={...k(),available:!1,reason:R instanceof Error?R.message:String(R)},_e(d)}};return{language:"rust",availability:P,dispose:()=>{o?.dispose()},importUsage:S=>{let d=y.get(S);if(d)return d;try{let R=f.importUsage(S);return y.set(S,R),R}catch(R){return g={...k(),available:!1,reason:R instanceof Error?R.message:String(R)},[]}},referencesFor:S=>h([S]).get(S.symbolId)??[],referencesForDefinitions:h,referencesAndCalleesForDefinitions:C,calleesFor:S=>x([S]).get(S.symbolId)??[],calleesForDefinitions:x,signatureFor:S=>v([S]).get(S.symbolId)??null}}function Pi(t){if(t.usePersistentSession!==void 0)return t.usePersistentSession;let e=process.env.SCIP_RUST_SEMANTIC_SESSION;return e!=="0"&&e!=="false"}function Fi(){return{importUsageFacts:()=>({usage:[],positions:[]})}}function ae(t){return t.map(e=>{let n=e;return{...e,leaf:typeof n.leaf=="string"?n.leaf:z(e.symbol),parentTypeName:n.parentTypeName??null,isFunctionLike:typeof n.isFunctionLike=="boolean"?n.isFunctionLike:Vn(e.symbol),isTypeLike:n.isTypeLike??!1,kind:n.kind??null,documentation:n.documentation??null,enclosingSymbol:n.enclosingSymbol??null}})}function Lt(t){return t.isFunctionLike}function Ot(t,e){if(!e)return!1;try{return e(t)}catch{return!1}}function Ut(t,e){if(!e||t.length===0)return new Map;try{return e(t)}catch{return new Map}}function _i(t,e){return{referencesForDefinitions:n=>Li(t,e,n)}}function Ni(t,e){return{calleesForDefinitions:n=>Oi(t,e,n)}}function Ai(t,e){return{signaturesForDefinitions:n=>Ui(t,e,n)}}function Li(t,e,n){let r=e(t);if(!r.available||!r.resolvedBinary)return{available:!1,resolvedBinary:r.resolvedBinary,reason:r.reason,references:$(n)};let i=dn();if(!fn(i))return{available:!1,resolvedBinary:r.resolvedBinary,reason:`Rust semantic worker was not found at ${i}. Run npm run build before using built semantic Rust queries.`,references:$(n)};let s=Z(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,pn),o=Ne(process.env.SCIP_RUST_SEMANTIC_REFERENCE_RETRY_TIMEOUT_MS,0),a=Z(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,mn),c=Ne(process.env.SCIP_RUST_SEMANTIC_DIAGNOSTICS_TIMEOUT_MS,Math.min(s,1e4)),l=oe(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS,{definitionCount:n.length,includeReferences:!0}),f={projectRoot:t,rustAnalyzerBinary:r.resolvedBinary,definitions:[...n],requestTimeoutMs:s,...o>0?{referenceRetryTimeoutMs:o}:{},diagnosticsTimeoutMs:c,settleDelayMs:l,concurrency:a},u=un(process.execPath,[i],{cwd:t,input:JSON.stringify(f),encoding:"utf8",maxBuffer:50*1024*1024,timeout:H(n.length,ln(s,f.referenceRetryTimeoutMs),a)}),p=yn(u.stdout);if(p)return{available:p.available,resolvedBinary:r.resolvedBinary,reason:p.reason,references:W(n,new Map(p.references),new Set(p.incompleteReferenceSymbolIds??[]))};let m=u.error instanceof Error?u.error.message:u.stderr.trim()||`Rust semantic worker exited with status ${u.status??"unknown"}.`;return{available:!1,resolvedBinary:r.resolvedBinary,reason:m,references:$(n)}}function Oi(t,e,n){let r=e(t);if(!r.available||!r.resolvedBinary)return{available:!1,resolvedBinary:r.resolvedBinary,reason:r.reason,callees:K(n)};let i=dn();if(!fn(i))return{available:!1,resolvedBinary:r.resolvedBinary,reason:`Rust semantic worker was not found at ${i}. Run npm run build before using built semantic Rust queries.`,callees:K(n)};let s=Z(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,pn),o=Z(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,mn),a=Ne(process.env.SCIP_RUST_SEMANTIC_DIAGNOSTICS_TIMEOUT_MS,Math.min(s,1e4)),c=oe(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS,{definitionCount:n.length,includeReferences:!1,includeCallees:!0}),l={projectRoot:t,rustAnalyzerBinary:r.resolvedBinary,definitions:[...n],requestTimeoutMs:s,diagnosticsTimeoutMs:a,settleDelayMs:c,concurrency:o,includeReferences:!1,includeCallees:!0},f=un(process.execPath,[i],{cwd:t,input:JSON.stringify(l),encoding:"utf8",maxBuffer:50*1024*1024,timeout:H(n.length,s,o)}),u=yn(f.stdout);if(u)return{available:u.available,resolvedBinary:r.resolvedBinary,reason:u.reason,callees:Q(n,new Map(u.callees??[]),void 0)};let p=f.error instanceof Error?f.error.message:f.stderr.trim()||`Rust semantic worker exited with status ${f.status??"unknown"}.`;return{available:!1,resolvedBinary:r.resolvedBinary,reason:p,callees:K(n)}}function Ui(t,e,n){let r=e(t);if(!r.available||!r.resolvedBinary)return{available:!1,resolvedBinary:r.resolvedBinary,reason:r.reason,signatures:_e(n)};let i=dn();if(!fn(i))return{available:!1,resolvedBinary:r.resolvedBinary,reason:`Rust semantic worker was not found at ${i}. Run npm run build before using built semantic Rust queries.`,signatures:_e(n)};let s=Z(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,pn),o=Z(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,mn),a=Ne(process.env.SCIP_RUST_SEMANTIC_DIAGNOSTICS_TIMEOUT_MS,Math.min(s,1e4)),c=oe(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS,{definitionCount:n.length,includeReferences:!1,includeCallees:!1,includeSignatures:!0}),l={projectRoot:t,rustAnalyzerBinary:r.resolvedBinary,definitions:[...n],requestTimeoutMs:s,diagnosticsTimeoutMs:a,settleDelayMs:c,concurrency:o,includeReferences:!1,includeCallees:!1,includeSignatures:!0},f=un(process.execPath,[i],{cwd:t,input:JSON.stringify(l),encoding:"utf8",maxBuffer:50*1024*1024,timeout:H(n.length,s,o)}),u=yn(f.stdout);if(u)return{available:u.available,resolvedBinary:r.resolvedBinary,reason:u.reason,signatures:jt(n,new Map(u.signatures??[]))};let p=f.error instanceof Error?f.error.message:f.stderr.trim()||`Rust semantic worker exited with status ${f.status??"unknown"}.`;return{available:!1,resolvedBinary:r.resolvedBinary,reason:p,signatures:_e(n)}}function Bi(t,e,n){let r=n.referenceDefinitions.length>0?t.referencesForDefinitions(n.referenceDefinitions):{available:!0,references:$(n.referenceDefinitions)},i=n.calleeDefinitions.length>0?e.calleesForDefinitions(n.calleeDefinitions):{available:!0,callees:K(n.calleeDefinitions)};return{available:r.available&&i.available,resolvedBinary:r.resolvedBinary??i.resolvedBinary,reason:r.reason??i.reason,references:r.references,callees:i.callees}}function $(t){return new Map(t.map(e=>[e.symbolId,[]]))}function K(t){return new Map(t.map(e=>[e.symbolId,[]]))}function _e(t){return new Map(t.map(e=>[e.symbolId,null]))}function Q(t,e,n){let r=0,i=0;return w("rust.semantic.callees.complete-map",()=>{let s=new Map;for(let o of t){let a=e.get(o.symbolId)??[];a.length>0&&(r+=1),i+=a.length,s.set(o.symbolId,a.map(c=>({...c,symbol:n?n(c):c.symbol})))}return s},()=>({definitions:t.length,rows:r,callees:i,resolveSymbols:!!n}))}function jt(t,e){return new Map(t.map(n=>[n.symbolId,e.get(n.symbolId)??null]))}function dn(){return Ei(new URL("./rust-semantic-worker.js",import.meta.url))}function yn(t){try{let e=JSON.parse(t);if(!e||typeof e!="object")return null;let n=e;return typeof n.available!="boolean"||!Array.isArray(n.references)?null:{available:n.available,reason:typeof n.reason=="string"?n.reason:void 0,references:n.references,incompleteReferenceSymbolIds:Array.isArray(n.incompleteReferenceSymbolIds)?n.incompleteReferenceSymbolIds.filter(r=>typeof r=="number"):void 0,callees:Array.isArray(n.callees)?n.callees:void 0,signatures:Array.isArray(n.signatures)?n.signatures:void 0}}catch{return null}}function Z(t,e){return J(t)??e}function Ne(t,e){if(!t)return e;let n=Number(t);return Number.isInteger(n)&&n>=0?n:e}import{existsSync as ji,readFileSync as qi}from"fs";import{deserializeSCIP as Wi,SymbolRole as zi}from"@c4312/scip";var Sn=new WeakMap;function Wt(t,e){let n=e.filter(Hi);if(n.length===0)return new Map;let r=!1,i=0,s=0;return w("rust.scip-occurrence.callees",()=>{let o=Vi(t);if(r=!!o,!o)return new Map;let a=new Map;for(let c of n){let l=$i(t,o,c);l!==null&&(a.set(c.symbolId,l),i+=1,s+=l.length)}return a},()=>({definitions:e.length,candidates:n.length,indexAvailable:r,resolvedDefinitions:i,resolvedCallees:s}))}function Hi(t){return!(!t.symbol.startsWith("rust-analyzer ")||!t.relativePath.endsWith(".rs")||!t.isFunctionLike||t.leaf==="main"||re(t.symbol))}function $i(t,e,n){let r=de(t,n.relativePath);if(!r||r.language!=="rust")return null;let i=r.callables.find(l=>l.startLine!==n.startLine||l.endLine!==n.endLine?!1:l.name===n.leaf||n.leaf.endsWith(l.name)||l.name.endsWith(n.leaf));if(!i)return null;let s=r.callSites.filter(l=>l.line>=i.startLine&&l.line<=i.endLine);if(s.length===0)return null;let o=(e.occurrencesByFile.get(n.relativePath)??[]).filter(l=>l.line>=i.startLine&&l.line<=i.endLine&&l.callee.symbol!==n.symbol);if(o.some(l=>l.traitImplMember)||!Ki(s,o))return null;let a=[],c=new Set;for(let l of o){let f=`${l.callee.symbol}\0${l.callee.file}\0${l.callee.line}`;c.has(f)||(c.add(f),a.push(l.callee))}return a}function Ki(t,e){let n=qt(t),r=qt(e);if(n.size!==r.size)return!1;for(let[i,s]of n)if(r.get(i)!==s)return!1;return!0}function qt(t){let e=new Map;for(let n of t){let r=n.calleeLeaf??n.leaf;if(!r)continue;let i=`${n.line}\0${r}`;e.set(i,(e.get(i)??0)+1)}return e}function Vi(t){if(Sn.has(t))return Sn.get(t)??null;let e=Yi(t);return Sn.set(t,e),e}function Yi(t){if(!ji(t.config.indexPath))return null;try{let e=Se(t).filter(s=>s.symbol.startsWith("rust-analyzer ")&&s.relativePath.endsWith(".rs")&&s.isFunctionLike),n=new Map(e.map(s=>[s.symbol,s])),r=Wi(qi(t.config.indexPath)),i=new Map;for(let s of r.documents??[]){let o=s.relativePath;if(!o||!o.endsWith(".rs")||t.isIgnored(o))continue;let a=[];for(let c of s.occurrences??[]){if(!c.symbol||(c.symbolRoles&zi.Definition)!==0)continue;let l=n.get(c.symbol);if(!l)continue;let f=c.range?.[0];Number.isInteger(f)&&a.push({line:f,leaf:l.leaf,traitImplMember:re(l.symbol),callee:{symbol:l.symbol,file:l.relativePath,line:l.startLine}})}i.set(o,a)}return{occurrencesByFile:i}}catch{return null}}var Ae=class{sessions=new WeakMap;getOrCreate(e,n,r){let i=Ji(e,n),s=this.sessions.get(e);s||(s=new Map,this.sessions.set(e,s));let o=s.get(i);if(o)return o.hits+=1,o.lastUsedAtMs=Date.now(),o.provider;let a=Date.now(),c=r();return s.set(i,{key:i,language:n,projectRoot:e.config.projectRoot,provider:c,createdAtMs:a,lastUsedAtMs:a,hits:1}),c}sessionsFor(e){return[...this.sessions.get(e)?.values()??[]]}clear(e){let n=this.sessions.get(e);if(n)for(let r of n.values())r.provider.dispose?.();this.sessions.delete(e)}};function Ji(t,e){return`${t.config.projectRoot}:${e}-workspace`}import{randomUUID as vs}from"crypto";import{existsSync as Ms,mkdirSync as cr,readFileSync as Ds,rmSync as lr}from"fs";import{dirname as Cs,resolve as ur}from"path";import{performance as D}from"perf_hooks";function L(t,e,n){if(t.has(e))return t.get(e);let r=n();return t.set(e,r),r}import zt from"path";function Gi(t,e){return t.getReferences().map(n=>{let r=n.getNode();return Le(r,e)})}function Qi(t){let e=t;return typeof e.findReferences=="function"?e.findReferences():[]}function Ht(t,e,n,r){let i=[];for(let s of Qi(t))for(let o of Gi(s,r))o.file===e.relativePath&&o.line>=e.startLine&&o.line<=e.endLine||i.push(o);for(let s of n)i.push(s);return X(i)}function $t(t,e,n,r){let i=[],s=n?.getStart();for(let o of t.getReferences()){let a=o.getNode();ee(r,a.getSourceFile().getFilePath())===e&&(s!==void 0&&a.getStart()===s||i.push({location:Le(a,r),node:a}))}return i}function Le(t,e){let n=t.getSourceFile(),r=n.getLineAndColumnAtPos(t.getStart());return{file:ee(e,n.getFilePath())??n.getBaseName(),line:r.line-1,column:r.column-1}}function Kt(t,e,n){let r=t.getSourceFile(),i=Rn(r,t),s=t.getText(),o=new RegExp(`\\b${te(s)}\\b`,"g"),a=r.getFullText().split(`
2
- `),c=[];for(let l=0;l<a.length;l++){if(l===i)continue;let f=a[l]??"";o.lastIndex=0;let u;for(;(u=o.exec(f))!==null;)c.push({file:e,line:l,column:u.index})}return X(c.filter(l=>ee(n,zt.join(n,l.file))===e))}function gn(t){for(let e=t;e;e=e.getParent()){let n=e.getKindName();if(n.includes("Type")||n==="InterfaceDeclaration"||n==="TypeAliasDeclaration")return!0;if(n==="CallExpression"||n==="NewExpression"||n==="ExpressionStatement")return!1}return!1}function Rn(t,e){return t.getLineAndColumnAtPos(e.getStart()).line-1}function X(t){let e=new Set,n=[];for(let r of t){let i=`${r.file}:${r.line}:${r.column}`;e.has(i)||(e.add(i),n.push(r))}return n}function ee(t,e){let n=zt.relative(t||process.cwd(),e).replace(/\\/g,"/");return!n||n.startsWith("..")?null:n}function Vt(t,e,n,r){let i=Zi(e,r);return i.size===0?new Map:Xi(t,n,i)}function Zi(t,e){let n=new Map;for(let r of q(t,e)){let i=z(r.symbol)??r.leaf;if(!i)continue;let s=n.get(i);s||(s=[],n.set(i,s)),s.push(r)}return n}function Xi(t,e,n){let r=new Map,i=new Map;return e.forEachDescendant(s=>{for(let o of es(t,s)){let a=n.get(o);if(!a)continue;let c=Rn(e,s);for(let l of a){if(c<l.startLine-1||c>l.endLine+1)continue;let f=Math.abs(c-l.startLine),u=i.get(l.symbolId);u!==void 0&&u<=f||(i.set(l.symbolId,f),r.set(l.symbolId,s))}}}),r}function es(t,e){let n=[],r=i=>{i&&!n.includes(i)&&n.push(i)};if("getNameNode"in e&&typeof e.getNameNode=="function"){let i=e.getNameNode();r(i?.getText())}if("getName"in e&&typeof e.getName=="function"){let i=e.getName();r(i)}return t.Node.isIdentifier(e)&&r(e.getText()),n}var ns=An("ts-definition-leaf-candidates",{clearGroups:["definition-catalog"]});function Yt(t,e,n,r){let i=In(t,e),s=bn(i.get(r)??[],n);if(s)return s;let o=[];for(let a of i.values())for(let c of a)((c.leaf||z(c.symbol)||"").includes(r)||c.symbol.includes(r))&&o.push(c);return bn(o,n)}function hn(t,e,n,r){return bn(In(t,e).get(r)??[],n)}function Jt(t,e){let n=new Map;for(let[r,i]of In(t,e)){let s=i[0];s&&n.set(r,s)}return n}function In(t,e){return ns.get(t,e,()=>{let n=new Map;for(let r of q(t,e)){let i=r.leaf||z(r.symbol);if(!i)continue;let s=n.get(i);s||(s=[],n.set(i,s)),s.push({...r,leaf:i})}for(let r of n.values())r.sort((i,s)=>i.startLine-s.startLine||i.endLine-s.endLine||i.symbolId-s.symbolId);return n})}function bn(t,e){let n=null,r=Number.POSITIVE_INFINITY;for(let i of t){let s=Math.abs(i.startLine-e);(s<r||s===r&&n&&i.startLine<n.startLine)&&(n=i,r=s)}return n}import vn from"path";function Gt(t,e){let n=new Map,r=null,i=null,s=()=>(i??=pe(t,{extensions:be}),i),o=()=>(r??=w("typescript.source-file-index",()=>ts(t.config.projectRoot,e,s()),()=>({projects:e.length,indexedDocuments:s().length})),r),a=c=>G(c)?L(n,c,()=>{let l=ce(vn.resolve(t.config.projectRoot,c));for(let{project:f,sourceFiles:u}of o()){let p=u.get(l)??null;if(p||(p=f.addSourceFileAtPathIfExists(l)??null,p&&u.set(ce(p.getFilePath()),p)),p)return{project:f,sourceFile:p}}return null}):null;return{sourceFile:c=>a(c)?.sourceFile??null,sourceFileMatch:a,indexedTypeScriptLikeDocuments:s}}function ts(t,e,n){let r=e.map(({project:i})=>({project:i,sourceFiles:new Map(i.getSourceFiles().map(s=>[ce(s.getFilePath()),s]))}));for(let i of n){let s=ce(vn.resolve(t,i));for(let o of r){if(o.sourceFiles.has(s))break;let a=o.project.addSourceFileAtPathIfExists(s)??null;if(a){o.sourceFiles.set(ce(a.getFilePath()),a);break}}}return r}function ce(t){return vn.resolve(t)}function Mn(t,e){for(let n of t)if(e===n.name||e.startsWith(`${n.name}/`))return n.name;return null}function Qt(t){let e=`${t.relativeDir}/src`;return[`${e}/index.ts`,`${e}/index.tsx`,`${e}/index.mts`,`${e}/index.cts`]}import{existsSync as le,readFileSync as rs}from"fs";import F from"path";var Dn=["tsconfig.json","tsconfig.app.json","tsconfig.node.json","tsconfig.base.json"];function Cn(t,e){let r=e?F.dirname(F.join(t,e)):t,i=F.resolve(t);for(;r.startsWith(i);){for(let o of Dn){let a=F.join(r,o);if(le(a))return a}let s=F.dirname(r);if(s===r)break;r=s}for(let s of Dn){let o=F.join(t,s);if(le(o))return o}return null}function Zt(t){let e=t.config.projectRoot,n=new Set(is(e,t.config.semantic?.typescript?.tsconfigs)),r=pe(t,{includeIgnored:!1,extensions:be});for(let i of r){let s=Cn(e,i);s&&n.add(F.resolve(s))}if(n.size===0){let i=Cn(e);i&&n.add(F.resolve(i))}return[...n].filter(i=>!Xt(e,i)).sort((i,s)=>i.localeCompare(s))}function is(t,e=[]){let n=new Set;for(let r of e){let i=F.isAbsolute(r)?r:F.join(t,r);le(i)&&n.add(F.resolve(i))}for(let r of ss(t))for(let i of Dn){let s=F.join(r,i);le(s)&&n.add(F.resolve(s))}if(n.size===0){let r=Cn(t);r&&n.add(F.resolve(r))}return[...n].filter(r=>!Xt(t,r)).sort((r,i)=>r.localeCompare(i))}function ss(t){let e=F.join(t,"package.json");if(!le(e))return[];let n;try{n=JSON.parse(rs(e,"utf8"))}catch{return[]}return(Array.isArray(n.workspaces)?n.workspaces:n.workspaces?.packages??[]).flatMap(i=>jn(t,i))}function Xt(t,e){let n=F.relative(t,e).replace(/\\/g,"/");return n.startsWith("..")||n.includes("/node_modules/")||n.startsWith("node_modules/")||n.includes("/dist/")||n.startsWith("dist/")}var os=32;function sr(t,e){let n=w("typescript.provider.load",()=>et());if(!n)return he("ts-morph is not installed");let r=w("typescript.provider.tsconfig-discovery",()=>Zt(t));if(r.length===0)return he("no tsconfig found");try{let i=w("typescript.provider.project-bundles",()=>nt(n,r),()=>({tsconfigs:r.length}));return as(t,n,i)}catch(i){return he(i instanceof Error?i.message:String(i),r[0],r)}}function as(t,e,n,r={}){return w("typescript.provider.construct",()=>new Tn(t,e,n),()=>({tsconfigs:n.length,reusedProjects:r.reusedProjects===!0}))}var Tn=class{constructor(e,n,r){this.db=e;this.tsMorph=n;this.projects=r;this.workspacePackages=Bn(e.config.projectRoot),this.sourceFiles=Gt(e,r)}db;tsMorph;projects;language="typescript";importUsageCache=new Map;referencesCache=new Map;calleesCache=new Map;fileCalleesCache=new Map;signatureCache=new Map;definitionNodeCache=new Map;fileDefinitionNodeCache=new Map;indexedDefinitionLeafCache=new Map;compilerCheckerCache=new WeakMap;packageImportReferenceIndex=null;packageExportIndex=null;workspacePackages;sourceFiles;availability(){return{available:!0,tsconfigPath:this.projects[0]?.tsconfigPath,tsconfigPaths:this.projects.map(e=>e.tsconfigPath)}}importUsage(e){return L(this.importUsageCache,e,()=>{let n=this.sourceFiles.sourceFile(e);if(!n)return[];let r=ls();return w("typescript.import-usage.file",()=>this.importUsageForSourceFile(e,n,r),()=>({file:e,...r}))})}referencesFor(e){return L(this.referencesCache,e.symbolId,()=>{let n=this.nodeForDefinition(e);return this.referencesForDefinitionNode(e,n)})}referencesForDefinitions(e,n={}){let r=new Map,i=A(),s=[];for(let f of e){let u=this.referencesCache.get(f.symbolId);u?r.set(f.symbolId,u):s.push(f)}if(s.length===0)return r;let o=s,a=n.exact?[]:s.filter(f=>!nr(f));if(a.length>=os){let f=this.referencesForDefinitionsBySymbolScan(a);for(let u of a){let p=f.get(u.symbolId)??[];this.referencesCache.set(u.symbolId,p),r.set(u.symbolId,p)}if(o=s.filter(u=>nr(u)),o.length===0)return r}let c=new Map;for(let f of o){let u=c.get(f.relativePath);u?u.push(f):c.set(f.relativePath,[f])}let l=[];for(let[f,u]of c){let p=tr();w("typescript.references-map.file",()=>{let m=this.definitionNodesForFile(f);for(let y of u){i&&(p.cacheMisses+=1);let I=m.get(y.symbolId)??null;i&&(I?p.nodeHits+=1:p.nodeMisses+=1);try{let b=this.referencesForDefinitionNode(y,I,i?p:void 0);this.referencesCache.set(y.symbolId,b),r.set(y.symbolId,b)}catch{p.preciseSearchFailures+=1,l.push(y)}}},()=>({relativePath:f,definitions:u.length,...rr(p)}))}if(l.length>0){let f=this.referencesForDefinitionsBySymbolScan(l);for(let u of l){let p=f.get(u.symbolId)??[];this.referencesCache.set(u.symbolId,p),r.set(u.symbolId,p)}}return r}referenceFragmentsForFiles(e){let n=Se(this.db).filter(s=>G(s.relativePath)),r=e.filter(s=>this.sourceFiles.sourceFile(s)!==null),i=this.referencesForDefinitionsBySymbolScan(n,r);return tt(n,i,r)}referencesForDefinitionsBySymbolScan(e,n){let r=A(),i=tr(),s=new Map,o=new Set(e.map(c=>c.symbolId)),a=new Map(e.map(c=>[c.symbolId,c]));for(let c of e)s.set(c.symbolId,[]);return w("typescript.references-map.inverted-scan",()=>{let c=r?D.now():0,l=n?this.packageImportReferencesForFiles(n):this.packageImportReferences();for(let b of e){let g=l.get(b.symbolId)??[];if(g.length>0){let k=s.get(b.symbolId)??[];k.push(...g),s.set(b.symbolId,k)}r&&(i.packageReferenceCount+=g.length)}r&&(i.packageRefsMs+=D.now()-c);let f=new Map,u=new Map,p=this.hierarchyTargetsForDefinitions(e),m=new Set(e.map(b=>b.leaf).filter(Boolean)),y=r?D.now():0;for(let b of n??this.sourceFiles.indexedTypeScriptLikeDocuments()){if(this.db.isIgnored(b))continue;let g=this.sourceFiles.sourceFile(b);g&&(r&&(i.scanFiles+=1),this.addReferencesFromSourceFileScan(g,b,o,a,p,m,f,u,s,r?i:void 0))}r&&(i.scanMs+=D.now()-y);let I=r?D.now():0;this.addHierarchyMemberReferences(e,s,r?i:void 0),r&&(i.hierarchyMs+=D.now()-I);for(let[b,g]of s){let k=X(g);s.set(b,k),r&&(i.referenceCount+=k.length)}},()=>({definitions:e.length,...rr(i)})),s}addReferencesFromSourceFileScan(e,n,r,i,s,o,a,c,l,f){let u=this.compilerCheckerForSourceFile(e),p=e.compilerNode,m=ps(e),y=I=>{if(this.tsMorph.ts.isIdentifier(I)){if(f&&(f.identifiers+=1),!o.has(I.text)&&!m.has(I.text)){this.tsMorph.ts.forEachChild(I,y);return}let b=this.compilerReferenceSymbol(u,I,f);if(b){let g;a.has(b)?g=a.get(b)??null:(g=this.referenceDefinitionFromCompilerSymbol(b),a.set(b,g)),f&&(g?f.targetHits+=1:f.targetMisses+=1);let k=L(c,b,()=>this.compilerSymbolKeys(b)),P=null,h=null,x=g&&r.has(g.symbolId)?i.get(g.symbolId):void 0;if(x&&(P=xn(p,I),!er(x,n,P))){let C=p.getLineAndCharacterOfPosition(I.getStart(p));h={file:n,line:C.line,column:C.character};let v=l.get(x.symbolId)??[];v.push(h),l.set(x.symbolId,v),f&&(f.requestedHits+=1)}for(let C of k)for(let v of s.get(C)?.values()??[]){if(P??=xn(p,I),er(v,n,P))continue;if(!h){let d=p.getLineAndCharacterOfPosition(I.getStart(p));h={file:n,line:d.line,column:d.character}}let S=l.get(v.symbolId)??[];S.push(h),l.set(v.symbolId,S),f&&(f.requestedHits+=1)}}}this.tsMorph.ts.forEachChild(I,y)};y(p)}hierarchyTargetsForDefinitions(e){let n=new Map;for(let r of e){let i=this.nodeForDefinition(r),s=i?.compilerNode;if(!s||!this.isHierarchyMethod(s))continue;let o=s.parent;if(!this.isHierarchyContainer(o))continue;let a=this.compilerCheckerForSourceFile(i.getSourceFile()),c=a.getSymbolAtLocation(s.name);if(c)for(let l of this.hierarchyMemberSymbols(a,o,c))for(let f of this.compilerSymbolKeys(l)){let u=n.get(f)??new Map;u.set(r.symbolId,r),n.set(f,u)}}return n}hierarchyMemberSymbols(e,n,r){let i=new Set,s=new Set,o=(a,c,l)=>{if(!s.has(a)){s.add(a),i.add(c);for(let f of l){let u=f.getProperty(r.name);u&&o(f,u,this.hierarchyAncestorTypesForType(e,f))}}};return o(e.getTypeAtLocation(n),r,this.hierarchyAncestorTypes(e,n)),i}addHierarchyMemberReferences(e,n,r){let i=new Map;for(let s of e){let o=this.nodeForDefinition(s),a=o?.compilerNode;if(!a||!this.isHierarchyMethod(a))continue;let c=a.parent;if(!this.isHierarchyContainer(c))continue;let l=this.compilerCheckerForSourceFile(o.getSourceFile()),f=l.getSymbolAtLocation(a.name);if(!f)continue;let u=a.getSourceFile(),p=u.getLineAndCharacterOfPosition(a.name.getStart(u)),m={definition:s,location:{file:s.relativePath,line:p.line,column:p.character}},y=n.get(s.symbolId)??[];for(let b of this.hierarchyMemberSymbols(l,c,f))if(b!==f)for(let g of this.compilerSymbolLocations(b))y.push(g),r&&(r.hierarchyReferences+=1);n.set(s.symbolId,y);let I=this.hierarchyRootMemberSymbols(l,c,f);for(let b of I){let g=i.get(b)??new Map;g.set(s.symbolId,m),i.set(b,g)}r&&(r.hierarchyDefinitions+=1)}for(let s of i.values())if(!(s.size<2)){r&&(r.hierarchyFamilies+=1);for(let{definition:o}of s.values()){let a=n.get(o.symbolId)??[];for(let c of s.values())c.definition.symbolId!==o.symbolId&&(a.push(c.location),r&&(r.hierarchyReferences+=1));n.set(o.symbolId,a)}}}hierarchyRootMemberSymbols(e,n,r){let i=new Set,s=new Set,o=(a,c,l)=>{if(s.has(a))return;s.add(a);let f=!1;for(let u of l){let p=u.getProperty(r.name);p&&(f=!0,o(u,p,this.hierarchyAncestorTypesForType(e,u)))}if(!f)for(let u of this.compilerSymbolKeys(c))i.add(u)};return o(e.getTypeAtLocation(n),r,this.hierarchyAncestorTypes(e,n)),i}compilerSymbolKeys(e){return(e.declarations??[]).map(n=>{let r=n.getSourceFile();return`${r.fileName}\0${n.getStart(r)}\0${e.name}`})}compilerSymbolLocations(e){let n=[];for(let r of e.declarations??[]){let i=r.getSourceFile(),s=ee(this.db.config.projectRoot,i.fileName);if(!s)continue;let o=r.name,a=i.getLineAndCharacterOfPosition((o??r).getStart(i));n.push({file:s,line:a.line,column:a.character})}return n}baseTypes(e,n){try{return e.getBaseTypes(n)??[]}catch{return[]}}hierarchyAncestorTypes(e,n){let r=new Set(this.hierarchyAncestorTypesForType(e,e.getTypeAtLocation(n)));for(let i of n.heritageClauses??[])for(let s of i.types)r.add(e.getTypeAtLocation(s));return[...r]}hierarchyAncestorTypesForType(e,n){let r=new Set(this.baseTypes(e,n));for(let i of n.getSymbol()?.declarations??[])if(this.isHierarchyContainer(i))for(let s of i.heritageClauses??[])for(let o of s.types)r.add(e.getTypeAtLocation(o));return[...r]}isHierarchyMethod(e){return this.tsMorph.ts.isMethodDeclaration(e)||this.tsMorph.ts.isMethodSignature(e)}isHierarchyContainer(e){return this.tsMorph.ts.isClassDeclaration(e)||this.tsMorph.ts.isClassExpression(e)||this.tsMorph.ts.isInterfaceDeclaration(e)}compilerReferenceSymbol(e,n,r){r&&(r.symbolLookups+=1);let i=e.getSymbolAtLocation(n);if(i){if((i.flags&this.tsMorph.ts.SymbolFlags.Alias)===0)return i;try{return r&&(r.aliasResolutions+=1),e.getAliasedSymbol(i)}catch{return i}}}calleesFor(e){return L(this.calleesCache,e.symbolId,()=>L(this.fileCalleesCache,e.relativePath,()=>this.calleeMapForFile(e.relativePath)).get(e.symbolId)??[])}calleesForDefinitions(e){let n=new Map,r=new Map;for(let i of e){let s=r.get(i.relativePath);s?s.push(i):r.set(i.relativePath,[i])}for(let[i,s]of r){let o=this.fileCalleesCache.get(i),a=new Set(s.map(l=>l.symbolId)),c=o??this.calleeMapForFile(i,a);for(let l of s){let f=c.get(l.symbolId)??[];this.calleesCache.set(l.symbolId,f),n.set(l.symbolId,f)}}return n}referencesForDefinitionNode(e,n,r){let i=r?D.now():0,s=this.packageImportReferencesForDefinition(e);if(r&&(r.packageRefsMs+=D.now()-i,r.packageReferenceCount+=s.length),!n)return s;let o=r?D.now():0,a=Ht(n,e,s,this.db.config.projectRoot);return r&&(r.semanticRefsMs+=D.now()-o,r.referenceCount+=a.length),a}signatureFor(e){return L(this.signatureCache,e.symbolId,()=>{let n=this.nodeForDefinition(e);if(!n||!this.tsMorph.Node.isFunctionDeclaration(n)&&!this.tsMorph.Node.isMethodDeclaration(n)&&!this.tsMorph.Node.isArrowFunction(n)&&!this.tsMorph.Node.isFunctionExpression(n)&&!this.tsMorph.Node.isConstructorDeclaration(n))return null;let r=n.getType().getCallSignatures()[0];if(!r)return null;let i=r.getParameters().map(o=>{let a=o.getDeclarations()[0],c=a?o.getTypeAtLocation(a).getText(a):o.getValueDeclaration()?.getType().getText()??"unknown";return ir(c)}),s=r.getReturnType().getText(n);return`(${i.join(",")})=>${ir(s)}`})}importUsageForSourceFile(e,n,r){let i=[],s=new Map;for(let o of n.getImportDeclarations()){r.declarations+=1;let a=$e(this.db,e,o.getModuleSpecifierValue()),c=o.getImportClause()?.isTypeOnly()??!1;for(let l of kn(o)){r.entries+=1;let f=c?null:l.identifier?.getSymbol()?.compilerSymbol??null;!c&&l.identifier&&(f?r.bindingSymbols+=1:r.missingBindingSymbols+=1);let u={sourcePath:a,entry:l,typeOnlyDeclaration:c,bindingSymbol:f,references:[]};if(i.push(u),c||!l.localName||!f)continue;let p=s.get(l.localName);p?p.push(u):s.set(l.localName,[u])}}return s.size>0&&n.forEachDescendant(o=>{if(o.getKindName()!=="Identifier")return;let a=s.get(o.getText());if(!a||us(o))return;r.scannedIdentifiers+=1;let c=o.getSymbol()?.compilerSymbol;if(r.symbolLookups+=1,!!c){for(let l of a)if(l.bindingSymbol===c){l.references.push({location:Le(o,this.db.config.projectRoot),node:o}),r.matchedReferences+=1;break}}}),i.map(o=>o.typeOnlyDeclaration?cs(e,o.sourcePath,o.entry):o.entry.identifier&&!o.bindingSymbol?(r.fallbackEntries+=1,this.valueImportUsageForEntry(e,o.sourcePath,o.entry)):this.valueImportUsageFromLocations(e,o.sourcePath,o.entry,o.references))}valueImportUsageForEntry(e,n,r){let i=r.identifier?r.identifier.findReferences():[],s=[];for(let o of i)for(let a of $t(o,e,r.identifier,this.db.config.projectRoot))s.push(a);return this.valueImportUsageFromLocations(e,n,r,s)}valueImportUsageFromLocations(e,n,r,i){let s=i.some(c=>!gn(c.node)),o=i.some(c=>gn(c.node)),a=r.isTypeOnly;return{importer:e,sourcePath:n,importedName:r.importedName,localName:r.localName,kind:r.kind,isTypeOnly:a,isUsed:a||i.length>0,isTypeUsed:a||o,isValueUsed:s,references:i.map(c=>c.location)}}packageImportReferencesForDefinition(e){return this.packageImportReferences().get(e.symbolId)??[]}packageImportReferencesForFiles(e){let n=new Map,r=new Set;for(let s of e){let o=this.sourceFiles.sourceFile(s);if(o)for(let a of o.getImportDeclarations()){let c=Mn(this.workspacePackages,a.getModuleSpecifierValue());c&&r.add(c)}}if(r.size===0)return n;let i=this.packageExportsForNames(r);for(let s of e)this.addPackageImportReferencesForDocument(n,i,s);for(let[s,o]of n)n.set(s,X(o));return n}packageImportReferences(){if(this.packageImportReferenceIndex)return this.packageImportReferenceIndex;let e=new Map,n=this.packageExports();for(let r of this.sourceFiles.indexedTypeScriptLikeDocuments())this.addPackageImportReferencesForDocument(e,n,r);for(let[r,i]of e)e.set(r,X(i));return this.packageImportReferenceIndex=e,e}addPackageImportReferencesForDocument(e,n,r){if(this.db.isIgnored(r))return;let i=this.sourceFiles.sourceFileMatch(r);if(i)for(let s of i.sourceFile.getImportDeclarations())this.addPackageImportReferencesForDeclaration(e,n,r,s)}addPackageImportReferencesForDeclaration(e,n,r,i){let s=Mn(this.workspacePackages,i.getModuleSpecifierValue());if(!s)return;let o=n.get(s);if(o)for(let a of kn(i)){if(a.kind!=="named"||!a.identifier)continue;let c=o.get(a.importedName);if(!c||c.size===0)continue;let l=Kt(a.identifier,r,this.db.config.projectRoot);l.length>0&&Ss(e,c,l)}}packageExports(){return this.packageExportIndex?this.packageExportIndex:(this.packageExportIndex=this.packageExportsForNames(new Set(this.workspacePackages.map(e=>e.name))),this.packageExportIndex)}packageExportsForNames(e){let n=new Map;for(let r of this.workspacePackages){if(!e.has(r.name))continue;let i=new Map;for(let s of Qt(r))this.collectPackageExports(r,s,i,new Set);i.size>0&&n.set(r.name,i)}return n}collectPackageExports(e,n,r,i){if(i.has(n))return;i.add(n);let s=this.sourceFiles.sourceFile(n);if(s)for(let o of s.getExportDeclarations()){let a=o.getModuleSpecifierValue(),c=a?$e(this.db,n,a):n;if(!c||!c.startsWith(`${e.relativeDir}/src/`))continue;let l=o.getNamedExports();if(l.length===0){if(o.isNamespaceExport())continue;this.collectPackageExports(e,c,r,i);continue}for(let f of l){let u=f.getNameNode().getText(),p=f.getAliasNode()?.getText()??u,m=this.indexedDefinitionByLeaf(c,u);if(!m)continue;let y=r.get(p);y||(y=new Set,r.set(p,y)),y.add(m.symbolId)}}}indexedDefinitionByLeaf(e,n){return L(this.indexedDefinitionLeafCache,e,()=>Jt(this.db,e)).get(n)??null}nodeForDefinition(e){return L(this.definitionNodeCache,e.symbolId,()=>this.definitionNodesForFile(e.relativePath).get(e.symbolId)??null)}definitionNodesForFile(e){return L(this.fileDefinitionNodeCache,e,()=>{let n=this.sourceFiles.sourceFile(e);return n?Vt(this.tsMorph,this.db,n,e):new Map})}referenceDefinitionFromCompilerSymbol(e){return this.definitionFromCompilerSymbol(e,void 0,!0)}definitionFromCompilerSymbol(e,n,r=!1){let i=e.name,s=n?D.now():0,o=e.declarations??[];n&&(n.declarationsMs+=D.now()-s,n.declarationChecks+=o.length);for(let a of o){let c=n?D.now():0,l=a.getSourceFile(),f=ee(this.db.config.projectRoot,l.fileName),u=l.getLineAndCharacterOfPosition(a.getStart(l)).line;if(n&&(n.declarationLocationMs+=D.now()-c),!f||this.db.isIgnored(f))continue;let p=n?D.now():0,m=this.compilerDeclarationName(a),y=r?hn(this.db,f,u,i)??(m&&m!==i?hn(this.db,f,u,m):null):Yt(this.db,f,u,i);if(n&&(n.indexedLookupMs+=D.now()-p),y)return{symbolId:y.symbolId,symbol:y.symbol,file:y.relativePath,line:y.startLine}}return null}compilerDeclarationName(e){let n=e.name;return n&&this.tsMorph.ts.isIdentifier(n)?n.text:null}calleeMapForFile(e,n){let r=A(),i=0,s=0,o=0,a=0,c=0,l=0,f=0,u=0,p=r?ds():void 0;return w("typescript.callee-map.file",()=>{let m=r?D.now():0,y=this.sourceFiles.sourceFile(e);if(r&&(c=Math.round(D.now()-m)),!y)return new Map;let I=r?D.now():0,b=q(this.db,e).sort((S,d)=>S.startLine-d.startLine||d.endLine-S.endLine);if(r&&(l=Math.round(D.now()-I)),i=b.length,b.length===0)return new Map;let g=new Map,k=r?D.now():0,P=this.compilerCheckerForSourceFile(y),h=y.compilerNode;r&&(f=Math.round(D.now()-k));let x=new Map,C=S=>{if(this.tsMorph.ts.isCallExpression(S)||this.tsMorph.ts.isNewExpression(S)){r&&(s+=1);let d=this.semanticCalleeForCallNode(P,h,b,S,x,n,p);d&&(r&&(o+=1),fs(g,d.callerId,d.target))}this.tsMorph.ts.forEachChild(S,C)},v=r?D.now():0;C(h),r&&(u=Math.round(D.now()-v));for(let[S,d]of g)g.set(S,gs(d));return a=g.size,g},()=>({relativePath:e,definitions:i,callNodes:s,resolvedCallees:o,outputRows:a,requestedDefinitions:n?.size??i,sourceFileLookupMs:c,definitionsLoadMs:l,checkerLookupMs:f,traversalMs:u,...p?ys(p):{}}))}semanticCalleeForCallNode(e,n,r,i,s,o,a){let c=a?D.now():0,l=ms(r,xn(n,i));if(a&&(a.callerLookupMs+=D.now()-c),!l)return null;if(o&&!o.has(l.symbolId))return a&&(a.skippedUnrequestedCallers+=1),null;let f=i.expression,u=this.compilerSymbolForExpression(e,f,a),p=null;if(u)if(a&&(a.targetSymbolHits+=1),s.has(u))a&&(a.compilerSymbolCacheHits+=1),p=s.get(u)??null;else{a&&(a.compilerSymbolCacheMisses+=1);let m=a?D.now():0;p=this.definitionFromCompilerSymbol(u,a),a&&(a.targetLookupMs+=D.now()-m),s.set(u,p)}else a&&(a.targetMisses+=1);return p?{callerId:l.symbolId,target:{symbol:p.symbol,file:p.file,line:p.line}}:null}compilerSymbolForExpression(e,n,r){let i=r?D.now():0,s=e.getSymbolAtLocation(n);if(r&&(r.expressionSymbolMs+=D.now()-i),s)return s;r&&(r.typeFallbacks+=1);let o=r?D.now():0,a=e.getTypeAtLocation(n).getSymbol();return r&&(r.typeSymbolMs+=D.now()-o),a}compilerCheckerForSourceFile(e){let n=e.getProject(),r=this.compilerCheckerCache.get(n);return r||(r=n.getTypeChecker().compilerObject,this.compilerCheckerCache.set(n,r)),r}};function kn(t){let e=[],n=t.getDefaultImport();n&&e.push({identifier:n,importedName:"default",localName:n.getText(),kind:"default",isTypeOnly:t.getImportClause()?.isTypeOnly()??!1});let r=t.getNamespaceImport();r&&e.push({identifier:r,importedName:"*",localName:r.getText(),kind:"namespace",isTypeOnly:t.getImportClause()?.isTypeOnly()??!1});for(let i of t.getNamedImports()){let s=i.getNameNode(),a=i.getAliasNode()??(s.getKindName()==="Identifier"?s:null);e.push({identifier:a,importedName:s.getText(),localName:a?.getText()??s.getText(),kind:"named",isTypeOnly:i.isTypeOnly()||(t.getImportClause()?.isTypeOnly()??!1)})}return e.length===0&&e.push({identifier:null,importedName:"*",localName:null,kind:"side-effect",isTypeOnly:!1}),e}function cs(t,e,n){return{importer:t,sourcePath:e,importedName:n.importedName,localName:n.localName,kind:n.kind,isTypeOnly:!0,isUsed:!0,isTypeUsed:!0,isValueUsed:!1,references:[]}}function ls(){return{declarations:0,entries:0,bindingSymbols:0,missingBindingSymbols:0,scannedIdentifiers:0,symbolLookups:0,matchedReferences:0,fallbackEntries:0}}function us(t){for(let e=t;e;e=e.getParent())if(e.getKindName()==="ImportDeclaration")return!0;return!1}function fs(t,e,n){let r=t.get(e);r||(r=[],t.set(e,r)),r.push(n)}function ps(t){let e=new Set;for(let n of t.getImportDeclarations())for(let r of kn(n))r.localName&&e.add(r.localName);return e}function ms(t,e){let n=null;for(let r of t)e<r.startLine||e>r.endLine||(!n||r.startLine>=n.startLine)&&(n=r);return n}function xn(t,e){return t.getLineAndCharacterOfPosition(e.getStart(t)).line}function er(t,e,n){return e===t.relativePath&&n>=t.startLine&&n<=t.endLine}function nr(t){return t.symbol.includes("#")?ye(t.symbol)==="type"&&t.relativePath.endsWith(".d.ts"):!1}function ds(){return{callerLookupMs:0,expressionSymbolMs:0,typeSymbolMs:0,targetLookupMs:0,declarationsMs:0,declarationLocationMs:0,indexedLookupMs:0,compilerSymbolCacheHits:0,compilerSymbolCacheMisses:0,targetSymbolHits:0,targetMisses:0,typeFallbacks:0,declarationChecks:0,skippedUnrequestedCallers:0}}function ys(t){return{...t,callerLookupMs:Math.round(t.callerLookupMs),expressionSymbolMs:Math.round(t.expressionSymbolMs),typeSymbolMs:Math.round(t.typeSymbolMs),targetLookupMs:Math.round(t.targetLookupMs),declarationsMs:Math.round(t.declarationsMs),declarationLocationMs:Math.round(t.declarationLocationMs),indexedLookupMs:Math.round(t.indexedLookupMs)}}function tr(){return{cacheHits:0,cacheMisses:0,nodeHits:0,nodeMisses:0,scanFiles:0,identifiers:0,symbolLookups:0,aliasResolutions:0,targetHits:0,targetMisses:0,requestedHits:0,scanMs:0,packageRefsMs:0,semanticRefsMs:0,packageReferenceCount:0,referenceCount:0,preciseSearchFailures:0,hierarchyDefinitions:0,hierarchyFamilies:0,hierarchyReferences:0,hierarchyMs:0}}function rr(t){return{...t,scanMs:Math.round(t.scanMs),packageRefsMs:Math.round(t.packageRefsMs),semanticRefsMs:Math.round(t.semanticRefsMs),hierarchyMs:Math.round(t.hierarchyMs)}}function Ss(t,e,n){for(let r of e){let i=t.get(r)??[];i.push(...n),t.set(r,i)}}function gs(t){let e=new Set,n=[];for(let r of t){let i=`${r.symbol}|${r.file}|${r.line}`;e.has(i)||(e.add(i),n.push(r))}return n}function ir(t){return t.replace(/\s+/g," ").replace(/\bimport\("[^"]+"\)\./g,"").trim()}import{createHash as Rs}from"crypto";import{readFileSync as bs}from"fs";import{dirname as hs,join as Oe}from"path";var Ue=2,Is="typescript-semantic";function or(t){let e=Oe(t,Is);return{rootDir:e,requestDir:Oe(e,"requests"),responseDir:Oe(e,"responses")}}function ar(t){try{let e=JSON.parse(bs(Oe(hs(t),"meta.json"),"utf8"));return e.version!==2&&e.version!==3||typeof e.status!="string"||typeof e.updatedAt!="string"||e.fingerprint===void 0?null:Rs("sha256").update(JSON.stringify({version:e.version,status:e.status,updatedAt:e.updatedAt,fingerprint:e.fingerprint,indexedLanguages:e.indexedLanguages})).digest("hex")}catch{return null}}var xs=12e4,Ts=5;function mr(t,e,n={}){let r=new wn(t,n),i=null,s=null,o=process.env.SCIP_QUERY_SKIP_WATCH_SERVICE==="1",a=()=>(i??=sr(t,e),i),c=(u,p,m)=>{if(o)return m();try{return p(r.request(u))}catch{return o=!0,m()}},l=(u,p)=>c({kind:"references",definitions:[...u],...p?.exact?{exact:!0}:{}},m=>pr(m),()=>a().referencesForDefinitions?.(u,p)??new Map(u.map(m=>[m.symbolId,a().referencesFor(m)]))),f=u=>c({kind:"callees",definitions:[...u]},p=>pr(p),()=>a().calleesForDefinitions?.(u)??new Map(u.map(p=>[p.symbolId,a().calleesFor(p)])));return{language:"typescript",availability:()=>(s??=c({kind:"availability"},Es,()=>a().availability()),s),importUsage:u=>c({kind:"import-usage",file:u},p=>p,()=>a().importUsage(u)),referencesFor:u=>l([u]).get(u.symbolId)??[],referencesForDefinitions:l,referenceFragmentsForFiles:u=>c({kind:"reference-fragments",files:[...u]},p=>ws(p),()=>a().referenceFragmentsForFiles?.(u)??new Map),calleesFor:u=>f([u]).get(u.symbolId)??[],calleesForDefinitions:f,signatureFor:u=>c({kind:"signature",definition:u},Ps,()=>a().signatureFor(u)),dispose:()=>i?.dispose?.()}}var wn=class{constructor(e,n={}){this.db=e;this.runtime=n.runtime??_s,this.timeoutMs=n.timeoutMs??Fs(),this.cacheDir=Cs(e.config.dbPath),this.projectRoot=Xn(e.config.projectRoot)}db;runtime;timeoutMs;cacheDir;projectRoot;request(e){let n=Zn(this.cacheDir),r=or(this.cacheDir),i=Ye(n.statePath);if(!fr(i,this.projectRoot,this.runtime))throw new Error("Compatible TypeScript semantic service is not running.");let s=ar(this.db.config.dbPath);if(!s)throw new Error("Published TypeScript generation identity is unavailable.");let o=this.runtime.randomId(),a=ur(r.requestDir,`${o}.json`),c=ur(r.responseDir,`${o}.json`),l=this.runtime.now()+this.timeoutMs;cr(r.requestDir,{recursive:!0}),cr(r.responseDir,{recursive:!0}),Re(a,{protocolVersion:Ue,id:o,generation:s,deadlineAtMs:l,profileEnvironment:qn(),request:e});try{for(;this.runtime.now()<=l;){if(Ms(c))return ks(Ds(c,"utf8"),o,s);let f=Ye(n.statePath);if(!fr(f,this.projectRoot,this.runtime))throw new Error("TypeScript semantic service stopped while processing a request.");this.runtime.sleep(Ts)}throw new Error(`TypeScript semantic service timed out after ${this.timeoutMs}ms.`)}finally{lr(a,{force:!0}),lr(c,{force:!0})}}};function fr(t,e,n){let r=t!==null&&n.now()-Date.parse(t.heartbeatAt)<=Qn,i=t?.typescriptSemantic?.busyUntil!==void 0&&n.now()<=Date.parse(t.typescriptSemantic.busyUntil);return t!==null&&t.projectRoot===e&&t.typescriptSemantic?.protocolVersion===Ue&&n.isProcessAlive(t.pid)&&(r||i)}function ks(t,e,n){let r=JSON.parse(t);if(r.protocolVersion!==Ue||r.id!==e||r.ok===!0&&r.generation!==n)throw new Error("TypeScript semantic service wrote an incompatible response.");if(r.ok===!0)return r.response;throw new Error(typeof r.error=="string"?r.error:"TypeScript semantic service request failed.")}function pr(t){if(!Array.isArray(t))throw new Error("TypeScript semantic service wrote an invalid numeric map.");return new Map(t)}function ws(t){if(!Array.isArray(t))throw new Error("TypeScript semantic service wrote an invalid string map.");return new Map(t)}function Es(t){if(!t||typeof t!="object"||typeof t.available!="boolean")throw new Error("TypeScript semantic service wrote invalid availability.");return t}function Ps(t){if(t!==null&&typeof t!="string")throw new Error("TypeScript semantic service wrote an invalid signature.");return t}function Fs(){let t=Number(process.env.SCIP_TYPESCRIPT_SEMANTIC_TIMEOUT_MS);return Number.isInteger(t)&&t>0?t:xs}var _s={now:Date.now,randomId:vs,sleep(t){let e=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(e,0,0,t)},isProcessAlive:ge};var dr=new Ae;Nn({name:"semantic-provider",groups:["semantic-provider"],clearAll:t=>dr.clear(t)});function V(t,e){let n=O(e)??"typescript";return dr.getOrCreate(t,n,()=>n==="rust"?Bt(t.config.projectRoot,{sourceImportUsageResolver:{importUsageFacts:r=>it(t,r)},calleeSymbolResolver:rt(t),sourceZeroCalleeOracle:r=>Ns(t,r),scipOccurrenceCalleeOracle:r=>Wt(t,r)}):mr(t,e))}function O(t){return t?Wn(t)==="rust"?"rust":G(t)?"typescript":null:"typescript"}function Ns(t,e){let n=de(t,e.relativePath);if(!n||n.language!=="rust")return!1;let r=n.callables.find(i=>i.startLine===e.startLine&&i.endLine===e.endLine&&i.name===e.leaf)??n.callables.find(i=>i.startLine===e.startLine&&i.endLine===e.endLine);return r?!n.callSites.some(i=>i.line>=r.startLine&&i.line<=r.endLine):!1}import{existsSync as As,readFileSync as Ls}from"fs";import{resolve as Os}from"path";function Oc(t,e){return Be(t,e,n=>{let r=n?`AND m.symbol_id IN (${n.map(()=>"?").join(",")})`:"";return t.all(`SELECT
3
- m.symbol_id,
4
- d.relative_path,
5
- COUNT(*) AS ref_count
6
- FROM mentions m
7
- JOIN chunks c ON m.chunk_id = c.id
8
- JOIN documents d ON c.document_id = d.id
9
- WHERE m.role != 1
10
- ${r}
11
- ${t.pathExclusionsFor("d")}
12
- GROUP BY m.symbol_id, d.relative_path`,...n??[])})}function Uc(t,e){return Be(t,e,n=>{let r=n?`AND m.symbol_id IN (${n.map(()=>"?").join(",")})`:"";return t.all(`SELECT DISTINCT m.symbol_id, d.relative_path
13
- FROM mentions m
14
- JOIN chunks c ON m.chunk_id = c.id
15
- JOIN documents d ON c.document_id = d.id
16
- WHERE m.role != 1
17
- ${r}
18
- ${t.pathExclusionsFor("d")}`,...n??[])}).filter(n=>n.symbol_id!==null)}function Bc(t,e){return Be(t,e,n=>{let r=n?`AND m.symbol_id IN (${n.map(()=>"?").join(",")})`:"";return t.all(`SELECT DISTINCT m.symbol_id
19
- FROM mentions m
20
- WHERE m.role != 1
21
- ${r}`,...n??[])}).filter(n=>n.symbol_id!==null)}function yr(t,e){return Be(t,e,n=>{let r=n?`AND m.symbol_id IN (${n.map(()=>"?").join(",")})`:"";return t.all(`SELECT DISTINCT m.symbol_id, d.relative_path, c.document_id,
22
- c.start_line AS chunk_start, c.end_line AS chunk_end
23
- FROM mentions m
24
- JOIN chunks c ON m.chunk_id = c.id
25
- JOIN documents d ON c.document_id = d.id
26
- WHERE m.role != 1
27
- ${r}
28
- ${t.pathExclusionsFor("d")}
29
- ORDER BY d.relative_path, c.start_line`,...n??[])})}function Be(t,e,n){if(!e)return n();if(e.length===0)return[];let r=[];for(let i=0;i<e.length;i+=750)r.push(...n(e.slice(i,i+750)));return r}var Us=/^[A-Za-z_][A-Za-z0-9_]*$/,Sr=/\bDefault::default\b/g,Bs=/^\.\.\s*Default::default\b/;function gr(t,e){let n=new Map,r=new Map;for(let i of e){let s=En(t,i,r);s!==null&&n.set(i.symbolId,s)}return n}function En(t,e,n=new Map){let r=qs(e.symbol);if(!r)return null;let i=yr(t,[e.symbolId]);if(i.length===0)return null;let s=new RegExp(`(^|[^A-Za-z0-9_])${te(r)}::default\\b`,"g"),o=new RegExp(`(^|[^A-Za-z0-9_])${te(r)}\\s*$`),a=js(t,e.symbolId),c=[];for(let l of i){let f=Ws(t,l.relative_path,n);if(f===null)return null;let u=f.split(/\r?\n/),p=0,m=[],y=0;for(let I=l.chunk_start;I<=l.chunk_end&&I<u.length;I+=1){let g=u[I]??"",k=new Set;s.lastIndex=0;let P;for(;P=s.exec(g);)c.push({file:l.relative_path,line:I,column:P.index+P[1].length+r.length+2}),y+=1;for(let h=0;h<g.length;h+=1){let x=Bs.exec(g.slice(h));if(x){if(a&&m.includes(p)){let v=h+x[0].lastIndexOf("default");c.push({file:l.relative_path,line:I,column:v}),k.add(v),y+=1}h+=x[0].length-1;continue}let C=g[h];if(C==="{"){let v=o.test(g.slice(0,h));p+=1,v&&m.push(p);continue}if(C==="}")for(p=Math.max(0,p-1);m.length>0&&m[m.length-1]>p;)m.pop()}for(Sr.lastIndex=0;P=Sr.exec(g);){let h=P.index+9;if(!k.has(h))return null}}if(y===0)return null}return Me(c)}function js(t,e){return t.get("SELECT 1 AS present FROM mentions WHERE symbol_id = ? AND role = 1 LIMIT 1",e)?.present===1}function qs(t){let e=/impl#\[([^\]]+)\]\[Default\]default\(\)\./.exec(t)?.[1]??null;return!e||!Us.test(e)?null:e}function Ws(t,e,n){if(n.has(e))return n.get(e)??null;let r=t.get("SELECT text FROM documents WHERE relative_path = ?",e),i=typeof r?.text=="string"?r.text:zs(t,e);return n.set(e,i),i}function zs(t,e){let n=Os(t.config.projectRoot,e);if(!As(n))return null;try{return Ls(n,"utf8")}catch{return null}}function Rr(t){let e=new Map;for(let n of t){let r=e.get(n.relativePath)??[];r.push(n),e.set(n.relativePath,r)}return e}var Hs="typescript-import-usage-v1",$s="typescript-signatures-v1",Pn=Ln("semantic-prefetched-callees",{clearGroups:["whole-project","source-file","semantic-provider"]}),br=Ve({kind:"semantic-import-usage",invalidation:ne("semantic-import-usage"),serialize:t=>JSON.stringify(t),deserialize:Tr}),hr=Ve({kind:"semantic-signatures",invalidation:ne("semantic-signatures"),serialize:t=>JSON.stringify(t),deserialize:no}),Ir=Ke({kind:"typescript-import-usage",invalidation:ne("typescript-import-usage"),serialize:t=>JSON.stringify(t),deserialize:Tr}),vr=Ke({kind:"typescript-signatures",invalidation:ne("typescript-signatures"),serialize:t=>JSON.stringify(t),deserialize:to});function fe(t){let e=new Map,n=new Set;return{capability:(r,i)=>kr(t,r,i),importUsage:r=>Vs(t,r),references:r=>Dr(t,r),materializeReferences:(r,i)=>Cr(t,r,e,n,i),callerMap:r=>Ys(t,r,e,n),calleeMap:r=>Zs(t,r),signature:r=>Xs(t,r)}}function Ks(t,e){if(e.size===0)return;let n=Pn.get(t,()=>new Map);for(let[r,i]of e)n.set(r,[...i])}function sl(t,e){if(!Pn.has(t))return{hits:[],misses:[...e]};let n=Pn.get(t,()=>new Map),r=[],i=[];for(let s of e)n.has(s.symbolId)?r.push({definition:s,callees:n.get(s.symbolId)??[]}):i.push(s);return{hits:r,misses:i}}function ol(t,e){return fe(t).importUsage(e)}function Vs(t,e){if(O(e)==="typescript"){let s="fallback",o=0,a=0,c=0,l=0;return w("typescript.import-usage.materialize",()=>{let f=Je(t,e,Hs);if(f?.key){o=1;let p=Ir.read(t,e,f.key);if(p)return s="hit",a=1,p;c=1;let m=B(t,e);if(!m)return s="unavailable",[];let y=m.importUsage(e);return Ir.write(t,e,f.key,y),s="computed",y}l=1;let u=B(t,e);return u?(s="direct-fallback",u.importUsage(e)):(s="unavailable",[])},()=>({state:s,eligible:o,cacheHits:a,cacheMisses:c,fallbacks:l}))}let n=xr(t,"semantic-import-usage",e);if(n){let s=br.read(t,e,n);if(s)return s}let r=B(t,e);if(!r)return[];let i=r.importUsage(e);return n&&br.write(t,e,n,i),i}function al(t,e){return fe(t).references(e)}function Dr(t,e){let n=En(t,e);if(n)return n;let r=at(t,e);if(r)return r;let i=B(t,e.relativePath);return i?i.referencesFor(e):[]}function cl(t,e){return fe(t).callerMap(e)}function ll(t,e){let n=new Map,r=new Map;for(let i of e){if(O(i.relativePath)==="typescript"){let s=B(t,i.relativePath);if(!s)continue;let o=r.get(s)??[];o.push(i),r.set(s,o);continue}Fn(t,n,i,Dr(t,i))}for(let[i,s]of r){let o=Qe(t,s,c=>V(t,c)),a=o?.references??(i.referencesForDefinitions?i.referencesForDefinitions(s,{exact:!0}):new Map(s.map(c=>[c.symbolId,i.referencesFor(c)])));!o&&A()&&Ge(t,s,a,c=>V(t,c));for(let c of s)Fn(t,n,c,a.get(c.symbolId)??[])}return n}function Ys(t,e,n=new Map,r=new Set){let i=new Map,s=Cr(t,e,n,r),o=0;return w("semantic.callers.from-references",()=>{for(let a of e)o+=Fn(t,i,a,n.get(a.symbolId)??[])},()=>({definitions:e.length,materialized:s.definitions,inMemoryHits:s.inMemoryHits,incompleteInMemoryHits:s.incompleteInMemoryHits,resultRows:i.size,callerFiles:o})),i}function Cr(t,e,n,r,i={}){let s=He(t),o=[],a=[],c=[],l=0,f=0,u=0,p=0,m=0,y=0,I=0,b=0,g=0,k=0,P=0,h=0,x=[],C=new Map,v=e.filter(d=>O(d.relativePath)==="typescript"&&!n.has(d.symbolId)&&!r.has(d.symbolId)),S=Qe(t,v,d=>V(t,d));if(S){g=v.length,k=S.cacheHits,P=S.cacheMisses,h=S.computedFiles;for(let d of v)n.set(d.symbolId,S.references.get(d.symbolId)??[])}if(w("semantic.references.cache-scan",()=>{for(let[d,R]of Rr(e)){let T=[];for(let M of R)n.has(M.symbolId)?f+=1:r.has(M.symbolId)?b+=1:T.push(M);if(T.length===0){I+=1;continue}let j=Js(t,s,d);if(!j){for(let M of T)O(M.relativePath)||(l+=1),c.push(M);continue}y+=1;let _=On(t,d,j);for(let M of T){let N=_.get(M.symbol)??null;if(N!==null){let E=Qs(N);if(E){u+=1,n.set(M.symbolId,E);continue}p+=1}a.push({definition:M,cacheFingerprint:j})}}},()=>({definitions:e.length,skippedUnsupportedLanguage:l,cacheHits:u,parseFailures:p,misses:a.length,unkeyed:c.length,inMemoryHits:f,incompleteInMemoryHits:b,fullyInMemoryFiles:I,cacheReadFiles:y})),a.length>0||c.length>0){x=[...c,...a.map(d=>d.definition)],C=w("semantic.references.compute-misses",()=>{let d=Gs(t,x,i);return m=d.size,d},()=>({definitions:x.length,misses:a.length,unkeyed:c.length,rows:m}));for(let d of x)C.has(d.symbolId)?(n.set(d.symbolId,C.get(d.symbolId)??[]),r.delete(d.symbolId)):r.add(d.symbolId);for(let{definition:d,cacheFingerprint:R}of a)C.has(d.symbolId)&&kr(t,"semantic-references",d.relativePath).available&&o.push({relativePath:d.relativePath,symbol:d.symbol,projectFingerprint:R,payload:JSON.stringify(C.get(d.symbolId)??[])})}return o.length>0&&w("semantic.references.cache-write",()=>Un(t,o),()=>({entries:o.length})),C.size>0&&Ge(t,x,C,d=>V(t,d)),{definitions:e.length,inMemoryHits:f,incompleteInMemoryHits:b,cacheHits:u,misses:a.length,unkeyed:c.length,skippedUnsupportedLanguage:l,parseFailures:p,computed:m,incomplete:r.size,cacheWrites:o.length,fragmentDefinitions:g,fragmentCacheHits:k,fragmentCacheMisses:P,fragmentComputedFiles:h}}function Js(t,e,n){if(!e)return null;let r=O(n);return r==="typescript"?e:r==="rust"?ze(JSON.stringify({kind:"semantic-references",language:r,engine:tn(t.config.projectRoot),projectFingerprint:e})):null}function Gs(t,e,n={}){let r=A(),i=new Map,s=0,o=0,a=0,c=0,l=0,f=0,u=0,p=0,m=0;return w("semantic.references.provider-loop",()=>{let y=gr(t,e),I=ot(t,e),b=new Map,g=n.prefetchCallees?new Map:null,k=[];for(let h of e){let x,C=()=>(x??=B(t,h.relativePath),x);if(g){let R=C();if(R?.referencesAndCalleesForDefinitions){let T=g.get(R);T?T.push(h):g.set(R,[h]),m+=1}}let v=y.get(h.symbolId);if(v){a+=1,c+=v.length,ue(i,h.symbolId,v,r,R=>{u+=1,p+=R});continue}let S=I.get(h.symbolId);if(S){l+=1,f+=S.length,ue(i,h.symbolId,S,r,R=>{u+=1,p+=R});continue}let d=C();if(!d){r&&(o+=1);continue}if(r&&(s+=1),d.referencesForDefinitions){let R=b.get(d);R?R.push(h):b.set(d,[h])}else k.push({provider:d,definition:h})}let P=new Set;if(g)for(let[h,x]of g){if(!h.referencesAndCalleesForDefinitions)continue;let C=b.get(h)??[],v=h.referencesAndCalleesForDefinitions(C,x);P.add(h),Ks(t,v.callees);for(let S of C){if(!v.references.has(S.symbolId))continue;let d=v.references.get(S.symbolId)??[];ue(i,S.symbolId,d,r,R=>{u+=1,p+=R})}}for(let[h,x]of b){if(P.has(h))continue;let C=h.referencesForDefinitions(x);for(let v of x){if(!C.has(v.symbolId))continue;let S=C.get(v.symbolId)??[];ue(i,v.symbolId,S,r,d=>{u+=1,p+=d})}}for(let{provider:h,definition:x}of k){let C=h.referencesFor(x);ue(i,x.symbolId,C,r,v=>{u+=1,p+=v})}return i},()=>({definitions:e.length,providerHits:s,providerMisses:o,rustDefaultFastPathRows:a,rustDefaultFastPathReferences:c,rustScipOccurrenceFastPathRows:l,rustScipOccurrenceFastPathReferences:f,prefetchCalleeDefinitions:m,definitionsWithReferences:u,referenceCount:p,rows:i.size}))}function ue(t,e,n,r,i){t.set(e,n),r&&n.length>0&&i(n.length)}function Fn(t,e,n,r){let i=0;for(let s of r){if(s.file===n.relativePath||t.isIgnored(s.file))continue;let o=e.get(n.symbolId);o||(o=new Set,e.set(n.symbolId,o));let a=o.size;o.add(s.file),o.size!==a&&(i+=1)}return i}function Qs(t){try{return JSON.parse(t)}catch{return null}}function ul(t,e){return fe(t).calleeMap(e)}function Zs(t,e){let n=A(),r=new Map,i=0,s=0,o=0,a=0;return w("semantic.callees.provider-loop",()=>{let c=new Map,l=[];for(let f of e){let u=B(t,f.relativePath);if(!u){n&&(s+=1);continue}n&&(i+=1);let p=f;if(u.calleesForDefinitions){let m=c.get(u);m?m.push(p):c.set(u,[p])}else l.push({provider:u,definition:p})}for(let[f,u]of c){let p=f.calleesForDefinitions(u);for(let m of u){let y=p.get(m.symbolId)??[];Mr(r,m.symbolId,y,n,I=>{o+=1,a+=I})}}for(let{provider:f,definition:u}of l){let p=f.calleesFor(u);Mr(r,u.symbolId,p,n,m=>{o+=1,a+=m})}return r},()=>({definitions:e.length,providerHits:i,providerMisses:s,definitionsWithCallees:o,calleeCount:a,rows:r.size}))}function Mr(t,e,n,r,i){n.length>0&&(t.set(e,n),r&&i(n.length))}function fl(t,e){return fe(t).signature(e)}function Xs(t,e){if(O(e.relativePath)==="typescript"){let o="fallback",a=0,c=0,l=0,f=0;return w("typescript.signature.materialize",()=>{let u=Je(t,e.relativePath,$s);if(u?.key){a=1;let m=vr.read(t,e.relativePath,u.key)??{};if(Object.prototype.hasOwnProperty.call(m,e.symbol))return o="hit",c=1,m[e.symbol]??null;l=1;let y=B(t,e.relativePath);if(!y)return o="unavailable",null;let I=y.signatureFor(e);return vr.write(t,e.relativePath,u.key,{...m,[e.symbol]:I}),o="computed",I}f=1;let p=B(t,e.relativePath);return p?(o="direct-fallback",p.signatureFor(e)):(o="unavailable",null)},()=>({state:o,eligible:a,cacheHits:c,cacheMisses:l,fallbacks:f}))}let n=xr(t,"semantic-signatures",e.relativePath),r=eo(e);if(n){let o=hr.read(t,r,n);if(o)return o.signature}let i=B(t,e.relativePath);if(!i)return null;let s=i.signatureFor(e);return n&&hr.write(t,r,n,{signature:s}),s}function xr(t,e,n){let r=He(t);if(!r)return null;let i=O(n);return i!=="rust"?null:ze(JSON.stringify({kind:e,language:i,engine:tn(t.config.projectRoot),projectFingerprint:r}))}function eo(t){return`${t.relativePath}\0${t.symbol}`}function Tr(t){try{let e=JSON.parse(t);return Array.isArray(e)?e:null}catch{return null}}function no(t){try{let e=JSON.parse(t);if(!e||typeof e!="object")return null;let n=e.signature;return n!==null&&typeof n!="string"?null:{signature:n}}catch{return null}}function to(t){try{let e=JSON.parse(t);if(!e||typeof e!="object"||Array.isArray(e))return null;for(let n of Object.values(e))if(n!==null&&typeof n!="string")return null;return e}catch{return null}}function kr(t,e,n){let r=O(n);if(!r)return{slot:e,language:"typescript",available:!1,reason:"semantic evidence is only available for TypeScript or Rust files"};try{return{slot:e,language:r,...V(t,n).availability()}}catch(i){return{slot:e,language:r,available:!1,reason:i instanceof Error?i.message:String(i)}}}function B(t,e){if(!O(e))return null;let n=V(t,e);return n.availability().available?n:null}export{Oc as a,Uc as b,Bc as c,yr as d,Rr as e,tn as f,O as g,fe as h,sl as i,ol as j,al as k,cl as l,ll as m,Gs as n,ul as o,fl as p};
30
- //# sourceMappingURL=chunk-U7DSEKOM.js.map
@@ -1,7 +0,0 @@
1
- import{a as o}from"./chunk-LM72NQ7T.js";import{execFileSync as l}from"child_process";import{createRequire as I}from"module";import{existsSync as E}from"fs";import{platform as a,arch as f}from"os";var m="v0.8.1",d="https://github.com/sourcegraph/scip",y="SCIP_QUERY_SCIP_BIN";function C(e){if(e.isOnPath("scip"))return{source:"path",path:"scip"};let t=e.env[y];if(t&&e.fileExists(t))return{source:"env",path:t};if(e.platform==="win32"){let r=e.resolveSidecar(e.arch);if(r&&e.fileExists(r))return{source:"sidecar",path:r}}return null}function P(e){let t=I(import.meta.url);for(let r of e==="arm64"?["arm64","x64"]:[e])try{return t.resolve(`scip-query-scip-windows/scip-win32-${r}.exe`)}catch{}return null}function h(e=process.env){return C({platform:a(),arch:f(),env:e,isOnPath:o,fileExists:E,resolveSidecar:P})?.path??null}function Z(){return h()!==null}function ee(){let e=h();if(!e)return null;try{return l(e,["--version"],{stdio:"pipe"}).toString().trim()}catch{return null}}function _(){let e=a(),t=f(),r,i,s;switch(e){case"darwin":r="darwin",s="tar.gz";break;case"linux":r="linux",s="tar.gz";break;default:return null}switch(t){case"arm64":i="arm64";break;case"x64":i="amd64";break;default:return null}let c=`scip-${r}-${i}.${s}`;return{url:`${d}/releases/download/${m}/${c}`,filename:c}}function te(){let e=_();console.log("\nThe `scip` CLI is required but not found on PATH.\n"),a()==="darwin"?(console.log("Install via Homebrew:"),console.log(` brew install sourcegraph/scip/scip
2
- `),console.log("Or download manually:")):a()==="win32"?(console.log("On Windows the scip binary ships via the npm sidecar package scip-query-scip-windows,"),console.log("installed automatically with scip-query. If it is missing:"),console.log(" npm install -g scip-query-scip-windows"),console.log(`Or set ${y} to a local scip.exe path.
3
- `),console.log("Upstream release page:")):console.log("Download from:"),console.log(e?` ${e.url}
4
- `:` ${d}/releases/tag/${m}
5
- `),console.log("After installing, ensure `scip` is on your PATH and run `scip-query reindex`.")}function re(e){if(a()==="darwin"&&o("brew")){e("Installing scip CLI via Homebrew...");try{if(l("brew",["install","sourcegraph/scip/scip"],{stdio:"inherit",timeout:3e5,env:process.env}),o("scip"))return e("Successfully installed scip CLI via Homebrew"),!0}catch(t){let r=t instanceof Error?t.message:String(t);e(`Homebrew install failed: ${r}`)}}if(o("go")){e("Installing scip CLI via go install...");try{if(l("go",["install","github.com/sourcegraph/scip/cmd/scip@latest"],{stdio:"inherit",timeout:3e5,env:process.env}),o("scip"))return e("Successfully installed scip CLI via go install"),!0}catch(t){let r=t instanceof Error?t.message:String(t);e(`go install failed: ${r}`)}}return e("Could not auto-install scip CLI."),e(`Install manually from: ${d}/releases`),!1}import{appendFileSync as D,existsSync as B,mkdirSync as O,readFileSync as se,renameSync as T,rmSync as L,statSync as x}from"fs";import{dirname as R,join as $}from"path";var N="reindex-activity.jsonl",k=".previous",M=1024*1024,ce=1440*60*1e3,H={appendFile:D,exists:B,mkdir:e=>O(e,{recursive:!0}),rename:T,remove:e=>L(e,{force:!0}),size:e=>x(e).size};function S(e){return $(R(e),N)}function j(e){if(e.reused)return 0;let t=v(e.indexPath)+v(e.dbPath);for(let r of e.shards??[])!r.reused&&r.outputBytes!==null&&(t+=r.outputBytes);return t}function ae(e,t){let r=t.lastRefresh;r&&A(S(e),{version:1,event:"run",recordedAt:r.completedAt,trigger:r.trigger,result:r.result,durationMs:r.durationMs,estimatedLogicalOutputBytes:j(t)})}function ue(e,t){A(S(e),{version:1,event:"run",recordedAt:t.completedAt,trigger:t.trigger,result:"failed",durationMs:t.durationMs,estimatedLogicalOutputBytes:0})}function F(e,t,r=M,i=H){let s=`${JSON.stringify(t)}
6
- `,c=Math.max(1,Math.floor(r)),u=`${e}${k}`;if(i.mkdir(R(e)),i.exists(e)){let g=i.size(e);g>c?(i.remove(e),i.remove(u)):g+Buffer.byteLength(s)>c&&(i.remove(u),i.rename(e,u))}i.appendFile(e,s)}function A(e,t){try{F(e,t)}catch{}}function v(e){try{return x(e).size}catch{return 0}}import{createHash as U}from"crypto";import{mkdirSync as Y,realpathSync as q}from"fs";import{homedir as V}from"os";import{join as n,resolve as w}from"path";function z(e,t){let r=process.env.SCIP_QUERY_CACHE_DIR;if(r)return p(r);if(t?.dbPath)return p(w(e,t.dbPath));let i=X(e);return p(i)}function b(){let e=process.env.XDG_CACHE_HOME;return n(e||n(V(),".cache"),"scip-query")}function X(e){let t=w(e);try{t=q(t)}catch{}let r=U("sha256").update(t).digest("hex").slice(0,12);return n(b(),"projects",r)}function me(e){if(!/^[a-f0-9]{24}$/.test(e))throw new Error(`invalid repository cache identity: ${e}`);return n(b(),"repositories",e)}function ye(e){return process.env.SCIP_QUERY_SHARED_CACHE!=="0"&&!process.env.SCIP_QUERY_CACHE_DIR&&!process.env.SCIP_QUERY_INDEX_DB&&!e?.dbPath}function he(e,t){let r=z(e,t);return{cacheDir:r,dbPath:n(r,"index.db"),indexPath:n(r,"index.scip"),metaPath:n(r,"meta.json")}}function p(e){return Y(e,{recursive:!0}),e}export{h as a,Z as b,ee as c,te as d,re as e,N as f,ae as g,ue as h,X as i,me as j,ye as k,he as l};
7
- //# sourceMappingURL=chunk-V27BEQJN.js.map
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env node
2
- import{Bc as Y,Cc as Q,Pc as X,Qc as Z,V as y,W as k,Wc as ee,b as B,ca as F,da as H,fa as w,ga as T,ha as b,ic as C,ja as _,jc as J,ka as U,kc as K,la as z,oa as L}from"./chunk-SVLTAG5O.js";import{spawn as ke}from"child_process";import{closeSync as we,existsSync as Ie,mkdirSync as We,openSync as Re,readFileSync as ie,rmSync as I,writeFileSync as be}from"fs";import{dirname as Ce,resolve as E}from"path";import{fileURLToPath as Ae}from"url";var te=5e3,Pe=2e3,oe=10,Ee=new Set(["bench","config-validate","hook-context","hook-stop","init","reindex","setup","setup-agent","setup-ci","setup-hooks","uninstall","watch","work-audit"]);function Je(e){let t=e.classification;if(t.kind!=="live")return;let{state:r}=t;return r.watcher.state==="idle"&&r.lastError===void 0?r.indexGeneration:void 0}function xe(e,t=process.env){return t.SCIP_QUERY_SKIP_WATCH_SERVICE!=="1"&&!e.startsWith("__")&&!Ee.has(e)}function Ke(e){let t=e.env??process.env;if(t.SCIP_QUERY_SKIP_WATCH_SERVICE==="1")return{kind:"skipped",reason:"environment"};if(!xe(e.commandName,t))return{kind:"skipped",reason:"excluded-command"};if(e.config.watch?.enabled!==!0)return{kind:"skipped",reason:"disabled"};try{let r=Te({projectRoot:e.projectRoot,cacheDir:e.cacheDir,cliVersion:e.cliVersion,gitContext:e.gitContext,runtime:e.runtime});return{kind:r.disposition,state:r.state}}catch(r){return{kind:"failed",message:r instanceof Error?r.message:String(r)}}}function se(e,t,r){let n=L(E(e));if(r&&L(r.projectRoot)===n)return{projectRoot:n,worktreeKind:"git",worktreeId:r.worktreeId,cliVersion:t};let i=U(n);if(i.kind==="error")throw new Error(`Could not establish Git worktree identity for ${n}: ${i.message}`);return i.kind==="non-git"?{projectRoot:n,worktreeKind:"non-git",cliVersion:t}:{projectRoot:n,worktreeKind:"git",worktreeId:i.identity.worktreeId,cliVersion:t}}function Ye(e){return P(e,se(e.projectRoot,e.cliVersion,e.gitContext))}function P(e,t){let r=e.runtime??O,n=w(e.cacheDir),i=T(n.statePath),s=m(n.lockPath);return{identity:t,classification:De(i,t,r.now(),r.isProcessAlive),lock:s,lockIsLive:s!==null&&r.isProcessAlive(s.pid),paths:n}}function Te(e){let t=e.runtime??O,r=se(e.projectRoot,e.cliVersion,e.gitContext),n=P(e,r),i=G("ensure",n.classification);if(i.kind==="reuse")return A(n.paths.activityPath,t),{disposition:"reused",state:i.state};if(i.kind==="replace")M(i.state.pid,e,t),W(n.paths,i.state.pid,t);else if(i.kind==="start"){if(n.lockIsLive){let o=re(e,r,t,Math.min(e.startupTimeoutMs??1e3,1e3));if(o)return A(n.paths.activityPath,t),{disposition:"reused",state:o};throw new Error(`scip-query watch is already running for ${E(e.projectRoot)} (pid ${n.lock?.pid}; lock: ${n.paths.lockPath}) without compatible daemon state. Stop the foreground watcher before starting the service.`)}n.classification.kind==="stale"&&W(n.paths,n.classification.state.pid,t)}else throw new Error(`Unexpected ensure action: ${i.kind}`);if(n=P(e,r),i=G("ensure",n.classification),i.kind==="reuse")return A(n.paths.activityPath,t),{disposition:"reused",state:i.state};let s=e.serverPath??Ae(new URL("./watch-server.js",import.meta.url));t.spawnServer(s,r.projectRoot,e.cliVersion,e.watchOverrides??{});let a=re(e,r,t,e.startupTimeoutMs??te);if(!a)throw new Error(`scip-query watch service did not become ready within ${e.startupTimeoutMs??te}ms.`);return A(n.paths.activityPath,t),{disposition:"started",state:a}}function ae(e){let t=e.runtime??O,r=w(e.cacheDir),n=T(r.statePath),i=n?t.isProcessAlive(n.pid)?{kind:"live",state:n}:{kind:"stale",state:n,reason:"dead-process"}:{kind:"stopped"},s=G("stop",i);if(s.kind==="signal-stop")return M(s.state.pid,e,t),W(r,s.state.pid,t),{disposition:"stopped",pid:s.state.pid};if(s.kind==="clean-stale")return W(r,s.state.pid,t),{disposition:"stopped",pid:s.state.pid};let a=m(r.lockPath);return s.kind==="already-stopped"&&a&&t.isProcessAlive(a.pid)?(M(a.pid,e,t),W(r,a.pid,t),{disposition:"stopped",pid:a.pid}):{disposition:"already-stopped"}}function _e(e,t=Date.now()){let r=Le(e);k(e,{version:1,at:new Date(t).toISOString(),...r?.refreshRequestedAtMs===void 0?{}:{refreshRequestedAt:new Date(r.refreshRequestedAtMs).toISOString(),...r.refreshDetail?{refreshDetail:r.refreshDetail}:{}}})}function Qe(e,t,r=Date.now()){k(e,{version:1,at:new Date(r).toISOString(),refreshRequestedAt:new Date(r).toISOString(),refreshDetail:t})}function Le(e){try{let t=JSON.parse(ie(e,"utf8"));return t.version!==1||!b(t.at)||t.refreshRequestedAt!==void 0&&!b(t.refreshRequestedAt)||t.refreshDetail!==void 0&&typeof t.refreshDetail!="string"?null:{atMs:Date.parse(t.at),...t.refreshRequestedAt===void 0?{}:{refreshRequestedAtMs:Date.parse(t.refreshRequestedAt)},...t.refreshDetail===void 0?{}:{refreshDetail:t.refreshDetail}}}catch{return null}}function Xe(e,t,r={}){let n=r.pid??process.pid,i=r.isProcessAlive??y,s=()=>{},a=m(e);if(a&&i(a.pid))return{acquired:!1,lockPath:e,message:ne(e,t,a),release:s};a&&I(e,{force:!0}),We(Ce(e),{recursive:!0});let o;try{o=Re(e,"wx")}catch(d){if(ce(d)==="EEXIST")return{acquired:!1,lockPath:e,message:ne(e,t,m(e)),release:s};throw d}let l={version:1,pid:n,projectRoot:E(t),startedAt:(r.now??(()=>new Date))().toISOString()};be(o,`${JSON.stringify(l)}
3
- `);let c=!1;return{acquired:!0,lockPath:e,message:"",release:()=>{if(c)return;c=!0,we(o);let d=m(e);d?.pid===l.pid&&d.startedAt===l.startedAt&&I(e,{force:!0})}}}function m(e){try{let t=JSON.parse(ie(e,"utf-8"));return t.version!==1||typeof t.pid!="number"||!Number.isInteger(t.pid)||t.pid<=0||typeof t.projectRoot!="string"||!b(t.startedAt)?null:t}catch{return null}}function De(e,t,r,n){if(!e)return{kind:"stopped"};if(e.protocolVersion!==F)return{kind:"incompatible",state:e,reason:"protocol"};if(e.projectRoot!==t.projectRoot)return{kind:"incompatible",state:e,reason:"project"};let i=t.worktreeKind==="git"?t.worktreeId:void 0;if(e.worktreeId!==i)return{kind:"incompatible",state:e,reason:"worktree"};if(e.cliVersion!==t.cliVersion)return{kind:"incompatible",state:e,reason:"cli-version"};if(!n(e.pid))return{kind:"stale",state:e,reason:"dead-process"};let s=Date.parse(e.heartbeatAt);return r-s>H?{kind:"stale",state:e,reason:"old-heartbeat"}:{kind:"live",state:e}}function G(e,t){switch(e){case"status":return{kind:"report",classification:t};case"ensure":switch(t.kind){case"stopped":return{kind:"start"};case"stale":return t.reason==="old-heartbeat"?{kind:"replace",state:t.state}:{kind:"start"};case"live":return{kind:"reuse",state:t.state};case"incompatible":return{kind:"replace",state:t.state};default:return D(t)}case"stop":switch(t.kind){case"stopped":return{kind:"already-stopped"};case"stale":return t.reason==="old-heartbeat"?{kind:"signal-stop",state:t.state}:{kind:"clean-stale",state:t.state};case"live":case"incompatible":return{kind:"signal-stop",state:t.state};default:return D(t)}default:return D(e)}}function re(e,t,r,n){let i=r.now()+n;for(;r.now()<=i;){let s=P(e,t).classification;if(s.kind==="live")return s.state;r.sleep(oe)}return null}function M(e,t,r){if(!r.isProcessAlive(e))return;r.signalProcess(e);let n=t.stopTimeoutMs??Pe,i=r.now()+n;for(;r.now()<=i;){if(!r.isProcessAlive(e))return;r.sleep(oe)}throw new Error(`scip-query watch service pid ${e} did not stop within ${n}ms.`)}function W(e,t,r){I(e.statePath,{force:!0}),I(e.activityPath,{force:!0}),m(e.lockPath)?.pid===t&&!r.isProcessAlive(t)&&I(e.lockPath,{force:!0})}function ne(e,t,r){return`error: scip-query watch is already running for ${E(t)}${r?` (pid ${r.pid}, started ${r.startedAt}; lock: ${e})`:` (lock: ${e})`}. Stop that watcher before starting another.`}function ce(e){return typeof e=="object"&&e&&"code"in e?e.code:void 0}function A(e,t){try{(t.recordActivity??_e)(e,t.now())}catch(r){let n=ce(r);if(n!=="EPERM"&&n!=="EACCES"&&n!=="EROFS")throw r}}var O={now:Date.now,isProcessAlive:y,spawnServer(e,t,r,n){if(!Ie(e))throw new Error(`Watch service helper was not found at ${e}. Run npm run build first.`);ke(process.execPath,[e,t,r,JSON.stringify(n)],{detached:!0,stdio:"ignore",env:{...process.env,SCIP_QUERY_SKIP_WATCH_SERVICE:"1"}}).unref()},signalProcess(e){process.kill(e,"SIGTERM")},sleep(e){let t=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(t,0,0,e)}};function D(e){throw new Error(`Unhandled watch service value: ${JSON.stringify(e)}`)}import{existsSync as pe,lstatSync as x,readFileSync as N,readdirSync as he,realpathSync as de,rmSync as R,statSync as fe}from"fs";import{join as h,resolve as g,sep as le}from"path";var Ge=3600*1e3,Me=2*1024*1024*1024,Oe=300*1e3;function je(e){let t=e.leases.filter(o=>o.managed&&!o.live&&!o.busy),r=Se(e.leases,e.locks),n={};for(let o of e.generations)r.has(o.generationId)||(n[o.generationId]=o.unreferencedAt??e.nowMs);let i=e.generations.filter(o=>!r.has(o.generationId)).sort((o,l)=>n[o.generationId]-n[l.generationId]||o.generationId.localeCompare(l.generationId)),s=new Set;for(let o of i)e.nowMs-n[o.generationId]>=e.policy.generationTtlMs&&s.add(o.generationId);let a=e.generations.filter(o=>!s.has(o.generationId)).reduce((o,l)=>o+l.size,0);for(let o of i){if(a<=e.policy.budgetBytes)break;s.has(o.generationId)||(s.add(o.generationId),a-=o.size)}for(let o of s)delete n[o];return{deleteWorktrees:t,deleteGenerations:e.generations.filter(o=>s.has(o.generationId)),deleteLocks:e.locks.filter(o=>!o.live),deleteTemporaries:e.temporaries.filter(o=>!o.live),protectedGenerationIds:[...r].sort(),unreferencedSince:n}}function Se(e,t){let r=new Set(e.filter(n=>n.managed&&(n.live||n.busy)).flatMap(n=>[n.lease.baseGenerationId,n.lease.activeGenerationId]).filter(n=>n!==void 0));for(let n of t)n.live&&r.add(n.generationId);return r}function ut(e,t,r={}){if(!K())return{kind:"disabled"};let n=_(e);if(!n)return{kind:"unavailable"};let i=h(C(),"repositories",n.repositoryId);if(!pe(i))return{kind:"unavailable"};let s=(r.now??Date.now)(),a=h(i,"gc-state.json"),o=me(a);if(!r.force&&o&&s-Date.parse(o.lastSweepAt)<Oe)return{kind:"throttled",sweptAt:o.lastSweepAt};let l=Y(i,{now:()=>s});if(!l)return{kind:"busy"};try{let c=ve(e,i,n.repositoryId,o?.unreferencedSince??{}),d=je({nowMs:s,...c,policy:{generationTtlMs:r.policy?.generationTtlMs??Ge,budgetBytes:r.policy?.budgetBytes??Me}}),u=0,f=0;for(let p of d.deleteWorktrees){if(!ye(p.lease))continue;let q=Q(h(p.lease.localCacheDir,"cache-lifecycle.lock"));if(q)try{if(V(p.lease,!0))continue;try{ae({projectRoot:p.lease.projectRoot,cacheDir:p.lease.localCacheDir,cliVersion:t})}catch{continue}if(V(p.lease,!0))continue;R(p.lease.localCacheDir,{recursive:!0,force:!0}),R(p.leasePath,{force:!0}),f+=1}finally{q.release()}}for(let p of d.deleteLocks)R(p.path,{force:!0});for(let p of d.deleteTemporaries)R(p.path,{recursive:!0,force:!0});for(let p of d.deleteGenerations)R(p.path,{recursive:!0,force:!0}),u+=p.size;B(h(i,"evidence.db"));let v={kind:"swept",sweptAt:new Date(s).toISOString(),deletedWorktrees:f,deletedGenerations:d.deleteGenerations.length,deletedBytes:u,protectedGenerations:d.protectedGenerationIds.length},S={version:1,lastSweepAt:v.sweptAt,unreferencedSince:d.unreferencedSince,lastResult:v};return k(a,S,{spacing:2,trailingNewline:!0}),v}catch(c){return{kind:"failed",error:c instanceof Error?c.message:String(c)}}finally{l.release()}}function pt(e,t,r){let n=X(e,r.dbPath,t);if(n)return{state:"bypassed",reason:n,localCacheDir:r.cacheDir,generations:0,generationBytes:0,protectedGenerations:0,unreferencedGenerations:0,unreferencedBytes:0,temporaryGenerations:0,sharedEvidence:{exists:!1,bytes:0}};let i=_(e);if(!i)return{state:"unavailable",reason:"Git worktree identity is unavailable",localCacheDir:r.cacheDir,generations:0,generationBytes:0,protectedGenerations:0,unreferencedGenerations:0,unreferencedBytes:0,temporaryGenerations:0,sharedEvidence:{exists:!1,bytes:0}};let s=h(C(),"repositories",i.repositoryId),a=ge(h(s,"worktrees",`${i.worktreeId}.json`)),o=me(h(s,"gc-state.json")),l=ve(e,s,i.repositoryId,o?.unreferencedSince??{}),c=Se(l.leases,l.locks),d=l.generations.filter(S=>!c.has(S.generationId)),u=l.generations.reduce((S,p)=>S+p.size,0),f=Z(e,t),v=0;return f&&(v=Ve(f)),{state:"managed",repositoryId:i.repositoryId,worktreeId:i.worktreeId,localCacheDir:r.cacheDir,...a?{baseGenerationId:a.baseGenerationId,activeGenerationId:a.activeGenerationId,lastAction:a.lastAction,reason:a.lastReason,lastSeenAt:a.lastSeenAt}:{},generations:l.generations.length,generationBytes:u,protectedGenerations:l.generations.filter(S=>c.has(S.generationId)).length,unreferencedGenerations:d.length,unreferencedBytes:d.reduce((S,p)=>S+p.size,0),temporaryGenerations:l.temporaries.length,sharedEvidence:{path:f,exists:v>0,bytes:v},cleanup:o?.lastResult}}function Ve(e){return[e,`${e}-wal`,`${e}-shm`].reduce((t,r)=>{try{return t+fe(r).size}catch{return t}},0)}function ve(e,t,r,n){let i=new Set(z(e).map(c=>g(c.path))),s=[];for(let c of j(h(t,"worktrees"))){if(!c.endsWith(".json"))continue;let d=h(t,"worktrees",c),u=ge(d);if(!u)continue;let f=g(u.projectRoot);s.push({leasePath:d,lease:u,managed:u.repositoryId===r&&ye(u),live:i.has(f)||pe(f),busy:V(u)})}let a=[];for(let c of j(h(t,"locks"))){let d=/^([a-f0-9]{64})\.lock$/.exec(c);if(!d)continue;let u=h(t,"locks",c),f=$(u),v=f!==void 0&&y(f),S=d[1];a.push({generationId:S,path:u,live:v})}let o=[],l=[];for(let c of j(h(t,"generations"))){let d=/^\.tmp-(\d+)-/.exec(c);if(d){let v=h(t,"generations",c),S=Number(d[1]);try{l.push({path:v,size:ue(v),live:Number.isSafeInteger(S)&&y(S)})}catch{}continue}if(!/^[a-f0-9]{64}$/.test(c))continue;let u=h(t,"generations",c),f;try{f=x(u)}catch{continue}!f.isDirectory()||f.isSymbolicLink()||o.push({generationId:c,path:u,size:ue(u),...n[c]===void 0?{}:{unreferencedAt:n[c]}})}return{leases:s,generations:o,locks:a,temporaries:l}}function ye(e){if(e.ownershipChecksum!==ee(e)||g(e.localCacheDir)!==g(J(e.projectRoot)))return!1;let t=g(C()),r=g(h(t,"projects")),n=g(e.localCacheDir);if(!n.startsWith(`${r}${le}`))return!1;try{let i=x(t),s=x(r),a=x(n);if(!i.isDirectory()||i.isSymbolicLink()||!s.isDirectory()||s.isSymbolicLink()||!a.isDirectory()||a.isSymbolicLink())return!1;let o=de(r);return de(n).startsWith(`${o}${le}`)}catch{return!1}}function V(e,t=!1){for(let n of t?["index.lock"]:["index.lock","cache-lifecycle.lock"]){let i=$(h(e.localCacheDir,n));if(i!==void 0&&y(i))return!0}let r=$(w(e.localCacheDir).lockPath);return r!==void 0&&y(r)}function ge(e){try{let t=JSON.parse(N(e,"utf8"));return t.version!==1||typeof t.repositoryId!="string"||typeof t.worktreeId!="string"||typeof t.projectRoot!="string"||t.treeOid!==void 0&&typeof t.treeOid!="string"||typeof t.localCacheDir!="string"||t.baseGenerationId!==void 0&&typeof t.baseGenerationId!="string"||t.activeGenerationId!==void 0&&typeof t.activeGenerationId!="string"||typeof t.ownershipChecksum!="string"||!/^[a-f0-9]{64}$/.test(t.ownershipChecksum)||typeof t.lastAction!="string"||t.lastReason!==void 0&&typeof t.lastReason!="string"||typeof t.lastSeenAt!="string"?null:t}catch{return null}}function $(e){try{let t=JSON.parse(N(e,"utf8"));return typeof t.pid=="number"&&Number.isSafeInteger(t.pid)&&t.pid>0?t.pid:void 0}catch{return}}function me(e){try{let t=JSON.parse(N(e,"utf8"));return t.version!==1||typeof t.lastSweepAt!="string"||!Number.isFinite(Date.parse(t.lastSweepAt))||!t.unreferencedSince||typeof t.unreferencedSince!="object"||!t.lastResult?null:t}catch{return null}}function j(e){try{return he(e)}catch{return[]}}function ue(e){let t=0,r=[e];for(;r.length>0;){let n=r.pop();for(let i of he(n,{withFileTypes:!0})){let s=h(n,i.name);i.isDirectory()?r.push(s):i.isFile()&&(t+=fe(s).size)}}return t}export{Je as a,xe as b,Ke as c,Ye as d,Te as e,ae as f,Qe as g,Xe as h,ut as i,pt as j};
4
- //# sourceMappingURL=chunk-VMNZB6WI.js.map
@@ -1,2 +0,0 @@
1
- import{execFileSync as l,spawnSync as P}from"child_process";import{platform as g}from"os";var a=g()==="win32";function i(e){let n=a?"where":"which";try{return l(n,[e],{stdio:"pipe"}),!0}catch{return!1}}var f=/\.(?:c|m)?js$/i,m=/\.(?:exe|com)$/i;function E(e,n){return f.test(e)?{binary:process.execPath,args:[e,...n]}:{binary:e,args:[...n]}}function d(e,n){return l(e,n,{stdio:["ignore","pipe","ignore"],encoding:"utf8"})}function B(e,n={}){let r=n.isWindows??a,u=n.lookup??d,o;try{o=u(r?"where":"which",[e])}catch{return null}let s=o.split(/\r?\n/).map(t=>t.trim()).filter(Boolean);return r?s.find(t=>m.test(t))??null:s[0]??null}import{execFileSync as c}from"child_process";import{createRequire as h}from"module";import{existsSync as w}from"fs";import{platform as p,arch as y}from"os";var S="https://github.com/sourcegraph/scip",v="SCIP_QUERY_SCIP_BIN";function x(e){if(e.isOnPath("scip"))return{source:"path",path:"scip"};let n=e.env[v];if(n&&e.fileExists(n))return{source:"env",path:n};if(e.platform==="win32"){let r=e.resolveSidecar(e.arch);if(r&&e.fileExists(r))return{source:"sidecar",path:r}}return null}function b(e){let n=h(import.meta.url);for(let r of e==="arm64"?["arm64","x64"]:[e])try{return n.resolve(`scip-query-scip-windows/scip-win32-${r}.exe`)}catch{}return null}function L(e=process.env){return x({platform:p(),arch:y(),env:e,isOnPath:i,fileExists:w,resolveSidecar:b})?.path??null}function k(e){if(p()==="darwin"&&i("brew")){e("Installing scip CLI via Homebrew...");try{if(c("brew",["install","sourcegraph/scip/scip"],{stdio:"inherit",timeout:3e5,env:process.env}),i("scip"))return e("Successfully installed scip CLI via Homebrew"),!0}catch(n){let r=n instanceof Error?n.message:String(n);e(`Homebrew install failed: ${r}`)}}if(i("go")){e("Installing scip CLI via go install...");try{if(c("go",["install","github.com/sourcegraph/scip/cmd/scip@latest"],{stdio:"inherit",timeout:3e5,env:process.env}),i("scip"))return e("Successfully installed scip CLI via go install"),!0}catch(n){let r=n instanceof Error?n.message:String(n);e(`go install failed: ${r}`)}}return e("Could not auto-install scip CLI."),e(`Install manually from: ${S}/releases`),!1}export{i as a,E as b,B as c,L as d,k as e};
2
- //# sourceMappingURL=chunk-XBN5VO53.js.map
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env node
2
- import{Ba as R,E as p,F as g,Fd as D,Gd as a,Kd as u,Ma as w,Md as j,Pd as y,cd as P,ec as C,fd as c,gd as O,hd as L,jd as h,ud as b,z as f}from"./chunk-SVLTAG5O.js";var _=P,J=(o=>parseInt(o,10)),z=(o=>{let e=parseInt(o,10);if(!Number.isFinite(e)||e<1)throw new Error(`Expected a positive integer, got ${o}`);return e}),H=parseFloat,K=parseInt;function l(o,e,t,...n){return n.length>0?{flags:o,description:e,parser:t,defaultValue:n[0]}:{flags:o,description:e,parser:t}}function k(){return l("--json","Output as JSON for programmatic consumption")}function N(o=[]){return o.some(e=>e.flags==="--json")?o:[...o,k()]}function d(o,e=[]){return{category:o,examples:e}}function x(o,e){let t=p(o,e),n=A(t);for(let r of n)console.log(r)}function S(o,e,t="No results found for resolved symbol."){return p(o,e).match?t:T(e,g(o,e,5))}function v(o,e,t,n){return{...F(o,e),[n]:t}}function F(o,e){let t=p(o,e);return t.match?{matched:!0,resolved:{symbol:t.match.symbol,shortName:f(t.match.symbol),relativePath:t.match.relativePath},otherMatches:t.candidates.map(n=>({shortName:n.shortName,relativePath:n.relativePath,startLine:n.startLine})),totalMatches:t.total}:{matched:!1,suggestions:g(o,e,5)}}function T(o,e){let t=`No definition matched '${o}'.`;return e.length>0?`${t} Suggestions: ${e.join(", ")}`:t}function A(o){if(!o.match||o.total<=1)return[];let e=o.match,t=Math.max(0,o.total-1),n=[`Resolved: ${f(e.symbol)} (${e.relativePath}) -- ${t} other definition(s) share this name; qualify as <dir/leaf> to target another.`],r=o.candidates.slice(0,3);return r.length>0&&n.push(`Alternates: ${r.map(s=>`${s.shortName} (${s.relativePath}:${c(s.startLine)})`).join("; ")}`),n.push(""),n}var B=b(({db:o,args:e,opts:t})=>{let n=a(e,0),r=u(t,"signatures"),s=w(o,n);if(u(t,"json")){y("outline",e,t,s);return}if(s.length===0)return h.empty(`No symbols found for "${n}".`);function i(M,$){for(let m of M){let I=" ".repeat($),E=r&&m.signature?` - ${V(m.signature)}`:"";console.log(`${I}${O(m.startLine,m.endLine)} ${m.shortName}${E}`),i(m.children,$+1)}}i(s,0)});function V(o){return o.length>120?`${o.slice(0,117)}...`:o}var q=D("refs",{query:({db:o,args:e,budget:t})=>R(o,a(e,0),{semantic:t.semantic}),format:o=>` line ${c(o.line)}`,before:(o,{db:e,args:t})=>x(e,a(t,0)),emptyMessage:({db:o,args:e})=>S(o,a(e,0),"No references found."),toJson:(o,{db:e,args:t})=>v(e,a(t,0),o,"references")}),G=b(({db:o,args:e,opts:t})=>{let n=a(e,0),r=C(o,n,{context:j(t,"context",0)});if(u(t,"json")){y("code",e,t,v(o,n,r,"code"));return}if(!r)return h.empty(S(o,n,"Symbol found, but source was unreadable."));x(o,n),console.log(`${L(r.relativePath,r.startLine,r.endLine)} ${r.shortName} [${r.language??"unknown"}]
3
- `);let s=r.source.split(`
4
- `);for(let i=0;i<s.length;i++)console.log(` ${String(c(r.startLine+i)).padStart(4)} ${s[i]}`)}),ao=[{id:"refs",command:"refs <symbol>",description:"Find all files referencing a symbol",options:[l("--full","Run unbounded semantic analysis on large indexes"),l("--json","Output as JSON for programmatic consumption")],budget:"semantic",renderShape:"grouped-by-file",docs:d("Navigation",["scip-query refs login"]),handler:q},{id:"outline",command:"outline <file>",description:"Tree view of symbols in a file, with line ranges",options:N([l("--signatures","Show trimmed symbol signatures")]),renderShape:"custom",docs:d("Navigation"),handler:B},{id:"code",command:"code <symbol>",description:"Read the source code for a symbol (bounded to its definition range)",options:N([l("-C, --context <n>","Extra lines of context above/below",J,0)]),renderShape:"custom",docs:d("Navigation"),handler:G}];export{_ as a,J as b,z as c,H as d,K as e,l as f,k as g,N as h,d as i,x as j,S as k,v as l,F as m,ao as n};
5
- //# sourceMappingURL=chunk-ZAIILQNP.js.map