scip-query 0.6.7 → 0.6.9

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 (175) hide show
  1. package/dist/chunk-2OP63JQQ.js +2 -0
  2. package/dist/chunk-33Z6HQBX.js +5 -0
  3. package/dist/chunk-3F453KPT.js +2 -0
  4. package/dist/{chunk-2YA36CXK.js → chunk-3JGBAAP7.js} +2 -2
  5. package/dist/chunk-3PKPUCIJ.js +11 -0
  6. package/dist/chunk-42BWO2NN.js +2 -0
  7. package/dist/chunk-4MDCFY3E.js +2 -0
  8. package/dist/chunk-4QWTQ6YV.js +2 -0
  9. package/dist/{chunk-WPY46NIL.js → chunk-5IRX5I64.js} +2 -2
  10. package/dist/chunk-5MPZ2A7J.js +2 -0
  11. package/dist/{chunk-G47V5V3U.js → chunk-67OMD56K.js} +2 -2
  12. package/dist/chunk-6UVVA5I4.js +7 -0
  13. package/dist/{chunk-2R7OKZE5.js → chunk-AXHDRSRI.js} +2 -2
  14. package/dist/{chunk-R373SHXM.js → chunk-BAA4EJRX.js} +2 -2
  15. package/dist/{chunk-QYWGC7JV.js → chunk-BT36WY5B.js} +2 -2
  16. package/dist/chunk-CLKFDBS6.js +39 -0
  17. package/dist/chunk-CWMWTHV3.js +2 -0
  18. package/dist/chunk-DXO2ECRF.js +7 -0
  19. package/dist/chunk-EHEZLULQ.js +85 -0
  20. package/dist/{chunk-2CC7RA6B.js → chunk-GRAEZYYU.js} +2 -2
  21. package/dist/chunk-GWBRU65E.js +2 -0
  22. package/dist/{chunk-6XRB6ATD.js → chunk-I2KUHGMX.js} +2 -2
  23. package/dist/{chunk-HTJ5BOYP.js → chunk-I5BB33E6.js} +2 -2
  24. package/dist/{chunk-TYRPQE6R.js → chunk-IIKNAXAE.js} +2 -2
  25. package/dist/{chunk-RRWPHKZA.js → chunk-IX45SWX5.js} +2 -2
  26. package/dist/{chunk-PQTGBYXV.js → chunk-JLFAQ2E2.js} +2 -2
  27. package/dist/chunk-JMASYYSW.js +2 -0
  28. package/dist/{chunk-IBWYWAWE.js → chunk-LBWLO7NA.js} +2 -2
  29. package/dist/{chunk-55ZJ2FCW.js → chunk-LLDPR3DG.js} +2 -2
  30. package/dist/chunk-LNUZWWWL.js +2 -0
  31. package/dist/{chunk-KYGNCIJ6.js → chunk-NLJCXHFU.js} +8 -8
  32. package/dist/chunk-NRAJIFQA.js +2 -0
  33. package/dist/chunk-OYRGWW6Z.js +2 -0
  34. package/dist/chunk-PVMRIOM6.js +33 -0
  35. package/dist/chunk-SF2HYG53.js +4 -0
  36. package/dist/chunk-SHGPRVWH.js +2 -0
  37. package/dist/chunk-SMOUOKAO.js +2 -0
  38. package/dist/chunk-TPXWXKL6.js +2 -0
  39. package/dist/chunk-TTCUMJ43.js +19 -0
  40. package/dist/chunk-TYR7QY5G.js +2 -0
  41. package/dist/{chunk-FYO3FPFH.js → chunk-U3GYMGBX.js} +2 -2
  42. package/dist/{chunk-OCQN6WF4.js → chunk-UIM4WALN.js} +2 -2
  43. package/dist/chunk-UZG3QXTG.js +2 -0
  44. package/dist/{chunk-KQWFRAQI.js → chunk-V4WRHJU3.js} +2 -2
  45. package/dist/chunk-VDMRAGBK.js +6 -0
  46. package/dist/chunk-W6SRVK2Y.js +5 -0
  47. package/dist/{chunk-7TGEXAN5.js → chunk-WGYJDGBI.js} +2 -2
  48. package/dist/{chunk-JVMXNDRU.js → chunk-WYX3RU2K.js} +2 -2
  49. package/dist/chunk-WZYA234B.js +2 -0
  50. package/dist/{chunk-K345WFTU.js → chunk-Y6ZFXZ7B.js} +2 -2
  51. package/dist/chunk-YCN5XEST.js +7 -0
  52. package/dist/{chunk-ILQSK2KJ.js → chunk-ZO5IFJRM.js} +2 -2
  53. package/dist/cli.js +186 -165
  54. package/dist/{db-DdlToIC-.d.ts → db-Rx8Ho_JF.d.ts} +3 -0
  55. package/dist/index.d.ts +11 -4
  56. package/dist/index.js +23 -23
  57. package/dist/queries/affected.d.ts +1 -1
  58. package/dist/queries/affected.js +1 -1
  59. package/dist/queries/bottlenecks.d.ts +3 -1
  60. package/dist/queries/bottlenecks.js +1 -1
  61. package/dist/queries/by-kind.d.ts +1 -1
  62. package/dist/queries/by-kind.js +1 -1
  63. package/dist/queries/call-graph.d.ts +4 -2
  64. package/dist/queries/call-graph.js +1 -1
  65. package/dist/queries/change-surface.d.ts +4 -2
  66. package/dist/queries/change-surface.js +1 -1
  67. package/dist/queries/code.d.ts +1 -1
  68. package/dist/queries/code.js +1 -1
  69. package/dist/queries/complexity-hotspots.d.ts +2 -1
  70. package/dist/queries/complexity-hotspots.js +1 -1
  71. package/dist/queries/complexity.d.ts +4 -2
  72. package/dist/queries/complexity.js +1 -1
  73. package/dist/queries/convergence.d.ts +4 -2
  74. package/dist/queries/convergence.js +1 -1
  75. package/dist/queries/coupling.d.ts +1 -1
  76. package/dist/queries/coupling.js +1 -1
  77. package/dist/queries/cycles.d.ts +1 -1
  78. package/dist/queries/cycles.js +1 -1
  79. package/dist/queries/dataflow.d.ts +4 -2
  80. package/dist/queries/dataflow.js +1 -1
  81. package/dist/queries/dead.d.ts +1 -1
  82. package/dist/queries/dead.js +1 -1
  83. package/dist/queries/deep-chains.d.ts +1 -1
  84. package/dist/queries/deep-chains.js +1 -1
  85. package/dist/queries/deps.d.ts +1 -1
  86. package/dist/queries/deps.js +1 -1
  87. package/dist/queries/diff-impact.d.ts +1 -1
  88. package/dist/queries/diff-impact.js +1 -1
  89. package/dist/queries/drift.d.ts +2 -1
  90. package/dist/queries/drift.js +1 -1
  91. package/dist/queries/extract-candidates.d.ts +2 -1
  92. package/dist/queries/extract-candidates.js +1 -1
  93. package/dist/queries/fan.d.ts +1 -1
  94. package/dist/queries/fan.js +1 -1
  95. package/dist/queries/files.d.ts +1 -1
  96. package/dist/queries/health-cache-control.d.ts +1 -1
  97. package/dist/queries/health-cache-control.js +1 -1
  98. package/dist/queries/health.d.ts +1 -1
  99. package/dist/queries/health.js +1 -1
  100. package/dist/queries/hierarchy.d.ts +1 -1
  101. package/dist/queries/hierarchy.js +1 -1
  102. package/dist/queries/hotspots.d.ts +1 -1
  103. package/dist/queries/hotspots.js +1 -1
  104. package/dist/queries/imports.d.ts +7 -3
  105. package/dist/queries/imports.js +1 -1
  106. package/dist/queries/index.d.ts +1 -1
  107. package/dist/queries/index.js +1 -1
  108. package/dist/queries/isolated.d.ts +3 -1
  109. package/dist/queries/isolated.js +1 -1
  110. package/dist/queries/members.d.ts +1 -1
  111. package/dist/queries/members.js +1 -1
  112. package/dist/queries/methods.d.ts +1 -1
  113. package/dist/queries/methods.js +1 -1
  114. package/dist/queries/outline.d.ts +1 -1
  115. package/dist/queries/outline.js +1 -1
  116. package/dist/queries/passthrough-candidates.d.ts +2 -1
  117. package/dist/queries/passthrough-candidates.js +1 -1
  118. package/dist/queries/redundant-reexports.d.ts +1 -1
  119. package/dist/queries/redundant-reexports.js +1 -1
  120. package/dist/queries/refs.d.ts +4 -2
  121. package/dist/queries/refs.js +1 -1
  122. package/dist/queries/similar-chains.d.ts +1 -1
  123. package/dist/queries/similar-chains.js +1 -1
  124. package/dist/queries/similar-files.d.ts +1 -1
  125. package/dist/queries/similar-files.js +1 -1
  126. package/dist/queries/similar-signatures.d.ts +3 -1
  127. package/dist/queries/similar-signatures.js +1 -1
  128. package/dist/queries/similar.d.ts +4 -1
  129. package/dist/queries/similar.js +1 -1
  130. package/dist/queries/slice.d.ts +2 -1
  131. package/dist/queries/slice.js +1 -1
  132. package/dist/queries/stale-abstractions.d.ts +2 -1
  133. package/dist/queries/stale-abstractions.js +1 -1
  134. package/dist/queries/stats.d.ts +1 -1
  135. package/dist/queries/surface.d.ts +1 -1
  136. package/dist/queries/surface.js +1 -1
  137. package/dist/queries/symbols.d.ts +1 -1
  138. package/dist/queries/symbols.js +1 -1
  139. package/dist/queries/system.d.ts +1 -1
  140. package/dist/queries/system.js +1 -1
  141. package/dist/queries/trace.d.ts +4 -2
  142. package/dist/queries/trace.js +1 -1
  143. package/dist/queries/wrapper-candidates.d.ts +2 -1
  144. package/dist/queries/wrapper-candidates.js +1 -1
  145. package/package.json +1 -1
  146. package/dist/chunk-2AUZ3PLO.js +0 -2
  147. package/dist/chunk-3A2M7AF3.js +0 -4
  148. package/dist/chunk-3EJRPTTB.js +0 -2
  149. package/dist/chunk-3SWWYJPB.js +0 -6
  150. package/dist/chunk-4M4FEWBL.js +0 -7
  151. package/dist/chunk-4Y6KUJDO.js +0 -39
  152. package/dist/chunk-6FLGPRBR.js +0 -5
  153. package/dist/chunk-7EQ4J66C.js +0 -2
  154. package/dist/chunk-ABLXPGAZ.js +0 -2
  155. package/dist/chunk-BG7YU4DJ.js +0 -2
  156. package/dist/chunk-D2R6IIEO.js +0 -2
  157. package/dist/chunk-E47WMJ5F.js +0 -2
  158. package/dist/chunk-EEA3R37V.js +0 -11
  159. package/dist/chunk-FAN2CVZT.js +0 -2
  160. package/dist/chunk-GS55K4WJ.js +0 -85
  161. package/dist/chunk-HADDFTMU.js +0 -2
  162. package/dist/chunk-IARIBTCL.js +0 -2
  163. package/dist/chunk-K6ULLR7M.js +0 -19
  164. package/dist/chunk-KCC3GMCX.js +0 -2
  165. package/dist/chunk-KRVRD6KZ.js +0 -5
  166. package/dist/chunk-LHLXHH43.js +0 -2
  167. package/dist/chunk-M7GBLQG4.js +0 -7
  168. package/dist/chunk-MEVK6R7N.js +0 -2
  169. package/dist/chunk-RUAJV3TN.js +0 -2
  170. package/dist/chunk-S57GUI2T.js +0 -7
  171. package/dist/chunk-SVUVC5VS.js +0 -2
  172. package/dist/chunk-T426XELO.js +0 -12
  173. package/dist/chunk-TX7BHRMT.js +0 -2
  174. package/dist/chunk-X3Z4KZNX.js +0 -2
  175. package/dist/chunk-ZNNCDAYX.js +0 -2
@@ -638,6 +638,9 @@ interface DeadOptions {
638
638
  includeTests?: boolean;
639
639
  skipBarrels?: boolean;
640
640
  includeMembers?: boolean;
641
+ deadCodeOnly?: boolean;
642
+ scanLimit?: number;
643
+ semantic?: boolean;
641
644
  }
642
645
  interface InstallMethod {
643
646
  /** Human-readable label (e.g., "npm", "pip", "go install") */
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { S as ScipDatabase, N as SymbolMatch, Q as SymbolLocation, V as IndexedDefinition, X as ScipSymbol, Y as ScipLocalSymbol, Z as SupportedLanguage, _ as IndexerConfig, $ as ProjectConfig, a0 as WatcherStatus } from './db-DdlToIC-.js';
2
- export { A as AffectedResult, B as BottleneckResult, a as ByKindResult, C as CallGraphResult, a1 as ChangeSurfaceEntry, b as ChangeSurfaceResult, c as CodeResult, d as ComplexityHotspot, e as ComplexityResult, f as ConvergenceResult, g as CouplingResult, h as CycleResult, D as DataflowResult, i as DeadOptions, j as DeadSummary, a2 as DeadSymbolResult, k as DeepChainResult, l as DepResult, a3 as DescriptorSuffix, m as DiffImpactResult, a4 as DocumentPathCandidate, a5 as DriftResult, n as DriftSummary, a6 as EntryRootsConfig, E as ExtractCandidate, F as FanResult, o as FileResult, a7 as HealthAction, H as HealthReport, p as HierarchyNode, q as HotspotResult, I as ImportResult, a8 as IndexerOverrides, a9 as InstallMethod, r as IsolatedResult, M as MemberResult, s as MethodResult, O as OutlineNode, aa as ParsedReExport, ab as ParsedSourceExport, ac as ParsedSourceImport, P as PassthroughCandidate, K as RedundantReexport, R as RefResult, ad as ReferenceSite, ae as ScipDescriptor, af as ScipQueryConfig, ag as SemanticConfig, z as SimilarChainResult, y as SimilarFileResult, L as SimilarSignatureGroup, x as SimilarSymbolResult, J as SliceResult, G as StaleAbstraction, t as StatsResult, w as SurfaceResult, u as SymbolResult, v as SystemResult, T as TraceResult, ah as TypeScriptSemanticConfig, U as UnusedImportResult, ai as WatchConfig, W as WrapperCandidate, aj as createGitignoreFilter } from './db-DdlToIC-.js';
1
+ import { S as ScipDatabase, N as SymbolMatch, Q as SymbolLocation, V as IndexedDefinition, X as ScipSymbol, Y as ScipLocalSymbol, Z as SupportedLanguage, _ as IndexerConfig, $ as ProjectConfig, a0 as WatcherStatus } from './db-Rx8Ho_JF.js';
2
+ export { A as AffectedResult, B as BottleneckResult, a as ByKindResult, C as CallGraphResult, a1 as ChangeSurfaceEntry, b as ChangeSurfaceResult, c as CodeResult, d as ComplexityHotspot, e as ComplexityResult, f as ConvergenceResult, g as CouplingResult, h as CycleResult, D as DataflowResult, i as DeadOptions, j as DeadSummary, a2 as DeadSymbolResult, k as DeepChainResult, l as DepResult, a3 as DescriptorSuffix, m as DiffImpactResult, a4 as DocumentPathCandidate, a5 as DriftResult, n as DriftSummary, a6 as EntryRootsConfig, E as ExtractCandidate, F as FanResult, o as FileResult, a7 as HealthAction, H as HealthReport, p as HierarchyNode, q as HotspotResult, I as ImportResult, a8 as IndexerOverrides, a9 as InstallMethod, r as IsolatedResult, M as MemberResult, s as MethodResult, O as OutlineNode, aa as ParsedReExport, ab as ParsedSourceExport, ac as ParsedSourceImport, P as PassthroughCandidate, K as RedundantReexport, R as RefResult, ad as ReferenceSite, ae as ScipDescriptor, af as ScipQueryConfig, ag as SemanticConfig, z as SimilarChainResult, y as SimilarFileResult, L as SimilarSignatureGroup, x as SimilarSymbolResult, J as SliceResult, G as StaleAbstraction, t as StatsResult, w as SurfaceResult, u as SymbolResult, v as SystemResult, T as TraceResult, ah as TypeScriptSemanticConfig, U as UnusedImportResult, ai as WatchConfig, W as WrapperCandidate, aj as createGitignoreFilter } from './db-Rx8Ho_JF.js';
3
3
  export { stats } from './queries/stats.js';
4
4
  export { files } from './queries/files.js';
5
5
  export { symbols } from './queries/symbols.js';
@@ -133,6 +133,7 @@ declare function buildFileDepGraph(db: ScipDatabase, scope?: string): Map<string
133
133
  */
134
134
  declare function buildCalleeMap(db: ScipDatabase, definitions: ReadonlyArray<SymbolMatch>, opts?: {
135
135
  additive?: boolean;
136
+ semantic?: boolean;
136
137
  }): Map<number, CalleeRow[]>;
137
138
  /**
138
139
  * Bulk caller map: symbolId → set of distinct files that reference the
@@ -147,7 +148,9 @@ declare function buildCalleeMap(db: ScipDatabase, definitions: ReadonlyArray<Sym
147
148
  * defining file are treated as potential self-references and only counted
148
149
  * when they originate from a different document.
149
150
  */
150
- declare function buildCrossFileCallerMap(db: ScipDatabase, definitions?: ReadonlyArray<SymbolLocation>): Map<number, Set<string>>;
151
+ declare function buildCrossFileCallerMap(db: ScipDatabase, definitions?: ReadonlyArray<SymbolLocation>, opts?: {
152
+ semantic?: boolean;
153
+ }): Map<number, Set<string>>;
151
154
 
152
155
  /**
153
156
  * Identifier-attribution module — one owner of "given a textual identifier
@@ -221,6 +224,7 @@ interface ScanSourceReferencesOptions {
221
224
  includeCrossLanguageDispatchNames?: boolean;
222
225
  includeRustAttributeNames?: boolean;
223
226
  identifierResolution?: 'strict' | 'permissive';
227
+ candidateNames?: ReadonlySet<string>;
224
228
  skipPath?: (relativePath: string) => boolean;
225
229
  }
226
230
  declare function scanSourceReferences(db: ScipDatabase, opts: ScanSourceReferencesOptions, visit: (hit: SourceReferenceHit) => void): void;
@@ -246,8 +250,11 @@ declare class ProjectIndex {
246
250
  productionCallableDefinitions(opts?: ProductionCallableDefinitionsOptions): IndexedDefinition[];
247
251
  calleeMap(definitions: ReadonlyArray<SymbolMatch>, opts?: {
248
252
  additive?: boolean;
253
+ semantic?: boolean;
249
254
  }): ReturnType<typeof buildCalleeMap>;
250
- crossFileCallerMap(definitions?: ReadonlyArray<SymbolMatch>): ReturnType<typeof buildCrossFileCallerMap>;
255
+ crossFileCallerMap(definitions?: ReadonlyArray<SymbolMatch>, opts?: {
256
+ semantic?: boolean;
257
+ }): ReturnType<typeof buildCrossFileCallerMap>;
251
258
  sourceFallbackCallerFiles(definitions: ReadonlyArray<IndexedDefinition>): ReturnType<typeof findCallerFiles>;
252
259
  fileDependencyGraph(scope?: string): ReturnType<typeof buildFileDepGraph>;
253
260
  fileKind(relativePath: string): ReturnType<typeof classifyFile>;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import"./chunk-FVH3Y44U.js";import{a as Ai}from"./chunk-ILQSK2KJ.js";import{a as Di}from"./chunk-3EJRPTTB.js";import{a as _i}from"./chunk-RRWPHKZA.js";import{a as Ni}from"./chunk-3A2M7AF3.js";import{a as Ds}from"./chunk-IBWYWAWE.js";import{a as Fi}from"./chunk-M7GBLQG4.js";import{a as cs}from"./chunk-2YA36CXK.js";import{a as us}from"./chunk-JVMXNDRU.js";import{a as Ls}from"./chunk-MEVK6R7N.js";import{a as Ts}from"./chunk-HADDFTMU.js";import{a as is}from"./chunk-2R7OKZE5.js";import{a as $i}from"./chunk-7TGEXAN5.js";import{a as Bi,b as Wi,c as Ui}from"./chunk-4Y6KUJDO.js";import{a as Gi}from"./chunk-BG7YU4DJ.js";import{a as Li}from"./chunk-LHLXHH43.js";import{a as Hi}from"./chunk-R373SHXM.js";import{a as ps,b as fs,c as ms,d as hs}from"./chunk-6XRB6ATD.js";import{a as qi,b as Ji,c as zi,d as Xi}from"./chunk-FYO3FPFH.js";import{a as Ti}from"./chunk-KAM4C6ZD.js";import{a as Rs,b as Is,c as ks,d as Ps}from"./chunk-TX7BHRMT.js";import{a as Ss}from"./chunk-KRVRD6KZ.js";import{a as Oi}from"./chunk-QRYEOK3M.js";import{a as ys}from"./chunk-4M4FEWBL.js";import{a as xs}from"./chunk-FAN2CVZT.js";import{a as os,b as as}from"./chunk-3SWWYJPB.js";import"./chunk-RKTDEIHF.js";import{a as es}from"./chunk-IARIBTCL.js";import{a as bs}from"./chunk-K6ULLR7M.js";import"./chunk-LJ2YWNQF.js";import{a as ls}from"./chunk-D2R6IIEO.js";import"./chunk-2AUZ3PLO.js";import{a as Es}from"./chunk-S57GUI2T.js";import{a as ws}from"./chunk-X3Z4KZNX.js";import{a as Ki,b as Qi}from"./chunk-OCQN6WF4.js";import{a as Yi}from"./chunk-2CC7RA6B.js";import{a as Os}from"./chunk-RUAJV3TN.js";import{a as Vi}from"./chunk-T426XELO.js";import{a as rs}from"./chunk-K345WFTU.js";import{a as ji,b as Mi}from"./chunk-PQTGBYXV.js";import{a as gs}from"./chunk-HTJ5BOYP.js";import{a as Zi}from"./chunk-KCC3GMCX.js";import{a as ts,b as ns}from"./chunk-ZNNCDAYX.js";import{a as ss}from"./chunk-E47WMJ5F.js";import{a as ds}from"./chunk-EEA3R37V.js";import{a as Cs}from"./chunk-KQWFRAQI.js";import"./chunk-55ZJ2FCW.js";import{a as vs}from"./chunk-ABLXPGAZ.js";import{a as rt}from"./chunk-SVUVC5VS.js";import"./chunk-TYRPQE6R.js";import"./chunk-7EQ4J66C.js";import{a as ge,b as de}from"./chunk-WPY46NIL.js";import"./chunk-GS55K4WJ.js";import"./chunk-6FLGPRBR.js";import"./chunk-G47V5V3U.js";import"./chunk-QYWGC7JV.js";import{p as et,q as tt,r as nt}from"./chunk-KYGNCIJ6.js";import it from"better-sqlite3";var H=class{db;config;pathFilter;constructor(t,n){this.config=t,this.pathFilter=n??null,this.db=new it(t.dbPath,{readonly:!0}),this.db.pragma("busy_timeout = 5000")}isIgnored(t){return this.pathFilter?.isIgnored(t)??!1}get localSymbolPredicate(){return`(
1
+ import"./chunk-FVH3Y44U.js";import{a as Vi}from"./chunk-ZO5IFJRM.js";import{a as Li}from"./chunk-SMOUOKAO.js";import{a as Ai}from"./chunk-IX45SWX5.js";import{a as ji}from"./chunk-SF2HYG53.js";import{a as Ls}from"./chunk-LBWLO7NA.js";import{a as Ni}from"./chunk-6UVVA5I4.js";import{a as ls}from"./chunk-3JGBAAP7.js";import{a as cs}from"./chunk-WYX3RU2K.js";import{a as Fs}from"./chunk-TPXWXKL6.js";import{a as Ds}from"./chunk-5MPZ2A7J.js";import{a as ss}from"./chunk-AXHDRSRI.js";import{a as Bi}from"./chunk-WGYJDGBI.js";import{a as Wi,b as Ui,c as Hi}from"./chunk-CLKFDBS6.js";import{a as qi}from"./chunk-WZYA234B.js";import{a as Fi}from"./chunk-CWMWTHV3.js";import{a as Gi}from"./chunk-BAA4EJRX.js";import{a as fs,b as ms,c as hs,d as bs}from"./chunk-I2KUHGMX.js";import{a as Ji,b as zi,c as Xi,d as Ki}from"./chunk-U3GYMGBX.js";import{a as Di}from"./chunk-KAM4C6ZD.js";import{a as Is,b as ks,c as Ps,d as ws}from"./chunk-TYR7QY5G.js";import{a as vs}from"./chunk-W6SRVK2Y.js";import{a as Oi}from"./chunk-QRYEOK3M.js";import{a as xs}from"./chunk-DXO2ECRF.js";import{a as Ss}from"./chunk-GWBRU65E.js";import{a as as,b as us}from"./chunk-VDMRAGBK.js";import"./chunk-RKTDEIHF.js";import{a as ts}from"./chunk-4QWTQ6YV.js";import{a as ys}from"./chunk-TTCUMJ43.js";import"./chunk-LJ2YWNQF.js";import{a as gs}from"./chunk-UZG3QXTG.js";import"./chunk-3F453KPT.js";import{a as Ts}from"./chunk-YCN5XEST.js";import{a as Cs}from"./chunk-4MDCFY3E.js";import{a as Qi,b as Yi}from"./chunk-UIM4WALN.js";import{a as Zi}from"./chunk-GRAEZYYU.js";import{a as Os}from"./chunk-OYRGWW6Z.js";import{a as $i}from"./chunk-PVMRIOM6.js";import{a as is}from"./chunk-Y6ZFXZ7B.js";import{a as _i,b as Mi}from"./chunk-JLFAQ2E2.js";import{a as ds}from"./chunk-I5BB33E6.js";import{a as es}from"./chunk-2OP63JQQ.js";import{a as ns,b as rs}from"./chunk-42BWO2NN.js";import{a as os}from"./chunk-NRAJIFQA.js";import{a as ps}from"./chunk-3PKPUCIJ.js";import{a as Es}from"./chunk-V4WRHJU3.js";import"./chunk-LLDPR3DG.js";import{a as Rs}from"./chunk-SHGPRVWH.js";import{a as rt}from"./chunk-LNUZWWWL.js";import"./chunk-IIKNAXAE.js";import"./chunk-JMASYYSW.js";import{a as ge,b as de}from"./chunk-5IRX5I64.js";import"./chunk-EHEZLULQ.js";import"./chunk-33Z6HQBX.js";import"./chunk-67OMD56K.js";import"./chunk-BT36WY5B.js";import{r as et,s as tt,t as nt}from"./chunk-NLJCXHFU.js";import it from"better-sqlite3";var st=["node_modules",".git","dist","build","out","coverage","target",".next",".nuxt",".cache",".turbo",".scipquery-cache","__pycache__",".venv","venv"],H=class{db;config;pathFilter;constructor(t,n){this.config=t,this.pathFilter=n??null,this.db=new it(t.dbPath,{readonly:!0}),this.db.pragma("busy_timeout = 5000")}isIgnored(t){return this.pathFilter?.isIgnored(t)??!1}get localSymbolPredicate(){return`(
2
2
  EXISTS (
3
3
  SELECT 1
4
4
  FROM defn_enclosing_ranges local_der
@@ -15,8 +15,8 @@ import"./chunk-FVH3Y44U.js";import{a as Ai}from"./chunk-ILQSK2KJ.js";import{a as
15
15
  AND local_m.role = 1
16
16
  ${this.pathExclusionsFor("local_d").trimStart()}
17
17
  )
18
- )`}get pathExclusions(){return this.pathExclusionsFor("d")}get symbolNoise(){return this.symbolNoiseFor("gs")}pathExclusionsFor(...t){return t.flatMap(n=>[`AND ${n}.relative_path NOT LIKE 'node_modules/%'`,`AND ${n}.relative_path NOT LIKE '.git/%'`]).join(`
19
- `)}symbolNoiseFor(t){return`AND ${t}.symbol NOT LIKE '%().(%' AND ${t}.symbol NOT LIKE '%typeLiteral%'`}all(t,...n){return this.db.prepare(t).all(...n)}get(t,...n){return this.db.prepare(t).get(...n)}close(){this.db.close()}};import st from"ignore";import{readFileSync as ot,existsSync as G}from"fs";import{dirname as q,isAbsolute as pe,join as J,relative as at,resolve as ut}from"path";function I(e){let t=st(),n=!1,r=ct(e);for(let i of r)try{let s=ot(i,"utf-8");t.add(s),n=!0}catch{}return n||t.add(lt),{isIgnored:i=>fe(t,e,i),filter:i=>i.filter(s=>!fe(t,e,s))}}function ct(e){let t=[],n=J(e,".gitignore");G(n)&&t.push(n);let r=q(e),i=0;for(;r!==q(r)&&i<5;){let s=J(r,".gitignore");if(G(s)&&t.push(s),G(J(r,".git")))break;r=q(r),i++}return t}var lt=`
18
+ )`}get pathExclusions(){return this.pathExclusionsFor("d")}get symbolNoise(){return this.symbolNoiseFor("gs")}pathExclusionsFor(...t){return t.flatMap(n=>st.flatMap(r=>[`AND ${n}.relative_path NOT LIKE '${r}/%'`,`AND ${n}.relative_path NOT LIKE '%/${r}/%'`])).join(`
19
+ `)}symbolNoiseFor(t){return`AND ${t}.symbol NOT LIKE '%().(%' AND ${t}.symbol NOT LIKE '%typeLiteral%'`}all(t,...n){return this.db.prepare(t).all(...n)}get(t,...n){return this.db.prepare(t).get(...n)}close(){this.db.close()}};import ot from"ignore";import{readFileSync as at,existsSync as G}from"fs";import{dirname as q,isAbsolute as pe,join as J,relative as ut,resolve as ct}from"path";function I(e){let t=ot(),n=!1,r=lt(e);for(let i of r)try{let s=at(i,"utf-8");t.add(s),n=!0}catch{}return n||t.add(gt),{isIgnored:i=>fe(t,e,i),filter:i=>i.filter(s=>!fe(t,e,s))}}function lt(e){let t=[],n=J(e,".gitignore");G(n)&&t.push(n);let r=q(e),i=0;for(;r!==q(r)&&i<5;){let s=J(r,".gitignore");if(G(s)&&t.push(s),G(J(r,".git")))break;r=q(r),i++}return t}var gt=`
20
20
  # Dependencies
21
21
  node_modules/
22
22
  vendor/
@@ -73,14 +73,14 @@ Thumbs.db
73
73
 
74
74
  # Type definitions (often noise in queries)
75
75
  *.d.ts
76
- `;function fe(e,t,n){let r=gt(t,n);if(!r)return!1;try{return e.ignores(r)}catch{return!1}}function gt(e,t){if(!t||t===".")return null;if(!pe(t)&&!t.startsWith(".."))return t.replaceAll("\\","/");let n=pe(t)?t:ut(e,t),r=at(e,n).replaceAll("\\","/");return!r||r==="."||r.startsWith("..")?null:r}import{execFile as kr,execFileSync as Pr}from"child_process";import{closeSync as wr,existsSync as y,mkdirSync as Ue,mkdtempSync as Cr,openSync as Er,readFileSync as Or,renameSync as v,rmSync as R,writeFileSync as He}from"fs";import{cpus as Tr}from"os";import{basename as W,dirname as b,extname as Dr,join as p}from"path";import{execFileSync as k}from"child_process";import{platform as O,arch as dt}from"os";var me=O()==="win32",he="v0.7.0";function E(e){let t=me?"where":"which";try{return k(t,[e],{stdio:"pipe"}),!0}catch{return!1}}function pt(){try{return k(me?"where":"which",["scip"],{stdio:"pipe"}),!0}catch{return!1}}function ft(){try{return k("scip",["--version"],{stdio:"pipe"}).toString().trim()}catch{return null}}function mt(){let e=O(),t=dt(),n,r,i;switch(e){case"darwin":n="darwin",i="tar.gz";break;case"linux":n="linux",i="tar.gz";break;case"win32":n="windows",i="zip";break;default:return null}switch(t){case"arm64":r="arm64";break;case"x64":r="amd64";break;default:return null}let s=`scip-${n}-${r}.${i}`;return{url:`https://github.com/sourcegraph/scip/releases/download/${he}/${s}`,filename:s}}function ht(){let e=mt();console.log("\nThe `scip` CLI is required but not found on PATH.\n"),O()==="darwin"?(console.log("Install via Homebrew:"),console.log(` brew install sourcegraph/scip/scip
76
+ `;function fe(e,t,n){let r=dt(t,n);if(!r)return!1;try{return e.ignores(r)}catch{return!1}}function dt(e,t){if(!t||t===".")return null;if(!pe(t)&&!t.startsWith(".."))return t.replaceAll("\\","/");let n=pe(t)?t:ct(e,t),r=ut(e,n).replaceAll("\\","/");return!r||r==="."||r.startsWith("..")?null:r}import{execFile as Pr,execFileSync as wr}from"child_process";import{closeSync as Cr,existsSync as y,mkdirSync as Ue,mkdtempSync as Er,openSync as Tr,readFileSync as Or,renameSync as v,rmSync as R,writeFileSync as He}from"fs";import{cpus as Dr}from"os";import{basename as W,dirname as b,extname as Lr,join as p}from"path";import{execFileSync as k}from"child_process";import{platform as T,arch as pt}from"os";var me=T()==="win32",he="v0.7.0";function E(e){let t=me?"where":"which";try{return k(t,[e],{stdio:"pipe"}),!0}catch{return!1}}function ft(){try{return k(me?"where":"which",["scip"],{stdio:"pipe"}),!0}catch{return!1}}function mt(){try{return k("scip",["--version"],{stdio:"pipe"}).toString().trim()}catch{return null}}function ht(){let e=T(),t=pt(),n,r,i;switch(e){case"darwin":n="darwin",i="tar.gz";break;case"linux":n="linux",i="tar.gz";break;case"win32":n="windows",i="zip";break;default:return null}switch(t){case"arm64":r="arm64";break;case"x64":r="amd64";break;default:return null}let s=`scip-${n}-${r}.${i}`;return{url:`https://github.com/sourcegraph/scip/releases/download/${he}/${s}`,filename:s}}function bt(){let e=ht();console.log("\nThe `scip` CLI is required but not found on PATH.\n"),T()==="darwin"?(console.log("Install via Homebrew:"),console.log(` brew install sourcegraph/scip/scip
77
77
  `),console.log("Or download manually:")):console.log("Download from:"),console.log(e?` ${e.url}
78
78
  `:` https://github.com/sourcegraph/scip/releases/tag/${he}
79
- `),console.log("After installing, ensure `scip` is on your PATH and run `scip-query reindex`.")}function T(e){if(O()==="darwin"&&E("brew")){e("Installing scip CLI via Homebrew...");try{if(k("brew",["install","sourcegraph/scip/scip"],{stdio:"inherit",timeout:3e5,env:process.env}),E("scip"))return e("Successfully installed scip CLI via Homebrew"),!0}catch(t){let n=t instanceof Error?t.message:String(t);e(`Homebrew install failed: ${n}`)}}if(E("go")){e("Installing scip CLI via go install...");try{if(k("go",["install","github.com/sourcegraph/scip/cmd/scip@latest"],{stdio:"inherit",timeout:3e5,env:process.env}),E("scip"))return e("Successfully installed scip CLI via go install"),!0}catch(t){let n=t instanceof Error?t.message:String(t);e(`go install failed: ${n}`)}}return e("Could not auto-install scip CLI."),e("Install manually from: https://github.com/sourcegraph/scip/releases"),!1}import bt from"better-sqlite3";import{execFileSync as yt}from"child_process";import{existsSync as xt,readdirSync as St,readFileSync as vt}from"fs";import{extname as D,join as be}from"path";function m(e){let t=new Set((e.extensions??ge).map(s=>s.toLowerCase()));if(t.size===0)return{scanned:0,inserted:0,existing:0};if(!xt(e.dbPath))throw new Error(`SCIP SQLite database not found at ${e.dbPath}`);let n=I(e.projectRoot),r=Rt(e.projectRoot,t).filter(s=>!n.isIgnored(s)),i=new bt(e.dbPath);try{let s=kt(i,r),o=i.prepare(`INSERT OR IGNORE INTO documents (language, relative_path, position_encoding, text)
80
- VALUES (?, ?, NULL, ?)`),u=i.transaction(g=>{let l=0;for(let d of g){if(s.has(d))continue;let f=vt(be(e.projectRoot,d),"utf-8"),Ze=o.run(Pt(d),d,f);l+=Number(Ze.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 Rt(e,t){let n=It(e,t);if(n)return n;let r=[],i=s=>{let o=s?be(e,s):e,a;try{a=St(o,{withFileTypes:!0})}catch{return}for(let u of a){if(de.has(u.name))continue;let c=s?`${s}/${u.name}`:u.name;if(u.isDirectory()){i(c);continue}t.has(D(u.name).toLowerCase())&&r.push(c)}};return i(""),r.sort()}function It(e,t){try{return yt("git",["-C",e,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:26214400,stdio:["ignore","pipe","ignore"]}).split(`
81
- `).filter(r=>r&&t.has(D(r).toLowerCase())).sort()}catch{return null}}function kt(e,t){let n=new Set,r=500;for(let i=0;i<t.length;i+=r){let s=t.slice(i,i+r),o=e.prepare(`SELECT relative_path FROM documents WHERE relative_path IN (${s.map(()=>"?").join(",")})`).all(...s);for(let a of o)n.add(a.relative_path)}return n}function Pt(e){return D(e).toLowerCase()===".vue"?"vue":D(e).replace(/^\./,"").toLowerCase()||"source"}import{execFileSync as wt}from"child_process";import{existsSync as Ct,readdirSync as xe}from"fs";import{extname as Se,join as ve}from"path";var Et=new Set([".git",".hg",".svn",".idea",".vscode","node_modules","vendor","dist","build","target","bin","obj",".dart_tool",".gradle",".next",".venv","venv","__pycache__"]),Ot=[{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 L(e){let t=[],n=Tt(e),r=Nt(e);for(let i of Ot){if(Dt(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")&&ye(t,"javascript"),t.includes("cpp")&&!r.has(".c")&&ye(t,"c"),t}function Tt(e){try{return xe(e)}catch{return[]}}function Dt(e,t){return t?.length?t.some(n=>Ct(ve(e,n))):!1}function Lt(e,t){return t?.length?e.some(n=>t.some(r=>Ft(n,r))):!1}function Ft(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 Nt(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 s;try{s=xe(i,{withFileTypes:!0})}catch{continue}for(let o of s){if(o.name.startsWith(".")&&!o.name.endsWith("proj")&&!o.name.endsWith("sln")&&o.isDirectory())continue;let a=ve(i,o.name);if(o.isDirectory()){Et.has(o.name)||r.push(a);continue}let u=Se(o.name).toLowerCase();u&&n.add(u)}}return n}function jt(e){try{let t=wt("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(`
82
- `)){if(!r)continue;let i=Se(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 ye(e,t){let n=e.indexOf(t);n!==-1&&e.splice(n,1)}import{existsSync as Re,readdirSync as _t}from"fs";import{join as z}from"path";var X={typescript:{language:"typescript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,pnpmWorkspaces:t,indexerBinary:n})=>{let r=["index","--infer-tsconfig","--output",e,"--no-progress-bar"];return t&&r.splice(1,0,"--pnpm-workspaces"),{binary:n,args:r}},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",Ie(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",Ie(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=z(e,"vendor","bin","scip-php"),r=z(e,"vendor","davidrjenni","scip-php","bin","scip-php");return{binary:"php",args:["-d","error_reporting=E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED",Re(r)?r:Re(n)?n:t]}},defaultOutputPath:"index.scip",markerFiles:["composer.json"],installMethods:[],installUrl:"https://github.com/davidrjenni/scip-php/releases"}};function F(e){return X[e]}function Ie(e,t){let n;try{n=_t(e)}catch{return null}for(let r of n)if(t.some(i=>r.endsWith(i)))return z(e,r);return null}import{readFileSync as At,writeFileSync as Vt}from"fs";import{create as K}from"@bufbuild/protobuf";import{deserializeSCIP as $t,serializeSCIP as Bt,DocumentSchema as Wt,IndexSchema as Ut,SymbolInformationSchema as Ht}from"@c4312/scip";function Q(e){if(e.length===0)throw new Error("Cannot merge zero SCIP indexes");if(e.length===1)return e[0];let t=Gt(e),n=qt(e.flatMap(i=>i.documents??[])),r=ke(e.flatMap(i=>i.externalSymbols??[]));return K(Ut,{metadata:t,documents:n,externalSymbols:r})}function N(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let n=e.map(i=>$t(At(i))),r=Q(n);return Vt(t,Buffer.from(Bt(r))),{documentCount:r.documents.length,externalSymbolCount:r.externalSymbols.length,inputCount:e.length}}function Gt(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,K(Wt,{language:r.language||n.language,relativePath:r.relativePath||n.relativePath,occurrences:[...r.occurrences,...n.occurrences],symbols:ke([...r.symbols,...n.symbols]),text:zt(r.text,n.text),positionEncoding:r.positionEncoding||n.positionEncoding}))}return[...t.values()]}function ke(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,K(Ht,{symbol:r.symbol,documentation:Xt([...r.documentation,...n.documentation]),relationships:Jt([...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 Jt(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 Xt(e){return[...new Set(e)]}import{execFileSync as Kt}from"child_process";import{createHash as Qt}from"crypto";import{readdirSync as Yt,readFileSync as Zt}from"fs";import{join as Pe}from"path";function en(e){return(tn(e)??nn(e)).filter(t=>t&&!we(t)).sort()}function j(e){return en(e).map(t=>{let n=Pe(e,t);try{let r=Zt(n);return{path:t,size:r.byteLength,hash:Qt("sha256").update(r).digest("hex")}}catch{return{path:t,size:-1,hash:"unreadable"}}})}function tn(e){try{return Kt("git",["-C",e,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:50*1024*1024,stdio:["ignore","pipe","ignore"]}).split(`
83
- `).filter(Boolean)}catch{return null}}function nn(e){let t=[],n=[""];for(;n.length>0;){let r=n.pop(),i=r?Pe(e,r):e,s;try{s=Yt(i,{withFileTypes:!0})}catch{continue}for(let o of s){let a=r?`${r}/${o.name}`:o.name;if(o.isDirectory()){we(a)||n.push(a);continue}t.push(a)}}return t}function we(e){return e.split("/").some(n=>rn.has(n))||e.endsWith(".db")||e.endsWith(".db-wal")||e.endsWith(".db-shm")||e.endsWith(".scip")}var rn=new Set([".git","node_modules",".scipquery-cache",".stryker-tmp","dist","build","coverage",".next",".nuxt","target"]);import{readFileSync as sn,writeFileSync as on}from"fs";import{create as Ce}from"@bufbuild/protobuf";import{deserializeSCIP as an,DocumentSchema as un,IndexSchema as cn,serializeSCIP as ln,SymbolRole as gn}from"@c4312/scip";function Ee(e){let t;try{t=an(sn(e))}catch{return{removedDefinitionOccurrences:0,touchedDocuments:0}}let n=dn(t);return n.removedDefinitionOccurrences>0&&on(e,Buffer.from(ln(n.index))),{removedDefinitionOccurrences:n.removedDefinitionOccurrences,touchedDocuments:n.touchedDocuments}}function dn(e){let t=new Set;for(let s of e.documents)for(let o of s.symbols)o.symbol&&t.add(o.symbol);for(let s of e.externalSymbols)s.symbol&&t.add(s.symbol);let n=0,r=0,i=[];for(let s of e.documents){let o=s.occurrences.filter(a=>(a.symbolRoles&gn.Definition)===0||t.has(a.symbol)?!0:(n+=1,!1));if(o.length===s.occurrences.length){i.push(s);continue}r+=1,i.push(Ce(un,{language:s.language,relativePath:s.relativePath,occurrences:o,symbols:s.symbols,text:s.text,positionEncoding:s.positionEncoding}))}return{index:n===0?e:Ce(cn,{metadata:e.metadata,documents:i,externalSymbols:e.externalSymbols}),removedDefinitionOccurrences:n,touchedDocuments:r}}import{execFileSync as _}from"child_process";import{existsSync as Y,readFileSync as pn}from"fs";import{createRequire as fn}from"module";import{platform as Te}from"os";import{dirname as Oe,join as M}from"path";var mn=fn(import.meta.url),hn=Te()==="win32";function h(e){let t=hn?"where":"which";try{return _(t,[e],{stdio:"pipe"}),!0}catch{return!1}}function Z(e){return[e.indexerBinary,...e.binaryAliases??[]]}function A(e){let t=Z(e);return t.length===1?t[0]:t.join(" or ")}function P(e){for(let t of Z(e))if(h(t))return t;return yn(e)}function V(e){return P(e)!==null||bn(e)}function bn(e){return De(e)!==null}function yn(e){let t=De(e);if(!t)return null;let r=JSON.parse(pn(t,"utf8")).bin;if(!r)return null;if(typeof r=="string")return M(Oe(t),r);for(let i of Z(e)){let s=r[i];if(s)return M(Oe(t),s)}return null}function De(e){if(!e.bundledNpmPackage)return null;try{return mn.resolve(`${e.bundledNpmPackage}/package.json`)}catch{return null}}function ee(e,t){for(let n of e.projectLocalBinaries??[]){let r=M(t,n);if(Y(r))return r}return null}function te(e,t=process.env,n=e.indexerBinary){if(e.indexerBinary!=="scip-dotnet"||Le(n,t))return t;let r=xn(n,t);return r?{...t,DOTNET_ROOT:r}:t}function $(e,t){let n=e.installMethods,r=A(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(h(i.prerequisite)){t(`Installing ${r} via ${i.label}...`);try{_(i.binary,i.args,{stdio:"inherit",timeout:3e5,env:process.env});let s=P(e);if(s){let o=s===e.indexerBinary?"":` (using ${s})`;return t(`Successfully installed ${r} via ${i.label}${o}`),!0}t(`${i.label} command completed but ${r} was not found on PATH`)}catch(s){let o=s instanceof Error?s.message:String(s);t(`${i.label} install failed: ${o}`)}}return t(`Could not auto-install ${r}.`),e.installUrl&&t(`Install manually from: ${e.installUrl}`),!1}function xn(e,t){for(let n of Sn(t))if(Le(e,{...t,DOTNET_ROOT:n}))return n;return null}function Sn(e){let t=[],n=e.DOTNET_ROOT;if(n&&Y(n)&&t.push(n),Te()==="darwin"&&h("brew"))try{let r=_("brew",["--prefix","dotnet@9"],{stdio:"pipe",env:e}).toString().trim(),i=M(r,"libexec");Y(i)&&!t.includes(i)&&t.push(i)}catch{}return t}function Le(e,t){try{return _(e,["--version"],{stdio:"pipe",env:t}),!0}catch{return!1}}import vn from"better-sqlite3";import{createRequire as Rn}from"module";import{existsSync as Ne,mkdtempSync as In,readFileSync as w,rmSync as kn,statSync as Pn,writeFileSync as wn}from"fs";import{cpus as Cn,tmpdir as En}from"os";import{dirname as re,extname as On,join as S,relative as Tn,resolve as je}from"path";import{pathToFileURL as Dn}from"url";import{Worker as Ln}from"worker_threads";function Me(e){m({projectRoot:e.projectRoot,dbPath:e.dbPath});let t=je(e.projectRoot,e.tsconfig);if(!Ne(t))throw new Error(`Vue tsconfig not found at ${t}`);let n=new vn(e.dbPath);try{let r=er(n,e.projectRoot),i=S(re(e.dbPath),"augment-vue-meta.json"),s=Fe(n,e.projectRoot,e.tsconfig),o=Fn(i,s,e.onStatus);if(o)return o;let a=cr(n,e.projectRoot,r),u=Nn(n,e,t,r,a),c=pr(u.occurrences),g=jn(n,e,r,a,c);e.onStatus?.(`Resolved ${c.length} Vue references with Volar; inserted ${g} mentions.`);let l=Mn(r,c,g,u,a);return An(i,Fe(n,e.projectRoot,e.tsconfig),l),l}finally{n.close()}}function Fn(e,t,n){let r=_n(e,t);return r&&n?.(`Vue references unchanged; reused ${r.resolvedReferences} cached resolved references.`),r}function Nn(e,t,n,r,i){if(qn(r))return Jn({projectRoot:t.projectRoot,dbPath:t.dbPath,tsconfig:t.tsconfig,vueFiles:r});let s=xr(),o=tr(t.projectRoot,n);return Vn({projectRoot:t.projectRoot,vueFiles:o.fileNames.filter(a=>a.endsWith(".vue")),context:o,symbolLookup:or(e,t.projectRoot,s),vueSymbolLookup:i,sourceCache:s})}function jn(e,t,n,r,i){return lr(e,t.projectRoot,n,r,i)}function Mn(e,t,n,r,i){return{vueFiles:e.length,resolvedReferences:t.length,insertedMentions:n,skippedReferences:r.skippedReferences,syntheticSymbols:i.syntheticSymbols}}function _n(e,t){try{let n=JSON.parse(w(e,"utf-8"));return JSON.stringify(n.fingerprint)===JSON.stringify(t)?n.result:null}catch{return null}}function An(e,t,n){wn(e,JSON.stringify({updatedAt:new Date().toISOString(),fingerprint:t,result:n},null,2)+`
79
+ `),console.log("After installing, ensure `scip` is on your PATH and run `scip-query reindex`.")}function O(e){if(T()==="darwin"&&E("brew")){e("Installing scip CLI via Homebrew...");try{if(k("brew",["install","sourcegraph/scip/scip"],{stdio:"inherit",timeout:3e5,env:process.env}),E("scip"))return e("Successfully installed scip CLI via Homebrew"),!0}catch(t){let n=t instanceof Error?t.message:String(t);e(`Homebrew install failed: ${n}`)}}if(E("go")){e("Installing scip CLI via go install...");try{if(k("go",["install","github.com/sourcegraph/scip/cmd/scip@latest"],{stdio:"inherit",timeout:3e5,env:process.env}),E("scip"))return e("Successfully installed scip CLI via go install"),!0}catch(t){let n=t instanceof Error?t.message:String(t);e(`go install failed: ${n}`)}}return e("Could not auto-install scip CLI."),e("Install manually from: https://github.com/sourcegraph/scip/releases"),!1}import yt from"better-sqlite3";import{execFileSync as xt}from"child_process";import{existsSync as St,readdirSync as vt,readFileSync as Rt}from"fs";import{extname as D,join as be}from"path";function m(e){let t=new Set((e.extensions??ge).map(s=>s.toLowerCase()));if(t.size===0)return{scanned:0,inserted:0,existing:0};if(!St(e.dbPath))throw new Error(`SCIP SQLite database not found at ${e.dbPath}`);let n=I(e.projectRoot),r=It(e.projectRoot,t).filter(s=>!n.isIgnored(s)),i=new yt(e.dbPath);try{let s=Pt(i,r),o=i.prepare(`INSERT OR IGNORE INTO documents (language, relative_path, position_encoding, text)
80
+ VALUES (?, ?, NULL, ?)`),u=i.transaction(g=>{let l=0;for(let d of g){if(s.has(d))continue;let f=Rt(be(e.projectRoot,d),"utf-8"),Ze=o.run(wt(d),d,f);l+=Number(Ze.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 It(e,t){let n=kt(e,t);if(n)return n;let r=[],i=s=>{let o=s?be(e,s):e,a;try{a=vt(o,{withFileTypes:!0})}catch{return}for(let u of a){if(de.has(u.name))continue;let c=s?`${s}/${u.name}`:u.name;if(u.isDirectory()){i(c);continue}t.has(D(u.name).toLowerCase())&&r.push(c)}};return i(""),r.sort()}function kt(e,t){try{return xt("git",["-C",e,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:26214400,stdio:["ignore","pipe","ignore"]}).split(`
81
+ `).filter(r=>r&&t.has(D(r).toLowerCase())).sort()}catch{return null}}function Pt(e,t){let n=new Set,r=500;for(let i=0;i<t.length;i+=r){let s=t.slice(i,i+r),o=e.prepare(`SELECT relative_path FROM documents WHERE relative_path IN (${s.map(()=>"?").join(",")})`).all(...s);for(let a of o)n.add(a.relative_path)}return n}function wt(e){return D(e).toLowerCase()===".vue"?"vue":D(e).replace(/^\./,"").toLowerCase()||"source"}import{execFileSync as Ct}from"child_process";import{existsSync as Et,readdirSync as xe}from"fs";import{extname as Se,join as ve}from"path";var Tt=new Set([".git",".hg",".svn",".idea",".vscode","node_modules","vendor","dist","build","target","bin","obj",".dart_tool",".gradle",".next",".venv","venv","__pycache__"]),Ot=[{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 L(e){let t=[],n=Dt(e),r=jt(e);for(let i of Ot){if(Lt(e,i.files)){t.push(i.language);continue}if(Ft(n,i.globs)){t.push(i.language);continue}Mt(r,i.extensions)&&t.push(i.language)}return t.includes("typescript")&&ye(t,"javascript"),t.includes("cpp")&&!r.has(".c")&&ye(t,"c"),t}function Dt(e){try{return xe(e)}catch{return[]}}function Lt(e,t){return t?.length?t.some(n=>Et(ve(e,n))):!1}function Ft(e,t){return t?.length?e.some(n=>t.some(r=>Nt(n,r))):!1}function Nt(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 jt(e){let t=_t(e);if(t)return t;let n=new Set,r=[e];for(;r.length>0;){let i=r.pop();if(!i)continue;let s;try{s=xe(i,{withFileTypes:!0})}catch{continue}for(let o of s){if(o.name.startsWith(".")&&!o.name.endsWith("proj")&&!o.name.endsWith("sln")&&o.isDirectory())continue;let a=ve(i,o.name);if(o.isDirectory()){Tt.has(o.name)||r.push(a);continue}let u=Se(o.name).toLowerCase();u&&n.add(u)}}return n}function _t(e){try{let t=Ct("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(`
82
+ `)){if(!r)continue;let i=Se(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 ye(e,t){let n=e.indexOf(t);n!==-1&&e.splice(n,1)}import{existsSync as Re,readdirSync as At}from"fs";import{join as z}from"path";var X={typescript:{language:"typescript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,pnpmWorkspaces:t,indexerBinary:n})=>{let r=["index","--infer-tsconfig","--output",e,"--no-progress-bar"];return t&&r.splice(1,0,"--pnpm-workspaces"),{binary:n,args:r}},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",Ie(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",Ie(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=z(e,"vendor","bin","scip-php"),r=z(e,"vendor","davidrjenni","scip-php","bin","scip-php");return{binary:"php",args:["-d","error_reporting=E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED",Re(r)?r:Re(n)?n:t]}},defaultOutputPath:"index.scip",markerFiles:["composer.json"],installMethods:[],installUrl:"https://github.com/davidrjenni/scip-php/releases"}};function F(e){return X[e]}function Ie(e,t){let n;try{n=At(e)}catch{return null}for(let r of n)if(t.some(i=>r.endsWith(i)))return z(e,r);return null}import{readFileSync as Vt,writeFileSync as $t}from"fs";import{create as K}from"@bufbuild/protobuf";import{deserializeSCIP as Bt,serializeSCIP as Wt,DocumentSchema as Ut,IndexSchema as Ht,SymbolInformationSchema as Gt}from"@c4312/scip";function Q(e){if(e.length===0)throw new Error("Cannot merge zero SCIP indexes");if(e.length===1)return e[0];let t=qt(e),n=Jt(e.flatMap(i=>i.documents??[])),r=ke(e.flatMap(i=>i.externalSymbols??[]));return K(Ht,{metadata:t,documents:n,externalSymbols:r})}function N(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let n=e.map(i=>Bt(Vt(i))),r=Q(n);return $t(t,Buffer.from(Wt(r))),{documentCount:r.documents.length,externalSymbolCount:r.externalSymbols.length,inputCount:e.length}}function qt(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 Jt(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,K(Ut,{language:r.language||n.language,relativePath:r.relativePath||n.relativePath,occurrences:[...r.occurrences,...n.occurrences],symbols:ke([...r.symbols,...n.symbols]),text:Xt(r.text,n.text),positionEncoding:r.positionEncoding||n.positionEncoding}))}return[...t.values()]}function ke(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,K(Gt,{symbol:r.symbol,documentation:Kt([...r.documentation,...n.documentation]),relationships:zt([...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 zt(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 Xt(e,t){return e?t?e.length>=t.length?e:t:e:t}function Kt(e){return[...new Set(e)]}import{execFileSync as Qt}from"child_process";import{createHash as Yt}from"crypto";import{readdirSync as Zt,readFileSync as en}from"fs";import{join as Pe}from"path";function tn(e){return(nn(e)??rn(e)).filter(t=>t&&!we(t)).sort()}function j(e){return tn(e).map(t=>{let n=Pe(e,t);try{let r=en(n);return{path:t,size:r.byteLength,hash:Yt("sha256").update(r).digest("hex")}}catch{return{path:t,size:-1,hash:"unreadable"}}})}function nn(e){try{return Qt("git",["-C",e,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:50*1024*1024,stdio:["ignore","pipe","ignore"]}).split(`
83
+ `).filter(Boolean)}catch{return null}}function rn(e){let t=[],n=[""];for(;n.length>0;){let r=n.pop(),i=r?Pe(e,r):e,s;try{s=Zt(i,{withFileTypes:!0})}catch{continue}for(let o of s){let a=r?`${r}/${o.name}`:o.name;if(o.isDirectory()){we(a)||n.push(a);continue}t.push(a)}}return t}function we(e){return e.split("/").some(n=>sn.has(n))||e.endsWith(".db")||e.endsWith(".db-wal")||e.endsWith(".db-shm")||e.endsWith(".scip")}var sn=new Set([".git","node_modules",".scipquery-cache",".stryker-tmp","dist","build","coverage",".next",".nuxt","target"]);import{readFileSync as on,writeFileSync as an}from"fs";import{create as Ce}from"@bufbuild/protobuf";import{deserializeSCIP as un,DocumentSchema as cn,IndexSchema as ln,serializeSCIP as gn,SymbolRole as dn}from"@c4312/scip";function Ee(e){let t;try{t=un(on(e))}catch{return{removedDefinitionOccurrences:0,touchedDocuments:0}}let n=pn(t);return n.removedDefinitionOccurrences>0&&an(e,Buffer.from(gn(n.index))),{removedDefinitionOccurrences:n.removedDefinitionOccurrences,touchedDocuments:n.touchedDocuments}}function pn(e){let t=new Set;for(let s of e.documents)for(let o of s.symbols)o.symbol&&t.add(o.symbol);for(let s of e.externalSymbols)s.symbol&&t.add(s.symbol);let n=0,r=0,i=[];for(let s of e.documents){let o=s.occurrences.filter(a=>(a.symbolRoles&dn.Definition)===0||t.has(a.symbol)?!0:(n+=1,!1));if(o.length===s.occurrences.length){i.push(s);continue}r+=1,i.push(Ce(cn,{language:s.language,relativePath:s.relativePath,occurrences:o,symbols:s.symbols,text:s.text,positionEncoding:s.positionEncoding}))}return{index:n===0?e:Ce(ln,{metadata:e.metadata,documents:i,externalSymbols:e.externalSymbols}),removedDefinitionOccurrences:n,touchedDocuments:r}}import{execFileSync as M}from"child_process";import{existsSync as Y,readFileSync as fn}from"fs";import{createRequire as mn}from"module";import{platform as Oe}from"os";import{dirname as Te,join as _}from"path";var hn=mn(import.meta.url),bn=Oe()==="win32";function h(e){let t=bn?"where":"which";try{return M(t,[e],{stdio:"pipe"}),!0}catch{return!1}}function Z(e){return[e.indexerBinary,...e.binaryAliases??[]]}function A(e){let t=Z(e);return t.length===1?t[0]:t.join(" or ")}function P(e){for(let t of Z(e))if(h(t))return t;return xn(e)}function V(e){return P(e)!==null||yn(e)}function yn(e){return De(e)!==null}function xn(e){let t=De(e);if(!t)return null;let r=JSON.parse(fn(t,"utf8")).bin;if(!r)return null;if(typeof r=="string")return _(Te(t),r);for(let i of Z(e)){let s=r[i];if(s)return _(Te(t),s)}return null}function De(e){if(!e.bundledNpmPackage)return null;try{return hn.resolve(`${e.bundledNpmPackage}/package.json`)}catch{return null}}function ee(e,t){for(let n of e.projectLocalBinaries??[]){let r=_(t,n);if(Y(r))return r}return null}function te(e,t=process.env,n=e.indexerBinary){if(e.indexerBinary!=="scip-dotnet"||Le(n,t))return t;let r=Sn(n,t);return r?{...t,DOTNET_ROOT:r}:t}function $(e,t){let n=e.installMethods,r=A(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(h(i.prerequisite)){t(`Installing ${r} via ${i.label}...`);try{M(i.binary,i.args,{stdio:"inherit",timeout:3e5,env:process.env});let s=P(e);if(s){let o=s===e.indexerBinary?"":` (using ${s})`;return t(`Successfully installed ${r} via ${i.label}${o}`),!0}t(`${i.label} command completed but ${r} was not found on PATH`)}catch(s){let o=s instanceof Error?s.message:String(s);t(`${i.label} install failed: ${o}`)}}return t(`Could not auto-install ${r}.`),e.installUrl&&t(`Install manually from: ${e.installUrl}`),!1}function Sn(e,t){for(let n of vn(t))if(Le(e,{...t,DOTNET_ROOT:n}))return n;return null}function vn(e){let t=[],n=e.DOTNET_ROOT;if(n&&Y(n)&&t.push(n),Oe()==="darwin"&&h("brew"))try{let r=M("brew",["--prefix","dotnet@9"],{stdio:"pipe",env:e}).toString().trim(),i=_(r,"libexec");Y(i)&&!t.includes(i)&&t.push(i)}catch{}return t}function Le(e,t){try{return M(e,["--version"],{stdio:"pipe",env:t}),!0}catch{return!1}}import Rn from"better-sqlite3";import{createRequire as In}from"module";import{existsSync as Ne,mkdtempSync as kn,readFileSync as w,rmSync as Pn,statSync as wn,writeFileSync as Cn}from"fs";import{cpus as En,tmpdir as Tn}from"os";import{dirname as re,extname as On,join as S,relative as Dn,resolve as je}from"path";import{pathToFileURL as Ln}from"url";import{Worker as Fn}from"worker_threads";function _e(e){m({projectRoot:e.projectRoot,dbPath:e.dbPath});let t=je(e.projectRoot,e.tsconfig);if(!Ne(t))throw new Error(`Vue tsconfig not found at ${t}`);let n=new Rn(e.dbPath);try{let r=tr(n,e.projectRoot),i=S(re(e.dbPath),"augment-vue-meta.json"),s=Fe(n,e.projectRoot,e.tsconfig),o=Nn(i,s,e.onStatus);if(o)return o;let a=lr(n,e.projectRoot,r),u=jn(n,e,t,r,a),c=fr(u.occurrences),g=_n(n,e,r,a,c);e.onStatus?.(`Resolved ${c.length} Vue references with Volar; inserted ${g} mentions.`);let l=Mn(r,c,g,u,a);return Vn(i,Fe(n,e.projectRoot,e.tsconfig),l),l}finally{n.close()}}function Nn(e,t,n){let r=An(e,t);return r&&n?.(`Vue references unchanged; reused ${r.resolvedReferences} cached resolved references.`),r}function jn(e,t,n,r,i){if(Jn(r))return zn({projectRoot:t.projectRoot,dbPath:t.dbPath,tsconfig:t.tsconfig,vueFiles:r});let s=Sr(),o=nr(t.projectRoot,n);return $n({projectRoot:t.projectRoot,vueFiles:o.fileNames.filter(a=>a.endsWith(".vue")),context:o,symbolLookup:ar(e,t.projectRoot,s),vueSymbolLookup:i,sourceCache:s})}function _n(e,t,n,r,i){return gr(e,t.projectRoot,n,r,i)}function Mn(e,t,n,r,i){return{vueFiles:e.length,resolvedReferences:t.length,insertedMentions:n,skippedReferences:r.skippedReferences,syntheticSymbols:i.syntheticSymbols}}function An(e,t){try{let n=JSON.parse(w(e,"utf-8"));return JSON.stringify(n.fingerprint)===JSON.stringify(t)?n.result:null}catch{return null}}function Vn(e,t,n){Cn(e,JSON.stringify({updatedAt:new Date().toISOString(),fingerprint:t,result:n},null,2)+`
84
84
  `)}function Fe(e,t,n){let r=e.prepare(`
85
85
  SELECT
86
86
  (SELECT COUNT(*) FROM documents) AS documents,
@@ -90,7 +90,7 @@ Thumbs.db
90
90
  (SELECT COUNT(*) FROM defn_enclosing_ranges) AS ranges,
91
91
  (SELECT MAX(id) FROM chunks) AS maxChunkId,
92
92
  (SELECT MAX(id) FROM global_symbols) AS maxSymbolId
93
- `).get();return{version:2,tsconfig:n,files:j(t),db:r}}function Vn(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 s=$n(e,i);t.push(...s.occurrences),n+=s.skippedReferences}return{occurrences:t,skippedReferences:n}}function $n(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.sourceCache(t.fileName);if(!i)return{occurrences:[],skippedReferences:t.countFileSkip?1:0};let s=e.context.language.maps.get(r,n),o=C(e.projectRoot,t.fileName),a=[...mr(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:Un(a),processedStarts:new Set};return Bn({...e,fileName:t.fileName,sourceInfo:i,sourceFile:o,map:s,tokenContext:u})}function Bn(e){let t=[],n=0;for(let r of e.tokenContext.tokens){if(e.tokenContext.processedStarts.has(r.start))continue;let i=hr(e.map,r.start);if(i===null)continue;let o=(e.context.languageService.getDefinitionAtPosition(e.fileName,i+1)??[]).find(u=>!br(e.projectRoot,u.fileName));if(!o){n++;continue}let a=dr(o,e.symbolLookup,e.vueSymbolLookup,e.context,e.projectRoot);if(a===null){n++;continue}_e(t,e.sourceInfo,e.sourceFile,r,a),e.tokenContext.processedStarts.add(r.start),Wn(t,e,r,i,a)}return{occurrences:t,skippedReferences:n}}function Wn(e,t,n,r,i){if(!((t.tokenContext.tokenTextCounts.get(n.text)??0)<=1))for(let s of Hn(t.context.languageService,t.fileName,r+1,t.map,n,t.tokenContext.tokenByStart)){if(t.tokenContext.processedStarts.has(s))continue;let o=t.tokenContext.tokenByStart.get(s);o&&(_e(e,t.sourceInfo,t.sourceFile,o,i),t.tokenContext.processedStarts.add(s))}}function _e(e,t,n,r,i){let s=We(t,r.start);e.push({sourceFile:n,sourceLine:s.line,sourceStartChar:s.character,sourceEndChar:s.character+r.text.length,symbolId:i})}function Un(e){let t=new Map;for(let n of e)t.set(n.text,(t.get(n.text)??0)+1);return t}function Hn(e,t,n,r,i,s){let o=e.getDocumentHighlights?.(t,n,[t])??[],a=[];for(let u of o)if(u.fileName===t)for(let c of u.highlightSpans){let g=Gn(r,c.textSpan.start,s,i.text);g!==null&&a.push(g)}return a}function Gn(e,t,n,r){let i=n.get(t);if(i?.text===r)return i.start;let s=Be(e,t);if(s===null)return null;let o=n.get(s);return o?.text===r?o.start:null}function qn(e){return e.length>=8&&Ae(e.length)>1}function Jn(e){let t=Ae(e.vueFiles.length),n=Xn(e.vueFiles),r=Qn(n,t),i=new URL("./augment-vue-worker.js",import.meta.url),s=In(S(En(),"scip-query-vue-workers-")),o=new SharedArrayBuffer(4),a=new Int32Array(o),u=zn(),c=Date.now();try{for(let l=0;l<r.length;l++)new Ln(i,{workerData:{projectRoot:e.projectRoot,dbPath:e.dbPath,tsconfig:e.tsconfig,tasks:r[l],resultPath:S(s,`${l}.json`),sharedBuffer:o}});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,d)=>{let f=JSON.parse(w(S(s,`${d}.json`),"utf-8"));if(!f.ok)throw new Error(`Vue reference worker failed: ${f.error}`);return f.result});return{occurrences:g.flatMap(l=>l.occurrences),skippedReferences:g.reduce((l,d)=>l+d.skippedReferences,0)}}finally{kn(s,{recursive:!0,force:!0})}}function Ae(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,Cn().length-1));return Math.max(1,Math.min(e,n))}function zn(){let e=Number(process.env.SCIP_QUERY_AUGMENT_VUE_WORKER_TIMEOUT_MS??0);return Number.isFinite(e)&&e>0?e:3e5}function Xn(e){let t=Kn(),n=[];for(let r of e){let i=Ve(r),s=Math.max(1,Math.ceil(i/t));for(let o=0;o<s;o++)n.push({fileName:r,startOffset:Math.floor(i*o/s),endOffset:o===s-1?Number.POSITIVE_INFINITY:Math.floor(i*(o+1)/s),countFileSkip:o===0})}return n}function Kn(){return Number.POSITIVE_INFINITY}function Qn(e,t){let n=Array.from({length:t},()=>({tasks:[],weight:0})),r=e.map(i=>({task:i,weight:Yn(i)})).sort((i,s)=>s.weight-i.weight);for(let i of r){let s=n.reduce((o,a)=>a.weight<o.weight?a:o);s.tasks.push(i.task),s.weight+=i.weight}return n.map(i=>i.tasks).filter(i=>i.length>0)}function Yn(e){return Number.isFinite(e.endOffset)?Math.max(1,e.endOffset-e.startOffset):Math.max(1,Ve(e.fileName)-e.startOffset)}function Ve(e){try{return Pn(e).size}catch{return 1}}function Zn(e){e.transaction(()=>{e.prepare(`
93
+ `).get();return{version:2,tsconfig:n,files:j(t),db:r}}function $n(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 s=Bn(e,i);t.push(...s.occurrences),n+=s.skippedReferences}return{occurrences:t,skippedReferences:n}}function Bn(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.sourceCache(t.fileName);if(!i)return{occurrences:[],skippedReferences:t.countFileSkip?1:0};let s=e.context.language.maps.get(r,n),o=C(e.projectRoot,t.fileName),a=[...hr(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:Hn(a),processedStarts:new Set};return Wn({...e,fileName:t.fileName,sourceInfo:i,sourceFile:o,map:s,tokenContext:u})}function Wn(e){let t=[],n=0;for(let r of e.tokenContext.tokens){if(e.tokenContext.processedStarts.has(r.start))continue;let i=br(e.map,r.start);if(i===null)continue;let o=(e.context.languageService.getDefinitionAtPosition(e.fileName,i+1)??[]).find(u=>!yr(e.projectRoot,u.fileName));if(!o){n++;continue}let a=pr(o,e.symbolLookup,e.vueSymbolLookup,e.context,e.projectRoot);if(a===null){n++;continue}Me(t,e.sourceInfo,e.sourceFile,r,a),e.tokenContext.processedStarts.add(r.start),Un(t,e,r,i,a)}return{occurrences:t,skippedReferences:n}}function Un(e,t,n,r,i){if(!((t.tokenContext.tokenTextCounts.get(n.text)??0)<=1))for(let s of Gn(t.context.languageService,t.fileName,r+1,t.map,n,t.tokenContext.tokenByStart)){if(t.tokenContext.processedStarts.has(s))continue;let o=t.tokenContext.tokenByStart.get(s);o&&(Me(e,t.sourceInfo,t.sourceFile,o,i),t.tokenContext.processedStarts.add(s))}}function Me(e,t,n,r,i){let s=We(t,r.start);e.push({sourceFile:n,sourceLine:s.line,sourceStartChar:s.character,sourceEndChar:s.character+r.text.length,symbolId:i})}function Hn(e){let t=new Map;for(let n of e)t.set(n.text,(t.get(n.text)??0)+1);return t}function Gn(e,t,n,r,i,s){let o=e.getDocumentHighlights?.(t,n,[t])??[],a=[];for(let u of o)if(u.fileName===t)for(let c of u.highlightSpans){let g=qn(r,c.textSpan.start,s,i.text);g!==null&&a.push(g)}return a}function qn(e,t,n,r){let i=n.get(t);if(i?.text===r)return i.start;let s=Be(e,t);if(s===null)return null;let o=n.get(s);return o?.text===r?o.start:null}function Jn(e){return e.length>=8&&Ae(e.length)>1}function zn(e){let t=Ae(e.vueFiles.length),n=Kn(e.vueFiles),r=Yn(n,t),i=new URL("./augment-vue-worker.js",import.meta.url),s=kn(S(Tn(),"scip-query-vue-workers-")),o=new SharedArrayBuffer(4),a=new Int32Array(o),u=Xn(),c=Date.now();try{for(let l=0;l<r.length;l++)new Fn(i,{workerData:{projectRoot:e.projectRoot,dbPath:e.dbPath,tsconfig:e.tsconfig,tasks:r[l],resultPath:S(s,`${l}.json`),sharedBuffer:o}});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,d)=>{let f=JSON.parse(w(S(s,`${d}.json`),"utf-8"));if(!f.ok)throw new Error(`Vue reference worker failed: ${f.error}`);return f.result});return{occurrences:g.flatMap(l=>l.occurrences),skippedReferences:g.reduce((l,d)=>l+d.skippedReferences,0)}}finally{Pn(s,{recursive:!0,force:!0})}}function Ae(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,En().length-1));return Math.max(1,Math.min(e,n))}function Xn(){let e=Number(process.env.SCIP_QUERY_AUGMENT_VUE_WORKER_TIMEOUT_MS??0);return Number.isFinite(e)&&e>0?e:3e5}function Kn(e){let t=Qn(),n=[];for(let r of e){let i=Ve(r),s=Math.max(1,Math.ceil(i/t));for(let o=0;o<s;o++)n.push({fileName:r,startOffset:Math.floor(i*o/s),endOffset:o===s-1?Number.POSITIVE_INFINITY:Math.floor(i*(o+1)/s),countFileSkip:o===0})}return n}function Qn(){return Number.POSITIVE_INFINITY}function Yn(e,t){let n=Array.from({length:t},()=>({tasks:[],weight:0})),r=e.map(i=>({task:i,weight:Zn(i)})).sort((i,s)=>s.weight-i.weight);for(let i of r){let s=n.reduce((o,a)=>a.weight<o.weight?a:o);s.tasks.push(i.task),s.weight+=i.weight}return n.map(i=>i.tasks).filter(i=>i.length>0)}function Zn(e){return Number.isFinite(e.endOffset)?Math.max(1,e.endOffset-e.startOffset):Math.max(1,Ve(e.fileName)-e.startOffset)}function Ve(e){try{return wn(e).size}catch{return 1}}function er(e){e.transaction(()=>{e.prepare(`
94
94
  DELETE FROM mentions
95
95
  WHERE chunk_id IN (
96
96
  SELECT c.id
@@ -105,12 +105,12 @@ Thumbs.db
105
105
  FROM documents
106
106
  WHERE language = 'vue' OR relative_path LIKE '%.vue'
107
107
  )
108
- `).run()})()}function er(e,t){return e.prepare(`
108
+ `).run()})()}function tr(e,t){return e.prepare(`
109
109
  SELECT relative_path AS relativePath
110
110
  FROM documents
111
111
  WHERE language = 'vue' OR relative_path LIKE '%.vue'
112
112
  ORDER BY relative_path
113
- `).all().map(r=>je(t,r.relativePath))}function tr(e,t){let{vueCore:n,ts:r,volarTs:i}=nr(e),{parsed:s,vueOptions:o}=rr(n,r,t),a=re(t),u=n.createVueLanguagePlugin(r,s.options,o,f=>f),c=ir(n,r,u),g=sr(a,s),{languageServiceHost:l}=i.createLanguageServiceHost(r,r.sys,c,f=>f,g),d=r.createLanguageService(l);return{ts:r,language:c,languageService:d,fileNames:s.fileNames,configDir:a}}function nr(e){let t=Rn(Dn(S(e,"package.json")).href);return{vueCore:ne(t,"@vue/language-core",e),ts:ne(t,"typescript",e),volarTs:ne(t,"@volar/typescript",e)}}function rr(e,t,n){let r=t.readConfigFile(n,t.sys.readFile);if(r.error||!r.config)throw new Error(`Failed to read ${n}`);let s=e.createParsedCommandLine(t,t.sys,n).vueOptions;return typeof e.createGlobalTypesWriter=="function"&&(s.globalTypesPath=e.createGlobalTypesWriter(s,t.sys.writeFile)),{parsed:t.parseJsonConfigFileContent(r.config,t.sys,re(n),void 0,n,void 0,e.getAllExtensions(s).map(o=>({extension:o.slice(1),isMixedContent:!0,scriptKind:t.ScriptKind.Deferred}))),vueOptions:s}}function ir(e,t,n){let r={},i=e.createLanguage([n],new Map,s=>{if(!Ne(s))return;let o=w(s,"utf-8");r.current?.scripts.set(s,t.ScriptSnapshot.fromString(o),n.getLanguageId(s)??yr(s))});return r.current=i,i}function sr(e,t){return{getCurrentDirectory:()=>e,getCompilationSettings:()=>t.options,getScriptFileNames:()=>t.fileNames,getProjectReferences:()=>t.projectReferences,getProjectVersion:()=>"0"}}function ne(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 or(e,t,n){let r=ar(e);return i=>{let s=C(t,i.fileName),o=n(i.fileName);if(!o)return null;let a=We(o,i.textSpan.start),u=r.get(s);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(`
113
+ `).all().map(r=>je(t,r.relativePath))}function nr(e,t){let{vueCore:n,ts:r,volarTs:i}=rr(e),{parsed:s,vueOptions:o}=ir(n,r,t),a=re(t),u=n.createVueLanguagePlugin(r,s.options,o,f=>f),c=sr(n,r,u),g=or(a,s),{languageServiceHost:l}=i.createLanguageServiceHost(r,r.sys,c,f=>f,g),d=r.createLanguageService(l);return{ts:r,language:c,languageService:d,fileNames:s.fileNames,configDir:a}}function rr(e){let t=In(Ln(S(e,"package.json")).href);return{vueCore:ne(t,"@vue/language-core",e),ts:ne(t,"typescript",e),volarTs:ne(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 s=e.createParsedCommandLine(t,t.sys,n).vueOptions;return typeof e.createGlobalTypesWriter=="function"&&(s.globalTypesPath=e.createGlobalTypesWriter(s,t.sys.writeFile)),{parsed:t.parseJsonConfigFileContent(r.config,t.sys,re(n),void 0,n,void 0,e.getAllExtensions(s).map(o=>({extension:o.slice(1),isMixedContent:!0,scriptKind:t.ScriptKind.Deferred}))),vueOptions:s}}function sr(e,t,n){let r={},i=e.createLanguage([n],new Map,s=>{if(!Ne(s))return;let o=w(s,"utf-8");r.current?.scripts.set(s,t.ScriptSnapshot.fromString(o),n.getLanguageId(s)??xr(s))});return r.current=i,i}function or(e,t){return{getCurrentDirectory:()=>e,getCompilationSettings:()=>t.options,getScriptFileNames:()=>t.fileNames,getProjectReferences:()=>t.projectReferences,getProjectVersion:()=>"0"}}function ne(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 ar(e,t,n){let r=ur(e);return i=>{let s=C(t,i.fileName),o=n(i.fileName);if(!o)return null;let a=We(o,i.textSpan.start),u=r.get(s);if(!u)return null;let c=u.containingByLine.get(a.line);return c!==void 0?c:cr(u.starts,a.line,2)}}function ur(e){let t=e.prepare(`
114
114
  SELECT
115
115
  d.relative_path AS relativePath,
116
116
  der.start_line AS startLine,
@@ -119,30 +119,30 @@ Thumbs.db
119
119
  FROM defn_enclosing_ranges der
120
120
  JOIN documents d ON d.id = der.document_id
121
121
  ORDER BY d.relative_path, (der.end_line - der.start_line) DESC
122
- `).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 s=r.startLine;s<=r.endLine;s++)i.containingByLine.set(s,r.symbolId)}for(let r of n.values())r.starts.sort((i,s)=>i.line-s.line);return n}function ur(e,t,n){let r=0,i=e.length-1;for(;r<=i;){let o=Math.floor((r+i)/2);e[o].line<t?r=o+1:i=o-1}let s=null;for(let o of[i,r]){let a=e[o];if(!a)continue;let u=Math.abs(a.line-t);u>n||(!s||u<s.distance)&&(s={distance:u,symbolId:a.symbolId})}return s?.symbolId??null}function cr(e,t,n){let r=Rr(t),i=e.prepare("SELECT id FROM global_symbols WHERE symbol = ?"),s=e.prepare(`
122
+ `).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 s=r.startLine;s<=r.endLine;s++)i.containingByLine.set(s,r.symbolId)}for(let r of n.values())r.starts.sort((i,s)=>i.line-s.line);return n}function cr(e,t,n){let r=0,i=e.length-1;for(;r<=i;){let o=Math.floor((r+i)/2);e[o].line<t?r=o+1:i=o-1}let s=null;for(let o of[i,r]){let a=e[o];if(!a)continue;let u=Math.abs(a.line-t);u>n||(!s||u<s.distance)&&(s={distance:u,symbolId:a.symbolId})}return s?.symbolId??null}function lr(e,t,n){let r=Ir(t),i=e.prepare("SELECT id FROM global_symbols WHERE symbol = ?"),s=e.prepare(`
123
123
  INSERT OR IGNORE INTO global_symbols (symbol, display_name, kind, documentation)
124
124
  VALUES (?, ?, ?, ?)
125
- `),o=0,a=new Map;return e.transaction(()=>{for(let c of n){let g=C(t,c),l=Ir(r.name,r.version,g);s.run(l,"default",7,`Vue component|${g}`);let d=i.get(l);d&&(o++,a.set(c,d.id))}})(),{get(c){return a.get(c)??null},syntheticSymbols:o}}function lr(e,t,n,r,i){return e.transaction(()=>(Zn(e),gr(e,t,n,r),fr(e,i)))()}function gr(e,t,n,r){let i=e.prepare("SELECT id FROM documents WHERE relative_path = ?"),s=e.prepare(`
125
+ `),o=0,a=new Map;return e.transaction(()=>{for(let c of n){let g=C(t,c),l=kr(r.name,r.version,g);s.run(l,"default",7,`Vue component|${g}`);let d=i.get(l);d&&(o++,a.set(c,d.id))}})(),{get(c){return a.get(c)??null},syntheticSymbols:o}}function gr(e,t,n,r,i){return e.transaction(()=>(er(e),dr(e,t,n,r),mr(e,i)))()}function dr(e,t,n,r){let i=e.prepare("SELECT id FROM documents WHERE relative_path = ?"),s=e.prepare(`
126
126
  INSERT INTO chunks (document_id, chunk_index, start_line, end_line, occurrences)
127
127
  VALUES (?, ?, ?, ?, X'00')
128
128
  `),o=e.prepare(`
129
129
  INSERT OR IGNORE INTO mentions (chunk_id, symbol_id, role)
130
130
  VALUES (?, ?, 1)
131
- `);for(let a of n){let u=r.get(a);if(!u)continue;let c=C(t,a),g=i.get(c);if(!g)continue;let l=s.run(g.id,-1,0,0);o.run(Number(l.lastInsertRowid),u)}}function dr(e,t,n,r,i){if(e.fileName.endsWith(".vue")){let s=r.language.scripts.get(e.fileName),o=s?.generated?.languagePlugin.typescript?.getServiceScript(s.generated.root)?.code;if(s&&o){let a=r.language.maps.get(o,s);if(Be(a,e.textSpan.start)!==null)return n.get(e.fileName)}return e.fileName.startsWith(i)?n.get(e.fileName):null}return t(e)}function pr(e){let t=new Set,n=[];for(let r of e){let i=$e(r);t.has(i)||(t.add(i),n.push(r))}return n}function $e(e){return[e.sourceFile,e.sourceLine,e.sourceStartChar,e.sourceEndChar,e.symbolId].join(":")}function fr(e,t){let n=vr(e,[...new Set(t.map(u=>u.sourceFile))]),r=e.prepare(`
131
+ `);for(let a of n){let u=r.get(a);if(!u)continue;let c=C(t,a),g=i.get(c);if(!g)continue;let l=s.run(g.id,-1,0,0);o.run(Number(l.lastInsertRowid),u)}}function pr(e,t,n,r,i){if(e.fileName.endsWith(".vue")){let s=r.language.scripts.get(e.fileName),o=s?.generated?.languagePlugin.typescript?.getServiceScript(s.generated.root)?.code;if(s&&o){let a=r.language.maps.get(o,s);if(Be(a,e.textSpan.start)!==null)return n.get(e.fileName)}return e.fileName.startsWith(i)?n.get(e.fileName):null}return t(e)}function fr(e){let t=new Set,n=[];for(let r of e){let i=$e(r);t.has(i)||(t.add(i),n.push(r))}return n}function $e(e){return[e.sourceFile,e.sourceLine,e.sourceStartChar,e.sourceEndChar,e.symbolId].join(":")}function mr(e,t){let n=Rr(e,[...new Set(t.map(u=>u.sourceFile))]),r=e.prepare(`
132
132
  INSERT INTO chunks (document_id, chunk_index, start_line, end_line, occurrences)
133
133
  VALUES (?, ?, ?, ?, X'00')
134
134
  `),i=e.prepare(`
135
135
  INSERT OR IGNORE INTO mentions (chunk_id, symbol_id, role)
136
136
  VALUES (?, ?, 0)
137
- `),s=new Set,o=0,a=0;for(let u of t){let c=$e(u);if(s.has(c))continue;s.add(c);let g=n.get(u.sourceFile);if(!g)continue;let l=r.run(g,a++,u.sourceLine,u.sourceLine),d=i.run(Number(l.lastInsertRowid),u.symbolId);o+=Number(d.changes)}return o}function*mr(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 hr(e,t){for(let[n]of e.toGeneratedLocation(t,r=>!!r.navigation))return n;return null}function Be(e,t){let n=e;for(let[r]of n.toSourceLocation(t,i=>!!i.navigation))return r;return null}function We(e,t){let n=0,r=e.lineStarts.length-1;for(;n<=r;){let s=Math.floor((n+r)/2);e.lineStarts[s]<=t?n=s+1:r=s-1}let i=Math.max(0,r);return{line:i,character:t-e.lineStarts[i]}}function br(e,t){return C(e,t).startsWith("node_modules/")}function C(e,t){return Tn(e,t).replaceAll("\\","/")}function yr(e){switch(On(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 xr(){let e=new Map;return t=>{if(e.has(t))return e.get(t)??null;try{let n=w(t,"utf-8"),r={text:n,lineStarts:Sr(n)};return e.set(t,r),r}catch{return e.set(t,null),null}}}function Sr(e){let t=[0];for(let n=0;n<e.length;n++)e.charCodeAt(n)===10&&t.push(n+1);return t}function vr(e,t){let n=new Map,r=500;for(let i=0;i<t.length;i+=r){let s=t.slice(i,i+r),o=e.prepare(`SELECT id, relative_path AS relativePath FROM documents WHERE relative_path IN (${s.map(()=>"?").join(",")})`).all(...s);for(let a of o)n.set(a.relativePath,a.id)}return n}function Rr(e){try{let t=JSON.parse(w(S(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 Ir(e,t,n){let r=n.split("/").map(i=>`\`${i.replaceAll("`","")}\``).join("/");return`scip-vue npm ${e} ${t} ${r}/default.`}async function Lr(e){let{projectRoot:t,maxHeapMb:n=8192,onStatus:r=console.log,skipAutoInstall:i=!1}=e,s=Fr(e),o=Date.now();Ue(b(s.outputScip),{recursive:!0}),Ue(b(s.outputDb),{recursive:!0});let a=e.languages??L(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=ni(t,a,{pnpmWorkspaces:e.pnpmWorkspaces}),c=Kr(p(b(s.outputDb),"index.lock")),g=null;try{let l=Nr({opts:e,paths:s,languages:a,fingerprint:u,start:o,onStatus:r});if(l)return l;Vr(i,r);let d=jr(s);return g=d.runDir,await Mr({opts:e,languages:a,projectRoot:t,paths:s,tempPaths:d,fingerprint:u,start:o,maxHeapMb:n,skipAutoInstall:i,onStatus:r})}finally{g&&R(g,{recursive:!0,force:!0}),c()}}function Fr(e){let t=e.outputScip??p(e.projectRoot,"index.scip"),n=e.outputDb??p(e.projectRoot,"index.db");return{outputScip:t,outputDb:n,metaPath:p(b(n),"meta.json")}}function Nr(e){if(e.opts.skipIfUnchanged===!1||!y(e.paths.outputScip)||!y(e.paths.outputDb)||!ri(e.paths.metaPath,e.fingerprint))return null;m({projectRoot:e.opts.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus});let t=Date.now()-e.start;return 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:[]}}function jr(e){let t=Cr(p(b(e.outputDb),"reindex-"));return{runDir:t,tempOutputScip:p(t,W(e.outputScip)),tempOutputDb:p(t,W(e.outputDb)),tempMetaPath:p(t,W(e.metaPath))}}async function Mr(e){let t={...process.env,NODE_OPTIONS:`--max-old-space-size=${e.maxHeapMb}`},{indexedOutputs:n,skippedLanguages:r}=await _r(e,t);Ar(e,t,n,r);let i=Date.now()-e.start;return e.onStatus(`Done in ${(i/1e3).toFixed(1)}s`),{languages:n.map(s=>s.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:i,reused:!1,skipped:r}}async function _r(e,t){let{preparedRuns:n,skippedLanguages:r}=$r({languages:e.languages,tempOutputScip:e.tempPaths.tempOutputScip,projectRoot:e.projectRoot,env:t,skipAutoInstall:e.skipAutoInstall,pnpmWorkspaces:e.opts.pnpmWorkspaces,onStatus:e.onStatus}),i=await Zr(n,e.projectRoot,e.onStatus,e.opts.indexerConcurrency),{indexedOutputs:s}=Wr(i,r);return Ur(s,r,e.languages,e.opts.allowPartial,e.onStatus),{indexedOutputs:s,skippedLanguages:r}}function Ar(e,t,n,r){Hr(n,e.tempPaths.tempOutputScip,e.onStatus),Gr(e.tempPaths.tempOutputScip,e.tempPaths.tempOutputDb,t,e.onStatus),m({projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,onStatus:e.onStatus}),ii(e.tempPaths.tempMetaPath,{version:2,status:r.length===0?"complete":"partial",updatedAt:new Date().toISOString(),fingerprint:e.fingerprint,requestedLanguages:e.languages,indexedLanguages:n.map(i=>i.language),skipped:[...r]}),Qr({tempOutputScip:e.tempPaths.tempOutputScip,tempOutputDb:e.tempPaths.tempOutputDb,tempMetaPath:e.tempPaths.tempMetaPath,outputScip:e.paths.outputScip,outputDb:e.paths.outputDb,metaPath:e.paths.metaPath})}function Vr(e,t){if(!h("scip")){if(e)throw new Error(`The scip CLI is required but not found on PATH.
138
- Install from: https://github.com/sourcegraph/scip/releases`);if(t("scip CLI not found on PATH. Attempting auto-install..."),!T(t))throw new Error(`The scip CLI is required but could not be installed.
139
- Install manually from: https://github.com/sourcegraph/scip/releases`)}}function $r(e){let t=[],n=[],r=e.languages.map((i,s)=>({language:i,scipPath:e.languages.length>1?Xr(e.tempOutputScip,i,s):e.tempOutputScip}));for(let{language:i,scipPath:s}of r){let o=Br({...e,language:i,scipPath:s});"skipped"in o?n.push(o.skipped):t.push(o.prepared)}return{preparedRuns:t,skippedLanguages:n}}function Br(e){let t=F(e.language),n=A(t),r=ee(t,e.projectRoot);if(!r&&!V(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...`),!$(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??P(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:s,args:o}=t.indexArgs({projectRoot:e.projectRoot,outputPath:e.scipPath,pnpmWorkspaces:e.pnpmWorkspaces,indexerBinary:i});return{prepared:{language:e.language,scipPath:e.scipPath,config:t,resolvedBinary:i,binary:s,args:o,env:te(t,e.env,i)}}}function Wr(e,t){let n=[];for(let r of e)r.skipped?t.push(r.skipped):n.push({language:r.language,scipPath:r.scipPath});return{indexedOutputs:n}}function Ur(e,t,n,r,i){if(e.length===0){let s=t.map(o=>` - ${o.language}: ${o.reason}`).join(`
137
+ `),s=new Set,o=0,a=0;for(let u of t){let c=$e(u);if(s.has(c))continue;s.add(c);let g=n.get(u.sourceFile);if(!g)continue;let l=r.run(g,a++,u.sourceLine,u.sourceLine),d=i.run(Number(l.lastInsertRowid),u.symbolId);o+=Number(d.changes)}return o}function*hr(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 br(e,t){for(let[n]of e.toGeneratedLocation(t,r=>!!r.navigation))return n;return null}function Be(e,t){let n=e;for(let[r]of n.toSourceLocation(t,i=>!!i.navigation))return r;return null}function We(e,t){let n=0,r=e.lineStarts.length-1;for(;n<=r;){let s=Math.floor((n+r)/2);e.lineStarts[s]<=t?n=s+1:r=s-1}let i=Math.max(0,r);return{line:i,character:t-e.lineStarts[i]}}function yr(e,t){return C(e,t).startsWith("node_modules/")}function C(e,t){return Dn(e,t).replaceAll("\\","/")}function xr(e){switch(On(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 Sr(){let e=new Map;return t=>{if(e.has(t))return e.get(t)??null;try{let n=w(t,"utf-8"),r={text:n,lineStarts:vr(n)};return e.set(t,r),r}catch{return e.set(t,null),null}}}function vr(e){let t=[0];for(let n=0;n<e.length;n++)e.charCodeAt(n)===10&&t.push(n+1);return t}function Rr(e,t){let n=new Map,r=500;for(let i=0;i<t.length;i+=r){let s=t.slice(i,i+r),o=e.prepare(`SELECT id, relative_path AS relativePath FROM documents WHERE relative_path IN (${s.map(()=>"?").join(",")})`).all(...s);for(let a of o)n.set(a.relativePath,a.id)}return n}function Ir(e){try{let t=JSON.parse(w(S(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 kr(e,t,n){let r=n.split("/").map(i=>`\`${i.replaceAll("`","")}\``).join("/");return`scip-vue npm ${e} ${t} ${r}/default.`}async function Fr(e){let{projectRoot:t,maxHeapMb:n=8192,onStatus:r=console.log,skipAutoInstall:i=!1}=e,s=Nr(e),o=Date.now();Ue(b(s.outputScip),{recursive:!0}),Ue(b(s.outputDb),{recursive:!0});let a=e.languages??L(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}),c=Qr(p(b(s.outputDb),"index.lock")),g=null;try{let l=jr({opts:e,paths:s,languages:a,fingerprint:u,start:o,onStatus:r});if(l)return l;$r(i,r);let d=_r(s);return g=d.runDir,await Mr({opts:e,languages:a,projectRoot:t,paths:s,tempPaths:d,fingerprint:u,start:o,maxHeapMb:n,skipAutoInstall:i,onStatus:r})}finally{g&&R(g,{recursive:!0,force:!0}),c()}}function Nr(e){let t=e.outputScip??p(e.projectRoot,"index.scip"),n=e.outputDb??p(e.projectRoot,"index.db");return{outputScip:t,outputDb:n,metaPath:p(b(n),"meta.json")}}function jr(e){if(e.opts.skipIfUnchanged===!1||!y(e.paths.outputScip)||!y(e.paths.outputDb)||!ii(e.paths.metaPath,e.fingerprint))return null;m({projectRoot:e.opts.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus});let t=Date.now()-e.start;return 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:[]}}function _r(e){let t=Er(p(b(e.outputDb),"reindex-"));return{runDir:t,tempOutputScip:p(t,W(e.outputScip)),tempOutputDb:p(t,W(e.outputDb)),tempMetaPath:p(t,W(e.metaPath))}}async function Mr(e){let t={...process.env,NODE_OPTIONS:`--max-old-space-size=${e.maxHeapMb}`},{indexedOutputs:n,skippedLanguages:r}=await Ar(e,t);Vr(e,t,n,r);let i=Date.now()-e.start;return e.onStatus(`Done in ${(i/1e3).toFixed(1)}s`),{languages:n.map(s=>s.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:i,reused:!1,skipped:r}}async function Ar(e,t){let{preparedRuns:n,skippedLanguages:r}=Br({languages:e.languages,tempOutputScip:e.tempPaths.tempOutputScip,projectRoot:e.projectRoot,env:t,skipAutoInstall:e.skipAutoInstall,pnpmWorkspaces:e.opts.pnpmWorkspaces,onStatus:e.onStatus}),i=await ei(n,e.projectRoot,e.onStatus,e.opts.indexerConcurrency),{indexedOutputs:s}=Ur(i,r);return Hr(s,r,e.languages,e.opts.allowPartial,e.onStatus),{indexedOutputs:s,skippedLanguages:r}}function Vr(e,t,n,r){Gr(n,e.tempPaths.tempOutputScip,e.onStatus),qr(e.tempPaths.tempOutputScip,e.tempPaths.tempOutputDb,t,e.onStatus),m({projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,onStatus:e.onStatus}),si(e.tempPaths.tempMetaPath,{version:2,status:r.length===0?"complete":"partial",updatedAt:new Date().toISOString(),fingerprint:e.fingerprint,requestedLanguages:e.languages,indexedLanguages:n.map(i=>i.language),skipped:[...r]}),Yr({tempOutputScip:e.tempPaths.tempOutputScip,tempOutputDb:e.tempPaths.tempOutputDb,tempMetaPath:e.tempPaths.tempMetaPath,outputScip:e.paths.outputScip,outputDb:e.paths.outputDb,metaPath:e.paths.metaPath})}function $r(e,t){if(!h("scip")){if(e)throw new Error(`The scip CLI is required but not found on PATH.
138
+ Install from: https://github.com/sourcegraph/scip/releases`);if(t("scip CLI not found on PATH. Attempting auto-install..."),!O(t))throw new Error(`The scip CLI is required but could not be installed.
139
+ Install manually from: https://github.com/sourcegraph/scip/releases`)}}function Br(e){let t=[],n=[],r=e.languages.map((i,s)=>({language:i,scipPath:e.languages.length>1?Kr(e.tempOutputScip,i,s):e.tempOutputScip}));for(let{language:i,scipPath:s}of r){let o=Wr({...e,language:i,scipPath:s});"skipped"in o?n.push(o.skipped):t.push(o.prepared)}return{preparedRuns:t,skippedLanguages:n}}function Wr(e){let t=F(e.language),n=A(t),r=ee(t,e.projectRoot);if(!r&&!V(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...`),!$(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??P(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:s,args:o}=t.indexArgs({projectRoot:e.projectRoot,outputPath:e.scipPath,pnpmWorkspaces:e.pnpmWorkspaces,indexerBinary:i});return{prepared:{language:e.language,scipPath:e.scipPath,config:t,resolvedBinary:i,binary:s,args:o,env:te(t,e.env,i)}}}function Ur(e,t){let n=[];for(let r of e)r.skipped?t.push(r.skipped):n.push({language:r.language,scipPath:r.scipPath});return{indexedOutputs:n}}function Hr(e,t,n,r,i){if(e.length===0){let s=t.map(o=>` - ${o.language}: ${o.reason}`).join(`
140
140
  `);throw new Error(`No language indexers ran successfully. Install at least one indexer for the languages in this project.
141
141
  `+s)}if(t.length!==0&&(i(`Indexed ${e.length} of ${n.length} languages; skipped ${t.map(s=>s.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.
142
142
  `+t.map(s=>` - ${s.language}: ${s.reason}`).join(`
143
- `))}function Hr(e,t,n){e.length>1?(n(`Merging ${e.length} language indexes...`),N(e.map(r=>r.scipPath),t)):e[0].scipPath!==t&&v(e[0].scipPath,t)}function Gr(e,t,n,r){if(r("Converting to SQLite..."),!y(e))throw new Error(`SCIP index not found at ${e} after indexing`);try{let i=Ee(e);i.removedDefinitionOccurrences>0&&r(`Sanitized ${i.removedDefinitionOccurrences} invalid definition occurrences across ${i.touchedDocuments} documents before SQLite conversion.`),Pr("scip",["expt-convert","--output",t,e],{env:n,stdio:"pipe",maxBuffer:50*1024*1024})}catch(i){let s=i instanceof Error?i.message:String(i);throw new Error(`Failed to convert SCIP index to SQLite: ${s}`,{cause:i})}}function qr(e,t,n){if(!e.defaultOutputPath)return;let r=p(t,e.defaultOutputPath);n!==r&&y(r)&&v(r,n)}function Jr(e,t,n){if(!e.defaultOutputPath)return null;let r=p(t,e.defaultOutputPath);if(r===n)return null;let i=`${n}.default-output-backup`;return R(i,{force:!0}),y(r)?(v(r,i),{defaultOutputPath:r,backupPath:i}):{defaultOutputPath:r,backupPath:null}}function zr(e){e&&(R(e.defaultOutputPath,{force:!0}),e.backupPath&&y(e.backupPath)&&v(e.backupPath,e.defaultOutputPath))}function Xr(e,t,n){let r=Dr(e)||".scip",i=W(e,r);return p(b(e),`${i}.${n+1}.${t}${r}`)}function Kr(e){let t;try{t=Er(e,"wx")}catch(n){throw(typeof n=="object"&&n&&"code"in n?n.code:void 0)==="EEXIST"?new Error(`Another scip-query reindex is already running for ${b(e)}.`,{cause:n}):n}return He(t,JSON.stringify({pid:process.pid,startedAt:new Date().toISOString()})+`
144
- `),()=>{try{wr(t)}finally{R(e,{force:!0})}}}function Qr(e){ie(e.tempOutputScip,e.outputScip),ie(e.tempOutputDb,e.outputDb),ie(e.tempMetaPath,e.metaPath)}function ie(e,t){R(`${t}.tmp-replace`,{force:!0}),v(e,`${t}.tmp-replace`),v(`${t}.tmp-replace`,t)}function Yr(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(2,Math.max(1,Tr().length-1));return Math.max(1,Math.min(e,Math.floor(r)))}async function Zr(e,t,n,r){let i=e.filter(c=>c.config.defaultOutputPath),s=e.filter(c=>!c.config.defaultOutputPath),o=[],a=Yr(s.length,r),u=await ti(s,a,c=>se(c,t,n));if(a>1){let c=new Map;for(let g of u.filter(l=>l.skipped)){let l=s.find(d=>d.language===g.language);l&&(n(`Retrying ${l.language} indexer serially after parallel failure...`),c.set(l.language,await se(l,t,n)))}o.push(...u.map(g=>c.get(g.language)??g))}else o.push(...u);for(let c of i)o.push(await se(c,t,n));return o.sort((c,g)=>e.findIndex(l=>l.language===c.language)-e.findIndex(l=>l.language===g.language))}async function se(e,t,n){n(`Indexing ${e.language} with ${e.resolvedBinary}...`),R(e.scipPath,{force:!0});let r=Jr(e.config,t,e.scipPath);try{await ei(e.binary,e.args,{cwd:t,env:e.env,maxBuffer:50*1024*1024}),qr(e.config,t,e.scipPath)}catch(i){let s=i instanceof Error?i.message:String(i),o=`${e.resolvedBinary} indexer failed: ${s.split(`
145
- `)[0]}`;return n(`Skipping ${e.language}: ${o}`),{language:e.language,scipPath:e.scipPath,skipped:{language:e.language,reason:o}}}finally{zr(r)}if(!y(e.scipPath)){let i=`${e.resolvedBinary} indexer completed but did not produce ${e.scipPath}`;return n(`Skipping ${e.language}: ${i}`),{language:e.language,scipPath:e.scipPath,skipped:{language:e.language,reason:i}}}return{language:e.language,scipPath:e.scipPath}}function ei(e,t,n){return new Promise((r,i)=>{kr(e,[...t],n,s=>{s?i(s):r()})})}async function ti(e,t,n){if(e.length===0)return[];let r=new Array(e.length),i=0,s=Math.max(1,Math.min(e.length,t)),o=Array.from({length:s},async()=>{for(;i<e.length;){let a=i++;r[a]=await n(e[a])}});return await Promise.all(o),r}function ni(e,t,n){return{version:1,languages:[...t].sort(),pnpmWorkspaces:n.pnpmWorkspaces===!0,files:j(e)}}function ri(e,t){try{let n=JSON.parse(Or(e,"utf-8"));return n.version===2&&n.status==="complete"&&B(n.fingerprint)===B(t)&&B([...n.indexedLanguages??[]].sort())===B(t.languages)}catch{return!1}}function ii(e,t){He(e,`${JSON.stringify(t,null,2)}
146
- `)}function B(e){return JSON.stringify(e)}import{readFileSync as si,writeFileSync as oi,existsSync as qe,mkdirSync as ai}from"fs";import{join as x,resolve as Ge}from"path";import{createHash as ui}from"crypto";import{homedir as ci}from"os";var Je=".scipquery.json",li={enabled:!1,debounceMs:3e4,cooldownMs:6e4,ignore:[]};function gi(e){let t=x(e,Je);if(!qe(t))return{};try{let n=si(t,"utf-8");return JSON.parse(n)}catch{return{}}}function ze(e){return{...li,...e.watch}}function di(e,t){let n=process.env.SCIP_QUERY_CACHE_DIR;if(n)return oe(n);if(t?.dbPath)return oe(Ge(e,t.dbPath));let i=process.env.XDG_CACHE_HOME||x(ci(),".cache"),s=ui("sha256").update(Ge(e)).digest("hex").slice(0,12),o=x(i,"scip-query","projects",s);return oe(o)}function ae(e,t){let n=di(e,t);return{cacheDir:n,dbPath:x(n,"index.db"),indexPath:x(n,"index.scip"),metaPath:x(n,"meta.json")}}function pi(e,t){let n=x(e,Je);return qe(n)||oi(n,JSON.stringify({languages:t,watch:{enabled:!1,debounceMs:3e4,cooldownMs:6e4}},null,2)+`
147
- `),n}function oe(e){return ai(e,{recursive:!0}),e}import{watch as fi}from"fs";import{existsSync as Xe,renameSync as Ke}from"fs";import{join as mi,relative as hi}from"path";import{fork as bi}from"child_process";import yi from"ignore";var ue=class{projectRoot;watchConfig;indexPaths;languages;pnpmWorkspaces;onStatus;onReindexComplete;onError;status={state:"idle"};debounceTimer=null;cooldownTimer=null;dirty=!1;changedFiles=0;reindexInFlight=!1;lastReindexEnd=0;fsWatchers=[];gitignoreFilter;extraIgnore;stopped=!1;constructor(t){this.projectRoot=t.projectRoot,this.watchConfig=ze(t.config),this.indexPaths=ae(t.projectRoot,t.config),this.languages=t.languages,this.pnpmWorkspaces=t.config.indexer?.typescript?.pnpmWorkspaces??!1,this.onStatus=t.onStatus??(()=>{}),this.onReindexComplete=t.onReindexComplete??(()=>{}),this.onError=t.onError??(n=>console.error(n.message)),this.gitignoreFilter=I(t.projectRoot),this.extraIgnore=yi(),this.watchConfig.ignore.length>0&&this.extraIgnore.add(this.watchConfig.ignore)}start(){this.stopped=!1,this.setStatus({state:"idle"});try{let t=fi(this.projectRoot,{recursive:!0},(n,r)=>{r&&!this.stopped&&this.handleFileChange(r)});this.fsWatchers.push(t)}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 t of this.fsWatchers)t.close();this.fsWatchers=[],this.clearDebounceTimer(),this.clearCooldownTimer(),this.setStatus({state:"idle"})}handleFileChange(t){let n=hi(this.projectRoot,mi(this.projectRoot,t));if(this.gitignoreFilter.isIgnored(n)||this.extraIgnore.ignores(n)||t.endsWith("index.db")||t.endsWith("index.scip")||t.endsWith("index.db.tmp")||t.endsWith(".scipquery.json"))return;if(this.changedFiles++,this.reindexInFlight){this.dirty=!0,this.setStatus({state:"indexing",startedAt:this.status.startedAt});return}if(this.status.state==="cooldown"){this.dirty=!0,this.setStatus({state:"cooldown",until:this.status.until,dirty:!0});return}this.clearDebounceTimer();let r=Date.now()+this.watchConfig.debounceMs;this.setStatus({state:"waiting",changedFiles:this.changedFiles,reindexAt:r}),this.debounceTimer=setTimeout(()=>{this.debounceTimer=null,this.triggerReindex()},this.watchConfig.debounceMs)}triggerReindex(){if(this.reindexInFlight||this.stopped)return;let t=Date.now()-this.lastReindexEnd;if(this.lastReindexEnd>0&&t<this.watchConfig.cooldownMs){let r=this.watchConfig.cooldownMs-t;this.dirty=!0;let i=Date.now()+r;this.setStatus({state:"cooldown",until:i,dirty:!0}),this.cooldownTimer=setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped&&(this.dirty=!1,this.triggerReindex())},r);return}this.reindexInFlight=!0,this.dirty=!1,this.changedFiles=0;let n=Date.now();this.setStatus({state:"indexing",startedAt:n}),this.runReindex().then(r=>{if(this.reindexInFlight=!1,this.lastReindexEnd=Date.now(),this.onReindexComplete(r),this.dirty&&!this.stopped){let i=Date.now()+this.watchConfig.cooldownMs;this.setStatus({state:"cooldown",until:i,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(r=>{this.reindexInFlight=!1,this.lastReindexEnd=Date.now(),this.onError(r instanceof Error?r:new Error(String(r))),this.setStatus({state:"idle"})})}runReindex(){return new Promise((t,n)=>{let r=Date.now(),i=this.indexPaths.dbPath+".tmp",s=xi(this.indexPaths.indexPath),o=bi(new URL("./reindex-worker.js",import.meta.url).pathname,[],{env:{...process.env,SCIP_REINDEX_PROJECT_ROOT:this.projectRoot,SCIP_REINDEX_OUTPUT_SCIP:s,SCIP_REINDEX_OUTPUT_DB:i,SCIP_REINDEX_LANGUAGES:this.languages?.join(",")??"",SCIP_REINDEX_PNPM_WORKSPACES:this.pnpmWorkspaces?"1":""},stdio:"pipe"});o.on("exit",a=>{if(a===0)try{Xe(i)&&Ke(i,this.indexPaths.dbPath),Xe(s)&&Ke(s,this.indexPaths.indexPath),t(Date.now()-r)}catch(u){n(new Error(`Atomic swap failed: ${u}`))}else n(new Error(`Reindex worker exited with code ${a}`))}),o.on("error",n)})}setStatus(t){this.status=t,this.onStatus(t)}clearDebounceTimer(){this.debounceTimer&&(clearTimeout(this.debounceTimer),this.debounceTimer=null)}clearCooldownTimer(){this.cooldownTimer&&(clearTimeout(this.cooldownTimer),this.cooldownTimer=null)}};function xi(e){return e.endsWith(".scip")?e.slice(0,-5)+".tmp.scip":e+".tmp.scip"}import{existsSync as ce,mkdirSync as Si,symlinkSync as vi,readlinkSync as Ri,unlinkSync as Ii}from"fs";import{join as U,dirname as Qe,resolve as le}from"path";import{homedir as Ye,platform as ki}from"os";import{fileURLToPath as Pi}from"url";var wi=ki()==="win32",Ci=["concrete-plan","scip-explore","scip-debloat","scip-verify","scip-language-playbook"];function Ei(e={}){let t=e.quiet?()=>{}:console.log,n=Pi(import.meta.url),r=le(Qe(n),"..","skills"),i=[U(Ye(),".claude","skills"),U(Ye(),".codex","skills")],s={installed:[],skipped:[],alreadyLinked:[]};for(let o of i){let a=Qe(o);if(!ce(a))continue;Si(o,{recursive:!0});let u=o.includes(".codex")?"Codex":"Claude";for(let c of Ci){let g=U(r,c),l=U(o,c);if(!ce(g)){s.skipped.push(`${u}/${c}`);continue}if(ce(l)){try{let d=Ri(l);if(le(d)===le(g)){s.alreadyLinked.push(`${u}/${c}`),t(` ok: ${c} \u2192 ${u} (already linked)`);continue}}catch{s.skipped.push(`${u}/${c}`),t(` skip: ${c} \u2192 ${u} (exists, not a symlink)`);continue}Ii(l)}vi(g,l,wi?"junction":"dir"),s.installed.push(`${u}/${c}`),t(` done: ${c} \u2192 ${u}`)}}return s}export{Rs as HEALTH_PHASES,X as INDEXER_CONFIGS,rt as ProjectIndex,H as ScipDatabase,ue as Watcher,gs as affected,m as augmentAuxiliaryDocuments,Me as augmentVueResolvedReferences,Zi as bottlenecks,ts as byKind,ss as callGraph,ds as changeSurface,Cs as code,Es as complexity,vs as complexityHotspots,ws as convergence,Ki as coupling,I as createGitignoreFilter,Yi as cycles,Os as dataflow,Vi as dead,rs as deepChains,ji as deps,L as detectLanguages,ps as diffImpact,ms as diffImpactPartial,fs as diffImpactPlan,bs as drift,ls as extractCandidates,qi as fanIn,Ji as fanOut,Ti as files,F as getIndexerConfig,ft as getScipVersion,Is as health,ks as healthPhase,Ps as healthReportFromPhases,is as hierarchy,$i as hotspots,Wi as importedBy,Bi as imports,pi as initProjectConfig,Ei as installSkills,h as isBinaryAvailable,V as isIndexerInstalled,pt as isScipInstalled,es as isolated,ns as kindCounts,nt as leafName,gi as loadProjectConfig,Gi as members,hs as mergeDiffImpactPartials,N as mergeScipFiles,Q as mergeScipIndexes,Li as methods,Hi as outline,et as parseSymbol,xs as passthroughCandidates,ht as printScipInstallInstructions,Mi as rdeps,Ds as redundantReexports,Fi as refs,Lr as reindex,ae as resolveIndexPaths,tt as shortenSymbol,os as similar,as as similarAll,cs as similarChains,us as similarFiles,Ls as similarSignatures,Ts as slice,Ss as staleAbstractions,Oi as stats,Ai as surface,Di as symbols,_i as system,Qi as topCoupling,zi as topFanIn,Xi as topFanOut,Ni as trace,$ as tryInstallIndexer,T as tryInstallScipCli,Ui as unusedImports,ys as wrapperCandidates};
143
+ `))}function Gr(e,t,n){e.length>1?(n(`Merging ${e.length} language indexes...`),N(e.map(r=>r.scipPath),t)):e[0].scipPath!==t&&v(e[0].scipPath,t)}function qr(e,t,n,r){if(r("Converting to SQLite..."),!y(e))throw new Error(`SCIP index not found at ${e} after indexing`);try{let i=Ee(e);i.removedDefinitionOccurrences>0&&r(`Sanitized ${i.removedDefinitionOccurrences} invalid definition occurrences across ${i.touchedDocuments} documents before SQLite conversion.`),wr("scip",["expt-convert","--output",t,e],{env:n,stdio:"pipe",maxBuffer:50*1024*1024})}catch(i){let s=i instanceof Error?i.message:String(i);throw new Error(`Failed to convert SCIP index to SQLite: ${s}`,{cause:i})}}function Jr(e,t,n){if(!e.defaultOutputPath)return;let r=p(t,e.defaultOutputPath);n!==r&&y(r)&&v(r,n)}function zr(e,t,n){if(!e.defaultOutputPath)return null;let r=p(t,e.defaultOutputPath);if(r===n)return null;let i=`${n}.default-output-backup`;return R(i,{force:!0}),y(r)?(v(r,i),{defaultOutputPath:r,backupPath:i}):{defaultOutputPath:r,backupPath:null}}function Xr(e){e&&(R(e.defaultOutputPath,{force:!0}),e.backupPath&&y(e.backupPath)&&v(e.backupPath,e.defaultOutputPath))}function Kr(e,t,n){let r=Lr(e)||".scip",i=W(e,r);return p(b(e),`${i}.${n+1}.${t}${r}`)}function Qr(e){let t;try{t=Tr(e,"wx")}catch(n){throw(typeof n=="object"&&n&&"code"in n?n.code:void 0)==="EEXIST"?new Error(`Another scip-query reindex is already running for ${b(e)}.`,{cause:n}):n}return He(t,JSON.stringify({pid:process.pid,startedAt:new Date().toISOString()})+`
144
+ `),()=>{try{Cr(t)}finally{R(e,{force:!0})}}}function Yr(e){ie(e.tempOutputScip,e.outputScip),ie(e.tempOutputDb,e.outputDb),ie(e.tempMetaPath,e.metaPath)}function ie(e,t){R(`${t}.tmp-replace`,{force:!0}),v(e,`${t}.tmp-replace`),v(`${t}.tmp-replace`,t)}function Zr(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(2,Math.max(1,Dr().length-1));return Math.max(1,Math.min(e,Math.floor(r)))}async function ei(e,t,n,r){let i=e.filter(c=>c.config.defaultOutputPath),s=e.filter(c=>!c.config.defaultOutputPath),o=[],a=Zr(s.length,r),u=await ni(s,a,c=>se(c,t,n));if(a>1){let c=new Map;for(let g of u.filter(l=>l.skipped)){let l=s.find(d=>d.language===g.language);l&&(n(`Retrying ${l.language} indexer serially after parallel failure...`),c.set(l.language,await se(l,t,n)))}o.push(...u.map(g=>c.get(g.language)??g))}else o.push(...u);for(let c of i)o.push(await se(c,t,n));return o.sort((c,g)=>e.findIndex(l=>l.language===c.language)-e.findIndex(l=>l.language===g.language))}async function se(e,t,n){n(`Indexing ${e.language} with ${e.resolvedBinary}...`),R(e.scipPath,{force:!0});let r=zr(e.config,t,e.scipPath);try{await ti(e.binary,e.args,{cwd:t,env:e.env,maxBuffer:50*1024*1024}),Jr(e.config,t,e.scipPath)}catch(i){let s=i instanceof Error?i.message:String(i),o=`${e.resolvedBinary} indexer failed: ${s.split(`
145
+ `)[0]}`;return n(`Skipping ${e.language}: ${o}`),{language:e.language,scipPath:e.scipPath,skipped:{language:e.language,reason:o}}}finally{Xr(r)}if(!y(e.scipPath)){let i=`${e.resolvedBinary} indexer completed but did not produce ${e.scipPath}`;return n(`Skipping ${e.language}: ${i}`),{language:e.language,scipPath:e.scipPath,skipped:{language:e.language,reason:i}}}return{language:e.language,scipPath:e.scipPath}}function ti(e,t,n){return new Promise((r,i)=>{Pr(e,[...t],n,s=>{s?i(s):r()})})}async function ni(e,t,n){if(e.length===0)return[];let r=new Array(e.length),i=0,s=Math.max(1,Math.min(e.length,t)),o=Array.from({length:s},async()=>{for(;i<e.length;){let a=i++;r[a]=await n(e[a])}});return await Promise.all(o),r}function ri(e,t,n){return{version:1,languages:[...t].sort(),pnpmWorkspaces:n.pnpmWorkspaces===!0,files:j(e)}}function ii(e,t){try{let n=JSON.parse(Or(e,"utf-8"));return n.version===2&&n.status==="complete"&&B(n.fingerprint)===B(t)&&B([...n.indexedLanguages??[]].sort())===B(t.languages)}catch{return!1}}function si(e,t){He(e,`${JSON.stringify(t,null,2)}
146
+ `)}function B(e){return JSON.stringify(e)}import{readFileSync as oi,writeFileSync as ai,existsSync as qe,mkdirSync as ui}from"fs";import{join as x,resolve as Ge}from"path";import{createHash as ci}from"crypto";import{homedir as li}from"os";var Je=".scipquery.json",gi={enabled:!1,debounceMs:3e4,cooldownMs:6e4,ignore:[]};function di(e){let t=x(e,Je);if(!qe(t))return{};try{let n=oi(t,"utf-8");return JSON.parse(n)}catch{return{}}}function ze(e){return{...gi,...e.watch}}function pi(e,t){let n=process.env.SCIP_QUERY_CACHE_DIR;if(n)return oe(n);if(t?.dbPath)return oe(Ge(e,t.dbPath));let i=process.env.XDG_CACHE_HOME||x(li(),".cache"),s=ci("sha256").update(Ge(e)).digest("hex").slice(0,12),o=x(i,"scip-query","projects",s);return oe(o)}function ae(e,t){let n=pi(e,t);return{cacheDir:n,dbPath:x(n,"index.db"),indexPath:x(n,"index.scip"),metaPath:x(n,"meta.json")}}function fi(e,t){let n=x(e,Je);return qe(n)||ai(n,JSON.stringify({languages:t,watch:{enabled:!1,debounceMs:3e4,cooldownMs:6e4}},null,2)+`
147
+ `),n}function oe(e){return ui(e,{recursive:!0}),e}import{watch as mi}from"fs";import{existsSync as Xe,renameSync as Ke}from"fs";import{join as hi,relative as bi}from"path";import{fork as yi}from"child_process";import xi from"ignore";var ue=class{projectRoot;watchConfig;indexPaths;languages;pnpmWorkspaces;onStatus;onReindexComplete;onError;status={state:"idle"};debounceTimer=null;cooldownTimer=null;dirty=!1;changedFiles=0;reindexInFlight=!1;lastReindexEnd=0;fsWatchers=[];gitignoreFilter;extraIgnore;stopped=!1;constructor(t){this.projectRoot=t.projectRoot,this.watchConfig=ze(t.config),this.indexPaths=ae(t.projectRoot,t.config),this.languages=t.languages,this.pnpmWorkspaces=t.config.indexer?.typescript?.pnpmWorkspaces??!1,this.onStatus=t.onStatus??(()=>{}),this.onReindexComplete=t.onReindexComplete??(()=>{}),this.onError=t.onError??(n=>console.error(n.message)),this.gitignoreFilter=I(t.projectRoot),this.extraIgnore=xi(),this.watchConfig.ignore.length>0&&this.extraIgnore.add(this.watchConfig.ignore)}start(){this.stopped=!1,this.setStatus({state:"idle"});try{let t=mi(this.projectRoot,{recursive:!0},(n,r)=>{r&&!this.stopped&&this.handleFileChange(r)});this.fsWatchers.push(t)}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 t of this.fsWatchers)t.close();this.fsWatchers=[],this.clearDebounceTimer(),this.clearCooldownTimer(),this.setStatus({state:"idle"})}handleFileChange(t){let n=bi(this.projectRoot,hi(this.projectRoot,t));if(this.gitignoreFilter.isIgnored(n)||this.extraIgnore.ignores(n)||t.endsWith("index.db")||t.endsWith("index.scip")||t.endsWith("index.db.tmp")||t.endsWith(".scipquery.json"))return;if(this.changedFiles++,this.reindexInFlight){this.dirty=!0,this.setStatus({state:"indexing",startedAt:this.status.startedAt});return}if(this.status.state==="cooldown"){this.dirty=!0,this.setStatus({state:"cooldown",until:this.status.until,dirty:!0});return}this.clearDebounceTimer();let r=Date.now()+this.watchConfig.debounceMs;this.setStatus({state:"waiting",changedFiles:this.changedFiles,reindexAt:r}),this.debounceTimer=setTimeout(()=>{this.debounceTimer=null,this.triggerReindex()},this.watchConfig.debounceMs)}triggerReindex(){if(this.reindexInFlight||this.stopped)return;let t=Date.now()-this.lastReindexEnd;if(this.lastReindexEnd>0&&t<this.watchConfig.cooldownMs){let r=this.watchConfig.cooldownMs-t;this.dirty=!0;let i=Date.now()+r;this.setStatus({state:"cooldown",until:i,dirty:!0}),this.cooldownTimer=setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped&&(this.dirty=!1,this.triggerReindex())},r);return}this.reindexInFlight=!0,this.dirty=!1,this.changedFiles=0;let n=Date.now();this.setStatus({state:"indexing",startedAt:n}),this.runReindex().then(r=>{if(this.reindexInFlight=!1,this.lastReindexEnd=Date.now(),this.onReindexComplete(r),this.dirty&&!this.stopped){let i=Date.now()+this.watchConfig.cooldownMs;this.setStatus({state:"cooldown",until:i,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(r=>{this.reindexInFlight=!1,this.lastReindexEnd=Date.now(),this.onError(r instanceof Error?r:new Error(String(r))),this.setStatus({state:"idle"})})}runReindex(){return new Promise((t,n)=>{let r=Date.now(),i=this.indexPaths.dbPath+".tmp",s=Si(this.indexPaths.indexPath),o=yi(new URL("./reindex-worker.js",import.meta.url).pathname,[],{env:{...process.env,SCIP_REINDEX_PROJECT_ROOT:this.projectRoot,SCIP_REINDEX_OUTPUT_SCIP:s,SCIP_REINDEX_OUTPUT_DB:i,SCIP_REINDEX_LANGUAGES:this.languages?.join(",")??"",SCIP_REINDEX_PNPM_WORKSPACES:this.pnpmWorkspaces?"1":""},stdio:"pipe"});o.on("exit",a=>{if(a===0)try{Xe(i)&&Ke(i,this.indexPaths.dbPath),Xe(s)&&Ke(s,this.indexPaths.indexPath),t(Date.now()-r)}catch(u){n(new Error(`Atomic swap failed: ${u}`))}else n(new Error(`Reindex worker exited with code ${a}`))}),o.on("error",n)})}setStatus(t){this.status=t,this.onStatus(t)}clearDebounceTimer(){this.debounceTimer&&(clearTimeout(this.debounceTimer),this.debounceTimer=null)}clearCooldownTimer(){this.cooldownTimer&&(clearTimeout(this.cooldownTimer),this.cooldownTimer=null)}};function Si(e){return e.endsWith(".scip")?e.slice(0,-5)+".tmp.scip":e+".tmp.scip"}import{existsSync as ce,mkdirSync as vi,symlinkSync as Ri,readlinkSync as Ii,unlinkSync as ki}from"fs";import{join as U,dirname as Qe,resolve as le}from"path";import{homedir as Ye,platform as Pi}from"os";import{fileURLToPath as wi}from"url";var Ci=Pi()==="win32",Ei=["concrete-plan","scip-explore","scip-debloat","scip-verify","scip-language-playbook"];function Ti(e={}){let t=e.quiet?()=>{}:console.log,n=wi(import.meta.url),r=le(Qe(n),"..","skills"),i=[U(Ye(),".claude","skills"),U(Ye(),".codex","skills")],s={installed:[],skipped:[],alreadyLinked:[]};for(let o of i){let a=Qe(o);if(!ce(a))continue;vi(o,{recursive:!0});let u=o.includes(".codex")?"Codex":"Claude";for(let c of Ei){let g=U(r,c),l=U(o,c);if(!ce(g)){s.skipped.push(`${u}/${c}`);continue}if(ce(l)){try{let d=Ii(l);if(le(d)===le(g)){s.alreadyLinked.push(`${u}/${c}`),t(` ok: ${c} \u2192 ${u} (already linked)`);continue}}catch{s.skipped.push(`${u}/${c}`),t(` skip: ${c} \u2192 ${u} (exists, not a symlink)`);continue}ki(l)}Ri(g,l,Ci?"junction":"dir"),s.installed.push(`${u}/${c}`),t(` done: ${c} \u2192 ${u}`)}}return s}export{Is as HEALTH_PHASES,X as INDEXER_CONFIGS,rt as ProjectIndex,H as ScipDatabase,ue as Watcher,ds as affected,m as augmentAuxiliaryDocuments,_e as augmentVueResolvedReferences,es as bottlenecks,ns as byKind,os as callGraph,ps as changeSurface,Es as code,Ts as complexity,Rs as complexityHotspots,Cs as convergence,Qi as coupling,I as createGitignoreFilter,Zi as cycles,Os as dataflow,$i as dead,is as deepChains,_i as deps,L as detectLanguages,fs as diffImpact,hs as diffImpactPartial,ms as diffImpactPlan,ys as drift,gs as extractCandidates,Ji as fanIn,zi as fanOut,Di as files,F as getIndexerConfig,mt as getScipVersion,ks as health,Ps as healthPhase,ws as healthReportFromPhases,ss as hierarchy,Bi as hotspots,Ui as importedBy,Wi as imports,fi as initProjectConfig,Ti as installSkills,h as isBinaryAvailable,V as isIndexerInstalled,ft as isScipInstalled,ts as isolated,rs as kindCounts,nt as leafName,di as loadProjectConfig,qi as members,bs as mergeDiffImpactPartials,N as mergeScipFiles,Q as mergeScipIndexes,Fi as methods,Gi as outline,et as parseSymbol,Ss as passthroughCandidates,bt as printScipInstallInstructions,Mi as rdeps,Ls as redundantReexports,Ni as refs,Fr as reindex,ae as resolveIndexPaths,tt as shortenSymbol,as as similar,us as similarAll,ls as similarChains,cs as similarFiles,Fs as similarSignatures,Ds as slice,vs as staleAbstractions,Oi as stats,Vi as surface,Li as symbols,Ai as system,Yi as topCoupling,Xi as topFanIn,Ki as topFanOut,ji as trace,$ as tryInstallIndexer,O as tryInstallScipCli,Hi as unusedImports,xs as wrapperCandidates};
148
148
  //# sourceMappingURL=index.js.map
@@ -1,4 +1,4 @@
1
- import { S as ScipDatabase, A as AffectedResult } from '../db-DdlToIC-.js';
1
+ import { S as ScipDatabase, A as AffectedResult } from '../db-Rx8Ho_JF.js';
2
2
  import 'better-sqlite3';
3
3
 
4
4
  /**
@@ -1,2 +1,2 @@
1
- import{a}from"../chunk-HTJ5BOYP.js";import"../chunk-GS55K4WJ.js";import"../chunk-6FLGPRBR.js";import"../chunk-G47V5V3U.js";import"../chunk-QYWGC7JV.js";import"../chunk-KYGNCIJ6.js";export{a as affected};
1
+ import{a}from"../chunk-I5BB33E6.js";import"../chunk-EHEZLULQ.js";import"../chunk-33Z6HQBX.js";import"../chunk-67OMD56K.js";import"../chunk-BT36WY5B.js";import"../chunk-NLJCXHFU.js";export{a as affected};
2
2
  //# sourceMappingURL=affected.js.map
@@ -1,4 +1,4 @@
1
- import { S as ScipDatabase, B as BottleneckResult } from '../db-DdlToIC-.js';
1
+ import { S as ScipDatabase, B as BottleneckResult } from '../db-Rx8Ho_JF.js';
2
2
  import 'better-sqlite3';
3
3
 
4
4
  /**
@@ -13,6 +13,8 @@ declare function bottlenecks(db: ScipDatabase, opts?: {
13
13
  scope?: string;
14
14
  minFanIn?: number;
15
15
  minFanOut?: number;
16
+ scanLimit?: number;
17
+ semantic?: boolean;
16
18
  }): BottleneckResult[];
17
19
 
18
20
  export { bottlenecks };
@@ -1,2 +1,2 @@
1
- import{a}from"../chunk-KCC3GMCX.js";import"../chunk-SVUVC5VS.js";import"../chunk-TYRPQE6R.js";import"../chunk-7EQ4J66C.js";import"../chunk-WPY46NIL.js";import"../chunk-GS55K4WJ.js";import"../chunk-6FLGPRBR.js";import"../chunk-G47V5V3U.js";import"../chunk-QYWGC7JV.js";import"../chunk-KYGNCIJ6.js";export{a as bottlenecks};
1
+ import{a}from"../chunk-2OP63JQQ.js";import"../chunk-LNUZWWWL.js";import"../chunk-IIKNAXAE.js";import"../chunk-JMASYYSW.js";import"../chunk-5IRX5I64.js";import"../chunk-EHEZLULQ.js";import"../chunk-33Z6HQBX.js";import"../chunk-67OMD56K.js";import"../chunk-BT36WY5B.js";import"../chunk-NLJCXHFU.js";export{a as bottlenecks};
2
2
  //# sourceMappingURL=bottlenecks.js.map
@@ -1,4 +1,4 @@
1
- import { S as ScipDatabase, a as ByKindResult } from '../db-DdlToIC-.js';
1
+ import { S as ScipDatabase, a as ByKindResult } from '../db-Rx8Ho_JF.js';
2
2
  import 'better-sqlite3';
3
3
 
4
4
  declare function byKind(db: ScipDatabase, kindQuery: string, opts?: {
@@ -1,2 +1,2 @@
1
- import{a,b}from"../chunk-ZNNCDAYX.js";import"../chunk-KYGNCIJ6.js";export{a as byKind,b as kindCounts};
1
+ import{a,b}from"../chunk-42BWO2NN.js";import"../chunk-NLJCXHFU.js";export{a as byKind,b as kindCounts};
2
2
  //# sourceMappingURL=by-kind.js.map
@@ -1,4 +1,4 @@
1
- import { S as ScipDatabase, C as CallGraphResult } from '../db-DdlToIC-.js';
1
+ import { S as ScipDatabase, C as CallGraphResult } from '../db-Rx8Ho_JF.js';
2
2
  import 'better-sqlite3';
3
3
 
4
4
  /**
@@ -8,6 +8,8 @@ import 'better-sqlite3';
8
8
  * Incoming: other symbols whose definition ranges contain a reference to this symbol.
9
9
  * Outgoing: symbols referenced within this symbol's definition range.
10
10
  */
11
- declare function callGraph(db: ScipDatabase, symbolPattern: string): CallGraphResult | null;
11
+ declare function callGraph(db: ScipDatabase, symbolPattern: string, opts?: {
12
+ semantic?: boolean;
13
+ }): CallGraphResult | null;
12
14
 
13
15
  export { callGraph };
@@ -1,2 +1,2 @@
1
- import{a}from"../chunk-E47WMJ5F.js";import"../chunk-GS55K4WJ.js";import"../chunk-6FLGPRBR.js";import"../chunk-G47V5V3U.js";import"../chunk-QYWGC7JV.js";import"../chunk-KYGNCIJ6.js";export{a as callGraph};
1
+ import{a}from"../chunk-NRAJIFQA.js";import"../chunk-EHEZLULQ.js";import"../chunk-33Z6HQBX.js";import"../chunk-67OMD56K.js";import"../chunk-BT36WY5B.js";import"../chunk-NLJCXHFU.js";export{a as callGraph};
2
2
  //# sourceMappingURL=call-graph.js.map
@@ -1,4 +1,4 @@
1
- import { S as ScipDatabase, b as ChangeSurfaceResult } from '../db-DdlToIC-.js';
1
+ import { S as ScipDatabase, b as ChangeSurfaceResult } from '../db-Rx8Ho_JF.js';
2
2
  import 'better-sqlite3';
3
3
 
4
4
  /**
@@ -8,6 +8,8 @@ import 'better-sqlite3';
8
8
  * Symbol ranges come from getDefinitionsForFile so they are source-corrected
9
9
  * and match `scip symbols` output.
10
10
  */
11
- declare function changeSurface(db: ScipDatabase, filePattern: string): ChangeSurfaceResult | null;
11
+ declare function changeSurface(db: ScipDatabase, filePattern: string, opts?: {
12
+ semantic?: boolean;
13
+ }): ChangeSurfaceResult | null;
12
14
 
13
15
  export { changeSurface };
@@ -1,2 +1,2 @@
1
- import{a}from"../chunk-EEA3R37V.js";import"../chunk-55ZJ2FCW.js";import"../chunk-SVUVC5VS.js";import"../chunk-TYRPQE6R.js";import"../chunk-7EQ4J66C.js";import"../chunk-WPY46NIL.js";import"../chunk-GS55K4WJ.js";import"../chunk-6FLGPRBR.js";import"../chunk-G47V5V3U.js";import"../chunk-QYWGC7JV.js";import"../chunk-KYGNCIJ6.js";export{a as changeSurface};
1
+ import{a}from"../chunk-3PKPUCIJ.js";import"../chunk-LLDPR3DG.js";import"../chunk-LNUZWWWL.js";import"../chunk-IIKNAXAE.js";import"../chunk-JMASYYSW.js";import"../chunk-5IRX5I64.js";import"../chunk-EHEZLULQ.js";import"../chunk-33Z6HQBX.js";import"../chunk-67OMD56K.js";import"../chunk-BT36WY5B.js";import"../chunk-NLJCXHFU.js";export{a as changeSurface};
2
2
  //# sourceMappingURL=change-surface.js.map
@@ -1,4 +1,4 @@
1
- import { S as ScipDatabase, c as CodeResult } from '../db-DdlToIC-.js';
1
+ import { S as ScipDatabase, c as CodeResult } from '../db-Rx8Ho_JF.js';
2
2
  import 'better-sqlite3';
3
3
 
4
4
  /**
@@ -1,2 +1,2 @@
1
- import{a}from"../chunk-KQWFRAQI.js";import"../chunk-55ZJ2FCW.js";import"../chunk-QYWGC7JV.js";import"../chunk-KYGNCIJ6.js";export{a as code};
1
+ import{a}from"../chunk-V4WRHJU3.js";import"../chunk-LLDPR3DG.js";import"../chunk-BT36WY5B.js";import"../chunk-NLJCXHFU.js";export{a as code};
2
2
  //# sourceMappingURL=code.js.map
@@ -1,4 +1,4 @@
1
- import { S as ScipDatabase, d as ComplexityHotspot } from '../db-DdlToIC-.js';
1
+ import { S as ScipDatabase, d as ComplexityHotspot } from '../db-Rx8Ho_JF.js';
2
2
  import 'better-sqlite3';
3
3
 
4
4
  /**
@@ -17,6 +17,7 @@ declare function complexityHotspots(db: ScipDatabase, opts?: {
17
17
  minLoc?: number;
18
18
  limit?: number;
19
19
  scanLimit?: number;
20
+ semantic?: boolean;
20
21
  }): ComplexityHotspot[];
21
22
 
22
23
  export { complexityHotspots };
@@ -1,2 +1,2 @@
1
- import{a}from"../chunk-ABLXPGAZ.js";import"../chunk-SVUVC5VS.js";import"../chunk-TYRPQE6R.js";import"../chunk-7EQ4J66C.js";import"../chunk-WPY46NIL.js";import"../chunk-GS55K4WJ.js";import"../chunk-6FLGPRBR.js";import"../chunk-G47V5V3U.js";import"../chunk-QYWGC7JV.js";import"../chunk-KYGNCIJ6.js";export{a as complexityHotspots};
1
+ import{a}from"../chunk-SHGPRVWH.js";import"../chunk-LNUZWWWL.js";import"../chunk-IIKNAXAE.js";import"../chunk-JMASYYSW.js";import"../chunk-5IRX5I64.js";import"../chunk-EHEZLULQ.js";import"../chunk-33Z6HQBX.js";import"../chunk-67OMD56K.js";import"../chunk-BT36WY5B.js";import"../chunk-NLJCXHFU.js";export{a as complexityHotspots};
2
2
  //# sourceMappingURL=complexity-hotspots.js.map