scip-query 0.19.5 → 0.19.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (421) hide show
  1. package/CHANGELOG.md +85 -1
  2. package/README.md +259 -53
  3. package/dist/augment-vue-worker.js +1 -1
  4. package/dist/chunk-2465DLHK.js +3 -0
  5. package/dist/{chunk-7GXM52MI.js → chunk-24GTWJ3N.js} +2 -2
  6. package/dist/{chunk-NH5ALKPW.js → chunk-2SNGN6U4.js} +2 -2
  7. package/dist/{chunk-3SVWW4PN.js → chunk-2U3OLUNJ.js} +2 -2
  8. package/dist/{chunk-XLTP42QA.js → chunk-33KUO7CG.js} +2 -2
  9. package/dist/{chunk-54HA4ZXH.js → chunk-33XTHFKR.js} +2 -2
  10. package/dist/{chunk-ZGZUZ7XE.js → chunk-3EDFLQ6A.js} +2 -2
  11. package/dist/chunk-3ZSJ3PWF.js +16 -0
  12. package/dist/{chunk-F6O7AAC3.js → chunk-43KC6EQZ.js} +2 -2
  13. package/dist/{chunk-I5RJM53C.js → chunk-464PLI5O.js} +2 -2
  14. package/dist/chunk-46XGSFNI.js +2 -0
  15. package/dist/{chunk-M7AIS73L.js → chunk-47BU5Z4T.js} +2 -2
  16. package/dist/chunk-4BV4QAZJ.js +5 -0
  17. package/dist/chunk-4YTUWQ6M.js +18 -0
  18. package/dist/{chunk-RV2FQIX3.js → chunk-5ML2BNRH.js} +2 -2
  19. package/dist/{chunk-6NSFJYRC.js → chunk-5YLUDDAF.js} +2 -2
  20. package/dist/chunk-67QRR5YC.js +6 -0
  21. package/dist/{chunk-GPBBJ5Y4.js → chunk-6GXYN7YA.js} +3 -3
  22. package/dist/{chunk-4333ETTV.js → chunk-6M7RONVB.js} +2 -2
  23. package/dist/chunk-6YTSKJJ3.js +2 -0
  24. package/dist/{chunk-QDV6RDCP.js → chunk-7FT5Y65S.js} +2 -2
  25. package/dist/{chunk-XTX6QHOF.js → chunk-7KYNAMMH.js} +2 -2
  26. package/dist/{chunk-DZ74OMG6.js → chunk-7LSVMFX7.js} +2 -2
  27. package/dist/{chunk-VTKGCT3V.js → chunk-7QHY3H7P.js} +2 -2
  28. package/dist/{chunk-MITTUCEH.js → chunk-7RAG65VK.js} +2 -2
  29. package/dist/{chunk-25LPM4DG.js → chunk-7SWJEWJF.js} +2 -2
  30. package/dist/{chunk-52ZYCAEO.js → chunk-7VCOXZH3.js} +2 -2
  31. package/dist/chunk-A2TNXAXO.js +8 -0
  32. package/dist/{chunk-IUFDSKGG.js → chunk-A3QXWFBK.js} +2 -2
  33. package/dist/{chunk-4T3LTWUS.js → chunk-AA4UWRNL.js} +2 -2
  34. package/dist/{chunk-4SALD7RU.js → chunk-ACAM6O5R.js} +2 -2
  35. package/dist/chunk-APMMR5Y2.js +2 -0
  36. package/dist/chunk-AQOFWNQJ.js +1 -0
  37. package/dist/chunk-AZFUMCQB.js +2 -0
  38. package/dist/{chunk-M7MTH5NR.js → chunk-BDOIKGDI.js} +2 -2
  39. package/dist/{chunk-BTEE5NZQ.js → chunk-BNXICU42.js} +2 -2
  40. package/dist/chunk-C5Q44Q5D.js +3 -0
  41. package/dist/{chunk-EOOJGLDU.js → chunk-CTF2GDEX.js} +2 -2
  42. package/dist/chunk-DHEQMPLW.js +2 -0
  43. package/dist/{chunk-IZKFSVBV.js → chunk-DQBCO2UY.js} +2 -2
  44. package/dist/{chunk-7B3UPBVA.js → chunk-DQGSM7RZ.js} +2 -2
  45. package/dist/chunk-E2LAW7SL.js +30 -0
  46. package/dist/chunk-E3HYEQO7.js +2 -0
  47. package/dist/chunk-E4NFOAD4.js +6 -0
  48. package/dist/chunk-E5HNT4X2.js +3 -0
  49. package/dist/{chunk-J77UIT3I.js → chunk-ELLMY7XJ.js} +2 -2
  50. package/dist/chunk-FD3HFKXR.js +5 -0
  51. package/dist/{chunk-SOAT6NLA.js → chunk-FIJCV235.js} +2 -2
  52. package/dist/{chunk-H7UKLTWJ.js → chunk-FJ5UDTQF.js} +2 -2
  53. package/dist/{chunk-HEXVUYFQ.js → chunk-GHKEJTCE.js} +2 -2
  54. package/dist/{chunk-LBMJEAEW.js → chunk-GLZTVKAB.js} +3 -3
  55. package/dist/{chunk-FWUUZTIO.js → chunk-GNC4JVAN.js} +2 -2
  56. package/dist/chunk-HIB452NU.js +949 -0
  57. package/dist/{chunk-NRCXJDHL.js → chunk-HZYDQPNY.js} +2 -2
  58. package/dist/chunk-IF6FP6B2.js +66 -0
  59. package/dist/{chunk-4RSI5EMG.js → chunk-JAY7YWS3.js} +2 -2
  60. package/dist/{chunk-STOL2BTL.js → chunk-JHF3E4YM.js} +2 -2
  61. package/dist/chunk-JORHF5AL.js +108 -0
  62. package/dist/{chunk-A2EZV2UM.js → chunk-K2WO7XY7.js} +2 -2
  63. package/dist/chunk-KFZNKUNT.js +2 -0
  64. package/dist/{chunk-YVVCVR2L.js → chunk-KJ2IIBZN.js} +2 -2
  65. package/dist/{chunk-QGXBRIM5.js → chunk-KKME5ZAI.js} +2 -2
  66. package/dist/chunk-KSGTULOS.js +9 -0
  67. package/dist/{chunk-UOAV44HR.js → chunk-KXDJAG4N.js} +3 -3
  68. package/dist/{chunk-UKZBVX4U.js → chunk-L4S2A7BV.js} +2 -2
  69. package/dist/chunk-LP3ARJKF.js +8 -0
  70. package/dist/chunk-LSOR3LQG.js +3 -0
  71. package/dist/{chunk-Q4IIEGXJ.js → chunk-MLFZP76A.js} +2 -2
  72. package/dist/{chunk-WQTAC523.js → chunk-MNSTUIDD.js} +2 -2
  73. package/dist/{chunk-VXQNNXJE.js → chunk-MSBDMFER.js} +2 -2
  74. package/dist/{chunk-X6D5IC6I.js → chunk-MZZBAITE.js} +5 -5
  75. package/dist/{chunk-I5AWSI2G.js → chunk-NE3TZUCI.js} +2 -2
  76. package/dist/{chunk-6E7UTQY7.js → chunk-NTUMF2X3.js} +2 -2
  77. package/dist/{chunk-S44IULR6.js → chunk-O23I56NA.js} +2 -2
  78. package/dist/{chunk-CFMXJPHH.js → chunk-O3O4XXO6.js} +2 -2
  79. package/dist/{chunk-IG7N5ZIK.js → chunk-OUBAF226.js} +2 -2
  80. package/dist/chunk-P3UO3EH3.js +2 -0
  81. package/dist/{chunk-YNRNA5LK.js → chunk-QGGLL3UH.js} +2 -2
  82. package/dist/chunk-QIQ63BHW.js +16 -0
  83. package/dist/{chunk-VGRICIQI.js → chunk-QJIVBYEK.js} +2 -2
  84. package/dist/chunk-QOXBSI6G.js +20 -0
  85. package/dist/chunk-QXK6UUSM.js +2 -0
  86. package/dist/{chunk-XYADIZHU.js → chunk-RA3AYNWP.js} +2 -2
  87. package/dist/chunk-RJMDJR3A.js +2 -0
  88. package/dist/{chunk-NSS46APD.js → chunk-RLH5VUMG.js} +2 -2
  89. package/dist/{chunk-GBQ5NYPR.js → chunk-S4S2WOIX.js} +6 -6
  90. package/dist/{chunk-YIJ7ZAA4.js → chunk-SERUIGV5.js} +2 -2
  91. package/dist/{chunk-FECYOO5O.js → chunk-SMQWE25B.js} +2 -2
  92. package/dist/{chunk-R4FQGQ4X.js → chunk-TAVELHYR.js} +2 -2
  93. package/dist/{chunk-U6WNH5GC.js → chunk-TWMJ3Y3G.js} +2 -2
  94. package/dist/chunk-VAXNI5NE.js +146 -0
  95. package/dist/chunk-VVY2G5ET.js +2 -0
  96. package/dist/{chunk-WER3B7MI.js → chunk-W3DBTGL4.js} +2 -2
  97. package/dist/{chunk-CNKAGUPL.js → chunk-WANA4KAQ.js} +2 -2
  98. package/dist/chunk-WJL2L6MV.js +60 -0
  99. package/dist/chunk-WUW7YUAH.js +11 -0
  100. package/dist/{chunk-QVWS2VWZ.js → chunk-WWKWUPSU.js} +2 -2
  101. package/dist/{chunk-ABMYA4TN.js → chunk-WY45BHKQ.js} +2 -2
  102. package/dist/chunk-X4FR5BZF.js +9 -0
  103. package/dist/chunk-X6RKPDY7.js +2 -0
  104. package/dist/{chunk-ZXJYMGD3.js → chunk-YLFORA5G.js} +2 -2
  105. package/dist/{chunk-KP6XRY5Z.js → chunk-YTVWB7YJ.js} +2 -2
  106. package/dist/{chunk-4XTA5OMB.js → chunk-ZCEJ63SP.js} +2 -2
  107. package/dist/{chunk-HKEHS2AS.js → chunk-ZJ5CBXK3.js} +2 -2
  108. package/dist/chunk-ZL2OGDCD.js +2 -0
  109. package/dist/cli.js +8 -3
  110. package/dist/command-descriptors-ZW5J4ZEM.js +631 -0
  111. package/dist/{config-types-D20KuvvZ.d.ts → config-types-B6MEoRNy.d.ts} +8 -0
  112. package/dist/{db-G_II8yXU.d.ts → db-DYLKr9Wn.d.ts} +18 -1
  113. package/dist/direct-navigation-42YHQPOI.js +3 -0
  114. package/dist/{health-oblXYgkF.d.ts → health-DgxIDXJC.d.ts} +1 -1
  115. package/dist/index.d.ts +2 -2
  116. package/dist/index.js +1 -1
  117. package/dist/postinstall.js +1 -1
  118. package/dist/queries/affected.d.ts +2 -2
  119. package/dist/queries/affected.js +1 -1
  120. package/dist/queries/architecture.d.ts +2 -2
  121. package/dist/queries/architecture.js +1 -1
  122. package/dist/queries/bottlenecks.d.ts +2 -2
  123. package/dist/queries/bottlenecks.js +1 -1
  124. package/dist/queries/by-kind.d.ts +2 -2
  125. package/dist/queries/by-kind.js +1 -1
  126. package/dist/queries/call-graph.d.ts +2 -2
  127. package/dist/queries/call-graph.js +1 -1
  128. package/dist/queries/change-surface.d.ts +2 -2
  129. package/dist/queries/change-surface.js +1 -1
  130. package/dist/queries/cleanup-plan.d.ts +2 -2
  131. package/dist/queries/cleanup-plan.js +1 -1
  132. package/dist/queries/co-change.d.ts +2 -2
  133. package/dist/queries/co-change.js +1 -1
  134. package/dist/queries/code.d.ts +2 -2
  135. package/dist/queries/code.js +1 -1
  136. package/dist/queries/complexity-hotspots.d.ts +2 -2
  137. package/dist/queries/complexity-hotspots.js +1 -1
  138. package/dist/queries/complexity.d.ts +2 -2
  139. package/dist/queries/complexity.js +1 -1
  140. package/dist/queries/convergence.d.ts +2 -2
  141. package/dist/queries/convergence.js +1 -1
  142. package/dist/queries/coupling.d.ts +2 -2
  143. package/dist/queries/coupling.js +1 -1
  144. package/dist/queries/cycles.d.ts +2 -2
  145. package/dist/queries/cycles.js +1 -1
  146. package/dist/queries/dataflow.d.ts +2 -2
  147. package/dist/queries/dataflow.js +1 -1
  148. package/dist/queries/dead.d.ts +2 -2
  149. package/dist/queries/dead.js +1 -1
  150. package/dist/queries/decorative-checkers.d.ts +3 -3
  151. package/dist/queries/decorative-checkers.js +1 -1
  152. package/dist/queries/deep-chains.d.ts +2 -2
  153. package/dist/queries/deep-chains.js +1 -1
  154. package/dist/queries/deps.d.ts +2 -2
  155. package/dist/queries/deps.js +1 -1
  156. package/dist/queries/diff-gate.d.ts +30 -2
  157. package/dist/queries/diff-gate.js +1 -1
  158. package/dist/queries/diff-impact.d.ts +2 -2
  159. package/dist/queries/diff-impact.js +1 -1
  160. package/dist/queries/doc-drift.d.ts +2 -2
  161. package/dist/queries/doc-drift.js +1 -1
  162. package/dist/queries/drift.d.ts +2 -2
  163. package/dist/queries/drift.js +1 -1
  164. package/dist/queries/duplicate-bodies.d.ts +2 -2
  165. package/dist/queries/duplicate-bodies.js +1 -1
  166. package/dist/queries/extract-candidates.d.ts +2 -2
  167. package/dist/queries/extract-candidates.js +1 -1
  168. package/dist/queries/fan.d.ts +2 -2
  169. package/dist/queries/fan.js +1 -1
  170. package/dist/queries/files.d.ts +2 -2
  171. package/dist/queries/health.d.ts +3 -3
  172. package/dist/queries/health.js +1 -1
  173. package/dist/queries/hierarchy.d.ts +2 -2
  174. package/dist/queries/hierarchy.js +1 -1
  175. package/dist/queries/hotspots.d.ts +2 -2
  176. package/dist/queries/hotspots.js +1 -1
  177. package/dist/queries/imports.d.ts +2 -2
  178. package/dist/queries/imports.js +1 -1
  179. package/dist/queries/incomplete-migration.d.ts +2 -2
  180. package/dist/queries/incomplete-migration.js +1 -1
  181. package/dist/queries/index.d.ts +17 -3
  182. package/dist/queries/index.js +1 -1
  183. package/dist/queries/isolated.d.ts +2 -2
  184. package/dist/queries/isolated.js +1 -1
  185. package/dist/queries/locality-candidates.d.ts +2 -2
  186. package/dist/queries/locality-candidates.js +1 -1
  187. package/dist/queries/members.d.ts +2 -2
  188. package/dist/queries/members.js +1 -1
  189. package/dist/queries/methods.d.ts +2 -2
  190. package/dist/queries/methods.js +1 -1
  191. package/dist/queries/not-implemented.d.ts +3 -3
  192. package/dist/queries/not-implemented.js +1 -1
  193. package/dist/queries/outline.d.ts +2 -2
  194. package/dist/queries/outline.js +1 -1
  195. package/dist/queries/passthrough-candidates.d.ts +2 -2
  196. package/dist/queries/passthrough-candidates.js +1 -1
  197. package/dist/queries/plan-context.d.ts +2 -2
  198. package/dist/queries/plan-context.js +1 -1
  199. package/dist/queries/react-component-duplicates.d.ts +2 -2
  200. package/dist/queries/react-component-duplicates.js +1 -1
  201. package/dist/queries/react-hook-candidates.d.ts +2 -2
  202. package/dist/queries/react-hook-candidates.js +1 -1
  203. package/dist/queries/react-large-component-pressure.d.ts +2 -2
  204. package/dist/queries/react-large-component-pressure.js +1 -1
  205. package/dist/queries/recent-duplicates.d.ts +2 -2
  206. package/dist/queries/recent-duplicates.js +1 -1
  207. package/dist/queries/redundant-reexports.d.ts +2 -2
  208. package/dist/queries/redundant-reexports.js +1 -1
  209. package/dist/queries/refs.d.ts +2 -2
  210. package/dist/queries/refs.js +1 -1
  211. package/dist/queries/self-audit.d.ts +2 -2
  212. package/dist/queries/self-audit.js +1 -1
  213. package/dist/queries/similar-chains.d.ts +2 -2
  214. package/dist/queries/similar-chains.js +1 -1
  215. package/dist/queries/similar-files.d.ts +2 -2
  216. package/dist/queries/similar-files.js +1 -1
  217. package/dist/queries/similar-signatures.d.ts +2 -2
  218. package/dist/queries/similar-signatures.js +1 -1
  219. package/dist/queries/similar.d.ts +2 -2
  220. package/dist/queries/similar.js +1 -1
  221. package/dist/queries/slice.d.ts +2 -2
  222. package/dist/queries/slice.js +1 -1
  223. package/dist/queries/stale-abstractions.d.ts +2 -2
  224. package/dist/queries/stale-abstractions.js +1 -1
  225. package/dist/queries/stats.d.ts +2 -2
  226. package/dist/queries/stats.js +1 -1
  227. package/dist/queries/surface.d.ts +2 -2
  228. package/dist/queries/surface.js +1 -1
  229. package/dist/queries/symbols.d.ts +2 -2
  230. package/dist/queries/symbols.js +1 -1
  231. package/dist/queries/system.d.ts +2 -2
  232. package/dist/queries/system.js +1 -1
  233. package/dist/queries/test-quality.d.ts +2 -2
  234. package/dist/queries/test-quality.js +1 -1
  235. package/dist/queries/trace.d.ts +2 -2
  236. package/dist/queries/trace.js +1 -1
  237. package/dist/queries/twin-ab.d.ts +3 -3
  238. package/dist/queries/twin-ab.js +1 -1
  239. package/dist/queries/twin-drift.d.ts +2 -2
  240. package/dist/queries/twin-drift.js +1 -1
  241. package/dist/queries/unused-imports.d.ts +2 -2
  242. package/dist/queries/unused-imports.js +1 -1
  243. package/dist/queries/unused-params.d.ts +2 -2
  244. package/dist/queries/unused-params.js +1 -1
  245. package/dist/queries/vue-component-duplicates.d.ts +2 -2
  246. package/dist/queries/vue-component-duplicates.js +1 -1
  247. package/dist/queries/vue-composable-candidates.d.ts +2 -2
  248. package/dist/queries/vue-composable-candidates.js +1 -1
  249. package/dist/queries/vue-large-view-pressure.d.ts +2 -2
  250. package/dist/queries/vue-large-view-pressure.js +1 -1
  251. package/dist/queries/wrapper-candidates.d.ts +2 -2
  252. package/dist/queries/wrapper-candidates.js +1 -1
  253. package/dist/reindex-worker.js +26 -26
  254. package/dist/reindex.d.ts +14 -4
  255. package/dist/reindex.js +34 -38
  256. package/dist/runtime.d.ts +167 -18
  257. package/dist/runtime.js +3 -2
  258. package/dist/rust-semantic-session-server.js +1 -1
  259. package/dist/rust-semantic-session-worker.js +1 -1
  260. package/dist/rust-semantic-worker.js +1 -1
  261. package/dist/{scip-cli-kRpaexVJ.d.ts → scip-cli-Cc6c00-a.d.ts} +6 -2
  262. package/dist/watch-server.js +5 -5
  263. package/docs/AGENT_GUIDE.md +20 -4
  264. package/docs/AI_FAILURE_MODES.md +17 -17
  265. package/docs/API_EVOLUTION.md +71 -0
  266. package/docs/CLI_JSON_OUTPUT.md +168 -0
  267. package/docs/COMMAND_REFERENCE.md +10 -6
  268. package/docs/COMMITTED_RECORD_COMPATIBILITY.md +117 -0
  269. package/docs/CONFIGURATION_WRITE_SAFETY.md +130 -0
  270. package/docs/DETECTOR_GUIDE.md +46 -46
  271. package/docs/DURABILITY.md +103 -0
  272. package/docs/INDEX_GENERATIONS.md +121 -0
  273. package/docs/LOCK_PROTOCOL.md +133 -0
  274. package/docs/MAILBOX_LIFECYCLE.md +197 -0
  275. package/docs/REINDEX_METADATA_COMPATIBILITY.md +84 -0
  276. package/docs/RUST_DURABLE_SESSION_PROTOCOL.md +126 -0
  277. package/docs/SECURITY_MODEL.md +129 -0
  278. package/docs/TELEMETRY_RETENTION.md +77 -0
  279. package/docs/TIME_SEMANTICS.md +77 -0
  280. package/docs/WATCH_REFRESH_REQUESTS.md +110 -0
  281. package/docs/WINDOWS_SIDECAR_RELEASE.md +298 -0
  282. package/docs/analyzer-validation-ledger.md +24 -23
  283. package/docs/schemas/cli-json-envelope.schema.json +53 -0
  284. package/docs/schemas/cli-output-page.schema.json +104 -0
  285. package/docs/schemas/npm-release-state.schema.json +146 -0
  286. package/docs/schemas/outcome-event-record.schema.json +39 -0
  287. package/docs/schemas/project-config.schema.json +247 -0
  288. package/docs/schemas/suppression-record.schema.json +31 -0
  289. package/docs/schemas/windows-sidecar-provenance.schema.json +137 -0
  290. package/package.json +21 -10
  291. package/scripts/build-scip-windows.mjs +180 -61
  292. package/scripts/scip-windows-provenance.mjs +364 -0
  293. package/scripts/verify-scip-windows.mjs +29 -0
  294. package/skills/_shared/SKILL.md +90 -229
  295. package/skills/_shared/agents/openai.yaml +1 -1
  296. package/skills/_shared/references/agent-contract-catalog.md +105 -0
  297. package/skills/_shared/references/command-catalog.md +118 -0
  298. package/skills/_shared/references/detector-precision-and-diffgate.md +59 -0
  299. package/skills/_shared/references/evidence-and-dead-code.md +25 -0
  300. package/skills/scip-audit/SKILL.md +77 -0
  301. package/skills/scip-audit/agents/openai.yaml +4 -0
  302. package/skills/scip-audit/references/claims.md +98 -0
  303. package/skills/scip-audit/references/cleanup.md +101 -0
  304. package/skills/scip-audit/references/directory.md +222 -0
  305. package/skills/scip-audit/references/frontend.md +130 -0
  306. package/skills/scip-audit/references/integrity.md +154 -0
  307. package/skills/scip-audit/references/maintainability.md +162 -0
  308. package/skills/scip-audit/references/twin-drift.md +104 -0
  309. package/skills/scip-diagnose/SKILL.md +52 -0
  310. package/skills/scip-diagnose/agents/openai.yaml +4 -0
  311. package/skills/scip-diagnose/references/debug.md +117 -0
  312. package/skills/{scip-probe-reachability/SKILL.md → scip-diagnose/references/probe-reachability.md} +11 -27
  313. package/skills/scip-diagnose/references/root-cause.md +145 -0
  314. package/skills/scip-diagnose/references/triage.md +119 -0
  315. package/skills/scip-explore/SKILL.md +54 -85
  316. package/skills/scip-explore/agents/openai.yaml +2 -2
  317. package/skills/scip-explore/references/diagrams.md +40 -0
  318. package/skills/scip-explore/references/language-playbook.md +49 -0
  319. package/skills/scip-improve/SKILL.md +56 -0
  320. package/skills/scip-improve/agents/openai.yaml +4 -0
  321. package/skills/scip-improve/references/cleanup-batches.md +53 -0
  322. package/skills/scip-improve/references/directory-moves.md +53 -0
  323. package/skills/scip-improve/references/doc-reconcile.md +30 -0
  324. package/skills/scip-improve/references/frontend-extraction.md +39 -0
  325. package/skills/scip-improve/references/maintainability-mechanism.md +43 -0
  326. package/skills/scip-improve/references/twin-drift.md +35 -0
  327. package/skills/scip-plan/SKILL.md +68 -0
  328. package/skills/scip-plan/agents/openai.yaml +4 -0
  329. package/skills/scip-plan/references/api-impact.md +19 -0
  330. package/skills/scip-plan/references/conductor.md +41 -0
  331. package/skills/scip-plan/references/high-assurance.md +43 -0
  332. package/skills/scip-plan/references/hyper-optimization.md +50 -0
  333. package/skills/scip-plan/references/tla-model.md +88 -0
  334. package/skills/scip-query/SKILL.md +53 -98
  335. package/skills/scip-query/agents/openai.yaml +2 -2
  336. package/skills/scip-setup/SKILL.md +69 -181
  337. package/skills/scip-setup/agents/openai.yaml +3 -3
  338. package/skills/scip-setup/references/bootstrap-workflow.md +120 -0
  339. package/skills/scip-setup/references/language-verification.md +61 -0
  340. package/skills/scip-setup/references/lifecycle-commands.md +119 -0
  341. package/skills/scip-setup/references/per-repo-triage.md +24 -0
  342. package/skills/scip-verify/SKILL.md +126 -84
  343. package/skills/scip-verify/agents/openai.yaml +2 -2
  344. package/skills/scip-verify/references/calibrate-detectors.md +170 -0
  345. package/dist/chunk-2CTX5CMX.js +0 -4
  346. package/dist/chunk-2Y373BDD.js +0 -2
  347. package/dist/chunk-2YU7I3QO.js +0 -2
  348. package/dist/chunk-3MJ5YA4Y.js +0 -16
  349. package/dist/chunk-64RFXJT5.js +0 -16
  350. package/dist/chunk-7UY7SD7D.js +0 -927
  351. package/dist/chunk-B5NLK2B3.js +0 -6
  352. package/dist/chunk-C2QSK7E7.js +0 -2
  353. package/dist/chunk-C7NIYIQ4.js +0 -67
  354. package/dist/chunk-D4U5Q3FT.js +0 -7
  355. package/dist/chunk-DGAGY7RJ.js +0 -60
  356. package/dist/chunk-DLWR3NUU.js +0 -5
  357. package/dist/chunk-K2ERX4UT.js +0 -3
  358. package/dist/chunk-KHE7J5ZN.js +0 -3
  359. package/dist/chunk-L7SPDE73.js +0 -84
  360. package/dist/chunk-LHMNRHGV.js +0 -3
  361. package/dist/chunk-LM72NQ7T.js +0 -3
  362. package/dist/chunk-MSWVMDAH.js +0 -122
  363. package/dist/chunk-NH7WNNQC.js +0 -20
  364. package/dist/chunk-NPKYOIFM.js +0 -18
  365. package/dist/chunk-NZL2DBT7.js +0 -2
  366. package/dist/chunk-OMPZHGHO.js +0 -2
  367. package/dist/chunk-P2PC2WGR.js +0 -2
  368. package/dist/chunk-Q3AFUTGB.js +0 -8
  369. package/dist/chunk-QRGV2F7L.js +0 -2
  370. package/dist/chunk-TW4OG5FC.js +0 -4
  371. package/dist/chunk-U7DSEKOM.js +0 -30
  372. package/dist/chunk-V27BEQJN.js +0 -7
  373. package/dist/chunk-XAGAZSFE.js +0 -6
  374. package/dist/chunk-XBN5VO53.js +0 -2
  375. package/dist/chunk-YGAGTIDK.js +0 -11
  376. package/dist/command-descriptors-N2TL4XM2.js +0 -613
  377. package/dist/direct-navigation-DUCZCTOE.js +0 -3
  378. package/skills/scip-api-impact/SKILL.md +0 -140
  379. package/skills/scip-api-impact/agents/openai.yaml +0 -4
  380. package/skills/scip-calibrate/SKILL.md +0 -131
  381. package/skills/scip-calibrate/agents/openai.yaml +0 -4
  382. package/skills/scip-claim-audit/SKILL.md +0 -107
  383. package/skills/scip-claim-audit/agents/openai.yaml +0 -4
  384. package/skills/scip-cleanup-audit/SKILL.md +0 -130
  385. package/skills/scip-cleanup-audit/agents/openai.yaml +0 -4
  386. package/skills/scip-cleanup-improve/SKILL.md +0 -85
  387. package/skills/scip-cleanup-improve/agents/openai.yaml +0 -4
  388. package/skills/scip-concrete-plan/HIGH_ASSURANCE.md +0 -317
  389. package/skills/scip-concrete-plan/SKILL.md +0 -105
  390. package/skills/scip-concrete-plan/agents/openai.yaml +0 -4
  391. package/skills/scip-conductor/SKILL.md +0 -133
  392. package/skills/scip-conductor/agents/openai.yaml +0 -4
  393. package/skills/scip-debug/SKILL.md +0 -130
  394. package/skills/scip-debug/agents/openai.yaml +0 -4
  395. package/skills/scip-diagram/SKILL.md +0 -110
  396. package/skills/scip-diagram/agents/openai.yaml +0 -4
  397. package/skills/scip-directory-architecture/SKILL.md +0 -266
  398. package/skills/scip-directory-architecture/agents/openai.yaml +0 -4
  399. package/skills/scip-doc-reconcile/SKILL.md +0 -89
  400. package/skills/scip-doc-reconcile/agents/openai.yaml +0 -4
  401. package/skills/scip-hyper-optimization/SKILL.md +0 -156
  402. package/skills/scip-hyper-optimization/agents/openai.yaml +0 -4
  403. package/skills/scip-integrity-audit/SKILL.md +0 -152
  404. package/skills/scip-integrity-audit/agents/openai.yaml +0 -4
  405. package/skills/scip-language-playbook/SKILL.md +0 -106
  406. package/skills/scip-language-playbook/agents/openai.yaml +0 -4
  407. package/skills/scip-maintainability/SKILL.md +0 -158
  408. package/skills/scip-maintainability/agents/openai.yaml +0 -4
  409. package/skills/scip-probe-reachability/agents/openai.yaml +0 -4
  410. package/skills/scip-react-maintainability/SKILL.md +0 -101
  411. package/skills/scip-react-maintainability/agents/openai.yaml +0 -4
  412. package/skills/scip-root-cause/SKILL.md +0 -151
  413. package/skills/scip-root-cause/agents/openai.yaml +0 -4
  414. package/skills/scip-tla-model-system/SKILL.md +0 -148
  415. package/skills/scip-tla-model-system/agents/openai.yaml +0 -4
  416. package/skills/scip-triage-issue/SKILL.md +0 -133
  417. package/skills/scip-triage-issue/agents/openai.yaml +0 -4
  418. package/skills/scip-twin-drift/SKILL.md +0 -109
  419. package/skills/scip-twin-drift/agents/openai.yaml +0 -4
  420. package/skills/scip-vue-maintainability/SKILL.md +0 -107
  421. package/skills/scip-vue-maintainability/agents/openai.yaml +0 -4
@@ -0,0 +1,146 @@
1
+ import{a as ji,b as w,c as Lt,d as Gi,e as ze,f as Bi}from"./chunk-IF6FP6B2.js";import{d as _i,e as Ai,f as N,g as qr,h as Ue,l as Oi,m as Li}from"./chunk-C5Q44Q5D.js";import{a as de,b as We,d as S,f as jr,g as Di,h as Fi,i as Wr,l as He,o as Mi,p as Ot,q as Y,s as Vr,t as $i,v as Ur,w as qi}from"./chunk-X4FR5BZF.js";import{a as Gr,b as Br,e as $r}from"./chunk-HGFDYOVB.js";import{a as Ve}from"./chunk-APMMR5Y2.js";import{a as K,b as qe,c as F,d as Dt,e as Mr,f as v,g as X,h as g,j as Ni,k as Ft}from"./chunk-46XGSFNI.js";import{createHash as Ui}from"crypto";import{chmodSync as Hi,closeSync as ja,existsSync as Je,fsyncSync as Ga,lstatSync as Gt,mkdirSync as Ba,openSync as $a,readdirSync as Jr,realpathSync as Z,unlinkSync as qa,writeSync as Wa}from"fs";import{homedir as Va}from"os";import{basename as Ua,dirname as zi,isAbsolute as Wi,join as O,resolve as Bt}from"path";import{createRequire as Oa}from"module";var La=Oa(import.meta.url),Mt=Ma().version;function Ma(){for(let e of["../package.json","../../package.json"])try{return La(e)}catch{}return{version:"0.0.0"}}var Ji=1,$t=".scip-query-cache-owner.json",Ha=16*1024;function jt(e,t){return Object.assign(new Error(`refusing unsafe project dbPath ${JSON.stringify(e)} (${t}); use a repository-relative directory that remains inside the checkout`),{name:"UnsafeCachePathError",code:"SCIP_QUERY_UNSAFE_CACHE_PATH",configuredPath:e,reason:t})}function Q(e,t){return Object.assign(new Error(`refusing unowned cache directory ${JSON.stringify(e)} (${t}); move unrelated data elsewhere or choose a new empty dbPath`),{name:"CacheOwnershipError",code:"SCIP_QUERY_CACHE_OWNERSHIP",cacheDir:e,reason:t})}function za(e,t){let r=Z(e),n=process.env.SCIP_QUERY_CACHE_DIR;return n?Hr(r,Bt(n)):t?.dbPath?Hr(r,Ja(r,t.dbPath)):Hr(r,Kr(r))}function Ki(){let e=process.env.XDG_CACHE_HOME;return O(e||O(Va(),".cache"),"scip-query")}function Kr(e){let t=Bt(e);try{t=Z(t)}catch{}let r=Ui("sha256").update(t).digest("hex").slice(0,12);return O(Ki(),"projects",r)}function Xr(e){if(!/^[a-f0-9]{24}$/.test(e))throw new Error(`invalid repository cache identity: ${e}`);let t=O(Ki(),"repositories",e);return Yi(t),Z(t)}function Yr(e){return process.env.SCIP_QUERY_SHARED_CACHE!=="0"&&!process.env.SCIP_QUERY_CACHE_DIR&&!process.env.SCIP_QUERY_INDEX_DB&&!e?.dbPath}function cg(e,t){let r=za(e,t);return{cacheDir:r,dbPath:O(r,"index.db"),indexPath:O(r,"index.scip"),metaPath:O(r,"meta.json")}}function Hr(e,t){let r=Z(e);Je(t)||Yi(t);let n=Z(t),i=O(n,$t);if(Je(i))return zr(r,n),Qr(i),st(n),n;Vi(n);let s=`${JSON.stringify({schemaVersion:Ji,canonicalProjectRoot:r,canonicalCacheDir:n,creatorVersion:Mt},null,2)}
2
+ `;try{ec(i,s)}catch(a){if(rc(a))return zr(r,n),n;throw a}try{Vi(n),Za(n)}catch(a){throw qa(i),a}return n}function zr(e,t){let r=Z(e),n=Z(t);return Xa(n,r,n)}function lg(e,t){return Je(O(t,$t))?(zr(e,t),Xi(t),!0):!1}function Ja(e,t){let r;try{r=Ue(t)}catch(s){throw s instanceof Ai?jt(t,s.reason):s}let n=Bt(e,...r.split("/"));if(n===e||!qr(e,n))throw jt(t,"outside-project");let i=Ka(n),o=Z(i);if(!qr(e,o)&&o!==e)throw jt(t,"symlink-escape");return n}function Ka(e){let t=e;for(;!Je(t);){let r=zi(t);if(r===t)throw jt(e,"no-existing-ancestor");t=r}return t}function Xa(e,t,r){let n=O(e,$t);if(!Je(n)||Gt(n).isSymbolicLink())throw Q(e,"missing regular ownership record");let i=Gt(n);if(!i.isFile()||i.size>Ha)throw Q(e,"invalid ownership record file");let o=g(n,"cache ownership record"),s=Ya(o,e);if(s.canonicalProjectRoot!==t)throw Q(e,"ownership record belongs to a different project");if(s.canonicalCacheDir!==r)throw Q(e,"ownership record names a different cache directory");return{record:s,ownerSha256:Ui("sha256").update(o).digest("hex"),physicalCacheDir:e}}function Ya(e,t){try{let r=JSON.parse(e);if(r.schemaVersion!==Ji||typeof r.canonicalProjectRoot!="string"||typeof r.canonicalCacheDir!="string"||typeof r.creatorVersion!="string"||!Wi(r.canonicalProjectRoot)||!Wi(r.canonicalCacheDir))throw new Error("invalid fields");return r}catch(r){throw Q(t,`malformed ownership record: ${r instanceof Error?r.message:String(r)}`)}}function Vi(e){let t=Jr(e).filter(r=>r!==$t&&!Qa(r));if(t.length>0)throw Q(e,`unrecognized existing entries: ${t.slice(0,3).join(", ")}`)}function Qa(e){return[".scipquery-generations","affected-shadow-latest.json","affected-shadow.jsonl","agent-hooks","augment-vue-meta.json","cache-lifecycle.lock","evidence.db","evidence.db-shm","evidence.db-wal","health-report-cache.json","index.db","index.db-shm","index.db-wal","index.lock","index.scip","language-indexes","meta.json","reindex-activity.jsonl","shared-cache.json","typescript-index","typescript-scip-fragments","typescript-scip-overlays","typescript-semantic","watch-activity.json","watch-refresh-requests","watch-state.json","watch.lock"].includes(e)?!0:/^(?:reindex-|rust-|typescript-)/.test(e)}function Za(e){for(let t of Jr(e)){let r=O(e,t),n=Gt(r);if(n.isSymbolicLink())throw Q(e,`legacy cache entry ${t} is a symlink`);if(n.isDirectory())st(r);else if(n.isFile())Qr(r);else throw Q(e,`legacy cache entry ${t} is not a file or directory`)}st(e)}function Xi(e){let t=Gt(e);if(t.isSymbolicLink())throw Q(e,"managed cache tree contains a symlink");if(t.isFile()){Qr(e);return}if(!t.isDirectory())throw Q(e,"managed cache tree contains a special file");st(e);for(let r of Jr(e))Xi(O(e,r))}function Yi(e){Ba(e,{recursive:!0,mode:448}),st(e)}function ec(e,t){let r=$a(e,"wx",384);try{Wa(r,t),Ga(r)}finally{ja(r)}}function st(e){process.platform!=="win32"&&Hi(e,448)}function Qr(e){process.platform!=="win32"&&Hi(e,384)}function tc(e){if(Je(e))return Z(e);let t=Z(zi(e));return O(t,Ua(e))}function Zr(e){return tc(Bt(e))}function rc(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="EEXIST"}import{statSync as hc}from"fs";import{dirname as Sc,join as xc}from"path";import{appendFileSync as nc,existsSync as ic,mkdirSync as oc,renameSync as sc,rmSync as ac,statSync as cc,truncateSync as lc}from"fs";import{basename as uc,dirname as dc}from"path";var qt=".previous",pc=".rotation.lock",fc=2e3,en=class extends Error{constructor(r,n){super(`Timed out after ${n}ms waiting for rotating JSONL lock: ${r}`);this.lockPath=r;this.timeoutMs=n;this.name="RotatingJsonlLockTimeoutError"}lockPath;timeoutMs;code="ROTATING_JSONL_LOCK_TIMEOUT"},tn=class extends Error{constructor(r){super(`Rotating JSONL lock ownership changed before release: ${r}`);this.lockPath=r;this.name="RotatingJsonlLockReleaseError"}lockPath;code="ROTATING_JSONL_LOCK_RELEASE_FAILED"},Qi=Object.freeze({monotonicNow:Ve,wait(e){Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,e)},tryAcquireLock(e,t){let r=He(e,{kind:"rotating-jsonl",detail:{target:uc(t)}});return r.kind==="acquired"?{kind:"acquired",lock:r.lock}:{kind:"contended"}},makeDirectory(e){oc(e,{recursive:!0})},exists:ic,readBytes(e){return v(e,{maxBytes:Dt,inputKind:"rotating JSONL segment"})},size(e){return cc(e).size},truncate:lc,remove(e){ac(e,{force:!0})},rename:sc,append:nc});function Zi(e,t,r){let n=r.runtime??Qi,i=JSON.stringify(t);if(i===void 0)throw new TypeError("Rotating JSONL records must be JSON-serializable values.");let o=Buffer.from(`${i}
3
+ `),s=Math.max(1,Math.floor(r.maxSegmentBytes),o.length);return to(e,r.lockTimeoutMs,n,()=>{n.makeDirectory(dc(e));let a=mc(e,Dt,n);r.onPhase?.("tail-repaired");let c=`${e}${r.previousSuffix??qt}`,l=!1,u=!1;return n.exists(e)&&n.size(e)+o.length>s&&(n.exists(c)&&(n.remove(c),u=!0),r.onPhase?.("previous-pruned"),n.rename(e,c),l=!0,r.onPhase?.("current-rotated")),n.append(e,o),r.onPhase?.("record-appended"),{lineBytes:o.length,segmentLimitBytes:s,repairedTailBytes:a,rotated:l,prunedPrevious:u}})}function eo(e,t={}){let r=t.runtime??Qi,n=gc(t.maxSegmentBytes);return to(e,t.lockTimeoutMs,r,()=>{let i=[],o=0,s=`${e}${t.previousSuffix??qt}`;for(let a of[s,e]){if(!r.exists(a))continue;let c=yc(ro(a,n,r));i.push(...c.lines),o+=c.partialTailBytes}return{lines:i,ignoredPartialTailBytes:o}})}function to(e,t,r,n){let i=`${e}${pc}`,o=Math.max(0,t??fc),s=r.monotonicNow()+o,a;for(;;){let p=r.tryAcquireLock(i,e);if(p.kind==="acquired"){a=p.lock;break}let m=s-r.monotonicNow();if(m<=0)throw new en(i,o);r.wait(Math.min(5,m))}let c=!1,l,u;try{u=n()}catch(p){c=!0,l=p}let d=!1;try{d=a.release()}catch(p){if(!c)throw p}if(c)throw l;if(!d)throw new tn(i);return u}function mc(e,t,r){if(!r.exists(e))return 0;let n=ro(e,t,r);if(n.length===0||n[n.length-1]===10)return 0;let i=n.lastIndexOf(10),o=i<0?0:i+1;return r.truncate(e,o),n.length-o}function gc(e){let t=e??Dt;if(!Number.isSafeInteger(t)||t<=0)throw new RangeError(`maxSegmentBytes must be a positive safe integer; received ${t}`);return t}function ro(e,t,r){let n=r.size(e);if(n>t)throw new Mr("rotating JSONL segment",e,"too-large",n,t);let i=r.readBytes(e),o=r.size(e);if(o!==n||i.byteLength!==n)throw new Mr("rotating JSONL segment",e,"changed-during-read",o,t);return i}function yc(e){let t=e.lastIndexOf(10),r=t<0?0:t+1;return{lines:e.subarray(0,r).toString("utf8").split(`
4
+ `).filter(i=>i.length>0),partialTailBytes:e.length-r}}var bc="reindex-activity.jsonl",rn=qt,Ic=1024*1024,Ec=1440*60*1e3,no=e=>g(e,"reindex activity segment");function Wt(e){return xc(Sc(e),bc)}function Rc(e){if(e.reused)return 0;let t=io(e.indexPath)+io(e.dbPath);for(let r of e.shards??[])!r.reused&&r.outputBytes!==null&&(t+=r.outputBytes);return t}function Eg(e,t){let r=t.lastRefresh;r&&nn(Wt(e),{version:1,event:"run",recordedAt:r.completedAt,trigger:r.trigger,result:r.result,durationMs:r.durationMs,estimatedLogicalOutputBytes:Rc(t)})}function Rg(e,t){nn(Wt(e),{version:1,event:"run",recordedAt:t.completedAt,trigger:t.trigger,result:"failed",durationMs:t.durationMs,estimatedLogicalOutputBytes:0})}function vg(e,t,r=new Date){nn(Wt(e),{version:1,event:"suppressed",recordedAt:r.toISOString(),trigger:t,reason:"completed-index-is-fresh"})}function vc(e,t,r=Ic,n){Zi(e,t,{maxSegmentBytes:r,previousSuffix:rn,...n?{runtime:n}:{}})}function Tg(e,t=new Date,r=Ec,n=no){let i=t.getTime(),o=i-r,s={windowStartedAt:new Date(o).toISOString(),windowEndedAt:t.toISOString(),runs:0,rebuilt:0,reused:0,failed:0,suppressed:0,estimatedLogicalOutputBytes:0,byTrigger:{}},a=Wt(e),c=[];if(n===no)try{c=eo(a,{previousSuffix:rn}).lines}catch{}else for(let l of[`${a}${rn}`,a])try{c.push(...Cc(n(l)))}catch{}for(let l of c){let u=Tc(l);if(!u)continue;let d=Date.parse(u.recordedAt);if(!(d<o||d>i)){if(s.byTrigger[u.trigger.kind]=(s.byTrigger[u.trigger.kind]??0)+1,u.event==="suppressed"){s.suppressed+=1;continue}s.runs+=1,s[u.result]+=1,s.estimatedLogicalOutputBytes+=u.estimatedLogicalOutputBytes}}return s}function nn(e,t){try{vc(e,t)}catch{}}function Tc(e){try{let t=JSON.parse(e);if(!t||typeof t!="object")return null;let r=t;return r.version!==1||!We(r.recordedAt)||!r.trigger||!wc(r.trigger.kind)?null:r.event==="suppressed"?r.reason==="completed-index-is-fresh"?r:null:r.event!=="run"||r.result!=="rebuilt"&&r.result!=="reused"&&r.result!=="failed"||!jr(r.durationMs)||!jr(r.estimatedLogicalOutputBytes)?null:r}catch{return null}}function wc(e){return e==="manual-cli"||e==="setup"||e==="watch-source"||e==="watch-startup"||e==="watch-demand"||e==="watch-git-head"||e==="watch-git-index"||e==="watch-git-state"||e==="unknown"}function io(e){try{return hc(e).size}catch{return 0}}function Cc(e){return e.endsWith(`
5
+ `)||(e=e.slice(0,Math.max(0,e.lastIndexOf(`
6
+ `)+1))),e.split(`
7
+ `).filter(t=>t.length>0)}import{createHash as Oc}from"crypto";import{dirname as Lc,join as co}from"path";var oo=["typescript","javascript","java","scala","kotlin","rust","python","ruby","go","cpp","c","csharp","vb","dart","php","clojure"];var on=2,Vt=3;var sn=new Set(oo);function pe(e){let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch(s){return{kind:"malformed",reason:`invalid JSON: ${Fc(s)}`}}if(!de(t))return{kind:"malformed",reason:"metadata must be a JSON object"};let r=t.version;if(!Number.isInteger(r))return{kind:"malformed",reason:"version must be an integer"};if(r!==on&&r!==Vt)return{kind:"unsupported",version:r,direction:r<on?"older":"future"};let n=kc(t,r);if(n)return{kind:"malformed",reason:n};let i=t,o={metadata:i,capabilities:Pc(i)};return r===on?{kind:"legacy",...o,metadata:i}:{kind:"supported",...o,metadata:i}}function _g(e){return e.kind==="legacy"||e.kind==="supported"?e.metadata:null}function Ut(e){if(e.kind!=="legacy"&&e.kind!=="supported"||!e.capabilities.stableGenerationIdentity)return null;let t=e.metadata;return JSON.stringify({version:t.version,status:t.status,updatedAt:t.updatedAt,fingerprint:t.fingerprint,indexedLanguages:t.indexedLanguages,scipCompanion:t.scipCompanion})}function Pc(e){let t=e.fingerprint!==void 0,r=de(e.fingerprint),n=e.indexedLanguages!==void 0,i=e.status==="complete",o=e.version===Vt?e:null;return{usableForQuery:n,usableForEvidenceCache:t,publishableGeneration:i&&r&&n,stableGenerationIdentity:i&&t&&typeof e.updatedAt=="string",languageShardReuse:!!o?.languageFingerprints,typescriptProjectShardReuse:!!o?.typescriptProjectShards}}function kc(e,t){if(e.status!=="complete"&&e.status!=="partial")return"status must be complete or partial";if(e.updatedAt!==void 0&&!We(e.updatedAt))return"updatedAt must be a valid timestamp";for(let r of["requestedLanguages","indexedLanguages"])if(e[r]!==void 0&&!Nc(e[r]))return`${r} must contain unique supported languages`;return e.skipped!==void 0&&!_c(e.skipped)?"skipped must contain supported language/reason pairs":e.scipCompanion!==void 0&&e.scipCompanion!=="current"&&e.scipCompanion!=="deferred"?"scipCompanion must be current or deferred":t===Vt&&e.languageFingerprints!==void 0&&!Ac(e.languageFingerprints)?"languageFingerprints must map supported languages to fingerprint objects":t===Vt&&e.typescriptProjectShards!==void 0&&!Dc(e.typescriptProjectShards)?"typescriptProjectShards must map project names to file fingerprints":null}function Nc(e){return!Array.isArray(e)||!e.every(t=>typeof t=="string"&&sn.has(t))?!1:new Set(e).size===e.length}function _c(e){return Array.isArray(e)&&e.every(t=>de(t)&&typeof t.language=="string"&&sn.has(t.language)&&typeof t.reason=="string")}function Ac(e){return de(e)&&Object.entries(e).every(([t,r])=>sn.has(t)&&de(r))}function Dc(e){return de(e)&&Object.values(e).every(t=>de(t)&&Array.isArray(t.files)&&t.files.every(_i))}function Fc(e){return e instanceof Error?e.message:String(e)}var so=3,Mc=2,jc="typescript-index";function jg(e){let t=co(e,jc),r=$i(t);return{...r,requestDir:r.legacyRequestDir}}function Gg(e){let t=JSON.parse(e),r=t.protocolVersion,n=r===Mc;if(!n&&r!==so||typeof t.id!="string"||!t.id||typeof t.baseGeneration!="string"||!t.baseGeneration||typeof t.deadlineAtMs!="number"||!Number.isFinite(t.deadlineAtMs)||!Gc(t.request)||!n&&(t.mailboxVersion!==Vr||typeof t.operationKey!="string"||!/^[a-f0-9]{64}$/.test(t.operationKey)||t.id!==qi(t.operationKey)||typeof t.clientId!="string"||!t.clientId||typeof t.enqueuedAtMs!="number"||!Number.isFinite(t.enqueuedAtMs)||t.deadlineAtMs<t.enqueuedAtMs))throw new Error("TypeScript index service received an invalid mailbox request.");if(!n){let o=t,s=Ur("typescript-index-v3",{baseGeneration:o.baseGeneration,request:o.request});if(o.operationKey!==s)throw new Error("TypeScript index service received a mismatched mailbox operation identity.");return o}let i=Ur("typescript-index-v2",{id:t.id,baseGeneration:t.baseGeneration,request:t.request});return{protocolVersion:so,mailboxVersion:Vr,id:t.id,operationKey:i,clientId:"legacy-v2",enqueuedAtMs:t.deadlineAtMs,deadlineAtMs:t.deadlineAtMs,baseGeneration:t.baseGeneration,request:t.request}}function Bg(e){try{let t=Ut(pe(g(co(Lc(e),"meta.json"),"reindex metadata")));return t?Oc("sha256").update(t).digest("hex"):null}catch{return null}}function Gc(e){if(!e||typeof e!="object")return!1;let t=e,r=ao(t.modifiedFiles)?t.modifiedFiles:null,n=ao(t.affectedFiles)?t.affectedFiles:null;return t.kind==="emit-documents"&&typeof t.tsconfigPath=="string"&&!!t.tsconfigPath&&typeof t.projectArgument=="string"&&!!t.projectArgument&&typeof t.projectIdentity=="string"&&!!t.projectIdentity&&typeof t.producerIdentity=="string"&&!!t.producerIdentity&&r!==null&&r.length>0&&new Set(r).size===r.length&&n!==null&&n.length>0&&new Set(n).size===n.length&&r.every(i=>n.includes(i))}function ao(e){return Array.isArray(e)&&e.every(t=>typeof t=="string"&&t.length>0)}import{join as Ht}from"path";var Hg=5;var Bc="watch.lock",$c="watch-state.json",qc="watch-activity.json",Wc="watch-refresh-requests";function zg(e){return{lockPath:Ht(e,Bc),statePath:Ht(e,$c),activityPath:Ht(e,qc),refreshRequestsPath:Ht(e,Wc)}}function Jg(e){try{return Vc(JSON.parse(g(e,"watch service state")))}catch{return null}}function Vc(e){if(!e||typeof e!="object")return null;let t=e;if(t.version!==1||typeof t.protocolVersion!="number"||typeof t.pid!="number"||!Number.isInteger(t.pid)||t.pid<=0||typeof t.projectRoot!="string"||t.worktreeId!==void 0&&(typeof t.worktreeId!="string"||t.worktreeId.length===0)||typeof t.cliVersion!="string"||!P(t.startedAt)||!P(t.heartbeatAt)||!P(t.lastActivityAt)||!Uc(t.watcher)||t.idleDeadlineAt!==void 0&&!P(t.idleDeadlineAt))return null;if(t.processIdentity!==void 0){let r=Di(t.processIdentity);if(!r||r.pid!==t.pid)return null;t.processIdentity=r}return t.indexGeneration!==void 0&&!/^[a-f0-9]{64}$/.test(t.indexGeneration)||t.lastError!==void 0&&!Hc(t.lastError)||t.lastRefresh!==void 0&&!zc(t.lastRefresh)||t.reindexActivity!==void 0&&!Jc(t.reindexActivity)||t.refreshRequests!==void 0&&!Kc(t.refreshRequests)||t.typescriptSemantic!==void 0&&!Xc(t.typescriptSemantic)||t.typescriptIndex!==void 0&&!Yc(t.typescriptIndex)?null:t}function P(e){return We(e)}function Uc(e){if(!e||typeof e!="object"||!("state"in e))return!1;let t=e;switch(t.state){case"idle":return!0;case"waiting":return C(t.changedFiles)&&C(t.reindexAt);case"indexing":return C(t.startedAt);case"cooldown":return C(t.until)&&typeof t.dirty=="boolean";case"draining":return C(t.startedAt)&&typeof t.reason=="string";default:return!1}}function Hc(e){if(!e||typeof e!="object")return!1;let t=e;return P(t.at)&&typeof t.message=="string"}function zc(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.trigger?.kind=="string"&&typeof t.result=="string"&&P(t.startedAt)&&P(t.completedAt)&&C(t.durationMs)}function Jc(e){if(!e||typeof e!="object")return!1;let t=e;return!P(t.windowStartedAt)||!P(t.windowEndedAt)||!S(t.runs)||!S(t.rebuilt)||!S(t.reused)||!S(t.failed)||!S(t.suppressed)||!C(t.estimatedLogicalOutputBytes)||t.estimatedLogicalOutputBytes<0||!t.byTrigger||typeof t.byTrigger!="object"?!1:Object.values(t.byTrigger).every(r=>r===void 0||S(r))}function Kc(e){if(!e||typeof e!="object")return!1;let t=e;return S(t.pending)&&S(t.claimed)&&S(t.completed)&&S(t.expired)&&S(t.invalid)&&(t.oldestPendingAt===void 0||P(t.oldestPendingAt))}function Xc(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.protocolVersion=="number"&&(t.state==="idle"||t.state==="ready"||t.state==="unavailable"||t.state==="error")&&C(t.requests)&&C(t.sessionsCreated)&&C(t.sessionsReused)&&C(t.sessionsRefreshed)&&C(t.sessionsReplaced)&&C(t.projectsCreated)&&(t.lastRequestAt===void 0||P(t.lastRequestAt))&&(t.lastError===void 0||typeof t.lastError=="string")&&(t.busyUntil===void 0||P(t.busyUntil))&&(t.mailbox===void 0||lo(t.mailbox))}function Yc(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.protocolVersion=="number"&&(t.state==="idle"||t.state==="ready"||t.state==="unavailable"||t.state==="error")&&S(t.requests)&&S(t.sessionsCreated)&&S(t.sessionsReplaced)&&S(t.initializations)&&S(t.programUpdates)&&S(t.documentsEmitted)&&S(t.documentsRemoved)&&(t.lastRequestAt===void 0||P(t.lastRequestAt))&&(t.lastDurationMs===void 0||C(t.lastDurationMs)&&t.lastDurationMs>=0)&&(t.lastError===void 0||typeof t.lastError=="string")&&(t.busyUntil===void 0||P(t.busyUntil))&&(t.mailbox===void 0||lo(t.mailbox))}function lo(e){if(!e||typeof e!="object")return!1;let t=e;return S(t.pending)&&S(t.inflight)&&S(t.responses)&&S(t.deadLetters)&&S(t.invalid)&&S(t.totalItems)&&C(t.totalBytes)&&t.totalBytes>=0&&t.totalItems===t.pending+t.inflight+t.responses+t.deadLetters&&(t.oldestPendingAt===void 0||P(t.oldestPendingAt))}function C(e){return typeof e=="number"&&Number.isFinite(e)}var Qc=new Map([[8,"\u2408"],[9,"\u2409"],[10,"\u2424"],[13,"\u240D"]]);function Zc(e,t={}){let r=t.allowNewlines??!0,n=t.allowTabs??!0,i="";for(let o=0;o<e.length;){let s=e.charCodeAt(o);if(s===27){o=el(e,o);continue}if(s===155){o=uo(e,o+1);continue}if(s===144||s===152||s===157||s===158||s===159){o=po(e,o+1);continue}if(nl(s)){s===10&&r?i+=`
8
+ `:s===9&&n?i+=" ":i+=Qc.get(s)??"\uFFFD",o+=1;continue}if(il(s)){i+="\uFFFD",o+=1;continue}i+=e[o],o+=1}return i}function Xg(e){return Zc(e,{allowNewlines:!1,allowTabs:!1})}function el(e,t){let r=e.charCodeAt(t+1);if(Number.isNaN(r))return e.length;if(r===91)return uo(e,t+2);if(r===80||r===88||r===93||r===94||r===95)return po(e,t+2);let n=t+1;for(;n<e.length&&tl(e.charCodeAt(n));)n+=1;return n<e.length&&rl(e.charCodeAt(n))?n+1:t+1}function uo(e,t){let r=t;for(;r<e.length;){let n=e.charCodeAt(r);if(r+=1,n>=64&&n<=126)return r}return e.length}function po(e,t){let r=t;for(;r<e.length;){let n=e.charCodeAt(r);if(n===7||n===156)return r+1;if(n===27&&e.charCodeAt(r+1)===92)return r+2;r+=1}return e.length}function tl(e){return e>=32&&e<=47}function rl(e){return e>=48&&e<=126}function nl(e){return e<=31||e>=127&&e<=159}function il(e){return e===1564||e===8206||e===8207||e>=8234&&e<=8238||e>=8294&&e<=8297}import{spawnSync as ol}from"child_process";import{createHash as sl}from"crypto";import{existsSync as al,lstatSync as cl,realpathSync as ll}from"fs";import{dirname as ul,isAbsolute as dl,join as pl,resolve as Jt}from"path";var Kt={run(e,t){let r=mo(e,t);return r.kind==="success"?r.output:void 0},runResult:mo},fl=["rev-parse","--show-toplevel","--absolute-git-dir","--git-common-dir","HEAD","HEAD^{tree}"],fo=/^[0-9a-f]{40,64}$/;function go(e,t=Kt){let r=t.runResult(e,fl);if(r.kind==="success"){let n=ml(r.output);if(n)return gl(n,t)}return yl(e,t)}function ml(e){let t=e.split(`
9
+ `).map(c=>c.trim());if(t.length!==5)return;let[r,n,i,o,s]=t;if(!r||!n||!i||!o||!s||!fo.test(o)||!fo.test(s))return;let a=we(r);return{root:a,gitDir:we(zt(a,n)),commonDir:we(zt(a,i)),headCommit:o,treeOid:s}}function gl(e,t){let r=t.run(e.root,["status","--porcelain=v1","-z","--untracked-files=all"]);return r===void 0?void 0:{...yo(e.root,e.gitDir),commonDir:e.commonDir,repositoryId:cn("repository",e.commonDir),headCommit:e.headCommit,treeOid:e.treeOid,clean:r.length===0}}function yl(e,t){let r=hl(e,t);if(r.kind!=="worktree")return;let n=r.identity,i=n.projectRoot,o=t.run(i,["rev-parse","--git-common-dir"])?.trim();if(!o)return;let s=we(zt(i,o)),a=an(t.run(i,["rev-parse","--verify","HEAD"])),c=an(t.run(i,["rev-parse","--verify","HEAD^{tree}"])),l=t.run(i,["status","--porcelain=v1","-z","--untracked-files=all"]);if(l!==void 0)return{...n,commonDir:s,repositoryId:cn("repository",s),headCommit:a,treeOid:c,clean:l.length===0}}function hl(e,t=Kt){let r=t.runResult(e,["rev-parse","--show-toplevel"]);if(r.kind==="not-repository")return{kind:"non-git"};if(r.kind==="error")return r;let n=r.output.trim();if(!n)return{kind:"error",message:"Git returned an empty worktree root."};let i=we(n),o=t.run(i,["rev-parse","--absolute-git-dir"])?.trim();if(!o)return{kind:"error",message:"Git did not return an absolute worktree directory."};let s=we(zt(i,o));return{kind:"worktree",identity:yo(i,s)}}function yo(e,t){return{projectRoot:e,gitDir:t,worktreeId:cn("worktree",`${e}\0${t}`)}}function Sl(e,t=Kt){let r=t.run(e,["worktree","list","--porcelain","-z"]);return r===void 0?[]:xl(r)}function xl(e){let t=[],r;for(let n of e.split("\0")){if(n===""){r&&t.push(r),r=void 0;continue}let i=n.indexOf(" "),o=i<0?n:n.slice(0,i),s=i<0?"":n.slice(i+1);if(o==="worktree"){r&&t.push(r),r={path:we(s),detached:!1,bare:!1,prunable:!1,locked:!1};continue}r&&(o==="HEAD"?r.head=s:o==="branch"?r.branch=s:o==="detached"?r.detached=!0:o==="bare"?r.bare=!0:o==="prunable"?r.prunable=!0:o==="locked"&&(r.locked=!0))}return r&&t.push(r),t}function ry(e,t,r=Kt){return an(r.run(e,t))}function zt(e,t){return dl(t)?t:Jt(e,t)}function we(e){try{return ll(e)}catch{return Jt(e)}}function cn(e,t){return sl("sha256").update(`${e}\0${t}`).digest("hex").slice(0,24)}function an(e){return e?.trim()||void 0}function mo(e,t){let r=ol("git",["-C",e,...t],{encoding:"utf-8",env:{...process.env,LC_ALL:"C"},maxBuffer:52428800,stdio:["ignore","pipe","pipe"],timeout:3e4,killSignal:"SIGKILL"});if(r.status===0)return{kind:"success",output:r.stdout.trimEnd()};let i=(typeof r.stderr=="string"?r.stderr.trim():"")||r.error?.message||`git exited with status ${r.status??"unknown"}`,o=r.error?.code;return(/not a git repository/i.test(i)||o==="ENOENT"&&al(Jt(e)))&&!bl(e)?{kind:"not-repository"}:{kind:"error",message:i}}function bl(e){if(process.env.GIT_DIR||process.env.GIT_COMMON_DIR)return!0;let t=Jt(e);for(;;){try{return cl(pl(t,".git")),!0}catch(n){let i=n.code;if(i!=="ENOENT"&&i!=="ENOTDIR")return!0}let r=ul(t);if(r===t)return!1;t=r}}import{join as Il}from"path";var El=e=>{if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e.pid;return typeof t=="number"&&Number.isSafeInteger(t)&&t>0?{pid:t}:null};function ho(e,t={}){return ln(Il(e,"gc.lock"),t)}function ln(e,t={}){let r=t.waitMs??0,n=t.pollMs??10,i=t.now??Ve,o=i()+r;do{let s=Rl(e);if(s)return vl(s);let a=o-i();if(a<=0)return null;Tl(Math.min(n,a))}while(i()<=o);return null}function Rl(e){let t=He(e,{kind:"generic",parseLegacy:El});return t.kind==="acquired"?t.lock:null}function vl(e){return{release:()=>{e.release()}}}function Tl(e){let t=new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));Atomics.wait(t,0,0,e)}import{createHash as wl}from"crypto";import{existsSync as at,statSync as fn}from"fs";import{basename as Cl,dirname as Xt,join as fe}from"path";var Ce=1,mn=1,ct=".scipquery-generations",Yt="manifest.json";function $(e){return fe(Xt(e),ct)}function Ke(e){try{let t=JSON.parse(g(fe($(e),"state.json"),"SQLite generation state"));return _l(t)?t:null}catch{return null}}function Qt(e,t){return Zt($(e),t)}function Zt(e,t){try{let r=JSON.parse(g(fe(e,t,Yt),"SQLite generation manifest"));return Nl(r,t)?r:null}catch{return null}}function gn(e){let t=Ke(e.dbPath);if(t){let r=Pl(e,t.currentGeneration);if(r)return r;if(t.artifactSet==="immutable-v1")throw new Error(`Published SQLite generation ${t.currentGeneration} is missing or invalid.`)}if(at(fe(Xt(e.dbPath),"index.lock")))throw new Error("Legacy SQLite publication is in progress; retry after the reindex lock is released.");return kl(e,t?.currentGeneration)}function fy(e){let t=Ke(e);if(t)return t.currentGeneration;try{let r=fe(Xt(e),"meta.json"),n=at(r)?g(r,"reindex metadata"):void 0;return So(e,n)}catch{return null}}function me(e){return Ut(pe(e))??e}function Pl(e,t){try{let r=fe($(e.dbPath),t),n=Qt(e.dbPath,t);if(!n)return null;let i=un(r,n.database),o=n.index?un(r,n.index):void 0,s=n.metadata?un(r,n.metadata):void 0;return!dn(i,n.database)||n.index&&(!o||!dn(o,n.index))||n.metadata&&(!s||!dn(s,n.metadata))?null:{identity:t,databasePath:i,...o?{indexPath:o}:{},...s?{metadataPath:s,metadataRaw:g(s,"reindex metadata")}:{},source:"immutable"}}catch{return null}}function kl(e,t){let r=ie(e.dbPath),n=fe(Xt(e.dbPath),"meta.json"),i=at(n)?g(n,"reindex metadata"):void 0,o=at(e.indexPath)?e.indexPath:void 0;return{identity:t??So(e.dbPath,i),databasePath:e.dbPath,...o?{indexPath:o}:{},...i===void 0?{}:{metadataPath:n,metadataRaw:i},source:"legacy",databaseFileIdentity:r}}function So(e,t){let r=wl("sha256").update("sqlite-generation-legacy-v1\0");return t!==void 0&&r.update(me(t)),r.update(`\0${ie(e)}`),r.digest("hex")}function ie(e){let t=fn(e);return`${t.dev}:${t.ino}:${t.size}:${t.mtimeMs}`}function un(e,t){if(Cl(t.file)!==t.file||t.file==="."||t.file==="..")throw new Error("SQLite generation manifest contains an unsafe artifact path");return fe(e,t.file)}function dn(e,t){return at(e)&&fn(e).isFile()&&fn(e).size===t.size}function Nl(e,t){return e.version===mn&&e.identity===t&&pn(e.database)&&(e.index===void 0||pn(e.index))&&(e.metadata===void 0||pn(e.metadata))}function pn(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.file=="string"&&!!t.file&&Number.isSafeInteger(t.size)&&(t.size??-1)>=0&&typeof t.sha256=="string"&&/^[a-f0-9]{64}$/.test(t.sha256)}function _l(e){return e.version===Ce&&typeof e.currentGeneration=="string"&&!!e.currentGeneration&&typeof e.publishedAt=="string"&&Number.isFinite(Date.parse(e.publishedAt))&&(e.artifactSet===void 0||e.artifactSet==="immutable-v1")&&Al(e.stableMirrors)&&Dl(e.previousGeneration)&&Fl(e.publication)}function Al(e){if(e===void 0)return!0;if(!e||typeof e!="object")return!1;let t=e;return typeof t.databaseFileIdentity=="string"&&!!t.databaseFileIdentity&&(t.indexFileIdentity===void 0||typeof t.indexFileIdentity=="string"&&!!t.indexFileIdentity)}function Dl(e){if(e===void 0)return!0;if(!e||typeof e!="object")return!1;let t=e;return typeof t.generationIdentity=="string"&&!!t.generationIdentity&&typeof t.databasePath=="string"&&!!t.databasePath&&(t.metadataPath===void 0||typeof t.metadataPath=="string"&&!!t.metadataPath)}function Fl(e){if(e===void 0)return!0;if(!e||typeof e!="object")return!1;let t=e,r=[t.converterDurationMs,t.affectedDocumentCount,t.changedDocumentCount,t.producerDurationMs,t.materializationDurationMs,t.patchDurationMs].filter(n=>n!==void 0);return(t.mode==="incremental"||t.mode==="full")&&t.validation==="passed"&&t.converterDurationMs!==void 0&&r.every(n=>typeof n=="number"&&Number.isFinite(n)&&n>=0)&&(t.scipCompanion===void 0||t.scipCompanion==="current"||t.scipCompanion==="deferred")&&(t.typescriptOverlayGeneration===void 0||typeof t.typescriptOverlayGeneration=="string"&&!!t.typescriptOverlayGeneration)&&(t.scipCompanion!=="deferred"||!!t.typescriptOverlayGeneration)&&(t.fallbackReason===void 0||typeof t.fallbackReason=="string")}import Ol from"better-sqlite3";var Ll=["node_modules",".git","dist","build","out","coverage","target",".next",".nuxt",".cache",".turbo",".nbb",".cpcache",".shadow-cljs",".scipquery-cache","__pycache__",".venv","venv"],xo=class{db;config;generation;pathFilter;statementCache=new Map;constructor(t,r){this.config=t,this.pathFilter=r??null;let n=jl(t);this.generation=n.generation,this.db=n.db,this.db.pragma("busy_timeout = 5000"),this.db.pragma("query_only = ON"),this.db.pragma("temp_store = MEMORY"),this.db.pragma("cache_size = -64000"),this.db.pragma("mmap_size = 268435456");try{Ml(this.db)}catch(i){throw this.db.close(),i}}isIgnored(t){return this.pathFilter?.isIgnored(t)??!1}get localSymbolPredicate(){return`(
10
+ EXISTS (
11
+ SELECT 1
12
+ FROM defn_enclosing_ranges local_der
13
+ JOIN documents local_d ON local_der.document_id = local_d.id
14
+ WHERE local_der.symbol_id = gs.id
15
+ ${this.pathExclusionsFor("local_d").trimStart()}
16
+ )
17
+ OR EXISTS (
18
+ SELECT 1
19
+ FROM mentions local_m
20
+ JOIN chunks local_c ON local_m.chunk_id = local_c.id
21
+ JOIN documents local_d ON local_c.document_id = local_d.id
22
+ WHERE local_m.symbol_id = gs.id
23
+ AND local_m.role = 1
24
+ ${this.pathExclusionsFor("local_d").trimStart()}
25
+ )
26
+ )`}get pathExclusions(){return this.pathExclusionsFor("d")}get symbolNoise(){return this.symbolNoiseFor("gs")}pathExclusionsFor(...t){return t.flatMap(r=>Ll.flatMap(n=>[`AND ${r}.relative_path NOT LIKE '${n}/%'`,`AND ${r}.relative_path NOT LIKE '%/${n}/%'`])).join(`
27
+ `)}symbolNoiseFor(t){return`AND ${t}.symbol NOT LIKE '%().(%' AND ${t}.symbol NOT LIKE '%typeLiteral%'`}all(t,...r){return this.statement(t).all(...r)}get(t,...r){return this.statement(t).get(...r)}close(){this.statementCache.clear(),this.db.close()}statement(t){let r=this.statementCache.get(t);return r||(r=this.db.prepare(t),this.statementCache.set(t,r)),r}};function Ml(e){if(!e.prepare("SELECT 1 AS present FROM sqlite_master WHERE type = 'table' AND name = 'documents'").get())return;let r=e.prepare("SELECT relative_path FROM documents").iterate();for(let n of r)Ue(n.relative_path)}function jl(e){for(let t=0;t<4;t+=1){let r=gn(e),n=new Ol(r.databasePath,{readonly:!0,fileMustExist:!0});if(r.source==="immutable")return{db:n,generation:r};try{let i=gn(e);if(r.databaseFileIdentity===ie(r.databasePath)&&i.source==="legacy"&&i.identity===r.identity&&i.databaseFileIdentity===r.databaseFileIdentity&&i.metadataRaw===r.metadataRaw)return{db:n,generation:r}}catch(i){throw n.close(),i}n.close()}throw new Error("SQLite index publication changed repeatedly while opening a coherent generation.")}import{createHash as Gl}from"crypto";import{existsSync as Bl,mkdirSync as $l}from"fs";import{dirname as bo,join as ql}from"path";import yn from"better-sqlite3";var Wl="evidence.db";var Vl=["source-facts","definition-exclusions","doc-path-tokens","react-component-behavior-profiles"],hn=new Set(Vl),Ul=25e4,Hl=512*1024*1024;var er=new WeakMap,zl=w("evidence-content-hash",{clearGroups:["whole-project","source-file"]}),Jl=w("evidence-project-fingerprint",{clearGroups:["whole-project"]}),ge="evidence-v1",Xe="version NOT LIKE 'evidence-%'";function tr(e){return Gl("sha256").update(e).digest("hex")}function lt(e,t,r){return zl.get(e,t,()=>tr(r))}function Io(e){return Jl.get(e,"current",()=>{try{if(!e.generation.metadataRaw)return null;let t=pe(e.generation.metadataRaw);if(t.kind!=="legacy"&&t.kind!=="supported"||!t.capabilities.usableForEvidenceCache)return null;let r=t.metadata,n=[...r.indexedLanguages??[]].sort();return tr(JSON.stringify({fingerprint:r.fingerprint,indexedLanguages:n,status:r.status}))}catch(t){return Ye("project fingerprint unavailable",t),null}})}function Ye(e,t){process.env.SCIP_QUERY_DEBUG&&console.error(`evidence-cache: ${e}: ${t instanceof Error?t.message:String(t)}`)}function ut(e){if(er.has(e))return er.get(e)??null;let t=null;try{let r=new yn(ql(bo(e.config.dbPath),Wl));r.pragma("journal_mode = WAL"),r.pragma("busy_timeout = 5000"),r.pragma("synchronous = NORMAL"),r.exec(`
28
+ CREATE TABLE IF NOT EXISTS file_evidence (
29
+ kind TEXT NOT NULL,
30
+ relative_path TEXT NOT NULL,
31
+ content_hash TEXT NOT NULL,
32
+ version TEXT NOT NULL,
33
+ payload TEXT NOT NULL,
34
+ PRIMARY KEY (kind, relative_path)
35
+ );
36
+ CREATE TABLE IF NOT EXISTS project_evidence (
37
+ kind TEXT NOT NULL,
38
+ cache_key TEXT NOT NULL,
39
+ project_fingerprint TEXT NOT NULL,
40
+ version TEXT NOT NULL,
41
+ payload TEXT NOT NULL,
42
+ PRIMARY KEY (kind, cache_key)
43
+ );
44
+ CREATE TABLE IF NOT EXISTS semantic_callees (
45
+ relative_path TEXT NOT NULL,
46
+ symbol TEXT NOT NULL,
47
+ content_hash TEXT NOT NULL,
48
+ deps_digest TEXT NOT NULL,
49
+ version TEXT NOT NULL,
50
+ payload TEXT NOT NULL,
51
+ PRIMARY KEY (relative_path, symbol)
52
+ );
53
+ CREATE TABLE IF NOT EXISTS semantic_references (
54
+ relative_path TEXT NOT NULL,
55
+ symbol TEXT NOT NULL,
56
+ project_fingerprint TEXT NOT NULL,
57
+ version TEXT NOT NULL,
58
+ payload TEXT NOT NULL,
59
+ PRIMARY KEY (relative_path, symbol)
60
+ );
61
+ CREATE TABLE IF NOT EXISTS finding_outcome_ledger (
62
+ check_name TEXT NOT NULL,
63
+ finding_id TEXT NOT NULL,
64
+ first_seen INTEGER NOT NULL,
65
+ last_seen INTEGER NOT NULL,
66
+ times_shown INTEGER NOT NULL,
67
+ outcome TEXT NOT NULL,
68
+ PRIMARY KEY (check_name, finding_id)
69
+ );
70
+ CREATE TABLE IF NOT EXISTS finding_outcome_observations (
71
+ observation_id TEXT PRIMARY KEY,
72
+ fingerprint TEXT NOT NULL,
73
+ observed_at INTEGER NOT NULL
74
+ );
75
+ `),t={evidence:r,shared:Kl(e.config.sharedEvidenceDbPath),readFileEvidence:r.prepare("SELECT payload FROM file_evidence WHERE kind = ? AND relative_path = ? AND content_hash = ? AND version = ?"),readLegacyFileEvidence:r.prepare(`SELECT payload FROM file_evidence
76
+ WHERE kind = ? AND relative_path = ? AND content_hash = ? AND ${Xe}
77
+ ORDER BY version DESC
78
+ LIMIT 1`),writeFileEvidence:r.prepare("INSERT OR REPLACE INTO file_evidence (kind, relative_path, content_hash, version, payload) VALUES (?, ?, ?, ?, ?)"),readProjectEvidence:r.prepare("SELECT payload FROM project_evidence WHERE kind = ? AND cache_key = ? AND project_fingerprint = ? AND version = ?"),readLegacyProjectEvidence:r.prepare(`SELECT payload FROM project_evidence
79
+ WHERE kind = ? AND cache_key = ? AND project_fingerprint = ? AND ${Xe}
80
+ ORDER BY version DESC
81
+ LIMIT 1`),writeProjectEvidence:r.prepare("INSERT OR REPLACE INTO project_evidence (kind, cache_key, project_fingerprint, version, payload) VALUES (?, ?, ?, ?, ?)"),readCallees:r.prepare(`SELECT payload FROM semantic_callees
82
+ WHERE relative_path = ? AND symbol = ? AND content_hash = ? AND deps_digest = ? AND version = ?`),readLegacyCallees:r.prepare(`SELECT payload FROM semantic_callees
83
+ WHERE relative_path = ? AND symbol = ? AND content_hash = ? AND deps_digest = ? AND ${Xe}
84
+ ORDER BY version DESC
85
+ LIMIT 1`),readCalleesForFile:r.prepare(`SELECT symbol, payload FROM semantic_callees
86
+ WHERE relative_path = ? AND content_hash = ? AND deps_digest = ? AND version = ?`),readLegacyCalleesForFile:r.prepare(`SELECT symbol, payload FROM semantic_callees
87
+ WHERE relative_path = ? AND content_hash = ? AND deps_digest = ? AND ${Xe}
88
+ ORDER BY symbol, version DESC`),writeCallees:r.prepare(`INSERT OR REPLACE INTO semantic_callees
89
+ (relative_path, symbol, content_hash, deps_digest, version, payload) VALUES (?, ?, ?, ?, ?, ?)`),dropStaleCallees:r.prepare("DELETE FROM semantic_callees WHERE relative_path = ? AND content_hash != ?"),readReferences:r.prepare(`SELECT payload FROM semantic_references
90
+ WHERE relative_path = ? AND symbol = ? AND project_fingerprint = ? AND version = ?`),readLegacyReferences:r.prepare(`SELECT payload FROM semantic_references
91
+ WHERE relative_path = ? AND symbol = ? AND project_fingerprint = ? AND ${Xe}
92
+ ORDER BY version DESC
93
+ LIMIT 1`),readReferencesForFile:r.prepare(`SELECT symbol, payload FROM semantic_references
94
+ WHERE relative_path = ? AND project_fingerprint = ? AND version = ?`),readLegacyReferencesForFile:r.prepare(`SELECT symbol, payload FROM semantic_references
95
+ WHERE relative_path = ? AND project_fingerprint = ? AND ${Xe}
96
+ ORDER BY symbol, version DESC`),writeReferences:r.prepare(`INSERT OR REPLACE INTO semantic_references
97
+ (relative_path, symbol, project_fingerprint, version, payload) VALUES (?, ?, ?, ?, ?)`),dropStaleReferences:r.prepare("DELETE FROM semantic_references WHERE relative_path = ? AND project_fingerprint != ?"),readFindingOutcomeLedger:r.prepare("SELECT check_name, finding_id, first_seen, last_seen, times_shown, outcome FROM finding_outcome_ledger"),claimFindingOutcomeObservation:r.prepare(`INSERT OR IGNORE INTO finding_outcome_observations
98
+ (observation_id, fingerprint, observed_at) VALUES (?, ?, ?)`),readFindingOutcomeObservation:r.prepare("SELECT fingerprint FROM finding_outcome_observations WHERE observation_id = ?"),upsertFindingOutcomeLedgerRow:r.prepare(`INSERT INTO finding_outcome_ledger
99
+ (check_name, finding_id, first_seen, last_seen, times_shown, outcome)
100
+ VALUES (?, ?, ?, ?, ?, ?)
101
+ ON CONFLICT(check_name, finding_id) DO UPDATE SET
102
+ first_seen = MIN(finding_outcome_ledger.first_seen, excluded.first_seen),
103
+ last_seen = MAX(finding_outcome_ledger.last_seen, excluded.last_seen),
104
+ times_shown = finding_outcome_ledger.times_shown + excluded.times_shown,
105
+ outcome = excluded.outcome`),updateFindingOutcomeLedgerRow:r.prepare(`UPDATE finding_outcome_ledger
106
+ SET first_seen = MIN(first_seen, ?),
107
+ last_seen = MAX(last_seen, ?),
108
+ outcome = ?
109
+ WHERE check_name = ? AND finding_id = ?`),trimFindingOutcomeLedgerCheck:r.prepare(`DELETE FROM finding_outcome_ledger
110
+ WHERE rowid IN (
111
+ SELECT rowid
112
+ FROM finding_outcome_ledger
113
+ WHERE check_name = ?
114
+ ORDER BY last_seen DESC, first_seen DESC, finding_id DESC
115
+ LIMIT -1 OFFSET ?
116
+ )`)}}catch(r){Ye("disabled (open failed)",r)}return er.set(e,t),t}function dt(e,t,r){Ye(`disabled (${t})`,r),er.set(e,null)}function Kl(e){if(!e)return null;try{$l(bo(e),{recursive:!0});let t=new yn(e);return t.pragma("journal_mode = WAL"),t.pragma("busy_timeout = 250"),t.pragma("synchronous = NORMAL"),t.exec(`
117
+ CREATE TABLE IF NOT EXISTS file_evidence (
118
+ kind TEXT NOT NULL,
119
+ relative_path TEXT NOT NULL,
120
+ content_hash TEXT NOT NULL,
121
+ version TEXT NOT NULL,
122
+ payload TEXT NOT NULL,
123
+ last_accessed_at INTEGER NOT NULL,
124
+ PRIMARY KEY (kind, relative_path, content_hash, version)
125
+ );
126
+ `),{evidence:t,readFileEvidence:t.prepare("SELECT payload FROM file_evidence WHERE kind = ? AND relative_path = ? AND content_hash = ? AND version = ?"),writeFileEvidence:t.prepare(`INSERT INTO file_evidence (kind, relative_path, content_hash, version, payload, last_accessed_at)
127
+ VALUES (?, ?, ?, ?, ?, ?)
128
+ ON CONFLICT(kind, relative_path, content_hash, version)
129
+ DO UPDATE SET payload = excluded.payload, last_accessed_at = excluded.last_accessed_at`)}}catch(t){return Ye("shared cache disabled (open failed)",t),null}}function Sn(e,t,r){Ye(`shared cache disabled (${t})`,r);try{e.shared?.evidence.close()}catch{}e.shared=null}function Ty(e,t={}){if(!Bl(e))return null;let r;try{r=new yn(e),r.pragma("busy_timeout = 50"),r.pragma("wal_checkpoint(TRUNCATE)");let n=r.prepare("SELECT COUNT(*) AS count FROM file_evidence").get().count,i=t.maxRows??Ul,o=t.budgetBytes??Hl,s=Number(r.pragma("page_size",{simple:!0})),a=Number(r.pragma("page_count",{simple:!0})),c=Number(r.pragma("freelist_count",{simple:!0})),l=Math.max(0,a-c)*s,u=n>0&&l>o?Math.min(n,Math.ceil((l-o)/Math.max(1,l/n))):0,d=Math.max(n-i,u);return d>0&&(r.prepare(`DELETE FROM file_evidence WHERE rowid IN (
130
+ SELECT rowid FROM file_evidence ORDER BY last_accessed_at ASC, rowid ASC LIMIT ?
131
+ )`).run(d),r.pragma("wal_checkpoint(TRUNCATE)")),{deletedRows:d,remainingRows:n-d}}catch(n){return Ye("shared cache maintenance skipped",n),null}finally{try{r?.close()}catch{}}}function Eo(e,t,r,n){let i=ut(e);if(!i)return null;try{let o=i.readFileEvidence.get(t,r,n,ge)??i.readLegacyFileEvidence.get(t,r,n);if(o?.payload!==void 0)return o.payload;if(!hn.has(t)||!i.shared)return null;try{return i.shared.readFileEvidence.get(t,r,n,ge)?.payload??null}catch(s){return Sn(i,"file_evidence read",s),null}}catch(o){return dt(e,"file_evidence read",o),null}}function Ro(e,t,r,n,i){let o=ut(e);if(o)try{if(o.writeFileEvidence.run(t,r,n,ge,i),hn.has(t)&&o.shared)try{o.shared.writeFileEvidence.run(t,r,n,ge,i,Date.now())}catch(s){Sn(o,"file_evidence write",s)}}catch(s){dt(e,"file_evidence write",s)}}function vo(e,t){if(t.length===0)return;let r=ut(e);if(r)try{r.evidence.transaction(()=>{for(let i of t)r.writeFileEvidence.run(i.kind,i.relativePath,i.contentHash,ge,i.payload)})();let n=t.filter(i=>hn.has(i.kind));if(n.length>0&&r.shared)try{r.shared.evidence.transaction(()=>{for(let i of n)r.shared.writeFileEvidence.run(i.kind,i.relativePath,i.contentHash,ge,i.payload,Date.now())})()}catch(i){Sn(r,"file_evidence batch write",i)}}catch(n){dt(e,"file_evidence batch write",n)}}function To(e,t,r,n){let i=ut(e);if(!i)return null;try{return(i.readProjectEvidence.get(t,r,n,ge)??i.readLegacyProjectEvidence.get(t,r,n))?.payload??null}catch(o){return dt(e,"project_evidence read",o),null}}function wo(e,t,r,n,i){let o=ut(e);if(o)try{o.writeProjectEvidence.run(t,r,n,ge,i)}catch(s){dt(e,"project_evidence write",s)}}function xn(e){return typeof e=="object"&&e!==null}function Cy(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")?e:null}import{execFileSync as Xl}from"child_process";import{existsSync as Yl,readdirSync as Po}from"fs";import{extname as ko,join as No}from"path";var _o=new Set([".git",".hg",".svn",".idea",".vscode","node_modules","vendor","dist","build","target","bin","obj",".dart_tool",".gradle",".next",".venv","venv","__pycache__"]),Ql=[{language:"typescript",files:["tsconfig.json","tsconfig.base.json"],extensions:[".ts",".tsx",".mts",".cts"]},{language:"rust",files:["Cargo.toml"],extensions:[".rs"]},{language:"go",files:["go.mod"],extensions:[".go"]},{language:"java",files:["pom.xml","build.gradle","build.gradle.kts"],extensions:[".java"]},{language:"kotlin",files:["build.gradle.kts"],extensions:[".kt",".kts"]},{language:"scala",files:["build.sbt"],extensions:[".scala"]},{language:"clojure",files:["deps.edn","project.clj","bb.edn","shadow-cljs.edn"],extensions:[".clj",".cljs",".cljc"]},{language:"python",files:["pyproject.toml","setup.py","setup.cfg","Pipfile"],extensions:[".py",".pyi"]},{language:"ruby",files:["Gemfile"],extensions:[".rb"]},{language:"cpp",files:["compile_commands.json","CMakeLists.txt","Makefile"],extensions:[".cc",".cpp",".cxx",".hpp",".hh",".hxx"]},{language:"c",files:["compile_commands.json","CMakeLists.txt","Makefile"],extensions:[".c",".h"]},{language:"csharp",globs:["*.csproj","*.sln"],extensions:[".cs"]},{language:"vb",globs:["*.vbproj"],extensions:[".vb"]},{language:"dart",files:["pubspec.yaml"],extensions:[".dart"]},{language:"php",files:["composer.json"],extensions:[".php"]},{language:"javascript",files:["package.json"],extensions:[".js",".jsx",".mjs",".cjs"]}];function Ay(e){let t=[],r=Zl(e),n=nu(e);for(let i of Ql){if(eu(e,i.files)){t.push(i.language);continue}if(tu(r,i.globs)){t.push(i.language);continue}ou(n,i.extensions)&&t.push(i.language)}return t.includes("typescript")&&Co(t,"javascript"),t.includes("cpp")&&!n.has(".c")&&Co(t,"c"),t}function Zl(e){try{return Po(e)}catch{return[]}}function eu(e,t){return t?.length?t.some(r=>Yl(No(e,r))):!1}function tu(e,t){return t?.length?e.some(r=>t.some(n=>ru(r,n))):!1}function ru(e,t){if(t==="*")return!0;if(!t.includes("*"))return e===t;let[r,n]=t.split("*");return e.startsWith(r??"")&&e.endsWith(n??"")}function nu(e){let t=iu(e);if(t)return t;let r=new Set,n=[e];for(;n.length>0;){let i=n.pop();if(!i)continue;let o;try{o=Po(i,{withFileTypes:!0})}catch{continue}for(let s of o){if(s.name.startsWith(".")&&!s.name.endsWith("proj")&&!s.name.endsWith("sln")&&s.isDirectory())continue;let a=No(i,s.name);if(s.isDirectory()){_o.has(s.name)||n.push(a);continue}let c=ko(s.name).toLowerCase();c&&r.add(c)}}return r}function iu(e){try{let t=Xl("git",["-C",e,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:26214400,stdio:["ignore","pipe","ignore"],timeout:3e4,killSignal:"SIGKILL"}),r=new Set;for(let n of t.split(`
132
+ `)){if(!n||n.split("/").some(o=>_o.has(o)))continue;let i=ko(n).toLowerCase();i&&r.add(i)}return r}catch{return null}}function ou(e,t){return t?.length?t.some(r=>e.has(r)):!1}function Co(e,t){let r=e.indexOf(t);r!==-1&&e.splice(r,1)}import{writeFileSync as su}from"fs";import{create as Ao}from"@bufbuild/protobuf";import{deserializeSCIP as au,DocumentSchema as cu,IndexSchema as lu,serializeSCIP as uu,SymbolRole as du}from"@c4312/scip";function Gy(e){let t;try{t=au(v(e,{inputKind:"SCIP sanitization input",maxBytes:F}))}catch{return{removedDefinitionOccurrences:0,touchedDocuments:0}}let r=bn(t);return r.removedDefinitionOccurrences>0&&su(e,Buffer.from(uu(r.index))),{removedDefinitionOccurrences:r.removedDefinitionOccurrences,touchedDocuments:r.touchedDocuments}}function bn(e){let t=new Set;for(let o of e.documents){Ue(o.relativePath);for(let s of o.symbols)s.symbol&&t.add(s.symbol)}for(let o of e.externalSymbols)o.symbol&&t.add(o.symbol);let r=0,n=0,i=[];for(let o of e.documents){let s=o.occurrences.filter(a=>(a.symbolRoles&du.Definition)===0||t.has(a.symbol)?!0:(r+=1,!1));if(s.length===o.occurrences.length){i.push(o);continue}n+=1,i.push(Ao(cu,{language:o.language,relativePath:o.relativePath,occurrences:s,symbols:o.symbols,text:o.text,positionEncoding:o.positionEncoding}))}return{index:r===0?e:Ao(lu,{metadata:e.metadata,documents:i,externalSymbols:e.externalSymbols}),removedDefinitionOccurrences:r,touchedDocuments:n}}import{writeFileSync as In}from"fs";import{create as pt}from"@bufbuild/protobuf";import{deserializeSCIP as En,serializeSCIP as Rn,DocumentSchema as pu,IndexSchema as Do,MetadataSchema as fu,SymbolInformationSchema as mu}from"@c4312/scip";function Fo(e){if(e.length===0)throw new Error("Cannot merge zero SCIP indexes");if(e.length===1)return e[0];let t=yu(e),r=hu(e.flatMap(i=>i.documents??[])),n=Lo(e.flatMap(i=>i.externalSymbols??[]));return pt(Do,{metadata:t,documents:r,externalSymbols:n})}function Hy(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let r=e.map(i=>En(v(i,{inputKind:"SCIP merge input",maxBytes:F}))),n=Fo(r);return In(t,Buffer.from(Rn(n))),{documentCount:n.documents.length,externalSymbolCount:n.externalSymbols.length,inputCount:e.length}}function zy(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let r=e.map(i=>En(v(i,{inputKind:"SCIP merge input",maxBytes:F}))),n=bn(Fo(r));return In(t,Buffer.from(Rn(n.index))),{documentCount:n.index.documents.length,externalSymbolCount:n.index.externalSymbols.length,inputCount:e.length,removedDefinitionOccurrences:n.removedDefinitionOccurrences,touchedDocuments:n.touchedDocuments}}function gu(e,t,r){let n=e.metadata;if(!n)throw new Error("Cannot rebase a SCIP index without metadata");if(n.projectRoot!==t)throw new Error(`Cannot rebase SCIP project root: expected ${t}, got ${n.projectRoot}`);return pt(Do,{metadata:pt(fu,{...n,projectRoot:r}),documents:e.documents,externalSymbols:e.externalSymbols})}function Oo(e,t,r){let n=En(v(e,{inputKind:"SCIP normalization input",maxBytes:F})),i=gu(n,t,r);In(e,Buffer.from(Rn(i)))}function yu(e){let t=e[0]?.metadata;if(!t)return;let r=t.projectRoot;for(let n of e.slice(1)){let i=n.metadata?.projectRoot;if(r&&i&&i!==r)throw new Error(`Cannot merge SCIP indexes with different project roots: ${r} vs ${i}`)}return t}function hu(e){let t=new Map;for(let r of e){let n=t.get(r.relativePath);if(!n){t.set(r.relativePath,r);continue}t.set(r.relativePath,pt(pu,{language:n.language||r.language,relativePath:n.relativePath||r.relativePath,occurrences:Su([...n.occurrences,...r.occurrences]),symbols:Lo([...n.symbols,...r.symbols]),text:bu(n.text,r.text),positionEncoding:n.positionEncoding||r.positionEncoding}))}return[...t.values()]}function Su(e){let t=new Set,r=[];for(let n of e){let i=JSON.stringify(n);t.has(i)||(t.add(i),r.push(n))}return r}function Lo(e){let t=new Map;for(let r of e){let n=t.get(r.symbol);if(!n){t.set(r.symbol,r);continue}t.set(r.symbol,pt(mu,{symbol:n.symbol,documentation:Iu([...n.documentation,...r.documentation]),relationships:xu([...n.relationships,...r.relationships]),kind:n.kind||r.kind,displayName:n.displayName||r.displayName,enclosingSymbol:n.enclosingSymbol||r.enclosingSymbol,signatureDocumentation:n.signatureDocumentation??r.signatureDocumentation}))}return[...t.values()]}function xu(e){let t=new Set,r=[];for(let n of e){let i=[n.symbol,n.isReference?"1":"0",n.isImplementation?"1":"0",n.isTypeDefinition?"1":"0",n.isDefinition?"1":"0"].join("|");t.has(i)||(t.add(i),r.push(n))}return r}function bu(e,t){return e?t?e.length>=t.length?e:t:e:t}function Iu(e){return[...new Set(e)]}import{createHash as Nu}from"crypto";import{existsSync as mt,mkdirSync as _u,readdirSync as Pn,renameSync as Au,rmSync as Qo,writeFileSync as Du}from"fs";import{join as z}from"path";import{createHash as Eu}from"crypto";import{existsSync as Tn,mkdirSync as Ru,readdirSync as Yy,renameSync as vu,rmSync as Qy,writeFileSync as Tu}from"fs";import{join as Qe}from"path";import{create as jo,fromBinary as Go,toBinary as wu}from"@bufbuild/protobuf";import{deserializeSCIP as rr,DocumentSchema as wn,IndexSchema as Bo,serializeSCIP as $o}from"@c4312/scip";var nr=1,ft="typescript-scip-fragments";function ih(e){if(e.length===0)throw new Error("affected TypeScript mini index requires documents");let t=new Set,r=[];for(let o of e){let s=Pe(o.relativePath);if(t.has(s))throw new Error(`duplicate TypeScript fragment replacement: ${s}`);if(t.add(s),o.bytes===null)throw new Error(`affected TypeScript mini index cannot contain a deleted document: ${s}`);let a=Go(wn,o.bytes);if(a.relativePath!==s)throw new Error(`TypeScript fragment path mismatch: expected ${s}, got ${a.relativePath}`);r.push(a)}let n=$o(jo(Bo,{documents:r,externalSymbols:[]})),i=rr(n);if(i.documents.length!==r.length||i.externalSymbols.length!==0)throw new Error("affected TypeScript SCIP index failed structural verification");return n}function ir(e){let t=Qe(e,ft);return{rootDir:t,blobDir:Qe(t,"blobs"),generationDir:Qe(t,"generations")}}function Cu(e){let t=rr(e.indexBytes);Xo(t.metadata,Yo(e)),Ko(t.externalSymbols);let r=new Set,n=[];for(let o of t.documents){let s=Pe(o.relativePath);if(r.has(s))throw new Error(`duplicate TypeScript SCIP document path: ${s}`);r.add(s);let a=wu(wn,o),c=e.documentIdentities.get(s)??(e.allowUntrackedDocuments?ke(JSON.stringify({version:1,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,untrackedDocument:s,contentHash:ke(a)})):null);if(!c)throw new Error(`missing TypeScript document identity: ${s}`);n.push(Uo(e.cacheDir,{relativePath:s,bytes:a,occurrences:o.occurrences.length,symbols:o.symbols.length,referenceFragments:[]},c))}let i=Ho(e,n);return zo(e.cacheDir,i),i}function oh(e){let t=ir(e.cacheDir);if(!Tn(Cn(t,e.generationIdentity)))return Cu(e);let r=qo({cacheDir:e.cacheDir,generationIdentity:e.generationIdentity,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity});if(!e.allowUntrackedDocuments&&r.manifest.documents.length!==e.documentIdentities.size)throw new Error("TypeScript fragment generation document identities changed");for(let n of r.manifest.documents){let i=e.documentIdentities.get(n.relativePath);if(!(i===void 0&&e.allowUntrackedDocuments)&&i!==n.documentIdentity)throw new Error(`TypeScript fragment generation document identity changed: ${n.relativePath}`)}return r.manifest}function sh(e){let t=qo({cacheDir:e.cacheDir,generationIdentity:e.previousGenerationIdentity,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity}).manifest,r=new Map(t.documents.map(o=>[o.relativePath,o])),n=new Set;for(let o of e.fragments){let s=Pe(o.relativePath);if(n.has(s))throw new Error(`duplicate TypeScript fragment replacement: ${s}`);if(n.add(s),!r.has(s))throw new Error(`TypeScript fragment replacement has no prior document: ${s}`);let a=e.documentIdentities.get(s);if(!a)throw new Error(`missing TypeScript document identity: ${s}`);o.bytes===null?r.delete(s):r.set(s,Uo(e.cacheDir,o,a))}if(n.size===0)throw new Error("TypeScript fragment generation requires at least one replacement");let i=Ho(e,[...r.values()]);return zo(e.cacheDir,i),i}function qo(e){let t=ir(e.cacheDir),r=Cn(t,e.generationIdentity),n;try{n=Jo(X(r,{maxBytes:K,inputKind:"TypeScript fragment manifest"}))}catch(o){throw new Error(`TypeScript fragment generation is unavailable: ${o instanceof Error?o.message:String(o)}`,{cause:o})}if(n.generationIdentity!==e.generationIdentity)throw new Error("TypeScript fragment generation identity does not match its manifest path");if(e.producerIdentity&&n.producerIdentity!==e.producerIdentity)throw new Error("TypeScript fragment producer identity changed");if(e.projectIdentity&&n.projectIdentity!==e.projectIdentity)throw new Error("TypeScript fragment project identity changed");let i=new Map;for(let o of n.documents){let s=Qe(t.blobDir,`${o.blobHash}.scipdoc`),a=v(s,{maxBytes:qe,inputKind:"TypeScript fragment blob"});if(a.byteLength!==o.byteLength||ke(a)!==o.blobHash)throw new Error(`TypeScript fragment blob is corrupt: ${o.relativePath}`);i.set(o.relativePath,a)}return{manifest:n,fragments:i}}function Wo(e){let t=Vo(e);return vn(t.baseIndex,t.completeDocuments,"assembled")}function ah(e){let t=Vo(e);return Pu(t.deletedAffectedPaths),{completeIndexBytes:vn(t.baseIndex,t.completeDocuments,"assembled"),affectedIndexBytes:vn(t.baseIndex,t.affectedDocuments,"affected")}}function Vo(e){let t=rr(e.baseIndexBytes);Xo(t.metadata,Yo(e)),Ko(t.externalSymbols);let r=new Map;for(let a of e.fragments){let c=Pe(a.relativePath);if(r.has(c))throw new Error(`duplicate TypeScript fragment replacement: ${c}`);r.set(c,a)}if(r.size===0)throw new Error("TypeScript index assembly requires at least one replacement");let n=new Set,i=[],o=[],s=[];for(let a of t.documents){let c=Pe(a.relativePath);if(n.has(c))throw new Error(`duplicate TypeScript SCIP document path: ${c}`);n.add(c);let l=r.get(c);if(!l){i.push(a);continue}if(r.delete(c),l.bytes===null){s.push(c);continue}let u=Go(wn,l.bytes);if(u.relativePath!==c)throw new Error(`TypeScript fragment path mismatch: expected ${c}, got ${u.relativePath}`);i.push(u),o.push(u)}if(r.size>0)throw new Error(`TypeScript fragment replacement has no prior document: ${[...r.keys()].sort()[0]}`);return{baseIndex:t,completeDocuments:i,affectedDocuments:o,deletedAffectedPaths:s}}function vn(e,t,r){let n=$o(jo(Bo,{metadata:e.metadata,documents:t,externalSymbols:[]})),i=rr(n);if(i.documents.length!==t.length||i.externalSymbols.length!==0)throw new Error(`${r} TypeScript SCIP index failed structural verification`);return n}function Pu(e){if(e.length>0)throw new Error(`affected TypeScript mini index cannot contain a deleted document: ${e[0]}`)}function Uo(e,t,r){if(t.bytes===null)throw new Error(`cannot persist an empty TypeScript fragment: ${t.relativePath}`);let n=Pe(t.relativePath),i=Buffer.from(t.bytes),o=ke(i),s=ir(e);Ru(s.blobDir,{recursive:!0});let a=Qe(s.blobDir,`${o}.scipdoc`);if(Tn(a)){let c=v(a,{maxBytes:qe,inputKind:"TypeScript fragment blob"});if(c.byteLength!==i.byteLength||ke(c)!==o)throw new Error(`existing TypeScript fragment blob is corrupt: ${n}`)}else{let c=`${a}.${process.pid}.${Date.now()}.tmp`;Tu(c,i),vu(c,a)}return{relativePath:n,blobHash:o,byteLength:i.byteLength,documentIdentity:r}}function Ho(e,t){if(!e.producerIdentity||!e.projectIdentity||!e.generationIdentity)throw new Error("TypeScript fragment generation identities must be non-empty");let r=[...t].sort((n,i)=>n.relativePath.localeCompare(i.relativePath));if(new Set(r.map(n=>n.relativePath)).size!==r.length)throw new Error("TypeScript fragment generation contains duplicate document paths");return{version:nr,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,generationIdentity:e.generationIdentity,createdAt:(e.now??(()=>new Date))().toISOString(),documents:r}}function zo(e,t){let r=ir(e),n=Cn(r,t.generationIdentity);if(Tn(n)){let i=Jo(X(n,{maxBytes:K,inputKind:"TypeScript fragment manifest"}));if(Mo(i)!==Mo(t))throw new Error(`TypeScript fragment generation is immutable: ${t.generationIdentity}`);return}Ot(n,t,{spacing:2,trailingNewline:!0})}function Mo(e){return ke(JSON.stringify({version:e.version,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,generationIdentity:e.generationIdentity,documents:e.documents}))}function Jo(e){let t=JSON.parse(e);if(t.version!==nr||typeof t.producerIdentity!="string"||typeof t.projectIdentity!="string"||typeof t.generationIdentity!="string"||typeof t.createdAt!="string"||!Number.isFinite(Date.parse(t.createdAt))||!Array.isArray(t.documents))throw new Error("invalid TypeScript fragment generation manifest");let r=new Set;for(let n of t.documents){if(!n||typeof n.relativePath!="string"||typeof n.blobHash!="string"||!/^[a-f0-9]{64}$/.test(n.blobHash)||typeof n.byteLength!="number"||!Number.isInteger(n.byteLength)||n.byteLength<0||typeof n.documentIdentity!="string"||!n.documentIdentity)throw new Error("invalid TypeScript fragment record");if(Pe(n.relativePath),r.has(n.relativePath))throw new Error("duplicate TypeScript fragment record");r.add(n.relativePath)}return t}function Cn(e,t){return Qe(e.generationDir,ku(t))}function ku(e){if(!e)throw new Error("TypeScript fragment generation identity must be non-empty");return`${ke(e)}.json`}function Ko(e){if(e.length>0)throw new Error("scip-typescript emitted external symbols; incremental document assembly is unsupported")}function Xo(e,t){if(!e||typeof e!="object")throw new Error("TypeScript SCIP shard has no producer metadata");let r=e,n=r.toolInfo??r.tool_info;if(!n||typeof n!="object")throw new Error("TypeScript SCIP shard has no producer tool identity");let i=n;if(i.name!=="scip-typescript"||i.version!==t)throw new Error("TypeScript SCIP shard producer identity changed")}function Yo(e){let t=e.packageVersion??e.runtime?.packageVersion;if(!t)throw new Error("scip-typescript package version is unavailable");return t}function Pe(e){if(!e||e.startsWith("/")||e.startsWith("\\")||e.includes("\\"))throw new Error(`invalid TypeScript SCIP document path: ${e}`);let t=e.split("/");if(t.includes("")||t.includes(".")||t.includes(".."))throw new Error(`invalid TypeScript SCIP document path: ${e}`);return e}function ke(e){return Eu("sha256").update(e).digest("hex")}var or=1,gh=64*1024*1024,yt="typescript-scip-overlays";function yh(e){let t=es(e.cacheDir,e.previousGenerationIdentity);if(!t&&!e.baseShardCurrent)throw new Error("deferred TypeScript SCIP base has no matching overlay generation");if(t&&(t.producerIdentity!==e.producerIdentity||t.projectIdentity!==e.projectIdentity))throw new Error("TypeScript overlay producer or project identity changed");let r=new Map((t?.overlays??[]).map(o=>[o.relativePath,o])),n=new Set;for(let o of e.fragments){let s=_n(o.relativePath);if(n.has(s))throw new Error(`duplicate TypeScript overlay: ${s}`);n.add(s),r.set(s,Fu(e.cacheDir,o))}if(n.size===0)throw new Error("TypeScript overlay generation requires affected documents");let i={version:or,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,baseGenerationIdentity:t?.baseGenerationIdentity??e.previousGenerationIdentity,generationIdentity:e.nextGenerationIdentity,createdAt:(e.now??(()=>new Date))().toISOString(),overlays:[...r.values()].sort((o,s)=>o.relativePath.localeCompare(s.relativePath))};return Ou(e.cacheDir,i),i}function hh(e){let t=es(e.cacheDir,e.generationIdentity);if(!t)throw new Error("TypeScript overlay generation is unavailable");let r=t.overlays.map(n=>{if(n.blobHash===null)return{relativePath:n.relativePath,bytes:null,occurrences:0,symbols:0,referenceFragments:[]};let i=v(z(ht(e.cacheDir),"blobs",`${n.blobHash}.scipdoc`),{maxBytes:qe,inputKind:"TypeScript overlay blob"});if(i.byteLength!==n.byteLength||gt(i)!==n.blobHash)throw new Error(`TypeScript overlay blob is corrupt: ${n.relativePath}`);return{relativePath:n.relativePath,bytes:i,occurrences:0,symbols:0,referenceFragments:[]}});return Wo({packageVersion:e.packageVersion,baseIndexBytes:e.baseIndexBytes,fragments:r})}function Sh(e,t){let r=ht(e),n=z(r,"generations");if(!mt(n))return;let i=new Set(t.map(Nn)),o=new Set;for(let a of Pn(n).filter(c=>i.has(c))){let c=kn(X(z(n,a),{maxBytes:K,inputKind:"TypeScript overlay manifest"}));for(let l of c.overlays)l.blobHash&&o.add(`${l.blobHash}.scipdoc`)}for(let a of Pn(n))i.has(a)||Qo(z(n,a),{force:!0});let s=z(r,"blobs");if(mt(s))for(let a of Pn(s))o.has(a)||Qo(z(s,a),{force:!0})}function es(e,t){let r=z(ht(e),"generations",Nn(t));if(!mt(r))return null;let n=kn(X(r,{maxBytes:K,inputKind:"TypeScript overlay manifest"}));if(n.generationIdentity!==t)throw new Error("TypeScript overlay generation identity does not match its path");return n}function Fu(e,t){let r=_n(t.relativePath);if(t.bytes===null)return{relativePath:r,blobHash:null,byteLength:0};let n=Buffer.from(t.bytes),i=gt(n),o=z(ht(e),"blobs");_u(o,{recursive:!0});let s=z(o,`${i}.scipdoc`);if(mt(s)){let a=v(s,{maxBytes:qe,inputKind:"TypeScript overlay blob"});if(a.byteLength!==n.byteLength||gt(a)!==i)throw new Error(`existing TypeScript overlay blob is corrupt: ${r}`)}else{let a=`${s}.${process.pid}.${Date.now()}.tmp`;Du(a,n),Au(a,s)}return{relativePath:r,blobHash:i,byteLength:n.byteLength}}function Ou(e,t){let r=z(ht(e),"generations",Nn(t.generationIdentity));if(mt(r)){let n=kn(X(r,{maxBytes:K,inputKind:"TypeScript overlay manifest"}));if(Zo(n)!==Zo(t))throw new Error(`TypeScript overlay generation is immutable: ${t.generationIdentity}`);return}Ot(r,t,{spacing:2,trailingNewline:!0})}function kn(e){let t=JSON.parse(e);if(t.version!==or||typeof t.producerIdentity!="string"||!t.producerIdentity||typeof t.projectIdentity!="string"||!t.projectIdentity||typeof t.baseGenerationIdentity!="string"||!t.baseGenerationIdentity||typeof t.generationIdentity!="string"||!t.generationIdentity||typeof t.createdAt!="string"||!Number.isFinite(Date.parse(t.createdAt))||!Array.isArray(t.overlays))throw new Error("invalid TypeScript overlay manifest");let r=new Set;for(let n of t.overlays){if(!n||typeof n.relativePath!="string"||n.blobHash!==null&&(typeof n.blobHash!="string"||!/^[a-f0-9]{64}$/.test(n.blobHash))||!Number.isInteger(n.byteLength)||n.byteLength<0||n.blobHash===null&&n.byteLength!==0)throw new Error("invalid TypeScript overlay record");if(_n(n.relativePath),r.has(n.relativePath))throw new Error("duplicate TypeScript overlay record");r.add(n.relativePath)}return t}function ht(e){return z(e,yt)}function Nn(e){if(!e)throw new Error("TypeScript overlay generation identity must be non-empty");return`${gt(e)}.json`}function Zo(e){return gt(JSON.stringify({version:e.version,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,baseGenerationIdentity:e.baseGenerationIdentity,generationIdentity:e.generationIdentity,overlays:e.overlays}))}function _n(e){if(!e||e.startsWith("/")||e.includes("\\")||e.split("/").some(t=>!t||t==="."))throw new Error(`invalid TypeScript overlay path: ${e}`);if(e.split("/").includes(".."))throw new Error(`invalid TypeScript overlay path: ${e}`);return e}function gt(e){return Nu("sha256").update(e).digest("hex")}import{createHash as Ln}from"crypto";import{closeSync as is,chmodSync as Lu,copyFileSync as Mu,constants as ju,existsSync as x,fsyncSync as Gu,mkdirSync as ts,openSync as os,readSync as Bu,readdirSync as $u,renameSync as On,rmSync as sr,statSync as ar}from"fs";import{basename as ss,dirname as ee,join as y,relative as rs}from"path";function as(e){let t=$(e.outputDb),r=Vu(e);e.onStage?.("after-recovery-retained");let n=e.preserveOutputScip?e.outputScip:e.tempOutputScip,i=Gn({generationRoot:t,databasePath:e.tempOutputDb,indexPath:x(n)?n:void 0,metadataPath:x(e.tempMetaPath)?e.tempMetaPath:void 0}),o=(e.now??(()=>new Date))().toISOString(),s={version:Ce,currentGeneration:i.identity,artifactSet:"immutable-v1",...r?{previousGeneration:r}:{},...e.publication?{publication:e.publication}:{},publishedAt:o};Y(y(t,"state.json"),s,{spacing:2,trailingNewline:!0}),e.onStage?.("after-pointer-handoff"),e.preserveOutputScip||Fn(e.tempOutputScip,e.outputScip),e.onStage?.("after-scip-handoff"),Fn(e.tempOutputDb,e.outputDb),e.onStage?.("after-database-handoff"),Fn(e.tempMetaPath,e.metaPath),e.onStage?.("after-metadata-handoff");let a=i.identity,c={...s,stableMirrors:jn(e.outputDb,e.outputScip)};return Y(y(t,"state.json"),c,{spacing:2,trailingNewline:!0}),{currentGeneration:a,...r?{previousGeneration:r}:{}}}function qu(e,t,r,n=()=>new Date){if(!x(e))return null;let i=Ke(e),o=y($(e),"state.json");if(i?.artifactSet==="immutable-v1"&&Qt(e,i.currentGeneration))return i;let s=$(e),a=!i&&x(o)?Hu(r,e,t):void 0;if(a&&!Zt(s,a))return null;let c=Gn({generationRoot:s,databasePath:e,indexPath:x(t)?t:void 0,metadataPath:x(r)?r:void 0,forcedIdentity:i?.currentGeneration??a}),l={version:Ce,currentGeneration:c.identity,artifactSet:"immutable-v1",stableMirrors:jn(e,t),...i?.previousGeneration?{previousGeneration:i.previousGeneration}:{},...i?.publication?{publication:i.publication}:{},publishedAt:i?.publishedAt??n().toISOString()};return Y(y(s,"state.json"),l,{spacing:2,trailingNewline:!0}),l}function Ch(e,t,r=()=>new Date){if(!x(e)||!x(t))throw new Error("metadata-only generation refresh requires stable database and metadata files");let n=Ke(e),i=$(e),o=Gn({generationRoot:i,databasePath:e,indexPath:x(y(ee(e),"index.scip"))?y(ee(e),"index.scip"):void 0,metadataPath:t}),s=n&&n.currentGeneration!==o.identity?cs(e,n.currentGeneration):void 0,a={version:Ce,currentGeneration:o.identity,artifactSet:"immutable-v1",stableMirrors:jn(e,y(ee(e),"index.scip")),...s?{previousGeneration:s}:{},...n?.publication?{publication:n.publication}:{},publishedAt:r().toISOString()};return Y(y($(e),"state.json"),a,{spacing:2,trailingNewline:!0}),a}function Mn(e,t=y(ee(e),"meta.json")){let r=y($(e),"state.json");if(!x(r))return{state:"legacy",statePath:r};let n=Ke(e);if(!n)return{state:"invalid",statePath:r,reason:"generation state is malformed"};try{let i=Qt(e,n.currentGeneration),o=i!==null,s=i?Wu(e,t,i,n):!1,a=n.previousGeneration?x(y(ee(e),n.previousGeneration.databasePath)):!0;return!s||!o||!a?{state:"drifted",statePath:r,currentMatches:s,recoveryExists:a,generation:n,reason:o?s?"retained recovery database is missing":"stable database or metadata no longer matches the published generation":"published immutable generation is missing"}:{state:"current",statePath:r,currentMatches:s,recoveryExists:a,generation:n}}catch(i){return{state:"drifted",statePath:r,currentMatches:!1,recoveryExists:!1,generation:n,reason:i instanceof Error?i.message:String(i)}}}function Wu(e,t,r,n){if(n.stableMirrors&&(n.stableMirrors.databaseFileIdentity!==ie(e)||n.stableMirrors.indexFileIdentity!==void 0&&n.stableMirrors.indexFileIdentity!==ie(y(ee(e),"index.scip")))||!ns(e,r.database))return!1;let i=y(ee(e),"index.scip");if(r.index&&!ns(i,r.index))return!1;if(!r.metadata)return!x(t);if(!x(t))return!1;let o=y($(e),r.identity,r.metadata.file);return x(o)&&me(g(t,"reindex metadata"))===me(g(o,"immutable reindex metadata"))}function ns(e,t){return x(e)&&ar(e).isFile()&&ar(e).size===t.size}function Vu(e){let t=qu(e.outputDb,e.outputScip,e.metaPath);return t?cs(e.outputDb,t.currentGeneration):void 0}function jn(e,t){return{databaseFileIdentity:ie(e),...x(t)?{indexFileIdentity:ie(t)}:{}}}function cs(e,t){let r=y($(e),t),n=y(r,ss(e)),i=y(r,"meta.json");return{generationIdentity:t,databasePath:rs(ee(e),n),...x(i)?{metadataPath:rs(ee(e),i)}:{}}}function Uu(e){if(x(e))for(let t of $u(e,{withFileTypes:!0}))t.isDirectory()&&t.name.endsWith(".tmp")&&sr(y(e,t.name),{recursive:!0,force:!0})}function Hu(e,t,r=y(ee(t),"index.scip")){let n=Ln("sha256").update("sqlite-generation-artifacts-v1\0");return n.update(cr(t)),x(r)&&n.update(`\0${cr(r)}`),x(e)&&n.update(`\0${me(g(e,"reindex metadata"))}`),n.digest("hex")}function Gn(e){let t=An(e.databasePath),r=e.indexPath?An(e.indexPath):void 0,n=e.metadataPath?An(e.metadataPath):void 0,i=e.forcedIdentity??zu(t,r,e.metadataPath),o=y(e.generationRoot,i),s=y(o,Yt);if(x(s)){let c=Zt(e.generationRoot,i);if(c&&ls(o,c.database,t)&&Ku(o,c.index,r)&&Xu(o,c.metadata,e.metadataPath))return{identity:i};throw new Error(`SQLite generation ${i} already exists with different or corrupt artifacts.`)}ts(e.generationRoot,{recursive:!0}),Uu(e.generationRoot);let a=`${o}.${process.pid}.${Date.now()}.tmp`;sr(a,{recursive:!0,force:!0}),ts(a,{recursive:!0});try{Dn(e.databasePath,y(a,t.file)),r&&e.indexPath&&Dn(e.indexPath,y(a,r.file)),n&&e.metadataPath&&Dn(e.metadataPath,y(a,n.file)),Y(y(a,Yt),{version:mn,identity:i,database:t,...r?{index:r}:{},...n?{metadata:n}:{}},{spacing:2,trailingNewline:!0}),On(a,o),Mi(e.generationRoot)}finally{sr(a,{recursive:!0,force:!0})}return{identity:i}}function zu(e,t,r){let n=Ln("sha256").update("sqlite-generation-artifacts-v1\0");return n.update(e.sha256),t&&n.update(`\0${t.sha256}`),r&&n.update(`\0${me(g(r,"reindex metadata"))}`),n.digest("hex")}function An(e){return{file:ss(e),size:ar(e).size,sha256:cr(e)}}function cr(e){let t=Ln("sha256"),r=os(e,"r"),n=Buffer.allocUnsafe(1024*1024);try{for(;;){let i=Ju(r,n);if(i===0)break;t.update(n.subarray(0,i))}}finally{is(r)}return t.digest("hex")}function Ju(e,t){let r=0;for(;r<t.length;){let n=Bu(e,t,r,t.length-r,null);if(r+=n,n===0)break}return r}function Dn(e,t){Mu(e,t,ju.COPYFILE_FICLONE);let r=os(t,"r");try{Gu(r)}finally{is(r)}Lu(t,292)}function ls(e,t,r){let n=y(e,t.file);return t.file===r.file&&t.size===r.size&&t.sha256===r.sha256&&x(n)&&ar(n).size===t.size&&cr(n)===t.sha256}function Ku(e,t,r){return!t||!r?t===r:ls(e,t,r)}function Xu(e,t,r){if(!t||!r)return t===void 0&&r===void 0;let n=y(e,t.file);return x(n)&&me(g(n,"stored reindex metadata"))===me(g(r,"candidate reindex metadata"))}function Fn(e,t){sr(`${t}.tmp-replace`,{force:!0}),On(e,`${t}.tmp-replace`),On(`${t}.tmp-replace`,t)}import{createHash as hs,randomUUID as nd}from"crypto";import{constants as id,copyFileSync as fs,existsSync as he,lstatSync as od,mkdirSync as Se,mkdtempSync as Ss,readdirSync as sd,realpathSync as ad,renameSync as Ne,rmSync as ye,statSync as pr}from"fs";import{dirname as dr,join as f,resolve as qn}from"path";import{setTimeout as cd}from"timers/promises";import{pathToFileURL as ms}from"url";import{deserializeSCIP as xs}from"@c4312/scip";import ld from"better-sqlite3";import{lstatSync as Yu,readdirSync as Qu}from"fs";import{join as Zu,relative as ed,resolve as Bn,sep as td}from"path";var St=1,$n="language-indexes",us=["index.db","index.scip","meta.json"],ds=[$n,ft,yt];function lr(e){let t=[];for(let r of us)rd(e,r),t.push(r);for(let r of ds)ps(e,r,t);return{version:St,files:t.sort()}}function ur(e){if(!e||e.includes("\0")||e.startsWith("/")||e.includes("\\"))throw new Error(`invalid index artifact path: ${e||"<empty>"}`);let t=e.split("/");if(t.some(n=>!n||n==="."||n===".."))throw new Error(`invalid index artifact path: ${e}`);let r=t[0];if(!us.includes(e)&&!ds.includes(r))throw new Error(`index artifact path is not shareable: ${e}`);return e}function te(e,t){let r=ur(t),n=Bn(e),i=Bn(n,...r.split("/"));if(i!==n&&!i.startsWith(`${n}${td}`))throw new Error(`index artifact escapes cache: ${t}`);return i}function ps(e,t,r){let n=Zu(e,t),i;try{i=Qu(n,{withFileTypes:!0,encoding:"utf8"})}catch{return}for(let o of i){let s=`${t}/${o.name}`;if(o.isSymbolicLink())throw new Error(`index artifact cannot be a symlink: ${s}`);o.isDirectory()?ps(e,s,r):o.isFile()&&r.push(ur(s))}}function rd(e,t){let r=te(e,t),n;try{n=Yu(r)}catch{throw new Error(`required index artifact is missing: ${t}`)}if(!n.isFile()||n.isSymbolicLink())throw new Error(`required index artifact is not a regular file: ${t}`);if(ed(Bn(e),r).startsWith(".."))throw new Error(`index artifact escapes cache: ${t}`)}var Vn=1,gs="SCIP_QUERY_SHARED_CACHE",Wn=JSON.stringify({cliVersion:Mt,artifactCatalogVersion:St,sqliteGenerationStoreVersion:Ce,typescriptFragmentStoreVersion:nr,typescriptOverlayStoreVersion:or}),bs="manifest.json",ud="shared-cache.json",Un=[$n,ft,yt];function tS(e,t){if(!e.clean||!e.treeOid)return;let r=Rs(JSON.stringify({version:Vn,repositoryId:e.repositoryId,treeOid:e.treeOid,fingerprint:t,producerIdentity:Wn}));return{repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,fingerprint:t,producerIdentity:Wn,generationId:r,repositoryCacheDir:Xr(e.repositoryId)}}function rS(e,t,r){if(process.env[gs]==="0")return`${gs}=0`;if(!Yr(r))return"explicit cache or database override";if(Zr(dr(t))!==Zr(Kr(e))||t!==f(dr(t),"index.db"))return"index database is outside the managed worktree cache"}function nS(e,t,r){if(!Yr(t))return;let n=r??go(e);return n?f(Xr(n.repositoryId),"evidence.db"):void 0}function bt(e,t=!0){let r=Hn(e),n;try{n=fd(X(f(r,bs),{inputKind:"shared-generation manifest",maxBytes:K}))}catch{return null}if(n.generationId!==e.generationId||n.repositoryId!==e.repositoryId||n.treeOid!==e.treeOid||n.producerIdentity!==e.producerIdentity||JSON.stringify(n.fingerprint)!==JSON.stringify(e.fingerprint))return null;if(!t)return n;try{for(let i of n.artifacts){let o=te(r,i.path),s=pr(o);if(!s.isFile()||s.size!==i.size||Ft(o,{inputKind:"shared-generation artifact",maxBytes:F})!==i.sha256)return null}}catch{return null}return n}function iS(e){let t=bt(e.snapshot);if(t)return t;if(!Es(e.sourceCacheDir,e.sourceProjectRoot,e.snapshot.fingerprint))throw new Error("source index is incomplete, incompatible, or corrupt");let r=ys(e.sourceCacheDir);if(!r)throw new Error("source index artifacts are incomplete");let n=lr(e.sourceCacheDir),i=f(e.snapshot.repositoryCacheDir,"generations");Se(i,{recursive:!0});let o=Ss(f(i,`.tmp-${process.pid}-`));try{let s=[];for(let d of n.files){let p=te(e.sourceCacheDir,d),m=te(o,d);It(p,m);let h=pr(m).size;s.push({path:d,size:h,sha256:Ft(m,{inputKind:"staged shared-generation artifact",maxBytes:F})})}let a=xs(v(f(o,"index.scip"),{inputKind:"staged shared SCIP index",maxBytes:F})).metadata?.projectRoot;if(!a)throw new Error("shared SCIP generation has no project root metadata");let c=zn(e.sourceProjectRoot);if(a!==c)throw new Error("shared SCIP generation root does not match its source worktree");if(ys(e.sourceCacheDir)!==r||e.sourceStillValid&&!e.sourceStillValid())throw new Error("source index changed while staging a shared generation");let l={version:Vn,artifactCatalogVersion:St,generationId:e.snapshot.generationId,repositoryId:e.snapshot.repositoryId,treeOid:e.snapshot.treeOid,fingerprint:e.snapshot.fingerprint,producerIdentity:e.snapshot.producerIdentity,sourceProjectRoot:e.sourceProjectRoot,scipProjectRoot:a,createdAt:(e.now??(()=>new Date))().toISOString(),artifacts:s.sort((d,p)=>d.path.localeCompare(p.path))};Y(f(o,bs),l,{spacing:2,trailingNewline:!0});let u=Hn(e.snapshot);try{if(he(u)&&!bt(e.snapshot)){let d=`${u}.corrupt-${process.pid}-${Date.now()}`;Ne(u,d),ye(d,{recursive:!0,force:!0})}Ne(o,u)}catch(d){let p=bt(e.snapshot);if(p)return p;throw d}return l}finally{ye(o,{recursive:!0,force:!0})}}function oS(e){let t=Hn(e.snapshot);Se(e.targetCacheDir,{recursive:!0});let r=ln(f(e.targetCacheDir,"cache-lifecycle.lock"),{waitMs:3e4});if(!r)throw new Error("timed out waiting for another cache hydration");let n,i,o=!1;try{n=Ss(f(e.targetCacheDir,".shared-hydrate-")),bd(e.manifest,e.snapshot);for(let c of e.manifest.artifacts){let l=te(t,c.path),u=te(n,c.path);if(It(l,u),pr(u).size!==c.size||Ft(u,{inputKind:"hydrated shared-generation artifact",maxBytes:F})!==c.sha256)throw new Error(`shared artifact is corrupt: ${c.path}`)}let s=zn(e.targetProjectRoot);if(s!==e.manifest.scipProjectRoot)for(let c of e.manifest.artifacts)c.path.endsWith(".scip")&&Oo(te(n,c.path),e.manifest.scipProjectRoot,s);if(!Es(n,e.targetProjectRoot,e.snapshot.fingerprint,!1))throw new Error("staged shared generation failed completeness or integrity validation");i=hd(e.targetCacheDir,n),o=!0,Sd(n,e.targetCacheDir,i),as({tempOutputScip:f(n,"index.scip"),tempOutputDb:f(n,"index.db"),tempMetaPath:f(n,"meta.json"),outputScip:f(e.targetCacheDir,"index.scip"),outputDb:f(e.targetCacheDir,"index.db"),metaPath:f(e.targetCacheDir,"meta.json"),now:e.now});let a=Mn(f(e.targetCacheDir,"index.db"),f(e.targetCacheDir,"meta.json"));if(a.state==="invalid"||a.state==="drifted")throw new Error(`hydrated SQLite generation failed validation: ${a.reason}`);dd(e.snapshot,e.targetCacheDir,e.action??"attached",e.now)}catch(s){throw o&&i&&xd(e.targetCacheDir,i),s}finally{n&&ye(n,{recursive:!0,force:!0}),r.release()}}async function sS(e,t={}){let r=t.timeoutMs??3e4,n=t.pollMs??100,i=t.now??Ve,o=i()+r,s=f(e.repositoryCacheDir,"locks"),a=f(s,`${e.generationId}.lock`),c=l=>{if(!l||typeof l!="object"||Array.isArray(l))return null;let u=l.pid;return typeof u=="number"&&Number.isSafeInteger(u)&&u>0?{pid:u}:null};for(;i()<=o;){if(bt(e))return{kind:"generation-ready"};let l=He(a,{kind:"shared-generation-build",detail:{generationId:e.generationId},parseLegacy:c});if(l.kind==="acquired")return{kind:"owner",release:()=>l.lock.release()};let u=o-i();if(u<=0)break;await cd(Math.min(n,u))}return bt(e)?{kind:"generation-ready"}:{kind:"timeout"}}function dd(e,t,r,n=void 0){let i={version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,localCacheDir:t,baseGenerationId:e.generationId,activeGenerationId:e.generationId,lastAction:r,lastSeenAt:(n??(()=>new Date))().toISOString()},o={...i,ownershipChecksum:pd(i)};return yd(e.repositoryCacheDir,o,!0),o}function pd(e){return Rs(JSON.stringify({version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:qn(e.projectRoot),localCacheDir:qn(e.localCacheDir)}))}function fd(e){let t=JSON.parse(e);if(t.version!==Vn||t.artifactCatalogVersion!==St||typeof t.generationId!="string"||!/^[a-f0-9]{64}$/.test(t.generationId)||typeof t.repositoryId!="string"||!/^[a-f0-9]{24}$/.test(t.repositoryId)||typeof t.treeOid!="string"||!t.treeOid||typeof t.producerIdentity!="string"||t.producerIdentity!==Wn||typeof t.sourceProjectRoot!="string"||typeof t.scipProjectRoot!="string"||typeof t.createdAt!="string"||!Number.isFinite(Date.parse(t.createdAt))||!t.fingerprint||!Array.isArray(t.artifacts))throw new Error("invalid shared generation manifest");let r=new Set;for(let n of t.artifacts){if(!n||typeof n.path!="string"||typeof n.size!="number"||n.size<0||typeof n.sha256!="string"||!/^[a-f0-9]{64}$/.test(n.sha256))throw new Error("invalid shared generation artifact");if(ur(n.path),r.has(n.path))throw new Error(`duplicate shared generation artifact: ${n.path}`);r.add(n.path)}for(let n of["index.db","index.scip","meta.json"])if(!r.has(n))throw new Error(`shared generation is missing ${n}`);return t}function It(e,t){Se(dr(t),{recursive:!0});try{fs(e,t,id.COPYFILE_FICLONE)}catch{fs(e,t)}}function md(e,t,r){Se(e,{recursive:!0}),Y(f(e,ud),{version:1,repositoryId:t,worktreeId:r},{spacing:2,trailingNewline:!0})}function ys(e){try{let t=lr(e),r=hs("sha256");for(let n of t.files){let i=te(e,n),o=pr(i).size;r.update(n).update("\0").update(String(o)).update("\0"),Ni(i,{inputKind:"source-generation artifact",maxBytes:F},s=>r.update(s)),r.update("\0")}return r.digest("hex")}catch{return null}}function gd(e){try{let t=pe(X(f(e,"meta.json"),{inputKind:"reindex metadata",maxBytes:K}));return(t.kind==="legacy"||t.kind==="supported")&&t.capabilities.publishableGeneration?t.metadata:void 0}catch{return}}function Hn(e){return f(e.repositoryCacheDir,"generations",e.generationId)}function yd(e,t,r){let n=ho(e,{waitMs:5e3});if(!n)throw new Error("repository cache cleanup is busy");try{if(r){let o=t.activeGenerationId;if(!o||!he(f(e,"generations",o)))throw new Error("shared generation disappeared before its lease was attached")}let i=f(e,"worktrees");Se(i,{recursive:!0}),Y(f(i,`${t.worktreeId}.json`),t,{spacing:2,trailingNewline:!0}),md(t.localCacheDir,t.repositoryId,t.worktreeId)}finally{n.release()}}function hd(e,t){let r=f(t,".rollback"),n=new Map,i=new Map;Se(r,{recursive:!0});for(let a of["index.scip","index.db","meta.json"]){let c=f(e,a),l=he(c);n.set(a,l),l&&It(c,f(r,"stable",a))}for(let a of Un){let c=f(e,a),l=he(c);if(l){let u=od(c);if(!u.isDirectory()||u.isSymbolicLink())throw new Error(`managed artifact path is not a directory: ${a}`)}i.set(a,l)}let o=f(e,ct),s=he(o);return s&&Is(o,f(r,"sqlite-generations")),{root:r,stableFiles:n,managedDirectories:i,generationStoreExisted:s}}function Sd(e,t,r){for(let n of Un){let i=f(t,n);if(r.managedDirectories.get(n)){let s=f(r.root,"managed",n);Se(dr(s),{recursive:!0}),Ne(i,s)}let o=f(e,n);he(o)&&Ne(o,i)}}function xd(e,t){for(let i of Un){let o=f(e,i),s=f(t.root,"managed",i);t.managedDirectories.get(i)?he(s)&&(ye(o,{recursive:!0,force:!0}),Ne(s,o)):ye(o,{recursive:!0,force:!0})}for(let[i,o]of t.stableFiles){let s=f(e,i);if(!o){ye(s,{force:!0});continue}let a=`${s}.shared-restore-${nd()}`;It(f(t.root,"stable",i),a),ye(s,{force:!0}),Ne(a,s)}let r=f(e,ct);ye(r,{recursive:!0,force:!0});let n=f(t.root,"sqlite-generations");t.generationStoreExisted&&he(n)&&Ne(n,r)}function Is(e,t){Se(t,{recursive:!0});for(let r of sd(e,{withFileTypes:!0})){let n=f(e,r.name),i=f(t,r.name);if(r.isSymbolicLink())throw new Error(`managed cache backup cannot contain a symlink: ${n}`);r.isDirectory()?Is(n,i):r.isFile()&&It(n,i)}}function bd(e,t){if(e.generationId!==t.generationId||e.repositoryId!==t.repositoryId||e.treeOid!==t.treeOid||e.producerIdentity!==t.producerIdentity||JSON.stringify(e.fingerprint)!==JSON.stringify(t.fingerprint))throw new Error("shared generation manifest does not match the requested snapshot")}function Es(e,t,r,n=!0,i=!0){try{let o=gd(e);if(!o||JSON.stringify(o.fingerprint)!==JSON.stringify(r)||JSON.stringify([...o.indexedLanguages??[]].sort())!==JSON.stringify([...r.languages].sort()))return xt("source validation rejected metadata"),!1;let s=lr(e),a=Mn(f(e,"index.db"),f(e,"meta.json"));if(n?a.state!=="current":a.state==="invalid"||a.state==="drifted")return xt(`source validation rejected SQLite generation state ${a.state}`),!1;let c=new ld(f(e,"index.db"),{readonly:!0,fileMustExist:!0});try{if(i){if(c.pragma("quick_check(1)",{simple:!0})!=="ok")return!1}else c.pragma("schema_version",{simple:!0})}finally{c.close()}let l=zn(t),d=(i?s.files.filter(p=>p.endsWith(".scip")):["index.scip"]).every(p=>{let m=xs(v(te(e,p),{inputKind:"shared SCIP validation artifact",maxBytes:F})).metadata?.projectRoot;return m!==l&&xt(`source validation rejected SCIP root for ${p}: ${String(m)}`),m===l});return d||xt("source validation rejected SCIP project roots"),d}catch(o){return xt(`source validation failed: ${o instanceof Error?o.message:String(o)}`),!1}}function xt(e){process.env.SCIP_QUERY_DEBUG&&console.error(`shared-cache: ${e}`)}function zn(e){try{return ms(ad(e)).href}catch{return ms(qn(e)).href}}function Rs(e){return hs("sha256").update(e).digest("hex")}import{createRequire as Id}from"module";import{dirname as Yn,isAbsolute as Ed,relative as Cs,resolve as be,sep as Jn}from"path";var xe=Id(import.meta.url),Rd=1,vs="0.4.0";function vd(){try{let e=Ps();if(!e.available)return e;let{packageRoot:t}=e,r=xe.resolve("typescript",{paths:[t]}),n=xe(r),{FileIndexer:i}=xe(be(t,"dist/src/FileIndexer.js")),{Input:o}=xe(be(t,"dist/src/Input.js")),{Packages:s}=xe(be(t,"dist/src/Packages.js")),a=xe(be(t,"dist/src/scip.js"));if(!i||!o||!s||!a.scip?.Document||!a.scip.Index)return{available:!1,reason:"scip-typescript document runtime has an unsupported module shape"};let c={packageVersion:e.packageVersion,typescript:n,Document:a.scip.Document,Index:a.scip.Index,FileIndexer:i,Input:o,Packages:s};return{available:!0,runtime:c,producerIdentity:Qn(c)}}catch(e){return{available:!1,reason:`scip-typescript document runtime unavailable: ${e instanceof Error?e.message:String(e)}`}}}function dS(){let e=Ps();return e.available?{available:!0,packageVersion:e.packageVersion,typescriptVersion:e.typescriptVersion,producerIdentity:e.producerIdentity}:e}function Ps(){try{let e=xe.resolve("@sourcegraph/scip-typescript/package.json"),t=JSON.parse(g(e,"scip-typescript package manifest"));if(t.version!==vs)return{available:!1,reason:`unsupported scip-typescript version ${String(t.version??"unknown")}; expected ${vs}`};let r=Yn(e),n=xe.resolve("typescript/package.json",{paths:[r]}),i=JSON.parse(g(n,"TypeScript package manifest"));return typeof i.version!="string"||!i.version?{available:!1,reason:"scip-typescript TypeScript compiler version is unavailable"}:{available:!0,packageRoot:r,packageVersion:t.version,typescriptVersion:i.version,producerIdentity:ks(t.version,i.version)}}catch(e){return{available:!1,reason:`scip-typescript document producer unavailable: ${e instanceof Error?e.message:String(e)}`}}}function pS(e){let t=e.runtime===void 0?vd():e.runtime===null?{available:!1,reason:"scip-typescript document runtime unavailable"}:{available:!0,runtime:e.runtime,producerIdentity:Qn(e.runtime)};return t.available?{available:!0,emitter:new Kn(e,t.runtime)}:t}var Kn=class{producerIdentity;workspaceRoot;tsconfigPath;projectRoot;maxFileByteSize;runtime;host;config=null;includedFiles=new Set;program=null;checker=null;symbolTable=new Map;constructorTable=new Map;packages;fragments=new Map;stats={initializations:0,programUpdates:0,documentsEmitted:0,documentsRemoved:0,sourceNodesReused:0,sourceNodesReplaced:0,symbolEntriesPruned:0};constructor(t,r){this.workspaceRoot=be(t.workspaceRoot),this.tsconfigPath=be(this.workspaceRoot,t.tsconfigPath),this.projectRoot=t.projectRoot??wd(this.workspaceRoot,Yn(this.tsconfigPath)),this.maxFileByteSize=t.maxFileByteSize??1024*1024,this.runtime=r,this.producerIdentity=Qn(r);let n=Ts(r.typescript,this.tsconfigPath);this.config=n,this.host=new Xn(r.typescript,n.options,this.workspaceRoot),this.packages=new r.Packages(this.projectRoot)}initialize(){let t=performance.now(),r=this.config??Ts(this.runtime.typescript,this.tsconfigPath);this.includedFiles=new Set(r.fileNames.map(Ze)),this.program=this.runtime.typescript.createProgram(r.fileNames,r.options,this.host.compilerHost),this.checker=this.program.getTypeChecker(),this.stats.initializations+=1;let n=[];for(let i of this.program.getSourceFiles())this.includedFiles.has(Ze(i.fileName))&&n.push(this.emitSourceFile(i));return this.result(n,t)}advance(t){if(!this.program||!this.checker||!this.config)return this.initializeAndAdvance(t);let r=performance.now(),n=fr(t.modifiedFiles),i=fr(t.affectedFiles);this.validateIncrementalPaths(n,i);let o=this.program,s=new Map;for(let c of n){let l=Et(this.workspaceRoot,c),u=o.getSourceFile(l);if(!u)throw new Error(`modified TypeScript source is unavailable: ${c}`);s.set(c,u),this.stats.symbolEntriesPruned+=ws(this.symbolTable,u),this.stats.symbolEntriesPruned+=ws(this.constructorTable,u),this.host.invalidate(l)}this.program=this.runtime.typescript.createProgram(this.config.fileNames,this.config.options,this.host.compilerHost,o),this.checker=this.program.getTypeChecker(),this.stats.programUpdates+=1;for(let[c,l]of s)this.program.getSourceFile(Et(this.workspaceRoot,c))===l?this.stats.sourceNodesReused+=1:this.stats.sourceNodesReplaced+=1;let a=i.map(c=>{let l=Et(this.workspaceRoot,c),u=this.program.getSourceFile(l);if(!u)throw new Error(`affected TypeScript source is unavailable: ${c}`);return this.emitSourceFile(u)});return this.result(a,r)}fragment(t){return this.fragments.get(mr(t))??null}snapshotStats(){return{...this.stats}}initializeAndAdvance(t){let r=this.initialize(),n=fr(t.modifiedFiles),i=fr(t.affectedFiles);this.validateIncrementalPaths(n,i);let o=new Set(i);return{...r,fragments:r.fragments.filter(s=>o.has(s.relativePath))}}validateIncrementalPaths(t,r){if(t.length===0)throw new Error("incremental TypeScript document update requires a modified file");if(r.length===0)throw new Error("incremental TypeScript document update requires an affected file");for(let n of t){let i=Et(this.workspaceRoot,n);if(!this.includedFiles.has(Ze(i)))throw new Error(`modified TypeScript file is outside the configured project: ${n}`)}for(let n of r){let i=Et(this.workspaceRoot,n);if(!this.includedFiles.has(Ze(i)))throw new Error(`affected TypeScript file is outside the configured project: ${n}`)}}emitSourceFile(t){if(!this.checker)throw new Error("TypeScript document emitter is not initialized");let r=mr(Cs(this.workspaceRoot,t.fileName)),n=new this.runtime.Document({relative_path:r,occurrences:[]});if(new this.runtime.FileIndexer(this.checker,{cwd:this.workspaceRoot,projectRoot:this.projectRoot,projectDisplayName:this.projectRoot,maxFileByteSizeNumber:this.maxFileByteSize},new this.runtime.Input(t.fileName,t.getText()),n,this.symbolTable,this.constructorTable,this.packages,t).index(),this.stats.documentsEmitted+=1,n.occurrences.length===0)return this.fragments.delete(r),this.stats.documentsRemoved+=1,{relativePath:r,bytes:null,occurrences:0,symbols:n.symbols.length,referenceFragments:[]};let o=n.serializeBinary();return this.fragments.set(r,o),{relativePath:r,bytes:o,occurrences:n.occurrences.length,symbols:n.symbols.length,referenceFragments:Td(r,n)}}result(t,r){return{producerIdentity:this.producerIdentity,fragments:t,durationMs:performance.now()-r,stats:this.snapshotStats()}}};function Td(e,t){let r=new Map;for(let n of t.occurrences){if(!n.symbol||(n.symbol_roles&1)!==0||n.range.length<3)continue;let i=n.range[0],o=n.range[1];if(!Number.isInteger(i)||!Number.isInteger(o))continue;let s={targetSymbol:n.symbol,location:{file:e,line:i,column:o}};r.set(`${n.symbol}\0${i}\0${o}`,s)}return[...r.values()].sort((n,i)=>n.targetSymbol.localeCompare(i.targetSymbol)||n.location.line-i.location.line||n.location.column-i.location.column)}var Xn=class{compilerHost;sourceFiles=new Map;constructor(t,r,n){let i=t.createCompilerHost(r),o=i.getSourceFile.bind(i);this.compilerHost={...i,getCurrentDirectory:()=>n,getSourceFile:(s,a,c,l)=>{let u=Ze(s);if(this.sourceFiles.has(u))return this.sourceFiles.get(u);let d=o(s,a,c,l);return this.sourceFiles.set(u,d),d}}}invalidate(t){this.sourceFiles.delete(Ze(t))}};function Ts(e,t){let r=e.readConfigFile(t,e.sys.readFile);if(r.error)throw new Error(e.formatDiagnostics([r.error],e.createCompilerHost({})));let n=e.parseJsonConfigFileContent(r.config,e.sys,Yn(t)),i=n.errors.filter(o=>o.code!==18003);if(i.length>0)throw new Error(e.formatDiagnostics(i,e.createCompilerHost({})));return n}function Qn(e){return ks(e.packageVersion,e.typescript.version)}function ks(e,t){return`scip-typescript:${e}:typescript:${t}:document-adapter:${Rd}`}function wd(e,t){return mr(Cs(e,t))||"."}function Et(e,t){if(Ed(t))throw new Error(`expected a project-relative path: ${t}`);let r=be(e,t),n=e.endsWith(Jn)?e:`${e}${Jn}`;if(r!==e&&!r.startsWith(n))throw new Error(`path escapes the project root: ${t}`);return r}function fr(e){return[...new Set(e.map(mr))].sort()}function mr(e){return e.split(Jn).join("/").replace(/^\.\//,"")}function Ze(e){return be(e)}function ws(e,t){let r=0;for(let n of e.keys())if(Cd(n)){try{if(n.getSourceFile()!==t)continue}catch{continue}e.delete(n),r+=1}return r}function Cd(e){return!!(e&&typeof e=="object"&&"kind"in e&&"getSourceFile"in e)}import{spawn as Pd}from"child_process";import{performance as Ns}from"perf_hooks";var hS={probe:1e4,git:3e4,analysis:18e4,install:3e5,indexer:6e5},Rt=class extends Error{constructor(r,n,i,o={}){super(i,o.cause===void 0?void 0:{cause:o.cause});this.kind=r;this.label=n;this.name="BoundedProcessError",this.timedOut=o.timedOut??!1,this.reaped=o.reaped??!1,this.stdout=o.stdout??"",this.stderr=o.stderr??"",this.stdoutTruncated=o.stdoutTruncated??!1,this.stderrTruncated=o.stderrTruncated??!1}kind;label;timedOut;reaped;stdout;stderr;stdoutTruncated;stderrTruncated};function gr(e,t){if(!Number.isFinite(e)||e<=0)throw new TypeError(`${t} must be a positive finite number.`)}function _s(e,t,r,n){let i=Math.max(0,n-r);i>0&&e.push(t.subarray(0,i))}function As(e,t,r){let n=Buffer.concat([...e,t]);e.length=0,e.push(n.subarray(Math.max(0,n.length-r)))}function kd(e,t){if(e.exitCode!==null||e.signalCode!==null||e.pid===void 0)return!1;if(!t)return!0;let r=Wr(e.pid);return r!==null&&Fi(t,r)}function SS(e){gr(e.timeoutMs,"timeoutMs"),gr(e.maxStdoutBytes,"maxStdoutBytes"),gr(e.maxStderrBytes,"maxStderrBytes");let t=e.terminationGraceMs??1e3;return gr(t,"terminationGraceMs"),new Promise((r,n)=>{let i=Ns.now(),o;try{o=Pd(e.command,[...e.args??[]],{cwd:e.cwd,env:e.env,detached:e.detached,stdio:["pipe","pipe","pipe"]})}catch(b){n(new Rt("spawn",e.label,`${e.label} could not start.`,{cause:b,reaped:!0}));return}let s=[],a=[],c=0,l=0,u=!1,d=!1,p=null,m=!1,h=null,ue=o.pid===void 0?null:Wr(o.pid),B=b=>{p||m||(p=b,o.kill("SIGTERM"),h=setTimeout(()=>{!m&&kd(o,ue)&&o.kill("SIGKILL")},t),h.unref())},ot=setTimeout(()=>{B({kind:"timeout",timedOut:!0,message:`${e.label} timed out after ${e.timeoutMs}ms.`})},e.timeoutMs);ot.unref();let $e=()=>{B({kind:"aborted",timedOut:!1,message:`${e.label} was cancelled.`})};e.signal?.addEventListener("abort",$e,{once:!0}),e.signal?.aborted&&$e(),o.stdout.on("data",b=>{let ne=Buffer.isBuffer(b)?b:Buffer.from(b);e.outputLimitBehavior==="truncate-tail"?As(s,ne,e.maxStdoutBytes):_s(s,ne,c,e.maxStdoutBytes),c+=ne.length,c>e.maxStdoutBytes&&(u=!0,e.outputLimitBehavior!=="truncate-tail"&&B({kind:"stdout-limit",timedOut:!1,message:`${e.label} exceeded stdout limit (${e.maxStdoutBytes} bytes).`}))}),o.stderr.on("data",b=>{let ne=Buffer.isBuffer(b)?b:Buffer.from(b);e.outputLimitBehavior==="truncate-tail"?As(a,ne,e.maxStderrBytes):_s(a,ne,l,e.maxStderrBytes),l+=ne.length,l>e.maxStderrBytes&&(d=!0,e.outputLimitBehavior!=="truncate-tail"&&B({kind:"stderr-limit",timedOut:!1,message:`${e.label} exceeded stderr limit (${e.maxStderrBytes} bytes).`}))}),o.on("error",b=>{if(!m&&!p){if(o.pid===void 0){clearTimeout(ot),h&&clearTimeout(h),e.signal?.removeEventListener("abort",$e),m=!0,n(new Rt("spawn",e.label,`${e.label} could not start: ${b.message}`,{cause:b,reaped:!0}));return}B({kind:"spawn",timedOut:!1,message:`${e.label} failed after start: ${b.message}`})}}),o.on("close",(b,ne)=>{if(m)return;m=!0,clearTimeout(ot),h&&clearTimeout(h),e.signal?.removeEventListener("abort",$e);let Pi=Buffer.concat(s).toString("utf8"),ki=Buffer.concat(a).toString("utf8");if(p){n(new Rt(p.kind,e.label,p.message,{timedOut:p.timedOut,reaped:!0,stdout:Pi,stderr:ki,stdoutTruncated:u,stderrTruncated:d}));return}r({status:b,signal:ne,stdout:Pi,stderr:ki,timedOut:!1,durationMs:Ns.now()-i,stdoutTruncated:u,stderrTruncated:d})}),e.input===void 0?o.stdin.end():o.stdin.end(e.input)})}var Nd=[_("source-facts",{dependsOn:["content-hash","tool-version"],keyParts:["kind","relativePath","contentHash","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/source/source-facts.ts"}),_("file-definitions",{dependsOn:["content-hash","project-fingerprint","indexed-language-set","tool-version"],keyParts:["kind","relativePath","contentHash","projectFingerprint","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/symbols/definition-catalog.ts"}),_("definition-exclusions",{dependsOn:["content-hash","tool-version"],keyParts:["kind","relativePath","contentHash","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/analysis/framework-patterns.ts"}),_("doc-path-tokens",{dependsOn:["content-hash","tool-version"],keyParts:["kind","relativePath","contentHash","payloadVersion"],stalenessTest:"tests/storage/evidence-products.test.ts",owner:"tests/storage/evidence-cache.test.ts"}),_("doc-path-evidence",{dependsOn:["content-hash","git-history","git-head","tool-version"],keyParts:["kind","relativePath","contentHash","trackedFiles","historyWindow","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/queries/cleanup/doc-drift.ts"}),_("source-imports",{dependsOn:["content-hash","import-resolution-fingerprint","config","tool-version"],keyParts:["kind","relativePath","contentHash","importResolutionFingerprint","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/language-parsers/index.ts"}),_("source-reexports",{dependsOn:["content-hash","import-resolution-fingerprint","config","tool-version"],keyParts:["kind","relativePath","contentHash","importResolutionFingerprint","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/language-parsers/index.ts"}),_("source-fingerprints",{dependsOn:["content-hash","project-fingerprint","indexed-language-set","tool-version"],keyParts:["kind","relativePath","contentHash","projectFingerprint","payloadVersion"],stalenessTest:"tests/symbols/definition-catalog.test.ts",owner:"src/queries/cleanup/similar.ts"}),_("consumer-file-usage",{dependsOn:["content-hash","project-fingerprint","indexed-language-set","tool-version"],keyParts:["kind","relativePath","contentHash","projectFingerprint","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/queries/internal/consumer-evidence.ts"}),_("react-component-behavior-profiles",{dependsOn:["content-hash","tool-version"],keyParts:["kind","relativePath","contentHash","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/source/react-profile.ts"}),_("git-file-adds",{dependsOn:["git-head","git-history","tool-version"],keyParts:["kind","cacheKey","head","historyWindow","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/analysis/git-history.ts"}),_("typescript-reference-fragments",{dependsOn:["content-hash","transitive-deps-digest","config","tool-version"],keyParts:["kind","relativePath","semanticIdentity","payloadVersion"],stalenessTest:"tests/semantic/typescript/typescript-reference-fragments.test.ts",owner:"src/semantic/typescript/reference-fragment-shadow.ts"}),_("typescript-import-usage",{dependsOn:["content-hash","transitive-deps-digest","config","tool-version"],keyParts:["kind","relativePath","semanticIdentity","payloadVersion"],stalenessTest:"tests/semantic/typescript/typescript-semantic-provider.test.ts",owner:"src/semantic/shared-primitives.ts"}),_("typescript-signatures",{dependsOn:["content-hash","transitive-deps-digest","config","tool-version"],keyParts:["kind","relativePath","semanticIdentity","payloadVersion"],stalenessTest:"tests/semantic/typescript/typescript-semantic-provider.test.ts",owner:"src/semantic/shared-primitives.ts"}),yr("file-dependency-graph",{dependsOn:["project-fingerprint","indexed-language-set","import-resolution-fingerprint","tool-version"],keyParts:["kind","scope","projectFingerprint","payloadVersion"],stalenessTest:"tests/symbols/file-dep-graph.test.ts",owner:"src/symbols/graph/file-dep-graph.ts"}),yr("semantic-import-usage",{dependsOn:["project-fingerprint","indexed-language-set","import-resolution-fingerprint","tool-version"],keyParts:["kind","relativePath","projectFingerprint","language","semanticEngine","payloadVersion"],stalenessTest:"tests/semantic/rust/rust-semantic-cache-gate.test.ts",owner:"src/semantic/shared-primitives.ts"}),yr("semantic-signatures",{dependsOn:["project-fingerprint","indexed-language-set","tool-version"],keyParts:["kind","relativePath","symbol","projectFingerprint","language","semanticEngine","payloadVersion"],stalenessTest:"tests/semantic/rust/rust-semantic-cache-gate.test.ts",owner:"src/semantic/shared-primitives.ts"}),yr("health-semantic-prewarm",{dependsOn:["project-fingerprint","indexed-language-set","tool-version"],keyParts:["kind","scope","cliVersion","projectFingerprint","payloadVersion"],stalenessTest:"tests/runtime/cli-support.test.ts",owner:"src/runtime/cli-support.ts"})];function vt(e){let t=new Map;return{kind:e.kind,read(r,n,i){let o=!1,s=0,a;if(Gr()){let c=Io(r);if(c){let l=`${c}\0${n}\0${i}`;a=t.get(l),a||(a=Br(["evidence-product-file-read-v1",e.kind,c,n,i]),t.set(l,a))}}return $r("evidence-product.file.read",()=>{let c=Eo(r,e.kind,n,i);if(c===null)return null;s=c.length;try{let l=e.deserialize(c);return o=l!==null,l}catch{return null}},()=>({...a?{workIdentity:a,workOutcome:"computed"}:{},scope:"file",kind:e.kind,available:!0,hit:o,payloadBytes:s}))},write(r,n,i,o){Ro(r,e.kind,n,i,e.serialize(o))},writeBatch(r,n){vo(r,n.map(i=>({kind:e.kind,relativePath:i.relativePath,contentHash:i.contentHash,payload:e.serialize(i.value)})))}}}function vS(e){let t=new Map;return{kind:e.kind,read(r,n,i){let o=!1,s=0,a;if(Gr()){let c=`${i}\0${n}`;a=t.get(c),a||(a=Br(["evidence-product-project-read-v1",e.kind,i,n]),t.set(c,a))}return $r("evidence-product.project.read",()=>{let c=To(r,e.kind,n,i);if(c===null)return null;s=c.length;try{let l=e.deserialize(c);return o=l!==null,l}catch{return null}},()=>({...a?{workIdentity:a,workOutcome:"computed"}:{},scope:"project",kind:e.kind,available:!0,hit:o,payloadBytes:s}))},write(r,n,i,o){wo(r,e.kind,n,i,e.serialize(o))}}}function Tt(e){let t=Nd.find(r=>r.kind===e);if(!t)throw new Error(`missing evidence product manifest entry for ${e}`);return t.invalidation}function _(e,t){return{scope:"file",kind:e,invalidation:{scope:"file",...t}}}function yr(e,t){return{scope:"project",kind:e,invalidation:{scope:"project",...t}}}var _d=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"];function wS(e){let t=e.toLowerCase();return _d.some(r=>t.endsWith(r))}import{createRequire as Ad}from"module";var Ds=Ad(import.meta.url),wt,hr;function Dd(){if(wt!==void 0)return wt;try{wt=Ds("ts-morph")}catch{wt=null}return wt}function kS(){if(hr)return hr;let e=Dd();if(!e)return"ts-morph:unavailable";let t="unknown";try{t=Ds("ts-morph/package.json").version??"unknown"}catch{}return hr=`ts-morph:${t}:typescript:${e.ts.version}`,hr}function NS(e,t){return t.map(r=>({tsconfigPath:r,project:new e.Project({tsConfigFilePath:r,skipFileDependencyResolution:!0})}))}function _S(e,t,r){return{language:"typescript",availability:()=>({available:!1,reason:e,tsconfigPath:t,tsconfigPaths:r}),importUsage:()=>[],referencesFor:()=>[],calleesFor:()=>[],signatureFor:()=>null}}function DS(e,t,r){let n=new Set(r),i=new Map(r.map(o=>[o,[]]));for(let o of e)for(let s of t.get(o.symbolId)??[])n.has(s.file)&&i.get(s.file).push({targetSymbol:o.symbol,location:s});for(let[o,s]of i)i.set(o,Fd(s));return i}function Fd(e){let t=new Map;for(let r of e){let{location:n}=r;t.set(`${r.targetSymbol}\0${n.file}\0${n.line}\0${n.column}`,r)}return[...t.values()].sort((r,n)=>r.targetSymbol.localeCompare(n.targetSymbol)||Od(r.location,n.location))}function Od(e,t){return e.file.localeCompare(t.file)||e.line-t.line||e.column-t.column}import{existsSync as ei,readdirSync as Ld,statSync as Md}from"fs";import{join as et,relative as jd}from"path";function Fs(e){let t=Gd(e)??Wd(e);if(!t||t.length===0)return[];let r=[],n=new Set;for(let i of t)for(let o of Vd(e,i)){if(n.has(o))continue;n.add(o);let s=Ud(e,o);s&&r.push(s)}return r}function Gd(e){let t=et(e,"pnpm-workspace.yaml");if(!ei(t))return null;try{return Bd(g(t,"pnpm workspace manifest"))}catch{return null}}function Bd(e){let t=[],r=!1;for(let n of e.split(/\r?\n/)){let i=$d(n);if(!r){/^packages\s*:\s*$/.test(i.trim())&&(r=!0);continue}let o=/^\s+-\s*(.+)$/.exec(i);if(o){let s=qd(o[1].trim());s&&t.push(s);continue}if(i.trim()!=="")break}return t}function $d(e){let t=e.indexOf("#");return t===-1?e:e.slice(0,t)}function qd(e){return e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'")?e.slice(1,-1):e}function Wd(e){let t=et(e,"package.json");if(!ei(t))return null;try{let r=JSON.parse(g(t,"workspace package manifest"));return r.workspaces?Array.isArray(r.workspaces)?r.workspaces:r.workspaces.packages??[]:null}catch{return null}}function Vd(e,t){if(!t||t.startsWith("!")||t.includes("node_modules"))return[];if(!t.includes("*")){let s=et(e,t);return Zn(s)?[s]:[]}let r=t.indexOf("*"),n=t.slice(0,r).replace(/\/$/,""),i=t.slice(r+1).replace(/^\//,""),o=et(e,n||".");return Zn(o)?Ld(o).map(s=>et(o,s,i)).filter(Zn):[]}function Zn(e){try{return Md(e).isDirectory()}catch{return!1}}function Ud(e,t){let r=et(t,"package.json");if(!ei(r))return null;try{let n=JSON.parse(g(r,"workspace package manifest"));return typeof n.name!="string"||n.name.length===0?null:{name:n.name,relativeDir:jd(e,t).replace(/\\/g,"/"),exports:n.exports}}catch{return null}}import{createRequire as Hd}from"module";import{existsSync as De}from"fs";import{basename as Os,dirname as L,extname as oe,join as q,relative as _e,resolve as T,sep as zd}from"path";var Jd=Lt("indexed-paths",{clearGroups:[]}),Kd=Lt("indexed-path-digest",{clearGroups:[]}),Xd=w("tsconfig-alias-config",{clearGroups:["whole-project"]}),Yd=w("tsconfig-alias-config-for-dir",{clearGroups:["whole-project"]}),Qd=Hd(import.meta.url),Ct;function Zd(){if(Ct!==void 0)return Ct;try{Ct=Qd("typescript")}catch{Ct=null}return Ct}var ep=["tsconfig.json","tsconfig.app.json","tsconfig.node.json","tsconfig.base.json"],tp=Lt("workspace-packages",{clearGroups:["whole-project"]}),Ae=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs",".vue"],Sr=[".py",".pyi"],M=[".java",".scala",".kt",".kts"],xr=[".rs"],br=[".rb"],Ir=[".c",".h",".cc",".cpp",".cxx",".hpp",".hh",".hxx"],Ie=[".cs",".vb"],Er=[".dart"],Fe=[".php"],tt=[".clj",".cljs",".cljc"],rp=new Set(Ae),ti=new Set(Sr),Ls=new Set(M),ri=new Set(xr),ni=new Set(br),Ms=new Set(Ir),js=new Set(Ie),ii=new Set(Er),Gs=new Set(Fe),Bs=new Set(tt),np=[{extensions:Ae,lookup:rp},{extensions:Sr,lookup:ti},{extensions:M,lookup:Ls},{extensions:xr,lookup:ri},{extensions:br,lookup:ni},{extensions:Ir,lookup:Ms},{extensions:Ie,lookup:js},{extensions:Er,lookup:ii},{extensions:Fe,lookup:Gs},{extensions:tt,lookup:Bs}];function se(e,t){return t.has(oe(e).toLowerCase())}function ip(e){return se(e,ti)}function op(e){return se(e,Ls)}function sp(e){return se(e,ri)}function ap(e){return se(e,ni)}function cp(e){return se(e,Ms)}function lp(e){return se(e,js)}function $s(e){return oe(e).toLowerCase()===".vb"}function up(e){return se(e,ii)}function dp(e){return se(e,Gs)}function pp(e){return se(e,Bs)}function oi(e){let t=oe(e).toLowerCase();for(let r of np)if(r.lookup.has(t))return r.extensions;return Ae}function fp(e){return op(e)||lp(e)||dp(e)}function Ee(e,t,r){return ip(t)?rt(e,t,r):sp(t)?ae(e,t,r):ap(t)?Rr(e,t,r):cp(t)?vr(e,t,r):fp(t)?E(e,r.replace(/\\/g,"."),oi(t)):up(t)?Tr(e,t,r):pp(t)?si(e,r):mp(e,t,r)}function mp(e,t,r){if(!r.startsWith(".")&&!r.startsWith("/"))return gp(e,t,r)??hp(e,r);let n=L(q(e.config.projectRoot,t)),i=T(n,r),o=ce(e);for(let s of ci(i)){let a=N(_e(e.config.projectRoot,s));if(o.has(a)||De(s))return a}return N(_e(e.config.projectRoot,i))}function gp(e,t,r){let n=Rp(e,t);if(!n)return null;let i=ce(e);for(let o of yp(n,r)){let s=T(n.baseUrl,o);for(let a of ci(s)){let c=N(_e(e.config.projectRoot,a));if(i.has(c)||De(a))return c}}return null}function yp(e,t){let r=[];for(let[n,i]of Object.entries(e.paths)){let o=n.indexOf("*");if(o===-1){if(t!==n)continue;r.push(...i);continue}let s=n.slice(0,o),a=n.slice(o+1);if(!t.startsWith(s)||!t.endsWith(a)||t.length<s.length+a.length)continue;let c=t.slice(s.length,t.length-a.length);for(let l of i)r.push(l.includes("*")?l.replace("*",c):l)}return r}function hp(e,t){let r=xp(Sp(e),t);if(!r)return null;let n=ce(e);for(let i of bp(r)){let o=T(e.config.projectRoot,r.pkg.relativeDir,i);for(let s of ci(o)){let a=N(_e(e.config.projectRoot,s));if(n.has(a)||De(s))return a}}return null}function Sp(e){return tp.get(e,()=>Fs(e.config.projectRoot))}function xp(e,t){let r=null;for(let n of e){let i=null;t===n.name?i="":t.startsWith(`${n.name}/`)&&(i=t.slice(n.name.length+1)),i!==null&&(!r||n.name.length>r.pkg.name.length)&&(r={pkg:n,subpath:i})}return r}function bp(e){let t=[],r=Ip(e.pkg.exports,e.subpath);if(r){let n=Ep(r);n&&t.push(n)}return t.push(e.subpath?`src/${e.subpath}`:"src/index"),t}function Ip(e,t){if(!e||typeof e!="object")return null;let r=t===""?".":`./${t}`;return qs(e[r])}function qs(e){if(typeof e=="string")return e;if(!e||typeof e!="object")return null;let t=e;for(let r of["types","import","default","require","node"]){let n=qs(t[r]);if(n)return n}return null}function Ep(e){let t=e.replace(/^\.\//,"");return t.startsWith("dist/")?`src/${t.slice(5)}`:null}function Rp(e,t){let r=N(L(t));return Yd.get(e,r,()=>vp(e,r))}function vp(e,t){let r=Zd();if(!r)return null;let n=T(e.config.projectRoot),i=T(n,t);for(;i===n||i.startsWith(n+zd);){for(let s of ep){let a=q(i,s);if(!De(a))continue;let c=Xd.get(e,a,()=>Tp(r,a));if(c)return c}let o=L(i);if(o===i)break;i=o}return null}function Tp(e,t){try{let r=e.readConfigFile(t,e.sys.readFile);if(r.error||!r.config)return null;let n=e.parseJsonConfigFileContent(r.config,e.sys,L(t)),i=n.options.paths;return!i||Object.keys(i).length===0?null:{baseUrl:n.options.baseUrl?T(L(t),n.options.baseUrl):L(t),paths:i}}catch{return null}}function rt(e,t,r){let n=ce(e),i;if(r.startsWith(".")){let o=r.match(/^(\.+)(.*)$/);if(!o)return null;let s=o[1].length,a=o[2].replace(/^\./,""),c=L(q(e.config.projectRoot,t));for(let l=1;l<s;l++)c=L(c);i=a?T(c,a.replace(/\./g,"/")):c}else i=T(e.config.projectRoot,r.replace(/\./g,"/"));for(let o of wp(i)){let s=N(_e(e.config.projectRoot,o));if(n.has(s)||De(o))return s}return null}function ae(e,t,r){if(!r)return null;let n=r.replace(/\s+as\s+.+$/,"").trim();if(!n.startsWith("crate::")&&!n.startsWith("self::")&&!n.startsWith("super::"))return null;let i=L(q(e.config.projectRoot,t)),o;return n.startsWith("crate::")?o=T(e.config.projectRoot,"src",n.slice(7).replace(/::/g,"/")):n.startsWith("self::")?o=T(i,n.slice(6).replace(/::/g,"/")):o=T(L(i),n.slice(7).replace(/::/g,"/")),ai(e,Cp(o))}function Rr(e,t,r){let n=L(q(e.config.projectRoot,t)),i=T(n,r);return ai(e,Pp(i))}function vr(e,t,r){let n=L(q(e.config.projectRoot,t)),i=[T(n,r),T(e.config.projectRoot,r),T(e.config.projectRoot,"include",r),T(e.config.projectRoot,"src",r)];return ai(e,i)}function E(e,t,r){let n=ce(e),i=t.replace(/\\/g,".").replace(/::/g,".").replace(/^global::/,""),o=i.replace(/\./g,"/"),s=i.split(".").pop()??i;for(let c of r){let l=`${o}${c}`,u=[...n].find(d=>d.endsWith(l));if(u)return u}for(let c of r){let l=[...n].find(u=>Os(u)===`${s}${c}`);if(l)return l}let a=[...n].filter(c=>r.includes(oe(c).toLowerCase())).filter(c=>c.includes(`/${o}/`)||c.includes(`/${s}/`)).sort((c,l)=>c.localeCompare(l));return a.length===1?a[0]:null}function Tr(e,t,r){let n=ce(e);if(r.startsWith("package:")){let s=r.slice(8),a=s.indexOf("/");if(a<0)return null;let c=s.slice(a+1),l=N(c.startsWith("lib/")?c:`lib/${c}`);return n.has(l)?l:null}let i=L(q(e.config.projectRoot,t)),o=T(i,r);for(let s of kp(o)){let a=N(_e(e.config.projectRoot,s));if(n.has(a)||De(s))return a}return null}function si(e,t){let r=t.replace(/-/g,"_").replace(/\./g,"/"),n=ce(e);for(let i of tt){let o=`${r}${i}`,s=[...n].find(a=>a.endsWith(o));if(s)return s}for(let i of tt){let o=[...n].find(s=>Os(s)===`${r.split("/").pop()}${i}`);if(o)return o}return null}function wp(e){let t=oe(e);return ti.has(t)?[e]:[`${e}.py`,`${e}.pyi`,q(e,"__init__.py"),q(e,"__init__.pyi")]}function ai(e,t){let r=ce(e);for(let n of t){let i=N(_e(e.config.projectRoot,n));if(r.has(i)||De(n))return i}return null}function Cp(e){let t=oe(e);return ri.has(t)?[e]:[`${e}.rs`,q(e,"mod.rs")]}function Pp(e){let t=oe(e);return ni.has(t)?[e]:[`${e}.rb`,q(e,"index.rb")]}function kp(e){let t=oe(e);return ii.has(t)?[e]:[`${e}.dart`,e]}function ci(e){let t=oe(e),r=new Set;if(t){r.add(e);for(let n of Ae)r.add(e.slice(0,-t.length)+n)}else for(let n of Ae)r.add(`${e}${n}`),r.add(q(e,`index${n}`));return[...r]}function ce(e){return Jd.get(e,()=>new Set(Bi(e,{includeIgnored:!1}).map(N)))}function li(e){return Kd.get(e,()=>tr([...ce(e)].sort().join(`
133
+ `)))}var Np=w("source-text",{clearGroups:["whole-project","source-file"]}),_p=w("source-lines",{clearGroups:["whole-project","source-file"]});function j(e,t){let r=t.replace(/\\/g,"/");return Np.get(e,r,()=>{try{return Oi(e.config.projectRoot,r,{inputKind:"indexed source file"})}catch(n){if(Li(n))return"";throw n}})}function XS(e,t){let r=t.replace(/\\/g,"/");return _p.get(e,r,()=>{let n=j(e,r);return n?n.split(`
134
+ `):[]})}import{basename as ma}from"path";function Oe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ap(e){return e.replace(/'''[\s\S]*?'''/g,Re).replace(/"""[\s\S]*?"""/g,Re).replace(/#.*$/gm,Re).replace(/\/\/.*$/gm,Re).replace(/\/\*[\s\S]*?\*\//g,Re).replace(/`(?:\\[\s\S]|[^`])*`/g,Re).replace(/'(?:\\.|[^'\\\r\n])*'/g,Re).replace(/"(?:\\.|[^"\\\r\n])*"/g,Re)}function Re(e){return e.replace(/[^\r\n]/g," ")}var rx=ze("stripped-lines",{clearGroups:["whole-project","source-file"]});ji({name:"stripped-source-singleton",groups:["whole-project","source-file"],clearAll:()=>{wr=null,Pt=""},clearFile:()=>{wr=null,Pt=""}});var wr=null,Pt="";function Dp(e){return wr===e||(wr=e,Pt=Ap(e)),Pt}function ve(e,t,r){let n=Dp(e);return`${n.slice(0,t)}${" ".repeat(r-t)}${n.slice(r)}`}function A(e,t){return new RegExp(`\\b${Oe(t)}\\b`,"m").test(e)}function nt(e,t){let r=new Set,n=new RegExp(`\\b${Oe(t)}\\s*\\.\\s*([A-Za-z_$][\\w$]*)`,"g");for(let i of e.matchAll(n)){let o=i[1];o&&r.add(o)}return[...r]}function ui(e){let t=0;for(let r of e)r==="("&&(t+=1),r===")"&&(t-=1);return t}import{extname as Ws}from"path";var Fp={".rs":"rust",".ts":"typescript",".mts":"typescript",".cts":"typescript",".tsx":"tsx",".js":"javascript",".jsx":"javascript",".mjs":"javascript",".cjs":"javascript",".py":"python",".pyi":"python",".java":"java",".kt":"kotlin",".kts":"kotlin",".scala":"scala",".sc":"scala",".rb":"ruby",".c":"c",".h":"c",".cc":"cpp",".cpp":"cpp",".cxx":"cpp",".hpp":"cpp",".hh":"cpp",".hxx":"cpp",".cs":"csharp",".php":"php",".vb":"vb",".clj":"clojure",".cljs":"clojure",".cljc":"clojure"};function Le(e){return Fp[Ws(e).toLowerCase()]??null}function Me(e){return Ws(e).toLowerCase()===".vue"}import{createRequire as Op}from"module";var k=Op(import.meta.url),Cr=null,Vs=!1;function Lp(){if(Vs)return null;if(Cr)return Cr;try{return Cr=k("tree-sitter"),Cr}catch{return Vs=!0,null}}var Us=new Map,Pr=new Set;function Mp(e){if(Pr.has(e))return null;let t=Us.get(e);if(t)return t;let r;try{switch(e){case"rust":r=k("tree-sitter-rust");break;case"typescript":r=k("tree-sitter-typescript").typescript;break;case"tsx":r=k("tree-sitter-typescript").tsx;break;case"javascript":r=k("tree-sitter-javascript");break;case"python":r=k("tree-sitter-python");break;case"java":r=k("tree-sitter-java");break;case"kotlin":r=k("tree-sitter-kotlin");break;case"scala":r=k("tree-sitter-scala");break;case"ruby":r=k("tree-sitter-ruby");break;case"c":r=k("tree-sitter-c");break;case"cpp":r=k("tree-sitter-cpp");break;case"csharp":r=k("tree-sitter-c-sharp");break;case"php":r=k("tree-sitter-php").php;break;case"vb":{let n=k("tree-sitter-vb-dotnet");r=n.language??n;break}case"clojure":return Pr.add(e),null}}catch{return Pr.add(e),null}return Us.set(e,r),r}var Hs=new Map;function jp(e){let t=Hs.get(e);if(t)return t;let r=Mp(e);if(!r)return null;let n=Lp();if(!n)return null;let i=new n;try{i.setLanguage(r)}catch{return Pr.add(e),null}return Hs.set(e,i),i}function Gp(e,t){return e.parse(n=>n>=t.length?null:t.slice(n,Math.min(t.length,n+16384)))}function di(e,t){let r=jp(e);if(!r)return null;try{return Gp(r,t)}catch{return null}}import{posix as pi}from"path";import{parse as Bp}from"@vue/compiler-sfc";var px=Gi("vue-sfc-units");function $p(e){return e.replace(/\\/g,"/").replace(/^\.\//,"")}function qp(e){let t=e?.toLowerCase();return!t||t==="js"||t==="javascript"||t==="jsx"?"javascript":t==="ts"||t==="typescript"?"typescript":t==="tsx"?"tsx":null}function Ks(e,t,r){let n={relativePath:t,template:null,scripts:[],styles:[],customBlocks:[],errors:[]};if(!r)return n;let i;try{i=Bp(r,{filename:t})}catch(s){return n.errors.push(Js(s)),n}n.errors.push(...i.errors.map(Js));let{descriptor:o}=i;return o.template&&(n.template=kr(e,t,"template",o.template)),o.script&&n.scripts.push(zs(e,t,o.script,!1)),o.scriptSetup&&n.scripts.push(zs(e,t,o.scriptSetup,!0)),n.styles=o.styles.map(s=>kr(e,t,"style",s)),n.customBlocks=o.customBlocks.map(s=>kr(e,t,"custom",s)),n.errors.push(...[n.template,...n.scripts,...n.styles,...n.customBlocks].flatMap(s=>s?.errors??[])),n}function zs(e,t,r,n){let i=kr(e,t,"script",r);return{...i,kind:"script",setup:n,astLanguage:qp(i.lang)}}function kr(e,t,r,n){let i=Vp(n.attrs),o=typeof i.lang=="string"?i.lang:null,s=typeof i.src=="string"?i.src:typeof n.src=="string"?n.src:void 0;if(s){let c=Wp(t,s);if(!c)return{kind:r,ownerPath:t,sourcePath:t,external:!0,src:s,attrs:i,lang:o,body:"",startLine:0,endLine:0,errors:[`Could not resolve Vue ${r} block source: ${s}`]};let l=j(e,c),u=l?Math.max(0,l.split(`
135
+ `).length-1):0;return{kind:r,ownerPath:t,sourcePath:c,external:!0,src:s,attrs:i,lang:o,body:l,startLine:0,endLine:u,errors:l?[]:[`Vue ${r} block source not found: ${c}`]}}let a=Math.max(0,n.loc.start.line-1);return{kind:r,ownerPath:t,sourcePath:t,external:!1,attrs:i,lang:o,body:n.content,startLine:a,endLine:Math.max(a,n.loc.end.line-1),errors:[]}}function Wp(e,t){let r=t.split(/[?#]/,1)[0];if(!r||r.startsWith("/")||r.includes("://"))return null;let n=$p(pi.normalize(pi.join(pi.dirname(e),r)));return n===".."||n.startsWith("../")?null:n}function Vp(e){return{...e}}function Js(e){return e instanceof Error?e.message:String(e)}function Nr(e,t,r){let i=Ks(e,t,r).scripts.filter(s=>s.astLanguage&&s.body.length>0),o=i[0]?.astLanguage;return o?{body:i.map(s=>`${`
136
+ `.repeat(s.startLine)}${s.body}`).join(`
137
+ `),startLine:0,language:o}:null}var Xs=ze("ast-trees",{clearGroups:["whole-project","source-file"]});function re(e,t){if(Me(t))return Up(e,t);let r=Le(t);if(!r)return null;let n=j(e,t);return n?Xs.get(e,t,n,()=>di(r,n)):null}function Up(e,t){let r=j(e,t);return r?Xs.get(e,t,r,()=>{let n=Nr(e,t,r);if(!n)return null;let i=`
138
+ `.repeat(n.startLine)+n.body;return di(n.language,i)}):null}function Ys(e,t){let r=Hp(e,t);if(!r)return null;let n=je(r);return n?{calleeLeaf:n,memberAccess:zp(r),line:e.startPosition.row}:null}function Hp(e,t){if(t==="rust")return e.type==="call_expression"?e.childForFieldName("function")??e.namedChild(0):e.type==="macro_invocation"?e.childForFieldName("macro")??e.namedChild(0):null;if(t==="python")return e.type!=="call"?null:e.childForFieldName("function")??e.namedChild(0);if(t==="typescript"||t==="tsx"||t==="javascript"){if(e.type==="call_expression")return e.childForFieldName("function")??e.namedChild(0);if(e.type==="new_expression")return e.childForFieldName("constructor")??e.namedChild(0)}return null}function zp(e){switch(e.type){case"field_expression":case"member_expression":case"attribute":return!0;default:return!1}}function je(e){switch(e.type){case"identifier":case"type_identifier":case"field_identifier":case"property_identifier":case"shorthand_property_identifier":return e.text;case"field_expression":case"member_expression":case"attribute":{let t=e.namedChild(e.namedChildCount-1);return t?je(t):null}case"generic_function":{let t=e.childForFieldName("function")??e.namedChild(0);return t?je(t):null}case"scoped_identifier":{let t=e.childForFieldName("name")??e.namedChild(e.namedChildCount-1);return t?je(t):null}case"super":case"self":case"this":return null;default:return null}}function kt(e){return e.type==="comment"||e.type==="line_comment"||e.type==="block_comment"}var Jp=new Set(["function_declaration","method_definition","method_signature","function_signature"]);function ra(e,t){let r=Xp(e,t);if(r)return{name:r.name,startLine:r.definitionNode.startPosition.row,endLine:r.definitionNode.endPosition.row,paramCount:ea(r.functionNode),params:Qs(r.functionNode),paramsEndLine:Zs(r.functionNode),isLiteralPassthrough:ta(r.functionNode,t)};if(!Kp(e.type,t))return null;let n=e.childForFieldName("name")??e.namedChildren.find(i=>i.type==="identifier"||i.type==="property_identifier");return n?{name:n.text,startLine:e.startPosition.row,endLine:e.endPosition.row,paramCount:ea(e),params:Qs(e),paramsEndLine:Zs(e),isLiteralPassthrough:ta(e,t)}:null}function na(e){return e.namedChildren.find(t=>t.type==="parameters"||t.type==="formal_parameters")}function Qs(e){let t=na(e);if(!t)return[];let r=[];for(let n of t.namedChildren){if(kt(n))continue;if(n.type==="identifier"){r.push({name:n.text,simple:!0});continue}let i=n.namedChildren.some(a=>a.type.endsWith("_modifier"))||/^\s*(?:public|private|protected|readonly|override)\b/.test(n.text),o=n.childForFieldName("pattern");if(!i&&o&&o.type==="identifier"){r.push({name:o.text,simple:!0});continue}let s=n.namedChildren.find(a=>a.type==="identifier");r.push({name:o?.type==="identifier"?o.text:s?.text??"",simple:!1})}return r}function Zs(e){let t=na(e);return t?t.endPosition.row:e.startPosition.row}function Kp(e,t){return t==="rust"?e==="function_item"||e==="function_signature_item":t==="python"?e==="function_definition":t==="typescript"||t==="tsx"||t==="javascript"?Jp.has(e):!1}function Xp(e,t){if(t!=="typescript"&&t!=="tsx"&&t!=="javascript")return null;if(e.type==="variable_declarator"){let r=e.childForFieldName("name")??e.namedChild(0),n=e.childForFieldName("value")??e.namedChild(1);return!r||!n||n.type!=="arrow_function"&&n.type!=="function_expression"?null:{name:r.text,definitionNode:e,functionNode:n}}if(e.type==="public_field_definition"){let r=e.childForFieldName("name")??e.namedChild(0),n=e.childForFieldName("value")??e.namedChild(1);return!r||!n||n.type!=="arrow_function"&&n.type!=="function_expression"?null:{name:r.text,definitionNode:e,functionNode:n}}return null}function ea(e){let t=e.namedChildren.find(n=>n.type==="parameters"||n.type==="formal_parameters");if(!t)return 0;let r=0;for(let n of t.namedChildren)kt(n)||(r+=1);return r}function ta(e,t){let r=e.namedChildren.find(d=>d.type==="block"||d.type==="statement_block");if(!r)return!1;let n=r.namedChildren.filter(d=>!kt(d));if(n.length!==1)return!1;let i=n[0],o=null;if(i.type==="return_statement"||i.type==="expression_statement"?o=i.namedChild(0)??null:t==="rust"&&(i.type==="call_expression"||i.type==="macro_invocation")&&(o=i),!o)return!1;let s=t==="python"?"call":"call_expression";if(o.type!==s)return!1;let a=o.namedChildren.find(d=>d.type==="arguments"||d.type==="argument_list");if(!a)return!1;let c=a.namedChildren.filter(d=>!kt(d)),l=e.namedChildren.find(d=>d.type==="parameters"||d.type==="formal_parameters");if(!l)return!1;let u=[];for(let d of l.namedChildren){if(d.type==="identifier"){u.push(d.text);continue}let p=d.namedChildren.find(m=>m.type==="identifier");p&&u.push(p.text)}if(c.length!==u.length)return!1;for(let d=0;d<u.length;d+=1){let p=c[d];if(p.type!=="identifier"||p.text!==u[d])return!1}return!0}var Yp=new Set(["identifier","type_identifier","field_identifier"]),Qp=new Set(["identifier"]),Zp=new Set(["identifier","property_identifier","type_identifier","shorthand_property_identifier","shorthand_property_identifier_pattern"]),ef=new Set(["rust","python"]),tf=/\{([^{}]*)\}/g,rf=/\b([A-Za-z_][\w]*)\b/g;function ia(e,t){return nf(t).has(e.type)}function oa(e,t){return ef.has(t)&&e.type==="string_content"}function fi(e){let t=0;for(let n of e.values()){let i=n[n.length-1];i!==void 0&&i>t&&(t=i)}let r=new Array(t+1);for(let n=0;n<=t;n+=1)r[n]=new Set;for(let[n,i]of e)for(let o of i)r[o].add(n);return r}function nf(e){return e==="rust"?Yp:e==="python"?Qp:Zp}function sa(e,t){let r=e.startPosition.row;for(let n of e.text.matchAll(tf)){let i=n[1]??"";for(let o of i.matchAll(rf))o[1]&&t(o[1],r)}}var of=[/\bdefault\s*=\s*"([^"]+)"/g,/\bwith\s*=\s*"([^"]+)"/g,/\bserialize_with\s*=\s*"([^"]+)"/g,/\bdeserialize_with\s*=\s*"([^"]+)"/g,/\bskip_serializing_if\s*=\s*"([^"]+)"/g,/\bgetter\s*=\s*"([^"]+)"/g,/\brename_all_with\s*=\s*"([^"]+)"/g,/\bschema_with\s*=\s*"([^"]+)"/g],sf=/^#!?\[\s*serde\s*\(/,af=/^#!?\[\s*schemars\s*\(/,cf=/^#!?\[\s*validate\s*\(/,lf=new Set(["invoke","invokeTauriCommand","listen","once","emit","subscribe","dispatch","sendCommand","callRust"]);function aa(e,t,r){if(t!=="typescript"&&t!=="tsx"&&t!=="javascript"||e.type!=="call_expression")return;let n=e.childForFieldName("function")??e.namedChild(0);if(!n)return;let i=je(n);if(!i||!lf.has(i))return;let o=e.namedChildren.find(c=>c.type==="arguments");if(!o)return;let s=o.namedChild(0);if(!s||s.type!=="string")return;let a=s.namedChildren.find(c=>c.type==="string_fragment");a&&r.add(a.text)}function ca(e,t){let r=sf.test(e),n=af.test(e),i=cf.test(e);if(!(!r&&!n&&!i))for(let o of of){o.lastIndex=0;let s;for(;(s=o.exec(e))!==null;){let a=s[1],c=a.split("::").pop()??a;c==="is_none"&&/\bOption\b/.test(a)||c==="is_empty"&&/\b(String|Vec|HashMap|BTreeMap|HashSet|BTreeSet)\b/.test(a)||c&&t.add(c)}}}function la(e,t){let r=new Map,n=(s,a)=>{if(s===a)return;let c=r.get(s);c||(c=new Set,r.set(s,c)),c.add(a)},i=t==="python"?new Set(["identifier"]):new Set(["type_identifier"]),o=(s,a)=>{let c=l=>{i.has(l.type)&&l.text!==a&&n(l.text,a);for(let u of l.children)c(u)};for(let l of s.children)c(l)};if(t==="rust")for(let s of e.rootNode.descendantsOfType(["struct_item","enum_item","union_item","type_item"])){let a=s.namedChildren.find(l=>l.type==="type_identifier")?.text;if(!a)continue;let c=s.namedChildren.find(l=>l.type==="field_declaration_list"||l.type==="enum_variant_list"||l.type==="ordered_field_declaration_list");c&&o(c,a),s.type==="type_item"&&o(s,a)}else if(t==="python")for(let s of e.rootNode.descendantsOfType("class_definition")){let a=s.namedChildren.find(u=>u.type==="identifier")?.text;if(!a)continue;let c=s.childForFieldName("superclasses");c&&o(c,a);let l=s.namedChildren.find(u=>u.type==="block");if(l)for(let u of l.descendantsOfType("type"))for(let d of u.descendantsOfType("identifier"))d.text!==a&&n(d.text,a)}else for(let s of e.rootNode.descendantsOfType(["interface_declaration","type_alias_declaration","class_declaration"])){let a=s.namedChildren.find(c=>c.type==="type_identifier")?.text;a&&o(s,a)}return r}var uf=new Map([["defn","function"],["defn-","function"],["defmacro","macro"],["defmacro-","macro"],["defmethod","method"]]),mi=new Set(["catch","comment","def","defprotocol","defrecord","deftype","defmethod","defmacro","defmacro-","defn","defn-","do","doseq","dotimes","fn","for","if","let","loop","ns","quote","recur","throw","try","extend-protocol","extend-type","when","when-let","when-not"]);function ua(e){let t=[],r=[],n=[],i=new Map,o=[],s=0,a=0,c=(l,u)=>{let d=i.get(l);if(!d){i.set(l,[u]);return}d[d.length-1]!==u&&d.push(u)};for(;a<e.length;){let l=e[a];if(l===`
139
+ `){s+=1,a+=1;continue}if(/\s|,/.test(l)){a+=1;continue}if(l===";"){a=Ar(e,a);continue}if(l==='"'){let h=_t(e,a,s);s=h.line,a=h.index;continue}if(l==="("||l==="["||l==="{"){o.push({kind:l,startLine:s,endLine:s,headTokens:[],tokens:[],children:[]}),a+=1;continue}if(l===")"||l==="]"||l==="}"){let h=o.pop();h&&(h.endLine=s,df(h,{callables:t,callSites:r,clojureMembers:n,recordIdentifier:c}),o[o.length-1]?.children.push(h)),a+=1;continue}if(gi(l)){a+=1;continue}let u=s,d=a;for(;a<e.length&&!yi(e[a]);)a+=1;let p=e.slice(d,a);if(!p)continue;let m={text:p,line:u};pf(o[o.length-1],m),c(W(p),u)}return{language:"clojure",callables:t,callSites:r,clojureMembers:n,typeContainerMap:new Map,identifierLineMap:i,identifiersByLine:hf(i),fileIdentifiers:new Set(i.keys()),rustAttrReferencedNames:new Set,crossLanguageDispatchNames:new Set}}function df(e,t){if(e.kind!=="("||e.headTokens.length===0)return;let r=e.headTokens[0],n=W(r.text),i=uf.get(r.text);if(i){let s=e.headTokens[1];if(s){let a=W(s.text);t.recordIdentifier(a,s.line),t.callables.push({name:a,startLine:e.startLine,endLine:e.endLine,paramCount:0,params:[],paramsEndLine:s.line,isLiteralPassthrough:!1,clojureKind:i})}}if(ff(e,t),!n||mi.has(r.text)||mi.has(n)||n.startsWith(":"))return;let o=yf(r.text);t.callSites.push({calleeLeaf:o.leaf,calleeQualifier:o.qualifier,calleeText:o.text,memberAccess:!1,line:r.line})}function pf(e,t){e&&(e.headTokens.length<2&&e.headTokens.push(t),e.tokens.length<200&&e.tokens.push(t))}function ff(e,t){let r=W(e.tokens[0]?.text??"");if(r==="defprotocol"){let n=W(e.tokens[1]?.text??"");if(!n)return;for(let i of _r(e))Nt(t,n,"protocol",i,"protocol-method");return}if(r==="defrecord"||r==="deftype"){let n=W(e.tokens[1]?.text??"");if(!n)return;let i=r==="defrecord"?"record":"type",o=r==="defrecord"?"record-method":"type-method";for(let s of _r(e))Nt(t,n,i,s,o);return}if(r==="extend-type"){let n=W(e.tokens[1]?.text??"");if(!n)return;for(let i of _r(e))Nt(t,n,"extension",i,"extension-method");return}if(r==="extend-protocol"){let n=W(e.tokens[1]?.text??"");for(let i of _r(e)){n&&Nt(t,n,"extension",i,"extension-method");let o=gf(e,i.startLine);o&&o!==n&&Nt(t,o,"extension",i,"extension-method")}}}function _r(e){return e.children.filter(mf)}function mf(e){if(e.kind!=="(")return!1;let t=W(e.tokens[0]?.text??"");return!!(t&&!mi.has(t)&&!t.startsWith(":"))}function Nt(e,t,r,n,i){let o=n.tokens[0],s=W(o?.text??"");!o||!s||(e.recordIdentifier(s,o.line),e.clojureMembers.push({ownerName:t,ownerKind:r,memberName:s,memberKind:i,startLine:n.startLine,endLine:n.endLine}))}function gf(e,t){let r=null;for(let n=2;n<e.tokens.length;n+=1){let i=e.tokens[n];if(i.line>t)break;let o=W(i.text);o&&!o.startsWith(":")&&(r=o)}return r}function W(e){return e.replace(/^#?['`~@]+/,"").split("/").pop()?.replace(/^\./,"")??""}function yf(e){let t=e.replace(/^#?['`~@]+/,""),r=t.lastIndexOf("/"),n=W(t);if(r<=0)return{leaf:n,text:t};let i=t.slice(0,r);return{leaf:n,qualifier:i,text:t}}function Ar(e,t){let r=t;for(;r<e.length&&e[r]!==`
140
+ `;)r+=1;return r}function _t(e,t,r){let n=t+1,i=r;for(;n<e.length;){let o=e[n];if(o==="\\"){n+=2;continue}if(o===`
141
+ `&&(i+=1),n+=1,o==='"')break}return{index:n,line:i}}function gi(e){return e==="'"||e==="`"||e==="~"||e==="@"||e==="^"||e==="#"}function yi(e){return/\s|,/.test(e)||e==="("||e===")"||e==="["||e==="]"||e==="{"||e==="}"||e==='"'||e===";"}function hf(e){let t=[];for(let[r,n]of e)for(let i of n)t[i]??=new Set,t[i].add(r);return t}var da=3,Sf=ze("source-facts",{clearGroups:["whole-project","source-file"]}),hi=vt({kind:"source-facts",invalidation:Tt("source-facts"),serialize:Ef,deserialize:Rf});function pa(e,t){return xf(e,t).facts}function xf(e,t){let r=j(e,t);if(!r)return{facts:null};let n=bf(e,t,r);return n?Sf.get(e,t,r,()=>If(e,t,n,r)):{facts:null}}function bf(e,t,r){return Me(t)?Nr(e,t,r)?.language??null:Le(t)}function If(e,t,r,n){let i=lt(e,t,n),o=hi.read(e,t,i);if(o&&o.language===r)return{facts:o};if(r==="clojure"){let c=ua(n);return hi.write(e,t,i,c),{facts:c}}let s=re(e,t);if(!s)return{facts:null,unavailable:{language:r,reason:"parser-unavailable"}};let a=vf(s,r);return hi.write(e,t,i,a),{facts:a}}function Ef(e){let t={version:da,language:e.language,callables:e.callables,callSites:e.callSites,clojureMembers:e.clojureMembers,typeContainerMap:[...e.typeContainerMap.entries()].map(([r,n])=>[r,[...n]]),identifierLineMap:[...e.identifierLineMap.entries()],rustAttrReferencedNames:[...e.rustAttrReferencedNames],crossLanguageDispatchNames:[...e.crossLanguageDispatchNames]};return JSON.stringify(t)}function Rf(e){try{let t=JSON.parse(e);if(t.version!==da||t.language==="clojure"&&(t.clojureMembers===void 0||t.callSites.some(n=>n.calleeText===void 0)))return null;let r=new Map(t.identifierLineMap);return{language:t.language,callables:t.callables,callSites:t.callSites,clojureMembers:t.clojureMembers??[],typeContainerMap:new Map(t.typeContainerMap.map(([n,i])=>[n,new Set(i)])),identifierLineMap:r,identifiersByLine:fi(r),fileIdentifiers:new Set(r.keys()),rustAttrReferencedNames:new Set(t.rustAttrReferencedNames),crossLanguageDispatchNames:new Set(t.crossLanguageDispatchNames)}}catch{return null}}function vf(e,t){let r=[],n=[],i=new Set,o=new Set,s=new Map,a=(l,u)=>{let d=s.get(l);if(!d){s.set(l,[u]);return}d[d.length-1]!==u&&d.push(u)},c=l=>{let u=ra(l,t);u&&r.push(u);let d=Ys(l,t);d&&n.push(d),aa(l,t,o),t==="rust"&&(l.type==="attribute_item"||l.type==="inner_attribute_item")&&ca(l.text,i),ia(l,t)&&a(l.text,l.startPosition.row),oa(l,t)&&sa(l,a);for(let p of l.children)c(p)};return c(e.rootNode),{language:t,callables:r,callSites:n,clojureMembers:[],typeContainerMap:la(e,t),identifierLineMap:s,identifiersByLine:fi(s),fileIdentifiers:new Set(s.keys()),rustAttrReferencedNames:i,crossLanguageDispatchNames:o}}var Tf=new Set(["rust","typescript","tsx","javascript","python","clojure"]);function wf(e,t){let r=pa(e,t);return!r||!Tf.has(r.language)?null:r.callables.map(n=>({name:n.name,startLine:n.startLine,endLine:n.endLine}))}function fa(e,t){return e.split(t).filter(Boolean).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join("")}var Cf=new Set(["identifier","type_identifier","property_identifier","shorthand_property_identifier","field_identifier"]);function D(e){let t=[],r=0,n=0;for(let i=0;i<e.length;i++){let o=e[i];(o==="{"||o==="["||o==="(")&&r++,(o==="}"||o==="]"||o===")")&&r--,o===","&&r===0&&(t.push(e.slice(n,i)),n=i+1)}return t.push(e.slice(n)),t}function G(e,t){for(let r of e.namedChildren)if(r.type===t)return r;return null}function R(e,t){let r=new Set,n=(i,o)=>{let s=o||t.has(i.type);!s&&Cf.has(i.type)&&r.add(i.text);for(let a of i.children)n(a,s)};return n(e.rootNode,!1),r}function J(e,t,r,n,i,o,s){return{importedName:i,localName:o,sourcePath:s??E(e,n,oi(t)),kind:"named",used:A(r,o),usedMembers:[]}}function I(e,t,r,n,i="named",o={}){return{importedName:e,localName:t,sourcePath:r,kind:i,used:n.has(t),usedMembers:[],isTypeOnly:o.isTypeOnly}}function le(e,t,r,n,i="named",o=[],s={}){return{importedName:e,localName:t,sourcePath:r,kind:i,used:n,usedMembers:o,isTypeOnly:s.isTypeOnly}}function Ge(e,t){return{importedName:e,localName:null,sourcePath:t,kind:"side-effect",used:!0,usedMembers:[]}}function Be(e,t,r={}){return{importedName:e,localName:r.localName??null,sourcePath:t,kind:"namespace",used:r.used??!0,usedMembers:r.usedMembers??[],isTypeOnly:r.isTypeOnly}}function V(e,t,r){let n=[];for(let i of e.matchAll(t)){let o=i[0];if(!o||typeof i.index!="number")continue;let s=ve(e,i.index,i.index+o.length);for(let a of r(i,s))n.push(a)}return n}function U(e,t,r,n){let i=re(e,t);if(i){let o=r(i);if(o)return o}return n()}function Dr(e,t,r,n){let i=re(e,t),o=Le(t),s=o?r[o]:void 0;return i&&s?s(i):n()}function ga(e,t,r){return U(e,t,n=>kf(e,t,n),()=>Pf(e,t,r))}function Pf(e,t,r){return V(r,/^[ \t]*#include\s+[<"]([^">]+)[">]\s*$/gm,(n,i)=>{let o=n[1]?.trim();if(!o)return[];let s=ma(o).replace(/\.[^.]+$/,"");return[le(o,s,vr(e,t,o),A(i,s))]})}function kf(e,t,r){let n=R(r,new Set(["preproc_include"])),i=[];for(let o of r.rootNode.descendantsOfType("preproc_include")){let s=null;for(let c of o.namedChildren){if(c.type==="system_lib_string"){s=c.text.replace(/^<|>$/g,"");break}if(c.type==="string_literal"){s=c.namedChildren.find(u=>u.type==="string_content")?.text??c.text.replace(/^"|"$/g,"");break}}if(!s)continue;let a=ma(s).replace(/\.[^.]+$/,"");i.push(I(s,a,vr(e,t,s),n))}return i}var Nf=new Set([":require",":require-macros",":use"]),bi=String.raw`A-Za-z0-9_$*+!?.<>=-`;function ha(e,t,r){let n=$f(r);if(!n)return[];let i=Bf(r,n.start,n.end),o=[];for(let s of n.children.slice(2)){if(s.type!=="list"||s.children.length===0)continue;let a=H(s.children[0]);if(a){if(Nf.has(a)){for(let c of Df(s.children.slice(1)))o.push(...Af(e,c,i));continue}if(a===":import")for(let c of Of(s.children.slice(1)))o.push(c)}}return o}function _f(e){return e.type==="list"&&H(e.children[0])==="ns"}function Af(e,t,r){let n=si(e,t.namespace),i=t.alias??t.namespace,o=Mf(r,i),s=[{importedName:t.namespace,localName:i,sourcePath:n,kind:"namespace",used:t.refers.length>0||t.referAll||o.length>0||jf(r,t.namespace),usedMembers:o}];t.referAll&&s.push({importedName:"*",localName:null,sourcePath:n,kind:"side-effect",used:!0,usedMembers:[]});for(let a of t.refers)s.push({importedName:a,localName:a,sourcePath:n,kind:"named",used:Gf(r,a),usedMembers:[]});return s}function Df(e){return e.flatMap(t=>Fr(t,null))}function Fr(e,t){if(e.type==="atom")return e.text.startsWith(":")?[]:[{namespace:xi(t,e.text),alias:null,refers:[],referAll:!1}];if(e.type==="vector")return e.children.length>0&&H(e.children[0])===null?e.children.flatMap(r=>Fr(r,t)):Ff(e,t);if(e.type==="list"&&e.children.length>0){let r=H(e.children[0]);return r?!r||r.startsWith(":")?[]:e.children.slice(1).flatMap(n=>Fr(n,xi(t,r))):e.children.flatMap(n=>Fr(n,t))}return[]}function Ff(e,t){let r=H(e.children[0]);if(!r||r.startsWith(":"))return[];let n={namespace:xi(t,r),alias:null,refers:[],referAll:!1};for(let i=1;i<e.children.length;i+=1){let o=H(e.children[i]);if(!o?.startsWith(":"))continue;let s=e.children[i+1];if((o===":as"||o===":as-alias")&&s){n.alias=H(s),i+=1;continue}o===":refer"&&s&&(H(s)===":all"?n.referAll=!0:(s.type==="vector"||s.type==="list")&&n.refers.push(...s.children.map(H).filter(Lf)),i+=1)}return[n]}function Of(e){let t=[];for(let r of e){if(r.type==="atom"){let i=r.text.split(".").pop()??r.text;t.push(le(i,i,null,!0));continue}if(r.type!=="vector")continue;let n=H(r.children[0]);if(n)for(let i of r.children.slice(1)){let o=H(i);o&&t.push(le(`${n}.${o}`,o,null,!0))}}return t}function xi(e,t){return e?`${e}.${t}`:t}function H(e){return e?.type==="atom"?e.text:null}function Lf(e){return!!(e&&!e.startsWith(":"))}function Mf(e,t){let r=new Set,n=new RegExp(`${Ii()}${Oe(t)}\\s*/\\s*([${bi}]+)`,"g");for(let i of e.matchAll(n)){let o=i[1];o&&r.add(o)}return[...r]}function jf(e,t){return new RegExp(`${Ii()}${Oe(t)}\\s*/`,"m").test(e)}function Gf(e,t){return new RegExp(`${Ii()}${Oe(t)}(?![${bi}])`,"m").test(e)}function Ii(){return`(?<![${bi}])`}function Bf(e,t,r){let n="",i=0;for(;i<e.length;){if(i>=t&&i<r){n+=e[i]===`
142
+ `?`
143
+ `:" ",i+=1;continue}let o=e[i];if(o===";"){let s=Ar(e,i);n+=ya(e.slice(i,s)),i=s;continue}if(o==='"'){let s=_t(e,i,0).index;n+=ya(e.slice(i,s)),i=s;continue}n+=o,i+=1}return n}function $f(e){let t=0;for(;t<e.length&&(t=Ei(e,t),!(t>=e.length));){let r=Or(e,t);if(!r){t+=1;continue}if(_f(r.form))return r.form;t=r.index}return null}function Or(e,t){let r=Ei(e,t);if(e.startsWith("#?@",r)||e.startsWith("#?",r))return qf(e,r);if(e.startsWith("#_",r)){let i=Or(e,r+2);return i?{form:{type:"atom",text:"",start:r,end:i.index},index:i.index}:null}for(;gi(e[r]);)r+=1;let n=e[r];return n?n==="("?Si(e,r,"list",")"):n==="["?Si(e,r,"vector","]"):n==="{"?Si(e,r,"map","}"):n==='"'?{form:{type:"atom",text:"",start:r,end:_t(e,r,0).index},index:_t(e,r,0).index}:Vf(e,r):null}function qf(e,t){let r=e.startsWith("#?@",t)?3:2,n=Or(e,t+r);return n?{form:{type:"list",children:n.form.type==="list"||n.form.type==="vector"||n.form.type==="map"?Wf(n.form.children):[],start:t,end:n.index},index:n.index}:null}function Wf(e){let t=[];for(let r=0;r<e.length;r+=2){let n=H(e[r]),i=e[r+1];n?.startsWith(":")&&i&&t.push(i)}return t}function Si(e,t,r,n){let i=[],o=t+1;for(;o<e.length;){if(o=Ei(e,o),e[o]===n)return{form:{type:r,children:i,start:t,end:o+1},index:o+1};let s=Or(e,o);if(!s){o+=1;continue}s.form.type==="atom"&&s.form.text===""||i.push(s.form),o=s.index}return{form:{type:r,children:i,start:t,end:e.length},index:e.length}}function Vf(e,t){let r=t;for(;r<e.length&&!yi(e[r]);)r+=1;return{form:{type:"atom",text:e.slice(t,r),start:t,end:r},index:r}}function Ei(e,t){let r=t;for(;r<e.length;){let n=e[r];if(/\s|,/.test(n)){r+=1;continue}if(n===";"){r=Ar(e,r);continue}break}return r}function ya(e){return e.replace(/[^\r\n]/g," ")}function Sa(e,t,r){let n=[];for(let i of r.matchAll(/^[ \t]*import\s+['"]([^'"]+)['"](?:\s+as\s+([A-Za-z_]\w*))?[\s\S]*?;$/gm)){let o=i[1]?.trim(),s=i[2]?.trim()??null,a=i[0];if(!o||!a||typeof i.index!="number")continue;let c=ve(r,i.index,i.index+a.length);n.push({importedName:o,localName:s,sourcePath:Tr(e,t,o),kind:s?"namespace":"side-effect",used:s?A(c,s):!0,usedMembers:s?nt(c,s):[]})}return n}function xa(e,t,r){let n=[];for(let i of r.matchAll(/^[ \t]*export\s+['"]([^'"]+)['"][\s\S]*?;$/gm)){let o=i[1]?.trim();o&&n.push({specifier:o,sourcePath:Tr(e,t,o)})}return n}function ba(e,t,r){return Dr(e,t,{csharp:n=>Hf(e,t,n),vb:n=>Uf(e,t,n)},()=>{let n=$s(t)?/^[ \t]*Imports\s+(.+?)\s*$/gm:/^[ \t]*using\s+(.+?)\s*;$/gm;return V(r,n,(i,o)=>{let s=i[1]?.trim();if(!s)return[];let[a,c]=s.split(/\s*=\s*/),l=!!c,u=(l?c:a)?.trim()??s,d=u.split(".").pop()??u,p=l?a?.trim()??d:d;return[J(e,t,o,u,d,p,E(e,u,Ie))]})})}function Uf(e,t,r){let n=R(r,new Set(["imports_statement"])),i=[];for(let o of r.rootNode.descendantsOfType("imports_statement")){let s=o.namedChildren.filter(p=>p.type==="namespace_name");if(s.length===0)continue;let a=s[s.length-1],c=s.length>1?s[0]:null,l=a.text,u=l.split(".").pop()??l,d=c?.text??u;i.push(I(u,d,E(e,l,Ie),n,c?"namespace":"named"))}return i}function Hf(e,t,r){let n=R(r,new Set(["using_directive"])),i=[];for(let o of r.rootNode.descendantsOfType("using_directive")){let s=o.namedChildren;if(s.length===0)continue;let a=null,c;s.length>=2&&s[0].type==="identifier"&&(s[1].type==="qualified_name"||s[1].type==="identifier")?(a=s[0],c=s[1]):c=s[s.length-1];let l=c.text,u=l.split(".").pop()??l,d=a?.text??u;i.push(I(u,d,E(e,l,Ie),n,a?"namespace":"named"))}return i}var zf=w("vue-non-script-identifiers",{clearGroups:["whole-project","source-file"]});function Ia(e,t){return zf.get(e,t,()=>{let r=new Set,n=j(e,t);if(!n)return r;let o=n.replace(/<script\b[^>]*>[\s\S]*?<\/script>/g,s=>s.replace(/[^\r\n]/g," ")).replace(/<!--[\s\S]*?-->/g,s=>s.replace(/[^\r\n]/g," ")).replace(/\/\*[\s\S]*?\*\//g,s=>s.replace(/[^\r\n]/g," "));for(let s of o.matchAll(/[A-Za-z_$][\w$]*/g))r.add(s[0]);return r})}function Ri(e,t,r){return U(e,t,n=>Kf(e,t,n),()=>Jf(e,t,r))}function Jf(e,t,r){return sm(r).flatMap(n=>am(e,t,n.clause,n.specifier,n.start,n.end,r))}function Kf(e,t,r){let n=Xf(e,t,r),i=[];for(let o of r.rootNode.descendantsOfType("import_statement"))i.push(...Yf(e,t,r,o,n));return i}function Xf(e,t,r){let n=R(r,new Set(["import_statement"]));if(Me(t))for(let i of Ia(e,t))n.add(i);return n}function Yf(e,t,r,n,i){let o=rm(n);if(!o)return[];let s=Ee(e,t,o),a=G(n,"import_clause");return a?Qf(r,a,s,i,nm(n.text)):[Ge("*",s)]}function Qf(e,t,r,n,i){let o=[];for(let s of t.namedChildren)if(s.type==="identifier")o.push(Zf(s.text,r,n,i));else if(s.type==="namespace_import"){let a=em(e,s,r,n,i);a&&o.push(a)}else s.type==="named_imports"&&o.push(...tm(s,r,n,i));return o}function Zf(e,t,r,n){return I("default",e,t,r,"default",{isTypeOnly:n})}function em(e,t,r,n,i){let s=G(t,"identifier")?.text??"";if(!s)return null;let a=om(e,s);return Be("*",r,{localName:s,usedMembers:a,isTypeOnly:i,used:a.length>0||n.has(s)})}function tm(e,t,r,n){let i=[];for(let o of e.namedChildren){if(o.type!=="import_specifier")continue;let s=o.namedChild(0),a=o.namedChild(1);if(!s)continue;let c=s.text,l=a?.text??c;i.push(I(c,l,t,r,"named",{isTypeOnly:n||im(o.text)}))}return i}function rm(e){let t=G(e,"string");if(!t)return null;let r=G(t,"string_fragment");return r?r.text:null}function nm(e){return/^\s*import\s+type\b/.test(e)}function im(e){return/^\s*type\b/.test(e.trim())}function om(e,t){let r=new Set;for(let n of e.rootNode.descendantsOfType("member_expression")){let i=n.namedChild(0),o=n.namedChild(1);!i||!o||i.type!=="identifier"||i.text!==t||(o.type==="property_identifier"||o.type==="identifier")&&r.add(o.text)}return[...r]}function sm(e){let t=[],r=/^[ \t]*import\s+([\s\S]*?)\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let i of e.matchAll(r)){let o=i[0],s=i[1],a=i[2];!o||!a||typeof i.index!="number"||t.push({clause:s,specifier:a,start:i.index,end:i.index+o.length})}let n=/^[ \t]*import\s+['"]([^'"]+)['"]\s*;?/gm;for(let i of e.matchAll(n)){let o=i[0],s=i[1];!o||!s||typeof i.index!="number"||t.push({clause:null,specifier:s,start:i.index,end:i.index+o.length})}return t.sort((i,o)=>i.start-o.start)}function am(e,t,r,n,i,o,s){let a=Ee(e,t,n),c=ve(s,i,o);return r?cm(r).map(u=>({...u,sourcePath:a})).map(u=>{if(u.kind==="namespace"){let d=nt(c,u.localName);return Be(u.importedName,u.sourcePath,{localName:u.localName,usedMembers:d,used:d.length>0||A(c,u.localName),isTypeOnly:u.isTypeOnly})}return u.kind==="side-effect"?Ge(u.importedName,u.sourcePath):le(u.importedName,u.localName??"",u.sourcePath,u.localName?A(c,u.localName):!1,u.kind,[],{isTypeOnly:u.isTypeOnly})}):[Ge("*",a)]}function cm(e){let t=e.trim(),r=/^type\b/.test(t),n=t.replace(/^type\s+/,""),[i,o]=lm(n),s=[];return i&&s.push(...Ea(i,r)),o&&s.push(...Ea(o,r)),s}function Ea(e,t){let r=e.trim();if(!r)return[];if(r.startsWith("{")){let n=r.slice(1,-1).trim();return n?D(n).map(i=>{let o=i.trim(),s=t||/^type\b/.test(o),a=o.replace(/^type\s+/,""),[c,l]=a.split(/\s+as\s+/);return{importedName:c.trim(),localName:(l??c).trim(),kind:"named",isTypeOnly:s}}):[]}return r.startsWith("* as ")?[{importedName:"*",localName:r.slice(5).trim(),kind:"namespace",isTypeOnly:t}]:[{importedName:"default",localName:r,kind:"default",isTypeOnly:t}]}function lm(e){let t=0;for(let r=0;r<e.length;r++){let n=e[r];if(n==="{"&&t++,n==="}"&&t--,n===","&&t===0)return[e.slice(0,r).trim(),e.slice(r+1).trim()]}return[e.trim(),null]}function vi(e,t,r){let n=re(e,t);return n?gm(e,t,n):um(e,t,r)}function um(e,t,r){return[...dm(e,t,r),...pm(e,t,r),...fm(e,t,r)]}function dm(e,t,r){let n=[],i=/^[ \t]*export\s+(?:type\s+)?\{([\s\S]*?)\}\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let o of r.matchAll(i)){if(typeof o.index!="number")continue;let s=o[1]??"",a=o[2]??"",c=D(s).map(d=>mm(d.trim())).filter(d=>!!d),l=it(r,o.index),u=it(r,o.index+o[0].length-1);n.push({kind:"named",sourcePath:Ee(e,t,a),names:c,startLine:l,endLine:u})}return n}function pm(e,t,r){let n=[],i=/^[ \t]*export\s+\*\s+as\s+(\w+)\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let o of r.matchAll(i)){if(typeof o.index!="number")continue;let s=o[2]??"",a=it(r,o.index),c=it(r,o.index+o[0].length-1);n.push({kind:"star-as",sourcePath:Ee(e,t,s),names:[],startLine:a,endLine:c})}return n}function fm(e,t,r){let n=[],i=/^[ \t]*export\s+\*\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let o of r.matchAll(i)){if(typeof o.index!="number")continue;let s=o[1]??"",a=it(r,o.index),c=it(r,o.index+o[0].length-1);n.push({kind:"star",sourcePath:Ee(e,t,s),names:[],startLine:a,endLine:c})}return n}function mm(e){if(!e)return null;let t=e.replace(/^type\s+/,"").trim();if(!t)return null;let r=t.match(/^(\w+)\s+as\s+(\w+)$/);if(r)return r[2]??null;let n=t.match(/^(\w+)$/);return n?n[1]??null:null}function it(e,t){let r=0;for(let n=0;n<t&&n<e.length;n++)e.charCodeAt(n)===10&&r++;return r}function gm(e,t,r){let n=[];for(let i of r.rootNode.descendantsOfType("export_statement")){let o=ym(e,t,i);if(o===void 0)continue;let s=i.startPosition.row,a=i.endPosition.row,c=hm(i,o,s,a);n.push(c)}return n}function ym(e,t,r){let n=G(r,"string");if(!n)return;let i=G(n,"string_fragment");if(i)return Ee(e,t,i.text)}function hm(e,t,r,n){let i=G(e,"export_clause");if(i){let s=[];for(let a of i.namedChildren){if(a.type!=="export_specifier")continue;let c=a.namedChild(0),l=a.namedChild(1);c&&s.push((l??c).text)}return{kind:"named",sourcePath:t,names:s,startLine:r,endLine:n}}return G(e,"namespace_export")?{kind:"star-as",sourcePath:t,names:[],startLine:r,endLine:n}:{kind:"star",sourcePath:t,names:[],startLine:r,endLine:n}}function Ra(e,t,r){return Dr(e,t,{java:n=>Sm(e,t,n),kotlin:n=>xm(e,t,n),scala:n=>bm(e,t,n)},()=>V(r,/^[ \t]*import\s+(?:static\s+)?(.+?)\s*;?$/gm,(n,i)=>{let o=n[1]?.trim();return o?Im(e,t,o,i):[]}))}function Sm(e,t,r){let n=R(r,new Set(["import_declaration"])),i=[];for(let o of r.rootNode.descendantsOfType("import_declaration")){let s=o.children.some(d=>d.type==="asterisk"),c=o.namedChildren.find(d=>d.type==="scoped_identifier")??o.namedChildren.find(d=>d.type==="identifier");if(!c)continue;let l=c.text;if(s){i.push(Be("*",E(e,l,M)));continue}let u=l.split(".").pop()??l;i.push(I(u,u,E(e,l,M),n))}return i}function xm(e,t,r){let n=R(r,new Set(["import_header","import_list"])),i=[];for(let o of r.rootNode.descendantsOfType("import_header")){let s=o.namedChildren.find(m=>m.type==="identifier");if(!s)continue;let a=o.namedChildren.some(m=>m.type==="wildcard_import"),c=o.namedChildren.find(m=>m.type==="import_alias");if(a){i.push(Be("*",E(e,s.text,M)));continue}let l=s.text,u=l.split(".").pop()??l,p=c?.namedChild(0)?.text??u;i.push(I(u,p,E(e,l,M),n))}return i}function bm(e,t,r){let n=R(r,new Set(["import_declaration"])),i=[];for(let o of r.rootNode.descendantsOfType("import_declaration")){let s=o.namedChildren.find(d=>d.type==="namespace_selectors"||d.type==="namespace_wildcard"),a=o.namedChildren.filter(d=>d!==s&&(d.type==="identifier"||d.type==="stable_identifier")),c=a.map(d=>d.text).join(".");if(!c)continue;if(s?.type==="namespace_wildcard"){i.push(Be("*",E(e,c,M)));continue}if(s?.type==="namespace_selectors"){for(let d of s.namedChildren)if(d.type==="arrow_renamed_identifier"){let[p,m]=d.namedChildren;if(!p)continue;let h=p.text,ue=m?.text??h;if(h==="_")continue;i.push(I(h,ue,E(e,`${c}.${h}`,M),n))}else if(d.type==="identifier"){let p=d.text;i.push(I(p,p,E(e,`${c}.${p}`,M),n))}continue}let l=a[a.length-1]?.text??c,u=a.slice(0,-1).map(d=>d.text).join(".")||c;i.push(I(l,l,E(e,u&&a.length>1?`${u}.${l}`:c,M),n))}return i}function Im(e,t,r,n){if(r.includes("{")&&r.includes("}")){let i=r.slice(0,r.indexOf("{")).replace(/\.$/,"").trim(),o=r.slice(r.indexOf("{")+1,r.lastIndexOf("}")).trim();return D(o).flatMap(s=>{let a=s.trim();if(!a)return[];let[c,l]=a.includes("=>")?a.split(/\s*=>\s*/):a.split(/\s+as\s+/),u=c?.trim();if(!u||u==="_")return[];let d=(l??u.split(".").pop()??u).trim(),p=u==="_"?i:`${i}.${u}`.replace(/\.\./g,".");return[J(e,t,n,p,u,d)]})}return[J(e,t,n,r,r.split(".").pop()??r,r.split(".").pop()??r)]}function Ta(e,t,r){return U(e,t,n=>Em(e,t,n),()=>V(r,/^[ \t]*use\s+(.+?)\s*;$/gm,(n,i)=>{let o=n[1]?.trim();return o?D(o).flatMap(s=>{let a=s.trim();if(!a)return[];let[c,l]=a.split(/\s+as\s+/i),u=c?.trim()??a,d=u.split("\\").pop()??u,p=(l??d).trim();return[J(e,t,i,u,d,p,E(e,u.replace(/\\/g,"."),Fe))]}):[]}))}function Em(e,t,r){let n=R(r,new Set(["namespace_use_declaration"])),i=[],o=(s,a,c)=>{i.push(I(a,c,E(e,s.replace(/\\/g,"."),Fe),n))};for(let s of r.rootNode.descendantsOfType("namespace_use_declaration")){let a=s.namedChildren.find(c=>c.type==="namespace_use_group");if(a){let c=s.namedChildren.find(l=>l.type==="namespace_name")?.text??"";for(let l of a.namedChildren){if(l.type!=="namespace_use_clause")continue;let{importedName:u,localName:d,qualified:p}=va(l,c);u&&o(p,u,d)}continue}for(let c of s.namedChildren){if(c.type!=="namespace_use_clause")continue;let{importedName:l,localName:u,qualified:d}=va(c,"");l&&o(d,l,u)}}return i}function va(e,t){let r=e.namedChildren.find(l=>l.type==="qualified_name"),n=e.namedChildren.filter(l=>l.type==="name"),i="";r?i=r.text:n.length>=1&&(i=n[0].text);let o=r&&n.length>0?n[n.length-1]:null,s=i.split("\\").pop()??i,a=o?.text??s,c=t?`${t}\\${i}`:i;return{importedName:s,localName:a,qualified:c}}function Ca(e,t,r){return U(e,t,n=>Rm(e,t,n),()=>Tm(r).flatMap(n=>Cm(e,t,n,r)))}function Rm(e,t,r){let n=R(r,new Set(["import_statement","import_from_statement"])),i=[];for(let o of r.rootNode.descendantsOfType("import_statement"))for(let s of o.namedChildren){let a=wa(s);if(!a)continue;let c=rt(e,t,a.qualifiedName);i.push({importedName:a.qualifiedName,localName:a.localName,sourcePath:c,kind:"namespace",used:n.has(a.localName),usedMembers:[]})}for(let o of r.rootNode.descendantsOfType("import_from_statement")){let s=o.namedChild(0);if(!s)continue;let a=vm(s);if(a===null)continue;let c=rt(e,t,a);for(let l=1;l<o.namedChildCount;l+=1){let u=o.namedChild(l);if(u.type==="wildcard_import"){i.push({importedName:"*",localName:null,sourcePath:c,kind:"side-effect",used:!0,usedMembers:[]});continue}let d=wa(u);d&&i.push({importedName:d.qualifiedName,localName:d.localName,sourcePath:c,kind:"named",used:n.has(d.localName),usedMembers:[]})}}return i}function wa(e){if(e.type==="aliased_import"){let t=e.namedChild(0),r=e.namedChild(1);return!t||!r?null:{qualifiedName:t.text,localName:r.text}}if(e.type==="dotted_name"){let t=e.text;return{qualifiedName:t,localName:t.split(".")[0]??t}}return e.type==="identifier"?{qualifiedName:e.text,localName:e.text}:null}function vm(e){if(e.type==="dotted_name")return e.text;if(e.type==="relative_import"){let t=G(e,"import_prefix")?.text??"",r=G(e,"dotted_name")?.text??"";return`${t}${r}`}return null}function Tm(e){let t=e.split(`
144
+ `),r=[],n=0;for(let i=0;i<t.length;i++){let o=t[i],s=o.trimStart(),a=n;if(n+=o.length+1,!s.startsWith("import ")&&!s.startsWith("from "))continue;let c=o,l=a+o.length,u=ui(o);for(;i+1<t.length&&(u>0||c.trimEnd().endsWith("\\"));){i++;let p=t[i];c+=`
145
+ ${p}`,l+=1+p.length,u+=ui(p),n+=p.length+1}let d=wm(c);d&&r.push({...d,start:a,end:l})}return r}function wm(e){let t=e.replace(/\\\s*\n/g," ").trim();if(t.startsWith("import "))return{kind:"import",module:null,clause:t.slice(7).trim()};let r=t.match(/^from\s+([.\w]+)\s+import\s+([\s\S]+)$/);if(!r)return null;let n=r[2].trim();return n.startsWith("(")&&n.endsWith(")")&&(n=n.slice(1,-1).trim()),{kind:"from",module:r[1],clause:n}}function Cm(e,t,r,n){let i=ve(n,r.start,r.end),o=r.clause.replace(/\n/g," ").trim();if(r.kind==="import")return D(o).flatMap(c=>{let l=c.trim().replace(/,$/,"");if(!l)return[];let[u,d]=l.split(/\s+as\s+/),p=u.trim(),m=(d??p.split(".")[0]??p).trim(),h=rt(e,t,p),ue=nt(i,m);return[{importedName:p,localName:m,sourcePath:h,kind:"namespace",used:A(i,m)||ue.length>0,usedMembers:ue}]});let s=r.module?rt(e,t,r.module):null,a=[];for(let c of D(o)){let l=c.trim().replace(/,$/,"");if(!l)continue;if(l==="*"){a.push({importedName:"*",localName:null,sourcePath:s,kind:"side-effect",used:!0,usedMembers:[]});continue}let[u,d]=l.split(/\s+as\s+/),p=(d??u).trim();a.push({importedName:u.trim(),localName:p,sourcePath:s,kind:"named",used:A(i,p),usedMembers:[]})}return a}import{basename as Pm}from"path";function Pa(e,t,r){return U(e,t,n=>Nm(e,t,n),()=>km(e,t,r))}function km(e,t,r){return V(r,/^[ \t]*(require_relative|require)\s+["']([^"']+)["']\s*$/gm,(n,i)=>{let o=n[1],s=n[2];if(!o||!s)return[];let a=o==="require_relative"?Rr(e,t,s):null;if(a){let c=ka(s);return[le(c,c,a,A(i,c))]}return[Ge(s,a)]})}function Nm(e,t,r){let n=R(r,new Set([])),i=[],o=new Set(["require","require_relative","load"]);for(let s of r.rootNode.descendantsOfType("call")){let a=s.namedChild(0);if(!a||a.type!=="identifier"||!o.has(a.text))continue;let l=s.namedChildren.find(m=>m.type==="argument_list")?.namedChild(0);if(!l||l.type!=="string")continue;let d=l.namedChildren.find(m=>m.type==="string_content")?.text;if(!d)continue;let p=a.text==="require_relative"?Rr(e,t,d):null;if(p){let m=ka(d);i.push(I(m,m,p,n))}else i.push(Ge(d,p))}return i}function ka(e){return fa(Pm(e).replace(/\.[^.]+$/,""),/_/)}function Na(e,t,r){return U(e,t,n=>_m(e,t,n),()=>V(r,/^[ \t]*use\s+(.+?)\s*;$/gm,(n,i)=>{let o=n[1]?.trim();return o?Am(e,t,o,i):[]}))}function _m(e,t,r){let n=R(r,new Set(["use_declaration"])),i=[];for(let o of r.rootNode.descendantsOfType("use_declaration")){let s=o.namedChild(0);if(s)for(let a of At(s,"")){if(!a.importedName||a.importedName==="*")continue;let c=ae(e,t,a.qualifiedName)??ae(e,t,a.qualifiedName.split("::").slice(0,-1).join("::"));i.push(I(a.importedName,a.localName,c,n))}}return i}function At(e,t){switch(e.type){case"identifier":case"super":case"crate":{let r=e.text;return[{qualifiedName:Lr(t,r),importedName:r,localName:r}]}case"self":{let r=t.split("::").filter(Boolean).pop()??"self";return[{qualifiedName:t||"self",importedName:r,localName:r}]}case"scoped_identifier":{let r=e.text,n=r.split("::").pop()??r;return[{qualifiedName:Lr(t,r),importedName:n,localName:n}]}case"scoped_use_list":{let r=e.namedChild(0),n=e.namedChild(1);if(!r||!n)return[];let i=Lr(t,r.text),o=[];for(let s of n.namedChildren)o.push(...At(s,i));return o}case"use_list":{let r=[];for(let n of e.namedChildren)r.push(...At(n,t));return r}case"use_as_clause":{let r=e.namedChild(0),n=e.namedChild(1);if(!r||!n)return[];let i=At(r,t),o=n.text;return i.map(s=>({...s,localName:o}))}case"use_wildcard":{let r=e.namedChild(0),n=r?r.text:"";return[{qualifiedName:Lr(t,`${n}::*`),importedName:"*",localName:"*"}]}default:return[]}}function Lr(e,t){return e?t?`${e}::${t}`:e:t}function Am(e,t,r,n){let i=r.trim();if(i.includes("{")&&i.includes("}")){let u=i.slice(0,i.indexOf("{")).replace(/::$/,"").trim(),d=i.slice(i.indexOf("{")+1,i.lastIndexOf("}")).trim();return D(d).flatMap(p=>{let m=p.trim();if(!m)return[];if(m==="self"){let b=u.split("::").filter(Boolean).pop();return b?[J(e,t,n,u,b,b)]:[]}let[h,ue]=m.split(/\s+as\s+/),B=h?.trim();if(!B)return[];let ot=(ue??B.split("::").pop()??B).trim(),$e=`${u}::${B}`.replace(/::::/g,"::");return[J(e,t,n,$e,B.split("::").pop()??B,ot,ae(e,t,u))]})}let[o,s]=i.split(/\s+as\s+/),a=o?.trim()??i,c=(s??a.split("::").pop()??a).trim(),l=ae(e,t,a)??ae(e,t,a.split("::").slice(0,-1).join("::"));return[J(e,t,n,a,a.split("::").pop()??a,c,l)]}function _a(e,t,r){let n=re(e,t);if(n)return Dm(e,t,n);let i=[];for(let o of r.matchAll(/^[ \t]*pub\s+use\s+(.+?)\s*;$/gm)){let s=o[1]?.trim();s&&i.push(...Om(e,t,s))}return i}function Dm(e,t,r){let n=[];for(let i of r.rootNode.descendantsOfType("use_declaration")){if(!Fm(i))continue;let o=i.namedChildren.find(s=>s.type!=="visibility_modifier");if(o)for(let s of At(o,""))s.importedName&&n.push(Ti(e,t,s.qualifiedName))}return n}function Fm(e){for(let t of e.children)if(t.type==="visibility_modifier"&&t.text.startsWith("pub"))return!0;return!1}function Om(e,t,r){let n=r.trim();if(n.includes("{")&&n.includes("}")){let i=n.slice(0,n.indexOf("{")).replace(/::$/,"").trim(),o=n.slice(n.indexOf("{")+1,n.lastIndexOf("}")).trim();return D(o).flatMap(s=>{let a=s.trim();if(!a||a==="self")return[];let[c]=a.split(/\s+as\s+/),l=`${i}::${c?.trim()??a}`.replace(/::::/g,"::");return[Ti(e,t,l)]})}return[Ti(e,t,n)]}function Ti(e,t,r){return{specifier:r,sourcePath:ae(e,t,r)??ae(e,t,r.split("::").slice(0,-1).join("::"))}}function Te({language:e,extensions:t,imports:r,parseImports:n}){return{language:e,extensions:t,capabilities:{imports:r},parseImports:n}}function Aa(e,t){let r=t.toLowerCase();for(let n of e)for(let i of n.extensions)if(r.endsWith(i))return n;return null}var Lm={language:"javascript",extensions:Ae,capabilities:{imports:"ast-with-regex-fallback",reExports:"ast-with-regex-fallback"},parseImports:Ri,parseReExports:vi},Mm=Te({language:"python",extensions:Sr,imports:"ast-with-regex-fallback",parseImports:Ca}),jm=Te({language:"jvm",extensions:M,imports:"ast-dispatch-with-regex-fallback",parseImports:Ra}),Gm={language:"rust",extensions:xr,capabilities:{imports:"ast-with-regex-fallback",exports:"ast-with-regex-fallback"},parseImports:Na,parseExports:_a},Bm=Te({language:"ruby",extensions:br,imports:"ast-with-regex-fallback",parseImports:Pa}),$m=Te({language:"c/cpp",extensions:Ir,imports:"ast-with-regex-fallback",parseImports:ga}),qm=Te({language:"dotnet",extensions:Ie,imports:"ast-dispatch-with-regex-fallback",parseImports:ba}),Wm={language:"dart",extensions:Er,capabilities:{imports:"regex-only",exports:"regex-only"},parseImports:Sa,parseExports:xa},Vm=Te({language:"php",extensions:Fe,imports:"ast-with-regex-fallback",parseImports:Ta}),Um=Te({language:"clojure",extensions:tt,imports:"regex-only",parseImports:ha}),Hm=[Lm,Mm,jm,Gm,Bm,$m,qm,Wm,Vm,Um];function wi(e){return Aa(Hm,e)}var Ci={clearGroups:["whole-project","source-file"]},zm=w("source-imports",Ci),vI=w("source-exports",Ci),Jm=w("source-reexports",Ci),Da=vt({kind:"source-imports",invalidation:Tt("source-imports"),serialize:Km,deserialize:Xm}),Fa=vt({kind:"source-reexports",invalidation:Tt("source-reexports"),serialize:Ym,deserialize:Qm});function TI(e,t){let r=N(t);return Jm.get(e,r,()=>{let n=wi(r);if(!n?.parseReExports)return[];let i=j(e,r);if(!i)return[];let o=lt(e,r,i),s=li(e),a=Fa.read(e,r,o);if(a?.resolutionFingerprint===s)return a.reExports;let c=n.parseReExports(e,r,i);return Fa.write(e,r,o,{resolutionFingerprint:s,reExports:c}),c})}function wI(e,t){let r=N(t);return zm.get(e,r,()=>{let n=wi(r);if(!n)return[];let i=j(e,r);if(!i)return[];let o=lt(e,r,i),s=li(e),a=Da.read(e,r,o);if(a?.resolutionFingerprint===s)return a.imports;let c=n.parseImports(e,r,i);return Da.write(e,r,o,{resolutionFingerprint:s,imports:c}),c})}function Km(e){return JSON.stringify(e)}function Xm(e){try{let t=JSON.parse(e);return!xn(t)||typeof t.resolutionFingerprint!="string"||!Array.isArray(t.imports)?null:{resolutionFingerprint:t.resolutionFingerprint,imports:t.imports}}catch{return null}}function Ym(e){return JSON.stringify(e)}function Qm(e){try{let t=JSON.parse(e);return!xn(t)||typeof t.resolutionFingerprint!="string"||!Array.isArray(t.reExports)?null:{resolutionFingerprint:t.resolutionFingerprint,reExports:t.reExports}}catch{return null}}export{oo as a,Vt as b,pe as c,_g as d,Pc as e,Ki as f,Kr as g,Yr as h,cg as i,lg as j,Zr as k,go as l,hl as m,Sl as n,ry as o,zt as p,we as q,ho as r,ln as s,fy as t,xo as u,tr as v,lt as w,Io as x,Ty as y,vt as z,vS as A,Tt as B,Fs as C,Vd as D,Ee as E,xn as F,Cy as G,j as H,XS as I,Oe as J,re as K,xf as L,wf as M,TI as N,wI as O,_d as P,wS as Q,Dd as R,kS as S,NS as T,_S as U,DS as V,qt as W,Zi as X,Ay as Y,Gy as Z,Hy as _,zy as $,bc as aa,Eg as ba,Rg as ca,vg as da,Tg as ea,ih as fa,oh as ga,sh as ha,ah as ia,gh as ja,yh as ka,hh as la,Sh as ma,as as na,qu as oa,Ch as pa,Mn as qa,tS as ra,rS as sa,nS as ta,bt as ua,iS as va,oS as wa,sS as xa,dd as ya,pd as za,dS as Aa,pS as Ba,so as Ca,jg as Da,Gg as Ea,Bg as Fa,Hg as Ga,zg as Ha,Jg as Ia,P as Ja,hS as Ka,Rt as La,SS as Ma,Xg as Na};
146
+ //# sourceMappingURL=chunk-VAXNI5NE.js.map
@@ -0,0 +1,2 @@
1
+ import{isAbsolute as x,relative as P}from"path";var u=class extends Error{constructor(r,n){super(`refusing unsafe project file path ${JSON.stringify(r)} (${n})`);this.relativePath=r;this.reason=n;this.name="UnsafeProjectPathError"}relativePath;reason;code="SCIP_QUERY_UNSAFE_PROJECT_PATH"};function f(e){return e.replace(/\\/g,"/").replace(/^\.\//,"")}function M(e){return e.replace(/\\/g,"/")}function W(e,t){return f(e)===f(t)}function z(e,t){let r=P(e,t);return r===""||!r.startsWith("..")&&!x(r)}function N(e){if(!e)throw new u(e,"empty-path");if(e.includes("\0"))throw new u(e,"nul-byte");if(x(e)||/^[A-Za-z]:/.test(e)||e.startsWith("//")||e.startsWith("\\\\"))throw new u(e,"absolute-path");let t=f(e);if(t.split("/").some(n=>n===".."))throw new u(e,"parent-traversal");if(!t||t===".")throw new u(e,"empty-path");return t}import{closeSync as d,fstatSync as l,openSync as m,readFileSync as T,readSync as b}from"fs";import{createHash as L}from"crypto";var S=8*1024*1024,k=64*1024*1024,w=512*1024*1024,v=256*1024*1024,c=class extends Error{constructor(r,n,i,o,s){let a=i==="too-large"?`is ${o} bytes; the safety limit is ${s} bytes`:i==="not-regular"?"is not a regular file":"changed while it was being read";super(`${r} ${JSON.stringify(n)} ${a}`);this.inputKind=r;this.inputPath=n;this.reason=i;this.observedBytes=o;this.limitBytes=s;this.name="BoundedFileReadError"}inputKind;inputPath;reason;observedBytes;limitBytes;code="SCIP_QUERY_BOUNDED_FILE_READ"};function C(e,t){h(t.maxBytes);let r=String(e),n=m(e,"r");try{let i=l(n);F(i,t,r);let o=T(n),s=l(n);if(s.dev!==i.dev||s.ino!==i.ino||s.size!==i.size||o.byteLength!==i.size)throw new c(t.inputKind,r,"changed-during-read",s.size,t.maxBytes);return o}finally{d(n)}}function B(e,t,r="utf8"){return C(e,t).toString(r)}function E(e,t){return B(e,{maxBytes:S,inputKind:t})}function y(e,t){h(t.maxBytes);let r=[],n=Buffer.allocUnsafe(64*1024),i=0;for(;;){let o=b(e,n,0,n.length,null);if(o===0)break;if(i+=o,!Number.isSafeInteger(i)||i>t.maxBytes)throw new c(t.inputKind,`file descriptor ${e}`,"too-large",i,t.maxBytes);r.push(Buffer.from(n.subarray(0,o)))}return Buffer.concat(r,i)}function _(e,t,r="utf8"){return y(e,t).toString(r)}function R(e,t){let r=m(e,"r");try{return y(r,t)}finally{d(r)}}function I(e,t,r="utf8"){return R(e,t).toString(r)}function A(e,t,r){h(t.maxBytes);let n=String(e),i=m(e,"r");try{let o=l(i);F(o,t,n);let s=Buffer.allocUnsafe(Math.min(1024*1024,Math.max(1,o.size))),a=0;for(;a<o.size;){let p=b(i,s,0,Math.min(s.length,o.size-a),a);if(p===0)break;r(s.subarray(0,p)),a+=p}let g=l(i);if(g.dev!==o.dev||g.ino!==o.ino||g.size!==o.size||a!==o.size)throw new c(t.inputKind,n,"changed-during-read",g.size,t.maxBytes);return a}finally{d(i)}}function O(e,t){let r=L("sha256");return A(e,t,n=>r.update(n)),r.digest("hex")}function F(e,t,r){if(!e.isFile())throw new c(t.inputKind,r,"not-regular",Number(e.size),t.maxBytes);if(e.size>t.maxBytes)throw new c(t.inputKind,r,"too-large",Number(e.size),t.maxBytes)}function h(e){if(!Number.isSafeInteger(e)||e<0)throw new RangeError(`maxBytes must be a non-negative safe integer; received ${e}`)}function J(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Q(e){return typeof e=="string"&&Number.isFinite(Date.parse(e))}function V(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>=0}var Z=["typescript","javascript","java","scala","kotlin","rust","python","ruby","go","cpp","c","csharp","vb","dart","php","clojure"];export{u as a,f as b,M as c,W as d,z as e,N as f,J as g,Q as h,V as i,Z as j,S as k,k as l,w as m,v as n,c as o,C as p,B as q,E as r,_ as s,I as t,A as u,O as v};
2
+ //# sourceMappingURL=chunk-VVY2G5ET.js.map
@@ -1,4 +1,4 @@
1
- import{a as f}from"./chunk-54HA4ZXH.js";import{c as d}from"./chunk-NH5ALKPW.js";import{l as c}from"./chunk-U7DSEKOM.js";import{d as u}from"./chunk-XYADIZHU.js";function L(e,n,i={}){let t=f(e,n);if(!t)return null;let r=h(e,t);if(!r||e.isIgnored(r.relative_path))return null;let s=[],m=0,l=g(e,r.relative_path),p=i.semantic===!1?new Map:c(e,l);for(let o of l){let a=S(e,r,o,p.get(o.symbolId)??new Set);m+=a,s.push({symbol:o.symbol,shortName:u(o.symbol),startLine:o.startLine,endLine:o.endLine,externalConsumers:a,riskLevel:b(a)})}return{file:r.relative_path,symbols:s,totalExternalConsumers:m}}function h(e,n){return e.get(`SELECT id, relative_path FROM documents
1
+ import{a as f}from"./chunk-33XTHFKR.js";import{c as d}from"./chunk-2SNGN6U4.js";import{l as c}from"./chunk-E2LAW7SL.js";import{d as u}from"./chunk-RA3AYNWP.js";function L(e,n,i={}){let t=f(e,n);if(!t)return null;let r=h(e,t);if(!r||e.isIgnored(r.relative_path))return null;let s=[],m=0,l=g(e,r.relative_path),p=i.semantic===!1?new Map:c(e,l);for(let o of l){let a=S(e,r,o,p.get(o.symbolId)??new Set);m+=a,s.push({symbol:o.symbol,shortName:u(o.symbol),startLine:o.startLine,endLine:o.endLine,externalConsumers:a,riskLevel:b(a)})}return{file:r.relative_path,symbols:s,totalExternalConsumers:m}}function h(e,n){return e.get(`SELECT id, relative_path FROM documents
2
2
  WHERE relative_path = ?
3
3
  ${e.pathExclusionsFor("documents")}
4
4
  LIMIT 1`,n)??null}function g(e,n){return new d(e).definitionsForFile(n).sort((i,t)=>i.startLine-t.startLine||i.endLine-t.endLine)}function S(e,n,i,t){let r=e.all(`SELECT DISTINCT consumer_d.relative_path
@@ -8,4 +8,4 @@ import{a as f}from"./chunk-54HA4ZXH.js";import{c as d}from"./chunk-NH5ALKPW.js";
8
8
  WHERE m.symbol_id = ?
9
9
  AND m.role != 1
10
10
  AND c.document_id != ?`,i.symbolId,n.id);return new Set([...r.map(s=>s.relative_path),...[...t].filter(s=>s!==n.relative_path)]).size}function b(e){return e>10?"high":e>0?"medium":"low"}export{L as a};
11
- //# sourceMappingURL=chunk-WER3B7MI.js.map
11
+ //# sourceMappingURL=chunk-W3DBTGL4.js.map