scip-query 0.10.10 → 0.10.12

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 (279) hide show
  1. package/README.md +56 -35
  2. package/dist/augment-vue-worker.js +1 -1
  3. package/dist/chunk-2DOW7QCA.js +71 -0
  4. package/dist/chunk-2FMFF4RI.js +2 -0
  5. package/dist/{chunk-J7RWXLUL.js → chunk-2GLNBCHB.js} +2 -2
  6. package/dist/chunk-2UVCH7CQ.js +2 -0
  7. package/dist/{chunk-LM5SHAN4.js → chunk-3XSNW5XB.js} +2 -2
  8. package/dist/chunk-4ISHQ7UW.js +35 -0
  9. package/dist/{chunk-XXZXDXTD.js → chunk-5GXTUANY.js} +2 -2
  10. package/dist/{chunk-TL6QPNF5.js → chunk-5JHEN5VN.js} +2 -2
  11. package/dist/chunk-62ULXMQ7.js +18 -0
  12. package/dist/chunk-63CI3IXR.js +102 -0
  13. package/dist/{chunk-Z4I7BVIU.js → chunk-6BN3EHQE.js} +2 -2
  14. package/dist/chunk-7C6JBBE4.js +23 -0
  15. package/dist/chunk-7EK7OSWS.js +2 -0
  16. package/dist/chunk-7IWIMNHI.js +2 -0
  17. package/dist/chunk-7XTO4YXB.js +8 -0
  18. package/dist/{chunk-5NVUWIAN.js → chunk-A4UTLKHU.js} +2 -2
  19. package/dist/{chunk-FDEQIPPK.js → chunk-ANUEY5WV.js} +2 -2
  20. package/dist/chunk-AOWFUGDL.js +2 -0
  21. package/dist/chunk-AREANYIA.js +3 -0
  22. package/dist/{chunk-7UQWUVRG.js → chunk-AZBELWZQ.js} +2 -2
  23. package/dist/{chunk-WG6KRH5F.js → chunk-CXWCLVYL.js} +2 -2
  24. package/dist/chunk-CYHIKTJN.js +3 -0
  25. package/dist/{chunk-BVRS7RKQ.js → chunk-DDQONX6B.js} +2 -2
  26. package/dist/{chunk-736BLPHR.js → chunk-DFSEARAU.js} +2 -2
  27. package/dist/{chunk-UFX7EPBA.js → chunk-DQ6433ZG.js} +2 -2
  28. package/dist/chunk-DVFP6PZI.js +2 -0
  29. package/dist/chunk-E3ADDB43.js +2 -0
  30. package/dist/{chunk-YWOOQ4FF.js → chunk-ELC77ZDE.js} +1 -1
  31. package/dist/chunk-EOLGSSDR.js +2 -0
  32. package/dist/chunk-F6IXELII.js +20 -0
  33. package/dist/{chunk-QYB5P7GL.js → chunk-FMGVZBS2.js} +2 -2
  34. package/dist/{chunk-VOYOYC5T.js → chunk-FX6ULETZ.js} +2 -2
  35. package/dist/chunk-GG5LHT27.js +2 -0
  36. package/dist/chunk-GKB4JJDU.js +2 -0
  37. package/dist/chunk-H7JF2CKK.js +2 -0
  38. package/dist/chunk-HHOMJCP5.js +4 -0
  39. package/dist/chunk-HRDSU5FN.js +9 -0
  40. package/dist/{chunk-BZ53S4ZN.js → chunk-HWVYTJOV.js} +2 -2
  41. package/dist/chunk-JJ5SAWBT.js +2 -0
  42. package/dist/chunk-JNMLBL36.js +2 -0
  43. package/dist/chunk-JS6B76AQ.js +2 -0
  44. package/dist/{chunk-ZQO43G2T.js → chunk-KZ4MG5NY.js} +2 -2
  45. package/dist/{chunk-UQLFQLAF.js → chunk-L446VQYQ.js} +2 -2
  46. package/dist/{chunk-NZ4UDB5N.js → chunk-LDJUB7XW.js} +2 -2
  47. package/dist/{chunk-MMLZEGMS.js → chunk-LEHVP4DY.js} +2 -2
  48. package/dist/chunk-MNCQPMCH.js +2 -0
  49. package/dist/chunk-MYTUWXHK.js +4 -0
  50. package/dist/chunk-N25HPUOK.js +2 -0
  51. package/dist/chunk-NABVR6B7.js +2 -0
  52. package/dist/{chunk-PTQVNJ4Q.js → chunk-NBNEVLRC.js} +2 -2
  53. package/dist/chunk-NTSR6SRP.js +2 -0
  54. package/dist/{chunk-RYXW3KRC.js → chunk-OFXN2BCT.js} +2 -2
  55. package/dist/chunk-PWAK75BU.js +2 -0
  56. package/dist/chunk-Q5P7NOVM.js +2 -0
  57. package/dist/chunk-RGKRYO22.js +4 -0
  58. package/dist/chunk-RM2WQ75T.js +2 -0
  59. package/dist/chunk-ROGZXWN2.js +2 -0
  60. package/dist/chunk-RSSXKJ6J.js +38 -0
  61. package/dist/chunk-RUV5IY25.js +7 -0
  62. package/dist/chunk-RVGEZYMQ.js +2 -0
  63. package/dist/{chunk-IPQTC36U.js → chunk-RXINFVBN.js} +2 -2
  64. package/dist/{chunk-RXRLZFUL.js → chunk-S2MRVIJ5.js} +2 -2
  65. package/dist/chunk-SA3DPTHT.js +7 -0
  66. package/dist/chunk-SGTKURU6.js +52 -0
  67. package/dist/chunk-SQNHOOJ5.js +3 -0
  68. package/dist/chunk-T3AEVJBG.js +4 -0
  69. package/dist/{chunk-DQVKIG3D.js → chunk-T4N2ZRVY.js} +2 -2
  70. package/dist/{chunk-5VG7RKEF.js → chunk-TBCHRDAC.js} +2 -2
  71. package/dist/chunk-THB6AM3V.js +11 -0
  72. package/dist/chunk-ULHLDOD6.js +4 -0
  73. package/dist/chunk-UQ73QF5D.js +43 -0
  74. package/dist/chunk-UVPY3RUZ.js +2 -0
  75. package/dist/chunk-V5FGK3DZ.js +2 -0
  76. package/dist/{chunk-3DGD6NKW.js → chunk-VB2EZZPA.js} +2 -2
  77. package/dist/{chunk-56P7PDST.js → chunk-WTY5FERW.js} +2 -2
  78. package/dist/chunk-WUOB4DHH.js +6 -0
  79. package/dist/chunk-XHMVZFA6.js +2 -0
  80. package/dist/chunk-XRUGSM76.js +10 -0
  81. package/dist/{chunk-UYD7FJ3K.js → chunk-XUCZ3RQ5.js} +2 -2
  82. package/dist/chunk-YFQIKYOP.js +2 -0
  83. package/dist/chunk-Z2LDWIJV.js +5 -0
  84. package/dist/chunk-ZNWWVYQL.js +3 -0
  85. package/dist/{chunk-UDGXK2WA.js → chunk-ZUUNREKS.js} +2 -2
  86. package/dist/cli.js +277 -252
  87. package/dist/{config-types-BDIWAYzr.d.ts → config-types-dvHOz0zU.d.ts} +4 -1
  88. package/dist/{db-Djj3Nqrb.d.ts → db-rMZO5JFK.d.ts} +1 -1
  89. package/dist/{health-D5J42g4D.d.ts → health-CtTIGh6H.d.ts} +1 -1
  90. package/dist/index.d.ts +9 -5
  91. package/dist/index.js +2 -2
  92. package/dist/queries/affected.d.ts +2 -2
  93. package/dist/queries/affected.js +1 -1
  94. package/dist/queries/bottlenecks.d.ts +2 -2
  95. package/dist/queries/bottlenecks.js +1 -1
  96. package/dist/queries/by-kind.d.ts +2 -2
  97. package/dist/queries/by-kind.js +1 -1
  98. package/dist/queries/call-graph.d.ts +2 -2
  99. package/dist/queries/call-graph.js +1 -1
  100. package/dist/queries/change-surface.d.ts +2 -2
  101. package/dist/queries/change-surface.js +1 -1
  102. package/dist/queries/cleanup-plan.d.ts +2 -2
  103. package/dist/queries/cleanup-plan.js +1 -1
  104. package/dist/queries/co-change.d.ts +2 -2
  105. package/dist/queries/co-change.js +1 -1
  106. package/dist/queries/code.d.ts +2 -2
  107. package/dist/queries/code.js +1 -1
  108. package/dist/queries/complexity-hotspots.d.ts +2 -2
  109. package/dist/queries/complexity-hotspots.js +1 -1
  110. package/dist/queries/complexity.d.ts +2 -2
  111. package/dist/queries/complexity.js +1 -1
  112. package/dist/queries/convergence.d.ts +2 -2
  113. package/dist/queries/convergence.js +1 -1
  114. package/dist/queries/coupling.d.ts +2 -2
  115. package/dist/queries/coupling.js +1 -1
  116. package/dist/queries/cycles.d.ts +2 -2
  117. package/dist/queries/cycles.js +1 -1
  118. package/dist/queries/dataflow.d.ts +2 -2
  119. package/dist/queries/dataflow.js +1 -1
  120. package/dist/queries/dead.d.ts +2 -2
  121. package/dist/queries/dead.js +1 -1
  122. package/dist/queries/deep-chains.d.ts +2 -2
  123. package/dist/queries/deep-chains.js +1 -1
  124. package/dist/queries/deps.d.ts +2 -2
  125. package/dist/queries/deps.js +1 -1
  126. package/dist/queries/diff-gate.d.ts +2 -2
  127. package/dist/queries/diff-gate.js +1 -1
  128. package/dist/queries/diff-impact.d.ts +2 -2
  129. package/dist/queries/diff-impact.js +1 -1
  130. package/dist/queries/doc-drift.d.ts +2 -2
  131. package/dist/queries/doc-drift.js +1 -1
  132. package/dist/queries/drift.d.ts +2 -2
  133. package/dist/queries/drift.js +1 -1
  134. package/dist/queries/extract-candidates.d.ts +2 -2
  135. package/dist/queries/extract-candidates.js +1 -1
  136. package/dist/queries/fan.d.ts +2 -2
  137. package/dist/queries/fan.js +1 -1
  138. package/dist/queries/files.d.ts +2 -2
  139. package/dist/queries/health.d.ts +3 -3
  140. package/dist/queries/health.js +1 -1
  141. package/dist/queries/hierarchy.d.ts +2 -2
  142. package/dist/queries/hierarchy.js +1 -1
  143. package/dist/queries/hotspots.d.ts +2 -2
  144. package/dist/queries/hotspots.js +1 -1
  145. package/dist/queries/imports.d.ts +2 -2
  146. package/dist/queries/imports.js +1 -1
  147. package/dist/queries/incomplete-migration.d.ts +2 -2
  148. package/dist/queries/incomplete-migration.js +1 -1
  149. package/dist/queries/index.d.ts +4 -4
  150. package/dist/queries/index.js +1 -1
  151. package/dist/queries/isolated.d.ts +2 -2
  152. package/dist/queries/isolated.js +1 -1
  153. package/dist/queries/locality-candidates.d.ts +2 -2
  154. package/dist/queries/locality-candidates.js +1 -1
  155. package/dist/queries/members.d.ts +2 -2
  156. package/dist/queries/members.js +1 -1
  157. package/dist/queries/methods.d.ts +2 -2
  158. package/dist/queries/methods.js +1 -1
  159. package/dist/queries/outline.d.ts +2 -2
  160. package/dist/queries/outline.js +1 -1
  161. package/dist/queries/passthrough-candidates.d.ts +2 -2
  162. package/dist/queries/passthrough-candidates.js +1 -1
  163. package/dist/queries/plan-context.d.ts +2 -2
  164. package/dist/queries/plan-context.js +1 -1
  165. package/dist/queries/react-component-duplicates.d.ts +2 -2
  166. package/dist/queries/react-component-duplicates.js +1 -1
  167. package/dist/queries/react-hook-candidates.d.ts +2 -2
  168. package/dist/queries/react-hook-candidates.js +1 -1
  169. package/dist/queries/react-large-component-pressure.d.ts +2 -2
  170. package/dist/queries/react-large-component-pressure.js +1 -1
  171. package/dist/queries/recent-duplicates.d.ts +2 -2
  172. package/dist/queries/recent-duplicates.js +1 -1
  173. package/dist/queries/redundant-reexports.d.ts +2 -2
  174. package/dist/queries/redundant-reexports.js +1 -1
  175. package/dist/queries/refs.d.ts +2 -2
  176. package/dist/queries/refs.js +1 -1
  177. package/dist/queries/self-audit.d.ts +7 -4
  178. package/dist/queries/self-audit.js +1 -1
  179. package/dist/queries/similar-chains.d.ts +2 -2
  180. package/dist/queries/similar-chains.js +1 -1
  181. package/dist/queries/similar-files.d.ts +2 -2
  182. package/dist/queries/similar-files.js +1 -1
  183. package/dist/queries/similar-signatures.d.ts +2 -2
  184. package/dist/queries/similar-signatures.js +1 -1
  185. package/dist/queries/similar.d.ts +55 -16
  186. package/dist/queries/similar.js +1 -1
  187. package/dist/queries/slice.d.ts +2 -2
  188. package/dist/queries/slice.js +1 -1
  189. package/dist/queries/stale-abstractions.d.ts +2 -2
  190. package/dist/queries/stale-abstractions.js +1 -1
  191. package/dist/queries/stats.d.ts +2 -2
  192. package/dist/queries/surface.d.ts +2 -2
  193. package/dist/queries/surface.js +1 -1
  194. package/dist/queries/symbols.d.ts +2 -2
  195. package/dist/queries/symbols.js +1 -1
  196. package/dist/queries/system.d.ts +2 -2
  197. package/dist/queries/system.js +1 -1
  198. package/dist/queries/trace.d.ts +2 -2
  199. package/dist/queries/trace.js +1 -1
  200. package/dist/queries/unused-imports.d.ts +2 -2
  201. package/dist/queries/unused-imports.js +1 -1
  202. package/dist/queries/unused-params.d.ts +2 -2
  203. package/dist/queries/unused-params.js +1 -1
  204. package/dist/queries/vue-component-duplicates.d.ts +2 -2
  205. package/dist/queries/vue-component-duplicates.js +1 -1
  206. package/dist/queries/vue-composable-candidates.d.ts +2 -2
  207. package/dist/queries/vue-composable-candidates.js +1 -1
  208. package/dist/queries/vue-large-view-pressure.d.ts +2 -2
  209. package/dist/queries/vue-large-view-pressure.js +1 -1
  210. package/dist/queries/wrapper-candidates.d.ts +2 -2
  211. package/dist/queries/wrapper-candidates.js +1 -1
  212. package/dist/reindex-worker.js +9 -9
  213. package/dist/reindex.d.ts +30 -4
  214. package/dist/reindex.js +19 -19
  215. package/dist/runtime.d.ts +4 -3
  216. package/dist/runtime.js +2 -2
  217. package/dist/{scip-cli-CnK9Va4O.d.ts → scip-cli-trnNvymv.d.ts} +1 -1
  218. package/docs/COMMAND_REFERENCE.md +2 -2
  219. package/docs/analyzer-inventory.md +8 -0
  220. package/docs/analyzer-validation-ledger.md +7 -0
  221. package/package.json +3 -1
  222. package/scripts/evidence-product-contract.mjs +197 -0
  223. package/skills/scip-hyper-optimization/SKILL.md +153 -24
  224. package/skills/scip-hyper-optimization/agents/openai.yaml +3 -3
  225. package/dist/chunk-2UYQLFVC.js +0 -2
  226. package/dist/chunk-2VM46FC5.js +0 -8
  227. package/dist/chunk-3Q77KKEY.js +0 -2
  228. package/dist/chunk-3VD3JMK2.js +0 -2
  229. package/dist/chunk-4KTOV4QN.js +0 -3
  230. package/dist/chunk-4N4WONI4.js +0 -102
  231. package/dist/chunk-65AU3HFZ.js +0 -2
  232. package/dist/chunk-6LNQOOTB.js +0 -2
  233. package/dist/chunk-72KY2ZFO.js +0 -2
  234. package/dist/chunk-7JRRXGVZ.js +0 -2
  235. package/dist/chunk-A536TEU4.js +0 -3
  236. package/dist/chunk-A6IDHNMC.js +0 -4
  237. package/dist/chunk-A6TANQNV.js +0 -2
  238. package/dist/chunk-AW2QHPLL.js +0 -4
  239. package/dist/chunk-BSN22NRK.js +0 -9
  240. package/dist/chunk-C5CTSJ6X.js +0 -6
  241. package/dist/chunk-CCKPYPDI.js +0 -35
  242. package/dist/chunk-CZ425R2B.js +0 -18
  243. package/dist/chunk-DS6QEB3G.js +0 -5
  244. package/dist/chunk-F6ICF7HL.js +0 -40
  245. package/dist/chunk-FAYI6KZ5.js +0 -2
  246. package/dist/chunk-FG4NT6VY.js +0 -2
  247. package/dist/chunk-FRPEPTYJ.js +0 -5
  248. package/dist/chunk-GBEYTDY5.js +0 -2
  249. package/dist/chunk-GRJY65YT.js +0 -2
  250. package/dist/chunk-HF25DFSC.js +0 -3
  251. package/dist/chunk-HHN2B5KA.js +0 -2
  252. package/dist/chunk-I46WR7MT.js +0 -10
  253. package/dist/chunk-JM72FNGA.js +0 -2
  254. package/dist/chunk-KX5PLFZ5.js +0 -3
  255. package/dist/chunk-LPL4MA6R.js +0 -2
  256. package/dist/chunk-LZHUWKGD.js +0 -2
  257. package/dist/chunk-OBGRLXWF.js +0 -3
  258. package/dist/chunk-P5RYBRIO.js +0 -4
  259. package/dist/chunk-PFOCOG57.js +0 -2
  260. package/dist/chunk-PKMZCDQD.js +0 -4
  261. package/dist/chunk-QPU7EXAW.js +0 -2
  262. package/dist/chunk-QVI3NR7E.js +0 -7
  263. package/dist/chunk-QX7LLCGB.js +0 -23
  264. package/dist/chunk-RVWSAMTT.js +0 -2
  265. package/dist/chunk-SGLLBSCV.js +0 -2
  266. package/dist/chunk-SULEXAHO.js +0 -38
  267. package/dist/chunk-TH2N6QHW.js +0 -2
  268. package/dist/chunk-UWYJDBDW.js +0 -2
  269. package/dist/chunk-VUKC6F77.js +0 -20
  270. package/dist/chunk-W2CBNBEL.js +0 -71
  271. package/dist/chunk-XIVO4SDZ.js +0 -2
  272. package/dist/chunk-XSNRACLV.js +0 -3
  273. package/dist/chunk-XUGQU7PM.js +0 -41
  274. package/dist/chunk-Y6E3JHC4.js +0 -2
  275. package/dist/chunk-YBEEVDJQ.js +0 -2
  276. package/dist/chunk-YGHUVQLR.js +0 -2
  277. package/dist/chunk-YWDVDAD7.js +0 -2
  278. package/dist/chunk-YZA6PPZL.js +0 -3
  279. package/dist/chunk-ZU6PROUY.js +0 -2
package/dist/reindex.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { a as SupportedLanguage, I as IndexerConfig, T as TypeScriptProjectMode } from './config-types-BDIWAYzr.js';
2
- import { R as RefreshTrigger, L as LastRefreshMetadata } from './scip-cli-CnK9Va4O.js';
3
- export { t as tryInstallScipCli } from './scip-cli-CnK9Va4O.js';
1
+ import { a as SupportedLanguage, I as IndexerConfig, T as TypeScriptProjectMode } from './config-types-dvHOz0zU.js';
2
+ import { R as RefreshTrigger, L as LastRefreshMetadata } from './scip-cli-trnNvymv.js';
3
+ export { t as tryInstallScipCli } from './scip-cli-trnNvymv.js';
4
4
  import { Index } from '@c4312/scip';
5
5
 
6
6
  /**
@@ -9,6 +9,24 @@ import { Index } from '@c4312/scip';
9
9
  */
10
10
  declare function detectLanguages(projectRoot: string): SupportedLanguage[];
11
11
 
12
+ type PostIndexAugmentationFact = 'auxiliary-document' | 'synthetic-symbol' | 'source-mapped-occurrence' | 'definition-mention' | 'replacement-chunk' | 'fingerprint-cache';
13
+ interface PostIndexAugmentationContext {
14
+ projectRoot: string;
15
+ dbPath: string;
16
+ onStatus?: (message: string) => void;
17
+ }
18
+ interface PostIndexAugmentationStage<Result> {
19
+ id: string;
20
+ facts: readonly PostIndexAugmentationFact[];
21
+ run(context: PostIndexAugmentationContext): Result;
22
+ }
23
+ declare function runPostIndexAugmentation<Result>(stage: PostIndexAugmentationStage<Result>, context: PostIndexAugmentationContext): {
24
+ stageId: string;
25
+ facts: readonly PostIndexAugmentationFact[];
26
+ durationMs: number;
27
+ result: Result;
28
+ };
29
+
12
30
  interface AugmentAuxiliaryDocumentsOptions {
13
31
  projectRoot: string;
14
32
  dbPath: string;
@@ -20,6 +38,9 @@ interface AugmentAuxiliaryDocumentsResult {
20
38
  inserted: number;
21
39
  existing: number;
22
40
  }
41
+ declare function auxiliaryDocumentsAugmentationStage(opts?: {
42
+ extensions?: readonly string[];
43
+ }): PostIndexAugmentationStage<AugmentAuxiliaryDocumentsResult>;
23
44
  /**
24
45
  * Add source files that upstream SCIP indexers skipped to the SQLite
25
46
  * documents table. Vue SFCs are the motivating case: scip-typescript can
@@ -41,6 +62,9 @@ interface AugmentVueResolvedOptions {
41
62
  tsconfig: string;
42
63
  onStatus?: (message: string) => void;
43
64
  }
65
+ declare function vueResolvedReferencesAugmentationStage(opts: {
66
+ tsconfig: string;
67
+ }): PostIndexAugmentationStage<AugmentVueResolvedResult>;
44
68
  declare function augmentVueResolvedReferences(opts: AugmentVueResolvedOptions): AugmentVueResolvedResult;
45
69
 
46
70
  /**
@@ -123,6 +147,8 @@ interface ReindexOptions {
123
147
  typescriptProjectMode?: TypeScriptProjectMode;
124
148
  /** Explicit TypeScript project roots or tsconfig paths for workspace mode. */
125
149
  typescriptProjects?: string[];
150
+ /** Optional scip-clojure config path, relative to project root unless absolute. */
151
+ clojureConfigPath?: string;
126
152
  /** Skip auto-install prompts */
127
153
  skipAutoInstall?: boolean;
128
154
  /** Reuse an existing index when tracked source inputs are unchanged (default true). */
@@ -159,4 +185,4 @@ interface ReindexResult {
159
185
  */
160
186
  declare function reindex(opts: ReindexOptions): Promise<ReindexResult>;
161
187
 
162
- export { INDEXER_CONFIGS, type ReindexOptions, type ReindexResult, augmentAuxiliaryDocuments, augmentVueResolvedReferences, describeIndexerBinary, detectLanguages, getIndexerConfig, getIndexerExecutionEnv, isBinaryAvailable, isIndexerInstalled, mergeScipFiles, mergeScipIndexes, reindex, resolveIndexerBinary, resolveProjectLocalIndexerBinary, tryInstallIndexer };
188
+ export { INDEXER_CONFIGS, type ReindexOptions, type ReindexResult, augmentAuxiliaryDocuments, augmentVueResolvedReferences, auxiliaryDocumentsAugmentationStage, describeIndexerBinary, detectLanguages, getIndexerConfig, getIndexerExecutionEnv, isBinaryAvailable, isIndexerInstalled, mergeScipFiles, mergeScipIndexes, reindex, resolveIndexerBinary, resolveProjectLocalIndexerBinary, runPostIndexAugmentation, tryInstallIndexer, vueResolvedReferencesAugmentationStage };
package/dist/reindex.js CHANGED
@@ -1,9 +1,10 @@
1
- import{a as x,b as F,f as E}from"./chunk-ONPCQ2PM.js";import{a as se}from"./chunk-UUBMFL3F.js";import{a as ie,b as oe}from"./chunk-A536TEU4.js";import"./chunk-64MNV6AB.js";import"./chunk-7S5E7KWT.js";import{execFileSync as Ar}from"child_process";import{closeSync as $r,copyFileSync as _r,existsSync as M,mkdirSync as te,mkdtempSync as Br,openSync as Wr,readFileSync as D,renameSync as k,rmSync as P,writeFileSync as Ze}from"fs";import{basename as T,dirname as f,extname as Ur,join as m}from"path";import ct from"better-sqlite3";import{execFileSync as lt}from"child_process";import{existsSync as gt,readdirSync as pt,readFileSync as dt}from"fs";import{extname as I,join as ae}from"path";function b(e){let t=new Set((e.extensions??ie).map(o=>o.toLowerCase()));if(t.size===0)return{scanned:0,inserted:0,existing:0};if(!gt(e.dbPath))throw new Error(`SCIP SQLite database not found at ${e.dbPath}`);let n=se(e.projectRoot),r=ft(e.projectRoot,t).filter(o=>!n.isIgnored(o)),i=new ct(e.dbPath);try{let o=ht(i,r),s=i.prepare(`INSERT OR IGNORE INTO documents (language, relative_path, position_encoding, text)
2
- VALUES (?, ?, NULL, ?)`),u=i.transaction(g=>{let l=0;for(let p of g){if(o.has(p))continue;let h=dt(ae(e.projectRoot,p),"utf-8"),ut=s.run(yt(p),p,h);l+=Number(ut.changes)}return l})(r),c={scanned:r.length,inserted:u,existing:r.length-u};return e.onStatus?.(`Augmented SQLite documents with ${u} auxiliary source file${u===1?"":"s"} (${c.existing} already present).`),c}finally{i.close()}}function ft(e,t){let n=mt(e,t);if(n)return n;let r=[],i=o=>{let s=o?ae(e,o):e,a;try{a=pt(s,{withFileTypes:!0})}catch{return}for(let u of a){if(oe.has(u.name))continue;let c=o?`${o}/${u.name}`:u.name;if(u.isDirectory()){i(c);continue}t.has(I(u.name).toLowerCase())&&r.push(c)}};return i(""),r.sort()}function mt(e,t){try{return lt("git",["-C",e,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:26214400,stdio:["ignore","pipe","ignore"]}).split(`
3
- `).filter(r=>r&&t.has(I(r).toLowerCase())).sort()}catch{return null}}function ht(e,t){let n=new Set,r=500;for(let i=0;i<t.length;i+=r){let o=t.slice(i,i+r),s=e.prepare(`SELECT relative_path FROM documents WHERE relative_path IN (${o.map(()=>"?").join(",")})`).all(...o);for(let a of s)n.add(a.relative_path)}return n}function yt(e){return I(e).toLowerCase()===".vue"?"vue":I(e).replace(/^\./,"").toLowerCase()||"source"}import{execFileSync as bt}from"child_process";import{existsSync as St,readdirSync as ce}from"fs";import{extname as le,join as ge}from"path";var xt=new Set([".git",".hg",".svn",".idea",".vscode","node_modules","vendor","dist","build","target","bin","obj",".dart_tool",".gradle",".next",".venv","venv","__pycache__"]),Rt=[{language:"typescript",files:["tsconfig.json","tsconfig.base.json"],extensions:[".ts",".tsx",".mts",".cts"]},{language:"rust",files:["Cargo.toml"],extensions:[".rs"]},{language:"go",files:["go.mod"],extensions:[".go"]},{language:"java",files:["pom.xml","build.gradle","build.gradle.kts"],extensions:[".java"]},{language:"kotlin",files:["build.gradle.kts"],extensions:[".kt",".kts"]},{language:"scala",files:["build.sbt"],extensions:[".scala"]},{language:"python",files:["pyproject.toml","setup.py","setup.cfg","Pipfile"],extensions:[".py",".pyi"]},{language:"ruby",files:["Gemfile"],extensions:[".rb"]},{language:"cpp",files:["compile_commands.json","CMakeLists.txt","Makefile"],extensions:[".cc",".cpp",".cxx",".hpp",".hh",".hxx"]},{language:"c",files:["compile_commands.json","CMakeLists.txt","Makefile"],extensions:[".c",".h"]},{language:"csharp",globs:["*.csproj","*.sln"],extensions:[".cs"]},{language:"vb",globs:["*.vbproj"],extensions:[".vb"]},{language:"dart",files:["pubspec.yaml"],extensions:[".dart"]},{language:"php",files:["composer.json"],extensions:[".php"]},{language:"javascript",files:["package.json"],extensions:[".js",".jsx",".mjs",".cjs"]}];function V(e){let t=[],n=vt(e),r=Lt(e);for(let i of Rt){if(kt(e,i.files)){t.push(i.language);continue}if(Pt(n,i.globs)){t.push(i.language);continue}wt(r,i.extensions)&&t.push(i.language)}return t.includes("typescript")&&ue(t,"javascript"),t.includes("cpp")&&!r.has(".c")&&ue(t,"c"),t}function vt(e){try{return ce(e)}catch{return[]}}function kt(e,t){return t?.length?t.some(n=>St(ge(e,n))):!1}function Pt(e,t){return t?.length?e.some(n=>t.some(r=>It(n,r))):!1}function It(e,t){if(t==="*")return!0;if(!t.includes("*"))return e===t;let[n,r]=t.split("*");return e.startsWith(n??"")&&e.endsWith(r??"")}function Lt(e){let t=jt(e);if(t)return t;let n=new Set,r=[e];for(;r.length>0;){let i=r.pop();if(!i)continue;let o;try{o=ce(i,{withFileTypes:!0})}catch{continue}for(let s of o){if(s.name.startsWith(".")&&!s.name.endsWith("proj")&&!s.name.endsWith("sln")&&s.isDirectory())continue;let a=ge(i,s.name);if(s.isDirectory()){xt.has(s.name)||r.push(a);continue}let u=le(s.name).toLowerCase();u&&n.add(u)}}return n}function jt(e){try{let t=bt("git",["-C",e,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:26214400,stdio:["ignore","pipe","ignore"]}),n=new Set;for(let r of t.split(`
4
- `)){if(!r)continue;let i=le(r).toLowerCase();i&&n.add(i)}return n}catch{return null}}function wt(e,t){return t?.length?t.some(n=>e.has(n)):!1}function ue(e,t){let n=e.indexOf(t);n!==-1&&e.splice(n,1)}import{existsSync as pe,readdirSync as Ct}from"fs";import{join as N}from"path";var fe={typescript:{language:"typescript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,pnpmWorkspaces:t,indexerBinary:n,projectPath:r})=>{let i=r?["index","--output",e,"--no-progress-bar",r]:["index","--infer-tsconfig","--output",e,"--no-progress-bar"];return t&&!r&&i.splice(1,0,"--pnpm-workspaces"),{binary:n,args:i}},markerFiles:["tsconfig.json"],installMethods:[{label:"npm",prerequisite:"npm",binary:"npm",args:["install","-g","@sourcegraph/scip-typescript"]}],installUrl:"https://github.com/sourcegraph/scip-typescript",bundledNpmPackage:"@sourcegraph/scip-typescript"},javascript:{language:"javascript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,indexerBinary:t})=>({binary:t,args:["index","--infer-tsconfig","--output",e,"--no-progress-bar"]}),markerFiles:["package.json"],installMethods:[{label:"npm",prerequisite:"npm",binary:"npm",args:["install","-g","@sourcegraph/scip-typescript"]}],installUrl:"https://github.com/sourcegraph/scip-typescript",bundledNpmPackage:"@sourcegraph/scip-typescript"},java:{language:"java",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:["pom.xml","build.gradle"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},scala:{language:"scala",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:["build.sbt"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},kotlin:{language:"kotlin",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:["build.gradle.kts"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},rust:{language:"rust",indexerBinary:"rust-analyzer",checkCommand:"rust-analyzer --version",indexArgs:({outputPath:e})=>({binary:"rust-analyzer",args:["scip",".","--output",e]}),markerFiles:["Cargo.toml"],installMethods:[{label:"rustup",prerequisite:"rustup",binary:"rustup",args:["component","add","rust-analyzer"]}],installUrl:"https://github.com/rust-lang/rust-analyzer"},python:{language:"python",indexerBinary:"scip-python-plus",binaryAliases:["scip-python"],checkCommand:"scip-python-plus --version",indexArgs:({outputPath:e,indexerBinary:t})=>({binary:t,args:["index","--output",e,"--project-name","project"]}),markerFiles:["pyproject.toml","setup.py"],installMethods:[{label:"npm",prerequisite:"npm",binary:"npm",args:["install","-g","scip-python-plus"]}],installUrl:"https://github.com/PlunderStruck/scip-python",bundledNpmPackage:"scip-python-plus"},ruby:{language:"ruby",indexerBinary:"scip-ruby",checkCommand:"scip-ruby --version",indexArgs:({indexerBinary:e})=>({binary:e,args:["--dir","."]}),defaultOutputPath:"index.scip",markerFiles:["Gemfile"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-ruby/releases"},go:{language:"go",indexerBinary:"scip-go",checkCommand:"scip-go --version",indexArgs:({outputPath:e})=>({binary:"scip-go",args:["--output",e]}),markerFiles:["go.mod"],installMethods:[{label:"go install",prerequisite:"go",binary:"go",args:["install","github.com/sourcegraph/scip-go@latest"]}],installUrl:"https://github.com/sourcegraph/scip-go"},cpp:{language:"cpp",indexerBinary:"scip-clang",checkCommand:"scip-clang --version",indexArgs:({outputPath:e})=>({binary:"scip-clang",args:["--compdb-path","compile_commands.json","--index-output-path",e]}),markerFiles:["CMakeLists.txt","Makefile"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-clang/releases"},c:{language:"c",indexerBinary:"scip-clang",checkCommand:"scip-clang --version",indexArgs:({outputPath:e})=>({binary:"scip-clang",args:["--compdb-path","compile_commands.json","--index-output-path",e]}),markerFiles:["CMakeLists.txt","Makefile"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-clang/releases"},csharp:{language:"csharp",indexerBinary:"scip-dotnet",checkCommand:"scip-dotnet --version",indexArgs:({projectRoot:e,outputPath:t})=>({binary:"scip-dotnet",args:["index",de(e,[".sln",".csproj"])??e,"--output",t,"--working-directory",e]}),markerFiles:["*.csproj","*.sln"],installMethods:[{label:"dotnet",prerequisite:"dotnet",binary:"dotnet",args:["tool","install","--global","scip-dotnet"]}],installUrl:"https://github.com/sourcegraph/scip-dotnet/releases"},vb:{language:"vb",indexerBinary:"scip-dotnet",checkCommand:"scip-dotnet --version",indexArgs:({projectRoot:e,outputPath:t})=>({binary:"scip-dotnet",args:["index",de(e,[".sln",".vbproj"])??e,"--output",t,"--working-directory",e]}),markerFiles:["*.vbproj","*.sln"],installMethods:[{label:"dotnet",prerequisite:"dotnet",binary:"dotnet",args:["tool","install","--global","scip-dotnet"]}],installUrl:"https://github.com/sourcegraph/scip-dotnet/releases"},dart:{language:"dart",indexerBinary:"scip-dart",checkCommand:"scip-dart --version",indexArgs:({indexerBinary:e,outputPath:t})=>({binary:e,args:["--output",t]}),markerFiles:["pubspec.yaml"],installMethods:[{label:"dart pub",prerequisite:"dart",binary:"dart",args:["pub","global","activate","scip_dart"]}],installUrl:"https://github.com/Workiva/scip-dart/releases"},php:{language:"php",indexerBinary:"scip-php",projectLocalBinaries:["vendor/davidrjenni/scip-php/bin/scip-php","vendor/bin/scip-php"],checkCommand:"scip-php --version",indexArgs:({projectRoot:e,indexerBinary:t})=>{let n=N(e,"vendor","bin","scip-php"),r=N(e,"vendor","davidrjenni","scip-php","bin","scip-php");return{binary:"php",args:["-d","error_reporting=E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED",pe(r)?r:pe(n)?n:t]}},defaultOutputPath:"index.scip",markerFiles:["composer.json"],installMethods:[],installUrl:"https://github.com/davidrjenni/scip-php/releases"}};function L(e){return fe[e]}function de(e,t){let n;try{n=Ct(e)}catch{return null}for(let r of t)for(let i of n)if(i.endsWith(r))return N(e,i);return null}import{readFileSync as Ot,writeFileSync as Tt}from"fs";import{create as A}from"@bufbuild/protobuf";import{deserializeSCIP as Mt,serializeSCIP as Dt,DocumentSchema as Ft,IndexSchema as Et,SymbolInformationSchema as Vt}from"@c4312/scip";function me(e){if(e.length===0)throw new Error("Cannot merge zero SCIP indexes");if(e.length===1)return e[0];let t=Nt(e),n=At(e.flatMap(i=>i.documents??[])),r=he(e.flatMap(i=>i.externalSymbols??[]));return A(Et,{metadata:t,documents:n,externalSymbols:r})}function j(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let n=e.map(i=>Mt(Ot(i))),r=me(n);return Tt(t,Buffer.from(Dt(r))),{documentCount:r.documents.length,externalSymbolCount:r.externalSymbols.length,inputCount:e.length}}function Nt(e){let t=e[0]?.metadata;if(!t)return;let n=t.projectRoot;for(let r of e.slice(1)){let i=r.metadata?.projectRoot;if(n&&i&&i!==n)throw new Error(`Cannot merge SCIP indexes with different project roots: ${n} vs ${i}`)}return t}function At(e){let t=new Map;for(let n of e){let r=t.get(n.relativePath);if(!r){t.set(n.relativePath,n);continue}t.set(n.relativePath,A(Ft,{language:r.language||n.language,relativePath:r.relativePath||n.relativePath,occurrences:$t([...r.occurrences,...n.occurrences]),symbols:he([...r.symbols,...n.symbols]),text:Bt(r.text,n.text),positionEncoding:r.positionEncoding||n.positionEncoding}))}return[...t.values()]}function $t(e){let t=new Set,n=[];for(let r of e){let i=JSON.stringify(r);t.has(i)||(t.add(i),n.push(r))}return n}function he(e){let t=new Map;for(let n of e){let r=t.get(n.symbol);if(!r){t.set(n.symbol,n);continue}t.set(n.symbol,A(Vt,{symbol:r.symbol,documentation:Wt([...r.documentation,...n.documentation]),relationships:_t([...r.relationships,...n.relationships]),kind:r.kind||n.kind,displayName:r.displayName||n.displayName,enclosingSymbol:r.enclosingSymbol||n.enclosingSymbol,signatureDocumentation:r.signatureDocumentation??n.signatureDocumentation}))}return[...t.values()]}function _t(e){let t=new Set,n=[];for(let r of e){let i=[r.symbol,r.isReference?"1":"0",r.isImplementation?"1":"0",r.isTypeDefinition?"1":"0",r.isDefinition?"1":"0"].join("|");t.has(i)||(t.add(i),n.push(r))}return n}function Bt(e,t){return e?t?e.length>=t.length?e:t:e:t}function Wt(e){return[...new Set(e)]}import{execFileSync as Ut}from"child_process";import{createHash as Jt}from"crypto";import{readdirSync as Gt,readFileSync as qt}from"fs";import{join as be}from"path";function ye(e){return(Ht(e)??Kt(e)).filter(t=>t&&!Se(t)).sort()}function R(e,t={}){return(t.language?ye(e).filter(r=>zt(r,t.language,t.markerFiles)):ye(e)).map(r=>{let i=be(e,r);try{let o=qt(i);return{path:r,size:o.byteLength,hash:Jt("sha256").update(o).digest("hex")}}catch{return{path:r,size:-1,hash:"unreadable"}}})}function zt(e,t,n){let r=e.split("/").at(-1)??e;if(n?.includes(e)||n?.includes(r)||Yt.has(r))return!0;let i=e.includes(".")?`.${e.split(".").at(-1).toLowerCase()}`:"";return(Qt[t]??[]).includes(i)}function Ht(e){try{return Ut("git",["-C",e,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:50*1024*1024,stdio:["ignore","pipe","ignore"]}).split(`
5
- `).filter(Boolean)}catch{return null}}function Kt(e){let t=[],n=[""];for(;n.length>0;){let r=n.pop(),i=r?be(e,r):e,o;try{o=Gt(i,{withFileTypes:!0})}catch{continue}for(let s of o){let a=r?`${r}/${s.name}`:s.name;if(s.isDirectory()){Se(a)||n.push(a);continue}t.push(a)}}return t}function Se(e){return e.split("/").some(n=>Xt.has(n))||e.endsWith(".db")||e.endsWith(".db-wal")||e.endsWith(".db-shm")||e.endsWith(".scip")}var Xt=new Set([".git","node_modules",".scipquery-cache",".stryker-tmp","dist","build","coverage",".next",".nuxt","target"]),Yt=new Set(["package.json","package-lock.json","pnpm-lock.yaml","yarn.lock","bun.lockb","tsconfig.json","tsconfig.base.json","pyproject.toml","setup.py","setup.cfg","Cargo.toml","Cargo.lock","go.mod","go.sum","pom.xml","build.gradle","build.gradle.kts","build.sbt","compile_commands.json","CMakeLists.txt","Makefile","Gemfile","Gemfile.lock","composer.json","composer.lock","pubspec.yaml","pubspec.lock"]),Qt={typescript:[".ts",".tsx",".mts",".cts"],javascript:[".js",".jsx",".mjs",".cjs"],java:[".java"],scala:[".scala"],kotlin:[".kt",".kts"],rust:[".rs"],python:[".py",".pyi"],ruby:[".rb"],go:[".go"],cpp:[".cc",".cpp",".cxx",".hpp",".hh",".hxx"],c:[".c",".h"],csharp:[".cs"],vb:[".vb"],dart:[".dart"],php:[".php"]};import{readFileSync as Zt,writeFileSync as en}from"fs";import{create as xe}from"@bufbuild/protobuf";import{deserializeSCIP as tn,DocumentSchema as nn,IndexSchema as rn,serializeSCIP as on,SymbolRole as sn}from"@c4312/scip";function Re(e){let t;try{t=tn(Zt(e))}catch{return{removedDefinitionOccurrences:0,touchedDocuments:0}}let n=an(t);return n.removedDefinitionOccurrences>0&&en(e,Buffer.from(on(n.index))),{removedDefinitionOccurrences:n.removedDefinitionOccurrences,touchedDocuments:n.touchedDocuments}}function an(e){let t=new Set;for(let o of e.documents)for(let s of o.symbols)s.symbol&&t.add(s.symbol);for(let o of e.externalSymbols)o.symbol&&t.add(o.symbol);let n=0,r=0,i=[];for(let o of e.documents){let s=o.occurrences.filter(a=>(a.symbolRoles&sn.Definition)===0||t.has(a.symbol)?!0:(n+=1,!1));if(s.length===o.occurrences.length){i.push(o);continue}r+=1,i.push(xe(nn,{language:o.language,relativePath:o.relativePath,occurrences:s,symbols:o.symbols,text:o.text,positionEncoding:o.positionEncoding}))}return{index:n===0?e:xe(rn,{metadata:e.metadata,documents:i,externalSymbols:e.externalSymbols}),removedDefinitionOccurrences:n,touchedDocuments:r}}import{existsSync as un,readFileSync as cn,readdirSync as ln,statSync as gn}from"fs";import d from"path";var pn=new Set([".cache",".git",".next",".nuxt",".turbo",".nx","build","coverage","dist","node_modules","tmp","vendor"]);function ve(e,t=[]){let n=d.resolve(e),r=dn(n),i=t.flatMap(u=>fn(n,u)),o=hn([...r,...i]),s=yn(n,o)?[n,...o]:o,a=s.length>0?s:[n];return[...new Set(a.map(u=>Sn(n,u)))].sort((u,c)=>u.localeCompare(c))}function dn(e){let t=[],n=[e];for(;n.length>0;){let r=n.pop(),i;try{i=ln(r,{withFileTypes:!0})}catch{continue}for(let o of i){let s=d.join(r,o.name);if(o.isDirectory()){!pn.has(o.name)&&!o.name.startsWith(".")&&n.push(s);continue}o.isFile()&&mn(s)&&t.push(d.dirname(s))}}return t}function fn(e,t){let n=t.trim();if(!n)return[];let r=d.resolve(e,n);if(!Rn(e,r))return[];try{let i=gn(r);if(i.isDirectory())return[r];if(i.isFile()&&ke(d.basename(r)))return[d.dirname(r)]}catch{return[]}return[]}function mn(e){if(!ke(d.basename(e)))return!1;let t=Pe(e);return t?d.basename(e)==="tsconfig.json"||"include"in t||"files"in t||"references"in t:!1}function ke(e){return e.startsWith("tsconfig")&&e.endsWith(".json")}function hn(e){let t=[...new Set(e.map(n=>d.resolve(n)))].sort((n,r)=>n.localeCompare(r));return t.length<=1?t:t.filter(n=>!t.some(r=>r!==n&&xn(n,r)))}function yn(e,t){if(t.length===0||t.some(r=>d.resolve(r)===e))return!1;let n=d.join(e,"tsconfig.json");return un(n)&&bn(n)}function bn(e){let n=Pe(e)?.include;return Array.isArray(n)?n.some(r=>typeof r=="string"&&r.trim()!==""&&!r.startsWith("!")&&(r.includes("/")||r.includes("**")||!d.extname(r))):!1}function Pe(e){try{let t=JSON.parse(cn(e,"utf-8"));return t&&typeof t=="object"&&!Array.isArray(t)?t:null}catch{return null}}function Sn(e,t){let n=d.relative(e,t);return n?n.split(d.sep).join("/"):"."}function xn(e,t){let n=d.relative(e,t);return!!n&&!n.startsWith("..")&&!d.isAbsolute(n)}function Rn(e,t){let n=d.relative(e,t);return!n.startsWith("..")&&!d.isAbsolute(n)}import{execFile as vn}from"child_process";import{existsSync as w,renameSync as _,rmSync as B}from"fs";import{cpus as kn}from"os";import{join as Ie}from"path";function Pn(e,t,n){if(!e.defaultOutputPath)return;let r=Ie(t,e.defaultOutputPath);n!==r&&w(r)&&_(r,n)}function In(e,t,n){if(!e.defaultOutputPath)return null;let r=Ie(t,e.defaultOutputPath);if(r===n)return null;let i=`${n}.default-output-backup`;return B(i,{force:!0}),w(r)?(_(r,i),{defaultOutputPath:r,backupPath:i}):{defaultOutputPath:r,backupPath:null}}function Ln(e){e&&(B(e.defaultOutputPath,{force:!0}),e.backupPath&&w(e.backupPath)&&_(e.backupPath,e.defaultOutputPath))}function jn(e,t){if(e<=1)return 1;let n=Number(process.env.SCIP_QUERY_INDEXER_CONCURRENCY??0),r=Number.isFinite(t)&&t&&t>0?t:Number.isFinite(n)&&n>0?n:Math.min(8,Math.max(1,kn().length));return Math.max(1,Math.min(e,Math.floor(r)))}async function Le(e,t,n,r){let i=e.filter(c=>c.config.defaultOutputPath),o=e.filter(c=>!c.config.defaultOutputPath),s=[],a=jn(o.length,r),u=await Cn(o,a,c=>$(c,t,n));if(a>1){let c=new Map;for(let g of u.filter(l=>l.skipped)){let l=o.find(p=>p.id===g.id);l&&(n(`Retrying ${l.label} indexer serially after parallel failure...`),c.set(l.id,await $(l,t,n)))}s.push(...u.map(g=>c.get(g.id)??g))}else s.push(...u);for(let c of i)s.push(await $(c,t,n));return s.sort((c,g)=>e.findIndex(l=>l.id===c.id)-e.findIndex(l=>l.id===g.id))}async function $(e,t,n){n(`Indexing ${e.label} with ${e.resolvedBinary}...`),B(e.scipPath,{force:!0});let r=In(e.config,t,e.scipPath);try{await wn(e.binary,e.args,{cwd:t,env:e.env,maxBuffer:50*1024*1024}),Pn(e.config,t,e.scipPath)}catch(i){let o=i instanceof Error?i.message:String(i),s=`${e.resolvedBinary} indexer failed: ${o.split(`
6
- `)[0]}`,a=e.label===e.language?s:`${e.label}: ${s}`;return n(`Skipping ${e.label}: ${s}`),{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,skipped:{language:e.language,reason:a}}}finally{Ln(r)}if(!w(e.scipPath)){let i=`${e.resolvedBinary} indexer completed but did not produce ${e.scipPath}`,o=e.label===e.language?i:`${e.label}: ${i}`;return n(`Skipping ${e.label}: ${i}`),{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,skipped:{language:e.language,reason:o}}}return{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath}}function wn(e,t,n){return new Promise((r,i)=>{vn(e,[...t],n,o=>{o?i(o):r()})})}async function Cn(e,t,n){if(e.length===0)return[];let r=new Array(e.length),i=0,o=Math.max(1,Math.min(e.length,t)),s=Array.from({length:o},async()=>{for(;i<e.length;){let a=i++;r[a]=await n(e[a])}});return await Promise.all(s),r}import{execFileSync as U}from"child_process";import{existsSync as W,readFileSync as On}from"fs";import{createRequire as Tn}from"module";import{platform as Mn}from"os";import{dirname as je,join as C}from"path";var Dn=Tn(import.meta.url);function J(e){return[e.indexerBinary,...e.binaryAliases??[]]}function O(e){let t=J(e);return t.length===1?t[0]:t.join(" or ")}function v(e){for(let t of J(e))if(x(t))return t;return En(e)}function G(e){return v(e)!==null||Fn(e)}function Fn(e){return we(e)!==null}function En(e){let t=we(e);if(!t)return null;let r=JSON.parse(On(t,"utf8")).bin;if(!r)return null;if(typeof r=="string")return C(je(t),r);for(let i of J(e)){let o=r[i];if(o)return C(je(t),o)}return null}function we(e){if(!e.bundledNpmPackage)return null;try{return Dn.resolve(`${e.bundledNpmPackage}/package.json`)}catch{return null}}function q(e,t){for(let n of e.projectLocalBinaries??[]){let r=C(t,n);if(W(r))return r}return null}function z(e,t=process.env,n=e.indexerBinary){if(e.indexerBinary!=="scip-dotnet"||Ce(n,t))return t;let r=Vn(n,t);return r?{...t,DOTNET_ROOT:r}:t}function H(e,t){let n=e.installMethods,r=O(e);if(!n?.length)return t(`No auto-install method available for ${r}.`),e.installUrl&&t(`Install manually from: ${e.installUrl}`),!1;for(let i of n)if(x(i.prerequisite)){t(`Installing ${r} via ${i.label}...`);try{U(i.binary,i.args,{stdio:"inherit",timeout:3e5,env:process.env});let o=v(e);if(o){let s=o===e.indexerBinary?"":` (using ${o})`;return t(`Successfully installed ${r} via ${i.label}${s}`),!0}t(`${i.label} command completed but ${r} was not found on PATH`)}catch(o){let s=o instanceof Error?o.message:String(o);t(`${i.label} install failed: ${s}`)}}return t(`Could not auto-install ${r}.`),e.installUrl&&t(`Install manually from: ${e.installUrl}`),!1}function Vn(e,t){for(let n of Nn(t))if(Ce(e,{...t,DOTNET_ROOT:n}))return n;return null}function Nn(e){let t=[],n=e.DOTNET_ROOT;if(n&&W(n)&&t.push(n),Mn()==="darwin"&&x("brew"))try{let r=U("brew",["--prefix","dotnet@9"],{stdio:"pipe",env:e}).toString().trim(),i=C(r,"libexec");W(i)&&!t.includes(i)&&t.push(i)}catch{}return t}function Ce(e,t){try{return U(e,["--version"],{stdio:"pipe",env:t}),!0}catch{return!1}}import yr from"better-sqlite3";import{existsSync as br,readFileSync as Sr,writeFileSync as xr}from"fs";import{dirname as Rr,join as vr,resolve as kr}from"path";import{readFileSync as An,rmSync as $n,statSync as _n,mkdtempSync as Bn}from"fs";import{cpus as Wn,tmpdir as Un}from"os";import{join as K}from"path";import{Worker as Jn}from"worker_threads";function Oe(e){return e.length>=8&&Me(e.length)>1}function Te(e){let t=Me(e.vueFiles.length),n=qn(e.vueFiles),r=Hn(n,t),i=new URL("./augment-vue-worker.js",import.meta.url),o=Bn(K(Un(),"scip-query-vue-workers-")),s=new SharedArrayBuffer(4),a=new Int32Array(s),u=Gn(),c=Date.now();try{for(let l=0;l<r.length;l++)new Jn(i,{workerData:{projectRoot:e.projectRoot,dbPath:e.dbPath,tsconfig:e.tsconfig,tasks:r[l],resultPath:K(o,`${l}.json`),sharedBuffer:s}});for(;Atomics.load(a,0)<r.length;){if(Date.now()-c>u)throw new Error(`Vue reference workers timed out after ${(u/1e3).toFixed(0)}s`);Atomics.wait(a,0,Atomics.load(a,0),100)}let g=r.map((l,p)=>{let h=JSON.parse(An(K(o,`${p}.json`),"utf-8"));if(!h.ok)throw new Error(`Vue reference worker failed: ${h.error}`);return h.result});return{occurrences:g.flatMap(l=>l.occurrences),skippedReferences:g.reduce((l,p)=>l+p.skippedReferences,0)}}finally{$n(o,{recursive:!0,force:!0})}}function Me(e){let t=Number(process.env.SCIP_QUERY_AUGMENT_VUE_WORKERS??0),n=Number.isFinite(t)&&t>0?t:Math.min(8,Math.max(1,Wn().length-1));return Math.max(1,Math.min(e,n))}function Gn(){let e=Number(process.env.SCIP_QUERY_AUGMENT_VUE_WORKER_TIMEOUT_MS??0);return Number.isFinite(e)&&e>0?e:3e5}function qn(e){let t=zn(),n=[];for(let r of e){let i=De(r),o=Math.max(1,Math.ceil(i/t));for(let s=0;s<o;s++)n.push({fileName:r,startOffset:Math.floor(i*s/o),endOffset:s===o-1?Number.POSITIVE_INFINITY:Math.floor(i*(s+1)/o),countFileSkip:s===0})}return n}function zn(){return Number.POSITIVE_INFINITY}function Hn(e,t){let n=Array.from({length:t},()=>({tasks:[],weight:0})),r=e.map(i=>({task:i,weight:Kn(i)})).sort((i,o)=>o.weight-i.weight);for(let i of r){let o=n.reduce((s,a)=>a.weight<s.weight?a:s);o.tasks.push(i.task),o.weight+=i.weight}return n.map(i=>i.tasks).filter(i=>i.length>0)}function Kn(e){return Number.isFinite(e.endOffset)?Math.max(1,e.endOffset-e.startOffset):Math.max(1,De(e.fileName)-e.startOffset)}function De(e){try{return _n(e).size}catch{return 1}}import{createRequire as Xn}from"module";import{existsSync as Yn,readFileSync as Y}from"fs";import{dirname as Fe,extname as Qn,join as Ee,relative as Zn,resolve as er}from"path";import{pathToFileURL as tr}from"url";function nr(e){e.transaction(()=>{e.prepare(`
1
+ import{a as R,b as E,f as V}from"./chunk-ONPCQ2PM.js";import{a as ae}from"./chunk-UUBMFL3F.js";import{a as oe,b as se}from"./chunk-AREANYIA.js";import"./chunk-64MNV6AB.js";import"./chunk-7S5E7KWT.js";import{execFileSync as Gr}from"child_process";import{closeSync as Hr,copyFileSync as zr,existsSync as M,mkdirSync as ne,mkdtempSync as Kr,openSync as Xr,readFileSync as D,renameSync as k,rmSync as I,writeFileSync as rt}from"fs";import{basename as T,dirname as f,extname as Yr,join as m}from"path";import ft from"better-sqlite3";import{execFileSync as mt}from"child_process";import{existsSync as ht,readdirSync as yt,readFileSync as bt}from"fs";import{extname as j,join as ue}from"path";function x(e={}){return{id:"auxiliary-documents",facts:["auxiliary-document"],run:t=>ce({projectRoot:t.projectRoot,dbPath:t.dbPath,extensions:e.extensions,onStatus:t.onStatus})}}function ce(e){let t=new Set((e.extensions??oe).map(o=>o.toLowerCase()));if(t.size===0)return{scanned:0,inserted:0,existing:0};if(!ht(e.dbPath))throw new Error(`SCIP SQLite database not found at ${e.dbPath}`);let n=ae(e.projectRoot),r=xt(e.projectRoot,t).filter(o=>!n.isIgnored(o)),i=new ft(e.dbPath);try{let o=Rt(i,r),s=i.prepare(`INSERT OR IGNORE INTO documents (language, relative_path, position_encoding, text)
2
+ VALUES (?, ?, NULL, ?)`),u=i.transaction(g=>{let l=0;for(let p of g){if(o.has(p))continue;let h=bt(ue(e.projectRoot,p),"utf-8"),dt=s.run(Pt(p),p,h);l+=Number(dt.changes)}return l})(r),c={scanned:r.length,inserted:u,existing:r.length-u};return e.onStatus?.(`Augmented SQLite documents with ${u} auxiliary source file${u===1?"":"s"} (${c.existing} already present).`),c}finally{i.close()}}function xt(e,t){let n=St(e,t);if(n)return n;let r=[],i=o=>{let s=o?ue(e,o):e,a;try{a=yt(s,{withFileTypes:!0})}catch{return}for(let u of a){if(se.has(u.name))continue;let c=o?`${o}/${u.name}`:u.name;if(u.isDirectory()){i(c);continue}t.has(j(u.name).toLowerCase())&&r.push(c)}};return i(""),r.sort()}function St(e,t){try{return mt("git",["-C",e,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:26214400,stdio:["ignore","pipe","ignore"]}).split(`
3
+ `).filter(r=>r&&t.has(j(r).toLowerCase())).sort()}catch{return null}}function Rt(e,t){let n=new Set,r=500;for(let i=0;i<t.length;i+=r){let o=t.slice(i,i+r),s=e.prepare(`SELECT relative_path FROM documents WHERE relative_path IN (${o.map(()=>"?").join(",")})`).all(...o);for(let a of s)n.add(a.relative_path)}return n}function Pt(e){return j(e).toLowerCase()===".vue"?"vue":j(e).replace(/^\./,"").toLowerCase()||"source"}import{execFileSync as vt}from"child_process";import{existsSync as kt,readdirSync as ge}from"fs";import{extname as pe,join as de}from"path";var It=new Set([".git",".hg",".svn",".idea",".vscode","node_modules","vendor","dist","build","target","bin","obj",".dart_tool",".gradle",".next",".venv","venv","__pycache__"]),jt=[{language:"typescript",files:["tsconfig.json","tsconfig.base.json"],extensions:[".ts",".tsx",".mts",".cts"]},{language:"rust",files:["Cargo.toml"],extensions:[".rs"]},{language:"go",files:["go.mod"],extensions:[".go"]},{language:"java",files:["pom.xml","build.gradle","build.gradle.kts"],extensions:[".java"]},{language:"kotlin",files:["build.gradle.kts"],extensions:[".kt",".kts"]},{language:"scala",files:["build.sbt"],extensions:[".scala"]},{language:"clojure",files:["deps.edn","project.clj","bb.edn","shadow-cljs.edn"],extensions:[".clj",".cljs",".cljc"]},{language:"python",files:["pyproject.toml","setup.py","setup.cfg","Pipfile"],extensions:[".py",".pyi"]},{language:"ruby",files:["Gemfile"],extensions:[".rb"]},{language:"cpp",files:["compile_commands.json","CMakeLists.txt","Makefile"],extensions:[".cc",".cpp",".cxx",".hpp",".hh",".hxx"]},{language:"c",files:["compile_commands.json","CMakeLists.txt","Makefile"],extensions:[".c",".h"]},{language:"csharp",globs:["*.csproj","*.sln"],extensions:[".cs"]},{language:"vb",globs:["*.vbproj"],extensions:[".vb"]},{language:"dart",files:["pubspec.yaml"],extensions:[".dart"]},{language:"php",files:["composer.json"],extensions:[".php"]},{language:"javascript",files:["package.json"],extensions:[".js",".jsx",".mjs",".cjs"]}];function A(e){let t=[],n=Ct(e),r=Ft(e);for(let i of jt){if(wt(e,i.files)){t.push(i.language);continue}if(Lt(n,i.globs)){t.push(i.language);continue}Mt(r,i.extensions)&&t.push(i.language)}return t.includes("typescript")&&le(t,"javascript"),t.includes("cpp")&&!r.has(".c")&&le(t,"c"),t}function Ct(e){try{return ge(e)}catch{return[]}}function wt(e,t){return t?.length?t.some(n=>kt(de(e,n))):!1}function Lt(e,t){return t?.length?e.some(n=>t.some(r=>Ot(n,r))):!1}function Ot(e,t){if(t==="*")return!0;if(!t.includes("*"))return e===t;let[n,r]=t.split("*");return e.startsWith(n??"")&&e.endsWith(r??"")}function Ft(e){let t=Tt(e);if(t)return t;let n=new Set,r=[e];for(;r.length>0;){let i=r.pop();if(!i)continue;let o;try{o=ge(i,{withFileTypes:!0})}catch{continue}for(let s of o){if(s.name.startsWith(".")&&!s.name.endsWith("proj")&&!s.name.endsWith("sln")&&s.isDirectory())continue;let a=de(i,s.name);if(s.isDirectory()){It.has(s.name)||r.push(a);continue}let u=pe(s.name).toLowerCase();u&&n.add(u)}}return n}function Tt(e){try{let t=vt("git",["-C",e,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:26214400,stdio:["ignore","pipe","ignore"]}),n=new Set;for(let r of t.split(`
4
+ `)){if(!r)continue;let i=pe(r).toLowerCase();i&&n.add(i)}return n}catch{return null}}function Mt(e,t){return t?.length?t.some(n=>e.has(n)):!1}function le(e,t){let n=e.indexOf(t);n!==-1&&e.splice(n,1)}import{existsSync as fe,readdirSync as Dt}from"fs";import{isAbsolute as Et,join as N,resolve as Vt}from"path";var he={typescript:{language:"typescript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,pnpmWorkspaces:t,indexerBinary:n,projectPath:r})=>{let i=r?["index","--output",e,"--no-progress-bar",r]:["index","--infer-tsconfig","--output",e,"--no-progress-bar"];return t&&!r&&i.splice(1,0,"--pnpm-workspaces"),{binary:n,args:i}},markerFiles:["tsconfig.json"],installMethods:[{label:"npm",prerequisite:"npm",binary:"npm",args:["install","-g","@sourcegraph/scip-typescript"]}],installUrl:"https://github.com/sourcegraph/scip-typescript",bundledNpmPackage:"@sourcegraph/scip-typescript"},javascript:{language:"javascript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,indexerBinary:t})=>({binary:t,args:["index","--infer-tsconfig","--output",e,"--no-progress-bar"]}),markerFiles:["package.json"],installMethods:[{label:"npm",prerequisite:"npm",binary:"npm",args:["install","-g","@sourcegraph/scip-typescript"]}],installUrl:"https://github.com/sourcegraph/scip-typescript",bundledNpmPackage:"@sourcegraph/scip-typescript"},java:{language:"java",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:["pom.xml","build.gradle"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},scala:{language:"scala",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:["build.sbt"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},kotlin:{language:"kotlin",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:["build.gradle.kts"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},rust:{language:"rust",indexerBinary:"rust-analyzer",checkCommand:"rust-analyzer --version",indexArgs:({outputPath:e})=>({binary:"rust-analyzer",args:["scip",".","--output",e]}),markerFiles:["Cargo.toml"],installMethods:[{label:"rustup",prerequisite:"rustup",binary:"rustup",args:["component","add","rust-analyzer"]}],installUrl:"https://github.com/rust-lang/rust-analyzer"},python:{language:"python",indexerBinary:"scip-python-plus",binaryAliases:["scip-python"],checkCommand:"scip-python-plus --version",indexArgs:({outputPath:e,indexerBinary:t})=>({binary:t,args:["index","--output",e,"--project-name","project"]}),markerFiles:["pyproject.toml","setup.py"],installMethods:[{label:"npm",prerequisite:"npm",binary:"npm",args:["install","-g","scip-python-plus"]}],installUrl:"https://github.com/PlunderStruck/scip-python",bundledNpmPackage:"scip-python-plus"},clojure:{language:"clojure",indexerBinary:"scip-clojure",projectLocalBinaries:["node_modules/.bin/scip-clojure"],checkCommand:"scip-clojure -h",indexArgs:({projectRoot:e,outputPath:t,indexerBinary:n,configPath:r})=>{let i=["-root",e,"-output",t];return r&&i.push("-config",Et(r)?r:Vt(e,r)),{binary:n,args:i}},markerFiles:["deps.edn","project.clj","bb.edn","shadow-cljs.edn"],installMethods:[{label:"npm",prerequisite:"npm",binary:"npm",args:["install","-g","scip-clojure"]}],installUrl:"https://github.com/PlunderStruck/scip-clojure"},ruby:{language:"ruby",indexerBinary:"scip-ruby",checkCommand:"scip-ruby --version",indexArgs:({indexerBinary:e})=>({binary:e,args:["--dir","."]}),defaultOutputPath:"index.scip",markerFiles:["Gemfile"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-ruby/releases"},go:{language:"go",indexerBinary:"scip-go",checkCommand:"scip-go --version",indexArgs:({outputPath:e})=>({binary:"scip-go",args:["--output",e]}),markerFiles:["go.mod"],installMethods:[{label:"go install",prerequisite:"go",binary:"go",args:["install","github.com/sourcegraph/scip-go@latest"]}],installUrl:"https://github.com/sourcegraph/scip-go"},cpp:{language:"cpp",indexerBinary:"scip-clang",checkCommand:"scip-clang --version",indexArgs:({outputPath:e})=>({binary:"scip-clang",args:["--compdb-path","compile_commands.json","--index-output-path",e]}),markerFiles:["CMakeLists.txt","Makefile"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-clang/releases"},c:{language:"c",indexerBinary:"scip-clang",checkCommand:"scip-clang --version",indexArgs:({outputPath:e})=>({binary:"scip-clang",args:["--compdb-path","compile_commands.json","--index-output-path",e]}),markerFiles:["CMakeLists.txt","Makefile"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-clang/releases"},csharp:{language:"csharp",indexerBinary:"scip-dotnet",checkCommand:"scip-dotnet --version",indexArgs:({projectRoot:e,outputPath:t})=>({binary:"scip-dotnet",args:["index",me(e,[".sln",".csproj"])??e,"--output",t,"--working-directory",e]}),markerFiles:["*.csproj","*.sln"],installMethods:[{label:"dotnet",prerequisite:"dotnet",binary:"dotnet",args:["tool","install","--global","scip-dotnet"]}],installUrl:"https://github.com/sourcegraph/scip-dotnet/releases"},vb:{language:"vb",indexerBinary:"scip-dotnet",checkCommand:"scip-dotnet --version",indexArgs:({projectRoot:e,outputPath:t})=>({binary:"scip-dotnet",args:["index",me(e,[".sln",".vbproj"])??e,"--output",t,"--working-directory",e]}),markerFiles:["*.vbproj","*.sln"],installMethods:[{label:"dotnet",prerequisite:"dotnet",binary:"dotnet",args:["tool","install","--global","scip-dotnet"]}],installUrl:"https://github.com/sourcegraph/scip-dotnet/releases"},dart:{language:"dart",indexerBinary:"scip-dart",checkCommand:"scip-dart --version",indexArgs:({indexerBinary:e,outputPath:t})=>({binary:e,args:["--output",t]}),markerFiles:["pubspec.yaml"],installMethods:[{label:"dart pub",prerequisite:"dart",binary:"dart",args:["pub","global","activate","scip_dart"]}],installUrl:"https://github.com/Workiva/scip-dart/releases"},php:{language:"php",indexerBinary:"scip-php",projectLocalBinaries:["vendor/davidrjenni/scip-php/bin/scip-php","vendor/bin/scip-php"],checkCommand:"scip-php --version",indexArgs:({projectRoot:e,indexerBinary:t})=>{let n=N(e,"vendor","bin","scip-php"),r=N(e,"vendor","davidrjenni","scip-php","bin","scip-php");return{binary:"php",args:["-d","error_reporting=E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED",fe(r)?r:fe(n)?n:t]}},defaultOutputPath:"index.scip",markerFiles:["composer.json"],installMethods:[],installUrl:"https://github.com/davidrjenni/scip-php/releases"}};function C(e){return he[e]}function me(e,t){let n;try{n=Dt(e)}catch{return null}for(let r of t)for(let i of n)if(i.endsWith(r))return N(e,i);return null}import{readFileSync as At,writeFileSync as Nt}from"fs";import{create as $}from"@bufbuild/protobuf";import{deserializeSCIP as $t,serializeSCIP as _t,DocumentSchema as Bt,IndexSchema as Wt,SymbolInformationSchema as Ut}from"@c4312/scip";function ye(e){if(e.length===0)throw new Error("Cannot merge zero SCIP indexes");if(e.length===1)return e[0];let t=Jt(e),n=qt(e.flatMap(i=>i.documents??[])),r=be(e.flatMap(i=>i.externalSymbols??[]));return $(Wt,{metadata:t,documents:n,externalSymbols:r})}function w(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let n=e.map(i=>$t(At(i))),r=ye(n);return Nt(t,Buffer.from(_t(r))),{documentCount:r.documents.length,externalSymbolCount:r.externalSymbols.length,inputCount:e.length}}function Jt(e){let t=e[0]?.metadata;if(!t)return;let n=t.projectRoot;for(let r of e.slice(1)){let i=r.metadata?.projectRoot;if(n&&i&&i!==n)throw new Error(`Cannot merge SCIP indexes with different project roots: ${n} vs ${i}`)}return t}function qt(e){let t=new Map;for(let n of e){let r=t.get(n.relativePath);if(!r){t.set(n.relativePath,n);continue}t.set(n.relativePath,$(Bt,{language:r.language||n.language,relativePath:r.relativePath||n.relativePath,occurrences:Gt([...r.occurrences,...n.occurrences]),symbols:be([...r.symbols,...n.symbols]),text:zt(r.text,n.text),positionEncoding:r.positionEncoding||n.positionEncoding}))}return[...t.values()]}function Gt(e){let t=new Set,n=[];for(let r of e){let i=JSON.stringify(r);t.has(i)||(t.add(i),n.push(r))}return n}function be(e){let t=new Map;for(let n of e){let r=t.get(n.symbol);if(!r){t.set(n.symbol,n);continue}t.set(n.symbol,$(Ut,{symbol:r.symbol,documentation:Kt([...r.documentation,...n.documentation]),relationships:Ht([...r.relationships,...n.relationships]),kind:r.kind||n.kind,displayName:r.displayName||n.displayName,enclosingSymbol:r.enclosingSymbol||n.enclosingSymbol,signatureDocumentation:r.signatureDocumentation??n.signatureDocumentation}))}return[...t.values()]}function Ht(e){let t=new Set,n=[];for(let r of e){let i=[r.symbol,r.isReference?"1":"0",r.isImplementation?"1":"0",r.isTypeDefinition?"1":"0",r.isDefinition?"1":"0"].join("|");t.has(i)||(t.add(i),n.push(r))}return n}function zt(e,t){return e?t?e.length>=t.length?e:t:e:t}function Kt(e){return[...new Set(e)]}import{readFileSync as Xt,writeFileSync as Yt}from"fs";function y(e,t){let n=Date.now(),r=e.run(t);return{stageId:e.id,facts:e.facts,durationMs:Date.now()-n,result:r}}function Se(e){let t=e.readFingerprint(),n=Qt(e.cachePath,t);if(n)return e.onCacheHit?.(n.result),n.result;let r=e.compute();return Zt(e.cachePath,e.readFingerprint(),r),r}function Qt(e,t){try{let n=JSON.parse(Xt(e,"utf-8"));return xe(n.fingerprint)===xe(t)?{result:n.result}:null}catch{return null}}function Zt(e,t,n){Yt(e,`${JSON.stringify({updatedAt:new Date().toISOString(),fingerprint:t,result:n},null,2)}
5
+ `)}function xe(e){return JSON.stringify(e)}import{execFileSync as en}from"child_process";import{createHash as tn}from"crypto";import{readdirSync as nn,readFileSync as rn}from"fs";import{join as Pe}from"path";function Re(e){return(sn(e)??an(e)).filter(t=>t&&!ve(t)).sort()}function P(e,t={}){return(t.language?Re(e).filter(r=>on(r,t.language,t.markerFiles)):Re(e)).map(r=>{let i=Pe(e,r);try{let o=rn(i);return{path:r,size:o.byteLength,hash:tn("sha256").update(o).digest("hex")}}catch{return{path:r,size:-1,hash:"unreadable"}}})}function on(e,t,n){let r=e.split("/").at(-1)??e;if(n?.includes(e)||n?.includes(r)||cn.has(r))return!0;let i=e.includes(".")?`.${e.split(".").at(-1).toLowerCase()}`:"";return(ln[t]??[]).includes(i)}function sn(e){try{return en("git",["-C",e,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:50*1024*1024,stdio:["ignore","pipe","ignore"]}).split(`
6
+ `).filter(Boolean)}catch{return null}}function an(e){let t=[],n=[""];for(;n.length>0;){let r=n.pop(),i=r?Pe(e,r):e,o;try{o=nn(i,{withFileTypes:!0})}catch{continue}for(let s of o){let a=r?`${r}/${s.name}`:s.name;if(s.isDirectory()){ve(a)||n.push(a);continue}t.push(a)}}return t}function ve(e){let t=e.split("/");return e==="meta.json"||t.some(n=>un.has(n))||e.endsWith(".db")||e.endsWith(".db-wal")||e.endsWith(".db-shm")||e.endsWith(".scip")}var un=new Set([".git","node_modules",".scipquery-cache",".stryker-tmp","dist","build","coverage",".next",".nuxt","target"]),cn=new Set(["package.json","package-lock.json","pnpm-lock.yaml","yarn.lock","bun.lockb","tsconfig.json","tsconfig.base.json","pyproject.toml","setup.py","setup.cfg","Cargo.toml","Cargo.lock","go.mod","go.sum","pom.xml","build.gradle","build.gradle.kts","build.sbt","compile_commands.json","CMakeLists.txt","Makefile","Gemfile","Gemfile.lock","composer.json","composer.lock","pubspec.yaml","pubspec.lock","deps.edn","project.clj","bb.edn","shadow-cljs.edn"]),ln={typescript:[".ts",".tsx",".mts",".cts"],javascript:[".js",".jsx",".mjs",".cjs"],java:[".java"],scala:[".scala"],kotlin:[".kt",".kts"],rust:[".rs"],python:[".py",".pyi"],ruby:[".rb"],go:[".go"],cpp:[".cc",".cpp",".cxx",".hpp",".hh",".hxx"],c:[".c",".h"],csharp:[".cs"],vb:[".vb"],dart:[".dart"],php:[".php"],clojure:[".clj",".cljs",".cljc"]};import{readFileSync as gn,writeFileSync as pn}from"fs";import{create as ke}from"@bufbuild/protobuf";import{deserializeSCIP as dn,DocumentSchema as fn,IndexSchema as mn,serializeSCIP as hn,SymbolRole as yn}from"@c4312/scip";function Ie(e){let t;try{t=dn(gn(e))}catch{return{removedDefinitionOccurrences:0,touchedDocuments:0}}let n=bn(t);return n.removedDefinitionOccurrences>0&&pn(e,Buffer.from(hn(n.index))),{removedDefinitionOccurrences:n.removedDefinitionOccurrences,touchedDocuments:n.touchedDocuments}}function bn(e){let t=new Set;for(let o of e.documents)for(let s of o.symbols)s.symbol&&t.add(s.symbol);for(let o of e.externalSymbols)o.symbol&&t.add(o.symbol);let n=0,r=0,i=[];for(let o of e.documents){let s=o.occurrences.filter(a=>(a.symbolRoles&yn.Definition)===0||t.has(a.symbol)?!0:(n+=1,!1));if(s.length===o.occurrences.length){i.push(o);continue}r+=1,i.push(ke(fn,{language:o.language,relativePath:o.relativePath,occurrences:s,symbols:o.symbols,text:o.text,positionEncoding:o.positionEncoding}))}return{index:n===0?e:ke(mn,{metadata:e.metadata,documents:i,externalSymbols:e.externalSymbols}),removedDefinitionOccurrences:n,touchedDocuments:r}}import{existsSync as xn,readFileSync as Sn,readdirSync as Rn,statSync as Pn}from"fs";import d from"path";var vn=new Set([".cache",".git",".next",".nuxt",".turbo",".nx","build","coverage","dist","node_modules","tmp","vendor"]);function je(e,t=[]){let n=d.resolve(e),r=kn(n),i=t.flatMap(u=>In(n,u)),o=Cn([...r,...i]),s=wn(n,o)?[n,...o]:o,a=s.length>0?s:[n];return[...new Set(a.map(u=>On(n,u)))].sort((u,c)=>u.localeCompare(c))}function kn(e){let t=[],n=[e];for(;n.length>0;){let r=n.pop(),i;try{i=Rn(r,{withFileTypes:!0})}catch{continue}for(let o of i){let s=d.join(r,o.name);if(o.isDirectory()){!vn.has(o.name)&&!o.name.startsWith(".")&&n.push(s);continue}o.isFile()&&jn(s)&&t.push(d.dirname(s))}}return t}function In(e,t){let n=t.trim();if(!n)return[];let r=d.resolve(e,n);if(!Tn(e,r))return[];try{let i=Pn(r);if(i.isDirectory())return[r];if(i.isFile()&&Ce(d.basename(r)))return[d.dirname(r)]}catch{return[]}return[]}function jn(e){if(!Ce(d.basename(e)))return!1;let t=we(e);return t?d.basename(e)==="tsconfig.json"||"include"in t||"files"in t||"references"in t:!1}function Ce(e){return e.startsWith("tsconfig")&&e.endsWith(".json")}function Cn(e){let t=[...new Set(e.map(n=>d.resolve(n)))].sort((n,r)=>n.localeCompare(r));return t.length<=1?t:t.filter(n=>!t.some(r=>r!==n&&Fn(n,r)))}function wn(e,t){if(t.length===0||t.some(r=>d.resolve(r)===e))return!1;let n=d.join(e,"tsconfig.json");return xn(n)&&Ln(n)}function Ln(e){let n=we(e)?.include;return Array.isArray(n)?n.some(r=>typeof r=="string"&&r.trim()!==""&&!r.startsWith("!")&&(r.includes("/")||r.includes("**")||!d.extname(r))):!1}function we(e){try{let t=JSON.parse(Sn(e,"utf-8"));return t&&typeof t=="object"&&!Array.isArray(t)?t:null}catch{return null}}function On(e,t){let n=d.relative(e,t);return n?n.split(d.sep).join("/"):"."}function Fn(e,t){let n=d.relative(e,t);return!!n&&!n.startsWith("..")&&!d.isAbsolute(n)}function Tn(e,t){let n=d.relative(e,t);return!n.startsWith("..")&&!d.isAbsolute(n)}import{execFile as Mn}from"child_process";import{existsSync as L,renameSync as B,rmSync as W}from"fs";import{cpus as Dn}from"os";import{join as Le}from"path";function En(e,t,n){if(!e.defaultOutputPath)return;let r=Le(t,e.defaultOutputPath);n!==r&&L(r)&&B(r,n)}function Vn(e,t,n){if(!e.defaultOutputPath)return null;let r=Le(t,e.defaultOutputPath);if(r===n)return null;let i=`${n}.default-output-backup`;return W(i,{force:!0}),L(r)?(B(r,i),{defaultOutputPath:r,backupPath:i}):{defaultOutputPath:r,backupPath:null}}function An(e){e&&(W(e.defaultOutputPath,{force:!0}),e.backupPath&&L(e.backupPath)&&B(e.backupPath,e.defaultOutputPath))}function Nn(e,t){if(e<=1)return 1;let n=Number(process.env.SCIP_QUERY_INDEXER_CONCURRENCY??0),r=Number.isFinite(t)&&t&&t>0?t:Number.isFinite(n)&&n>0?n:Math.min(8,Math.max(1,Dn().length));return Math.max(1,Math.min(e,Math.floor(r)))}async function Oe(e,t,n,r){let i=e.filter(c=>c.config.defaultOutputPath),o=e.filter(c=>!c.config.defaultOutputPath),s=[],a=Nn(o.length,r),u=await _n(o,a,c=>_(c,t,n));if(a>1){let c=new Map;for(let g of u.filter(l=>l.skipped)){let l=o.find(p=>p.id===g.id);l&&(n(`Retrying ${l.label} indexer serially after parallel failure...`),c.set(l.id,await _(l,t,n)))}s.push(...u.map(g=>c.get(g.id)??g))}else s.push(...u);for(let c of i)s.push(await _(c,t,n));return s.sort((c,g)=>e.findIndex(l=>l.id===c.id)-e.findIndex(l=>l.id===g.id))}async function _(e,t,n){n(`Indexing ${e.label} with ${e.resolvedBinary}...`),W(e.scipPath,{force:!0});let r=Vn(e.config,t,e.scipPath);try{await $n(e.binary,e.args,{cwd:t,env:e.env,maxBuffer:50*1024*1024}),En(e.config,t,e.scipPath)}catch(i){let o=i instanceof Error?i.message:String(i),s=`${e.resolvedBinary} indexer failed: ${o.split(`
7
+ `)[0]}`,a=e.label===e.language?s:`${e.label}: ${s}`;return n(`Skipping ${e.label}: ${s}`),{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,skipped:{language:e.language,reason:a}}}finally{An(r)}if(!L(e.scipPath)){let i=`${e.resolvedBinary} indexer completed but did not produce ${e.scipPath}`,o=e.label===e.language?i:`${e.label}: ${i}`;return n(`Skipping ${e.label}: ${i}`),{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,skipped:{language:e.language,reason:o}}}return{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath}}function $n(e,t,n){return new Promise((r,i)=>{Mn(e,[...t],n,o=>{o?i(o):r()})})}async function _n(e,t,n){if(e.length===0)return[];let r=new Array(e.length),i=0,o=Math.max(1,Math.min(e.length,t)),s=Array.from({length:o},async()=>{for(;i<e.length;){let a=i++;r[a]=await n(e[a])}});return await Promise.all(s),r}import{execFileSync as J}from"child_process";import{existsSync as U,readFileSync as Bn}from"fs";import{createRequire as Wn}from"module";import{platform as Un}from"os";import{dirname as Fe,join as O}from"path";var Jn=Wn(import.meta.url);function q(e){return[e.indexerBinary,...e.binaryAliases??[]]}function F(e){let t=q(e);return t.length===1?t[0]:t.join(" or ")}function v(e){for(let t of q(e))if(R(t))return t;return Gn(e)}function G(e){return v(e)!==null||qn(e)}function qn(e){return Te(e)!==null}function Gn(e){let t=Te(e);if(!t)return null;let r=JSON.parse(Bn(t,"utf8")).bin;if(!r)return null;if(typeof r=="string")return O(Fe(t),r);for(let i of q(e)){let o=r[i];if(o)return O(Fe(t),o)}return null}function Te(e){if(!e.bundledNpmPackage)return null;try{return Jn.resolve(`${e.bundledNpmPackage}/package.json`)}catch{return null}}function H(e,t){for(let n of e.projectLocalBinaries??[]){let r=O(t,n);if(U(r))return r}return null}function z(e,t=process.env,n=e.indexerBinary){if(e.indexerBinary!=="scip-dotnet"||Me(n,t))return t;let r=Hn(n,t);return r?{...t,DOTNET_ROOT:r}:t}function K(e,t){let n=e.installMethods,r=F(e);if(!n?.length)return t(`No auto-install method available for ${r}.`),e.installUrl&&t(`Install manually from: ${e.installUrl}`),!1;for(let i of n)if(R(i.prerequisite)){t(`Installing ${r} via ${i.label}...`);try{J(i.binary,i.args,{stdio:"inherit",timeout:3e5,env:process.env});let o=v(e);if(o){let s=o===e.indexerBinary?"":` (using ${o})`;return t(`Successfully installed ${r} via ${i.label}${s}`),!0}t(`${i.label} command completed but ${r} was not found on PATH`)}catch(o){let s=o instanceof Error?o.message:String(o);t(`${i.label} install failed: ${s}`)}}return t(`Could not auto-install ${r}.`),e.installUrl&&t(`Install manually from: ${e.installUrl}`),!1}function Hn(e,t){for(let n of zn(t))if(Me(e,{...t,DOTNET_ROOT:n}))return n;return null}function zn(e){let t=[],n=e.DOTNET_ROOT;if(n&&U(n)&&t.push(n),Un()==="darwin"&&R("brew"))try{let r=J("brew",["--prefix","dotnet@9"],{stdio:"pipe",env:e}).toString().trim(),i=O(r,"libexec");U(i)&&!t.includes(i)&&t.push(i)}catch{}return t}function Me(e,t){try{return J(e,["--version"],{stdio:"pipe",env:t}),!0}catch{return!1}}import wr from"better-sqlite3";import{existsSync as Lr}from"fs";import{dirname as Or,join as Fr,resolve as Tr}from"path";import{readFileSync as Kn,rmSync as Xn,statSync as Yn,mkdtempSync as Qn}from"fs";import{cpus as Zn,tmpdir as er}from"os";import{join as X}from"path";import{Worker as tr}from"worker_threads";function De(e){return e.length>=8&&Ve(e.length)>1}function Ee(e){let t=Ve(e.vueFiles.length),n=rr(e.vueFiles),r=or(n,t),i=new URL("./augment-vue-worker.js",import.meta.url),o=Qn(X(er(),"scip-query-vue-workers-")),s=new SharedArrayBuffer(4),a=new Int32Array(s),u=nr(),c=Date.now();try{for(let l=0;l<r.length;l++)new tr(i,{workerData:{projectRoot:e.projectRoot,dbPath:e.dbPath,tsconfig:e.tsconfig,tasks:r[l],resultPath:X(o,`${l}.json`),sharedBuffer:s}});for(;Atomics.load(a,0)<r.length;){if(Date.now()-c>u)throw new Error(`Vue reference workers timed out after ${(u/1e3).toFixed(0)}s`);Atomics.wait(a,0,Atomics.load(a,0),100)}let g=r.map((l,p)=>{let h=JSON.parse(Kn(X(o,`${p}.json`),"utf-8"));if(!h.ok)throw new Error(`Vue reference worker failed: ${h.error}`);return h.result});return{occurrences:g.flatMap(l=>l.occurrences),skippedReferences:g.reduce((l,p)=>l+p.skippedReferences,0)}}finally{Xn(o,{recursive:!0,force:!0})}}function Ve(e){let t=Number(process.env.SCIP_QUERY_AUGMENT_VUE_WORKERS??0),n=Number.isFinite(t)&&t>0?t:Math.min(8,Math.max(1,Zn().length-1));return Math.max(1,Math.min(e,n))}function nr(){let e=Number(process.env.SCIP_QUERY_AUGMENT_VUE_WORKER_TIMEOUT_MS??0);return Number.isFinite(e)&&e>0?e:3e5}function rr(e){let t=ir(),n=[];for(let r of e){let i=Ae(r),o=Math.max(1,Math.ceil(i/t));for(let s=0;s<o;s++)n.push({fileName:r,startOffset:Math.floor(i*s/o),endOffset:s===o-1?Number.POSITIVE_INFINITY:Math.floor(i*(s+1)/o),countFileSkip:s===0})}return n}function ir(){return Number.POSITIVE_INFINITY}function or(e,t){let n=Array.from({length:t},()=>({tasks:[],weight:0})),r=e.map(i=>({task:i,weight:sr(i)})).sort((i,o)=>o.weight-i.weight);for(let i of r){let o=n.reduce((s,a)=>a.weight<s.weight?a:s);o.tasks.push(i.task),o.weight+=i.weight}return n.map(i=>i.tasks).filter(i=>i.length>0)}function sr(e){return Number.isFinite(e.endOffset)?Math.max(1,e.endOffset-e.startOffset):Math.max(1,Ae(e.fileName)-e.startOffset)}function Ae(e){try{return Yn(e).size}catch{return 1}}import{createRequire as ar}from"module";import{existsSync as ur,readFileSync as Q}from"fs";import{dirname as Ne,extname as cr,join as $e,relative as lr,resolve as gr}from"path";import{pathToFileURL as pr}from"url";function dr(e){e.transaction(()=>{e.prepare(`
7
8
  DELETE FROM mentions
8
9
  WHERE chunk_id IN (
9
10
  SELECT c.id
@@ -18,12 +19,12 @@ import{a as x,b as F,f as E}from"./chunk-ONPCQ2PM.js";import{a as se}from"./chun
18
19
  FROM documents
19
20
  WHERE language = 'vue' OR relative_path LIKE '%.vue'
20
21
  )
21
- `).run()})()}function Ve(e,t){return e.prepare(`
22
+ `).run()})()}function _e(e,t){return e.prepare(`
22
23
  SELECT relative_path AS relativePath
23
24
  FROM documents
24
25
  WHERE language = 'vue' OR relative_path LIKE '%.vue'
25
26
  ORDER BY relative_path
26
- `).all().map(r=>er(t,r.relativePath))}function Ne(e,t){let{vueCore:n,ts:r,volarTs:i}=rr(e),{parsed:o,vueOptions:s}=ir(n,r,t),a=Fe(t),u=n.createVueLanguagePlugin(r,o.options,s,h=>h),c=or(n,r,u),g=sr(a,o),{languageServiceHost:l}=i.createLanguageServiceHost(r,r.sys,c,h=>h,g),p=r.createLanguageService(l);return{ts:r,language:c,languageService:p,fileNames:o.fileNames,configDir:a}}function rr(e){let t=Xn(tr(Ee(e,"package.json")).href);return{vueCore:X(t,"@vue/language-core",e),ts:X(t,"typescript",e),volarTs:X(t,"@volar/typescript",e)}}function ir(e,t,n){let r=t.readConfigFile(n,t.sys.readFile);if(r.error||!r.config)throw new Error(`Failed to read ${n}`);let o=e.createParsedCommandLine(t,t.sys,n).vueOptions;return typeof e.createGlobalTypesWriter=="function"&&(o.globalTypesPath=e.createGlobalTypesWriter(o,t.sys.writeFile)),{parsed:t.parseJsonConfigFileContent(r.config,t.sys,Fe(n),void 0,n,void 0,e.getAllExtensions(o).map(s=>({extension:s.slice(1),isMixedContent:!0,scriptKind:t.ScriptKind.Deferred}))),vueOptions:o}}function or(e,t,n){let r={},i=e.createLanguage([n],new Map,o=>{if(!Yn(o))return;let s=Y(o,"utf-8");r.current?.scripts.set(o,t.ScriptSnapshot.fromString(s),n.getLanguageId(o)??pr(o))});return r.current=i,i}function sr(e,t){return{getCurrentDirectory:()=>e,getCompilationSettings:()=>t.options,getScriptFileNames:()=>t.fileNames,getProjectReferences:()=>t.projectReferences,getProjectVersion:()=>"0"}}function X(e,t,n){try{return e(t)}catch(r){throw(typeof r=="object"&&r!==null&&"code"in r?r.code:null)==="MODULE_NOT_FOUND"?new Error(`Vue augmentation requires ${t} to be installed in ${n}. Install Vue/Volar dependencies for that project, then rerun augment-vue.`,{cause:r}):r}}function Ae(e,t,n){let r=ar(e);return i=>{let o=y(t,i.fileName),s=n.get(i.fileName);if(!s)return null;let a=n.positionAt(s,i.textSpan.start),u=r.get(o);if(!u)return null;let c=u.containingByLine.get(a.line);return c!==void 0?c:ur(u.starts,a.line,2)}}function ar(e){let t=e.prepare(`
27
+ `).all().map(r=>gr(t,r.relativePath))}function Be(e,t){let{vueCore:n,ts:r,volarTs:i}=fr(e),{parsed:o,vueOptions:s}=mr(n,r,t),a=Ne(t),u=n.createVueLanguagePlugin(r,o.options,s,h=>h),c=hr(n,r,u),g=yr(a,o),{languageServiceHost:l}=i.createLanguageServiceHost(r,r.sys,c,h=>h,g),p=r.createLanguageService(l);return{ts:r,language:c,languageService:p,fileNames:o.fileNames,configDir:a}}function fr(e){let t=ar(pr($e(e,"package.json")).href);return{vueCore:Y(t,"@vue/language-core",e),ts:Y(t,"typescript",e),volarTs:Y(t,"@volar/typescript",e)}}function mr(e,t,n){let r=t.readConfigFile(n,t.sys.readFile);if(r.error||!r.config)throw new Error(`Failed to read ${n}`);let o=e.createParsedCommandLine(t,t.sys,n).vueOptions;return typeof e.createGlobalTypesWriter=="function"&&(o.globalTypesPath=e.createGlobalTypesWriter(o,t.sys.writeFile)),{parsed:t.parseJsonConfigFileContent(r.config,t.sys,Ne(n),void 0,n,void 0,e.getAllExtensions(o).map(s=>({extension:s.slice(1),isMixedContent:!0,scriptKind:t.ScriptKind.Deferred}))),vueOptions:o}}function hr(e,t,n){let r={},i=e.createLanguage([n],new Map,o=>{if(!ur(o))return;let s=Q(o,"utf-8");r.current?.scripts.set(o,t.ScriptSnapshot.fromString(s),n.getLanguageId(o)??vr(o))});return r.current=i,i}function yr(e,t){return{getCurrentDirectory:()=>e,getCompilationSettings:()=>t.options,getScriptFileNames:()=>t.fileNames,getProjectReferences:()=>t.projectReferences,getProjectVersion:()=>"0"}}function Y(e,t,n){try{return e(t)}catch(r){throw(typeof r=="object"&&r!==null&&"code"in r?r.code:null)==="MODULE_NOT_FOUND"?new Error(`Vue augmentation requires ${t} to be installed in ${n}. Install Vue/Volar dependencies for that project, then rerun augment-vue.`,{cause:r}):r}}function We(e,t,n){let r=br(e);return i=>{let o=b(t,i.fileName),s=n.get(i.fileName);if(!s)return null;let a=n.positionAt(s,i.textSpan.start),u=r.get(o);if(!u)return null;let c=u.containingByLine.get(a.line);return c!==void 0?c:xr(u.starts,a.line,2)}}function br(e){let t=e.prepare(`
27
28
  SELECT
28
29
  d.relative_path AS relativePath,
29
30
  der.start_line AS startLine,
@@ -32,23 +33,22 @@ import{a as x,b as F,f as E}from"./chunk-ONPCQ2PM.js";import{a as se}from"./chun
32
33
  FROM defn_enclosing_ranges der
33
34
  JOIN documents d ON d.id = der.document_id
34
35
  ORDER BY d.relative_path, (der.end_line - der.start_line) DESC
35
- `).all(),n=new Map;for(let r of t){let i=n.get(r.relativePath);i||(i={containingByLine:new Map,starts:[]},n.set(r.relativePath,i)),i.starts.push({line:r.startLine,symbolId:r.symbolId});for(let o=r.startLine;o<=r.endLine;o++)i.containingByLine.set(o,r.symbolId)}for(let r of n.values())r.starts.sort((i,o)=>i.line-o.line);return n}function ur(e,t,n){let r=0,i=e.length-1;for(;r<=i;){let s=Math.floor((r+i)/2);e[s].line<t?r=s+1:i=s-1}let o=null;for(let s of[i,r]){let a=e[s];if(!a)continue;let u=Math.abs(a.line-t);u>n||(!o||u<o.distance)&&(o={distance:u,symbolId:a.symbolId})}return o?.symbolId??null}function $e(e,t,n){let r=mr(t),i=e.prepare("SELECT id FROM global_symbols WHERE symbol = ?"),o=e.prepare(`
36
+ `).all(),n=new Map;for(let r of t){let i=n.get(r.relativePath);i||(i={containingByLine:new Map,starts:[]},n.set(r.relativePath,i)),i.starts.push({line:r.startLine,symbolId:r.symbolId});for(let o=r.startLine;o<=r.endLine;o++)i.containingByLine.set(o,r.symbolId)}for(let r of n.values())r.starts.sort((i,o)=>i.line-o.line);return n}function xr(e,t,n){let r=0,i=e.length-1;for(;r<=i;){let s=Math.floor((r+i)/2);e[s].line<t?r=s+1:i=s-1}let o=null;for(let s of[i,r]){let a=e[s];if(!a)continue;let u=Math.abs(a.line-t);u>n||(!o||u<o.distance)&&(o={distance:u,symbolId:a.symbolId})}return o?.symbolId??null}function Ue(e,t,n){let r=jr(t),i=e.prepare("SELECT id FROM global_symbols WHERE symbol = ?"),o=e.prepare(`
36
37
  INSERT OR IGNORE INTO global_symbols (symbol, display_name, kind, documentation)
37
38
  VALUES (?, ?, ?, ?)
38
- `),s=0,a=new Map;return e.transaction(()=>{for(let c of n){let g=y(t,c),l=He(r.name,r.version,g);o.run(l,"default",7,`Vue component|${g}`);let p=hr(i,r,t,c);p&&(s++,a.set(c,p))}})(),{get(c){return a.get(c)??null},syntheticSymbols:s}}function _e(e,t,n,r,i){return e.transaction(()=>(nr(e),cr(e,t,n,r),lr(e,i)))()}function cr(e,t,n,r){let i=e.prepare("SELECT id FROM documents WHERE relative_path = ?"),o=e.prepare(`
39
+ `),s=0,a=new Map;return e.transaction(()=>{for(let c of n){let g=b(t,c),l=Qe(r.name,r.version,g);o.run(l,"default",7,`Vue component|${g}`);let p=Cr(i,r,t,c);p&&(s++,a.set(c,p))}})(),{get(c){return a.get(c)??null},syntheticSymbols:s}}function Je(e,t,n,r,i){return e.transaction(()=>(dr(e),Sr(e,t,n,r),Rr(e,i)))()}function Sr(e,t,n,r){let i=e.prepare("SELECT id FROM documents WHERE relative_path = ?"),o=e.prepare(`
39
40
  INSERT INTO chunks (document_id, chunk_index, start_line, end_line, occurrences)
40
41
  VALUES (?, ?, ?, ?, X'00')
41
42
  `),s=e.prepare(`
42
43
  INSERT OR IGNORE INTO mentions (chunk_id, symbol_id, role)
43
44
  VALUES (?, ?, 1)
44
- `);for(let a of n){let u=r.get(a);if(!u)continue;let c=y(t,a),g=i.get(c);if(!g)continue;let l=o.run(g.id,-1,0,0);s.run(Number(l.lastInsertRowid),u)}}function Be(e,t,n,r,i){if(e.fileName.endsWith(".vue")){let o=r.language.scripts.get(e.fileName),s=o?.generated?.languagePlugin.typescript?.getServiceScript(o.generated.root)?.code;if(o&&s){let a=r.language.maps.get(s,o);if(Q(a,e.textSpan.start)!==null)return n.get(e.fileName)}return e.fileName.startsWith(i)?n.get(e.fileName):null}return t(e)}function We(e){let t=new Set,n=[];for(let r of e){let i=Ue(r);t.has(i)||(t.add(i),n.push(r))}return n}function Ue(e){return[e.sourceFile,e.sourceLine,e.sourceStartChar,e.sourceEndChar,e.symbolId].join(":")}function lr(e,t){let n=fr(e,[...new Set(t.map(u=>u.sourceFile))]),r=e.prepare(`
45
+ `);for(let a of n){let u=r.get(a);if(!u)continue;let c=b(t,a),g=i.get(c);if(!g)continue;let l=o.run(g.id,-1,0,0);s.run(Number(l.lastInsertRowid),u)}}function qe(e,t,n,r,i){if(e.fileName.endsWith(".vue")){let o=r.language.scripts.get(e.fileName),s=o?.generated?.languagePlugin.typescript?.getServiceScript(o.generated.root)?.code;if(o&&s){let a=r.language.maps.get(s,o);if(Z(a,e.textSpan.start)!==null)return n.get(e.fileName)}return e.fileName.startsWith(i)?n.get(e.fileName):null}return t(e)}function Ge(e){let t=new Set,n=[];for(let r of e){let i=He(r);t.has(i)||(t.add(i),n.push(r))}return n}function He(e){return[e.sourceFile,e.sourceLine,e.sourceStartChar,e.sourceEndChar,e.symbolId].join(":")}function Rr(e,t){let n=Ir(e,[...new Set(t.map(u=>u.sourceFile))]),r=e.prepare(`
45
46
  INSERT INTO chunks (document_id, chunk_index, start_line, end_line, occurrences)
46
47
  VALUES (?, ?, ?, ?, X'00')
47
48
  `),i=e.prepare(`
48
49
  INSERT OR IGNORE INTO mentions (chunk_id, symbol_id, role)
49
50
  VALUES (?, ?, 0)
50
- `),o=new Set,s=0,a=0;for(let u of t){let c=Ue(u);if(o.has(c))continue;o.add(c);let g=n.get(u.sourceFile);if(!g)continue;let l=r.run(g,a++,u.sourceLine,u.sourceLine),p=i.run(Number(l.lastInsertRowid),u.symbolId);s+=Number(p.changes)}return s}function*Je(e){let t=/\b[A-Za-z_$][A-Za-z0-9_$]*\b/g,n=new Set(["script","setup","template","style","lang","scoped","true","false","null","undefined","const","let","var","import","from","export","return","if","else","for","while","function","class","type","interface","as","await","async"]),r;for(;r=t.exec(e);){let i=r[0];n.has(i)||(yield{text:i,start:r.index,end:r.index+i.length})}}function Ge(e,t){for(let[n]of e.toGeneratedLocation(t,r=>!!r.navigation))return n;return null}function Q(e,t){let n=e;for(let[r]of n.toSourceLocation(t,i=>!!i.navigation))return r;return null}function gr(e,t){let n=0,r=e.lineStarts.length-1;for(;n<=r;){let o=Math.floor((n+r)/2);e.lineStarts[o]<=t?n=o+1:r=o-1}let i=Math.max(0,r);return{line:i,character:t-e.lineStarts[i]}}function qe(e,t){return y(e,t).startsWith("node_modules/")}function y(e,t){return Zn(e,t).replaceAll("\\","/")}function pr(e){switch(Qn(e)){case".vue":return"vue";case".tsx":return"typescriptreact";case".ts":case".mts":case".cts":return"typescript";case".jsx":return"javascriptreact";case".js":case".mjs":case".cjs":return"javascript";case".json":return"json";default:return"typescript"}}function ze(){let e=new Map;return{get(t){if(e.has(t))return e.get(t)??null;try{let n=Y(t,"utf-8"),r={text:n,lineStarts:dr(n)};return e.set(t,r),r}catch{return e.set(t,null),null}},positionAt:gr}}function dr(e){let t=[0];for(let n=0;n<e.length;n++)e.charCodeAt(n)===10&&t.push(n+1);return t}function fr(e,t){let n=new Map,r=500;for(let i=0;i<t.length;i+=r){let o=t.slice(i,i+r),s=e.prepare(`SELECT id, relative_path AS relativePath FROM documents WHERE relative_path IN (${o.map(()=>"?").join(",")})`).all(...o);for(let a of s)n.set(a.relativePath,a.id)}return n}function mr(e){try{let t=JSON.parse(Y(Ee(e,"package.json"),"utf-8"));return{name:t.name??"workspace",version:t.version??"0.0.0"}}catch{return{name:"workspace",version:"0.0.0"}}}function hr(e,t,n,r){let i=y(n,r),o=He(t.name,t.version,i);return e.get(o)?.id??null}function He(e,t,n){let r=n.split("/").map(i=>`\`${i.replaceAll("`","")}\``).join("/");return`scip-vue npm ${e} ${t} ${r}/default.`}function Pr(e){b({projectRoot:e.projectRoot,dbPath:e.dbPath});let t=kr(e.projectRoot,e.tsconfig);if(!br(t))throw new Error(`Vue tsconfig not found at ${t}`);let n=new yr(e.dbPath);try{let r=Ve(n,e.projectRoot),i=vr(Rr(e.dbPath),"augment-vue-meta.json"),o=Ke(n,e.projectRoot,e.tsconfig),s=Ir(i,o,e.onStatus);if(s)return s;let a=Lr({db:n,projectRoot:e.projectRoot,dbPath:e.dbPath,tsconfig:e.tsconfig,configPath:t,vueFiles:r,onStatus:e.onStatus});return Cr(i,Ke(n,e.projectRoot,e.tsconfig),a),a}finally{n.close()}}function Ir(e,t,n){let r=wr(e,t);return r&&n?.(`Vue references unchanged; reused ${r.resolvedReferences} cached resolved references.`),r}function Lr(e){let t=$e(e.db,e.projectRoot,e.vueFiles),n=jr(e,t),r=We(n.occurrences),i=_e(e.db,e.projectRoot,e.vueFiles,t,r),o={vueFiles:e.vueFiles.length,resolvedReferences:r.length,insertedMentions:i,skippedReferences:n.skippedReferences,syntheticSymbols:t.syntheticSymbols};return e.onStatus?.(`Resolved ${o.resolvedReferences} Vue references with Volar; inserted ${o.insertedMentions} mentions.`),o}function jr(e,t){if(Oe(e.vueFiles))return Te({projectRoot:e.projectRoot,dbPath:e.dbPath,tsconfig:e.tsconfig,vueFiles:e.vueFiles});let n=Or({db:e.db,projectRoot:e.projectRoot,configPath:e.configPath,vueSymbolLookup:t});return Tr({...n,vueFiles:n.context.fileNames.filter(r=>r.endsWith(".vue"))})}function wr(e,t){try{let n=JSON.parse(Sr(e,"utf-8"));return JSON.stringify(n.fingerprint)===JSON.stringify(t)?n.result:null}catch{return null}}function Cr(e,t,n){xr(e,JSON.stringify({updatedAt:new Date().toISOString(),fingerprint:t,result:n},null,2)+`
51
- `)}function Ke(e,t,n){let r=e.prepare(`
51
+ `),o=new Set,s=0,a=0;for(let u of t){let c=He(u);if(o.has(c))continue;o.add(c);let g=n.get(u.sourceFile);if(!g)continue;let l=r.run(g,a++,u.sourceLine,u.sourceLine),p=i.run(Number(l.lastInsertRowid),u.symbolId);s+=Number(p.changes)}return s}function*ze(e){let t=/\b[A-Za-z_$][A-Za-z0-9_$]*\b/g,n=new Set(["script","setup","template","style","lang","scoped","true","false","null","undefined","const","let","var","import","from","export","return","if","else","for","while","function","class","type","interface","as","await","async"]),r;for(;r=t.exec(e);){let i=r[0];n.has(i)||(yield{text:i,start:r.index,end:r.index+i.length})}}function Ke(e,t){for(let[n]of e.toGeneratedLocation(t,r=>!!r.navigation))return n;return null}function Z(e,t){let n=e;for(let[r]of n.toSourceLocation(t,i=>!!i.navigation))return r;return null}function Pr(e,t){let n=0,r=e.lineStarts.length-1;for(;n<=r;){let o=Math.floor((n+r)/2);e.lineStarts[o]<=t?n=o+1:r=o-1}let i=Math.max(0,r);return{line:i,character:t-e.lineStarts[i]}}function Xe(e,t){return b(e,t).startsWith("node_modules/")}function b(e,t){return lr(e,t).replaceAll("\\","/")}function vr(e){switch(cr(e)){case".vue":return"vue";case".tsx":return"typescriptreact";case".ts":case".mts":case".cts":return"typescript";case".jsx":return"javascriptreact";case".js":case".mjs":case".cjs":return"javascript";case".json":return"json";default:return"typescript"}}function Ye(){let e=new Map;return{get(t){if(e.has(t))return e.get(t)??null;try{let n=Q(t,"utf-8"),r={text:n,lineStarts:kr(n)};return e.set(t,r),r}catch{return e.set(t,null),null}},positionAt:Pr}}function kr(e){let t=[0];for(let n=0;n<e.length;n++)e.charCodeAt(n)===10&&t.push(n+1);return t}function Ir(e,t){let n=new Map,r=500;for(let i=0;i<t.length;i+=r){let o=t.slice(i,i+r),s=e.prepare(`SELECT id, relative_path AS relativePath FROM documents WHERE relative_path IN (${o.map(()=>"?").join(",")})`).all(...o);for(let a of s)n.set(a.relativePath,a.id)}return n}function jr(e){try{let t=JSON.parse(Q($e(e,"package.json"),"utf-8"));return{name:t.name??"workspace",version:t.version??"0.0.0"}}catch{return{name:"workspace",version:"0.0.0"}}}function Cr(e,t,n,r){let i=b(n,r),o=Qe(t.name,t.version,i);return e.get(o)?.id??null}function Qe(e,t,n){let r=n.split("/").map(i=>`\`${i.replaceAll("`","")}\``).join("/");return`scip-vue npm ${e} ${t} ${r}/default.`}function Ze(e){return{id:"vue-resolved-references",facts:["synthetic-symbol","source-mapped-occurrence","definition-mention","replacement-chunk","fingerprint-cache"],run:t=>Dr({projectRoot:t.projectRoot,dbPath:t.dbPath,tsconfig:e.tsconfig,onStatus:t.onStatus})}}function Mr(e){return y(x(),{projectRoot:e.projectRoot,dbPath:e.dbPath}),y(Ze({tsconfig:e.tsconfig}),{projectRoot:e.projectRoot,dbPath:e.dbPath,onStatus:e.onStatus}).result}function Dr(e){let t=Tr(e.projectRoot,e.tsconfig);if(!Lr(t))throw new Error(`Vue tsconfig not found at ${t}`);let n=new wr(e.dbPath);try{let r=_e(n,e.projectRoot),i=Fr(Or(e.dbPath),"augment-vue-meta.json");return Se({cachePath:i,readFingerprint:()=>Ar(n,e.projectRoot,e.tsconfig),compute:()=>Er({db:n,projectRoot:e.projectRoot,dbPath:e.dbPath,tsconfig:e.tsconfig,configPath:t,vueFiles:r,onStatus:e.onStatus}),onCacheHit:o=>e.onStatus?.(`Vue references unchanged; reused ${o.resolvedReferences} cached resolved references.`)})}finally{n.close()}}function Er(e){let t=Ue(e.db,e.projectRoot,e.vueFiles),n=Vr(e,t),r=Ge(n.occurrences),i=Je(e.db,e.projectRoot,e.vueFiles,t,r),o={vueFiles:e.vueFiles.length,resolvedReferences:r.length,insertedMentions:i,skippedReferences:n.skippedReferences,syntheticSymbols:t.syntheticSymbols};return e.onStatus?.(`Resolved ${o.resolvedReferences} Vue references with Volar; inserted ${o.insertedMentions} mentions.`),o}function Vr(e,t){if(De(e.vueFiles))return Ee({projectRoot:e.projectRoot,dbPath:e.dbPath,tsconfig:e.tsconfig,vueFiles:e.vueFiles});let n=Nr({db:e.db,projectRoot:e.projectRoot,configPath:e.configPath,vueSymbolLookup:t});return $r({...n,vueFiles:n.context.fileNames.filter(r=>r.endsWith(".vue"))})}function Ar(e,t,n){let r=e.prepare(`
52
52
  SELECT
53
53
  (SELECT COUNT(*) FROM documents) AS documents,
54
54
  (SELECT COUNT(*) FROM global_symbols) AS symbols,
@@ -57,13 +57,13 @@ import{a as x,b as F,f as E}from"./chunk-ONPCQ2PM.js";import{a as se}from"./chun
57
57
  (SELECT COUNT(*) FROM defn_enclosing_ranges) AS ranges,
58
58
  (SELECT MAX(id) FROM chunks) AS maxChunkId,
59
59
  (SELECT MAX(id) FROM global_symbols) AS maxSymbolId
60
- `).get();return{version:2,tsconfig:n,files:R(t),db:r}}function Or(e){let t=ze();return{projectRoot:e.projectRoot,context:Ne(e.projectRoot,e.configPath),symbolLookup:Ae(e.db,e.projectRoot,t),vueSymbolLookup:e.vueSymbolLookup,sourceReader:t}}function Tr(e){let t=[],n=0,r=e.tasks??e.vueFiles.map(i=>({fileName:i,startOffset:0,endOffset:Number.POSITIVE_INFINITY,countFileSkip:!0}));for(let i of r){let o=Mr(e,i);t.push(...o.occurrences),n+=o.skippedReferences}return{occurrences:t,skippedReferences:n}}function Mr(e,t){let n=e.context.language.scripts.get(t.fileName),r=n?.generated?.languagePlugin.typescript?.getServiceScript(n.generated.root)?.code;if(!n||!r)return{occurrences:[],skippedReferences:t.countFileSkip?1:0};let i=e.sourceReader.get(t.fileName);if(!i)return{occurrences:[],skippedReferences:t.countFileSkip?1:0};let o=e.context.language.maps.get(r,n),s=y(e.projectRoot,t.fileName),a=[...Je(i.text)],u={tokens:a.filter(c=>c.start>=t.startOffset&&c.start<t.endOffset),tokenByStart:new Map(a.map(c=>[c.start,c])),tokenTextCounts:Er(a),processedStarts:new Set};return Dr({...e,fileName:t.fileName,sourceInfo:i,sourceFile:s,map:o,tokenContext:u})}function Dr(e){let t=[],n=0;for(let r of e.tokenContext.tokens){if(e.tokenContext.processedStarts.has(r.start))continue;let i=Ge(e.map,r.start);if(i===null)continue;let s=(e.context.languageService.getDefinitionAtPosition(e.fileName,i+1)??[]).find(u=>!qe(e.projectRoot,u.fileName));if(!s){n++;continue}let a=Be(s,e.symbolLookup,e.vueSymbolLookup,e.context,e.projectRoot);if(a===null){n++;continue}Xe(t,e.sourceReader,e.sourceInfo,e.sourceFile,r,a),e.tokenContext.processedStarts.add(r.start),Fr(t,e,r,i,a)}return{occurrences:t,skippedReferences:n}}function Fr(e,t,n,r,i){if(!((t.tokenContext.tokenTextCounts.get(n.text)??0)<=1))for(let o of Vr(t.context.languageService,t.fileName,r+1,t.map,n,t.tokenContext.tokenByStart)){if(t.tokenContext.processedStarts.has(o))continue;let s=t.tokenContext.tokenByStart.get(o);s&&(Xe(e,t.sourceReader,t.sourceInfo,t.sourceFile,s,i),t.tokenContext.processedStarts.add(o))}}function Xe(e,t,n,r,i,o){let s=t.positionAt(n,i.start);e.push({sourceFile:r,sourceLine:s.line,sourceStartChar:s.character,sourceEndChar:s.character+i.text.length,symbolId:o})}function Er(e){let t=new Map;for(let n of e)t.set(n.text,(t.get(n.text)??0)+1);return t}function Vr(e,t,n,r,i,o){let s=e.getDocumentHighlights?.(t,n,[t])??[],a=[];for(let u of s)if(u.fileName===t)for(let c of u.highlightSpans){let g=Nr(r,c.textSpan.start,o,i.text);g!==null&&a.push(g)}return a}function Nr(e,t,n,r){let i=n.get(t);if(i?.text===r)return i.start;let o=Q(e,t);if(o===null)return null;let s=n.get(o);return s?.text===r?s.start:null}async function No(e){let{projectRoot:t,maxHeapMb:n=8192,onStatus:r=console.log,skipAutoInstall:i=!1}=e,o=Jr(e),s=Date.now();te(f(o.outputScip),{recursive:!0}),te(f(o.outputDb),{recursive:!0});let a=e.languages??V(t);if(a.length===0)throw new Error("No supported languages detected in this project. Looked for: tsconfig.json, Cargo.toml, go.mod, pyproject.toml, etc.");r(`Detected languages: ${a.join(", ")}`);let u=di(t,a,{pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:e.typescriptProjects}),c=await oi(m(f(o.outputDb),"index.lock"),{projectRoot:t,trigger:e.trigger,onStatus:r}),g=null;try{let l=Gr({opts:e,paths:o,languages:a,fingerprint:u,start:s,onStatus:r});if(l)return l;Qr(i,r);let p=qr(o);return g=p.runDir,await zr({opts:e,languages:a,projectRoot:t,paths:o,tempPaths:p,fingerprint:u,start:s,maxHeapMb:n,skipAutoInstall:i,onStatus:r})}catch(l){throw at(o.metaPath,re({trigger:e.trigger,result:"failed",start:s,error:l instanceof Error?l.message:String(l)})),l}finally{g&&P(g,{recursive:!0,force:!0}),c()}}function Jr(e){let t=e.outputScip??m(e.projectRoot,"index.scip"),n=e.outputDb??m(e.projectRoot,"index.db");return{outputScip:t,outputDb:n,metaPath:m(f(n),"meta.json")}}function Gr(e){if(e.opts.skipIfUnchanged===!1||!M(e.paths.outputScip)||!M(e.paths.outputDb)||!fi(e.paths.metaPath,e.fingerprint))return null;b({projectRoot:e.opts.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus});let t=Date.now()-e.start,n=re({trigger:e.opts.trigger,result:"reused",start:e.start,languages:e.languages,skipped:[]});return at(e.paths.metaPath,n),e.onStatus(`Index unchanged; reused existing SQLite index in ${(t/1e3).toFixed(1)}s`),{languages:e.languages,indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:t,reused:!0,skipped:[],lastRefresh:n}}function qr(e){let t=Br(m(f(e.outputDb),"reindex-"));return{runDir:t,tempOutputScip:m(t,T(e.outputScip)),tempOutputDb:m(t,T(e.outputDb)),tempMetaPath:m(t,T(e.metaPath))}}async function zr(e){let t={...process.env,NODE_OPTIONS:`--max-old-space-size=${e.maxHeapMb}`},{indexedOutputs:n,skippedLanguages:r,reusedLanguages:i}=await Hr(e,t);i.length>0&&e.onStatus(`Reused ${i.length} cached language shard(s): ${i.join(", ")}`);let o=Kr(e,t,n,r),s=o.durationMs;return e.onStatus(`Done in ${(s/1e3).toFixed(1)}s`),{languages:n.map(a=>a.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:s,reused:!1,skipped:r,lastRefresh:o}}async function Hr(e,t){let n=Xr(e),r=new Set(n.map(c=>c.language));for(let c of r)e.onStatus(`Reusing cached ${c} SCIP shard (language inputs unchanged).`);let{preparedRuns:i,skippedLanguages:o}=Zr({languages:e.languages.filter(c=>!r.has(c)),tempOutputScip:e.tempPaths.tempOutputScip,projectRoot:e.projectRoot,env:t,skipAutoInstall:e.skipAutoInstall,pnpmWorkspaces:e.opts.pnpmWorkspaces,typescriptProjectMode:e.opts.typescriptProjectMode,typescriptProjects:e.opts.typescriptProjects,onStatus:e.onStatus}),s=await Le(i,e.projectRoot,e.onStatus,e.opts.indexerConcurrency),{indexedOutputs:a}=ti(s,o),u=[...n,...a];return ni(u,o,e.languages,e.opts.allowPartial,e.onStatus),{indexedOutputs:u,skippedLanguages:o,reusedLanguages:[...r]}}function Kr(e,t,n,r){Yr(e.paths.outputDb,n),ri(n,e.tempPaths.tempOutputScip,e.onStatus),ii(e.tempPaths.tempOutputScip,e.tempPaths.tempOutputDb,t,e.onStatus),b({projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,onStatus:e.onStatus});let i=re({trigger:e.opts.trigger,result:"rebuilt",start:e.start,languages:n.map(o=>o.language),skipped:[...r]});return st(e.tempPaths.tempMetaPath,{version:3,status:r.length===0?"complete":"partial",updatedAt:new Date().toISOString(),fingerprint:e.fingerprint,languageFingerprints:nt(e.projectRoot,e.languages,{pnpmWorkspaces:e.opts.pnpmWorkspaces,typescriptProjectMode:e.opts.typescriptProjectMode,typescriptProjects:e.opts.typescriptProjects}),requestedLanguages:e.languages,indexedLanguages:n.map(o=>o.language),skipped:[...r],lastRefresh:i}),pi({tempOutputScip:e.tempPaths.tempOutputScip,tempOutputDb:e.tempPaths.tempOutputDb,tempMetaPath:e.tempPaths.tempMetaPath,outputScip:e.paths.outputScip,outputDb:e.paths.outputDb,metaPath:e.paths.metaPath}),i}function Xr(e){let t;try{t=JSON.parse(D(e.paths.metaPath,"utf-8"))}catch{return[]}if(t.version!==3||!t.languageFingerprints)return[];let n=[],r=nt(e.projectRoot,e.languages,{pnpmWorkspaces:e.opts.pnpmWorkspaces,typescriptProjectMode:e.opts.typescriptProjectMode,typescriptProjects:e.opts.typescriptProjects});for(let i of e.languages){let o=ot(e.paths.outputDb,i);M(o)&&S(t.languageFingerprints[i])===S(r[i])&&n.push({language:i,scipPath:o})}return n}function Yr(e,t){for(let n of t){let r=ot(e,n.language);te(f(r),{recursive:!0}),n.scipPath!==r&&_r(n.scipPath,r)}}function Qr(e,t){if(!F()){if(e)throw new Error(`The scip CLI is required but not found on PATH.
61
- Install from: https://github.com/sourcegraph/scip/releases`);if(t("scip CLI not found on PATH. Attempting auto-install..."),!E(t))throw new Error(`The scip CLI is required but could not be installed.
62
- Install manually from: https://github.com/sourcegraph/scip/releases`)}}function Zr(e){let t=[],n=[],r=e.languages.map((i,o)=>({language:i,scipPath:e.languages.length>1?tt(e.tempOutputScip,i,o):e.tempOutputScip}));for(let{language:i,scipPath:o}of r){let s=ei({...e,language:i,scipPath:o});for(let a of s)"skipped"in a?et(n,a.skipped):t.push(a.prepared)}return{preparedRuns:t,skippedLanguages:n}}function ei(e){if(e.language!=="typescript"||e.typescriptProjectMode!=="workspace")return[Z({...e,id:e.language,label:e.language,outputScipPath:e.scipPath})];let t=ve(e.projectRoot,e.typescriptProjects);return t.length===0?[Z({...e,id:e.language,label:e.language,outputScipPath:e.scipPath})]:(e.onStatus(`Indexing TypeScript workspace as ${t.length} project shard(s).`),t.map((n,r)=>Z({...e,id:`typescript:${n}`,label:`typescript (${n})`,scipPath:tt(e.tempOutputScip,"typescript-project",r),outputScipPath:e.scipPath,pnpmWorkspaces:!1,projectPath:n})))}function Z(e){let t=L(e.language),n=O(t),r=q(t,e.projectRoot);if(!r&&!G(t)){if(e.skipAutoInstall){let a=`${n} not found on PATH (auto-install disabled). ${t.installUrl??""}`.trim();return e.onStatus(`Skipping ${e.language}: ${a}`),{skipped:{language:e.language,reason:a}}}if(e.onStatus(`${n} not found. Attempting auto-install...`),!H(t,e.onStatus)){let a=`${n} could not be auto-installed. ${t.installUrl?`Install manually from ${t.installUrl}`:`Install ${n} and put it on PATH.`}`;return e.onStatus(`Skipping ${e.language}: ${a}`),{skipped:{language:e.language,reason:a}}}}let i=r??v(t);if(!i){let a=`${n} was not found after installation checks.`;return e.onStatus(`Skipping ${e.language}: ${a}`),{skipped:{language:e.language,reason:a}}}let{binary:o,args:s}=t.indexArgs({projectRoot:e.projectRoot,outputPath:e.scipPath,pnpmWorkspaces:e.pnpmWorkspaces,indexerBinary:i,projectPath:e.projectPath});return{prepared:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,config:t,resolvedBinary:i,binary:o,args:s,env:z(t,e.env,i)}}}function ti(e,t){let n=new Map;for(let i of e)if(i.skipped)et(t,i.skipped);else{let o=`${i.language}\0${i.outputScipPath}`,s=n.get(o)??{language:i.language,outputScipPath:i.outputScipPath,scipPaths:[]};s.scipPaths.push(i.scipPath),n.set(o,s)}let r=[];for(let i of n.values())if(i.scipPaths.length>1)j(i.scipPaths,i.outputScipPath),r.push({language:i.language,scipPath:i.outputScipPath});else{let o=i.scipPaths[0];o!==i.outputScipPath&&k(o,i.outputScipPath),r.push({language:i.language,scipPath:i.outputScipPath})}return{indexedOutputs:r}}function et(e,t){let n=e.find(r=>r.language===t.language);if(!n){e.push(t);return}n.reason.includes(t.reason)||(n.reason=`${n.reason}; ${t.reason}`)}function ni(e,t,n,r,i){if(e.length===0){let o=t.map(s=>` - ${s.language}: ${s.reason}`).join(`
60
+ `).get();return{version:2,tsconfig:n,files:P(t),db:r}}function Nr(e){let t=Ye();return{projectRoot:e.projectRoot,context:Be(e.projectRoot,e.configPath),symbolLookup:We(e.db,e.projectRoot,t),vueSymbolLookup:e.vueSymbolLookup,sourceReader:t}}function $r(e){let t=[],n=0,r=e.tasks??e.vueFiles.map(i=>({fileName:i,startOffset:0,endOffset:Number.POSITIVE_INFINITY,countFileSkip:!0}));for(let i of r){let o=_r(e,i);t.push(...o.occurrences),n+=o.skippedReferences}return{occurrences:t,skippedReferences:n}}function _r(e,t){let n=e.context.language.scripts.get(t.fileName),r=n?.generated?.languagePlugin.typescript?.getServiceScript(n.generated.root)?.code;if(!n||!r)return{occurrences:[],skippedReferences:t.countFileSkip?1:0};let i=e.sourceReader.get(t.fileName);if(!i)return{occurrences:[],skippedReferences:t.countFileSkip?1:0};let o=e.context.language.maps.get(r,n),s=b(e.projectRoot,t.fileName),a=[...ze(i.text)],u={tokens:a.filter(c=>c.start>=t.startOffset&&c.start<t.endOffset),tokenByStart:new Map(a.map(c=>[c.start,c])),tokenTextCounts:Ur(a),processedStarts:new Set};return Br({...e,fileName:t.fileName,sourceInfo:i,sourceFile:s,map:o,tokenContext:u})}function Br(e){let t=[],n=0;for(let r of e.tokenContext.tokens){if(e.tokenContext.processedStarts.has(r.start))continue;let i=Ke(e.map,r.start);if(i===null)continue;let s=(e.context.languageService.getDefinitionAtPosition(e.fileName,i+1)??[]).find(u=>!Xe(e.projectRoot,u.fileName));if(!s){n++;continue}let a=qe(s,e.symbolLookup,e.vueSymbolLookup,e.context,e.projectRoot);if(a===null){n++;continue}et(t,e.sourceReader,e.sourceInfo,e.sourceFile,r,a),e.tokenContext.processedStarts.add(r.start),Wr(t,e,r,i,a)}return{occurrences:t,skippedReferences:n}}function Wr(e,t,n,r,i){if(!((t.tokenContext.tokenTextCounts.get(n.text)??0)<=1))for(let o of Jr(t.context.languageService,t.fileName,r+1,t.map,n,t.tokenContext.tokenByStart)){if(t.tokenContext.processedStarts.has(o))continue;let s=t.tokenContext.tokenByStart.get(o);s&&(et(e,t.sourceReader,t.sourceInfo,t.sourceFile,s,i),t.tokenContext.processedStarts.add(o))}}function et(e,t,n,r,i,o){let s=t.positionAt(n,i.start);e.push({sourceFile:r,sourceLine:s.line,sourceStartChar:s.character,sourceEndChar:s.character+i.text.length,symbolId:o})}function Ur(e){let t=new Map;for(let n of e)t.set(n.text,(t.get(n.text)??0)+1);return t}function Jr(e,t,n,r,i,o){let s=e.getDocumentHighlights?.(t,n,[t])??[],a=[];for(let u of s)if(u.fileName===t)for(let c of u.highlightSpans){let g=qr(r,c.textSpan.start,o,i.text);g!==null&&a.push(g)}return a}function qr(e,t,n,r){let i=n.get(t);if(i?.text===r)return i.start;let o=Z(e,t);if(o===null)return null;let s=n.get(o);return s?.text===r?s.start:null}async function Ko(e){let{projectRoot:t,maxHeapMb:n=8192,onStatus:r=console.log,skipAutoInstall:i=!1}=e,o=Qr(e),s=Date.now();ne(f(o.outputScip),{recursive:!0}),ne(f(o.outputDb),{recursive:!0});let a=e.languages??A(t);if(a.length===0)throw new Error("No supported languages detected in this project. Looked for: tsconfig.json, Cargo.toml, go.mod, pyproject.toml, etc.");r(`Detected languages: ${a.join(", ")}`);let u=Ri(t,a,{pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:e.typescriptProjects,clojureConfigPath:e.clojureConfigPath}),c=await di(m(f(o.outputDb),"index.lock"),{projectRoot:t,trigger:e.trigger,onStatus:r}),g=null;try{let l=Zr({opts:e,paths:o,languages:a,fingerprint:u,start:s,onStatus:r});if(l)return l;si(i,r);let p=ei(o);return g=p.runDir,await ti({opts:e,languages:a,projectRoot:t,paths:o,tempPaths:p,fingerprint:u,start:s,maxHeapMb:n,skipAutoInstall:i,onStatus:r})}catch(l){throw pt(o.metaPath,ie({trigger:e.trigger,result:"failed",start:s,error:l instanceof Error?l.message:String(l)})),l}finally{g&&I(g,{recursive:!0,force:!0}),c()}}function Qr(e){let t=e.outputScip??m(e.projectRoot,"index.scip"),n=e.outputDb??m(e.projectRoot,"index.db");return{outputScip:t,outputDb:n,metaPath:m(f(n),"meta.json")}}function Zr(e){if(e.opts.skipIfUnchanged===!1||!M(e.paths.outputScip)||!M(e.paths.outputDb)||!Pi(e.paths.metaPath,e.fingerprint))return null;y(x(),{projectRoot:e.opts.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus});let t=Date.now()-e.start,n=ie({trigger:e.opts.trigger,result:"reused",start:e.start,languages:e.languages,skipped:[]});return pt(e.paths.metaPath,n),e.onStatus(`Index unchanged; reused existing SQLite index in ${(t/1e3).toFixed(1)}s`),{languages:e.languages,indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:t,reused:!0,skipped:[],lastRefresh:n}}function ei(e){let t=Kr(m(f(e.outputDb),"reindex-"));return{runDir:t,tempOutputScip:m(t,T(e.outputScip)),tempOutputDb:m(t,T(e.outputDb)),tempMetaPath:m(t,T(e.metaPath))}}async function ti(e){let t={...process.env,NODE_OPTIONS:`--max-old-space-size=${e.maxHeapMb}`},{indexedOutputs:n,skippedLanguages:r,reusedLanguages:i}=await ni(e,t);i.length>0&&e.onStatus(`Reused ${i.length} cached language shard(s): ${i.join(", ")}`);let o=ri(e,t,n,r),s=o.durationMs;return e.onStatus(`Done in ${(s/1e3).toFixed(1)}s`),{languages:n.map(a=>a.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:s,reused:!1,skipped:r,lastRefresh:o}}async function ni(e,t){let n=ii(e),r=new Set(n.map(c=>c.language));for(let c of r)e.onStatus(`Reusing cached ${c} SCIP shard (language inputs unchanged).`);let{preparedRuns:i,skippedLanguages:o}=ai({languages:e.languages.filter(c=>!r.has(c)),tempOutputScip:e.tempPaths.tempOutputScip,projectRoot:e.projectRoot,env:t,skipAutoInstall:e.skipAutoInstall,pnpmWorkspaces:e.opts.pnpmWorkspaces,typescriptProjectMode:e.opts.typescriptProjectMode,typescriptProjects:e.opts.typescriptProjects,clojureConfigPath:e.opts.clojureConfigPath,onStatus:e.onStatus}),s=await Oe(i,e.projectRoot,e.onStatus,e.opts.indexerConcurrency),{indexedOutputs:a}=ci(s,o),u=[...n,...a];return li(u,o,e.languages,e.opts.allowPartial,e.onStatus),{indexedOutputs:u,skippedLanguages:o,reusedLanguages:[...r]}}function ri(e,t,n,r){oi(e.paths.outputDb,n),gi(n,e.tempPaths.tempOutputScip,e.onStatus),pi(e.tempPaths.tempOutputScip,e.tempPaths.tempOutputDb,t,e.onStatus),y(x(),{projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,onStatus:e.onStatus});let i=ie({trigger:e.opts.trigger,result:"rebuilt",start:e.start,languages:n.map(o=>o.language),skipped:[...r]});return gt(e.tempPaths.tempMetaPath,{version:3,status:r.length===0?"complete":"partial",updatedAt:new Date().toISOString(),fingerprint:e.fingerprint,languageFingerprints:st(e.projectRoot,e.languages,{pnpmWorkspaces:e.opts.pnpmWorkspaces,typescriptProjectMode:e.opts.typescriptProjectMode,typescriptProjects:e.opts.typescriptProjects,clojureConfigPath:e.opts.clojureConfigPath}),requestedLanguages:e.languages,indexedLanguages:n.map(o=>o.language),skipped:[...r],lastRefresh:i}),Si({tempOutputScip:e.tempPaths.tempOutputScip,tempOutputDb:e.tempPaths.tempOutputDb,tempMetaPath:e.tempPaths.tempMetaPath,outputScip:e.paths.outputScip,outputDb:e.paths.outputDb,metaPath:e.paths.metaPath}),i}function ii(e){let t;try{t=JSON.parse(D(e.paths.metaPath,"utf-8"))}catch{return[]}if(t.version!==3||!t.languageFingerprints)return[];let n=[],r=st(e.projectRoot,e.languages,{pnpmWorkspaces:e.opts.pnpmWorkspaces,typescriptProjectMode:e.opts.typescriptProjectMode,typescriptProjects:e.opts.typescriptProjects,clojureConfigPath:e.opts.clojureConfigPath});for(let i of e.languages){let o=lt(e.paths.outputDb,i);M(o)&&S(t.languageFingerprints[i])===S(r[i])&&n.push({language:i,scipPath:o})}return n}function oi(e,t){for(let n of t){let r=lt(e,n.language);ne(f(r),{recursive:!0}),n.scipPath!==r&&zr(n.scipPath,r)}}function si(e,t){if(!E()){if(e)throw new Error(`The scip CLI is required but not found on PATH.
61
+ Install from: https://github.com/sourcegraph/scip/releases`);if(t("scip CLI not found on PATH. Attempting auto-install..."),!V(t))throw new Error(`The scip CLI is required but could not be installed.
62
+ Install manually from: https://github.com/sourcegraph/scip/releases`)}}function ai(e){let t=[],n=[],r=e.languages.map((i,o)=>({language:i,scipPath:e.languages.length>1?ot(e.tempOutputScip,i,o):e.tempOutputScip}));for(let{language:i,scipPath:o}of r){let s=ui({...e,language:i,scipPath:o});for(let a of s)"skipped"in a?it(n,a.skipped):t.push(a.prepared)}return{preparedRuns:t,skippedLanguages:n}}function ui(e){if(e.language!=="typescript"||e.typescriptProjectMode!=="workspace")return[ee({...e,id:e.language,label:e.language,outputScipPath:e.scipPath})];let t=je(e.projectRoot,e.typescriptProjects);return t.length===0?[ee({...e,id:e.language,label:e.language,outputScipPath:e.scipPath})]:(e.onStatus(`Indexing TypeScript workspace as ${t.length} project shard(s).`),t.map((n,r)=>ee({...e,id:`typescript:${n}`,label:`typescript (${n})`,scipPath:ot(e.tempOutputScip,"typescript-project",r),outputScipPath:e.scipPath,pnpmWorkspaces:!1,projectPath:n})))}function ee(e){let t=C(e.language),n=F(t),r=H(t,e.projectRoot);if(!r&&!G(t)){if(e.skipAutoInstall){let a=`${n} not found on PATH (auto-install disabled). ${t.installUrl??""}`.trim();return e.onStatus(`Skipping ${e.language}: ${a}`),{skipped:{language:e.language,reason:a}}}if(e.onStatus(`${n} not found. Attempting auto-install...`),!K(t,e.onStatus)){let a=`${n} could not be auto-installed. ${t.installUrl?`Install manually from ${t.installUrl}`:`Install ${n} and put it on PATH.`}`;return e.onStatus(`Skipping ${e.language}: ${a}`),{skipped:{language:e.language,reason:a}}}}let i=r??v(t);if(!i){let a=`${n} was not found after installation checks.`;return e.onStatus(`Skipping ${e.language}: ${a}`),{skipped:{language:e.language,reason:a}}}let{binary:o,args:s}=t.indexArgs({projectRoot:e.projectRoot,outputPath:e.scipPath,pnpmWorkspaces:e.pnpmWorkspaces,indexerBinary:i,projectPath:e.projectPath,configPath:e.language==="clojure"?e.clojureConfigPath:void 0});return{prepared:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,config:t,resolvedBinary:i,binary:o,args:s,env:z(t,e.env,i)}}}function ci(e,t){let n=new Map;for(let i of e)if(i.skipped)it(t,i.skipped);else{let o=`${i.language}\0${i.outputScipPath}`,s=n.get(o)??{language:i.language,outputScipPath:i.outputScipPath,scipPaths:[]};s.scipPaths.push(i.scipPath),n.set(o,s)}let r=[];for(let i of n.values())if(i.scipPaths.length>1)w(i.scipPaths,i.outputScipPath),r.push({language:i.language,scipPath:i.outputScipPath});else{let o=i.scipPaths[0];o!==i.outputScipPath&&k(o,i.outputScipPath),r.push({language:i.language,scipPath:i.outputScipPath})}return{indexedOutputs:r}}function it(e,t){let n=e.find(r=>r.language===t.language);if(!n){e.push(t);return}n.reason.includes(t.reason)||(n.reason=`${n.reason}; ${t.reason}`)}function li(e,t,n,r,i){if(e.length===0){let o=t.map(s=>` - ${s.language}: ${s.reason}`).join(`
63
63
  `);throw new Error(`No language indexers ran successfully. Install at least one indexer for the languages in this project.
64
64
  `+o)}if(t.length!==0&&(i(`Indexed ${e.length} language output(s); skipped or incomplete: ${t.map(o=>o.language).join(", ")}.`),!r))throw new Error(`Failed to index all required languages; preserving the previous index. Pass --allow-partial to intentionally write an incomplete index.
65
65
  `+t.map(o=>` - ${o.language}: ${o.reason}`).join(`
66
- `))}function ri(e,t,n){e.length>1?(n(`Merging ${e.length} language indexes...`),j(e.map(r=>r.scipPath),t)):e[0].scipPath!==t&&k(e[0].scipPath,t)}function ii(e,t,n,r){if(r("Converting to SQLite..."),!M(e))throw new Error(`SCIP index not found at ${e} after indexing`);try{let i=Re(e);i.removedDefinitionOccurrences>0&&r(`Sanitized ${i.removedDefinitionOccurrences} invalid definition occurrences across ${i.touchedDocuments} documents before SQLite conversion.`);let o=F();if(!o)throw new Error("scip CLI is not available");Ar(o,["expt-convert","--output",t,e],{env:n,stdio:"pipe",maxBuffer:50*1024*1024})}catch(i){let o=i instanceof Error?i.message:String(i);throw new Error(`Failed to convert SCIP index to SQLite: ${o}`,{cause:i})}}function tt(e,t,n){let r=Ur(e)||".scip",i=T(e,r);return m(f(e),`${i}.${n+1}.${t}${r}`)}async function oi(e,t){for(let n=0;n<2;n++){let r=si(e,t);if(r)return r;let i=ai(e);if(i&&ui(t.trigger,i)){t.onStatus(`Manual reindex preempting watcher refresh started at ${i.startedAt}.`),await li(i.pid),P(e,{force:!0});continue}if(i&&!ne(i.pid)){P(e,{force:!0});continue}throw new Error(`Another scip-query reindex is already running for ${f(e)}.`)}throw new Error(`Could not acquire scip-query reindex lock for ${f(e)}.`)}function si(e,t){let n;try{n=Wr(e,"wx")}catch(i){if((typeof i=="object"&&i&&"code"in i?i.code:void 0)==="EEXIST")return null;throw i}let r={version:1,pid:process.pid,projectRoot:t.projectRoot,startedAt:new Date().toISOString(),trigger:t.trigger};return Ze(n,JSON.stringify(r)+`
67
- `),()=>{try{$r(n)}finally{P(e,{force:!0})}}}function ai(e){try{let t=JSON.parse(D(e,"utf-8"));return typeof t.pid!="number"||!Number.isInteger(t.pid)||t.pid<=0?null:{version:1,pid:t.pid,projectRoot:typeof t.projectRoot=="string"?t.projectRoot:f(e),startedAt:typeof t.startedAt=="string"?t.startedAt:"unknown",trigger:t.trigger}}catch{return null}}function ui(e,t){return e?.kind==="manual-cli"&&ci(t?.trigger)}function ci(e){return e?.kind==="watch-source"||e?.kind==="watch-git-head"||e?.kind==="watch-git-index"||e?.kind==="watch-git-state"}async function li(e){Ye(e,"SIGTERM"),!await Qe(e,2e3)&&(Ye(e,"SIGKILL"),await Qe(e,1e3))}function Ye(e,t){try{process.kill(-e,t)}catch{try{process.kill(e,t)}catch{}}}async function Qe(e,t){let n=Date.now()+t;for(;Date.now()<n;){if(!ne(e))return!0;await gi(50)}return!ne(e)}function ne(e){try{return process.kill(e,0),!0}catch{return!1}}function gi(e){return new Promise(t=>setTimeout(t,e))}function pi(e){ee(e.tempOutputScip,e.outputScip),ee(e.tempOutputDb,e.outputDb),ee(e.tempMetaPath,e.metaPath)}function ee(e,t){P(`${t}.tmp-replace`,{force:!0}),k(e,`${t}.tmp-replace`),k(`${t}.tmp-replace`,t)}function di(e,t,n){return{version:2,languages:[...t].sort(),pnpmWorkspaces:it(n),typescriptProjectMode:n.typescriptProjectMode??"single",typescriptProjects:rt(n.typescriptProjects),files:R(e)}}function nt(e,t,n){return Object.fromEntries(t.map(r=>{let i=L(r).markerFiles,o=r==="typescript"?{typescriptProjectMode:n.typescriptProjectMode??"single",typescriptProjects:rt(n.typescriptProjects)}:{typescriptProjectMode:"single",typescriptProjects:[]};return[r,{version:2,languages:[r],pnpmWorkspaces:r==="typescript"&&it(n),...o,files:R(e,{language:r,markerFiles:i})}]}))}function rt(e){return[...new Set((e??[]).map(t=>t.trim()).filter(Boolean))].sort((t,n)=>t.localeCompare(n))}function it(e){return e.typescriptProjectMode!=="workspace"&&e.pnpmWorkspaces===!0}function ot(e,t){return m(f(e),"language-indexes",`${t}.scip`)}function fi(e,t){try{let n=JSON.parse(D(e,"utf-8"));return(n.version===2||n.version===3)&&n.status==="complete"&&S(n.fingerprint)===S(t)&&S([...n.indexedLanguages??[]].sort())===S(t.languages)}catch{return!1}}function st(e,t){let n=`${e}.tmp-${process.pid}-${Date.now()}`;Ze(n,`${JSON.stringify(t,null,2)}
68
- `),k(n,e)}function at(e,t){try{let n=JSON.parse(D(e,"utf-8"));if(n.version!==2&&n.version!==3)return;st(e,{...n,lastRefresh:t})}catch{}}function re(e){return{trigger:e.trigger??{kind:"unknown"},result:e.result,startedAt:new Date(e.start).toISOString(),completedAt:new Date().toISOString(),durationMs:Date.now()-e.start,indexedLanguages:e.languages?[...e.languages]:void 0,skipped:e.skipped?[...e.skipped]:void 0,error:e.error}}function S(e){return JSON.stringify(e)}export{fe as INDEXER_CONFIGS,b as augmentAuxiliaryDocuments,Pr as augmentVueResolvedReferences,O as describeIndexerBinary,V as detectLanguages,L as getIndexerConfig,z as getIndexerExecutionEnv,x as isBinaryAvailable,G as isIndexerInstalled,j as mergeScipFiles,me as mergeScipIndexes,No as reindex,v as resolveIndexerBinary,q as resolveProjectLocalIndexerBinary,H as tryInstallIndexer,E as tryInstallScipCli};
66
+ `))}function gi(e,t,n){e.length>1?(n(`Merging ${e.length} language indexes...`),w(e.map(r=>r.scipPath),t)):e[0].scipPath!==t&&k(e[0].scipPath,t)}function pi(e,t,n,r){if(r("Converting to SQLite..."),!M(e))throw new Error(`SCIP index not found at ${e} after indexing`);try{let i=Ie(e);i.removedDefinitionOccurrences>0&&r(`Sanitized ${i.removedDefinitionOccurrences} invalid definition occurrences across ${i.touchedDocuments} documents before SQLite conversion.`);let o=E();if(!o)throw new Error("scip CLI is not available");Gr(o,["expt-convert","--output",t,e],{env:n,stdio:"pipe",maxBuffer:50*1024*1024})}catch(i){let o=i instanceof Error?i.message:String(i);throw new Error(`Failed to convert SCIP index to SQLite: ${o}`,{cause:i})}}function ot(e,t,n){let r=Yr(e)||".scip",i=T(e,r);return m(f(e),`${i}.${n+1}.${t}${r}`)}async function di(e,t){for(let n=0;n<2;n++){let r=fi(e,t);if(r)return r;let i=mi(e);if(i&&hi(t.trigger,i)){t.onStatus(`Manual reindex preempting watcher refresh started at ${i.startedAt}.`),await bi(i.pid),I(e,{force:!0});continue}if(i&&!re(i.pid)){I(e,{force:!0});continue}throw new Error(`Another scip-query reindex is already running for ${f(e)}.`)}throw new Error(`Could not acquire scip-query reindex lock for ${f(e)}.`)}function fi(e,t){let n;try{n=Xr(e,"wx")}catch(i){if((typeof i=="object"&&i&&"code"in i?i.code:void 0)==="EEXIST")return null;throw i}let r={version:1,pid:process.pid,projectRoot:t.projectRoot,startedAt:new Date().toISOString(),trigger:t.trigger};return rt(n,JSON.stringify(r)+`
67
+ `),()=>{try{Hr(n)}finally{I(e,{force:!0})}}}function mi(e){try{let t=JSON.parse(D(e,"utf-8"));return typeof t.pid!="number"||!Number.isInteger(t.pid)||t.pid<=0?null:{version:1,pid:t.pid,projectRoot:typeof t.projectRoot=="string"?t.projectRoot:f(e),startedAt:typeof t.startedAt=="string"?t.startedAt:"unknown",trigger:t.trigger}}catch{return null}}function hi(e,t){return e?.kind==="manual-cli"&&yi(t?.trigger)}function yi(e){return e?.kind==="watch-source"||e?.kind==="watch-git-head"||e?.kind==="watch-git-index"||e?.kind==="watch-git-state"}async function bi(e){tt(e,"SIGTERM"),!await nt(e,2e3)&&(tt(e,"SIGKILL"),await nt(e,1e3))}function tt(e,t){try{process.kill(-e,t)}catch{try{process.kill(e,t)}catch{}}}async function nt(e,t){let n=Date.now()+t;for(;Date.now()<n;){if(!re(e))return!0;await xi(50)}return!re(e)}function re(e){try{return process.kill(e,0),!0}catch{return!1}}function xi(e){return new Promise(t=>setTimeout(t,e))}function Si(e){te(e.tempOutputScip,e.outputScip),te(e.tempOutputDb,e.outputDb),te(e.tempMetaPath,e.metaPath)}function te(e,t){I(`${t}.tmp-replace`,{force:!0}),k(e,`${t}.tmp-replace`),k(`${t}.tmp-replace`,t)}function Ri(e,t,n){return{version:2,languages:[...t].sort(),pnpmWorkspaces:ct(n),typescriptProjectMode:n.typescriptProjectMode??"single",typescriptProjects:at(n.typescriptProjects),clojureConfigPath:ut(n.clojureConfigPath),files:P(e)}}function st(e,t,n){return Object.fromEntries(t.map(r=>{let i=C(r).markerFiles,o=r==="typescript"?{typescriptProjectMode:n.typescriptProjectMode??"single",typescriptProjects:at(n.typescriptProjects)}:{typescriptProjectMode:"single",typescriptProjects:[]},s=r==="clojure"?ut(n.clojureConfigPath):void 0;return[r,{version:2,languages:[r],pnpmWorkspaces:r==="typescript"&&ct(n),...o,clojureConfigPath:s,files:P(e,{language:r,markerFiles:i})}]}))}function at(e){return[...new Set((e??[]).map(t=>t.trim()).filter(Boolean))].sort((t,n)=>t.localeCompare(n))}function ut(e){return e?.trim()||void 0}function ct(e){return e.typescriptProjectMode!=="workspace"&&e.pnpmWorkspaces===!0}function lt(e,t){return m(f(e),"language-indexes",`${t}.scip`)}function Pi(e,t){try{let n=JSON.parse(D(e,"utf-8"));return(n.version===2||n.version===3)&&n.status==="complete"&&S(n.fingerprint)===S(t)&&S([...n.indexedLanguages??[]].sort())===S(t.languages)}catch{return!1}}function gt(e,t){let n=`${e}.tmp-${process.pid}-${Date.now()}`;rt(n,`${JSON.stringify(t,null,2)}
68
+ `),k(n,e)}function pt(e,t){try{let n=JSON.parse(D(e,"utf-8"));if(n.version!==2&&n.version!==3)return;gt(e,{...n,lastRefresh:t})}catch{}}function ie(e){return{trigger:e.trigger??{kind:"unknown"},result:e.result,startedAt:new Date(e.start).toISOString(),completedAt:new Date().toISOString(),durationMs:Date.now()-e.start,indexedLanguages:e.languages?[...e.languages]:void 0,skipped:e.skipped?[...e.skipped]:void 0,error:e.error}}function S(e){return JSON.stringify(e)}export{he as INDEXER_CONFIGS,ce as augmentAuxiliaryDocuments,Mr as augmentVueResolvedReferences,x as auxiliaryDocumentsAugmentationStage,F as describeIndexerBinary,A as detectLanguages,C as getIndexerConfig,z as getIndexerExecutionEnv,R as isBinaryAvailable,G as isIndexerInstalled,w as mergeScipFiles,ye as mergeScipIndexes,Ko as reindex,v as resolveIndexerBinary,H as resolveProjectLocalIndexerBinary,y as runPostIndexAugmentation,K as tryInstallIndexer,V as tryInstallScipCli,Ze as vueResolvedReferencesAugmentationStage};
69
69
  //# sourceMappingURL=reindex.js.map
package/dist/runtime.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { P as ProjectConfig, a as SupportedLanguage } from './config-types-BDIWAYzr.js';
2
- import { W as WatcherStatus } from './scip-cli-CnK9Va4O.js';
3
- export { g as getScipVersion, i as isScipInstalled, p as printScipInstallInstructions } from './scip-cli-CnK9Va4O.js';
1
+ import { P as ProjectConfig, a as SupportedLanguage } from './config-types-dvHOz0zU.js';
2
+ import { W as WatcherStatus } from './scip-cli-trnNvymv.js';
3
+ export { g as getScipVersion, i as isScipInstalled, p as printScipInstallInstructions } from './scip-cli-trnNvymv.js';
4
4
 
5
5
  /**
6
6
  * Load project config from .scipquery.json in the project root.
@@ -48,6 +48,7 @@ declare class Watcher {
48
48
  private pnpmWorkspaces;
49
49
  private typescriptProjectMode?;
50
50
  private typescriptProjects?;
51
+ private clojureConfigPath?;
51
52
  private indexerConcurrency?;
52
53
  private onStatus;
53
54
  private onReindexComplete;
package/dist/runtime.js CHANGED
@@ -1,3 +1,3 @@
1
- import{c as I,d as M,e as E}from"./chunk-ONPCQ2PM.js";import{a as C}from"./chunk-UUBMFL3F.js";import{readFileSync as $,writeFileSync as D,existsSync as R,mkdirSync as _}from"fs";import{isAbsolute as oe,join as c,relative as ae,resolve as P}from"path";import{createHash as A}from"crypto";import{homedir as N}from"os";var g=".scipquery.json",W={enabled:!1,debounceMs:3e4,cooldownMs:6e4,gitPollMs:2e3,autoRefresh:!0,ignore:[]};function m(i){let e=c(i,g);if(!R(e))return{};try{let t=$(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 j(i){return{...W,...i.watch}}function G(i,e){let t=process.env.SCIP_QUERY_CACHE_DIR;if(t)return f(t);if(e?.dbPath)return f(P(i,e.dbPath));let s=process.env.XDG_CACHE_HOME||c(N(),".cache"),n=A("sha256").update(P(i)).digest("hex").slice(0,12),a=c(s,"scip-query","projects",n);return f(a)}function y(i,e){let t=G(i,e);return{cacheDir:t,dbPath:c(t,"index.db"),indexPath:c(t,"index.scip"),metaPath:c(t,"meta.json")}}function F(i,e){let t=c(i,g);return R(t)||D(t,JSON.stringify({languages:e,watch:{enabled:!1,debounceMs:3e4,cooldownMs:6e4,gitPollMs:2e3,autoRefresh:!0}},null,2)+`
2
- `),t}function f(i){return _(i,{recursive:!0}),i}import{execFileSync as O,fork as L}from"child_process";import{statSync as U,watch as H}from"fs";import{join as q,relative as X}from"path";import B from"ignore";var x=class{projectRoot;config;watchConfig;languages;pnpmWorkspaces;typescriptProjectMode;typescriptProjects;indexerConcurrency;onStatus;onReindexComplete;onError;status={state:"idle"};debounceTimer=null;cooldownTimer=null;dirty=!1;changedFiles=0;pendingTrigger=null;reindexInFlight=!1;lastReindexEnd=0;fsWatchers=[];gitPollTimer=null;lastGitState=null;gitignoreFilter;extraIgnore;stopped=!1;constructor(e){this.projectRoot=e.projectRoot,this.config=e.config,this.watchConfig=j(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.indexerConcurrency=e.config.indexerConcurrency,this.onStatus=e.onStatus??(()=>{}),this.onReindexComplete=e.onReindexComplete??(()=>{}),this.onError=e.onError??(t=>console.error(t.message)),this.gitignoreFilter=C(e.projectRoot),this.extraIgnore=B(),this.watchConfig.ignore.length>0&&this.extraIgnore.add(this.watchConfig.ignore)}start(){this.stopped=!1,this.setStatus({state:"idle"}),this.startGitStatePolling();try{let e=H(this.projectRoot,{recursive:!0},(t,r)=>{r&&!this.stopped&&this.handleFileChange(r)});this.fsWatchers.push(e)}catch{this.onError(new Error("Failed to start file watcher. On Linux, you may need to increase inotify limits: sysctl -w fs.inotify.max_user_watches=524288"))}}stop(){this.stopped=!0;for(let e of this.fsWatchers)e.close();this.fsWatchers=[],this.clearDebounceTimer(),this.clearCooldownTimer(),this.clearGitPollTimer(),this.setStatus({state:"idle"})}handleFileChange(e){let t=X(this.projectRoot,q(this.projectRoot,e));t===".git"||t.startsWith(".git/")||this.gitignoreFilter.isIgnored(t)||this.extraIgnore.ignores(t)||e.endsWith("index.db")||e.endsWith("index.scip")||e.endsWith("index.db.tmp")||this.scheduleReindex({kind:"watch-source",detail:t})}scheduleReindex(e){if(this.pendingTrigger=z(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 s=this.watchConfig.cooldownMs-e;this.dirty=!0;let n=Date.now()+s;this.setStatus({state:"cooldown",until:n,dirty:!0}),this.cooldownTimer=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 t=this.pendingTrigger??{kind:"watch-source"};this.pendingTrigger=null;let r=Date.now();this.setStatus({state:"indexing",startedAt:r}),this.runReindex(t).then(s=>{if(this.reindexInFlight=!1,this.lastReindexEnd=Date.now(),this.onReindexComplete(s),this.dirty&&!this.stopped){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(s=>{this.reindexInFlight=!1,this.lastReindexEnd=Date.now(),this.onError(s instanceof Error?s:new Error(String(s))),this.setStatus({state:"idle"})})}runReindex(e){return new Promise((t,r)=>{let s=Date.now(),n=m(this.projectRoot),a=Object.keys(n).length>0?n:this.config,h=y(this.projectRoot,a),l=a.indexer?.typescript,o=L(new URL("./reindex-worker.js",import.meta.url).pathname,[],{detached:!0,env:{...process.env,SCIP_REINDEX_PROJECT_ROOT:this.projectRoot,SCIP_REINDEX_OUTPUT_SCIP:h.indexPath,SCIP_REINDEX_OUTPUT_DB:h.dbPath,SCIP_REINDEX_LANGUAGES:(a.languages??this.languages)?.join(",")??"",SCIP_REINDEX_INDEXER_CONCURRENCY:String(a.indexerConcurrency??this.indexerConcurrency??""),SCIP_REINDEX_PNPM_WORKSPACES:l?.pnpmWorkspaces??this.pnpmWorkspaces?"1":"",SCIP_REINDEX_TYPESCRIPT_CONFIG:JSON.stringify({projectMode:l?.projectMode??this.typescriptProjectMode,projects:l?.projects??this.typescriptProjects??[]}),SCIP_REINDEX_TRIGGER_KIND:e.kind,SCIP_REINDEX_TRIGGER_DETAIL:e.detail??""},stdio:"pipe"});o.on("exit",p=>{p===0?t(Date.now()-s):r(new Error(`Reindex worker exited with code ${p}`))}),o.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,s=e.indexPath!==t.indexPath||e.indexMtimeMs!==t.indexMtimeMs||e.indexSize!==t.indexSize;r&&s?this.scheduleReindex({kind:"watch-git-state",detail:"HEAD and index changed"}):r?this.scheduleReindex({kind:"watch-git-head",detail:"HEAD changed"}):s&&this.scheduleReindex({kind:"watch-git-index",detail:t.indexPath??"index changed"})}readGitState(){let e=T(this.projectRoot,["rev-parse","--git-path","index"]);if(!e)return null;let t={head:T(this.projectRoot,["rev-parse","--verify","HEAD"]),indexPath:e};try{let r=U(e);t.indexMtimeMs=r.mtimeMs,t.indexSize=r.size}catch{t.indexMtimeMs=void 0,t.indexSize=void 0}return t}clearGitPollTimer(){this.gitPollTimer&&(clearInterval(this.gitPollTimer),this.gitPollTimer=null)}};function T(i,e){try{return O("git",["-C",i,...e],{encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).trim()}catch{return}}function z(i,e){return i?i.kind===e.kind?i.detail===e.detail?i:{kind:i.kind,detail:"multiple changes"}:{kind:"watch-git-state",detail:`${i.kind}, ${e.kind}`}:e}import{existsSync as S,mkdirSync as J,symlinkSync as K,readlinkSync as V,unlinkSync as Y}from"fs";import{join as d,dirname as k,resolve as v}from"path";import{homedir as w,platform as Q}from"os";import{fileURLToPath as Z}from"url";var ee=Q()==="win32",te=["scip-query","scip-query-setup","scip-adoption","scip-health-audit","scip-health-improve","scip-hyper-optimization","scip-api-impact","concrete-plan","scip-ai-cleanup","scip-debug","scip-explore","scip-triage-issue","scip-diagram","scip-debloat","scip-doc-reconcile","scip-directory-architecture","scip-maintainability","scip-react-maintainability","scip-vue-maintainability","scip-verify","scip-language-playbook"];function ie(i={}){let e=i.quiet?()=>{}:console.log,t=Z(import.meta.url),r=v(k(t),"..","skills"),s=[d(w(),".claude","skills"),d(w(),".codex","skills"),d(w(),".agents","skills")],n={installed:[],skipped:[],alreadyLinked:[]};for(let a of s){let h=k(a);if(!S(h))continue;J(a,{recursive:!0});let l=re(a);for(let o of te){let p=d(r,o),u=d(a,o);if(!S(p)){n.skipped.push(`${l}/${o}`);continue}if(S(u)){try{let b=V(u);if(v(b)===v(p)){n.alreadyLinked.push(`${l}/${o}`),e(` ok: ${o} \u2192 ${l} (already linked)`);continue}}catch{n.skipped.push(`${l}/${o}`),e(` skip: ${o} \u2192 ${l} (exists, not a symlink)`);continue}Y(u)}K(p,u,ee?"junction":"dir"),n.installed.push(`${l}/${o}`),e(` done: ${o} \u2192 ${l}`)}}return n}function re(i){return i.includes(".codex")?"Codex":i.includes(".agents")?"Agents":"Claude"}export{x as Watcher,M as getScipVersion,F as initProjectConfig,ie as installSkills,I as isScipInstalled,m as loadProjectConfig,E as printScipInstallInstructions,y as resolveIndexPaths};
1
+ import{c as k,d as E,e as M}from"./chunk-ONPCQ2PM.js";import{a as w}from"./chunk-UUBMFL3F.js";import{readFileSync as $,writeFileSync as D,existsSync as j,mkdirSync as _}from"fs";import{isAbsolute as oe,join as p,relative as ae,resolve as P}from"path";import{createHash as A}from"crypto";import{homedir as N}from"os";var g=".scipquery.json",W={enabled:!1,debounceMs:3e4,cooldownMs:6e4,gitPollMs:2e3,autoRefresh:!0,ignore:[]};function m(i){let e=p(i,g);if(!j(e))return{};try{let t=$(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 R(i){return{...W,...i.watch}}function G(i,e){let t=process.env.SCIP_QUERY_CACHE_DIR;if(t)return f(t);if(e?.dbPath)return f(P(i,e.dbPath));let s=process.env.XDG_CACHE_HOME||p(N(),".cache"),n=A("sha256").update(P(i)).digest("hex").slice(0,12),o=p(s,"scip-query","projects",n);return f(o)}function x(i,e){let t=G(i,e);return{cacheDir:t,dbPath:p(t,"index.db"),indexPath:p(t,"index.scip"),metaPath:p(t,"meta.json")}}function F(i,e){let t=p(i,g);return j(t)||D(t,JSON.stringify({languages:e,watch:{enabled:!1,debounceMs:3e4,cooldownMs:6e4,gitPollMs:2e3,autoRefresh:!0}},null,2)+`
2
+ `),t}function f(i){return _(i,{recursive:!0}),i}import{execFileSync as O,fork as L}from"child_process";import{statSync as U,watch as H}from"fs";import{join as q,relative as X}from"path";import B from"ignore";var y=class{projectRoot;config;watchConfig;languages;pnpmWorkspaces;typescriptProjectMode;typescriptProjects;clojureConfigPath;indexerConcurrency;onStatus;onReindexComplete;onError;status={state:"idle"};debounceTimer=null;cooldownTimer=null;dirty=!1;changedFiles=0;pendingTrigger=null;reindexInFlight=!1;lastReindexEnd=0;fsWatchers=[];gitPollTimer=null;lastGitState=null;gitignoreFilter;extraIgnore;stopped=!1;constructor(e){this.projectRoot=e.projectRoot,this.config=e.config,this.watchConfig=R(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.onError=e.onError??(t=>console.error(t.message)),this.gitignoreFilter=w(e.projectRoot),this.extraIgnore=B(),this.watchConfig.ignore.length>0&&this.extraIgnore.add(this.watchConfig.ignore)}start(){this.stopped=!1,this.setStatus({state:"idle"}),this.startGitStatePolling();try{let e=H(this.projectRoot,{recursive:!0},(t,r)=>{r&&!this.stopped&&this.handleFileChange(r)});this.fsWatchers.push(e)}catch{this.onError(new Error("Failed to start file watcher. On Linux, you may need to increase inotify limits: sysctl -w fs.inotify.max_user_watches=524288"))}}stop(){this.stopped=!0;for(let e of this.fsWatchers)e.close();this.fsWatchers=[],this.clearDebounceTimer(),this.clearCooldownTimer(),this.clearGitPollTimer(),this.setStatus({state:"idle"})}handleFileChange(e){let t=X(this.projectRoot,q(this.projectRoot,e));t===".git"||t.startsWith(".git/")||this.gitignoreFilter.isIgnored(t)||this.extraIgnore.ignores(t)||e.endsWith("index.db")||e.endsWith("index.scip")||e.endsWith("index.db.tmp")||this.scheduleReindex({kind:"watch-source",detail:t})}scheduleReindex(e){if(this.pendingTrigger=z(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 s=this.watchConfig.cooldownMs-e;this.dirty=!0;let n=Date.now()+s;this.setStatus({state:"cooldown",until:n,dirty:!0}),this.cooldownTimer=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 t=this.pendingTrigger??{kind:"watch-source"};this.pendingTrigger=null;let r=Date.now();this.setStatus({state:"indexing",startedAt:r}),this.runReindex(t).then(s=>{if(this.reindexInFlight=!1,this.lastReindexEnd=Date.now(),this.onReindexComplete(s),this.dirty&&!this.stopped){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(s=>{this.reindexInFlight=!1,this.lastReindexEnd=Date.now(),this.onError(s instanceof Error?s:new Error(String(s))),this.setStatus({state:"idle"})})}runReindex(e){return new Promise((t,r)=>{let s=Date.now(),n=m(this.projectRoot),o=Object.keys(n).length>0?n:this.config,u=x(this.projectRoot,o),a=o.indexer?.typescript,l=o.indexer?.clojure,d=L(new URL("./reindex-worker.js",import.meta.url).pathname,[],{detached:!0,env:{...process.env,SCIP_REINDEX_PROJECT_ROOT:this.projectRoot,SCIP_REINDEX_OUTPUT_SCIP:u.indexPath,SCIP_REINDEX_OUTPUT_DB:u.dbPath,SCIP_REINDEX_LANGUAGES:(o.languages??this.languages)?.join(",")??"",SCIP_REINDEX_INDEXER_CONCURRENCY:String(o.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"});d.on("exit",c=>{c===0?t(Date.now()-s):r(new Error(`Reindex worker exited with code ${c}`))}),d.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,s=e.indexPath!==t.indexPath||e.indexMtimeMs!==t.indexMtimeMs||e.indexSize!==t.indexSize;r&&s?this.scheduleReindex({kind:"watch-git-state",detail:"HEAD and index changed"}):r?this.scheduleReindex({kind:"watch-git-head",detail:"HEAD changed"}):s&&this.scheduleReindex({kind:"watch-git-index",detail:t.indexPath??"index changed"})}readGitState(){let e=I(this.projectRoot,["rev-parse","--git-path","index"]);if(!e)return null;let t={head:I(this.projectRoot,["rev-parse","--verify","HEAD"]),indexPath:e};try{let r=U(e);t.indexMtimeMs=r.mtimeMs,t.indexSize=r.size}catch{t.indexMtimeMs=void 0,t.indexSize=void 0}return t}clearGitPollTimer(){this.gitPollTimer&&(clearInterval(this.gitPollTimer),this.gitPollTimer=null)}};function I(i,e){try{return O("git",["-C",i,...e],{encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).trim()}catch{return}}function z(i,e){return i?i.kind===e.kind?i.detail===e.detail?i:{kind:i.kind,detail:"multiple changes"}:{kind:"watch-git-state",detail:`${i.kind}, ${e.kind}`}:e}import{existsSync as S,mkdirSync as J,symlinkSync as K,readlinkSync as V,unlinkSync as Y}from"fs";import{join as h,dirname as T,resolve as v}from"path";import{homedir as C,platform as Q}from"os";import{fileURLToPath as Z}from"url";var ee=Q()==="win32",te=["scip-query","scip-query-setup","scip-adoption","scip-health-audit","scip-health-improve","scip-hyper-optimization","scip-api-impact","concrete-plan","scip-ai-cleanup","scip-debug","scip-explore","scip-triage-issue","scip-diagram","scip-debloat","scip-doc-reconcile","scip-directory-architecture","scip-maintainability","scip-react-maintainability","scip-vue-maintainability","scip-verify","scip-language-playbook"];function ie(i={}){let e=i.quiet?()=>{}:console.log,t=Z(import.meta.url),r=v(T(t),"..","skills"),s=[h(C(),".claude","skills"),h(C(),".codex","skills"),h(C(),".agents","skills")],n={installed:[],skipped:[],alreadyLinked:[]};for(let o of s){let u=T(o);if(!S(u))continue;J(o,{recursive:!0});let a=re(o);for(let l of te){let d=h(r,l),c=h(o,l);if(!S(d)){n.skipped.push(`${a}/${l}`);continue}if(S(c)){try{let b=V(c);if(v(b)===v(d)){n.alreadyLinked.push(`${a}/${l}`),e(` ok: ${l} \u2192 ${a} (already linked)`);continue}}catch{n.skipped.push(`${a}/${l}`),e(` skip: ${l} \u2192 ${a} (exists, not a symlink)`);continue}Y(c)}K(d,c,ee?"junction":"dir"),n.installed.push(`${a}/${l}`),e(` done: ${l} \u2192 ${a}`)}}return n}function re(i){return i.includes(".codex")?"Codex":i.includes(".agents")?"Agents":"Claude"}export{y as Watcher,E as getScipVersion,F as initProjectConfig,ie as installSkills,k as isScipInstalled,m as loadProjectConfig,M as printScipInstallInstructions,x as resolveIndexPaths};
3
3
  //# sourceMappingURL=runtime.js.map
@@ -1,4 +1,4 @@
1
- import { a as SupportedLanguage } from './config-types-BDIWAYzr.js';
1
+ import { a as SupportedLanguage } from './config-types-dvHOz0zU.js';
2
2
 
3
3
  type WatcherStatus = {
4
4
  state: 'idle';
@@ -107,7 +107,7 @@ This syntax summary is generated from the CLI command descriptors. Keep workflow
107
107
 
108
108
  | Command | Description | Options |
109
109
  |---|---|---|
110
- | `self-audit` | Score the cheap evidence paths against the TypeScript compiler oracle on sampled symbols | `--samples <n>`<br>`-s, --scope <path>`<br>`--json` |
110
+ | `self-audit` | Score cheap evidence paths against the best available semantic/source oracle on sampled symbols | `--samples <n>`<br>`-s, --scope <path>`<br>`--json` |
111
111
  | `health` | Composite codebase health report with prioritized action list | `-s, --scope <path>`<br>`--full`<br>`--json`<br>`--baseline`<br>`--write-baseline` |
112
112
  | `complexity <symbol>` | Per-symbol complexity: branches, cyclomatic estimate, fan-in/out, callees | `--full`<br>`--json` |
113
113
 
@@ -115,7 +115,7 @@ This syntax summary is generated from the CLI command descriptors. Keep workflow
115
115
 
116
116
  | Command | Description | Options |
117
117
  |---|---|---|
118
- | `bench` | Benchmark indexing and command runtimes for this repository | `--json`<br>`--cold-index`<br>`--include-heavy`<br>`--command <cmd>`<br>`--timeout-ms <n>` |
118
+ | `bench` | Benchmark indexing and command runtimes for this repository | `--json`<br>`--cold-index`<br>`--include-heavy`<br>`--command <cmd>`<br>`--timeout-ms <n>`<br>`--progress`<br>`--profile`<br>`--profile-out <path>` |
119
119
  | `install-skills` | Install skills (scip-query, scip-query-setup, scip-adoption, scip-health-audit, scip-health-improve, scip-hyper-optimization, scip-api-impact, concrete-plan, scip-ai-cleanup, scip-debug, scip-explore, scip-triage-issue, scip-diagram, scip-debloat, scip-doc-reconcile, scip-directory-architecture, scip-maintainability, scip-react-maintainability, scip-vue-maintainability, scip-verify, scip-language-playbook) into Claude Code, Codex, and shared agent roots | - |
120
120
  | `setup-hooks` | Install or refresh project-local Codex and Claude Code lifecycle hooks | `--json` |
121
121
  | `check-deps` | Check whether scip-query and the detected language indexers are actually runnable | - |
@@ -193,3 +193,11 @@ The `src/queries/impact/diff-gate.ts` citation remains accurate after the
193
193
  focused co-change history optimization. Diff-gate still owns the check list and
194
194
  co-change partner gate; the latest change only narrows the git-history read for
195
195
  that gate to commits in the bounded analysis window that touched changed files.
196
+
197
+ ## 2026-06-30 Git Evidence Product Follow-Up
198
+
199
+ The `src/queries/health/health.ts` and `src/queries/impact/diff-gate.ts`
200
+ citations remain accurate after the Git evidence product migration. Health
201
+ still owns the composite phase inventory, and diff-gate still owns
202
+ `DIFF_GATE_CHECKS`; both now obtain Git history facts through
203
+ `gitEvidenceProduct()` instead of direct helper reads.
@@ -299,3 +299,10 @@ optimization. Default diff-gate still runs the same check family; the
299
299
  co-change partner check now reads only changed-file commits from the same
300
300
  bounded git-history window instead of parsing the whole name-only history
301
301
  payload.
302
+
303
+ ## 2026-06-30 Git Evidence Product Follow-Up
304
+
305
+ The `diffGate()` and health citations remain accurate after the Git evidence
306
+ product migration. Default diff-gate still runs the same check family, and
307
+ health still reports the same Git evidence summary; both paths now read Git
308
+ history through `gitEvidenceProduct()`.