scip-query 0.19.4 → 0.19.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (400) hide show
  1. package/CHANGELOG.md +75 -1
  2. package/README.md +242 -49
  3. package/dist/augment-vue-worker.js +1 -1
  4. package/dist/{chunk-2YU7I3QO.js → chunk-24QNP7MN.js} +2 -2
  5. package/dist/{chunk-CNKAGUPL.js → chunk-26X7KCJR.js} +2 -2
  6. package/dist/{chunk-GPBBJ5Y4.js → chunk-273W2U4Y.js} +3 -3
  7. package/dist/{chunk-7GXM52MI.js → chunk-2CVXCGL4.js} +2 -2
  8. package/dist/{chunk-ABMYA4TN.js → chunk-2EZSOTSY.js} +2 -2
  9. package/dist/{chunk-HKEHS2AS.js → chunk-2GSQR6YA.js} +2 -2
  10. package/dist/{chunk-FECYOO5O.js → chunk-2OXVAGGT.js} +2 -2
  11. package/dist/chunk-2ZOCHAL2.js +8 -0
  12. package/dist/{chunk-QGXBRIM5.js → chunk-336DC5NJ.js} +2 -2
  13. package/dist/chunk-35SQLYCQ.js +2 -0
  14. package/dist/{chunk-VXQNNXJE.js → chunk-3OIKRYU5.js} +2 -2
  15. package/dist/{chunk-52ZYCAEO.js → chunk-47X75ZKH.js} +2 -2
  16. package/dist/{chunk-NPKYOIFM.js → chunk-4CGVLUDP.js} +2 -2
  17. package/dist/chunk-4RI4BJGT.js +8 -0
  18. package/dist/{chunk-P2PC2WGR.js → chunk-52HQTTPB.js} +2 -2
  19. package/dist/{chunk-YNRNA5LK.js → chunk-5OC3HWP5.js} +2 -2
  20. package/dist/{chunk-STOL2BTL.js → chunk-6XFC7PQ5.js} +2 -2
  21. package/dist/{chunk-J77UIT3I.js → chunk-6XHTISLI.js} +2 -2
  22. package/dist/chunk-6YTSKJJ3.js +2 -0
  23. package/dist/{chunk-BTEE5NZQ.js → chunk-7E3TH5ZN.js} +2 -2
  24. package/dist/{chunk-X6D5IC6I.js → chunk-7LABSJSR.js} +2 -2
  25. package/dist/chunk-7Q6VYYCH.js +2 -0
  26. package/dist/{chunk-FWUUZTIO.js → chunk-A43URCQ3.js} +2 -2
  27. package/dist/chunk-A63U2W3P.js +3 -0
  28. package/dist/{chunk-3MJ5YA4Y.js → chunk-ADFSIJP2.js} +2 -2
  29. package/dist/chunk-AOLE4DYM.js +6 -0
  30. package/dist/chunk-APMMR5Y2.js +2 -0
  31. package/dist/chunk-B5MHCHP3.js +107 -0
  32. package/dist/{chunk-4RSI5EMG.js → chunk-CSTYYXKC.js} +2 -2
  33. package/dist/{chunk-25LPM4DG.js → chunk-CYJM7CYF.js} +2 -2
  34. package/dist/{chunk-S44IULR6.js → chunk-DD5BOU5I.js} +2 -2
  35. package/dist/{chunk-YGAGTIDK.js → chunk-DGMCFMPG.js} +7 -7
  36. package/dist/{chunk-UOAV44HR.js → chunk-E2ZXPB7J.js} +2 -2
  37. package/dist/{chunk-IZKFSVBV.js → chunk-EVOC5I5I.js} +2 -2
  38. package/dist/{chunk-XTX6QHOF.js → chunk-F42A3AKG.js} +2 -2
  39. package/dist/{chunk-Q4IIEGXJ.js → chunk-FHCTEANE.js} +2 -2
  40. package/dist/{chunk-3SVWW4PN.js → chunk-FKGN4A4E.js} +2 -2
  41. package/dist/{chunk-IG7N5ZIK.js → chunk-FQTPPXNA.js} +2 -2
  42. package/dist/{chunk-F6O7AAC3.js → chunk-G4UQL4CP.js} +2 -2
  43. package/dist/chunk-GA64UPMI.js +6 -0
  44. package/dist/{chunk-ZXJYMGD3.js → chunk-GK3GRUJX.js} +2 -2
  45. package/dist/chunk-HEBAY673.js +2 -0
  46. package/dist/chunk-HELS7KFF.js +2 -0
  47. package/dist/{chunk-B5NLK2B3.js → chunk-IPDCSB6N.js} +2 -2
  48. package/dist/{chunk-M7MTH5NR.js → chunk-IYAOX36F.js} +2 -2
  49. package/dist/{chunk-YVVCVR2L.js → chunk-J7VT2CRB.js} +2 -2
  50. package/dist/{chunk-4333ETTV.js → chunk-JELJLXEE.js} +2 -2
  51. package/dist/{chunk-LBMJEAEW.js → chunk-JERWGHQT.js} +2 -2
  52. package/dist/chunk-JJJCO4QC.js +945 -0
  53. package/dist/{chunk-6E7UTQY7.js → chunk-JZNLMHWY.js} +2 -2
  54. package/dist/{chunk-R4FQGQ4X.js → chunk-K42M2KWT.js} +2 -2
  55. package/dist/{chunk-H7UKLTWJ.js → chunk-KLVJABXA.js} +2 -2
  56. package/dist/chunk-KP4KBDVF.js +3 -0
  57. package/dist/{chunk-RV2FQIX3.js → chunk-LMFVTUW2.js} +2 -2
  58. package/dist/chunk-LRTP3DKL.js +3 -0
  59. package/dist/{chunk-U6WNH5GC.js → chunk-MGBJHRFB.js} +2 -2
  60. package/dist/{chunk-QDV6RDCP.js → chunk-MLGTCX56.js} +2 -2
  61. package/dist/{chunk-54HA4ZXH.js → chunk-N3SE646F.js} +2 -2
  62. package/dist/{chunk-KP6XRY5Z.js → chunk-NBRUH7OE.js} +2 -2
  63. package/dist/{chunk-M7AIS73L.js → chunk-NN4ZIRPK.js} +2 -2
  64. package/dist/{chunk-I5RJM53C.js → chunk-NQLSSVOB.js} +2 -2
  65. package/dist/{chunk-4SALD7RU.js → chunk-OBKDTVZ3.js} +2 -2
  66. package/dist/{chunk-GBQ5NYPR.js → chunk-OHWZKLVA.js} +6 -6
  67. package/dist/{chunk-6NSFJYRC.js → chunk-OP3MTFJR.js} +2 -2
  68. package/dist/{chunk-EOOJGLDU.js → chunk-OQ2A4G2G.js} +2 -2
  69. package/dist/{chunk-DLWR3NUU.js → chunk-P6HBYNBE.js} +2 -2
  70. package/dist/{chunk-QVWS2VWZ.js → chunk-PC44K7RF.js} +2 -2
  71. package/dist/{chunk-A2EZV2UM.js → chunk-QBYYWGAT.js} +2 -2
  72. package/dist/{chunk-QRGV2F7L.js → chunk-QHKUY4FW.js} +2 -2
  73. package/dist/chunk-QHRL4LKM.js +2 -0
  74. package/dist/{chunk-I5AWSI2G.js → chunk-QQWOFXNW.js} +2 -2
  75. package/dist/{chunk-WQTAC523.js → chunk-RBFFD4V2.js} +2 -2
  76. package/dist/{chunk-SOAT6NLA.js → chunk-RJHCPSZ7.js} +2 -2
  77. package/dist/{chunk-VGRICIQI.js → chunk-RWRLUZ6U.js} +2 -2
  78. package/dist/{chunk-4T3LTWUS.js → chunk-S2GP3CU3.js} +2 -2
  79. package/dist/{chunk-HEXVUYFQ.js → chunk-SHKZ7OVJ.js} +2 -2
  80. package/dist/{chunk-NSS46APD.js → chunk-TFUU5MQQ.js} +2 -2
  81. package/dist/{chunk-IUFDSKGG.js → chunk-TYQ76QHQ.js} +2 -2
  82. package/dist/{chunk-NRCXJDHL.js → chunk-U5CNPPTZ.js} +2 -2
  83. package/dist/{chunk-MITTUCEH.js → chunk-UQK5CRUK.js} +2 -2
  84. package/dist/{chunk-XLTP42QA.js → chunk-UUJBLG6J.js} +2 -2
  85. package/dist/chunk-UXP636P5.js +144 -0
  86. package/dist/{chunk-64RFXJT5.js → chunk-VEVBIAOJ.js} +6 -6
  87. package/dist/chunk-VKRQDBW5.js +9 -0
  88. package/dist/{chunk-C7NIYIQ4.js → chunk-VOQFGC2W.js} +4 -4
  89. package/dist/{chunk-DZ74OMG6.js → chunk-VP542C25.js} +2 -2
  90. package/dist/{chunk-Q3AFUTGB.js → chunk-WMXRRBII.js} +2 -2
  91. package/dist/{chunk-ZGZUZ7XE.js → chunk-WXAAURU7.js} +2 -2
  92. package/dist/chunk-X3NLZHPA.js +20 -0
  93. package/dist/{chunk-WER3B7MI.js → chunk-XF3KLXN3.js} +2 -2
  94. package/dist/{chunk-NH5ALKPW.js → chunk-XVJ3V7LM.js} +2 -2
  95. package/dist/{chunk-4XTA5OMB.js → chunk-YGQN3XGZ.js} +2 -2
  96. package/dist/{chunk-CFMXJPHH.js → chunk-YHXBD52M.js} +2 -2
  97. package/dist/{chunk-7B3UPBVA.js → chunk-YLVE3SXZ.js} +2 -2
  98. package/dist/{chunk-YIJ7ZAA4.js → chunk-YTUD45PU.js} +2 -2
  99. package/dist/{chunk-VTKGCT3V.js → chunk-YWB2EBNB.js} +2 -2
  100. package/dist/{chunk-UKZBVX4U.js → chunk-Z2LHPIOM.js} +2 -2
  101. package/dist/chunk-Z5QQPJ3U.js +30 -0
  102. package/dist/{chunk-NZL2DBT7.js → chunk-ZLJLE6LK.js} +2 -2
  103. package/dist/{chunk-XYADIZHU.js → chunk-ZTTISZ7J.js} +2 -2
  104. package/dist/cli.js +3 -3
  105. package/dist/command-descriptors-SJDZ7QGR.js +617 -0
  106. package/dist/{config-types-D20KuvvZ.d.ts → config-types-BWQ5xPGI.d.ts} +4 -0
  107. package/dist/{db-G_II8yXU.d.ts → db-B0r1o7Vt.d.ts} +18 -1
  108. package/dist/direct-navigation-HTKOZEOM.js +3 -0
  109. package/dist/{health-oblXYgkF.d.ts → health-CFnlCiTz.d.ts} +1 -1
  110. package/dist/index.d.ts +2 -2
  111. package/dist/index.js +1 -1
  112. package/dist/postinstall.js +1 -1
  113. package/dist/queries/affected.d.ts +2 -2
  114. package/dist/queries/affected.js +1 -1
  115. package/dist/queries/architecture.d.ts +2 -2
  116. package/dist/queries/architecture.js +1 -1
  117. package/dist/queries/bottlenecks.d.ts +2 -2
  118. package/dist/queries/bottlenecks.js +1 -1
  119. package/dist/queries/by-kind.d.ts +2 -2
  120. package/dist/queries/by-kind.js +1 -1
  121. package/dist/queries/call-graph.d.ts +2 -2
  122. package/dist/queries/call-graph.js +1 -1
  123. package/dist/queries/change-surface.d.ts +2 -2
  124. package/dist/queries/change-surface.js +1 -1
  125. package/dist/queries/cleanup-plan.d.ts +2 -2
  126. package/dist/queries/cleanup-plan.js +1 -1
  127. package/dist/queries/co-change.d.ts +2 -2
  128. package/dist/queries/co-change.js +1 -1
  129. package/dist/queries/code.d.ts +2 -2
  130. package/dist/queries/code.js +1 -1
  131. package/dist/queries/complexity-hotspots.d.ts +2 -2
  132. package/dist/queries/complexity-hotspots.js +1 -1
  133. package/dist/queries/complexity.d.ts +2 -2
  134. package/dist/queries/complexity.js +1 -1
  135. package/dist/queries/convergence.d.ts +2 -2
  136. package/dist/queries/convergence.js +1 -1
  137. package/dist/queries/coupling.d.ts +2 -2
  138. package/dist/queries/coupling.js +1 -1
  139. package/dist/queries/cycles.d.ts +2 -2
  140. package/dist/queries/cycles.js +1 -1
  141. package/dist/queries/dataflow.d.ts +2 -2
  142. package/dist/queries/dataflow.js +1 -1
  143. package/dist/queries/dead.d.ts +2 -2
  144. package/dist/queries/dead.js +1 -1
  145. package/dist/queries/decorative-checkers.d.ts +3 -3
  146. package/dist/queries/decorative-checkers.js +1 -1
  147. package/dist/queries/deep-chains.d.ts +2 -2
  148. package/dist/queries/deep-chains.js +1 -1
  149. package/dist/queries/deps.d.ts +2 -2
  150. package/dist/queries/deps.js +1 -1
  151. package/dist/queries/diff-gate.d.ts +30 -2
  152. package/dist/queries/diff-gate.js +1 -1
  153. package/dist/queries/diff-impact.d.ts +2 -2
  154. package/dist/queries/diff-impact.js +1 -1
  155. package/dist/queries/doc-drift.d.ts +2 -2
  156. package/dist/queries/doc-drift.js +1 -1
  157. package/dist/queries/drift.d.ts +2 -2
  158. package/dist/queries/drift.js +1 -1
  159. package/dist/queries/duplicate-bodies.d.ts +2 -2
  160. package/dist/queries/duplicate-bodies.js +1 -1
  161. package/dist/queries/extract-candidates.d.ts +2 -2
  162. package/dist/queries/extract-candidates.js +1 -1
  163. package/dist/queries/fan.d.ts +2 -2
  164. package/dist/queries/fan.js +1 -1
  165. package/dist/queries/files.d.ts +2 -2
  166. package/dist/queries/health.d.ts +3 -3
  167. package/dist/queries/health.js +1 -1
  168. package/dist/queries/hierarchy.d.ts +2 -2
  169. package/dist/queries/hierarchy.js +1 -1
  170. package/dist/queries/hotspots.d.ts +2 -2
  171. package/dist/queries/hotspots.js +1 -1
  172. package/dist/queries/imports.d.ts +2 -2
  173. package/dist/queries/imports.js +1 -1
  174. package/dist/queries/incomplete-migration.d.ts +2 -2
  175. package/dist/queries/incomplete-migration.js +1 -1
  176. package/dist/queries/index.d.ts +17 -3
  177. package/dist/queries/index.js +1 -1
  178. package/dist/queries/isolated.d.ts +2 -2
  179. package/dist/queries/isolated.js +1 -1
  180. package/dist/queries/locality-candidates.d.ts +2 -2
  181. package/dist/queries/locality-candidates.js +1 -1
  182. package/dist/queries/members.d.ts +2 -2
  183. package/dist/queries/members.js +1 -1
  184. package/dist/queries/methods.d.ts +2 -2
  185. package/dist/queries/methods.js +1 -1
  186. package/dist/queries/not-implemented.d.ts +3 -3
  187. package/dist/queries/not-implemented.js +1 -1
  188. package/dist/queries/outline.d.ts +2 -2
  189. package/dist/queries/outline.js +1 -1
  190. package/dist/queries/passthrough-candidates.d.ts +2 -2
  191. package/dist/queries/passthrough-candidates.js +1 -1
  192. package/dist/queries/plan-context.d.ts +2 -2
  193. package/dist/queries/plan-context.js +1 -1
  194. package/dist/queries/react-component-duplicates.d.ts +2 -2
  195. package/dist/queries/react-component-duplicates.js +1 -1
  196. package/dist/queries/react-hook-candidates.d.ts +2 -2
  197. package/dist/queries/react-hook-candidates.js +1 -1
  198. package/dist/queries/react-large-component-pressure.d.ts +2 -2
  199. package/dist/queries/react-large-component-pressure.js +1 -1
  200. package/dist/queries/recent-duplicates.d.ts +2 -2
  201. package/dist/queries/recent-duplicates.js +1 -1
  202. package/dist/queries/redundant-reexports.d.ts +2 -2
  203. package/dist/queries/redundant-reexports.js +1 -1
  204. package/dist/queries/refs.d.ts +2 -2
  205. package/dist/queries/refs.js +1 -1
  206. package/dist/queries/self-audit.d.ts +2 -2
  207. package/dist/queries/self-audit.js +1 -1
  208. package/dist/queries/similar-chains.d.ts +2 -2
  209. package/dist/queries/similar-chains.js +1 -1
  210. package/dist/queries/similar-files.d.ts +2 -2
  211. package/dist/queries/similar-files.js +1 -1
  212. package/dist/queries/similar-signatures.d.ts +2 -2
  213. package/dist/queries/similar-signatures.js +1 -1
  214. package/dist/queries/similar.d.ts +2 -2
  215. package/dist/queries/similar.js +1 -1
  216. package/dist/queries/slice.d.ts +2 -2
  217. package/dist/queries/slice.js +1 -1
  218. package/dist/queries/stale-abstractions.d.ts +2 -2
  219. package/dist/queries/stale-abstractions.js +1 -1
  220. package/dist/queries/stats.d.ts +2 -2
  221. package/dist/queries/stats.js +1 -1
  222. package/dist/queries/surface.d.ts +2 -2
  223. package/dist/queries/surface.js +1 -1
  224. package/dist/queries/symbols.d.ts +2 -2
  225. package/dist/queries/symbols.js +1 -1
  226. package/dist/queries/system.d.ts +2 -2
  227. package/dist/queries/system.js +1 -1
  228. package/dist/queries/test-quality.d.ts +2 -2
  229. package/dist/queries/test-quality.js +1 -1
  230. package/dist/queries/trace.d.ts +2 -2
  231. package/dist/queries/trace.js +1 -1
  232. package/dist/queries/twin-ab.d.ts +3 -3
  233. package/dist/queries/twin-ab.js +1 -1
  234. package/dist/queries/twin-drift.d.ts +2 -2
  235. package/dist/queries/twin-drift.js +1 -1
  236. package/dist/queries/unused-imports.d.ts +2 -2
  237. package/dist/queries/unused-imports.js +1 -1
  238. package/dist/queries/unused-params.d.ts +2 -2
  239. package/dist/queries/unused-params.js +1 -1
  240. package/dist/queries/vue-component-duplicates.d.ts +2 -2
  241. package/dist/queries/vue-component-duplicates.js +1 -1
  242. package/dist/queries/vue-composable-candidates.d.ts +2 -2
  243. package/dist/queries/vue-composable-candidates.js +1 -1
  244. package/dist/queries/vue-large-view-pressure.d.ts +2 -2
  245. package/dist/queries/vue-large-view-pressure.js +1 -1
  246. package/dist/queries/wrapper-candidates.d.ts +2 -2
  247. package/dist/queries/wrapper-candidates.js +1 -1
  248. package/dist/reindex-worker.js +23 -24
  249. package/dist/reindex.d.ts +10 -4
  250. package/dist/reindex.js +33 -38
  251. package/dist/runtime.d.ts +167 -11
  252. package/dist/runtime.js +3 -2
  253. package/dist/rust-semantic-session-server.js +1 -1
  254. package/dist/rust-semantic-session-worker.js +1 -1
  255. package/dist/rust-semantic-worker.js +1 -1
  256. package/dist/{scip-cli-kRpaexVJ.d.ts → scip-cli-DCvnlZCu.d.ts} +5 -1
  257. package/dist/watch-server.js +5 -5
  258. package/docs/AGENT_GUIDE.md +1 -1
  259. package/docs/AI_FAILURE_MODES.md +18 -18
  260. package/docs/API_EVOLUTION.md +71 -0
  261. package/docs/CLI_JSON_OUTPUT.md +83 -0
  262. package/docs/COMMAND_REFERENCE.md +10 -8
  263. package/docs/COMMITTED_RECORD_COMPATIBILITY.md +117 -0
  264. package/docs/CONFIGURATION_WRITE_SAFETY.md +130 -0
  265. package/docs/DETECTOR_GUIDE.md +47 -47
  266. package/docs/DURABILITY.md +103 -0
  267. package/docs/INDEX_GENERATIONS.md +121 -0
  268. package/docs/LOCK_PROTOCOL.md +133 -0
  269. package/docs/MAILBOX_LIFECYCLE.md +197 -0
  270. package/docs/REINDEX_METADATA_COMPATIBILITY.md +84 -0
  271. package/docs/RUST_DURABLE_SESSION_PROTOCOL.md +126 -0
  272. package/docs/TELEMETRY_RETENTION.md +72 -0
  273. package/docs/TIME_SEMANTICS.md +77 -0
  274. package/docs/WATCH_REFRESH_REQUESTS.md +110 -0
  275. package/docs/WINDOWS_SIDECAR_RELEASE.md +298 -0
  276. package/docs/analyzer-validation-ledger.md +24 -23
  277. package/docs/schemas/cli-json-envelope.schema.json +53 -0
  278. package/docs/schemas/npm-release-state.schema.json +146 -0
  279. package/docs/schemas/outcome-event-record.schema.json +39 -0
  280. package/docs/schemas/project-config.schema.json +247 -0
  281. package/docs/schemas/suppression-record.schema.json +31 -0
  282. package/docs/schemas/windows-sidecar-provenance.schema.json +137 -0
  283. package/package.json +15 -5
  284. package/scripts/build-scip-windows.mjs +180 -61
  285. package/scripts/scip-windows-provenance.mjs +364 -0
  286. package/scripts/verify-scip-windows.mjs +29 -0
  287. package/skills/_shared/SKILL.md +91 -242
  288. package/skills/_shared/agents/openai.yaml +1 -1
  289. package/skills/_shared/references/agent-contract-catalog.md +105 -0
  290. package/skills/_shared/references/command-catalog.md +118 -0
  291. package/skills/_shared/references/detector-precision-and-diffgate.md +59 -0
  292. package/skills/_shared/references/evidence-and-dead-code.md +25 -0
  293. package/skills/scip-audit/SKILL.md +76 -0
  294. package/skills/scip-audit/agents/openai.yaml +4 -0
  295. package/skills/scip-audit/references/claims.md +98 -0
  296. package/skills/scip-audit/references/cleanup.md +101 -0
  297. package/skills/scip-audit/references/directory.md +222 -0
  298. package/skills/scip-audit/references/frontend.md +130 -0
  299. package/skills/scip-audit/references/integrity.md +154 -0
  300. package/skills/scip-audit/references/maintainability.md +162 -0
  301. package/skills/scip-audit/references/twin-drift.md +104 -0
  302. package/skills/scip-diagnose/SKILL.md +52 -0
  303. package/skills/scip-diagnose/agents/openai.yaml +4 -0
  304. package/skills/scip-diagnose/references/debug.md +117 -0
  305. package/skills/{scip-probe-reachability/SKILL.md → scip-diagnose/references/probe-reachability.md} +12 -27
  306. package/skills/scip-diagnose/references/root-cause.md +145 -0
  307. package/skills/scip-diagnose/references/triage.md +119 -0
  308. package/skills/scip-explore/SKILL.md +53 -84
  309. package/skills/scip-explore/agents/openai.yaml +2 -2
  310. package/skills/scip-explore/references/diagrams.md +40 -0
  311. package/skills/scip-explore/references/language-playbook.md +49 -0
  312. package/skills/scip-improve/SKILL.md +56 -0
  313. package/skills/scip-improve/agents/openai.yaml +4 -0
  314. package/skills/scip-improve/references/cleanup-batches.md +53 -0
  315. package/skills/scip-improve/references/directory-moves.md +53 -0
  316. package/skills/scip-improve/references/doc-reconcile.md +30 -0
  317. package/skills/scip-improve/references/frontend-extraction.md +39 -0
  318. package/skills/scip-improve/references/maintainability-mechanism.md +43 -0
  319. package/skills/scip-improve/references/twin-drift.md +35 -0
  320. package/skills/scip-plan/SKILL.md +68 -0
  321. package/skills/scip-plan/agents/openai.yaml +4 -0
  322. package/skills/scip-plan/references/api-impact.md +19 -0
  323. package/skills/scip-plan/references/conductor.md +41 -0
  324. package/skills/scip-plan/references/high-assurance.md +43 -0
  325. package/skills/scip-plan/references/hyper-optimization.md +50 -0
  326. package/skills/scip-plan/references/tla-model.md +88 -0
  327. package/skills/scip-query/SKILL.md +52 -97
  328. package/skills/scip-query/agents/openai.yaml +2 -2
  329. package/skills/scip-setup/SKILL.md +65 -176
  330. package/skills/scip-setup/agents/openai.yaml +3 -3
  331. package/skills/scip-setup/references/bootstrap-workflow.md +120 -0
  332. package/skills/scip-setup/references/language-verification.md +61 -0
  333. package/skills/scip-setup/references/lifecycle-commands.md +119 -0
  334. package/skills/scip-setup/references/per-repo-triage.md +24 -0
  335. package/skills/scip-verify/SKILL.md +123 -70
  336. package/skills/scip-verify/agents/openai.yaml +2 -2
  337. package/skills/scip-verify/references/calibrate-detectors.md +170 -0
  338. package/dist/chunk-2CTX5CMX.js +0 -4
  339. package/dist/chunk-2Y373BDD.js +0 -2
  340. package/dist/chunk-C2QSK7E7.js +0 -2
  341. package/dist/chunk-D4U5Q3FT.js +0 -7
  342. package/dist/chunk-K2ERX4UT.js +0 -3
  343. package/dist/chunk-KHE7J5ZN.js +0 -3
  344. package/dist/chunk-L7SPDE73.js +0 -84
  345. package/dist/chunk-LHMNRHGV.js +0 -3
  346. package/dist/chunk-LM72NQ7T.js +0 -3
  347. package/dist/chunk-MSWVMDAH.js +0 -122
  348. package/dist/chunk-NH7WNNQC.js +0 -20
  349. package/dist/chunk-OMPZHGHO.js +0 -2
  350. package/dist/chunk-SVLTAG5O.js +0 -927
  351. package/dist/chunk-U7DSEKOM.js +0 -30
  352. package/dist/chunk-V27BEQJN.js +0 -7
  353. package/dist/chunk-VMNZB6WI.js +0 -4
  354. package/dist/chunk-XBN5VO53.js +0 -2
  355. package/dist/chunk-ZAIILQNP.js +0 -5
  356. package/dist/command-descriptors-MFU4BCJ7.js +0 -612
  357. package/dist/direct-navigation-MRMQFIRB.js +0 -3
  358. package/skills/scip-api-impact/SKILL.md +0 -139
  359. package/skills/scip-api-impact/agents/openai.yaml +0 -4
  360. package/skills/scip-calibrate/SKILL.md +0 -131
  361. package/skills/scip-calibrate/agents/openai.yaml +0 -4
  362. package/skills/scip-claim-audit/SKILL.md +0 -106
  363. package/skills/scip-claim-audit/agents/openai.yaml +0 -4
  364. package/skills/scip-cleanup-audit/SKILL.md +0 -126
  365. package/skills/scip-cleanup-audit/agents/openai.yaml +0 -4
  366. package/skills/scip-cleanup-improve/SKILL.md +0 -84
  367. package/skills/scip-cleanup-improve/agents/openai.yaml +0 -4
  368. package/skills/scip-concrete-plan/SKILL.md +0 -262
  369. package/skills/scip-concrete-plan/agents/openai.yaml +0 -4
  370. package/skills/scip-conductor/SKILL.md +0 -133
  371. package/skills/scip-conductor/agents/openai.yaml +0 -4
  372. package/skills/scip-debug/SKILL.md +0 -130
  373. package/skills/scip-debug/agents/openai.yaml +0 -4
  374. package/skills/scip-diagram/SKILL.md +0 -110
  375. package/skills/scip-diagram/agents/openai.yaml +0 -4
  376. package/skills/scip-directory-architecture/SKILL.md +0 -254
  377. package/skills/scip-directory-architecture/agents/openai.yaml +0 -4
  378. package/skills/scip-doc-reconcile/SKILL.md +0 -89
  379. package/skills/scip-doc-reconcile/agents/openai.yaml +0 -4
  380. package/skills/scip-hyper-optimization/SKILL.md +0 -156
  381. package/skills/scip-hyper-optimization/agents/openai.yaml +0 -4
  382. package/skills/scip-integrity-audit/SKILL.md +0 -152
  383. package/skills/scip-integrity-audit/agents/openai.yaml +0 -4
  384. package/skills/scip-language-playbook/SKILL.md +0 -106
  385. package/skills/scip-language-playbook/agents/openai.yaml +0 -4
  386. package/skills/scip-maintainability/SKILL.md +0 -158
  387. package/skills/scip-maintainability/agents/openai.yaml +0 -4
  388. package/skills/scip-probe-reachability/agents/openai.yaml +0 -4
  389. package/skills/scip-react-maintainability/SKILL.md +0 -101
  390. package/skills/scip-react-maintainability/agents/openai.yaml +0 -4
  391. package/skills/scip-root-cause/SKILL.md +0 -150
  392. package/skills/scip-root-cause/agents/openai.yaml +0 -4
  393. package/skills/scip-tla-model-system/SKILL.md +0 -148
  394. package/skills/scip-tla-model-system/agents/openai.yaml +0 -4
  395. package/skills/scip-triage-issue/SKILL.md +0 -126
  396. package/skills/scip-triage-issue/agents/openai.yaml +0 -4
  397. package/skills/scip-twin-drift/SKILL.md +0 -107
  398. package/skills/scip-twin-drift/agents/openai.yaml +0 -4
  399. package/skills/scip-vue-maintainability/SKILL.md +0 -107
  400. package/skills/scip-vue-maintainability/agents/openai.yaml +0 -4
package/dist/runtime.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- import { P as ProjectConfig, a as SupportedLanguage } from './config-types-D20KuvvZ.js';
2
- import { W as WatcherStatus, R as RefreshTrigger } from './scip-cli-kRpaexVJ.js';
3
- export { g as getScipVersion, i as isScipInstalled, p as printScipInstallInstructions } from './scip-cli-kRpaexVJ.js';
1
+ import { P as ProjectConfig, a as SupportedLanguage, T as TypeScriptProjectMode } from './config-types-BWQ5xPGI.js';
2
+ import { watch } from 'chokidar';
3
+ import { R as RefreshTrigger, W as WatcherStatus } from './scip-cli-DCvnlZCu.js';
4
+ export { g as getScipVersion, i as isScipInstalled, p as printScipInstallInstructions } from './scip-cli-DCvnlZCu.js';
4
5
 
5
6
  /**
6
7
  * Resolve all storage paths for a project's index files (cache dir, SQLite
@@ -31,11 +32,82 @@ interface WatcherOptions {
31
32
  projectRoot: string;
32
33
  config: ProjectConfig;
33
34
  languages?: SupportedLanguage[];
35
+ reindexRunner?: ReindexRunner;
36
+ subscriptionFactory?: WatchSubscriptionFactory;
37
+ clock?: WatchClock;
34
38
  onStatus?: (status: WatcherStatus) => void;
35
- onReindexComplete?: (durationMs: number) => boolean | void;
39
+ onReindexComplete?: (durationMs: number, trigger: RefreshTrigger) => boolean | void;
40
+ onReindexError?: (error: Error, trigger: RefreshTrigger) => void;
36
41
  onRefreshSuppressed?: (trigger: RefreshTrigger) => void;
37
42
  onError?: (error: Error) => void;
38
43
  }
44
+ interface ReindexRunRequest {
45
+ projectRoot: string;
46
+ config: ProjectConfig;
47
+ languages?: SupportedLanguage[];
48
+ pnpmWorkspaces: boolean;
49
+ typescriptProjectMode?: TypeScriptProjectMode;
50
+ typescriptProjects?: string[];
51
+ clojureConfigPath?: string;
52
+ indexerConcurrency?: number;
53
+ trigger: RefreshTrigger;
54
+ }
55
+ interface ReindexWorkerLaunch {
56
+ workerPath: string;
57
+ env: NodeJS.ProcessEnv;
58
+ }
59
+ interface ReindexRunner {
60
+ start(request: ReindexRunRequest): ReindexOperation;
61
+ }
62
+ interface ReindexDiagnostics {
63
+ stdoutTail: string;
64
+ stderrTail: string;
65
+ stdoutTruncated: boolean;
66
+ stderrTruncated: boolean;
67
+ }
68
+ type ReindexCancellationResult = {
69
+ state: 'exited';
70
+ diagnostics: ReindexDiagnostics;
71
+ } | {
72
+ state: 'degraded';
73
+ reason: string;
74
+ diagnostics: ReindexDiagnostics;
75
+ };
76
+ interface ReindexOperation {
77
+ completion: Promise<number>;
78
+ cancel(): Promise<ReindexCancellationResult>;
79
+ diagnostics(): ReindexDiagnostics;
80
+ }
81
+ type WatcherStopResult = {
82
+ state: 'stopped';
83
+ } | {
84
+ state: 'degraded';
85
+ reasons: string[];
86
+ };
87
+ interface ReindexRunnerOptions {
88
+ timeoutMs?: number;
89
+ terminationGraceMs?: number;
90
+ maxOutputBytes?: number;
91
+ resolveLaunch?: (request: ReindexRunRequest) => ReindexWorkerLaunch;
92
+ }
93
+ interface WatchSubscription {
94
+ on(event: 'all', listener: (eventName: string, path: string) => void): WatchSubscription;
95
+ on(event: 'error', listener: (error: unknown) => void): WatchSubscription;
96
+ close(): void | Promise<void>;
97
+ }
98
+ type WatchSubscriptionOptions = NonNullable<Parameters<typeof watch>[1]>;
99
+ type WatchSubscriptionFactory = (projectRoot: string, options: WatchSubscriptionOptions) => WatchSubscription;
100
+ type WatchTimer = ReturnType<typeof setTimeout>;
101
+ interface WatchClock {
102
+ /** Process-local elapsed clock used for debounce/cooldown control. */
103
+ now(): number;
104
+ /** Civil clock used only in externally visible status timestamps. */
105
+ wallNow?(): number;
106
+ setTimeout(callback: () => void, delayMs: number): WatchTimer;
107
+ clearTimeout(timer: WatchTimer): void;
108
+ setInterval(callback: () => void, intervalMs: number): WatchTimer;
109
+ clearInterval(timer: WatchTimer): void;
110
+ }
39
111
  /**
40
112
  * File watcher that triggers single-flight background reindexing.
41
113
  *
@@ -58,8 +130,15 @@ declare class Watcher {
58
130
  private indexerConcurrency?;
59
131
  private onStatus;
60
132
  private onReindexComplete;
133
+ private onReindexError;
61
134
  private onRefreshSuppressed;
62
135
  private onError;
136
+ private reindexRunner;
137
+ private subscriptionFactory;
138
+ private clock;
139
+ private activeOperation;
140
+ private stopPromise;
141
+ private stopInProgress;
63
142
  private status;
64
143
  private debounceTimer;
65
144
  private cooldownTimer;
@@ -79,7 +158,7 @@ declare class Watcher {
79
158
  /** Start watching for file changes */
80
159
  start(): void;
81
160
  /** Stop watching and clean up */
82
- stop(): void;
161
+ stop(): Promise<WatcherStopResult>;
83
162
  /** Request a refresh through the same single-flight/coalescing state machine used by file events. */
84
163
  requestRefresh(trigger: RefreshTrigger, opts?: {
85
164
  immediate?: boolean;
@@ -91,11 +170,9 @@ declare class Watcher {
91
170
  private relativeWatchPath;
92
171
  private scheduleReindex;
93
172
  private triggerReindex;
94
- /**
95
- * Run the reindex in a forked child process.
96
- * The child process uses the reindexer's own atomic publish path.
97
- */
98
- private runReindex;
173
+ private finishStop;
174
+ private wallNow;
175
+ private reindexRequest;
99
176
  private setStatus;
100
177
  private clearDebounceTimer;
101
178
  private clearCooldownTimer;
@@ -104,6 +181,8 @@ declare class Watcher {
104
181
  private readGitState;
105
182
  private clearGitPollTimer;
106
183
  }
184
+ declare function resolveReindexWorkerLaunch(request: ReindexRunRequest): ReindexWorkerLaunch;
185
+ declare function createReindexRunner(options?: ReindexRunnerOptions): ReindexRunner;
107
186
 
108
187
  interface InstallSkillsResult {
109
188
  installed: string[];
@@ -121,4 +200,81 @@ declare function installSkills(opts?: {
121
200
  quiet?: boolean;
122
201
  }): InstallSkillsResult;
123
202
 
124
- export { Watcher, type WatcherOptions, initProjectConfig, installSkills, loadProjectConfig, resolveIndexStoragePaths };
203
+ declare const CLI_JSON_ENVELOPE_KIND: "scip-query-result";
204
+ declare const LEGACY_CLI_JSON_ENVELOPE_SCHEMA_VERSION: 0;
205
+ declare const CURRENT_CLI_JSON_ENVELOPE_SCHEMA_VERSION: 1;
206
+ interface CliJsonProducer {
207
+ name: 'scip-query';
208
+ version: string;
209
+ }
210
+ /**
211
+ * One public machine-readable CLI response. The envelope is the stable
212
+ * transport contract; `result` remains the command-owned payload whose schema
213
+ * can advance independently through `resultSchemaVersion`.
214
+ */
215
+ interface CliJsonEnvelopeV1<Result = unknown> {
216
+ kind: typeof CLI_JSON_ENVELOPE_KIND;
217
+ schemaVersion: typeof CURRENT_CLI_JSON_ENVELOPE_SCHEMA_VERSION;
218
+ producer: CliJsonProducer;
219
+ command: string;
220
+ resultSchemaVersion: number;
221
+ evidence?: 'graph-fact' | 'heuristic' | 'mixed';
222
+ analysisBudget?: unknown;
223
+ args: readonly unknown[];
224
+ options: Readonly<Record<string, unknown>>;
225
+ result: Result;
226
+ coverage?: unknown;
227
+ agentResult?: unknown;
228
+ }
229
+ interface LegacyCliJsonEnvelope<Result = unknown> {
230
+ command: string;
231
+ args: readonly unknown[];
232
+ options: Readonly<Record<string, unknown>>;
233
+ result: Result;
234
+ evidence?: 'graph-fact' | 'heuristic' | 'mixed';
235
+ analysisBudget?: unknown;
236
+ coverage?: unknown;
237
+ agentResult?: unknown;
238
+ }
239
+ type CompatibleCliJsonEnvelope<Result = unknown> = {
240
+ kind: 'legacy';
241
+ schemaVersion: typeof LEGACY_CLI_JSON_ENVELOPE_SCHEMA_VERSION;
242
+ envelope: LegacyCliJsonEnvelope<Result>;
243
+ } | {
244
+ kind: 'supported';
245
+ schemaVersion: typeof CURRENT_CLI_JSON_ENVELOPE_SCHEMA_VERSION;
246
+ envelope: CliJsonEnvelopeV1<Result>;
247
+ };
248
+ type DecodedCliJsonEnvelope<Result = unknown> = CompatibleCliJsonEnvelope<Result> | {
249
+ kind: 'unsupported';
250
+ schemaVersion: number;
251
+ direction: 'older' | 'future';
252
+ producer?: {
253
+ name: string;
254
+ version: string;
255
+ };
256
+ } | {
257
+ kind: 'unsupported-result';
258
+ schemaVersion: typeof CURRENT_CLI_JSON_ENVELOPE_SCHEMA_VERSION;
259
+ command: string;
260
+ resultSchemaVersion: number;
261
+ supportedResultSchemaVersions: readonly number[];
262
+ } | {
263
+ kind: 'malformed';
264
+ reason: string;
265
+ };
266
+ /**
267
+ * Decodes the current envelope and the immediately preceding unversioned
268
+ * shape. Unknown additive fields are deliberately preserved on the returned
269
+ * object and ignored by compatibility checks.
270
+ */
271
+ declare function decodeCliJsonEnvelope<Result = unknown>(input: unknown): DecodedCliJsonEnvelope<Result>;
272
+ declare function requireCompatibleCliJsonEnvelope<Result = unknown>(input: unknown): CompatibleCliJsonEnvelope<Result>;
273
+ /**
274
+ * Result schemas start at v1. A command that advances independently adds its
275
+ * supported transition window here without forcing unrelated commands to
276
+ * change their payload contract.
277
+ */
278
+ declare function supportedCliResultSchemaVersions(command: string): readonly number[];
279
+
280
+ export { CLI_JSON_ENVELOPE_KIND, CURRENT_CLI_JSON_ENVELOPE_SCHEMA_VERSION, type CliJsonEnvelopeV1, type CliJsonProducer, type CompatibleCliJsonEnvelope, type DecodedCliJsonEnvelope, LEGACY_CLI_JSON_ENVELOPE_SCHEMA_VERSION, type LegacyCliJsonEnvelope, type ReindexCancellationResult, type ReindexDiagnostics, type ReindexOperation, type ReindexRunRequest, type ReindexRunner, type ReindexRunnerOptions, type ReindexWorkerLaunch, type WatchClock, type WatchSubscription, type WatchSubscriptionFactory, type WatchSubscriptionOptions, Watcher, type WatcherOptions, type WatcherStopResult, createReindexRunner, decodeCliJsonEnvelope, initProjectConfig, installSkills, loadProjectConfig, requireCompatibleCliJsonEnvelope, resolveIndexStoragePaths, resolveReindexWorkerLaunch, supportedCliResultSchemaVersions };
package/dist/runtime.js CHANGED
@@ -1,3 +1,4 @@
1
- import{b as D,c as N,d as F,f as m,l as y}from"./chunk-V27BEQJN.js";import{a as R}from"./chunk-DGAGY7RJ.js";import{e as f,f as x}from"./chunk-LM72NQ7T.js";import{readFileSync as W,writeFileSync as G,existsSync as P}from"fs";import{isAbsolute as he,join as E,relative as de,resolve as ge}from"path";var g=".scipquery.json",k=250,j=0,T=10*6e4,U={enabled:!1,debounceMs:k,cooldownMs:j,gitPollMs:2e3,idleTimeoutMs:T,autoRefresh:!0,ignore:[]},q=["typescript","javascript","java","scala","kotlin","rust","python","ruby","go","cpp","c","csharp","vb","dart","php","clojure"];var fe=new Set(q);function S(s){let e=E(s,g);if(!P(e))return{};try{let t=W(e,"utf-8");return JSON.parse(t)}catch(t){let r=t instanceof Error?t.message:String(t);throw t instanceof SyntaxError?new Error(`invalid ${g} at ${e}: ${r}`,{cause:t}):new Error(`unable to read ${g} at ${e}: ${r}`,{cause:t})}}function I(s){return{...U,...s.watch}}function L(s,e){let t=E(s,g);return P(t)||G(t,JSON.stringify({languages:e,watch:{enabled:!0,debounceMs:k,cooldownMs:j,gitPollMs:2e3,idleTimeoutMs:T,autoRefresh:!0}},null,2)+`
2
- `),t}import{fork as Y}from"child_process";import{statSync as K}from"fs";import{isAbsolute as B,join as H,relative as z}from"path";import{watch as X}from"chokidar";import J from"ignore";var v=class{projectRoot;config;watchConfig;languages;pnpmWorkspaces;typescriptProjectMode;typescriptProjects;clojureConfigPath;indexerConcurrency;onStatus;onReindexComplete;onRefreshSuppressed;onError;status={state:"idle"};debounceTimer=null;cooldownTimer=null;dirty=!1;changedFiles=0;pendingTrigger=null;reindexInFlight=!1;lastReindexEnd=0;fsWatchers=[];sourcePollingFallbackStarted=!1;gitPollTimer=null;lastGitState=null;gitignoreFilter;extraIgnore;stopped=!1;constructor(e){this.projectRoot=e.projectRoot,this.config=e.config,this.watchConfig=I(e.config),this.languages=e.languages,this.pnpmWorkspaces=e.config.indexer?.typescript?.pnpmWorkspaces??!1,this.typescriptProjectMode=e.config.indexer?.typescript?.projectMode,this.typescriptProjects=e.config.indexer?.typescript?.projects,this.clojureConfigPath=e.config.indexer?.clojure?.configPath,this.indexerConcurrency=e.config.indexerConcurrency,this.onStatus=e.onStatus??(()=>{}),this.onReindexComplete=e.onReindexComplete??(()=>{}),this.onRefreshSuppressed=e.onRefreshSuppressed??(()=>{}),this.onError=e.onError??(t=>console.error(t.message)),this.gitignoreFilter=R(e.projectRoot),this.extraIgnore=J(),this.watchConfig.ignore.length>0&&this.extraIgnore.add(this.watchConfig.ignore)}start(){this.stopped=!1,this.sourcePollingFallbackStarted=!1,this.setStatus({state:"idle"}),this.startGitStatePolling();try{this.startSourceWatcher()}catch(e){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(e)}`))}}stop(){this.stopped=!0;for(let e of this.fsWatchers)e.close();this.fsWatchers=[],this.clearDebounceTimer(),this.clearCooldownTimer(),this.clearGitPollTimer(),this.setStatus({state:"idle"})}requestRefresh(e,t={}){if(!t.immediate||this.reindexInFlight||this.status.state==="cooldown"){this.scheduleReindex(e);return}this.pendingTrigger=$(this.pendingTrigger,e),this.changedFiles+=1,this.clearDebounceTimer(),this.triggerReindex()}startSourceWatcher(e=!1){let t=X(this.projectRoot,{ignoreInitial:!0,ignored:(r,i)=>this.isIgnoredWatchPath(r,i?.isDirectory()??!1),usePolling:e,...e?{interval:500,binaryInterval:1e3}:{}});t.on("all",(r,i)=>{this.stopped||this.handleFileChange(i)}),t.on("error",r=>this.handleSourceWatcherError(t,r,e)),this.fsWatchers.push(t)}handleSourceWatcherError(e,t,r){if(r||this.sourcePollingFallbackStarted||!V(t)||this.stopped){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(t)}`));return}this.sourcePollingFallbackStarted=!0,this.fsWatchers=this.fsWatchers.filter(i=>i!==e),e.close();try{this.startSourceWatcher(!0)}catch(i){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(i)}`))}}isIgnoredWatchPath(e,t){let r=this.relativeWatchPath(e);if(!r)return!1;let i=t?`${r}/`:r;return i===".git/"||i.startsWith(".git/")?!0:this.gitignoreFilter.isIgnored(i)||this.extraIgnore.ignores(i)}handleFileChange(e){let t=this.relativeWatchPath(e);!t||t===".."||t.startsWith("../")||t===".git"||t.startsWith(".git/")||this.gitignoreFilter.isIgnored(t)||this.extraIgnore.ignores(t)||t.endsWith("index.db")||t.endsWith("index.scip")||t.endsWith("index.db.tmp")||t.endsWith(m)||t.endsWith(`${m}.previous`)||this.scheduleReindex({kind:"watch-source",detail:t})}relativeWatchPath(e){let t=B(e)?e:H(this.projectRoot,e);return z(this.projectRoot,t).replaceAll("\\","/")}scheduleReindex(e){if(this.pendingTrigger=$(this.pendingTrigger,e),this.changedFiles++,this.reindexInFlight){this.dirty=!0,this.setStatus({state:"indexing",startedAt:this.status.startedAt});return}if(this.status.state==="cooldown"){this.dirty=!0,this.setStatus({state:"cooldown",until:this.status.until,dirty:!0});return}this.clearDebounceTimer();let t=Date.now()+this.watchConfig.debounceMs;this.setStatus({state:"waiting",changedFiles:this.changedFiles,reindexAt:t}),this.debounceTimer=setTimeout(()=>{this.debounceTimer=null,this.triggerReindex()},this.watchConfig.debounceMs)}triggerReindex(){if(this.reindexInFlight||this.stopped)return;let e=Date.now()-this.lastReindexEnd;if(this.lastReindexEnd>0&&e<this.watchConfig.cooldownMs){let i=this.watchConfig.cooldownMs-e;this.dirty=!0;let o=Date.now()+i;this.setStatus({state:"cooldown",until:o,dirty:!0}),this.cooldownTimer=setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped&&(this.dirty=!1,this.triggerReindex())},i);return}this.reindexInFlight=!0,this.dirty=!1,this.changedFiles=0;let t=this.pendingTrigger??{kind:"watch-source"};this.pendingTrigger=null;let r=Date.now();this.setStatus({state:"indexing",startedAt:r}),this.runReindex(t).then(i=>{this.reindexInFlight=!1,this.lastReindexEnd=Date.now();let o=!1;try{o=this.onReindexComplete(i)===!0}catch(n){this.onError(n instanceof Error?n:new Error(String(n)))}if(this.dirty&&!this.stopped){if(o){let c=this.pendingTrigger??{kind:"unknown"};this.dirty=!1,this.changedFiles=0,this.pendingTrigger=null,this.onRefreshSuppressed(c),this.setStatus({state:"idle"});return}let n=Date.now()+this.watchConfig.cooldownMs;this.setStatus({state:"cooldown",until:n,dirty:!0}),this.cooldownTimer=setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped?(this.dirty=!1,this.triggerReindex()):this.setStatus({state:"idle"})},this.watchConfig.cooldownMs)}else this.setStatus({state:"idle"})}).catch(i=>{this.reindexInFlight=!1,this.lastReindexEnd=Date.now(),this.onError(i instanceof Error?i:new Error(String(i))),this.setStatus({state:"idle"})})}runReindex(e){return new Promise((t,r)=>{let i=Date.now(),o=S(this.projectRoot),n=Object.keys(o).length>0?o:this.config,c=y(this.projectRoot,n),a=n.indexer?.typescript,l=n.indexer?.clojure,p=Y(new URL("./reindex-worker.js",import.meta.url).pathname,[],{detached:!0,env:{...process.env,SCIP_REINDEX_PROJECT_ROOT:this.projectRoot,SCIP_REINDEX_OUTPUT_SCIP:c.indexPath,SCIP_REINDEX_OUTPUT_DB:c.dbPath,SCIP_REINDEX_LANGUAGES:(n.languages??this.languages)?.join(",")??"",SCIP_REINDEX_INDEXER_CONCURRENCY:String(n.indexerConcurrency??this.indexerConcurrency??""),SCIP_REINDEX_PNPM_WORKSPACES:a?.pnpmWorkspaces??this.pnpmWorkspaces?"1":"",SCIP_REINDEX_TYPESCRIPT_CONFIG:JSON.stringify({projectMode:a?.projectMode??this.typescriptProjectMode,projects:a?.projects??this.typescriptProjects??[]}),SCIP_REINDEX_CLOJURE_CONFIG_PATH:l?.configPath??this.clojureConfigPath??"",SCIP_REINDEX_TRIGGER_KIND:e.kind,SCIP_REINDEX_TRIGGER_DETAIL:e.detail??""},stdio:"pipe"});p.on("exit",u=>{u===0?t(Date.now()-i):r(new Error(`Reindex worker exited with code ${u}`))}),p.on("error",r)})}setStatus(e){this.status=e,this.onStatus(e)}clearDebounceTimer(){this.debounceTimer&&(clearTimeout(this.debounceTimer),this.debounceTimer=null)}clearCooldownTimer(){this.cooldownTimer&&(clearTimeout(this.cooldownTimer),this.cooldownTimer=null)}startGitStatePolling(){this.lastGitState=this.readGitState(),this.lastGitState&&(this.gitPollTimer=setInterval(()=>this.pollGitState(),this.watchConfig.gitPollMs),this.gitPollTimer.unref?.())}pollGitState(){let e=this.lastGitState,t=this.readGitState();if(!e||!t||this.stopped){this.lastGitState=t;return}this.lastGitState=t;let r=e.head!==t.head,i=e.indexPath!==t.indexPath||e.indexMtimeMs!==t.indexMtimeMs||e.indexSize!==t.indexSize;r&&i?this.scheduleReindex({kind:"watch-git-state",detail:"HEAD and index changed"}):r?this.scheduleReindex({kind:"watch-git-head",detail:"HEAD changed"}):i&&this.scheduleReindex({kind:"watch-git-index",detail:t.indexPath??"index changed"})}readGitState(){let e=f(this.projectRoot,["rev-parse","--git-path","index"]);if(!e)return null;let t=x(this.projectRoot,e),r={head:f(this.projectRoot,["rev-parse","--verify","HEAD"]),indexPath:t};try{let i=K(t);r.indexMtimeMs=i.mtimeMs,r.indexSize=i.size}catch{r.indexMtimeMs=void 0,r.indexSize=void 0}return r}clearGitPollTimer(){this.gitPollTimer&&(clearInterval(this.gitPollTimer),this.gitPollTimer=null)}};function $(s,e){return s?s.kind===e.kind?s.detail===e.detail?s:{kind:s.kind,detail:"multiple changes"}:{kind:"watch-git-state",detail:`${s.kind}, ${e.kind}`}:e}function V(s){return s instanceof Error&&"code"in s&&s.code==="EMFILE"||String(s).includes("EMFILE: too many open files")}import{existsSync as C,mkdirSync as Q,symlinkSync as Z,readlinkSync as A,unlinkSync as _,readdirSync as ee}from"fs";import{join as h,dirname as b,resolve as d,relative as te,isAbsolute as re}from"path";import{homedir as w,platform as ie}from"os";import{fileURLToPath as se}from"url";var ne=ie()==="win32",M=["_shared","scip-query","scip-setup","scip-calibrate","scip-cleanup-audit","scip-cleanup-improve","scip-integrity-audit","scip-twin-drift","scip-claim-audit","scip-probe-reachability","scip-hyper-optimization","scip-api-impact","scip-concrete-plan","scip-conductor","scip-debug","scip-explore","scip-root-cause","scip-triage-issue","scip-diagram","scip-doc-reconcile","scip-directory-architecture","scip-maintainability","scip-react-maintainability","scip-vue-maintainability","scip-verify","scip-language-playbook","scip-tla-model-system"];function oe(s={}){let e=s.quiet?()=>{}:console.log,t=se(import.meta.url),r=d(b(t),"..","skills"),i=[h(w(),".claude","skills"),h(w(),".codex","skills"),h(w(),".agents","skills")],o={installed:[],skipped:[],alreadyLinked:[],pruned:[]};for(let n of i){let c=b(n);if(!C(c))continue;Q(n,{recursive:!0});let a=ce(n);ae(n,r,a,o,e);for(let l of M){let p=h(r,l),u=h(n,l);if(!C(p)){o.skipped.push(`${a}/${l}`);continue}if(C(u)){try{let O=A(u);if(d(O)===d(p)){o.alreadyLinked.push(`${a}/${l}`),e(` ok: ${l} \u2192 ${a} (already linked)`);continue}}catch{o.skipped.push(`${a}/${l}`),e(` skip: ${l} \u2192 ${a} (exists, not a symlink)`);continue}_(u)}Z(p,u,ne?"junction":"dir"),o.installed.push(`${a}/${l}`),e(` done: ${l} \u2192 ${a}`)}}return o}function ae(s,e,t,r,i){let o=new Set(M);for(let n of ee(s)){if(o.has(n))continue;let c=h(s,n),a;try{a=d(b(c),A(c))}catch{continue}le(a,e)&&(_(c),r.pruned.push(`${t}/${n}`),i(` prune: ${n} \u2192 ${t} (removed stale scip-query skill link)`))}}function le(s,e){let t=te(d(e),d(s));return t===""||!t.startsWith("..")&&!re(t)}function ce(s){return s.includes(".codex")?"Codex":s.includes(".agents")?"Agents":"Claude"}export{v as Watcher,N as getScipVersion,L as initProjectConfig,oe as installSkills,D as isScipInstalled,S as loadProjectConfig,F as printScipInstallInstructions,y as resolveIndexStoragePaths};
1
+ import{b as ge,c as me,d as ye,f as L,k as V,q as b,s as W,t as D}from"./chunk-2ZOCHAL2.js";import{a as F}from"./chunk-DGAGY7RJ.js";import{h as R,k as N,l as M,m as $,o as w,p as A}from"./chunk-A63U2W3P.js";import{a as h,d as O}from"./chunk-35SQLYCQ.js";import{existsSync as Ie,readFileSync as je}from"fs";import{isAbsolute as bt,join as z,relative as kt,resolve as Pt}from"path";var p=1,f=2,ve="./node_modules/scip-query/docs/schemas/project-config.schema.json";function G(t){let e=t;if(typeof t=="string")try{e=JSON.parse(t)}catch(l){return{kind:"malformed",reason:`invalid JSON: ${l instanceof Error?l.message:String(l)}`}}if(!h(e))return{kind:"malformed",reason:"project config must be a JSON object"};let r=e.schemaVersion;if(r!==void 0&&!Number.isInteger(r))return{kind:"malformed",reason:"schemaVersion must be an integer"};let n=r===void 0?p:r;if(n!==p&&n!==f)return{kind:"unsupported",schemaVersion:n,direction:n<p?"older":"future"};let i=e.$schema;if(i!==void 0&&(typeof i!="string"||i.trim()===""))return{kind:"malformed",reason:"$schema must be a non-empty string when present"};let s=k(e),o=n!==f||typeof e.$schema!="string";return n===p?{kind:"legacy",sourceVersion:p,config:s,needsMigration:o}:{kind:"supported",sourceVersion:f,config:s,needsMigration:o}}function k(t){let e=t,{$schema:r,schemaVersion:n,...i}=e;return{$schema:typeof r=="string"&&r.trim()!==""?r:ve,schemaVersion:f,...i}}function q(t){return`${JSON.stringify(k(t),null,2)}
2
+ `}import{createHash as J}from"crypto";import{closeSync as Ce,fstatSync as U,openSync as Re,readFileSync as Se,rmSync as xe}from"fs";import{dirname as Ee}from"path";var we=2e3,be=10,ke=3,x=class extends Error{constructor(r,n,i){super(`Concurrent edit detected for ${r}; expected revision ${Y(n)}, but found ${Y(i)}. The latest file was left untouched.`);this.path=r;this.original=n;this.latest=i;this.name="FileRevisionConflictError"}path;original;latest};function B(t,e,r={}){let n=Pe(t,r.lockTimeoutMs??we,r.monotonicNow??R);try{let i=Math.max(0,Math.floor(r.maxRetries??ke));for(let s=0;;s+=1){let o=S(t),l=e(o,s);if(l.kind==="unchanged")return{changed:!1,attempts:s+1,previous:o,current:o};r.onBeforeCommit?.({attempt:s,snapshot:o,mutation:l});let c=S(t);if(!_e(o.revision,c.revision)){if(s<i)continue;throw new x(t,o.revision,c.revision)}try{Te(t,l,o.revision)}catch(u){if(u.code==="EEXIST"){let d=S(t);if(s<i)continue;throw new x(t,o.revision,d.revision)}throw u}return{changed:!0,attempts:s+1,previous:o,current:S(t)}}}finally{n.release()}}function S(t){for(let e=0;e<4;e+=1){let r;try{r=Re(t,"r");let n=H(U(r)),i=Se(r,"utf8"),s=H(U(r));if(!K(n,s))continue;return{path:t,text:i,revision:{exists:!0,hash:J("sha256").update(i).digest("hex"),identity:s}}}catch(n){if(n.code==="ENOENT")return{path:t,text:"",revision:{exists:!1,hash:J("sha256").update("").digest("hex")}};throw n}finally{r!==void 0&&Ce(r)}}throw new Error(`Could not read a stable revision of ${t}; the file is changing continuously.`)}function Pe(t,e,r){let n=`${t}.scip-query-write.lock`,i=r()+Math.max(0,e);for(;;){let s=L(n,{kind:"revisioned-file-mutation",detail:{target:t}});if(s.kind==="acquired")return s.lock;if(r()>=i)throw new Error(`Timed out after ${e}ms waiting to update ${t}; the file was left untouched.`);Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,be)}}function Te(t,e,r){if(e.kind==="delete"){if(!r.exists)return;xe(t),$(Ee(t));return}let n=e.mode??r.identity?.mode;r.exists?N(t,e.text,{durability:"durable",mode:n}):M(t,e.text,{durability:"durable",mode:n})}function _e(t,e){return t.exists===e.exists&&t.hash===e.hash&&(t.identity===void 0?e.identity===void 0:e.identity!==void 0&&K(t.identity,e.identity))}function H(t){return{dev:t.dev,ino:t.ino,size:t.size,mtimeMs:t.mtimeMs,mode:t.mode&511}}function K(t,e){return t.dev===e.dev&&t.ino===e.ino&&t.size===e.size&&t.mtimeMs===e.mtimeMs&&t.mode===e.mode}function Y(t){return t.exists?t.hash.slice(0,12):"<absent>"}var v=".scipquery.json",X=250,Q=0,Z=10*6e4,Oe={enabled:!1,debounceMs:X,cooldownMs:Q,gitPollMs:2e3,idleTimeoutMs:Z,autoRefresh:!0,ignore:[]};var jt=new Set(O);function P(t){let e=z(t,v);if(!Ie(e))return{};let r;try{r=je(e,"utf-8")}catch(n){let i=n instanceof Error?n.message:String(n);throw new Error(`unable to read ${v} at ${e}: ${i}`,{cause:n})}return $e(G(r),e,"read").config}function ee(t){return{...Oe,...t.watch}}function Ne(t,e){let r=z(t,v),n={languages:e,watch:{enabled:!0,debounceMs:X,cooldownMs:Q,gitPollMs:2e3,idleTimeoutMs:Z,autoRefresh:!0}};return B(r,i=>i.revision.exists?{kind:"unchanged"}:{kind:"write",text:Me(n)}),r}function Me(t){return q(t)}function $e(t,e,r){if(t.kind==="legacy"||t.kind==="supported")return t;if(t.kind==="malformed"){let i=r==="read"?`invalid ${v} at ${e}: ${t.reason}`:`Cannot update ${e}: the latest project config is ${t.reason}.`;throw new Error(`${i} The file was left untouched.`)}let n=r==="read"?`invalid ${v} at ${e}`:`Cannot update ${e}: the latest project config is invalid`;throw new Error(`${n} (unsupported ${t.direction} schemaVersion ${t.schemaVersion}; this scip-query reads legacy v${p} and current v${f}). Upgrade scip-query before retrying; the file was left untouched.`)}import{statSync as Ae}from"fs";import{basename as Fe,isAbsolute as Le,join as Ve,relative as We}from"path";import{watch as De}from"chokidar";import Ge from"ignore";var T=class{projectRoot;config;watchConfig;languages;pnpmWorkspaces;typescriptProjectMode;typescriptProjects;clojureConfigPath;indexerConcurrency;onStatus;onReindexComplete;onReindexError;onRefreshSuppressed;onError;reindexRunner;subscriptionFactory;clock;activeOperation=null;stopPromise=null;stopInProgress=!1;status={state:"idle"};debounceTimer=null;cooldownTimer=null;dirty=!1;changedFiles=0;pendingTrigger=null;reindexInFlight=!1;lastReindexEnd=0;fsWatchers=[];sourcePollingFallbackStarted=!1;gitPollTimer=null;lastGitState=null;gitignoreFilter;extraIgnore;stopped=!1;constructor(e){this.projectRoot=e.projectRoot,this.config=e.config,this.watchConfig=ee(e.config),this.languages=e.languages,this.pnpmWorkspaces=e.config.indexer?.typescript?.pnpmWorkspaces??!1,this.typescriptProjectMode=e.config.indexer?.typescript?.projectMode,this.typescriptProjects=e.config.indexer?.typescript?.projects,this.clojureConfigPath=e.config.indexer?.clojure?.configPath,this.indexerConcurrency=e.config.indexerConcurrency,this.onStatus=e.onStatus??(()=>{}),this.onReindexComplete=e.onReindexComplete??(()=>{}),this.onReindexError=e.onReindexError??(()=>{}),this.onRefreshSuppressed=e.onRefreshSuppressed??(()=>{}),this.onError=e.onError??(r=>console.error(r.message)),this.clock=e.clock??qe,this.reindexRunner=e.reindexRunner??ie(),this.subscriptionFactory=e.subscriptionFactory??Je,this.gitignoreFilter=F(e.projectRoot),this.extraIgnore=Ge(),this.watchConfig.ignore.length>0&&this.extraIgnore.add(this.watchConfig.ignore)}start(){if(this.stopInProgress)throw new Error("Cannot restart a watcher while its previous ownership is still draining.");this.stopped=!1,this.stopPromise=null,this.sourcePollingFallbackStarted=!1,this.setStatus({state:"idle"}),this.startGitStatePolling();try{this.startSourceWatcher()}catch(e){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(e)}`))}}stop(){if(this.stopPromise)return this.stopPromise;this.stopped=!0,this.stopInProgress=!0;let e=this.fsWatchers;this.fsWatchers=[],this.clearDebounceTimer(),this.clearCooldownTimer(),this.clearGitPollTimer();let r=this.activeOperation;return r&&this.setStatus({state:"draining",startedAt:this.wallNow(),reason:"waiting for the active reindex worker to exit"}),this.stopPromise=this.finishStop(e,r).finally(()=>{this.stopInProgress=!1}),this.stopPromise}requestRefresh(e,r={}){if(!this.stopped){if(!r.immediate||this.reindexInFlight||this.status.state==="cooldown"){this.scheduleReindex(e);return}this.pendingTrigger=re(this.pendingTrigger,e),this.changedFiles+=1,this.clearDebounceTimer(),this.triggerReindex()}}startSourceWatcher(e=!1){let r=this.subscriptionFactory(this.projectRoot,{ignoreInitial:!0,ignored:(n,i)=>this.isIgnoredWatchPath(n,i?.isDirectory()??!1),usePolling:e,...e?{interval:500,binaryInterval:1e3}:{}});r.on("all",(n,i)=>{this.stopped||this.handleFileChange(i)}),r.on("error",n=>this.handleSourceWatcherError(r,n,e)),this.fsWatchers.push(r)}handleSourceWatcherError(e,r,n){if(n||this.sourcePollingFallbackStarted||!Ke(r)||this.stopped){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(r)}`));return}this.sourcePollingFallbackStarted=!0,this.fsWatchers=this.fsWatchers.filter(i=>i!==e),e.close();try{this.startSourceWatcher(!0)}catch(i){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(i)}`))}}isIgnoredWatchPath(e,r){let n=this.relativeWatchPath(e);if(!n)return!1;let i=r?`${n}/`:n;return i===".git/"||i.startsWith(".git/")?!0:this.gitignoreFilter.isIgnored(i)||this.extraIgnore.ignores(i)}handleFileChange(e){let r=this.relativeWatchPath(e);!r||r===".."||r.startsWith("../")||r===".git"||r.startsWith(".git/")||this.gitignoreFilter.isIgnored(r)||this.extraIgnore.ignores(r)||r.endsWith("index.db")||r.endsWith("index.scip")||r.endsWith("index.db.tmp")||Fe(r).startsWith(V)||this.scheduleReindex({kind:"watch-source",detail:r})}relativeWatchPath(e){let r=Le(e)?e:Ve(this.projectRoot,e);return We(this.projectRoot,r).replaceAll("\\","/")}scheduleReindex(e){if(this.pendingTrigger=re(this.pendingTrigger,e),this.changedFiles++,this.reindexInFlight){this.dirty=!0,this.setStatus({state:"indexing",startedAt:this.status.startedAt});return}if(this.status.state==="cooldown"){this.dirty=!0,this.setStatus({state:"cooldown",until:this.status.until,dirty:!0});return}this.clearDebounceTimer();let r=this.wallNow()+this.watchConfig.debounceMs;this.setStatus({state:"waiting",changedFiles:this.changedFiles,reindexAt:r}),this.debounceTimer=this.clock.setTimeout(()=>{this.debounceTimer=null,this.triggerReindex()},this.watchConfig.debounceMs)}triggerReindex(){if(this.reindexInFlight||this.stopped)return;let e=this.clock.now()-this.lastReindexEnd;if(this.lastReindexEnd>0&&e<this.watchConfig.cooldownMs){let s=this.watchConfig.cooldownMs-e;this.dirty=!0;let o=this.wallNow()+s;this.setStatus({state:"cooldown",until:o,dirty:!0}),this.cooldownTimer=this.clock.setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped&&(this.dirty=!1,this.triggerReindex())},s);return}this.reindexInFlight=!0,this.dirty=!1,this.changedFiles=0;let r=this.pendingTrigger??{kind:"watch-source"};this.pendingTrigger=null;let n=this.wallNow();this.setStatus({state:"indexing",startedAt:n});let i=this.reindexRunner.start(this.reindexRequest(r));this.activeOperation=i,i.completion.then(s=>{if(this.reindexInFlight=!1,this.lastReindexEnd=this.clock.now(),this.stopped)return;let o=!1;try{o=this.onReindexComplete(s,r)===!0}catch(l){this.onError(l instanceof Error?l:new Error(String(l)))}if(this.dirty&&!this.stopped){if(o){let c=this.pendingTrigger??{kind:"unknown"};this.dirty=!1,this.changedFiles=0,this.pendingTrigger=null,this.onRefreshSuppressed(c),this.setStatus({state:"idle"});return}let l=this.wallNow()+this.watchConfig.cooldownMs;this.setStatus({state:"cooldown",until:l,dirty:!0}),this.cooldownTimer=this.clock.setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped?(this.dirty=!1,this.triggerReindex()):this.setStatus({state:"idle"})},this.watchConfig.cooldownMs)}else this.setStatus({state:"idle"})}).catch(s=>{if(this.reindexInFlight=!1,this.lastReindexEnd=this.clock.now(),this.stopped)return;let o=s instanceof Error?s:new Error(String(s));this.onReindexError(o,r),this.onError(o),this.setStatus({state:"idle"})}).finally(()=>{this.activeOperation===i&&(this.activeOperation=null)})}async finishStop(e,r){let n=[],i=r?r.cancel():null,s=await Promise.allSettled(e.map(o=>Promise.resolve().then(()=>o.close())));for(let o of s)o.status==="rejected"&&n.push(`watch subscription close failed: ${String(o.reason)}`);if(i)try{let o=await i;o.state==="degraded"&&n.push(o.reason)}catch(o){n.push(`reindex cancellation failed: ${o instanceof Error?o.message:String(o)}`)}return n.length>0?(this.setStatus({state:"draining",startedAt:this.wallNow(),reason:n.join("; ")}),{state:"degraded",reasons:n}):(this.setStatus({state:"idle"}),{state:"stopped"})}wallNow(){return this.clock.wallNow?.()??this.clock.now()}reindexRequest(e){return{projectRoot:this.projectRoot,config:this.config,languages:this.languages,pnpmWorkspaces:this.pnpmWorkspaces,typescriptProjectMode:this.typescriptProjectMode,typescriptProjects:this.typescriptProjects,clojureConfigPath:this.clojureConfigPath,indexerConcurrency:this.indexerConcurrency,trigger:e}}setStatus(e){this.status=e,this.onStatus(e)}clearDebounceTimer(){this.debounceTimer&&(this.clock.clearTimeout(this.debounceTimer),this.debounceTimer=null)}clearCooldownTimer(){this.cooldownTimer&&(this.clock.clearTimeout(this.cooldownTimer),this.cooldownTimer=null)}startGitStatePolling(){this.lastGitState=this.readGitState(),this.lastGitState&&(this.gitPollTimer=this.clock.setInterval(()=>this.pollGitState(),this.watchConfig.gitPollMs),this.gitPollTimer.unref?.())}pollGitState(){let e=this.lastGitState,r=this.readGitState();if(!e||!r||this.stopped){this.lastGitState=r;return}this.lastGitState=r;let n=e.head!==r.head,i=e.indexPath!==r.indexPath||e.indexMtimeMs!==r.indexMtimeMs||e.indexSize!==r.indexSize;n&&i?this.scheduleReindex({kind:"watch-git-state",detail:"HEAD and index changed"}):n?this.scheduleReindex({kind:"watch-git-head",detail:"HEAD changed"}):i&&this.scheduleReindex({kind:"watch-git-index",detail:r.indexPath??"index changed"})}readGitState(){let e=w(this.projectRoot,["rev-parse","--git-path","index"]);if(!e)return null;let r=A(this.projectRoot,e),n={head:w(this.projectRoot,["rev-parse","--verify","HEAD"]),indexPath:r};try{let i=Ae(r);n.indexMtimeMs=i.mtimeMs,n.indexSize=i.size}catch{n.indexMtimeMs=void 0,n.indexSize=void 0}return n}clearGitPollTimer(){this.gitPollTimer&&(this.clock.clearInterval(this.gitPollTimer),this.gitPollTimer=null)}};function ne(t){let{projectRoot:e,config:r,languages:n,pnpmWorkspaces:i,typescriptProjectMode:s,typescriptProjects:o,clojureConfigPath:l,indexerConcurrency:c,trigger:u}=t,d=P(e),a=Object.keys(d).length>0?d:r,C=b(e,a),E=a.indexer?.typescript,fe=a.indexer?.clojure;return{workerPath:new URL("./reindex-worker.js",import.meta.url).pathname,env:{...process.env,SCIP_REINDEX_PROJECT_ROOT:e,SCIP_REINDEX_OUTPUT_SCIP:C.indexPath,SCIP_REINDEX_OUTPUT_DB:C.dbPath,SCIP_REINDEX_LANGUAGES:(a.languages??n)?.join(",")??"",SCIP_REINDEX_INDEXER_CONCURRENCY:String(a.indexerConcurrency??c??""),SCIP_REINDEX_PNPM_WORKSPACES:E?.pnpmWorkspaces??i?"1":"",SCIP_REINDEX_TYPESCRIPT_CONFIG:JSON.stringify({projectMode:E?.projectMode??s,projects:E?.projects??o??[]}),SCIP_REINDEX_CLOJURE_CONFIG_PATH:fe?.configPath??l??"",SCIP_REINDEX_TRIGGER_KIND:u.kind,SCIP_REINDEX_TRIGGER_DETAIL:u.detail??"",SCIP_REINDEX_PROCESS_GROUP_LEADER:"1"}}}var qe={now:R,wallNow:()=>Date.now(),setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},Je=(t,e)=>De(t,e),Ue=15*6e4,He=1e3,Ye=64*1024;function Be(){return{stdoutTail:"",stderrTail:"",stdoutTruncated:!1,stderrTruncated:!1}}function te(t,e){let r=t instanceof Error?t.message:String(t),n=e.stderrTail.trim()||e.stdoutTail.trim();return n?`${r}
3
+ ${n}`:r}function ie(t={}){let e=t.timeoutMs??Ue,r=t.terminationGraceMs??He,n=t.maxOutputBytes??Ye,i=t.resolveLaunch??ne;return{start(s){let o=i(s),l=new AbortController,c=Be(),u=!1,d=D({command:process.execPath,args:[...process.execArgv,o.workerPath],label:"watch reindex worker",env:o.env,timeoutMs:e,terminationGraceMs:r,maxStdoutBytes:n,maxStderrBytes:n,outputLimitBehavior:"truncate-tail",signal:l.signal,detached:!0}).then(a=>{if(c={stdoutTail:a.stdout,stderrTail:a.stderr,stdoutTruncated:a.stdoutTruncated,stderrTruncated:a.stderrTruncated},a.status!==0)throw new Error(te(new Error(`Reindex worker exited with ${a.signal?`signal ${a.signal}`:`code ${a.status}`}`),c));return a.durationMs}).catch(a=>{throw a instanceof W&&(c={stdoutTail:a.stdout,stderrTail:a.stderr,stdoutTruncated:a.stdoutTruncated,stderrTruncated:a.stderrTruncated}),new Error(te(a,c),{cause:a})}).finally(()=>{u=!0});return{completion:d,async cancel(){u||l.abort();try{await d}catch{}return{state:"exited",diagnostics:c}},diagnostics:()=>c}}}}function re(t,e){return t?t.kind===e.kind?t.detail===e.detail?t:{kind:t.kind,detail:"multiple changes"}:{kind:"watch-git-state",detail:`${t.kind}, ${e.kind}`}:e}function Ke(t){return t instanceof Error&&"code"in t&&t.code==="EMFILE"||String(t).includes("EMFILE: too many open files")}import{existsSync as _,mkdirSync as ze,symlinkSync as Xe,readlinkSync as oe,unlinkSync as se,readdirSync as Qe}from"fs";import{join as g,dirname as j,resolve as m,relative as Ze,isAbsolute as et}from"path";import{homedir as I,platform as tt}from"os";import{fileURLToPath as rt}from"url";var nt=tt()==="win32",ae=["_shared","scip-query","scip-setup","scip-explore","scip-plan","scip-diagnose","scip-audit","scip-improve","scip-verify"];function it(t={}){let e=t.quiet?()=>{}:console.log,r=rt(import.meta.url),n=m(j(r),"..","skills"),i=[g(I(),".claude","skills"),g(I(),".codex","skills"),g(I(),".agents","skills")],s={installed:[],skipped:[],alreadyLinked:[],pruned:[]};for(let o of i){let l=j(o);if(!_(l))continue;ze(o,{recursive:!0});let c=at(o);ot(o,n,c,s,e);for(let u of ae){let d=g(n,u),a=g(o,u);if(!_(d)){s.skipped.push(`${c}/${u}`);continue}if(_(a)){try{let C=oe(a);if(m(C)===m(d)){s.alreadyLinked.push(`${c}/${u}`),e(` ok: ${u} \u2192 ${c} (already linked)`);continue}}catch{s.skipped.push(`${c}/${u}`),e(` skip: ${u} \u2192 ${c} (exists, not a symlink)`);continue}se(a)}Xe(d,a,nt?"junction":"dir"),s.installed.push(`${c}/${u}`),e(` done: ${u} \u2192 ${c}`)}}return s}function ot(t,e,r,n,i){let s=new Set(ae);for(let o of Qe(t)){if(s.has(o))continue;let l=g(t,o),c;try{c=m(j(l),oe(l))}catch{continue}st(c,e)&&(se(l),n.pruned.push(`${r}/${o}`),i(` prune: ${o} \u2192 ${r} (removed stale scip-query skill link)`))}}function st(t,e){let r=Ze(m(e),m(t));return r===""||!r.startsWith("..")&&!et(r)}function at(t){return t.includes(".codex")?"Codex":t.includes(".agents")?"Agents":"Claude"}var ue="scip-query-result",de=0,y=1,ct=1;function pe(t){if(!h(t))return{kind:"malformed",reason:"CLI JSON output must be an object."};let e=Object.hasOwn(t,"kind"),r=Object.hasOwn(t,"schemaVersion");if(!e&&!r){let o=ce(t);return o?{kind:"malformed",reason:`Legacy CLI JSON envelope: ${o}`}:{kind:"legacy",schemaVersion:de,envelope:t}}if(!e||!r)return{kind:"malformed",reason:"CLI JSON envelope must contain both kind and schemaVersion."};if(t.kind!==ue)return{kind:"malformed",reason:`Unsupported CLI JSON envelope kind: ${pt(t.kind)}.`};let n=t.schemaVersion;if(!Number.isSafeInteger(n)||Number(n)<1)return{kind:"malformed",reason:"CLI JSON envelope schemaVersion must be a positive safe integer."};if(n!==y)return{kind:"unsupported",schemaVersion:Number(n),direction:Number(n)<y?"older":"future",...le(t.producer)?{producer:t.producer}:{}};let i=ce(t);if(i)return{kind:"malformed",reason:`CLI JSON envelope v1: ${i}`};if(!le(t.producer))return{kind:"malformed",reason:"CLI JSON envelope v1: producer must identify scip-query and its non-empty version."};if(!dt(t.resultSchemaVersion))return{kind:"malformed",reason:"CLI JSON envelope v1: resultSchemaVersion must be a positive safe integer."};let s=he(t.command);return s.includes(t.resultSchemaVersion)?{kind:"supported",schemaVersion:y,envelope:t}:{kind:"unsupported-result",schemaVersion:y,command:t.command,resultSchemaVersion:t.resultSchemaVersion,supportedResultSchemaVersions:s}}function lt(t){let e=pe(t);if(e.kind==="legacy"||e.kind==="supported")return e;if(e.kind==="unsupported"){let r=e.producer?` from ${e.producer.name}@${e.producer.version}`:"";throw new Error(`Unsupported scip-query CLI JSON schemaVersion ${e.schemaVersion}${r}; this consumer supports the legacy unversioned envelope and schemaVersion ${y}.`)}throw e.kind==="unsupported-result"?new Error(`Unsupported resultSchemaVersion ${e.resultSchemaVersion} for scip-query command ${JSON.stringify(e.command)}; this consumer supports ${e.supportedResultSchemaVersions.join(", ")}.`):new Error(`Malformed scip-query CLI JSON envelope: ${e.reason}`)}function he(t){return ut[t]??[ct]}var ut={};function ce(t){return typeof t.command!="string"||t.command.length===0?"command must be a non-empty string.":Array.isArray(t.args)?h(t.options)?Object.hasOwn(t,"result")?null:"result is required.":"options must be an object.":"args must be an array."}function le(t){return h(t)&&t.name==="scip-query"&&typeof t.version=="string"&&t.version.length>0}function dt(t){return Number.isSafeInteger(t)&&Number(t)>0}function pt(t){return typeof t=="string"?JSON.stringify(t):String(t)}export{ue as CLI_JSON_ENVELOPE_KIND,y as CURRENT_CLI_JSON_ENVELOPE_SCHEMA_VERSION,de as LEGACY_CLI_JSON_ENVELOPE_SCHEMA_VERSION,T as Watcher,ie as createReindexRunner,pe as decodeCliJsonEnvelope,me as getScipVersion,Ne as initProjectConfig,it as installSkills,ge as isScipInstalled,P as loadProjectConfig,ye as printScipInstallInstructions,lt as requireCompatibleCliJsonEnvelope,b as resolveIndexStoragePaths,ne as resolveReindexWorkerLaunch,he as supportedCliResultSchemaVersions};
3
4
  //# sourceMappingURL=runtime.js.map
@@ -1,2 +1,2 @@
1
- import"./chunk-P5XHIJHI.js";import{a as b,b as v}from"./chunk-KHE7J5ZN.js";import{a as w,g as k}from"./chunk-HGFDYOVB.js";import d from"process";import{closeSync as ee,mkdirSync as y,openSync as re,readFileSync as O,readdirSync as ne,rmSync as h,writeFileSync as te}from"fs";import{dirname as se,resolve as c}from"path";import{pathToFileURL as oe}from"url";import{spawn as x}from"child_process";import{createHash as B,randomUUID as W}from"crypto";import{existsSync as L,mkdirSync as ge,readFileSync as he,realpathSync as Ee,rmSync as Ie}from"fs";import{tmpdir as _e}from"os";import{resolve as ke}from"path";var T=2;var g=class{constructor(r,n=z){this.createRequester=r;this.applyEnvironment=n}createRequester;applyEnvironment;requester=null;identityKey=null;semanticResponseCache=null;handle(r){this.applyEnvironment(r.workerEnvironment??{});let n;if(this.requester?this.identityKey!==r.identityKey?(this.semanticResponseCache=null,this.requester.shutdown(),this.requester=this.createRequester(),this.identityKey=r.identityKey,n="invalidated"):n="reused":(this.requester=this.createRequester(),this.identityKey=r.identityKey,n="created"),r.kind==="semantic"){let s=j(r.request),o=n==="reused"&&s!==null&&this.semanticResponseCache?.identityKey===r.identityKey&&this.semanticResponseCache.requestKey===s?this.semanticResponseCache.response:null;if(o)return M(!0,r.request.definitions.length),{session:n,response:o};let a=this.requester.requestSemantic(r.request,r.timeoutMs);return s!==null&&F(a)&&(this.semanticResponseCache={identityKey:r.identityKey,requestKey:s,response:a}),M(!1,r.request.definitions.length),{session:n,response:a}}return{session:n,response:this.requester.requestImportDefinitions(r.request,r.timeoutMs)}}shutdown(){this.requester?.shutdown(),this.requester=null,this.identityKey=null,this.semanticResponseCache=null}};function j(e){if(e.includeReferences===!1||e.includeCallees!==!0||e.includeSignatures===!0||(e.referenceDefinitions?.length??0)===0||(e.calleeDefinitions?.length??0)===0)return null;let{readinessDeadlineMs:r,...n}=e;return $(I(n))}function F(e){return e.available&&Array.isArray(e.callees)&&(e.incompleteReferenceSymbolIds?.length??0)===0}function M(e,r){w()&&k({type:"span",name:"rust.semantic.durable-session.response-cache",durationMs:0,ok:!0,hit:e,definitions:r})}function z(e){for(let r of Object.keys(process.env))Y(r)&&delete process.env[r];for(let[r,n]of Object.entries(e))n!==null&&(process.env[r]=n)}function K(e){return e==="HOME"||e==="PATH"||e.startsWith("CARGO_")||e.startsWith("RA_")||e.startsWith("RUST")}function Y(e){return K(e)||e.startsWith("SCIP_RUST_")||e==="SCIP_QUERY_PROFILE"||e==="SCIP_QUERY_PROFILE_CACHE_STATE"||e==="SCIP_QUERY_PROFILE_COMMAND"||e==="SCIP_QUERY_PROFILE_OUT"||e==="SCIP_QUERY_PROFILE_RUN_ID"||e==="SCIP_QUERY_PROFILE_WORKLOAD_IDENTITY"||e==="SCIP_QUERY_PROFILE_WORKLOAD_IDENTITY_KIND"||e==="SCIP_QUERY_PROFILE_MIN_MS"}var Ae={now:Date.now,randomId:W,isProcessAlive:b,spawnServer(e,r,n){if(!L(e))throw new Error(`Durable Rust semantic session helper was not found at ${e}. Run npm run build first.`);x(process.execPath,[e,r,n],{detached:!0,stdio:"ignore"}).unref()},sleep(e){let r=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(r,0,0,e)}};function I(e){return Array.isArray(e)?`[${e.map(I).join(",")}]`:e&&typeof e=="object"?`{${Object.entries(e).sort(([r],[n])=>r.localeCompare(n)).map(([r,n])=>`${JSON.stringify(r)}:${I(n)}`).join(",")}}`:JSON.stringify(e)}function $(e){return B("sha256").update(e).digest("hex")}import{existsSync as H,mkdtempSync as A,readFileSync as C,rmSync as D}from"fs";import{tmpdir as q}from"os";import{join as _}from"path";import{fileURLToPath as P,pathToFileURL as V}from"url";import{SHARE_ENV as J,Worker as Q}from"worker_threads";function U(e={}){let r=null,n=null,s=1,o=!1,a=()=>{n&&(D(n,{recursive:!0,force:!0}),n=null)},f=()=>{let t=r;r=null,t&&t.terminate(),a()},u=()=>{if(r)return r;let t=e.semanticWorkerPath?V(e.semanticWorkerPath):Z();if(!H(P(t)))throw new Error(`Rust semantic session worker was not found at ${P(t)}. Run npm run build before using built semantic Rust queries.`);return n=A(_(q(),"scip-query-rust-session-")),r=new Q(t,e.shareEnvironment?{env:J}:void 0),r.unref(),r},l=()=>{let t=n??A(_(q(),"scip-query-rust-session-"));return n=t,_(t,`${s++}.json`)};return{requestSemantic(t,i){if(o)throw new Error("Rust semantic session was already disposed.");let R=u(),p=l(),S=new SharedArrayBuffer(4),E=new Int32Array(S);if(R.postMessage({kind:"semantic",request:t,responsePath:p,sharedBuffer:S}),Atomics.wait(E,0,0,i)==="timed-out")throw f(),new Error(`Rust semantic session worker timed out after ${(i/1e3).toFixed(0)}s`);try{let m=G(C(p,"utf8"));if(!m.ok)throw new Error(m.error);return m.response}finally{D(p,{force:!0})}},requestImportDefinitions(t,i){if(o)throw new Error("Rust semantic session was already disposed.");let R=u(),p=l(),S=new SharedArrayBuffer(4),E=new Int32Array(S);if(R.postMessage({kind:"import-definitions",request:t,responsePath:p,sharedBuffer:S}),Atomics.wait(E,0,0,i)==="timed-out")throw f(),new Error(`Rust semantic import-definition session worker timed out after ${(i/1e3).toFixed(0)}s`);try{let m=X(C(p,"utf8"));if(!m.ok)throw new Error(m.error);return m.response}finally{D(p,{force:!0})}},shutdown(){if(o)return;if(o=!0,!r){a();return}let t=l(),i=new SharedArrayBuffer(4),R=new Int32Array(i);r.postMessage({kind:"shutdown",responsePath:t,sharedBuffer:i}),Atomics.wait(R,0,0,5e3),f()}}}function G(e){let r=JSON.parse(e);if(!r||typeof r!="object")return{ok:!1,error:"Rust semantic session worker wrote a non-object response."};let n=r;return n.ok===!0&&"response"in n?{ok:!0,response:n.response}:{ok:!1,error:typeof r.error=="string"?r.error:"Rust semantic session worker failed."}}function X(e){let r=JSON.parse(e);if(!r||typeof r!="object")return{ok:!1,error:"Rust semantic session worker wrote a non-object response."};let n=r;return n.ok===!0&&"response"in n?{ok:!0,response:n.response}:{ok:!1,error:typeof r.error=="string"?r.error:"Rust semantic session worker failed."}}function Z(){return new URL("./rust-semantic-session-worker.js",import.meta.url)}var ie=10*6e4,ae=10,ue=1e3;function le(e,r,n={}){let s=c(e,"requests"),o=c(e,"responses");y(s,{recursive:!0}),y(o,{recursive:!0});let a=0;for(let f of ne(s).filter(u=>u.endsWith(".json")).sort()){let u=c(s,f),l=null;try{l=fe(O(u,"utf8")),n.beforeRequest?.(l.request);let t=r.handle(l.request);v(c(o,`${l.id}.json`),{ok:!0,...t})}catch(t){let i=l?.id??f.slice(0,-5);v(c(o,`${i}.json`),{ok:!1,error:t instanceof Error?t.message:String(t)})}finally{h(u,{force:!0}),a+=1}}return a}async function ce(e,r){y(c(e,"requests"),{recursive:!0}),y(c(e,"responses"),{recursive:!0});let n=c(e,"server.lock");if(!Re(n))return;let s=new g(()=>U({semanticWorkerPath:r,shareEnvironment:!0})),o=!1,a=Date.now(),f=0,u,l=()=>{o=!0};d.once("SIGINT",l),d.once("SIGTERM",l);let t=(i=!1)=>{let R=Date.now();!i&&R-f<ue||(f=R,v(c(e,"server.json"),{protocolVersion:T,pid:d.pid,heartbeatAtMs:R,...u===void 0?{}:{busyUntilMs:u}}))};try{t(!0);let i=pe();for(;!o&&Date.now()-a<i;)le(e,s,{beforeRequest(p){u=Date.now()+p.timeoutMs+5e3,t(!0)}})>0?(a=Date.now(),u=void 0,t(!0)):t(),await me(ae)}finally{s.shutdown(),h(c(e,"server.json"),{force:!0}),h(n,{force:!0})}}function Re(e){y(se(e),{recursive:!0});for(let r=0;r<2;r+=1)try{let n=re(e,"wx");return te(n,String(d.pid)),ee(n),!0}catch{let n=de(e);if(n!==null&&b(n))return!1;h(e,{force:!0})}return!1}function de(e){try{let r=Number(O(e,"utf8"));return Number.isInteger(r)&&r>0?r:null}catch{return null}}function fe(e){let r=JSON.parse(e);if(typeof r.id!="string"||!r.request||typeof r.request!="object")throw new Error("Durable Rust semantic helper received an invalid mailbox request.");return{id:r.id,request:r.request}}function pe(){let e=Number(d.env.SCIP_RUST_SEMANTIC_DURABLE_IDLE_MS);return Number.isInteger(e)&&e>=0?e:ie}function me(e){return new Promise(r=>setTimeout(r,e))}var Se=d.argv[1]?oe(c(d.argv[1])).href:null;if(Se===import.meta.url){let e=d.argv[2],r=d.argv[3];!e||!r?(console.error("durable-rust-session: expected <session-dir> <semantic-worker-path>"),d.exitCode=1):await ce(e,r)}export{le as processDurableRustSessionRequests};
1
+ import"./chunk-P5XHIJHI.js";import{A as G,B as X,C as Z,a as D,c as j,d as I,e as v,f as K,i as E,j as k,l as Y,q as H,r as A,s as _,t as C,u as P,v as N,w as $,y as Q,z as J}from"./chunk-VKRQDBW5.js";import{a as V,g as z}from"./chunk-HGFDYOVB.js";import{a as g}from"./chunk-APMMR5Y2.js";import p from"process";import{randomUUID as Ue}from"crypto";import{rmSync as Oe}from"fs";import{resolve as T}from"path";import{pathToFileURL as Be}from"url";import{spawn as Ie}from"child_process";import{createHash as ge,randomUUID as Me}from"crypto";import{existsSync as De,readFileSync as pn,realpathSync as Rn,rmSync as fn}from"fs";import{tmpdir as yn}from"os";import{resolve as Sn}from"path";import{createHash as Re}from"crypto";import{resolve as fe}from"path";var m=3;function q(e){return Re("sha256").update(A({kind:"scip-query-durable-rust-mailbox",protocolVersion:m,sessionDir:fe(e)})).digest("hex")}function B(e,n){if(!D(e)||typeof e.id!="string"||!e.id)return w("Durable Rust semantic helper received an invalid mailbox request.");if(e.id!==n.claimRequestId)return w("Durable Rust semantic request identity does not match its mailbox path.");if(e.protocolVersion===void 0){if(e.mailboxVersion!==void 0||e.operationKey!==void 0||e.clientId!==void 0||e.enqueuedAtMs!==void 0||e.deadlineAtMs!==void 0||e.sessionIdentity!==void 0)return w("Durable Rust semantic helper received a partially versioned request without a protocol version.");let o=ee(e.request);if(!o)return w("Durable Rust semantic helper received an invalid legacy request kind or payload.");let c=n.nowMs+Math.max(1,o.timeoutMs);return{ok:!0,compatibility:"legacy-v2",value:{mailboxVersion:_,protocolVersion:m,id:e.id,operationKey:N("rust-semantic-v2",{id:e.id,request:o}),clientId:"legacy-v2",enqueuedAtMs:n.nowMs,deadlineAtMs:c,sessionIdentity:n.sessionIdentity,request:o}}}let t=me(e,n);if(!t.ok)return t;if(e.protocolVersion!==m)return{ok:!1,code:"unsupported-protocol",error:`Durable Rust semantic helper does not support mailbox protocol ${String(e.protocolVersion)}.`,responseIdentity:t.responseIdentity};let i=ee(e.request);return i?t.operationKey!==N("rust-semantic-v3",i)?{ok:!1,code:"malformed-request",error:"Durable Rust semantic helper received a mismatched mailbox operation identity.",responseIdentity:t.responseIdentity}:t.deadlineAtMs-t.enqueuedAtMs!==i.timeoutMs?{ok:!1,code:"malformed-request",error:"Durable Rust semantic helper received a deadline that does not match the request timeout.",responseIdentity:t.responseIdentity}:t.deadlineAtMs<n.nowMs?{ok:!1,code:"expired-request",error:"Durable Rust semantic request expired before processing.",responseIdentity:t.responseIdentity}:{ok:!0,compatibility:t.priorSessionIdentity?"prior-v3":"current-v3",value:{mailboxVersion:_,protocolVersion:m,id:e.id,operationKey:t.operationKey,clientId:t.clientId,enqueuedAtMs:t.enqueuedAtMs,deadlineAtMs:t.deadlineAtMs,sessionIdentity:n.sessionIdentity,request:i}}:{ok:!1,code:"malformed-request",error:"Durable Rust semantic helper received an invalid request kind or payload.",responseIdentity:t.responseIdentity}}function me(e,n){if(e.mailboxVersion!==_||typeof e.protocolVersion!="number"||!Number.isInteger(e.protocolVersion)||typeof e.operationKey!="string"||!ne(e.operationKey)||e.id!==$(e.operationKey)||typeof e.clientId!="string"||!e.clientId||typeof e.enqueuedAtMs!="number"||!Number.isFinite(e.enqueuedAtMs)||typeof e.deadlineAtMs!="number"||!Number.isFinite(e.deadlineAtMs)||e.deadlineAtMs<e.enqueuedAtMs||e.sessionIdentity!==void 0&&(typeof e.sessionIdentity!="string"||!ne(e.sessionIdentity))||e.sessionIdentity===void 0&&e.protocolVersion!==m)return w("Durable Rust semantic helper received an invalid mailbox lifecycle.");let t={id:n.claimRequestId,sessionIdentity:n.sessionIdentity,deadlineAtMs:e.deadlineAtMs};return e.sessionIdentity!==void 0&&e.sessionIdentity!==n.sessionIdentity?{ok:!1,code:"malformed-request",error:"Durable Rust semantic request belongs to a different mailbox session.",responseIdentity:t}:{ok:!0,responseIdentity:t,operationKey:e.operationKey,clientId:e.clientId,enqueuedAtMs:e.enqueuedAtMs,deadlineAtMs:e.deadlineAtMs,priorSessionIdentity:e.sessionIdentity===void 0}}function ee(e){return!D(e)||typeof e.identityKey!="string"||!e.identityKey||!v(e.timeoutMs)||e.workerEnvironment!==void 0&&!j(e.workerEnvironment)?null:e.kind==="semantic"&&ye(e.request)?{kind:"semantic",identityKey:e.identityKey,...e.workerEnvironment===void 0?{}:{workerEnvironment:e.workerEnvironment},request:e.request,timeoutMs:e.timeoutMs}:e.kind==="import-definitions"&&be(e.request)?{kind:"import-definitions",identityKey:e.identityKey,...e.workerEnvironment===void 0?{}:{workerEnvironment:e.workerEnvironment},request:e.request,timeoutMs:e.timeoutMs}:null}function ye(e){return!D(e)||!h(e.projectRoot)||!h(e.rustAnalyzerBinary)||!re(e.definitions)?!1:U(e.referenceDefinitions)&&U(e.calleeDefinitions)&&U(e.signatureDefinitions)&&b(e.requestTimeoutMs)&&b(e.readinessDeadlineMs)&&b(e.referenceRetryTimeoutMs)&&b(e.diagnosticsTimeoutMs)&&b(e.settleDelayMs)&&se(e.concurrency)&&O(e.includeReferences)&&O(e.includeCallees)&&O(e.includeSignatures)}function be(e){return!D(e)||!h(e.projectRoot)||!h(e.rustAnalyzerBinary)||!h(e.file)||!Array.isArray(e.positions)||!e.positions.every(n=>D(n)&&h(n.id)&&h(n.file)&&I(n.line)&&I(n.column))?!1:b(e.requestTimeoutMs)&&b(e.readinessDeadlineMs)&&b(e.diagnosticsTimeoutMs)&&b(e.settleDelayMs)&&se(e.concurrency)}function re(e){return Array.isArray(e)&&e.every(Se)}function U(e){return e===void 0||re(e)}function Se(e){return D(e)&&I(e.symbolId)&&I(e.documentId)&&I(e.startLine)&&te(e.startChar)&&I(e.endLine)&&te(e.endChar)&&typeof e.symbol=="string"&&typeof e.relativePath=="string"&&typeof e.leaf=="string"&&(e.parentTypeName===null||typeof e.parentTypeName=="string")&&typeof e.isFunctionLike=="boolean"&&typeof e.isTypeLike=="boolean"&&(e.kind===null||Number.isSafeInteger(e.kind))&&(e.documentation===null||typeof e.documentation=="string")&&(e.enclosingSymbol===null||typeof e.enclosingSymbol=="string")}function w(e){return{ok:!1,code:"malformed-request",error:e}}function ne(e){return/^[a-f0-9]{64}$/.test(e)}function h(e){return typeof e=="string"&&e.length>0}function se(e){return e===void 0||v(e)}function te(e){return e===void 0||I(e)}function b(e){return e===void 0||K(e)}function O(e){return e===void 0||typeof e=="boolean"}var x=class{constructor(n,t=we){this.createRequester=n;this.applyEnvironment=t}createRequester;applyEnvironment;requester=null;identityKey=null;semanticResponseCache=null;handle(n){this.applyEnvironment(n.workerEnvironment??{});let t;if(this.requester?this.identityKey!==n.identityKey?(this.semanticResponseCache=null,this.requester.shutdown(),this.requester=this.createRequester(),this.identityKey=n.identityKey,t="invalidated"):t="reused":(this.requester=this.createRequester(),this.identityKey=n.identityKey,t="created"),n.kind==="semantic"){let i=he(n.request),o=t==="reused"&&i!==null&&this.semanticResponseCache?.identityKey===n.identityKey&&this.semanticResponseCache.requestKey===i?this.semanticResponseCache.response:null;if(o)return oe(!0,n.request.definitions.length),{session:t,response:o};let c=this.requester.requestSemantic(n.request,n.timeoutMs);return i!==null&&Ee(c)&&(this.semanticResponseCache={identityKey:n.identityKey,requestKey:i,response:c}),oe(!1,n.request.definitions.length),{session:t,response:c}}return{session:t,response:this.requester.requestImportDefinitions(n.request,n.timeoutMs)}}shutdown(){this.requester?.shutdown(),this.requester=null,this.identityKey=null,this.semanticResponseCache=null}};function he(e){if(e.includeReferences===!1||e.includeCallees!==!0||e.includeSignatures===!0||(e.referenceDefinitions?.length??0)===0||(e.calleeDefinitions?.length??0)===0)return null;let{readinessDeadlineMs:n,...t}=e;return _e(A(t))}function Ee(e){return e.available&&Array.isArray(e.callees)&&(e.incompleteReferenceSymbolIds?.length??0)===0}function oe(e,n){V()&&z({type:"span",name:"rust.semantic.durable-session.response-cache",durationMs:0,ok:!0,hit:e,definitions:n})}function we(e){for(let n of Object.keys(process.env))Ae(n)&&delete process.env[n];for(let[n,t]of Object.entries(e))t!==null&&(process.env[n]=t)}function ke(e){return e==="HOME"||e==="PATH"||e.startsWith("CARGO_")||e.startsWith("RA_")||e.startsWith("RUST")}function Ae(e){return ke(e)||e.startsWith("SCIP_RUST_")||e==="SCIP_QUERY_PROFILE"||e==="SCIP_QUERY_PROFILE_CACHE_STATE"||e==="SCIP_QUERY_PROFILE_COMMAND"||e==="SCIP_QUERY_PROFILE_OUT"||e==="SCIP_QUERY_PROFILE_RUN_ID"||e==="SCIP_QUERY_PROFILE_WORKLOAD_IDENTITY"||e==="SCIP_QUERY_PROFILE_WORKLOAD_IDENTITY_KIND"||e==="SCIP_QUERY_PROFILE_MIN_MS"}var En={now:Date.now,monotonicNow:g,randomId:Me,isProcessAlive:k,readProcessIdentity:E,spawnServer(e,n,t){if(!De(e))throw new Error(`Durable Rust semantic session helper was not found at ${e}. Run npm run build first.`);Ie(process.execPath,[e,n,t],{detached:!0,stdio:"ignore"}).unref()},sleep(e){let n=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(n,0,0,e)}};function _e(e){return ge("sha256").update(e).digest("hex")}import{existsSync as qe,mkdtempSync as ie,readFileSync as ae,rmSync as L}from"fs";import{tmpdir as ue}from"os";import{join as W}from"path";import{fileURLToPath as le,pathToFileURL as xe}from"url";import{SHARE_ENV as Te,Worker as ve}from"worker_threads";function de(e={}){let n=null,t=null,i=1,o=!1,c=()=>{t&&(L(t,{recursive:!0,force:!0}),t=null)},S=()=>{let r=n;n=null,r&&r.terminate(),c()},M=()=>{if(n)return n;let r=e.semanticWorkerPath?xe(e.semanticWorkerPath):Ne();if(!qe(le(r)))throw new Error(`Rust semantic session worker was not found at ${le(r)}. Run npm run build before using built semantic Rust queries.`);return t=ie(W(ue(),"scip-query-rust-session-")),n=new ve(r,e.shareEnvironment?{env:Te}:void 0),n.unref(),n},y=()=>{let r=t??ie(W(ue(),"scip-query-rust-session-"));return t=r,W(r,`${i++}.json`)};return{requestSemantic(r,s){if(o)throw new Error("Rust semantic session was already disposed.");let f=M(),l=y(),u=new SharedArrayBuffer(4),R=new Int32Array(u);if(f.postMessage({kind:"semantic",request:r,responsePath:l,sharedBuffer:u}),Atomics.wait(R,0,0,s)==="timed-out")throw S(),new Error(`Rust semantic session worker timed out after ${(s/1e3).toFixed(0)}s`);try{let a=Ce(ae(l,"utf8"));if(!a.ok)throw new Error(a.error);return a.response}finally{L(l,{force:!0})}},requestImportDefinitions(r,s){if(o)throw new Error("Rust semantic session was already disposed.");let f=M(),l=y(),u=new SharedArrayBuffer(4),R=new Int32Array(u);if(f.postMessage({kind:"import-definitions",request:r,responsePath:l,sharedBuffer:u}),Atomics.wait(R,0,0,s)==="timed-out")throw S(),new Error(`Rust semantic import-definition session worker timed out after ${(s/1e3).toFixed(0)}s`);try{let a=Pe(ae(l,"utf8"));if(!a.ok)throw new Error(a.error);return a.response}finally{L(l,{force:!0})}},shutdown(){if(o)return;if(o=!0,!n){c();return}let r=y(),s=new SharedArrayBuffer(4),f=new Int32Array(s);n.postMessage({kind:"shutdown",responsePath:r,sharedBuffer:s}),Atomics.wait(f,0,0,5e3),S()}}}function Ce(e){let n=JSON.parse(e);if(!n||typeof n!="object")return{ok:!1,error:"Rust semantic session worker wrote a non-object response."};let t=n;return t.ok===!0&&"response"in t?{ok:!0,response:t.response}:{ok:!1,error:typeof n.error=="string"?n.error:"Rust semantic session worker failed."}}function Pe(e){let n=JSON.parse(e);if(!n||typeof n!="object")return{ok:!1,error:"Rust semantic session worker wrote a non-object response."};let t=n;return t.ok===!0&&"response"in t?{ok:!0,response:t.response}:{ok:!1,error:typeof n.error=="string"?n.error:"Rust semantic session worker failed."}}function Ne(){return new URL("./rust-semantic-session-worker.js",import.meta.url)}var Le=10*6e4,We=10,Fe=1e3;function je(e,n,t={}){let i=C(e);P(i);let o=t.now??(t.nowMs===void 0?Date.now:()=>t.nowMs),c=o(),S=q(e),M=Q(i,{ownerId:t.ownerId??Je,nowMs:c,limits:t.limits,owner:Ge,liveness:Xe}),y=0;for(let r of M){let s=null,f,l="handler-error";try{let u=J(r,t.limits),R;try{R=JSON.parse(u)}catch{throw l="malformed-request",new Error("Durable Rust semantic helper received malformed request JSON.")}let d=B(R,{claimRequestId:r.requestId,sessionIdentity:S,nowMs:o()});if(!d.ok)throw l=d.code,f=d.responseIdentity,new Error(d.error);s=d.value,f={id:s.id,sessionIdentity:s.sessionIdentity,deadlineAtMs:s.deadlineAtMs};let a=Ke(s.request,t.monotonicNowMs??g());t.beforeRequest?.(a);let pe=n.handle(a),F=o();if(s.deadlineAtMs<F)throw l="expired-request",new Error("Durable Rust semantic request expired while the helper was processing it.");G(i,r,{ok:!0,protocolVersion:m,id:s.id,sessionIdentity:s.sessionIdentity,deadlineAtMs:s.deadlineAtMs,...pe},{nowMs:F,limits:t.limits})}catch(u){let R=o(),d=f??(s?{id:s.id,sessionIdentity:s.sessionIdentity,deadlineAtMs:s.deadlineAtMs}:void 0),a=u instanceof Error?u.message:String(u);X(i,r,{ok:!1,protocolVersion:m,id:d?.id??r.requestId,...d?{sessionIdentity:d.sessionIdentity,deadlineAtMs:d.deadlineAtMs}:{},errorCode:l,error:a},a,{nowMs:R,limits:t.limits})}y+=1}return y}function Ke(e,n){let t=n+Math.max(1,e.timeoutMs-1e3);return{...e,request:{...e.request,readinessDeadlineMs:t}}}async function Ve(e,n){let t=C(e);P(t);let i=T(e,"server.lock"),o=Ye(i);if(!o)return;let c=new x(()=>de({semanticWorkerPath:n,shareEnvironment:!0})),S=!1,M=g(),y=Number.NEGATIVE_INFINITY,r,s=E(p.pid),f=q(e),l=()=>{S=!0};p.once("SIGINT",l),p.once("SIGTERM",l);let u=(R=!1)=>{let d=Date.now(),a=g();!R&&a-y<Fe||(y=a,H(T(e,"server.json"),{protocolVersion:m,sessionIdentity:f,pid:p.pid,...s?{processIdentity:s}:{},heartbeatAtMs:d,...r===void 0?{}:{busyUntilMs:r},mailbox:Z(t)}))};try{u(!0);let R=He();for(;!S&&g()-M<R;)je(e,c,{beforeRequest(a){r=Date.now()+a.timeoutMs+5e3,u(!0)}})>0?(M=g(),r=void 0,u(!0)):u(),await $e(We)}finally{c.shutdown(),Oe(T(e,"server.json"),{force:!0}),o.release()}}var ze=e=>{let n=Number(e);return Number.isInteger(n)&&n>0?{pid:n}:null};function Ye(e){let n=Y(e,{kind:"rust-durable-session-server",parseLegacy:ze});return n.kind==="acquired"?n.lock:null}function He(){let e=Number(p.env.SCIP_RUST_SEMANTIC_DURABLE_IDLE_MS);return Number.isInteger(e)&&e>=0?e:Le}function $e(e){return new Promise(n=>setTimeout(n,e))}var Qe=p.argv[1]?Be(T(p.argv[1])).href:null;if(Qe===import.meta.url){let e=p.argv[2],n=p.argv[3];!e||!n?(console.error("durable-rust-session: expected <session-dir> <semantic-worker-path>"),p.exitCode=1):await Ve(e,n)}var Je=`rust-semantic-${p.pid}-${Ue()}`,ce=E(p.pid),Ge={pid:p.pid,...ce?{processIdentity:ce}:{}},Xe={isProcessAlive:k,readProcessIdentity:E};export{Ye as acquireDurableRustSessionServerLock,je as processDurableRustSessionRequests};
2
2
  //# sourceMappingURL=rust-semantic-session-server.js.map
@@ -1,2 +1,2 @@
1
- import{A as ue,B as de,C as b,D as S,a as q,b as ee,c as A,d as G,e as N,f as F,g as B,h as E,i as ne,j as te,k as ie,l as se,n as j,o as H,p as U,q as W,r as re,u as ae,v as oe,w as le,x as ce,y as k}from"./chunk-D4U5Q3FT.js";import{a as O,f as d,g as D}from"./chunk-HGFDYOVB.js";import _ from"process";import{existsSync as pe,readFileSync as we,writeFileSync as Pe}from"fs";import{isAbsolute as De,resolve as K}from"path";import{performance as L}from"perf_hooks";import{parentPort as ke}from"worker_threads";var be="SCIP_RUST_SEMANTIC_REFERENCE_TASK_PROFILE_MS",Se="SCIP_RUST_SEMANTIC_CALLEE_TASK_PROFILE_MS",P=new Map,fe=Promise.resolve();ke?.on("message",e=>{fe=fe.then(()=>Te(e)).catch(()=>{})});async function Te(e){if(e.kind==="shutdown"){await We(),g(e.responsePath,{ok:!0},e.sharedBuffer);return}if(e.kind==="import-definitions"){try{let t=await ze(e.request);g(e.responsePath,{ok:!0,response:t},e.sharedBuffer)}catch(t){let i=B(t);if(i){g(e.responsePath,i,e.sharedBuffer);return}let n={available:!1,reason:t instanceof Error?t.message:String(t),sourcePaths:e.request.positions.map(r=>[r.id,null])};g(e.responsePath,{ok:!0,response:n},e.sharedBuffer)}return}try{let t=await ve(e.request);g(e.responsePath,{ok:!0,response:t},e.sharedBuffer)}catch(t){let i=B(t);if(i){g(e.responsePath,i,e.sharedBuffer);return}let n=ye(e.request,t instanceof Error?t.message:String(t));g(e.responsePath,{ok:!0,response:n},e.sharedBuffer)}}async function ze(e){let t={timeoutMs:e.requestTimeoutMs,deadlineMs:e.readinessDeadlineMs},i=await d("rust.semantic.worker.session",()=>Re(e.projectRoot,e.rustAnalyzerBinary,[e.file],{requestTimeoutMs:e.requestTimeoutMs,readinessDeadlineMs:e.readinessDeadlineMs}),()=>({kind:"import-definitions",files:1,positions:e.positions.length}));if(!i.capabilities.definitionProvider)return{available:!1,reason:"rust-analyzer initialized without textDocument/definition support.",sourcePaths:e.positions.map(o=>[o.id,null])};let n=0;await F(()=>d("rust.semantic.worker.open-source-documents",async()=>{n=await Ae(i,e.projectRoot,[e.file],{diagnosticsTimeoutMs:e.diagnosticsTimeoutMs,settleDelayMs:e.settleDelayMs,readinessDeadlineMs:e.readinessDeadlineMs})},()=>({files:1,openedDocuments:n,positions:e.positions.length})),()=>ge(P,i,e.readinessDeadlineMs));let r=0;return{available:!0,sourcePaths:await d("rust.semantic.worker.import-definitions",()=>S(e.positions,e.concurrency??8,async o=>{let c=await i.client.definition({textDocument:{uri:E(e.projectRoot,o.file)},position:{line:o.line,character:o.column}},t),f=Fe(e.projectRoot,c);return f&&(r+=1),[o.id,f]}),()=>({positions:e.positions.length,resolvedPositions:r,concurrency:e.concurrency??8}))}}async function ve(e){let t={timeoutMs:e.requestTimeoutMs,deadlineMs:e.readinessDeadlineMs},i=e.includeReferences!==!1,n=e.includeCallees===!0,r=e.includeSignatures===!0,a=j(e),o=H(e),c=U(e),f=W(e),l=await d("rust.semantic.worker.session",()=>Ie(e),()=>({kind:"semantic",definitions:f.length,referenceDefinitions:a.length,calleeDefinitions:o.length,signatureDefinitions:c.length,references:i,callees:n,signatures:r})),p=Ee(l.capabilities,{references:i,callees:n,signatures:r});if(p)return ye(e,p);let u=0;await F(()=>d("rust.semantic.worker.open-definition-documents",async()=>{u=await Ce(l,e)},()=>({definitions:f.length,openedDocuments:u})),()=>ge(P,l,e.readinessDeadlineMs));let m=0,M=0,y=O(),J=y?new Map:null,T=y?me(_.env[be]):null,V=()=>i?d("rust.semantic.worker.references",()=>S(a,e.concurrency??8,async s=>{let w=y?L.now():0,h=await ue(l.client,te(e.projectRoot,s,!1),{requestTimeoutMs:e.requestTimeoutMs,retryTimeoutMs:e.referenceRetryTimeoutMs,deadlineMs:e.readinessDeadlineMs}),R=se(ie(e.projectRoot,h.locations)),C=y?Math.round(L.now()-w):0;return _e(J,s.relativePath,{durationMs:C,references:R.length,hasReferences:R.length>0,slow:T!==null&&C>=T}),T!==null&&C>=T&&D({type:"span",name:"rust.semantic.worker.reference-task",durationMs:C,ok:!0,symbolId:s.symbolId,relativePath:s.relativePath,leaf:s.leaf,kind:s.kind,startLine:s.startLine,endLine:s.endLine,references:R.length,complete:h.complete}),R.length>0&&(M+=1),m+=R.length,{symbolId:s.symbolId,references:R,complete:h.complete}}),()=>({definitions:a.length,concurrency:e.concurrency??8,definitionsWithReferences:M,references:m})):Promise.resolve(a.map(s=>({symbolId:s.symbolId,references:[],complete:!0}))),Q=0,X=0,z=O(),Y=z?new Map:null,v=z?me(_.env[Se]):null,Z=()=>n?d("rust.semantic.worker.callees",()=>S(o,e.concurrency??8,async s=>{let w=z?L.now():0,h=await de(l.client,e.projectRoot,s,t),R=z?Math.round(L.now()-w):0;return Ge(Y,s.relativePath,{durationMs:R,callees:h.length,hasCallees:h.length>0,slow:v!==null&&R>=v}),v!==null&&R>=v&&D({type:"span",name:"rust.semantic.worker.callee-task",durationMs:R,ok:!0,symbolId:s.symbolId,relativePath:s.relativePath,leaf:s.leaf,kind:s.kind,startLine:s.startLine,endLine:s.endLine,callees:h.length}),h.length>0&&(X+=1),Q+=h.length,{symbolId:s.symbolId,callees:h}}),()=>({definitions:o.length,concurrency:e.concurrency??8,definitionsWithCallees:X,callees:Q})):Promise.resolve([]),I,x;i&&n&&a.length>0&&o.length>0&&je()?[I,x]=await Promise.all([V(),Z()]):(I=await V(),x=await Z()),xe(J),Ne(Y);let $=0,Me=r?await d("rust.semantic.worker.signatures",()=>S(c,e.concurrency??8,async s=>{let w=await re(l.client,e.projectRoot,s,t);return w&&($+=1),{symbolId:s.symbolId,signature:w}}),()=>({definitions:c.length,concurrency:e.concurrency??8,signaturesFound:$})):[];return{available:!0,references:I.filter(s=>s.complete).map(s=>[s.symbolId,s.references]),incompleteReferenceSymbolIds:I.filter(s=>!s.complete).map(s=>s.symbolId),...n?{callees:x.map(s=>[s.symbolId,s.callees])}:{},...r?{signatures:Me.map(s=>[s.symbolId,s.signature])}:{}}}async function Ie(e){return Re(e.projectRoot,e.rustAnalyzerBinary,W(e).map(t=>t.relativePath),{requestTimeoutMs:e.requestTimeoutMs,readinessDeadlineMs:e.readinessDeadlineMs})}async function Re(e,t,i,n){let r=le(e,i.map(M=>({relativePath:M}))),a=oe(e,r),o=Le(t,a,r),c=P.get(o);if(c)return c;let f=ae(r),l=new q(ee(t,a),{requestTimeoutMs:n.requestTimeoutMs,configuration:f}),p=n.readinessDeadlineMs===void 0?null:{afterGeneration:l.serverStatusGeneration(),deadlineMs:n.readinessDeadlineMs},u=await F(()=>d("rust.semantic.worker.initialize",()=>l.initialize({processId:_.pid,rootUri:E(a,"."),capabilities:{textDocument:{references:{dynamicRegistration:!1},definition:{dynamicRegistration:!1},callHierarchy:{dynamicRegistration:!1},hover:{dynamicRegistration:!1}}},initializationOptions:f},{timeoutMs:n.requestTimeoutMs,deadlineMs:n.readinessDeadlineMs}),()=>({linkedProjects:r.length,relativePaths:i.length})),()=>l.shutdown({deadlineMs:n.readinessDeadlineMs}).catch(()=>{})),m={key:o,client:l,capabilities:u.capabilities,openedPaths:new Set,initializationReadiness:p};return P.set(o,m),m}async function Ce(e,t){let i=W(t).filter(l=>e.openedPaths.has(l.relativePath)?!1:pe(K(t.projectRoot,l.relativePath)));if(i.length===0)return await he(e),0;let n=e.initializationReadiness,r=t.readinessDeadlineMs===void 0?null:{statusSnapshot:n?null:e.client.serverStatusSnapshot(),initializationGeneration:n?.afterGeneration,deadlineMs:t.readinessDeadlineMs},a=ce(e.client,t.projectRoot,i);for(let l of i)e.openedPaths.add(l.relativePath);let o=t.diagnosticsTimeoutMs??1e4,c=o;await d("rust.semantic.worker.diagnostics",()=>r?N(l=>(c=l,k(e.client,a,l)),o,r.deadlineMs):k(e.client,a,o),()=>({openedDocuments:a.length,timeoutMs:c}));let f=t.settleDelayMs??5e3;if(!r)await d("rust.semantic.worker.settle",()=>b(f),()=>({openedDocuments:a.length,settleDelayMs:f}));else{let l;await d("rust.semantic.worker.readiness",async()=>{let p=m=>d("rust.semantic.worker.settle",()=>b(m),()=>({openedDocuments:a.length,settleDelayMs:m})),u=r.initializationGeneration===void 0?await G(e.client,r.statusSnapshot,a.length,r.deadlineMs,f,Date.now,p):await A(e.client,r.initializationGeneration,a.length,r.deadlineMs,f,Date.now,p);r.initializationGeneration!==void 0&&(e.initializationReadiness=null),l=u?.health},()=>({phase:r.initializationGeneration===void 0?"didOpen":"initialize+didOpen",openedDocuments:a.length,health:l}))}return a.length}async function Ae(e,t,i,n){let r=i.filter(u=>e.openedPaths.has(u)?!1:pe(K(t,u)));if(r.length===0)return await he(e),0;let a=e.initializationReadiness,o=n.readinessDeadlineMs===void 0?null:{statusSnapshot:a?null:e.client.serverStatusSnapshot(),initializationGeneration:a?.afterGeneration,deadlineMs:n.readinessDeadlineMs},c=[];for(let u of r){let m=E(t,u);e.client.didOpenTextDocument({uri:m,languageId:"rust",version:1,text:we(K(t,u),"utf8")}),e.openedPaths.add(u),c.push(m)}let f=n.diagnosticsTimeoutMs??1e4,l=f;await d("rust.semantic.worker.diagnostics",()=>o?N(u=>(l=u,k(e.client,c,u)),f,o.deadlineMs):k(e.client,c,f),()=>({openedDocuments:c.length,timeoutMs:l}));let p=n.settleDelayMs??5e3;if(!o)await d("rust.semantic.worker.settle",()=>b(p),()=>({openedDocuments:c.length,settleDelayMs:p}));else{let u;await d("rust.semantic.worker.readiness",async()=>{let m=y=>d("rust.semantic.worker.settle",()=>b(y),()=>({openedDocuments:c.length,settleDelayMs:y})),M=o.initializationGeneration===void 0?await G(e.client,o.statusSnapshot,c.length,o.deadlineMs,p,Date.now,m):await A(e.client,o.initializationGeneration,c.length,o.deadlineMs,p,Date.now,m);o.initializationGeneration!==void 0&&(e.initializationReadiness=null),u=M?.health},()=>({phase:o.initializationGeneration===void 0?"didOpen":"initialize+didOpen",openedDocuments:c.length,health:u}))}return c.length}async function he(e){let t=e.initializationReadiness;if(!t)return;let i;await d("rust.semantic.worker.readiness",async()=>{i=(await A(e.client,t.afterGeneration,0,t.deadlineMs,0)).health,e.initializationReadiness=null},()=>({phase:"initialize",openedDocuments:0,health:i}))}function Fe(e,t){for(let i of t){let n=ne(e,i.uri);if(!(!n||n===".."||n.startsWith("../")||De(n)))return n}return null}function Ee(e,t){return t.references&&!e.referencesProvider?"rust-analyzer initialized without textDocument/references support.":t.callees&&!e.callHierarchyProvider?"rust-analyzer initialized without call hierarchy support.":t.signatures&&!e.hoverProvider?"rust-analyzer initialized without hover support.":null}function ye(e,t){let i=j(e),n=H(e),r=U(e);return{available:!1,reason:t,references:i.map(a=>[a.symbolId,[]]),...e.includeCallees?{callees:n.map(a=>[a.symbolId,[]])}:{},...e.includeSignatures?{signatures:r.map(a=>[a.symbolId,null])}:{}}}async function We(){let e=[...P.values()];P.clear(),await Promise.all(e.map(t=>t.client.shutdown().catch(()=>{})))}async function ge(e,t,i){e.get(t.key)===t&&e.delete(t.key),await t.client.shutdown({deadlineMs:i}).catch(()=>{})}function Le(e,t,i){return JSON.stringify({binary:e,sessionRoot:t,linkedProjects:i})}function _e(e,t,i){if(!e)return;let n=Oe(e,t);n.definitions+=1,i.hasReferences&&(n.definitionsWithReferences+=1),n.references+=i.references,n.durationMs+=i.durationMs,n.maxDurationMs=Math.max(n.maxDurationMs,i.durationMs),i.slow&&(n.slowTasks+=1)}function xe(e){if(!e)return;let t=[...e.entries()].sort(([i,n],[r,a])=>a.durationMs-n.durationMs||i.localeCompare(r));for(let[i,n]of t)D({type:"span",name:"rust.semantic.worker.references.by-file",durationMs:n.durationMs,ok:!0,relativePath:i,definitions:n.definitions,definitionsWithReferences:n.definitionsWithReferences,references:n.references,maxDurationMs:n.maxDurationMs,slowTasks:n.slowTasks,aggregate:"sum-task-duration"})}function Oe(e,t){let i=e.get(t);if(i)return i;let n={definitions:0,definitionsWithReferences:0,references:0,durationMs:0,maxDurationMs:0,slowTasks:0};return e.set(t,n),n}function Ge(e,t,i){if(!e)return;let n=Be(e,t);n.definitions+=1,i.hasCallees&&(n.definitionsWithCallees+=1),n.callees+=i.callees,n.durationMs+=i.durationMs,n.maxDurationMs=Math.max(n.maxDurationMs,i.durationMs),i.slow&&(n.slowTasks+=1)}function Ne(e){if(!e)return;let t=[...e.entries()].sort(([i,n],[r,a])=>a.durationMs-n.durationMs||i.localeCompare(r));for(let[i,n]of t)D({type:"span",name:"rust.semantic.worker.callees.by-file",durationMs:n.durationMs,ok:!0,relativePath:i,definitions:n.definitions,definitionsWithCallees:n.definitionsWithCallees,callees:n.callees,maxDurationMs:n.maxDurationMs,slowTasks:n.slowTasks,aggregate:"sum-task-duration"})}function Be(e,t){let i=e.get(t);if(i)return i;let n={definitions:0,definitionsWithCallees:0,callees:0,durationMs:0,maxDurationMs:0,slowTasks:0};return e.set(t,n),n}function me(e){if(e===void 0||e==="")return null;let t=Number(e);return Number.isInteger(t)&&t>=0?t:null}function je(){let e=_.env.SCIP_RUST_SEMANTIC_PARALLEL_OPERATIONS;return e!=="0"&&e!=="false"}function g(e,t,i){Pe(e,JSON.stringify(t));let n=new Int32Array(i);Atomics.store(n,0,1),Atomics.notify(n,0)}export{ge as discardRustAnalyzerSession};
1
+ import{A as ue,B as de,C as b,D as S,a as q,b as ee,c as A,d as G,e as N,f as F,g as B,h as E,i as ne,j as te,k as ie,l as se,n as j,o as H,p as U,q as W,r as re,u as ae,v as oe,w as le,x as ce,y as k}from"./chunk-4RI4BJGT.js";import{a as O,f as d,g as D}from"./chunk-HGFDYOVB.js";import"./chunk-APMMR5Y2.js";import _ from"process";import{existsSync as pe,readFileSync as we,writeFileSync as Pe}from"fs";import{isAbsolute as De,resolve as K}from"path";import{performance as L}from"perf_hooks";import{parentPort as ke}from"worker_threads";var be="SCIP_RUST_SEMANTIC_REFERENCE_TASK_PROFILE_MS",Se="SCIP_RUST_SEMANTIC_CALLEE_TASK_PROFILE_MS",P=new Map,fe=Promise.resolve();ke?.on("message",e=>{fe=fe.then(()=>Te(e)).catch(()=>{})});async function Te(e){if(e.kind==="shutdown"){await We(),g(e.responsePath,{ok:!0},e.sharedBuffer);return}if(e.kind==="import-definitions"){try{let t=await ze(e.request);g(e.responsePath,{ok:!0,response:t},e.sharedBuffer)}catch(t){let i=B(t);if(i){g(e.responsePath,i,e.sharedBuffer);return}let n={available:!1,reason:t instanceof Error?t.message:String(t),sourcePaths:e.request.positions.map(r=>[r.id,null])};g(e.responsePath,{ok:!0,response:n},e.sharedBuffer)}return}try{let t=await ve(e.request);g(e.responsePath,{ok:!0,response:t},e.sharedBuffer)}catch(t){let i=B(t);if(i){g(e.responsePath,i,e.sharedBuffer);return}let n=ye(e.request,t instanceof Error?t.message:String(t));g(e.responsePath,{ok:!0,response:n},e.sharedBuffer)}}async function ze(e){let t={timeoutMs:e.requestTimeoutMs,deadlineMs:e.readinessDeadlineMs},i=await d("rust.semantic.worker.session",()=>Re(e.projectRoot,e.rustAnalyzerBinary,[e.file],{requestTimeoutMs:e.requestTimeoutMs,readinessDeadlineMs:e.readinessDeadlineMs}),()=>({kind:"import-definitions",files:1,positions:e.positions.length}));if(!i.capabilities.definitionProvider)return{available:!1,reason:"rust-analyzer initialized without textDocument/definition support.",sourcePaths:e.positions.map(o=>[o.id,null])};let n=0;await F(()=>d("rust.semantic.worker.open-source-documents",async()=>{n=await Ae(i,e.projectRoot,[e.file],{diagnosticsTimeoutMs:e.diagnosticsTimeoutMs,settleDelayMs:e.settleDelayMs,readinessDeadlineMs:e.readinessDeadlineMs})},()=>({files:1,openedDocuments:n,positions:e.positions.length})),()=>ge(P,i,e.readinessDeadlineMs));let r=0;return{available:!0,sourcePaths:await d("rust.semantic.worker.import-definitions",()=>S(e.positions,e.concurrency??8,async o=>{let c=await i.client.definition({textDocument:{uri:E(e.projectRoot,o.file)},position:{line:o.line,character:o.column}},t),f=Fe(e.projectRoot,c);return f&&(r+=1),[o.id,f]}),()=>({positions:e.positions.length,resolvedPositions:r,concurrency:e.concurrency??8}))}}async function ve(e){let t={timeoutMs:e.requestTimeoutMs,deadlineMs:e.readinessDeadlineMs},i=e.includeReferences!==!1,n=e.includeCallees===!0,r=e.includeSignatures===!0,a=j(e),o=H(e),c=U(e),f=W(e),l=await d("rust.semantic.worker.session",()=>Ie(e),()=>({kind:"semantic",definitions:f.length,referenceDefinitions:a.length,calleeDefinitions:o.length,signatureDefinitions:c.length,references:i,callees:n,signatures:r})),p=Ee(l.capabilities,{references:i,callees:n,signatures:r});if(p)return ye(e,p);let u=0;await F(()=>d("rust.semantic.worker.open-definition-documents",async()=>{u=await Ce(l,e)},()=>({definitions:f.length,openedDocuments:u})),()=>ge(P,l,e.readinessDeadlineMs));let m=0,M=0,y=O(),J=y?new Map:null,T=y?me(_.env[be]):null,V=()=>i?d("rust.semantic.worker.references",()=>S(a,e.concurrency??8,async s=>{let w=y?L.now():0,h=await ue(l.client,te(e.projectRoot,s,!1),{requestTimeoutMs:e.requestTimeoutMs,retryTimeoutMs:e.referenceRetryTimeoutMs,deadlineMs:e.readinessDeadlineMs}),R=se(ie(e.projectRoot,h.locations)),C=y?Math.round(L.now()-w):0;return _e(J,s.relativePath,{durationMs:C,references:R.length,hasReferences:R.length>0,slow:T!==null&&C>=T}),T!==null&&C>=T&&D({type:"span",name:"rust.semantic.worker.reference-task",durationMs:C,ok:!0,symbolId:s.symbolId,relativePath:s.relativePath,leaf:s.leaf,kind:s.kind,startLine:s.startLine,endLine:s.endLine,references:R.length,complete:h.complete}),R.length>0&&(M+=1),m+=R.length,{symbolId:s.symbolId,references:R,complete:h.complete}}),()=>({definitions:a.length,concurrency:e.concurrency??8,definitionsWithReferences:M,references:m})):Promise.resolve(a.map(s=>({symbolId:s.symbolId,references:[],complete:!0}))),Q=0,X=0,z=O(),Y=z?new Map:null,v=z?me(_.env[Se]):null,Z=()=>n?d("rust.semantic.worker.callees",()=>S(o,e.concurrency??8,async s=>{let w=z?L.now():0,h=await de(l.client,e.projectRoot,s,t),R=z?Math.round(L.now()-w):0;return Ge(Y,s.relativePath,{durationMs:R,callees:h.length,hasCallees:h.length>0,slow:v!==null&&R>=v}),v!==null&&R>=v&&D({type:"span",name:"rust.semantic.worker.callee-task",durationMs:R,ok:!0,symbolId:s.symbolId,relativePath:s.relativePath,leaf:s.leaf,kind:s.kind,startLine:s.startLine,endLine:s.endLine,callees:h.length}),h.length>0&&(X+=1),Q+=h.length,{symbolId:s.symbolId,callees:h}}),()=>({definitions:o.length,concurrency:e.concurrency??8,definitionsWithCallees:X,callees:Q})):Promise.resolve([]),I,x;i&&n&&a.length>0&&o.length>0&&je()?[I,x]=await Promise.all([V(),Z()]):(I=await V(),x=await Z()),xe(J),Ne(Y);let $=0,Me=r?await d("rust.semantic.worker.signatures",()=>S(c,e.concurrency??8,async s=>{let w=await re(l.client,e.projectRoot,s,t);return w&&($+=1),{symbolId:s.symbolId,signature:w}}),()=>({definitions:c.length,concurrency:e.concurrency??8,signaturesFound:$})):[];return{available:!0,references:I.filter(s=>s.complete).map(s=>[s.symbolId,s.references]),incompleteReferenceSymbolIds:I.filter(s=>!s.complete).map(s=>s.symbolId),...n?{callees:x.map(s=>[s.symbolId,s.callees])}:{},...r?{signatures:Me.map(s=>[s.symbolId,s.signature])}:{}}}async function Ie(e){return Re(e.projectRoot,e.rustAnalyzerBinary,W(e).map(t=>t.relativePath),{requestTimeoutMs:e.requestTimeoutMs,readinessDeadlineMs:e.readinessDeadlineMs})}async function Re(e,t,i,n){let r=le(e,i.map(M=>({relativePath:M}))),a=oe(e,r),o=Le(t,a,r),c=P.get(o);if(c)return c;let f=ae(r),l=new q(ee(t,a),{requestTimeoutMs:n.requestTimeoutMs,configuration:f}),p=n.readinessDeadlineMs===void 0?null:{afterGeneration:l.serverStatusGeneration(),deadlineMs:n.readinessDeadlineMs},u=await F(()=>d("rust.semantic.worker.initialize",()=>l.initialize({processId:_.pid,rootUri:E(a,"."),capabilities:{textDocument:{references:{dynamicRegistration:!1},definition:{dynamicRegistration:!1},callHierarchy:{dynamicRegistration:!1},hover:{dynamicRegistration:!1}}},initializationOptions:f},{timeoutMs:n.requestTimeoutMs,deadlineMs:n.readinessDeadlineMs}),()=>({linkedProjects:r.length,relativePaths:i.length})),()=>l.shutdown({deadlineMs:n.readinessDeadlineMs}).catch(()=>{})),m={key:o,client:l,capabilities:u.capabilities,openedPaths:new Set,initializationReadiness:p};return P.set(o,m),m}async function Ce(e,t){let i=W(t).filter(l=>e.openedPaths.has(l.relativePath)?!1:pe(K(t.projectRoot,l.relativePath)));if(i.length===0)return await he(e),0;let n=e.initializationReadiness,r=t.readinessDeadlineMs===void 0?null:{statusSnapshot:n?null:e.client.serverStatusSnapshot(),initializationGeneration:n?.afterGeneration,deadlineMs:t.readinessDeadlineMs},a=ce(e.client,t.projectRoot,i);for(let l of i)e.openedPaths.add(l.relativePath);let o=t.diagnosticsTimeoutMs??1e4,c=o;await d("rust.semantic.worker.diagnostics",()=>r?N(l=>(c=l,k(e.client,a,l)),o,r.deadlineMs):k(e.client,a,o),()=>({openedDocuments:a.length,timeoutMs:c}));let f=t.settleDelayMs??5e3;if(!r)await d("rust.semantic.worker.settle",()=>b(f),()=>({openedDocuments:a.length,settleDelayMs:f}));else{let l;await d("rust.semantic.worker.readiness",async()=>{let p=m=>d("rust.semantic.worker.settle",()=>b(m),()=>({openedDocuments:a.length,settleDelayMs:m})),u=r.initializationGeneration===void 0?await G(e.client,r.statusSnapshot,a.length,r.deadlineMs,f,Date.now,p):await A(e.client,r.initializationGeneration,a.length,r.deadlineMs,f,Date.now,p);r.initializationGeneration!==void 0&&(e.initializationReadiness=null),l=u?.health},()=>({phase:r.initializationGeneration===void 0?"didOpen":"initialize+didOpen",openedDocuments:a.length,health:l}))}return a.length}async function Ae(e,t,i,n){let r=i.filter(u=>e.openedPaths.has(u)?!1:pe(K(t,u)));if(r.length===0)return await he(e),0;let a=e.initializationReadiness,o=n.readinessDeadlineMs===void 0?null:{statusSnapshot:a?null:e.client.serverStatusSnapshot(),initializationGeneration:a?.afterGeneration,deadlineMs:n.readinessDeadlineMs},c=[];for(let u of r){let m=E(t,u);e.client.didOpenTextDocument({uri:m,languageId:"rust",version:1,text:we(K(t,u),"utf8")}),e.openedPaths.add(u),c.push(m)}let f=n.diagnosticsTimeoutMs??1e4,l=f;await d("rust.semantic.worker.diagnostics",()=>o?N(u=>(l=u,k(e.client,c,u)),f,o.deadlineMs):k(e.client,c,f),()=>({openedDocuments:c.length,timeoutMs:l}));let p=n.settleDelayMs??5e3;if(!o)await d("rust.semantic.worker.settle",()=>b(p),()=>({openedDocuments:c.length,settleDelayMs:p}));else{let u;await d("rust.semantic.worker.readiness",async()=>{let m=y=>d("rust.semantic.worker.settle",()=>b(y),()=>({openedDocuments:c.length,settleDelayMs:y})),M=o.initializationGeneration===void 0?await G(e.client,o.statusSnapshot,c.length,o.deadlineMs,p,Date.now,m):await A(e.client,o.initializationGeneration,c.length,o.deadlineMs,p,Date.now,m);o.initializationGeneration!==void 0&&(e.initializationReadiness=null),u=M?.health},()=>({phase:o.initializationGeneration===void 0?"didOpen":"initialize+didOpen",openedDocuments:c.length,health:u}))}return c.length}async function he(e){let t=e.initializationReadiness;if(!t)return;let i;await d("rust.semantic.worker.readiness",async()=>{i=(await A(e.client,t.afterGeneration,0,t.deadlineMs,0)).health,e.initializationReadiness=null},()=>({phase:"initialize",openedDocuments:0,health:i}))}function Fe(e,t){for(let i of t){let n=ne(e,i.uri);if(!(!n||n===".."||n.startsWith("../")||De(n)))return n}return null}function Ee(e,t){return t.references&&!e.referencesProvider?"rust-analyzer initialized without textDocument/references support.":t.callees&&!e.callHierarchyProvider?"rust-analyzer initialized without call hierarchy support.":t.signatures&&!e.hoverProvider?"rust-analyzer initialized without hover support.":null}function ye(e,t){let i=j(e),n=H(e),r=U(e);return{available:!1,reason:t,references:i.map(a=>[a.symbolId,[]]),...e.includeCallees?{callees:n.map(a=>[a.symbolId,[]])}:{},...e.includeSignatures?{signatures:r.map(a=>[a.symbolId,null])}:{}}}async function We(){let e=[...P.values()];P.clear(),await Promise.all(e.map(t=>t.client.shutdown().catch(()=>{})))}async function ge(e,t,i){e.get(t.key)===t&&e.delete(t.key),await t.client.shutdown({deadlineMs:i}).catch(()=>{})}function Le(e,t,i){return JSON.stringify({binary:e,sessionRoot:t,linkedProjects:i})}function _e(e,t,i){if(!e)return;let n=Oe(e,t);n.definitions+=1,i.hasReferences&&(n.definitionsWithReferences+=1),n.references+=i.references,n.durationMs+=i.durationMs,n.maxDurationMs=Math.max(n.maxDurationMs,i.durationMs),i.slow&&(n.slowTasks+=1)}function xe(e){if(!e)return;let t=[...e.entries()].sort(([i,n],[r,a])=>a.durationMs-n.durationMs||i.localeCompare(r));for(let[i,n]of t)D({type:"span",name:"rust.semantic.worker.references.by-file",durationMs:n.durationMs,ok:!0,relativePath:i,definitions:n.definitions,definitionsWithReferences:n.definitionsWithReferences,references:n.references,maxDurationMs:n.maxDurationMs,slowTasks:n.slowTasks,aggregate:"sum-task-duration"})}function Oe(e,t){let i=e.get(t);if(i)return i;let n={definitions:0,definitionsWithReferences:0,references:0,durationMs:0,maxDurationMs:0,slowTasks:0};return e.set(t,n),n}function Ge(e,t,i){if(!e)return;let n=Be(e,t);n.definitions+=1,i.hasCallees&&(n.definitionsWithCallees+=1),n.callees+=i.callees,n.durationMs+=i.durationMs,n.maxDurationMs=Math.max(n.maxDurationMs,i.durationMs),i.slow&&(n.slowTasks+=1)}function Ne(e){if(!e)return;let t=[...e.entries()].sort(([i,n],[r,a])=>a.durationMs-n.durationMs||i.localeCompare(r));for(let[i,n]of t)D({type:"span",name:"rust.semantic.worker.callees.by-file",durationMs:n.durationMs,ok:!0,relativePath:i,definitions:n.definitions,definitionsWithCallees:n.definitionsWithCallees,callees:n.callees,maxDurationMs:n.maxDurationMs,slowTasks:n.slowTasks,aggregate:"sum-task-duration"})}function Be(e,t){let i=e.get(t);if(i)return i;let n={definitions:0,definitionsWithCallees:0,callees:0,durationMs:0,maxDurationMs:0,slowTasks:0};return e.set(t,n),n}function me(e){if(e===void 0||e==="")return null;let t=Number(e);return Number.isInteger(t)&&t>=0?t:null}function je(){let e=_.env.SCIP_RUST_SEMANTIC_PARALLEL_OPERATIONS;return e!=="0"&&e!=="false"}function g(e,t,i){Pe(e,JSON.stringify(t));let n=new Int32Array(i);Atomics.store(n,0,1),Atomics.notify(n,0)}export{ge as discardRustAnalyzerSession};
2
2
  //# sourceMappingURL=rust-semantic-session-worker.js.map
@@ -1,2 +1,2 @@
1
- import{A as o,B as p,C as q,D as r,m as a,n as b,o as c,p as d,q as e,r as f,s as g,t as h,u as i,v as j,w as k,x as l,y as m,z as n}from"./chunk-D4U5Q3FT.js";export{p as calleesForDefinition,k as cargoManifestsForDefinitions,h as hoverToRustSignature,g as hoverWithRetry,l as openDefinitionDocuments,o as referencesWithCompletion,n as referencesWithRetry,a as runRustAnalyzerReferenceBatch,r as runWithConcurrency,i as rustAnalyzerInitializationOptions,j as rustAnalyzerSessionRoot,c as rustRequestCalleeDefinitions,b as rustRequestReferenceDefinitions,e as rustRequestSessionDefinitions,d as rustRequestSignatureDefinitions,f as signatureForDefinition,q as sleep,m as waitForOpenedDocuments};
1
+ import{A as o,B as p,C as q,D as r,m as a,n as b,o as c,p as d,q as e,r as f,s as g,t as h,u as i,v as j,w as k,x as l,y as m,z as n}from"./chunk-4RI4BJGT.js";import"./chunk-APMMR5Y2.js";export{p as calleesForDefinition,k as cargoManifestsForDefinitions,h as hoverToRustSignature,g as hoverWithRetry,l as openDefinitionDocuments,o as referencesWithCompletion,n as referencesWithRetry,a as runRustAnalyzerReferenceBatch,r as runWithConcurrency,i as rustAnalyzerInitializationOptions,j as rustAnalyzerSessionRoot,c as rustRequestCalleeDefinitions,b as rustRequestReferenceDefinitions,e as rustRequestSessionDefinitions,d as rustRequestSignatureDefinitions,f as signatureForDefinition,q as sleep,m as waitForOpenedDocuments};
2
2
  //# sourceMappingURL=rust-semantic-worker.js.map
@@ -1,4 +1,4 @@
1
- import { a as SupportedLanguage } from './config-types-D20KuvvZ.js';
1
+ import { a as SupportedLanguage } from './config-types-BWQ5xPGI.js';
2
2
 
3
3
  type WatcherStatus = {
4
4
  state: 'idle';
@@ -13,6 +13,10 @@ type WatcherStatus = {
13
13
  state: 'cooldown';
14
14
  until: number;
15
15
  dirty: boolean;
16
+ } | {
17
+ state: 'draining';
18
+ startedAt: number;
19
+ reason: string;
16
20
  };
17
21
  type RefreshTriggerKind = 'manual-cli' | 'setup' | 'watch-source' | 'watch-startup' | 'watch-demand' | 'watch-git-head' | 'watch-git-index' | 'watch-git-state' | 'unknown';
18
22
  interface RefreshTrigger {