scip-query 0.6.7 → 0.7.0
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.
- package/README.md +3 -1
- package/dist/augment-vue-worker.js +1 -1
- package/dist/chunk-23YIGCYF.js +25 -0
- package/dist/{chunk-KQWFRAQI.js → chunk-2IYEIFPP.js} +6 -6
- package/dist/chunk-2JEFS2YJ.js +2 -0
- package/dist/chunk-33SSUPCB.js +7 -0
- package/dist/chunk-3GNFUVFA.js +2 -0
- package/dist/{chunk-ZNNCDAYX.js → chunk-3OUC276S.js} +2 -2
- package/dist/{chunk-PQTGBYXV.js → chunk-4STLJYHI.js} +4 -4
- package/dist/chunk-563HLCDW.js +35 -0
- package/dist/chunk-5TT47UMX.js +44 -0
- package/dist/chunk-6H2XIIPY.js +71 -0
- package/dist/{chunk-HTJ5BOYP.js → chunk-72JOIFXL.js} +3 -3
- package/dist/chunk-7H4RJ4MC.js +2 -0
- package/dist/chunk-7O4MJYIW.js +63 -0
- package/dist/chunk-7OX2O53H.js +62 -0
- package/dist/chunk-A2AVLALL.js +2 -0
- package/dist/chunk-AQYBOORI.js +2 -0
- package/dist/chunk-ARBZM2NF.js +34 -0
- package/dist/{chunk-2CC7RA6B.js → chunk-BI4F6GXI.js} +2 -2
- package/dist/chunk-BOVNTAKQ.js +3 -0
- package/dist/chunk-CKIO6SVS.js +2 -0
- package/dist/chunk-D6Z67MZL.js +2 -0
- package/dist/chunk-DFK54IRN.js +2 -0
- package/dist/chunk-FD37DBTD.js +2 -0
- package/dist/chunk-FOQQDXE7.js +2 -0
- package/dist/chunk-GAQGJ52J.js +11 -0
- package/dist/chunk-IODTPF5H.js +20 -0
- package/dist/chunk-J6Z5YKGQ.js +4 -0
- package/dist/chunk-JB4PUN5S.js +40 -0
- package/dist/chunk-JTXKS5GK.js +3 -0
- package/dist/chunk-KJ3ZJIE5.js +2 -0
- package/dist/chunk-KJ6CW6EK.js +2 -0
- package/dist/{chunk-2R7OKZE5.js → chunk-KNA6Z7JB.js} +3 -3
- package/dist/{chunk-FYO3FPFH.js → chunk-LDV2B7ET.js} +8 -8
- package/dist/chunk-LWYIGRHR.js +5 -0
- package/dist/chunk-MDAYGS6T.js +2 -0
- package/dist/chunk-MX6F756F.js +2 -0
- package/dist/chunk-NHDPYW7O.js +2 -0
- package/dist/{chunk-TYRPQE6R.js → chunk-NKJKI6SE.js} +2 -2
- package/dist/chunk-NN3O7TPH.js +8 -0
- package/dist/chunk-NSTZMBAB.js +18 -0
- package/dist/chunk-NYEMZHUC.js +6 -0
- package/dist/chunk-OHEIZWIA.js +4 -0
- package/dist/chunk-PG3ZI5IH.js +2 -0
- package/dist/chunk-QAEDNTY7.js +2 -0
- package/dist/chunk-QE6MGGUY.js +2 -0
- package/dist/chunk-QPRIYXH4.js +2 -0
- package/dist/chunk-QWJBIBE6.js +3 -0
- package/dist/chunk-RCJEFQOK.js +4 -0
- package/dist/chunk-ROOHENEP.js +61 -0
- package/dist/{chunk-2YA36CXK.js → chunk-ROZNBWIF.js} +2 -2
- package/dist/chunk-TGK5DFBJ.js +2 -0
- package/dist/chunk-TKDJQ2WD.js +59 -0
- package/dist/chunk-TRNAQABL.js +7 -0
- package/dist/chunk-U75WH4XG.js +2 -0
- package/dist/chunk-V53J46BX.js +2 -0
- package/dist/chunk-V76FCF5F.js +2 -0
- package/dist/chunk-VUBQBW7H.js +16 -0
- package/dist/chunk-WJQY2LGT.js +2 -0
- package/dist/{chunk-ILQSK2KJ.js → chunk-WODJHE6Z.js} +3 -3
- package/dist/{chunk-RRWPHKZA.js → chunk-WPLKHAH7.js} +4 -4
- package/dist/chunk-XO6R3X5J.js +2 -0
- package/dist/chunk-YSZNAG4G.js +2 -0
- package/dist/chunk-ZNUPGRPR.js +3 -0
- package/dist/{chunk-OCQN6WF4.js → chunk-ZXFTC5ET.js} +4 -4
- package/dist/cli.js +361 -505
- package/dist/config-types-CGIeLEpY.d.ts +108 -0
- package/dist/db-DdTPetj5.d.ts +69 -0
- package/dist/health-x7B4Xu_6.d.ts +119 -0
- package/dist/index.d.ts +109 -336
- package/dist/index.js +3 -131
- package/dist/postinstall.js +1 -1
- package/dist/queries/affected.d.ts +9 -2
- package/dist/queries/affected.js +1 -1
- package/dist/queries/bottlenecks.d.ts +14 -2
- package/dist/queries/bottlenecks.js +1 -1
- package/dist/queries/by-kind.d.ts +12 -2
- package/dist/queries/by-kind.js +1 -1
- package/dist/queries/call-graph.d.ts +22 -3
- package/dist/queries/call-graph.js +1 -1
- package/dist/queries/change-surface.d.ts +19 -3
- package/dist/queries/change-surface.js +1 -1
- package/dist/queries/code.d.ts +12 -2
- package/dist/queries/code.js +1 -1
- package/dist/queries/complexity-hotspots.d.ts +16 -2
- package/dist/queries/complexity-hotspots.js +1 -1
- package/dist/queries/complexity.d.ts +22 -3
- package/dist/queries/complexity.js +1 -1
- package/dist/queries/convergence.d.ts +25 -3
- package/dist/queries/convergence.js +1 -1
- package/dist/queries/coupling.d.ts +8 -2
- package/dist/queries/coupling.js +1 -1
- package/dist/queries/cycles.d.ts +16 -2
- package/dist/queries/cycles.js +1 -1
- package/dist/queries/dataflow.d.ts +35 -3
- package/dist/queries/dataflow.js +1 -1
- package/dist/queries/dead.d.ts +34 -2
- package/dist/queries/dead.js +1 -1
- package/dist/queries/deep-chains.d.ts +8 -2
- package/dist/queries/deep-chains.js +1 -1
- package/dist/queries/deps.d.ts +6 -2
- package/dist/queries/deps.js +1 -1
- package/dist/queries/diff-impact.d.ts +22 -2
- package/dist/queries/diff-impact.js +1 -1
- package/dist/queries/drift.d.ts +19 -2
- package/dist/queries/drift.js +1 -1
- package/dist/queries/extract-candidates.d.ts +20 -2
- package/dist/queries/extract-candidates.js +1 -1
- package/dist/queries/fan.d.ts +7 -2
- package/dist/queries/fan.js +1 -1
- package/dist/queries/files.d.ts +6 -2
- package/dist/queries/files.js +1 -1
- package/dist/queries/health.d.ts +4 -81
- package/dist/queries/health.js +1 -1
- package/dist/queries/hierarchy.d.ts +8 -2
- package/dist/queries/hierarchy.js +1 -1
- package/dist/queries/hotspots.d.ts +10 -2
- package/dist/queries/hotspots.js +1 -1
- package/dist/queries/imports.d.ts +19 -4
- package/dist/queries/imports.js +1 -1
- package/dist/queries/index.d.ts +45 -44
- package/dist/queries/index.js +1 -1
- package/dist/queries/isolated.d.ts +13 -2
- package/dist/queries/isolated.js +1 -1
- package/dist/queries/members.d.ts +10 -2
- package/dist/queries/members.js +1 -1
- package/dist/queries/methods.d.ts +8 -2
- package/dist/queries/methods.js +1 -1
- package/dist/queries/outline.d.ts +10 -2
- package/dist/queries/outline.js +1 -1
- package/dist/queries/passthrough-candidates.d.ts +15 -2
- package/dist/queries/passthrough-candidates.js +1 -1
- package/dist/queries/redundant-reexports.d.ts +13 -2
- package/dist/queries/redundant-reexports.js +1 -1
- package/dist/queries/refs.d.ts +10 -3
- package/dist/queries/refs.js +1 -1
- package/dist/queries/similar-chains.d.ts +21 -2
- package/dist/queries/similar-chains.js +1 -1
- package/dist/queries/similar-files.d.ts +12 -2
- package/dist/queries/similar-files.js +1 -1
- package/dist/queries/similar-signatures.d.ts +18 -2
- package/dist/queries/similar-signatures.js +1 -1
- package/dist/queries/similar.d.ts +24 -2
- package/dist/queries/similar.js +1 -1
- package/dist/queries/slice.d.ts +17 -2
- package/dist/queries/slice.js +1 -1
- package/dist/queries/stale-abstractions.d.ts +37 -3
- package/dist/queries/stale-abstractions.js +1 -1
- package/dist/queries/stats.d.ts +11 -2
- package/dist/queries/stats.js +1 -1
- package/dist/queries/surface.d.ts +8 -2
- package/dist/queries/surface.js +1 -1
- package/dist/queries/symbols.d.ts +10 -2
- package/dist/queries/symbols.js +1 -1
- package/dist/queries/system.d.ts +10 -2
- package/dist/queries/system.js +1 -1
- package/dist/queries/trace.d.ts +21 -3
- package/dist/queries/trace.js +1 -1
- package/dist/queries/wrapper-candidates.d.ts +15 -2
- package/dist/queries/wrapper-candidates.js +1 -1
- package/dist/reindex-worker.js +10 -10
- package/dist/reindex.d.ts +153 -0
- package/dist/reindex.js +69 -0
- package/dist/runtime.d.ts +108 -0
- package/dist/runtime.js +3 -0
- package/dist/scip-cli-a-xOztiK.d.ts +20 -0
- package/package.json +184 -4
- package/dist/chunk-2AUZ3PLO.js +0 -2
- package/dist/chunk-3A2M7AF3.js +0 -4
- package/dist/chunk-3EJRPTTB.js +0 -2
- package/dist/chunk-3SWWYJPB.js +0 -6
- package/dist/chunk-4M4FEWBL.js +0 -7
- package/dist/chunk-4Y6KUJDO.js +0 -39
- package/dist/chunk-55ZJ2FCW.js +0 -6
- package/dist/chunk-6FLGPRBR.js +0 -5
- package/dist/chunk-6XRB6ATD.js +0 -16
- package/dist/chunk-7EQ4J66C.js +0 -2
- package/dist/chunk-7TGEXAN5.js +0 -25
- package/dist/chunk-ABLXPGAZ.js +0 -2
- package/dist/chunk-BG7YU4DJ.js +0 -2
- package/dist/chunk-D2R6IIEO.js +0 -2
- package/dist/chunk-E47WMJ5F.js +0 -2
- package/dist/chunk-EEA3R37V.js +0 -11
- package/dist/chunk-FAN2CVZT.js +0 -2
- package/dist/chunk-FVH3Y44U.js +0 -1
- package/dist/chunk-G47V5V3U.js +0 -90
- package/dist/chunk-GS55K4WJ.js +0 -85
- package/dist/chunk-H4DXD2FB.js +0 -5
- package/dist/chunk-HADDFTMU.js +0 -2
- package/dist/chunk-IARIBTCL.js +0 -2
- package/dist/chunk-IBWYWAWE.js +0 -70
- package/dist/chunk-JVMXNDRU.js +0 -2
- package/dist/chunk-K345WFTU.js +0 -2
- package/dist/chunk-K6ULLR7M.js +0 -19
- package/dist/chunk-KAM4C6ZD.js +0 -4
- package/dist/chunk-KCC3GMCX.js +0 -2
- package/dist/chunk-KRVRD6KZ.js +0 -5
- package/dist/chunk-KYGNCIJ6.js +0 -84
- package/dist/chunk-LHLXHH43.js +0 -2
- package/dist/chunk-LJ2YWNQF.js +0 -2
- package/dist/chunk-M7GBLQG4.js +0 -7
- package/dist/chunk-MEVK6R7N.js +0 -2
- package/dist/chunk-QRYEOK3M.js +0 -2
- package/dist/chunk-QYWGC7JV.js +0 -114
- package/dist/chunk-R373SHXM.js +0 -2
- package/dist/chunk-RUAJV3TN.js +0 -2
- package/dist/chunk-S57GUI2T.js +0 -7
- package/dist/chunk-SVUVC5VS.js +0 -2
- package/dist/chunk-T426XELO.js +0 -12
- package/dist/chunk-TBJDUS4E.js +0 -71
- package/dist/chunk-TX7BHRMT.js +0 -2
- package/dist/chunk-WPY46NIL.js +0 -5
- package/dist/chunk-X3Z4KZNX.js +0 -2
- package/dist/db-DdlToIC-.d.ts +0 -835
- package/dist/queries/drift-policy.d.ts +0 -6
- package/dist/queries/drift-policy.js +0 -2
- package/dist/queries/health-cache-control.d.ts +0 -15
- package/dist/queries/health-cache-control.js +0 -2
package/dist/queries/surface.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a}from"../chunk-
|
|
1
|
+
import{a}from"../chunk-WODJHE6Z.js";import"../chunk-DFK54IRN.js";import"../chunk-QAEDNTY7.js";import"../chunk-NKJKI6SE.js";import"../chunk-IODTPF5H.js";import"../chunk-ARBZM2NF.js";import"../chunk-JB4PUN5S.js";import"../chunk-7O4MJYIW.js";import"../chunk-ZNUPGRPR.js";import"../chunk-RCJEFQOK.js";import"../chunk-BOVNTAKQ.js";import"../chunk-KJ6CW6EK.js";import"../chunk-7OX2O53H.js";import"../chunk-5TT47UMX.js";import"../chunk-NHDPYW7O.js";import"../chunk-NN3O7TPH.js";export{a as surface};
|
|
2
2
|
//# sourceMappingURL=surface.js.map
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
import { S as ScipDatabase
|
|
1
|
+
import { S as ScipDatabase } from '../db-DdTPetj5.js';
|
|
2
2
|
import 'better-sqlite3';
|
|
3
|
+
import '../config-types-CGIeLEpY.js';
|
|
3
4
|
|
|
5
|
+
interface SymbolResult {
|
|
6
|
+
startLine: number;
|
|
7
|
+
endLine: number;
|
|
8
|
+
symbol: string;
|
|
9
|
+
shortName: string;
|
|
10
|
+
signature: string | null;
|
|
11
|
+
}
|
|
4
12
|
declare function symbols(db: ScipDatabase, filePattern: string): SymbolResult[];
|
|
5
13
|
|
|
6
|
-
export { symbols };
|
|
14
|
+
export { type SymbolResult, symbols };
|
package/dist/queries/symbols.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a}from"../chunk-
|
|
1
|
+
import{a}from"../chunk-CKIO6SVS.js";import"../chunk-DFK54IRN.js";import"../chunk-ZNUPGRPR.js";import"../chunk-7OX2O53H.js";import"../chunk-5TT47UMX.js";import"../chunk-NHDPYW7O.js";import"../chunk-NN3O7TPH.js";export{a as symbols};
|
|
2
2
|
//# sourceMappingURL=symbols.js.map
|
package/dist/queries/system.d.ts
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
import { S as ScipDatabase
|
|
1
|
+
import { S as ScipDatabase } from '../db-DdTPetj5.js';
|
|
2
|
+
import { SymbolResult } from './symbols.js';
|
|
2
3
|
import 'better-sqlite3';
|
|
4
|
+
import '../config-types-CGIeLEpY.js';
|
|
3
5
|
|
|
6
|
+
interface SystemResult {
|
|
7
|
+
files: string[];
|
|
8
|
+
symbols: SymbolResult[];
|
|
9
|
+
dependsOn: string[];
|
|
10
|
+
dependedOnBy: string[];
|
|
11
|
+
}
|
|
4
12
|
/** Full system map for a module path: files, symbols, deps in/out.
|
|
5
13
|
*
|
|
6
14
|
* Exported-symbol ranges come from getDefinitionsForFile so they are
|
|
@@ -8,4 +16,4 @@ import 'better-sqlite3';
|
|
|
8
16
|
*/
|
|
9
17
|
declare function system(db: ScipDatabase, modulePattern: string): SystemResult;
|
|
10
18
|
|
|
11
|
-
export { system };
|
|
19
|
+
export { type SystemResult, system };
|
package/dist/queries/system.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a}from"../chunk-
|
|
1
|
+
import{a}from"../chunk-WPLKHAH7.js";import"../chunk-DFK54IRN.js";import"../chunk-ZNUPGRPR.js";import"../chunk-7OX2O53H.js";import"../chunk-5TT47UMX.js";import"../chunk-NHDPYW7O.js";import"../chunk-NN3O7TPH.js";export{a as system};
|
|
2
2
|
//# sourceMappingURL=system.js.map
|
package/dist/queries/trace.d.ts
CHANGED
|
@@ -1,6 +1,24 @@
|
|
|
1
|
-
import { S as ScipDatabase
|
|
1
|
+
import { S as ScipDatabase } from '../db-DdTPetj5.js';
|
|
2
2
|
import 'better-sqlite3';
|
|
3
|
+
import '../config-types-CGIeLEpY.js';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
interface TraceResult {
|
|
6
|
+
definitions: Array<{
|
|
7
|
+
relativePath: string;
|
|
8
|
+
startLine: number;
|
|
9
|
+
endLine: number;
|
|
10
|
+
signature: string | null;
|
|
11
|
+
source: string | null;
|
|
12
|
+
}>;
|
|
13
|
+
referencedBy: Array<{
|
|
14
|
+
relativePath: string;
|
|
15
|
+
line: number;
|
|
16
|
+
enclosingSymbol: string | null;
|
|
17
|
+
enclosingShort: string;
|
|
18
|
+
}>;
|
|
19
|
+
}
|
|
20
|
+
declare function trace(db: ScipDatabase, symbolPattern: string, opts?: {
|
|
21
|
+
semantic?: boolean;
|
|
22
|
+
}): TraceResult;
|
|
5
23
|
|
|
6
|
-
export { trace };
|
|
24
|
+
export { type TraceResult, trace };
|
package/dist/queries/trace.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a}from"../chunk-
|
|
1
|
+
import{a}from"../chunk-J6Z5YKGQ.js";import"../chunk-JB4PUN5S.js";import"../chunk-7O4MJYIW.js";import"../chunk-ZNUPGRPR.js";import"../chunk-RCJEFQOK.js";import"../chunk-BOVNTAKQ.js";import"../chunk-KJ6CW6EK.js";import"../chunk-7OX2O53H.js";import"../chunk-5TT47UMX.js";import"../chunk-NHDPYW7O.js";import"../chunk-NN3O7TPH.js";export{a as trace};
|
|
2
2
|
//# sourceMappingURL=trace.js.map
|
|
@@ -1,6 +1,18 @@
|
|
|
1
|
-
import { S as ScipDatabase
|
|
1
|
+
import { S as ScipDatabase } from '../db-DdTPetj5.js';
|
|
2
2
|
import 'better-sqlite3';
|
|
3
|
+
import '../config-types-CGIeLEpY.js';
|
|
3
4
|
|
|
5
|
+
interface WrapperCandidate {
|
|
6
|
+
symbol: string;
|
|
7
|
+
shortName: string;
|
|
8
|
+
file: string;
|
|
9
|
+
startLine: number;
|
|
10
|
+
endLine: number;
|
|
11
|
+
loc: number;
|
|
12
|
+
singleCaller: string;
|
|
13
|
+
singleCallerShort: string;
|
|
14
|
+
callerFanIn: number;
|
|
15
|
+
}
|
|
4
16
|
/**
|
|
5
17
|
* Find wrapper candidates: symbols called by only one other symbol.
|
|
6
18
|
*
|
|
@@ -13,6 +25,7 @@ declare function wrapperCandidates(db: ScipDatabase, opts?: {
|
|
|
13
25
|
maxLoc?: number;
|
|
14
26
|
limit?: number;
|
|
15
27
|
scanLimit?: number;
|
|
28
|
+
semantic?: boolean;
|
|
16
29
|
}): WrapperCandidate[];
|
|
17
30
|
|
|
18
|
-
export { wrapperCandidates };
|
|
31
|
+
export { type WrapperCandidate, wrapperCandidates };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a}from"../chunk-
|
|
1
|
+
import{a}from"../chunk-TRNAQABL.js";import"../chunk-JTXKS5GK.js";import"../chunk-V76FCF5F.js";import"../chunk-MX6F756F.js";import"../chunk-QAEDNTY7.js";import"../chunk-NKJKI6SE.js";import"../chunk-IODTPF5H.js";import"../chunk-ARBZM2NF.js";import"../chunk-JB4PUN5S.js";import"../chunk-7O4MJYIW.js";import"../chunk-ZNUPGRPR.js";import"../chunk-RCJEFQOK.js";import"../chunk-BOVNTAKQ.js";import"../chunk-KJ6CW6EK.js";import"../chunk-7OX2O53H.js";import"../chunk-5TT47UMX.js";import"../chunk-NHDPYW7O.js";import"../chunk-NN3O7TPH.js";export{a as wrapperCandidates};
|
|
2
2
|
//# sourceMappingURL=wrapper-candidates.js.map
|
package/dist/reindex-worker.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import{a as
|
|
2
|
-
`)){if(!r)continue;let a=N(r).toLowerCase();a&&t.add(a)}return t}catch{return null}}function ye(e,n){return n?.length?n.some(t=>e.has(t)):!1}function B(e,n){let t=e.indexOf(n);t!==-1&&e.splice(t,1)}import{existsSync as _,readdirSync as be}from"fs";import{join as R}from"path";var Se={typescript:{language:"typescript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,pnpmWorkspaces:n,indexerBinary:t})=>{let r=["index","--infer-tsconfig","--output",e,"--no-progress-bar"];return n&&r.splice(1,0,"--pnpm-workspaces"),{binary:t,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:n})=>({binary:n,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:n})=>({binary:n,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:n})=>({binary:"scip-dotnet",args:["index",T(e,[".sln",".csproj"])??e,"--output",n,"--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:n})=>({binary:"scip-dotnet",args:["index",T(e,[".sln",".vbproj"])??e,"--output",n,"--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:n})=>({binary:e,args:["--output",n]}),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:n})=>{let t=R(e,"vendor","bin","scip-php"),r=R(e,"vendor","davidrjenni","scip-php","bin","scip-php");return{binary:"php",args:["-d","error_reporting=E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED",_(r)?r:_(t)?t:n]}},defaultOutputPath:"index.scip",markerFiles:["composer.json"],installMethods:[],installUrl:"https://github.com/davidrjenni/scip-php/releases"}};function U(e){return Se[e]}function T(e,n){let t;try{t=be(e)}catch{return null}for(let r of t)if(n.some(a=>r.endsWith(a)))return R(e,r);return null}import{readFileSync as Pe,writeFileSync as ve}from"fs";import{create as D}from"@bufbuild/protobuf";import{deserializeSCIP as Ie,serializeSCIP as ke,DocumentSchema as Re,IndexSchema as De,SymbolInformationSchema as Ce}from"@c4312/scip";function Oe(e){if(e.length===0)throw new Error("Cannot merge zero SCIP indexes");if(e.length===1)return e[0];let n=je(e),t=Le(e.flatMap(a=>a.documents??[])),r=q(e.flatMap(a=>a.externalSymbols??[]));return D(De,{metadata:n,documents:t,externalSymbols:r})}function W(e,n){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let t=e.map(a=>Ie(Pe(a))),r=Oe(t);return ve(n,Buffer.from(ke(r))),{documentCount:r.documents.length,externalSymbolCount:r.externalSymbols.length,inputCount:e.length}}function je(e){let n=e[0]?.metadata;if(!n)return;let t=n.projectRoot;for(let r of e.slice(1)){let a=r.metadata?.projectRoot;if(t&&a&&a!==t)throw new Error(`Cannot merge SCIP indexes with different project roots: ${t} vs ${a}`)}return n}function Le(e){let n=new Map;for(let t of e){let r=n.get(t.relativePath);if(!r){n.set(t.relativePath,t);continue}n.set(t.relativePath,D(Re,{language:r.language||t.language,relativePath:r.relativePath||t.relativePath,occurrences:[...r.occurrences,...t.occurrences],symbols:q([...r.symbols,...t.symbols]),text:Ee(r.text,t.text),positionEncoding:r.positionEncoding||t.positionEncoding}))}return[...n.values()]}function q(e){let n=new Map;for(let t of e){let r=n.get(t.symbol);if(!r){n.set(t.symbol,t);continue}n.set(t.symbol,D(Ce,{symbol:r.symbol,documentation:$e([...r.documentation,...t.documentation]),relationships:we([...r.relationships,...t.relationships]),kind:r.kind||t.kind,displayName:r.displayName||t.displayName,enclosingSymbol:r.enclosingSymbol||t.enclosingSymbol,signatureDocumentation:r.signatureDocumentation??t.signatureDocumentation}))}return[...n.values()]}function we(e){let n=new Set,t=[];for(let r of e){let a=[r.symbol,r.isReference?"1":"0",r.isImplementation?"1":"0",r.isTypeDefinition?"1":"0",r.isDefinition?"1":"0"].join("|");n.has(a)||(n.add(a),t.push(r))}return t}function Ee(e,n){return e?n?e.length>=n.length?e:n:e:n}function $e(e){return[...new Set(e)]}import{readFileSync as Be,writeFileSync as Me}from"fs";import{create as z}from"@bufbuild/protobuf";import{deserializeSCIP as Ne,DocumentSchema as Fe,IndexSchema as Ae,serializeSCIP as _e,SymbolRole as Te}from"@c4312/scip";function J(e){let n;try{n=Ne(Be(e))}catch{return{removedDefinitionOccurrences:0,touchedDocuments:0}}let t=Ue(n);return t.removedDefinitionOccurrences>0&&Me(e,Buffer.from(_e(t.index))),{removedDefinitionOccurrences:t.removedDefinitionOccurrences,touchedDocuments:t.touchedDocuments}}function Ue(e){let n=new Set;for(let i of e.documents)for(let s of i.symbols)s.symbol&&n.add(s.symbol);for(let i of e.externalSymbols)i.symbol&&n.add(i.symbol);let t=0,r=0,a=[];for(let i of e.documents){let s=i.occurrences.filter(o=>(o.symbolRoles&Te.Definition)===0||n.has(o.symbol)?!0:(t+=1,!1));if(s.length===i.occurrences.length){a.push(i);continue}r+=1,a.push(z(Fe,{language:i.language,relativePath:i.relativePath,occurrences:s,symbols:i.symbols,text:i.text,positionEncoding:i.positionEncoding}))}return{index:t===0?e:z(Ae,{metadata:e.metadata,documents:a,externalSymbols:e.externalSymbols}),removedDefinitionOccurrences:t,touchedDocuments:r}}import{execFileSync as S}from"child_process";import{existsSync as C,readFileSync as We}from"fs";import{createRequire as qe}from"module";import{platform as H}from"os";import{dirname as G,join as b}from"path";var ze=qe(import.meta.url),Je=H()==="win32";function x(e){let n=Je?"where":"which";try{return S(n,[e],{stdio:"pipe"}),!0}catch{return!1}}function O(e){return[e.indexerBinary,...e.binaryAliases??[]]}function j(e){let n=O(e);return n.length===1?n[0]:n.join(" or ")}function P(e){for(let n of O(e))if(x(n))return n;return He(e)}function X(e){return P(e)!==null||Ge(e)}function Ge(e){return Q(e)!==null}function He(e){let n=Q(e);if(!n)return null;let r=JSON.parse(We(n,"utf8")).bin;if(!r)return null;if(typeof r=="string")return b(G(n),r);for(let a of O(e)){let i=r[a];if(i)return b(G(n),i)}return null}function Q(e){if(!e.bundledNpmPackage)return null;try{return ze.resolve(`${e.bundledNpmPackage}/package.json`)}catch{return null}}function K(e,n){for(let t of e.projectLocalBinaries??[]){let r=b(n,t);if(C(r))return r}return null}function V(e,n=process.env,t=e.indexerBinary){if(e.indexerBinary!=="scip-dotnet"||Z(t,n))return n;let r=Xe(t,n);return r?{...n,DOTNET_ROOT:r}:n}function Y(e,n){let t=e.installMethods,r=j(e);if(!t?.length)return n(`No auto-install method available for ${r}.`),e.installUrl&&n(`Install manually from: ${e.installUrl}`),!1;for(let a of t)if(x(a.prerequisite)){n(`Installing ${r} via ${a.label}...`);try{S(a.binary,a.args,{stdio:"inherit",timeout:3e5,env:process.env});let i=P(e);if(i){let s=i===e.indexerBinary?"":` (using ${i})`;return n(`Successfully installed ${r} via ${a.label}${s}`),!0}n(`${a.label} command completed but ${r} was not found on PATH`)}catch(i){let s=i instanceof Error?i.message:String(i);n(`${a.label} install failed: ${s}`)}}return n(`Could not auto-install ${r}.`),e.installUrl&&n(`Install manually from: ${e.installUrl}`),!1}function Xe(e,n){for(let t of Qe(n))if(Z(e,{...n,DOTNET_ROOT:t}))return t;return null}function Qe(e){let n=[],t=e.DOTNET_ROOT;if(t&&C(t)&&n.push(t),H()==="darwin"&&x("brew"))try{let r=S("brew",["--prefix","dotnet@9"],{stdio:"pipe",env:e}).toString().trim(),a=b(r,"libexec");C(a)&&!n.includes(a)&&n.push(a)}catch{}return n}function Z(e,n){try{return S(e,["--version"],{stdio:"pipe",env:n}),!0}catch{return!1}}async function te(e){let{projectRoot:n,maxHeapMb:t=8192,onStatus:r=console.log,skipAutoInstall:a=!1}=e,i=an(e),s=Date.now();ee(d(i.outputScip),{recursive:!0}),ee(d(i.outputDb),{recursive:!0});let o=e.languages??A(n);if(o.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: ${o.join(", ")}`);let g=On(n,o,{pnpmWorkspaces:e.pnpmWorkspaces}),u=vn(c(d(i.outputDb),"index.lock")),p=null;try{let l=sn({opts:e,paths:i,languages:o,fingerprint:g,start:s,onStatus:r});if(l)return l;pn(a,r);let y=on(i);return p=y.runDir,await un({opts:e,languages:o,projectRoot:n,paths:i,tempPaths:y,fingerprint:g,start:s,maxHeapMb:t,skipAutoInstall:a,onStatus:r})}finally{p&&h(p,{recursive:!0,force:!0}),u()}}function an(e){let n=e.outputScip??c(e.projectRoot,"index.scip"),t=e.outputDb??c(e.projectRoot,"index.db");return{outputScip:n,outputDb:t,metaPath:c(d(t),"meta.json")}}function sn(e){if(e.opts.skipIfUnchanged===!1||!m(e.paths.outputScip)||!m(e.paths.outputDb)||!jn(e.paths.metaPath,e.fingerprint))return null;k({projectRoot:e.opts.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus});let n=Date.now()-e.start;return e.onStatus(`Index unchanged; reused existing SQLite index in ${(n/1e3).toFixed(1)}s`),{languages:e.languages,indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:n,reused:!0,skipped:[]}}function on(e){let n=Ze(c(d(e.outputDb),"reindex-"));return{runDir:n,tempOutputScip:c(n,I(e.outputScip)),tempOutputDb:c(n,I(e.outputDb)),tempMetaPath:c(n,I(e.metaPath))}}async function un(e){let n={...process.env,NODE_OPTIONS:`--max-old-space-size=${e.maxHeapMb}`},{indexedOutputs:t,skippedLanguages:r}=await ln(e,n);cn(e,n,t,r);let a=Date.now()-e.start;return e.onStatus(`Done in ${(a/1e3).toFixed(1)}s`),{languages:t.map(i=>i.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:a,reused:!1,skipped:r}}async function ln(e,n){let{preparedRuns:t,skippedLanguages:r}=gn({languages:e.languages,tempOutputScip:e.tempPaths.tempOutputScip,projectRoot:e.projectRoot,env:n,skipAutoInstall:e.skipAutoInstall,pnpmWorkspaces:e.opts.pnpmWorkspaces,onStatus:e.onStatus}),a=await Rn(t,e.projectRoot,e.onStatus,e.opts.indexerConcurrency),{indexedOutputs:i}=mn(a,r);return fn(i,r,e.languages,e.opts.allowPartial,e.onStatus),{indexedOutputs:i,skippedLanguages:r}}function cn(e,n,t,r){hn(t,e.tempPaths.tempOutputScip,e.onStatus),xn(e.tempPaths.tempOutputScip,e.tempPaths.tempOutputDb,n,e.onStatus),k({projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,onStatus:e.onStatus}),Ln(e.tempPaths.tempMetaPath,{version:2,status:r.length===0?"complete":"partial",updatedAt:new Date().toISOString(),fingerprint:e.fingerprint,requestedLanguages:e.languages,indexedLanguages:t.map(a=>a.language),skipped:[...r]}),In({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 pn(e,n){if(!x("scip")){if(e)throw new Error(`The scip CLI is required but not found on PATH.
|
|
3
|
-
|
|
4
|
-
Install
|
|
1
|
+
import{a as P,b as N}from"./chunk-6H2XIIPY.js";import{a as m,e as M}from"./chunk-LWYIGRHR.js";import{execFileSync as ln}from"child_process";import{closeSync as pn,existsSync as E,mkdirSync as ie,mkdtempSync as cn,openSync as gn,readFileSync as dn,renameSync as $,rmSync as B,writeFileSync as ae}from"fs";import{basename as S,dirname as d,extname as mn,join as g}from"path";import{execFileSync as ge}from"child_process";import{existsSync as de,readdirSync as A}from"fs";import{extname as _,join as T}from"path";var me=new Set([".git",".hg",".svn",".idea",".vscode","node_modules","vendor","dist","build","target","bin","obj",".dart_tool",".gradle",".next",".venv","venv","__pycache__"]),fe=[{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 U(e){let n=[],t=he(e),r=Se(e);for(let i of fe){if(xe(e,i.files)){n.push(i.language);continue}if(ye(t,i.globs)){n.push(i.language);continue}ve(r,i.extensions)&&n.push(i.language)}return n.includes("typescript")&&F(n,"javascript"),n.includes("cpp")&&!r.has(".c")&&F(n,"c"),n}function he(e){try{return A(e)}catch{return[]}}function xe(e,n){return n?.length?n.some(t=>de(T(e,t))):!1}function ye(e,n){return n?.length?e.some(t=>n.some(r=>be(t,r))):!1}function be(e,n){if(n==="*")return!0;if(!n.includes("*"))return e===n;let[t,r]=n.split("*");return e.startsWith(t??"")&&e.endsWith(r??"")}function Se(e){let n=Pe(e);if(n)return n;let t=new Set,r=[e];for(;r.length>0;){let i=r.pop();if(!i)continue;let a;try{a=A(i,{withFileTypes:!0})}catch{continue}for(let s of a){if(s.name.startsWith(".")&&!s.name.endsWith("proj")&&!s.name.endsWith("sln")&&s.isDirectory())continue;let o=T(i,s.name);if(s.isDirectory()){me.has(s.name)||r.push(o);continue}let c=_(s.name).toLowerCase();c&&t.add(c)}}return t}function Pe(e){try{let n=ge("git",["-C",e,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:26214400,stdio:["ignore","pipe","ignore"]}),t=new Set;for(let r of n.split(`
|
|
2
|
+
`)){if(!r)continue;let i=_(r).toLowerCase();i&&t.add(i)}return t}catch{return null}}function ve(e,n){return n?.length?n.some(t=>e.has(t)):!1}function F(e,n){let t=e.indexOf(n);t!==-1&&e.splice(t,1)}import{existsSync as W,readdirSync as Ie}from"fs";import{join as v}from"path";var ke={typescript:{language:"typescript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,pnpmWorkspaces:n,indexerBinary:t})=>{let r=["index","--infer-tsconfig","--output",e,"--no-progress-bar"];return n&&r.splice(1,0,"--pnpm-workspaces"),{binary:t,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:n})=>({binary:n,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:n})=>({binary:n,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:n})=>({binary:"scip-dotnet",args:["index",q(e,[".sln",".csproj"])??e,"--output",n,"--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:n})=>({binary:"scip-dotnet",args:["index",q(e,[".sln",".vbproj"])??e,"--output",n,"--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:n})=>({binary:e,args:["--output",n]}),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:n})=>{let t=v(e,"vendor","bin","scip-php"),r=v(e,"vendor","davidrjenni","scip-php","bin","scip-php");return{binary:"php",args:["-d","error_reporting=E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED",W(r)?r:W(t)?t:n]}},defaultOutputPath:"index.scip",markerFiles:["composer.json"],installMethods:[],installUrl:"https://github.com/davidrjenni/scip-php/releases"}};function z(e){return ke[e]}function q(e,n){let t;try{t=Ie(e)}catch{return null}for(let r of t)if(n.some(i=>r.endsWith(i)))return v(e,r);return null}import{readFileSync as Re,writeFileSync as De}from"fs";import{create as I}from"@bufbuild/protobuf";import{deserializeSCIP as Ce,serializeSCIP as je,DocumentSchema as Oe,IndexSchema as Le,SymbolInformationSchema as we}from"@c4312/scip";function Ee(e){if(e.length===0)throw new Error("Cannot merge zero SCIP indexes");if(e.length===1)return e[0];let n=$e(e),t=Be(e.flatMap(i=>i.documents??[])),r=G(e.flatMap(i=>i.externalSymbols??[]));return I(Le,{metadata:n,documents:t,externalSymbols:r})}function J(e,n){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let t=e.map(i=>Ce(Re(i))),r=Ee(t);return De(n,Buffer.from(je(r))),{documentCount:r.documents.length,externalSymbolCount:r.externalSymbols.length,inputCount:e.length}}function $e(e){let n=e[0]?.metadata;if(!n)return;let t=n.projectRoot;for(let r of e.slice(1)){let i=r.metadata?.projectRoot;if(t&&i&&i!==t)throw new Error(`Cannot merge SCIP indexes with different project roots: ${t} vs ${i}`)}return n}function Be(e){let n=new Map;for(let t of e){let r=n.get(t.relativePath);if(!r){n.set(t.relativePath,t);continue}n.set(t.relativePath,I(Oe,{language:r.language||t.language,relativePath:r.relativePath||t.relativePath,occurrences:[...r.occurrences,...t.occurrences],symbols:G([...r.symbols,...t.symbols]),text:Ne(r.text,t.text),positionEncoding:r.positionEncoding||t.positionEncoding}))}return[...n.values()]}function G(e){let n=new Map;for(let t of e){let r=n.get(t.symbol);if(!r){n.set(t.symbol,t);continue}n.set(t.symbol,I(we,{symbol:r.symbol,documentation:Fe([...r.documentation,...t.documentation]),relationships:Me([...r.relationships,...t.relationships]),kind:r.kind||t.kind,displayName:r.displayName||t.displayName,enclosingSymbol:r.enclosingSymbol||t.enclosingSymbol,signatureDocumentation:r.signatureDocumentation??t.signatureDocumentation}))}return[...n.values()]}function Me(e){let n=new Set,t=[];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("|");n.has(i)||(n.add(i),t.push(r))}return t}function Ne(e,n){return e?n?e.length>=n.length?e:n:e:n}function Fe(e){return[...new Set(e)]}import{readFileSync as Ae,writeFileSync as _e}from"fs";import{create as H}from"@bufbuild/protobuf";import{deserializeSCIP as Te,DocumentSchema as Ue,IndexSchema as We,serializeSCIP as qe,SymbolRole as ze}from"@c4312/scip";function X(e){let n;try{n=Te(Ae(e))}catch{return{removedDefinitionOccurrences:0,touchedDocuments:0}}let t=Je(n);return t.removedDefinitionOccurrences>0&&_e(e,Buffer.from(qe(t.index))),{removedDefinitionOccurrences:t.removedDefinitionOccurrences,touchedDocuments:t.touchedDocuments}}function Je(e){let n=new Set;for(let a of e.documents)for(let s of a.symbols)s.symbol&&n.add(s.symbol);for(let a of e.externalSymbols)a.symbol&&n.add(a.symbol);let t=0,r=0,i=[];for(let a of e.documents){let s=a.occurrences.filter(o=>(o.symbolRoles&ze.Definition)===0||n.has(o.symbol)?!0:(t+=1,!1));if(s.length===a.occurrences.length){i.push(a);continue}r+=1,i.push(H(Ue,{language:a.language,relativePath:a.relativePath,occurrences:s,symbols:a.symbols,text:a.text,positionEncoding:a.positionEncoding}))}return{index:t===0?e:H(We,{metadata:e.metadata,documents:i,externalSymbols:e.externalSymbols}),removedDefinitionOccurrences:t,touchedDocuments:r}}import{execFile as Ge}from"child_process";import{existsSync as h,renameSync as R,rmSync as D}from"fs";import{cpus as He}from"os";import{join as Q}from"path";function Xe(e,n,t){if(!e.defaultOutputPath)return;let r=Q(n,e.defaultOutputPath);t!==r&&h(r)&&R(r,t)}function Qe(e,n,t){if(!e.defaultOutputPath)return null;let r=Q(n,e.defaultOutputPath);if(r===t)return null;let i=`${t}.default-output-backup`;return D(i,{force:!0}),h(r)?(R(r,i),{defaultOutputPath:r,backupPath:i}):{defaultOutputPath:r,backupPath:null}}function Ke(e){e&&(D(e.defaultOutputPath,{force:!0}),e.backupPath&&h(e.backupPath)&&R(e.backupPath,e.defaultOutputPath))}function Ve(e,n){if(e<=1)return 1;let t=Number(process.env.SCIP_QUERY_INDEXER_CONCURRENCY??0),r=Number.isFinite(n)&&n&&n>0?n:Number.isFinite(t)&&t>0?t:Math.min(2,Math.max(1,He().length-1));return Math.max(1,Math.min(e,Math.floor(r)))}async function K(e,n,t,r){let i=e.filter(u=>u.config.defaultOutputPath),a=e.filter(u=>!u.config.defaultOutputPath),s=[],o=Ve(a.length,r),c=await Ze(a,o,u=>k(u,n,t));if(o>1){let u=new Map;for(let p of c.filter(l=>l.skipped)){let l=a.find(f=>f.language===p.language);l&&(t(`Retrying ${l.language} indexer serially after parallel failure...`),u.set(l.language,await k(l,n,t)))}s.push(...c.map(p=>u.get(p.language)??p))}else s.push(...c);for(let u of i)s.push(await k(u,n,t));return s.sort((u,p)=>e.findIndex(l=>l.language===u.language)-e.findIndex(l=>l.language===p.language))}async function k(e,n,t){t(`Indexing ${e.language} with ${e.resolvedBinary}...`),D(e.scipPath,{force:!0});let r=Qe(e.config,n,e.scipPath);try{await Ye(e.binary,e.args,{cwd:n,env:e.env,maxBuffer:50*1024*1024}),Xe(e.config,n,e.scipPath)}catch(i){let a=i instanceof Error?i.message:String(i),s=`${e.resolvedBinary} indexer failed: ${a.split(`
|
|
3
|
+
`)[0]}`;return t(`Skipping ${e.language}: ${s}`),{language:e.language,scipPath:e.scipPath,skipped:{language:e.language,reason:s}}}finally{Ke(r)}if(!h(e.scipPath)){let i=`${e.resolvedBinary} indexer completed but did not produce ${e.scipPath}`;return t(`Skipping ${e.language}: ${i}`),{language:e.language,scipPath:e.scipPath,skipped:{language:e.language,reason:i}}}return{language:e.language,scipPath:e.scipPath}}function Ye(e,n,t){return new Promise((r,i)=>{Ge(e,[...n],t,a=>{a?i(a):r()})})}async function Ze(e,n,t){if(e.length===0)return[];let r=new Array(e.length),i=0,a=Math.max(1,Math.min(e.length,n)),s=Array.from({length:a},async()=>{for(;i<e.length;){let o=i++;r[o]=await t(e[o])}});return await Promise.all(s),r}import{execFileSync as j}from"child_process";import{existsSync as C,readFileSync as en}from"fs";import{createRequire as nn}from"module";import{platform as tn}from"os";import{dirname as V,join as x}from"path";var rn=nn(import.meta.url);function O(e){return[e.indexerBinary,...e.binaryAliases??[]]}function L(e){let n=O(e);return n.length===1?n[0]:n.join(" or ")}function y(e){for(let n of O(e))if(m(n))return n;return sn(e)}function Y(e){return y(e)!==null||an(e)}function an(e){return Z(e)!==null}function sn(e){let n=Z(e);if(!n)return null;let r=JSON.parse(en(n,"utf8")).bin;if(!r)return null;if(typeof r=="string")return x(V(n),r);for(let i of O(e)){let a=r[i];if(a)return x(V(n),a)}return null}function Z(e){if(!e.bundledNpmPackage)return null;try{return rn.resolve(`${e.bundledNpmPackage}/package.json`)}catch{return null}}function ee(e,n){for(let t of e.projectLocalBinaries??[]){let r=x(n,t);if(C(r))return r}return null}function ne(e,n=process.env,t=e.indexerBinary){if(e.indexerBinary!=="scip-dotnet"||re(t,n))return n;let r=on(t,n);return r?{...n,DOTNET_ROOT:r}:n}function te(e,n){let t=e.installMethods,r=L(e);if(!t?.length)return n(`No auto-install method available for ${r}.`),e.installUrl&&n(`Install manually from: ${e.installUrl}`),!1;for(let i of t)if(m(i.prerequisite)){n(`Installing ${r} via ${i.label}...`);try{j(i.binary,i.args,{stdio:"inherit",timeout:3e5,env:process.env});let a=y(e);if(a){let s=a===e.indexerBinary?"":` (using ${a})`;return n(`Successfully installed ${r} via ${i.label}${s}`),!0}n(`${i.label} command completed but ${r} was not found on PATH`)}catch(a){let s=a instanceof Error?a.message:String(a);n(`${i.label} install failed: ${s}`)}}return n(`Could not auto-install ${r}.`),e.installUrl&&n(`Install manually from: ${e.installUrl}`),!1}function on(e,n){for(let t of un(n))if(re(e,{...n,DOTNET_ROOT:t}))return t;return null}function un(e){let n=[],t=e.DOTNET_ROOT;if(t&&C(t)&&n.push(t),tn()==="darwin"&&m("brew"))try{let r=j("brew",["--prefix","dotnet@9"],{stdio:"pipe",env:e}).toString().trim(),i=x(r,"libexec");C(i)&&!n.includes(i)&&n.push(i)}catch{}return n}function re(e,n){try{return j(e,["--version"],{stdio:"pipe",env:n}),!0}catch{return!1}}async function se(e){let{projectRoot:n,maxHeapMb:t=8192,onStatus:r=console.log,skipAutoInstall:i=!1}=e,a=fn(e),s=Date.now();ie(d(a.outputScip),{recursive:!0}),ie(d(a.outputDb),{recursive:!0});let o=e.languages??U(n);if(o.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: ${o.join(", ")}`);let c=wn(n,o,{pnpmWorkspaces:e.pnpmWorkspaces}),u=On(g(d(a.outputDb),"index.lock")),p=null;try{let l=hn({opts:e,paths:a,languages:o,fingerprint:c,start:s,onStatus:r});if(l)return l;Pn(i,r);let f=xn(a);return p=f.runDir,await yn({opts:e,languages:o,projectRoot:n,paths:a,tempPaths:f,fingerprint:c,start:s,maxHeapMb:t,skipAutoInstall:i,onStatus:r})}finally{p&&B(p,{recursive:!0,force:!0}),u()}}function fn(e){let n=e.outputScip??g(e.projectRoot,"index.scip"),t=e.outputDb??g(e.projectRoot,"index.db");return{outputScip:n,outputDb:t,metaPath:g(d(t),"meta.json")}}function hn(e){if(e.opts.skipIfUnchanged===!1||!E(e.paths.outputScip)||!E(e.paths.outputDb)||!En(e.paths.metaPath,e.fingerprint))return null;P({projectRoot:e.opts.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus});let n=Date.now()-e.start;return e.onStatus(`Index unchanged; reused existing SQLite index in ${(n/1e3).toFixed(1)}s`),{languages:e.languages,indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:n,reused:!0,skipped:[]}}function xn(e){let n=cn(g(d(e.outputDb),"reindex-"));return{runDir:n,tempOutputScip:g(n,S(e.outputScip)),tempOutputDb:g(n,S(e.outputDb)),tempMetaPath:g(n,S(e.metaPath))}}async function yn(e){let n={...process.env,NODE_OPTIONS:`--max-old-space-size=${e.maxHeapMb}`},{indexedOutputs:t,skippedLanguages:r}=await bn(e,n);Sn(e,n,t,r);let i=Date.now()-e.start;return e.onStatus(`Done in ${(i/1e3).toFixed(1)}s`),{languages:t.map(a=>a.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:i,reused:!1,skipped:r}}async function bn(e,n){let{preparedRuns:t,skippedLanguages:r}=vn({languages:e.languages,tempOutputScip:e.tempPaths.tempOutputScip,projectRoot:e.projectRoot,env:n,skipAutoInstall:e.skipAutoInstall,pnpmWorkspaces:e.opts.pnpmWorkspaces,onStatus:e.onStatus}),i=await K(t,e.projectRoot,e.onStatus,e.opts.indexerConcurrency),{indexedOutputs:a}=kn(i,r);return Rn(a,r,e.languages,e.opts.allowPartial,e.onStatus),{indexedOutputs:a,skippedLanguages:r}}function Sn(e,n,t,r){Dn(t,e.tempPaths.tempOutputScip,e.onStatus),Cn(e.tempPaths.tempOutputScip,e.tempPaths.tempOutputDb,n,e.onStatus),P({projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,onStatus:e.onStatus}),$n(e.tempPaths.tempMetaPath,{version:2,status:r.length===0?"complete":"partial",updatedAt:new Date().toISOString(),fingerprint:e.fingerprint,requestedLanguages:e.languages,indexedLanguages:t.map(i=>i.language),skipped:[...r]}),Ln({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 Pn(e,n){if(!m("scip")){if(e)throw new Error(`The scip CLI is required but not found on PATH.
|
|
4
|
+
Install from: https://github.com/sourcegraph/scip/releases`);if(n("scip CLI not found on PATH. Attempting auto-install..."),!M(n))throw new Error(`The scip CLI is required but could not be installed.
|
|
5
|
+
Install manually from: https://github.com/sourcegraph/scip/releases`)}}function vn(e){let n=[],t=[],r=e.languages.map((i,a)=>({language:i,scipPath:e.languages.length>1?jn(e.tempOutputScip,i,a):e.tempOutputScip}));for(let{language:i,scipPath:a}of r){let s=In({...e,language:i,scipPath:a});"skipped"in s?t.push(s.skipped):n.push(s.prepared)}return{preparedRuns:n,skippedLanguages:t}}function In(e){let n=z(e.language),t=L(n),r=ee(n,e.projectRoot);if(!r&&!Y(n)){if(e.skipAutoInstall){let o=`${t} not found on PATH (auto-install disabled). ${n.installUrl??""}`.trim();return e.onStatus(`Skipping ${e.language}: ${o}`),{skipped:{language:e.language,reason:o}}}if(e.onStatus(`${t} not found. Attempting auto-install...`),!te(n,e.onStatus)){let o=`${t} could not be auto-installed. ${n.installUrl?`Install manually from ${n.installUrl}`:`Install ${t} and put it on PATH.`}`;return e.onStatus(`Skipping ${e.language}: ${o}`),{skipped:{language:e.language,reason:o}}}}let i=r??y(n);if(!i){let o=`${t} was not found after installation checks.`;return e.onStatus(`Skipping ${e.language}: ${o}`),{skipped:{language:e.language,reason:o}}}let{binary:a,args:s}=n.indexArgs({projectRoot:e.projectRoot,outputPath:e.scipPath,pnpmWorkspaces:e.pnpmWorkspaces,indexerBinary:i});return{prepared:{language:e.language,scipPath:e.scipPath,config:n,resolvedBinary:i,binary:a,args:s,env:ne(n,e.env,i)}}}function kn(e,n){let t=[];for(let r of e)r.skipped?n.push(r.skipped):t.push({language:r.language,scipPath:r.scipPath});return{indexedOutputs:t}}function Rn(e,n,t,r,i){if(e.length===0){let a=n.map(s=>` - ${s.language}: ${s.reason}`).join(`
|
|
5
6
|
`);throw new Error(`No language indexers ran successfully. Install at least one indexer for the languages in this project.
|
|
6
|
-
`+
|
|
7
|
-
`+n.map(
|
|
8
|
-
`))}function
|
|
9
|
-
`),()=>{try{
|
|
10
|
-
`)
|
|
11
|
-
`)}function v(e){return JSON.stringify(e)}var ie=process.env.SCIP_REINDEX_PROJECT_ROOT,se=process.env.SCIP_REINDEX_OUTPUT_SCIP,oe=process.env.SCIP_REINDEX_OUTPUT_DB,re=process.env.SCIP_REINDEX_LANGUAGES,wn=process.env.SCIP_REINDEX_PNPM_WORKSPACES==="1";(!ie||!se||!oe)&&(console.error("reindex-worker: missing required env vars"),process.exit(1));var ae=re?re.split(",").filter(Boolean):void 0;te({projectRoot:ie,outputScip:se,outputDb:oe,languages:ae?.length?ae:void 0,pnpmWorkspaces:wn,onStatus:e=>process.stderr.write(`[reindex] ${e}
|
|
7
|
+
`+a)}if(n.length!==0&&(i(`Indexed ${e.length} of ${t.length} languages; skipped ${n.map(a=>a.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.
|
|
8
|
+
`+n.map(a=>` - ${a.language}: ${a.reason}`).join(`
|
|
9
|
+
`))}function Dn(e,n,t){e.length>1?(t(`Merging ${e.length} language indexes...`),J(e.map(r=>r.scipPath),n)):e[0].scipPath!==n&&$(e[0].scipPath,n)}function Cn(e,n,t,r){if(r("Converting to SQLite..."),!E(e))throw new Error(`SCIP index not found at ${e} after indexing`);try{let i=X(e);i.removedDefinitionOccurrences>0&&r(`Sanitized ${i.removedDefinitionOccurrences} invalid definition occurrences across ${i.touchedDocuments} documents before SQLite conversion.`),ln("scip",["expt-convert","--output",n,e],{env:t,stdio:"pipe",maxBuffer:50*1024*1024})}catch(i){let a=i instanceof Error?i.message:String(i);throw new Error(`Failed to convert SCIP index to SQLite: ${a}`,{cause:i})}}function jn(e,n,t){let r=mn(e)||".scip",i=S(e,r);return g(d(e),`${i}.${t+1}.${n}${r}`)}function On(e){let n;try{n=gn(e,"wx")}catch(t){throw(typeof t=="object"&&t&&"code"in t?t.code:void 0)==="EEXIST"?new Error(`Another scip-query reindex is already running for ${d(e)}.`,{cause:t}):t}return ae(n,JSON.stringify({pid:process.pid,startedAt:new Date().toISOString()})+`
|
|
10
|
+
`),()=>{try{pn(n)}finally{B(e,{force:!0})}}}function Ln(e){w(e.tempOutputScip,e.outputScip),w(e.tempOutputDb,e.outputDb),w(e.tempMetaPath,e.metaPath)}function w(e,n){B(`${n}.tmp-replace`,{force:!0}),$(e,`${n}.tmp-replace`),$(`${n}.tmp-replace`,n)}function wn(e,n,t){return{version:1,languages:[...n].sort(),pnpmWorkspaces:t.pnpmWorkspaces===!0,files:N(e)}}function En(e,n){try{let t=JSON.parse(dn(e,"utf-8"));return t.version===2&&t.status==="complete"&&b(t.fingerprint)===b(n)&&b([...t.indexedLanguages??[]].sort())===b(n.languages)}catch{return!1}}function $n(e,n){ae(e,`${JSON.stringify(n,null,2)}
|
|
11
|
+
`)}function b(e){return JSON.stringify(e)}var le=process.env.SCIP_REINDEX_PROJECT_ROOT,pe=process.env.SCIP_REINDEX_OUTPUT_SCIP,ce=process.env.SCIP_REINDEX_OUTPUT_DB,oe=process.env.SCIP_REINDEX_LANGUAGES,Bn=process.env.SCIP_REINDEX_PNPM_WORKSPACES==="1";(!le||!pe||!ce)&&(console.error("reindex-worker: missing required env vars"),process.exit(1));var ue=oe?oe.split(",").filter(Boolean):void 0;se({projectRoot:le,outputScip:pe,outputDb:ce,languages:ue?.length?ue:void 0,pnpmWorkspaces:Bn,onStatus:e=>process.stderr.write(`[reindex] ${e}
|
|
12
12
|
`)}).then(()=>{process.exit(0)}).catch(e=>{console.error(`reindex-worker error: ${e}`),process.exit(1)});
|
|
13
13
|
//# sourceMappingURL=reindex-worker.js.map
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { a as SupportedLanguage, I as IndexerConfig } from './config-types-CGIeLEpY.js';
|
|
2
|
+
import { Index } from '@c4312/scip';
|
|
3
|
+
export { t as tryInstallScipCli } from './scip-cli-a-xOztiK.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Detect which languages are present in a project directory by checking for
|
|
7
|
+
* marker files, root-level project files, and source-file extensions.
|
|
8
|
+
*/
|
|
9
|
+
declare function detectLanguages(projectRoot: string): SupportedLanguage[];
|
|
10
|
+
|
|
11
|
+
interface AugmentAuxiliaryDocumentsOptions {
|
|
12
|
+
projectRoot: string;
|
|
13
|
+
dbPath: string;
|
|
14
|
+
extensions?: readonly string[];
|
|
15
|
+
onStatus?: (message: string) => void;
|
|
16
|
+
}
|
|
17
|
+
interface AugmentAuxiliaryDocumentsResult {
|
|
18
|
+
scanned: number;
|
|
19
|
+
inserted: number;
|
|
20
|
+
existing: number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Add source files that upstream SCIP indexers skipped to the SQLite
|
|
24
|
+
* documents table. Vue SFCs are the motivating case: scip-typescript can
|
|
25
|
+
* resolve imports to generated TS, but it does not emit `.vue` documents.
|
|
26
|
+
*/
|
|
27
|
+
declare function augmentAuxiliaryDocuments(opts: AugmentAuxiliaryDocumentsOptions): AugmentAuxiliaryDocumentsResult;
|
|
28
|
+
|
|
29
|
+
interface AugmentVueResolvedResult {
|
|
30
|
+
vueFiles: number;
|
|
31
|
+
resolvedReferences: number;
|
|
32
|
+
insertedMentions: number;
|
|
33
|
+
skippedReferences: number;
|
|
34
|
+
syntheticSymbols: number;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface AugmentVueResolvedOptions {
|
|
38
|
+
projectRoot: string;
|
|
39
|
+
dbPath: string;
|
|
40
|
+
tsconfig: string;
|
|
41
|
+
onStatus?: (message: string) => void;
|
|
42
|
+
}
|
|
43
|
+
declare function augmentVueResolvedReferences(opts: AugmentVueResolvedOptions): AugmentVueResolvedResult;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Indexer configurations for each supported language.
|
|
47
|
+
* Each entry describes how to produce a SCIP index for that language.
|
|
48
|
+
*
|
|
49
|
+
* The `scip` CLI binary is required for all languages (to convert protobuf -> SQLite).
|
|
50
|
+
* Each language also needs its own SCIP indexer installed.
|
|
51
|
+
*/
|
|
52
|
+
declare const INDEXER_CONFIGS: Record<SupportedLanguage, IndexerConfig>;
|
|
53
|
+
/** Get the indexer config for a language */
|
|
54
|
+
declare function getIndexerConfig(language: SupportedLanguage): IndexerConfig;
|
|
55
|
+
|
|
56
|
+
interface MergeScipResult {
|
|
57
|
+
documentCount: number;
|
|
58
|
+
externalSymbolCount: number;
|
|
59
|
+
inputCount: number;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Merge multiple SCIP indices into a single index message.
|
|
63
|
+
*
|
|
64
|
+
* A SCIP index is a code graph snapshot: metadata about one indexed project plus
|
|
65
|
+
* the documents and external symbols discovered by one or more indexers. Merging
|
|
66
|
+
* means producing one unified snapshot so later conversion to SQLite sees the
|
|
67
|
+
* whole repo instead of whichever language indexed last.
|
|
68
|
+
*/
|
|
69
|
+
declare function mergeScipIndexes(indexes: readonly Index[]): Index;
|
|
70
|
+
declare function mergeScipFiles(inputPaths: readonly string[], outputPath: string): MergeScipResult;
|
|
71
|
+
|
|
72
|
+
declare function isBinaryAvailable(name: string): boolean;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Describe the accepted executable names for an indexer.
|
|
76
|
+
*/
|
|
77
|
+
declare function describeIndexerBinary(config: IndexerConfig): string;
|
|
78
|
+
/**
|
|
79
|
+
* Resolve the first available executable name for an indexer.
|
|
80
|
+
*
|
|
81
|
+
* Falls back to the indexer's bundled npm package bin when it is installed
|
|
82
|
+
* alongside scip-query. Returning the concrete bin path keeps indexing stable
|
|
83
|
+
* even when the target project is not itself an npm project.
|
|
84
|
+
*/
|
|
85
|
+
declare function resolveIndexerBinary(config: IndexerConfig): string | null;
|
|
86
|
+
/**
|
|
87
|
+
* Check if an indexer's binary is available on PATH.
|
|
88
|
+
*/
|
|
89
|
+
declare function isIndexerInstalled(config: IndexerConfig): boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Resolve a project-local indexer binary when the project vendors its own executable.
|
|
92
|
+
*/
|
|
93
|
+
declare function resolveProjectLocalIndexerBinary(config: IndexerConfig, projectRoot: string): string | null;
|
|
94
|
+
/**
|
|
95
|
+
* Build the environment needed to execute a language indexer.
|
|
96
|
+
* Currently only .NET indexers need special handling because `scip-dotnet`
|
|
97
|
+
* still targets the .NET 9 runtime.
|
|
98
|
+
*/
|
|
99
|
+
declare function getIndexerExecutionEnv(config: IndexerConfig, baseEnv?: NodeJS.ProcessEnv, binary?: string): NodeJS.ProcessEnv;
|
|
100
|
+
/**
|
|
101
|
+
* Attempt to auto-install an indexer using its configured install methods.
|
|
102
|
+
* Tries each method in order, checking prerequisites first.
|
|
103
|
+
* Returns true if installation succeeded.
|
|
104
|
+
*/
|
|
105
|
+
declare function tryInstallIndexer(config: IndexerConfig, onStatus: (msg: string) => void): boolean;
|
|
106
|
+
|
|
107
|
+
interface ReindexOptions {
|
|
108
|
+
projectRoot: string;
|
|
109
|
+
/** Override language detection — index only these languages */
|
|
110
|
+
languages?: SupportedLanguage[];
|
|
111
|
+
/** Path for the SCIP protobuf output (default: <projectRoot>/index.scip) */
|
|
112
|
+
outputScip?: string;
|
|
113
|
+
/** Path for the SQLite output (default: <projectRoot>/index.db) */
|
|
114
|
+
outputDb?: string;
|
|
115
|
+
/** Max Node.js heap size in MB (default: 8192) */
|
|
116
|
+
maxHeapMb?: number;
|
|
117
|
+
/** Callback for status updates */
|
|
118
|
+
onStatus?: (message: string) => void;
|
|
119
|
+
/** Extra flags for pnpm-workspace-aware TS indexing */
|
|
120
|
+
pnpmWorkspaces?: boolean;
|
|
121
|
+
/** Skip auto-install prompts */
|
|
122
|
+
skipAutoInstall?: boolean;
|
|
123
|
+
/** Reuse an existing index when tracked source inputs are unchanged (default true). */
|
|
124
|
+
skipIfUnchanged?: boolean;
|
|
125
|
+
/** Permit a partial index when some detected/requested languages fail (default false). */
|
|
126
|
+
allowPartial?: boolean;
|
|
127
|
+
/** Number of language indexers to run at once (default: conservative auto). */
|
|
128
|
+
indexerConcurrency?: number;
|
|
129
|
+
}
|
|
130
|
+
interface ReindexResult {
|
|
131
|
+
/** Languages that were successfully indexed. */
|
|
132
|
+
languages: SupportedLanguage[];
|
|
133
|
+
indexPath: string;
|
|
134
|
+
dbPath: string;
|
|
135
|
+
durationMs: number;
|
|
136
|
+
/** True when existing SCIP/SQLite outputs were reused because inputs were unchanged. */
|
|
137
|
+
reused: boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Languages detected in the project but skipped because their indexer
|
|
140
|
+
* could not be located, installed, or run. Each entry includes the reason.
|
|
141
|
+
*/
|
|
142
|
+
skipped: {
|
|
143
|
+
language: SupportedLanguage;
|
|
144
|
+
reason: string;
|
|
145
|
+
}[];
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Reindex a project: detect languages, run the appropriate SCIP indexer(s),
|
|
149
|
+
* and convert the output to SQLite.
|
|
150
|
+
*/
|
|
151
|
+
declare function reindex(opts: ReindexOptions): Promise<ReindexResult>;
|
|
152
|
+
|
|
153
|
+
export { INDEXER_CONFIGS, type ReindexOptions, type ReindexResult, augmentAuxiliaryDocuments, augmentVueResolvedReferences, describeIndexerBinary, detectLanguages, getIndexerConfig, getIndexerExecutionEnv, isBinaryAvailable, isIndexerInstalled, mergeScipFiles, mergeScipIndexes, reindex, resolveIndexerBinary, resolveProjectLocalIndexerBinary, tryInstallIndexer };
|
package/dist/reindex.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import{a as m,e as w}from"./chunk-LWYIGRHR.js";import{a as Z}from"./chunk-TKDJQ2WD.js";import{a as Y,b as Q}from"./chunk-KJ6CW6EK.js";import"./chunk-NHDPYW7O.js";import"./chunk-NN3O7TPH.js";import{execFileSync as er}from"child_process";import{closeSync as nr,existsSync as q,mkdirSync as $e,mkdtempSync as tr,openSync as rr,readFileSync as ir,renameSync as K,rmSync as X,writeFileSync as Be}from"fs";import{basename as C,dirname as b,extname as or,join as f}from"path";import We from"better-sqlite3";import{execFileSync as He}from"child_process";import{existsSync as Je,readdirSync as ze,readFileSync as Ge}from"fs";import{extname as S,join as ee}from"path";function y(e){let n=new Set((e.extensions??Y).map(o=>o.toLowerCase()));if(n.size===0)return{scanned:0,inserted:0,existing:0};if(!Je(e.dbPath))throw new Error(`SCIP SQLite database not found at ${e.dbPath}`);let t=Z(e.projectRoot),r=qe(e.projectRoot,n).filter(o=>!t.isIgnored(o)),i=new We(e.dbPath);try{let o=Xe(i,r),s=i.prepare(`INSERT OR IGNORE INTO documents (language, relative_path, position_encoding, text)
|
|
2
|
+
VALUES (?, ?, NULL, ?)`),u=i.transaction(g=>{let l=0;for(let p of g){if(o.has(p))continue;let d=Ge(ee(e.projectRoot,p),"utf-8"),Ue=s.run(Ye(p),p,d);l+=Number(Ue.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 qe(e,n){let t=Ke(e,n);if(t)return t;let r=[],i=o=>{let s=o?ee(e,o):e,a;try{a=ze(s,{withFileTypes:!0})}catch{return}for(let u of a){if(Q.has(u.name))continue;let c=o?`${o}/${u.name}`:u.name;if(u.isDirectory()){i(c);continue}n.has(S(u.name).toLowerCase())&&r.push(c)}};return i(""),r.sort()}function Ke(e,n){try{return He("git",["-C",e,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:26214400,stdio:["ignore","pipe","ignore"]}).split(`
|
|
3
|
+
`).filter(r=>r&&n.has(S(r).toLowerCase())).sort()}catch{return null}}function Xe(e,n){let t=new Set,r=500;for(let i=0;i<n.length;i+=r){let o=n.slice(i,i+r),s=e.prepare(`SELECT relative_path FROM documents WHERE relative_path IN (${o.map(()=>"?").join(",")})`).all(...o);for(let a of s)t.add(a.relative_path)}return t}function Ye(e){return S(e).toLowerCase()===".vue"?"vue":S(e).replace(/^\./,"").toLowerCase()||"source"}import{execFileSync as Qe}from"child_process";import{existsSync as Ze,readdirSync as te}from"fs";import{extname as re,join as ie}from"path";var en=new Set([".git",".hg",".svn",".idea",".vscode","node_modules","vendor","dist","build","target","bin","obj",".dart_tool",".gradle",".next",".venv","venv","__pycache__"]),nn=[{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 n=[],t=tn(e),r=an(e);for(let i of nn){if(rn(e,i.files)){n.push(i.language);continue}if(on(t,i.globs)){n.push(i.language);continue}cn(r,i.extensions)&&n.push(i.language)}return n.includes("typescript")&&ne(n,"javascript"),n.includes("cpp")&&!r.has(".c")&&ne(n,"c"),n}function tn(e){try{return te(e)}catch{return[]}}function rn(e,n){return n?.length?n.some(t=>Ze(ie(e,t))):!1}function on(e,n){return n?.length?e.some(t=>n.some(r=>sn(t,r))):!1}function sn(e,n){if(n==="*")return!0;if(!n.includes("*"))return e===n;let[t,r]=n.split("*");return e.startsWith(t??"")&&e.endsWith(r??"")}function an(e){let n=un(e);if(n)return n;let t=new Set,r=[e];for(;r.length>0;){let i=r.pop();if(!i)continue;let o;try{o=te(i,{withFileTypes:!0})}catch{continue}for(let s of o){if(s.name.startsWith(".")&&!s.name.endsWith("proj")&&!s.name.endsWith("sln")&&s.isDirectory())continue;let a=ie(i,s.name);if(s.isDirectory()){en.has(s.name)||r.push(a);continue}let u=re(s.name).toLowerCase();u&&t.add(u)}}return t}function un(e){try{let n=Qe("git",["-C",e,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:26214400,stdio:["ignore","pipe","ignore"]}),t=new Set;for(let r of n.split(`
|
|
4
|
+
`)){if(!r)continue;let i=re(r).toLowerCase();i&&t.add(i)}return t}catch{return null}}function cn(e,n){return n?.length?n.some(t=>e.has(t)):!1}function ne(e,n){let t=e.indexOf(n);t!==-1&&e.splice(t,1)}import{existsSync as oe,readdirSync as ln}from"fs";import{join as O}from"path";var ae={typescript:{language:"typescript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,pnpmWorkspaces:n,indexerBinary:t})=>{let r=["index","--infer-tsconfig","--output",e,"--no-progress-bar"];return n&&r.splice(1,0,"--pnpm-workspaces"),{binary:t,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:n})=>({binary:n,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:n})=>({binary:n,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:n})=>({binary:"scip-dotnet",args:["index",se(e,[".sln",".csproj"])??e,"--output",n,"--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:n})=>({binary:"scip-dotnet",args:["index",se(e,[".sln",".vbproj"])??e,"--output",n,"--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:n})=>({binary:e,args:["--output",n]}),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:n})=>{let t=O(e,"vendor","bin","scip-php"),r=O(e,"vendor","davidrjenni","scip-php","bin","scip-php");return{binary:"php",args:["-d","error_reporting=E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED",oe(r)?r:oe(t)?t:n]}},defaultOutputPath:"index.scip",markerFiles:["composer.json"],installMethods:[],installUrl:"https://github.com/davidrjenni/scip-php/releases"}};function D(e){return ae[e]}function se(e,n){let t;try{t=ln(e)}catch{return null}for(let r of t)if(n.some(i=>r.endsWith(i)))return O(e,r);return null}import{readFileSync as gn,writeFileSync as pn}from"fs";import{create as T}from"@bufbuild/protobuf";import{deserializeSCIP as dn,serializeSCIP as fn,DocumentSchema as mn,IndexSchema as hn,SymbolInformationSchema as bn}from"@c4312/scip";function ue(e){if(e.length===0)throw new Error("Cannot merge zero SCIP indexes");if(e.length===1)return e[0];let n=yn(e),t=xn(e.flatMap(i=>i.documents??[])),r=ce(e.flatMap(i=>i.externalSymbols??[]));return T(hn,{metadata:n,documents:t,externalSymbols:r})}function F(e,n){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let t=e.map(i=>dn(gn(i))),r=ue(t);return pn(n,Buffer.from(fn(r))),{documentCount:r.documents.length,externalSymbolCount:r.externalSymbols.length,inputCount:e.length}}function yn(e){let n=e[0]?.metadata;if(!n)return;let t=n.projectRoot;for(let r of e.slice(1)){let i=r.metadata?.projectRoot;if(t&&i&&i!==t)throw new Error(`Cannot merge SCIP indexes with different project roots: ${t} vs ${i}`)}return n}function xn(e){let n=new Map;for(let t of e){let r=n.get(t.relativePath);if(!r){n.set(t.relativePath,t);continue}n.set(t.relativePath,T(mn,{language:r.language||t.language,relativePath:r.relativePath||t.relativePath,occurrences:[...r.occurrences,...t.occurrences],symbols:ce([...r.symbols,...t.symbols]),text:vn(r.text,t.text),positionEncoding:r.positionEncoding||t.positionEncoding}))}return[...n.values()]}function ce(e){let n=new Map;for(let t of e){let r=n.get(t.symbol);if(!r){n.set(t.symbol,t);continue}n.set(t.symbol,T(bn,{symbol:r.symbol,documentation:Rn([...r.documentation,...t.documentation]),relationships:Sn([...r.relationships,...t.relationships]),kind:r.kind||t.kind,displayName:r.displayName||t.displayName,enclosingSymbol:r.enclosingSymbol||t.enclosingSymbol,signatureDocumentation:r.signatureDocumentation??t.signatureDocumentation}))}return[...n.values()]}function Sn(e){let n=new Set,t=[];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("|");n.has(i)||(n.add(i),t.push(r))}return t}function vn(e,n){return e?n?e.length>=n.length?e:n:e:n}function Rn(e){return[...new Set(e)]}import{execFileSync as kn}from"child_process";import{createHash as In}from"crypto";import{readdirSync as Pn,readFileSync as Cn}from"fs";import{join as le}from"path";function wn(e){return(Ln(e)??On(e)).filter(n=>n&&!ge(n)).sort()}function v(e){return wn(e).map(n=>{let t=le(e,n);try{let r=Cn(t);return{path:n,size:r.byteLength,hash:In("sha256").update(r).digest("hex")}}catch{return{path:n,size:-1,hash:"unreadable"}}})}function Ln(e){try{return kn("git",["-C",e,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:50*1024*1024,stdio:["ignore","pipe","ignore"]}).split(`
|
|
5
|
+
`).filter(Boolean)}catch{return null}}function On(e){let n=[],t=[""];for(;t.length>0;){let r=t.pop(),i=r?le(e,r):e,o;try{o=Pn(i,{withFileTypes:!0})}catch{continue}for(let s of o){let a=r?`${r}/${s.name}`:s.name;if(s.isDirectory()){ge(a)||t.push(a);continue}n.push(a)}}return n}function ge(e){return e.split("/").some(t=>Dn.has(t))||e.endsWith(".db")||e.endsWith(".db-wal")||e.endsWith(".db-shm")||e.endsWith(".scip")}var Dn=new Set([".git","node_modules",".scipquery-cache",".stryker-tmp","dist","build","coverage",".next",".nuxt","target"]);import{readFileSync as Tn,writeFileSync as Fn}from"fs";import{create as pe}from"@bufbuild/protobuf";import{deserializeSCIP as En,DocumentSchema as Vn,IndexSchema as jn,serializeSCIP as Mn,SymbolRole as Nn}from"@c4312/scip";function de(e){let n;try{n=En(Tn(e))}catch{return{removedDefinitionOccurrences:0,touchedDocuments:0}}let t=An(n);return t.removedDefinitionOccurrences>0&&Fn(e,Buffer.from(Mn(t.index))),{removedDefinitionOccurrences:t.removedDefinitionOccurrences,touchedDocuments:t.touchedDocuments}}function An(e){let n=new Set;for(let o of e.documents)for(let s of o.symbols)s.symbol&&n.add(s.symbol);for(let o of e.externalSymbols)o.symbol&&n.add(o.symbol);let t=0,r=0,i=[];for(let o of e.documents){let s=o.occurrences.filter(a=>(a.symbolRoles&Nn.Definition)===0||n.has(a.symbol)?!0:(t+=1,!1));if(s.length===o.occurrences.length){i.push(o);continue}r+=1,i.push(pe(Vn,{language:o.language,relativePath:o.relativePath,occurrences:s,symbols:o.symbols,text:o.text,positionEncoding:o.positionEncoding}))}return{index:t===0?e:pe(jn,{metadata:e.metadata,documents:i,externalSymbols:e.externalSymbols}),removedDefinitionOccurrences:t,touchedDocuments:r}}import{execFile as _n}from"child_process";import{existsSync as R,renameSync as V,rmSync as j}from"fs";import{cpus as $n}from"os";import{join as fe}from"path";function Bn(e,n,t){if(!e.defaultOutputPath)return;let r=fe(n,e.defaultOutputPath);t!==r&&R(r)&&V(r,t)}function Un(e,n,t){if(!e.defaultOutputPath)return null;let r=fe(n,e.defaultOutputPath);if(r===t)return null;let i=`${t}.default-output-backup`;return j(i,{force:!0}),R(r)?(V(r,i),{defaultOutputPath:r,backupPath:i}):{defaultOutputPath:r,backupPath:null}}function Wn(e){e&&(j(e.defaultOutputPath,{force:!0}),e.backupPath&&R(e.backupPath)&&V(e.backupPath,e.defaultOutputPath))}function Hn(e,n){if(e<=1)return 1;let t=Number(process.env.SCIP_QUERY_INDEXER_CONCURRENCY??0),r=Number.isFinite(n)&&n&&n>0?n:Number.isFinite(t)&&t>0?t:Math.min(2,Math.max(1,$n().length-1));return Math.max(1,Math.min(e,Math.floor(r)))}async function me(e,n,t,r){let i=e.filter(c=>c.config.defaultOutputPath),o=e.filter(c=>!c.config.defaultOutputPath),s=[],a=Hn(o.length,r),u=await zn(o,a,c=>E(c,n,t));if(a>1){let c=new Map;for(let g of u.filter(l=>l.skipped)){let l=o.find(p=>p.language===g.language);l&&(t(`Retrying ${l.language} indexer serially after parallel failure...`),c.set(l.language,await E(l,n,t)))}s.push(...u.map(g=>c.get(g.language)??g))}else s.push(...u);for(let c of i)s.push(await E(c,n,t));return s.sort((c,g)=>e.findIndex(l=>l.language===c.language)-e.findIndex(l=>l.language===g.language))}async function E(e,n,t){t(`Indexing ${e.language} with ${e.resolvedBinary}...`),j(e.scipPath,{force:!0});let r=Un(e.config,n,e.scipPath);try{await Jn(e.binary,e.args,{cwd:n,env:e.env,maxBuffer:50*1024*1024}),Bn(e.config,n,e.scipPath)}catch(i){let o=i instanceof Error?i.message:String(i),s=`${e.resolvedBinary} indexer failed: ${o.split(`
|
|
6
|
+
`)[0]}`;return t(`Skipping ${e.language}: ${s}`),{language:e.language,scipPath:e.scipPath,skipped:{language:e.language,reason:s}}}finally{Wn(r)}if(!R(e.scipPath)){let i=`${e.resolvedBinary} indexer completed but did not produce ${e.scipPath}`;return t(`Skipping ${e.language}: ${i}`),{language:e.language,scipPath:e.scipPath,skipped:{language:e.language,reason:i}}}return{language:e.language,scipPath:e.scipPath}}function Jn(e,n,t){return new Promise((r,i)=>{_n(e,[...n],t,o=>{o?i(o):r()})})}async function zn(e,n,t){if(e.length===0)return[];let r=new Array(e.length),i=0,o=Math.max(1,Math.min(e.length,n)),s=Array.from({length:o},async()=>{for(;i<e.length;){let a=i++;r[a]=await t(e[a])}});return await Promise.all(s),r}import{execFileSync as N}from"child_process";import{existsSync as M,readFileSync as Gn}from"fs";import{createRequire as qn}from"module";import{platform as Kn}from"os";import{dirname as he,join as k}from"path";var Xn=qn(import.meta.url);function A(e){return[e.indexerBinary,...e.binaryAliases??[]]}function I(e){let n=A(e);return n.length===1?n[0]:n.join(" or ")}function x(e){for(let n of A(e))if(m(n))return n;return Qn(e)}function _(e){return x(e)!==null||Yn(e)}function Yn(e){return be(e)!==null}function Qn(e){let n=be(e);if(!n)return null;let r=JSON.parse(Gn(n,"utf8")).bin;if(!r)return null;if(typeof r=="string")return k(he(n),r);for(let i of A(e)){let o=r[i];if(o)return k(he(n),o)}return null}function be(e){if(!e.bundledNpmPackage)return null;try{return Xn.resolve(`${e.bundledNpmPackage}/package.json`)}catch{return null}}function $(e,n){for(let t of e.projectLocalBinaries??[]){let r=k(n,t);if(M(r))return r}return null}function B(e,n=process.env,t=e.indexerBinary){if(e.indexerBinary!=="scip-dotnet"||ye(t,n))return n;let r=Zn(t,n);return r?{...n,DOTNET_ROOT:r}:n}function U(e,n){let t=e.installMethods,r=I(e);if(!t?.length)return n(`No auto-install method available for ${r}.`),e.installUrl&&n(`Install manually from: ${e.installUrl}`),!1;for(let i of t)if(m(i.prerequisite)){n(`Installing ${r} via ${i.label}...`);try{N(i.binary,i.args,{stdio:"inherit",timeout:3e5,env:process.env});let o=x(e);if(o){let s=o===e.indexerBinary?"":` (using ${o})`;return n(`Successfully installed ${r} via ${i.label}${s}`),!0}n(`${i.label} command completed but ${r} was not found on PATH`)}catch(o){let s=o instanceof Error?o.message:String(o);n(`${i.label} install failed: ${s}`)}}return n(`Could not auto-install ${r}.`),e.installUrl&&n(`Install manually from: ${e.installUrl}`),!1}function Zn(e,n){for(let t of et(n))if(ye(e,{...n,DOTNET_ROOT:t}))return t;return null}function et(e){let n=[],t=e.DOTNET_ROOT;if(t&&M(t)&&n.push(t),Kn()==="darwin"&&m("brew"))try{let r=N("brew",["--prefix","dotnet@9"],{stdio:"pipe",env:e}).toString().trim(),i=k(r,"libexec");M(i)&&!n.includes(i)&&n.push(i)}catch{}return n}function ye(e,n){try{return N(e,["--version"],{stdio:"pipe",env:n}),!0}catch{return!1}}import Vt from"better-sqlite3";import{existsSync as jt,readFileSync as Mt,writeFileSync as Nt}from"fs";import{dirname as At,join as _t,resolve as $t}from"path";import{readFileSync as nt,rmSync as tt,statSync as rt,mkdtempSync as it}from"fs";import{cpus as ot,tmpdir as st}from"os";import{join as W}from"path";import{Worker as at}from"worker_threads";function xe(e){return e.length>=8&&ve(e.length)>1}function Se(e){let n=ve(e.vueFiles.length),t=ct(e.vueFiles),r=gt(t,n),i=new URL("./augment-vue-worker.js",import.meta.url),o=it(W(st(),"scip-query-vue-workers-")),s=new SharedArrayBuffer(4),a=new Int32Array(s),u=ut(),c=Date.now();try{for(let l=0;l<r.length;l++)new at(i,{workerData:{projectRoot:e.projectRoot,dbPath:e.dbPath,tsconfig:e.tsconfig,tasks:r[l],resultPath:W(o,`${l}.json`),sharedBuffer:s}});for(;Atomics.load(a,0)<r.length;){if(Date.now()-c>u)throw new Error(`Vue reference workers timed out after ${(u/1e3).toFixed(0)}s`);Atomics.wait(a,0,Atomics.load(a,0),100)}let g=r.map((l,p)=>{let d=JSON.parse(nt(W(o,`${p}.json`),"utf-8"));if(!d.ok)throw new Error(`Vue reference worker failed: ${d.error}`);return d.result});return{occurrences:g.flatMap(l=>l.occurrences),skippedReferences:g.reduce((l,p)=>l+p.skippedReferences,0)}}finally{tt(o,{recursive:!0,force:!0})}}function ve(e){let n=Number(process.env.SCIP_QUERY_AUGMENT_VUE_WORKERS??0),t=Number.isFinite(n)&&n>0?n:Math.min(8,Math.max(1,ot().length-1));return Math.max(1,Math.min(e,t))}function ut(){let e=Number(process.env.SCIP_QUERY_AUGMENT_VUE_WORKER_TIMEOUT_MS??0);return Number.isFinite(e)&&e>0?e:3e5}function ct(e){let n=lt(),t=[];for(let r of e){let i=Re(r),o=Math.max(1,Math.ceil(i/n));for(let s=0;s<o;s++)t.push({fileName:r,startOffset:Math.floor(i*s/o),endOffset:s===o-1?Number.POSITIVE_INFINITY:Math.floor(i*(s+1)/o),countFileSkip:s===0})}return t}function lt(){return Number.POSITIVE_INFINITY}function gt(e,n){let t=Array.from({length:n},()=>({tasks:[],weight:0})),r=e.map(i=>({task:i,weight:pt(i)})).sort((i,o)=>o.weight-i.weight);for(let i of r){let o=t.reduce((s,a)=>a.weight<s.weight?a:s);o.tasks.push(i.task),o.weight+=i.weight}return t.map(i=>i.tasks).filter(i=>i.length>0)}function pt(e){return Number.isFinite(e.endOffset)?Math.max(1,e.endOffset-e.startOffset):Math.max(1,Re(e.fileName)-e.startOffset)}function Re(e){try{return rt(e).size}catch{return 1}}import{createRequire as dt}from"module";import{existsSync as ft,readFileSync as J}from"fs";import{dirname as ke,extname as mt,join as Ie,relative as ht,resolve as bt}from"path";import{pathToFileURL as yt}from"url";function xt(e){e.transaction(()=>{e.prepare(`
|
|
7
|
+
DELETE FROM mentions
|
|
8
|
+
WHERE chunk_id IN (
|
|
9
|
+
SELECT c.id
|
|
10
|
+
FROM chunks c
|
|
11
|
+
JOIN documents d ON d.id = c.document_id
|
|
12
|
+
WHERE d.language = 'vue' OR d.relative_path LIKE '%.vue'
|
|
13
|
+
)
|
|
14
|
+
`).run(),e.prepare(`
|
|
15
|
+
DELETE FROM chunks
|
|
16
|
+
WHERE document_id IN (
|
|
17
|
+
SELECT id
|
|
18
|
+
FROM documents
|
|
19
|
+
WHERE language = 'vue' OR relative_path LIKE '%.vue'
|
|
20
|
+
)
|
|
21
|
+
`).run()})()}function Pe(e,n){return e.prepare(`
|
|
22
|
+
SELECT relative_path AS relativePath
|
|
23
|
+
FROM documents
|
|
24
|
+
WHERE language = 'vue' OR relative_path LIKE '%.vue'
|
|
25
|
+
ORDER BY relative_path
|
|
26
|
+
`).all().map(r=>bt(n,r.relativePath))}function Ce(e,n){let{vueCore:t,ts:r,volarTs:i}=St(e),{parsed:o,vueOptions:s}=vt(t,r,n),a=ke(n),u=t.createVueLanguagePlugin(r,o.options,s,d=>d),c=Rt(t,r,u),g=kt(a,o),{languageServiceHost:l}=i.createLanguageServiceHost(r,r.sys,c,d=>d,g),p=r.createLanguageService(l);return{ts:r,language:c,languageService:p,fileNames:o.fileNames,configDir:a}}function St(e){let n=dt(yt(Ie(e,"package.json")).href);return{vueCore:H(n,"@vue/language-core",e),ts:H(n,"typescript",e),volarTs:H(n,"@volar/typescript",e)}}function vt(e,n,t){let r=n.readConfigFile(t,n.sys.readFile);if(r.error||!r.config)throw new Error(`Failed to read ${t}`);let o=e.createParsedCommandLine(n,n.sys,t).vueOptions;return typeof e.createGlobalTypesWriter=="function"&&(o.globalTypesPath=e.createGlobalTypesWriter(o,n.sys.writeFile)),{parsed:n.parseJsonConfigFileContent(r.config,n.sys,ke(t),void 0,t,void 0,e.getAllExtensions(o).map(s=>({extension:s.slice(1),isMixedContent:!0,scriptKind:n.ScriptKind.Deferred}))),vueOptions:o}}function Rt(e,n,t){let r={},i=e.createLanguage([t],new Map,o=>{if(!ft(o))return;let s=J(o,"utf-8");r.current?.scripts.set(o,n.ScriptSnapshot.fromString(s),t.getLanguageId(o)??Ot(o))});return r.current=i,i}function kt(e,n){return{getCurrentDirectory:()=>e,getCompilationSettings:()=>n.options,getScriptFileNames:()=>n.fileNames,getProjectReferences:()=>n.projectReferences,getProjectVersion:()=>"0"}}function H(e,n,t){try{return e(n)}catch(r){throw(typeof r=="object"&&r!==null&&"code"in r?r.code:null)==="MODULE_NOT_FOUND"?new Error(`Vue augmentation requires ${n} to be installed in ${t}. Install Vue/Volar dependencies for that project, then rerun augment-vue.`,{cause:r}):r}}function we(e,n,t){let r=It(e);return i=>{let o=h(n,i.fileName),s=t.get(i.fileName);if(!s)return null;let a=t.positionAt(s,i.textSpan.start),u=r.get(o);if(!u)return null;let c=u.containingByLine.get(a.line);return c!==void 0?c:Pt(u.starts,a.line,2)}}function It(e){let n=e.prepare(`
|
|
27
|
+
SELECT
|
|
28
|
+
d.relative_path AS relativePath,
|
|
29
|
+
der.start_line AS startLine,
|
|
30
|
+
der.end_line AS endLine,
|
|
31
|
+
der.symbol_id AS symbolId
|
|
32
|
+
FROM defn_enclosing_ranges der
|
|
33
|
+
JOIN documents d ON d.id = der.document_id
|
|
34
|
+
ORDER BY d.relative_path, (der.end_line - der.start_line) DESC
|
|
35
|
+
`).all(),t=new Map;for(let r of n){let i=t.get(r.relativePath);i||(i={containingByLine:new Map,starts:[]},t.set(r.relativePath,i)),i.starts.push({line:r.startLine,symbolId:r.symbolId});for(let o=r.startLine;o<=r.endLine;o++)i.containingByLine.set(o,r.symbolId)}for(let r of t.values())r.starts.sort((i,o)=>i.line-o.line);return t}function Pt(e,n,t){let r=0,i=e.length-1;for(;r<=i;){let s=Math.floor((r+i)/2);e[s].line<n?r=s+1:i=s-1}let o=null;for(let s of[i,r]){let a=e[s];if(!a)continue;let u=Math.abs(a.line-n);u>t||(!o||u<o.distance)&&(o={distance:u,symbolId:a.symbolId})}return o?.symbolId??null}function Le(e,n,t){let r=Ft(n),i=e.prepare("SELECT id FROM global_symbols WHERE symbol = ?"),o=e.prepare(`
|
|
36
|
+
INSERT OR IGNORE INTO global_symbols (symbol, display_name, kind, documentation)
|
|
37
|
+
VALUES (?, ?, ?, ?)
|
|
38
|
+
`),s=0,a=new Map;return e.transaction(()=>{for(let c of t){let g=h(n,c),l=Ne(r.name,r.version,g);o.run(l,"default",7,`Vue component|${g}`);let p=Et(i,r,n,c);p&&(s++,a.set(c,p))}})(),{get(c){return a.get(c)??null},syntheticSymbols:s}}function Oe(e,n,t,r,i){return e.transaction(()=>(xt(e),Ct(e,n,t,r),wt(e,i)))()}function Ct(e,n,t,r){let i=e.prepare("SELECT id FROM documents WHERE relative_path = ?"),o=e.prepare(`
|
|
39
|
+
INSERT INTO chunks (document_id, chunk_index, start_line, end_line, occurrences)
|
|
40
|
+
VALUES (?, ?, ?, ?, X'00')
|
|
41
|
+
`),s=e.prepare(`
|
|
42
|
+
INSERT OR IGNORE INTO mentions (chunk_id, symbol_id, role)
|
|
43
|
+
VALUES (?, ?, 1)
|
|
44
|
+
`);for(let a of t){let u=r.get(a);if(!u)continue;let c=h(n,a),g=i.get(c);if(!g)continue;let l=o.run(g.id,-1,0,0);s.run(Number(l.lastInsertRowid),u)}}function De(e,n,t,r,i){if(e.fileName.endsWith(".vue")){let o=r.language.scripts.get(e.fileName),s=o?.generated?.languagePlugin.typescript?.getServiceScript(o.generated.root)?.code;if(o&&s){let a=r.language.maps.get(s,o);if(z(a,e.textSpan.start)!==null)return t.get(e.fileName)}return e.fileName.startsWith(i)?t.get(e.fileName):null}return n(e)}function Te(e){let n=new Set,t=[];for(let r of e){let i=Fe(r);n.has(i)||(n.add(i),t.push(r))}return t}function Fe(e){return[e.sourceFile,e.sourceLine,e.sourceStartChar,e.sourceEndChar,e.symbolId].join(":")}function wt(e,n){let t=Tt(e,[...new Set(n.map(u=>u.sourceFile))]),r=e.prepare(`
|
|
45
|
+
INSERT INTO chunks (document_id, chunk_index, start_line, end_line, occurrences)
|
|
46
|
+
VALUES (?, ?, ?, ?, X'00')
|
|
47
|
+
`),i=e.prepare(`
|
|
48
|
+
INSERT OR IGNORE INTO mentions (chunk_id, symbol_id, role)
|
|
49
|
+
VALUES (?, ?, 0)
|
|
50
|
+
`),o=new Set,s=0,a=0;for(let u of n){let c=Fe(u);if(o.has(c))continue;o.add(c);let g=t.get(u.sourceFile);if(!g)continue;let l=r.run(g,a++,u.sourceLine,u.sourceLine),p=i.run(Number(l.lastInsertRowid),u.symbolId);s+=Number(p.changes)}return s}function*Ee(e){let n=/\b[A-Za-z_$][A-Za-z0-9_$]*\b/g,t=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=n.exec(e);){let i=r[0];t.has(i)||(yield{text:i,start:r.index,end:r.index+i.length})}}function Ve(e,n){for(let[t]of e.toGeneratedLocation(n,r=>!!r.navigation))return t;return null}function z(e,n){let t=e;for(let[r]of t.toSourceLocation(n,i=>!!i.navigation))return r;return null}function Lt(e,n){let t=0,r=e.lineStarts.length-1;for(;t<=r;){let o=Math.floor((t+r)/2);e.lineStarts[o]<=n?t=o+1:r=o-1}let i=Math.max(0,r);return{line:i,character:n-e.lineStarts[i]}}function je(e,n){return h(e,n).startsWith("node_modules/")}function h(e,n){return ht(e,n).replaceAll("\\","/")}function Ot(e){switch(mt(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 Me(){let e=new Map;return{get(n){if(e.has(n))return e.get(n)??null;try{let t=J(n,"utf-8"),r={text:t,lineStarts:Dt(t)};return e.set(n,r),r}catch{return e.set(n,null),null}},positionAt:Lt}}function Dt(e){let n=[0];for(let t=0;t<e.length;t++)e.charCodeAt(t)===10&&n.push(t+1);return n}function Tt(e,n){let t=new Map,r=500;for(let i=0;i<n.length;i+=r){let o=n.slice(i,i+r),s=e.prepare(`SELECT id, relative_path AS relativePath FROM documents WHERE relative_path IN (${o.map(()=>"?").join(",")})`).all(...o);for(let a of s)t.set(a.relativePath,a.id)}return t}function Ft(e){try{let n=JSON.parse(J(Ie(e,"package.json"),"utf-8"));return{name:n.name??"workspace",version:n.version??"0.0.0"}}catch{return{name:"workspace",version:"0.0.0"}}}function Et(e,n,t,r){let i=h(t,r),o=Ne(n.name,n.version,i);return e.get(o)?.id??null}function Ne(e,n,t){let r=t.split("/").map(i=>`\`${i.replaceAll("`","")}\``).join("/");return`scip-vue npm ${e} ${n} ${r}/default.`}function Bt(e){y({projectRoot:e.projectRoot,dbPath:e.dbPath});let n=$t(e.projectRoot,e.tsconfig);if(!jt(n))throw new Error(`Vue tsconfig not found at ${n}`);let t=new Vt(e.dbPath);try{let r=Pe(t,e.projectRoot),i=_t(At(e.dbPath),"augment-vue-meta.json"),o=Ae(t,e.projectRoot,e.tsconfig),s=Ut(i,o,e.onStatus);if(s)return s;let a=Wt({db:t,projectRoot:e.projectRoot,dbPath:e.dbPath,tsconfig:e.tsconfig,configPath:n,vueFiles:r,onStatus:e.onStatus});return zt(i,Ae(t,e.projectRoot,e.tsconfig),a),a}finally{t.close()}}function Ut(e,n,t){let r=Jt(e,n);return r&&t?.(`Vue references unchanged; reused ${r.resolvedReferences} cached resolved references.`),r}function Wt(e){let n=Le(e.db,e.projectRoot,e.vueFiles),t=Ht(e,n),r=Te(t.occurrences),i=Oe(e.db,e.projectRoot,e.vueFiles,n,r),o={vueFiles:e.vueFiles.length,resolvedReferences:r.length,insertedMentions:i,skippedReferences:t.skippedReferences,syntheticSymbols:n.syntheticSymbols};return e.onStatus?.(`Resolved ${o.resolvedReferences} Vue references with Volar; inserted ${o.insertedMentions} mentions.`),o}function Ht(e,n){if(xe(e.vueFiles))return Se({projectRoot:e.projectRoot,dbPath:e.dbPath,tsconfig:e.tsconfig,vueFiles:e.vueFiles});let t=Me(),r=Ce(e.projectRoot,e.configPath);return Gt({projectRoot:e.projectRoot,vueFiles:r.fileNames.filter(i=>i.endsWith(".vue")),context:r,symbolLookup:we(e.db,e.projectRoot,t),vueSymbolLookup:n,sourceReader:t})}function Jt(e,n){try{let t=JSON.parse(Mt(e,"utf-8"));return JSON.stringify(t.fingerprint)===JSON.stringify(n)?t.result:null}catch{return null}}function zt(e,n,t){Nt(e,JSON.stringify({updatedAt:new Date().toISOString(),fingerprint:n,result:t},null,2)+`
|
|
51
|
+
`)}function Ae(e,n,t){let r=e.prepare(`
|
|
52
|
+
SELECT
|
|
53
|
+
(SELECT COUNT(*) FROM documents) AS documents,
|
|
54
|
+
(SELECT COUNT(*) FROM global_symbols) AS symbols,
|
|
55
|
+
(SELECT COUNT(*) FROM chunks) AS chunks,
|
|
56
|
+
(SELECT COUNT(*) FROM mentions) AS mentions,
|
|
57
|
+
(SELECT COUNT(*) FROM defn_enclosing_ranges) AS ranges,
|
|
58
|
+
(SELECT MAX(id) FROM chunks) AS maxChunkId,
|
|
59
|
+
(SELECT MAX(id) FROM global_symbols) AS maxSymbolId
|
|
60
|
+
`).get();return{version:2,tsconfig:t,files:v(n),db:r}}function Gt(e){let n=[],t=0,r=e.tasks??e.vueFiles.map(i=>({fileName:i,startOffset:0,endOffset:Number.POSITIVE_INFINITY,countFileSkip:!0}));for(let i of r){let o=qt(e,i);n.push(...o.occurrences),t+=o.skippedReferences}return{occurrences:n,skippedReferences:t}}function qt(e,n){let t=e.context.language.scripts.get(n.fileName),r=t?.generated?.languagePlugin.typescript?.getServiceScript(t.generated.root)?.code;if(!t||!r)return{occurrences:[],skippedReferences:n.countFileSkip?1:0};let i=e.sourceReader.get(n.fileName);if(!i)return{occurrences:[],skippedReferences:n.countFileSkip?1:0};let o=e.context.language.maps.get(r,t),s=h(e.projectRoot,n.fileName),a=[...Ee(i.text)],u={tokens:a.filter(c=>c.start>=n.startOffset&&c.start<n.endOffset),tokenByStart:new Map(a.map(c=>[c.start,c])),tokenTextCounts:Yt(a),processedStarts:new Set};return Kt({...e,fileName:n.fileName,sourceInfo:i,sourceFile:s,map:o,tokenContext:u})}function Kt(e){let n=[],t=0;for(let r of e.tokenContext.tokens){if(e.tokenContext.processedStarts.has(r.start))continue;let i=Ve(e.map,r.start);if(i===null)continue;let s=(e.context.languageService.getDefinitionAtPosition(e.fileName,i+1)??[]).find(u=>!je(e.projectRoot,u.fileName));if(!s){t++;continue}let a=De(s,e.symbolLookup,e.vueSymbolLookup,e.context,e.projectRoot);if(a===null){t++;continue}_e(n,e.sourceReader,e.sourceInfo,e.sourceFile,r,a),e.tokenContext.processedStarts.add(r.start),Xt(n,e,r,i,a)}return{occurrences:n,skippedReferences:t}}function Xt(e,n,t,r,i){if(!((n.tokenContext.tokenTextCounts.get(t.text)??0)<=1))for(let o of Qt(n.context.languageService,n.fileName,r+1,n.map,t,n.tokenContext.tokenByStart)){if(n.tokenContext.processedStarts.has(o))continue;let s=n.tokenContext.tokenByStart.get(o);s&&(_e(e,n.sourceReader,n.sourceInfo,n.sourceFile,s,i),n.tokenContext.processedStarts.add(o))}}function _e(e,n,t,r,i,o){let s=n.positionAt(t,i.start);e.push({sourceFile:r,sourceLine:s.line,sourceStartChar:s.character,sourceEndChar:s.character+i.text.length,symbolId:o})}function Yt(e){let n=new Map;for(let t of e)n.set(t.text,(n.get(t.text)??0)+1);return n}function Qt(e,n,t,r,i,o){let s=e.getDocumentHighlights?.(n,t,[n])??[],a=[];for(let u of s)if(u.fileName===n)for(let c of u.highlightSpans){let g=Zt(r,c.textSpan.start,o,i.text);g!==null&&a.push(g)}return a}function Zt(e,n,t,r){let i=t.get(n);if(i?.text===r)return i.start;let o=z(e,n);if(o===null)return null;let s=t.get(o);return s?.text===r?s.start:null}async function Bi(e){let{projectRoot:n,maxHeapMb:t=8192,onStatus:r=console.log,skipAutoInstall:i=!1}=e,o=sr(e),s=Date.now();$e(b(o.outputScip),{recursive:!0}),$e(b(o.outputDb),{recursive:!0});let a=e.languages??L(n);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=Rr(n,a,{pnpmWorkspaces:e.pnpmWorkspaces}),c=Sr(f(b(o.outputDb),"index.lock")),g=null;try{let l=ar({opts:e,paths:o,languages:a,fingerprint:u,start:s,onStatus:r});if(l)return l;pr(i,r);let p=ur(o);return g=p.runDir,await cr({opts:e,languages:a,projectRoot:n,paths:o,tempPaths:p,fingerprint:u,start:s,maxHeapMb:t,skipAutoInstall:i,onStatus:r})}finally{g&&X(g,{recursive:!0,force:!0}),c()}}function sr(e){let n=e.outputScip??f(e.projectRoot,"index.scip"),t=e.outputDb??f(e.projectRoot,"index.db");return{outputScip:n,outputDb:t,metaPath:f(b(t),"meta.json")}}function ar(e){if(e.opts.skipIfUnchanged===!1||!q(e.paths.outputScip)||!q(e.paths.outputDb)||!kr(e.paths.metaPath,e.fingerprint))return null;y({projectRoot:e.opts.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus});let n=Date.now()-e.start;return e.onStatus(`Index unchanged; reused existing SQLite index in ${(n/1e3).toFixed(1)}s`),{languages:e.languages,indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:n,reused:!0,skipped:[]}}function ur(e){let n=tr(f(b(e.outputDb),"reindex-"));return{runDir:n,tempOutputScip:f(n,C(e.outputScip)),tempOutputDb:f(n,C(e.outputDb)),tempMetaPath:f(n,C(e.metaPath))}}async function cr(e){let n={...process.env,NODE_OPTIONS:`--max-old-space-size=${e.maxHeapMb}`},{indexedOutputs:t,skippedLanguages:r}=await lr(e,n);gr(e,n,t,r);let i=Date.now()-e.start;return e.onStatus(`Done in ${(i/1e3).toFixed(1)}s`),{languages:t.map(o=>o.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:i,reused:!1,skipped:r}}async function lr(e,n){let{preparedRuns:t,skippedLanguages:r}=dr({languages:e.languages,tempOutputScip:e.tempPaths.tempOutputScip,projectRoot:e.projectRoot,env:n,skipAutoInstall:e.skipAutoInstall,pnpmWorkspaces:e.opts.pnpmWorkspaces,onStatus:e.onStatus}),i=await me(t,e.projectRoot,e.onStatus,e.opts.indexerConcurrency),{indexedOutputs:o}=mr(i,r);return hr(o,r,e.languages,e.opts.allowPartial,e.onStatus),{indexedOutputs:o,skippedLanguages:r}}function gr(e,n,t,r){br(t,e.tempPaths.tempOutputScip,e.onStatus),yr(e.tempPaths.tempOutputScip,e.tempPaths.tempOutputDb,n,e.onStatus),y({projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,onStatus:e.onStatus}),Ir(e.tempPaths.tempMetaPath,{version:2,status:r.length===0?"complete":"partial",updatedAt:new Date().toISOString(),fingerprint:e.fingerprint,requestedLanguages:e.languages,indexedLanguages:t.map(i=>i.language),skipped:[...r]}),vr({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 pr(e,n){if(!m("scip")){if(e)throw new Error(`The scip CLI is required but not found on PATH.
|
|
61
|
+
Install from: https://github.com/sourcegraph/scip/releases`);if(n("scip CLI not found on PATH. Attempting auto-install..."),!w(n))throw new Error(`The scip CLI is required but could not be installed.
|
|
62
|
+
Install manually from: https://github.com/sourcegraph/scip/releases`)}}function dr(e){let n=[],t=[],r=e.languages.map((i,o)=>({language:i,scipPath:e.languages.length>1?xr(e.tempOutputScip,i,o):e.tempOutputScip}));for(let{language:i,scipPath:o}of r){let s=fr({...e,language:i,scipPath:o});"skipped"in s?t.push(s.skipped):n.push(s.prepared)}return{preparedRuns:n,skippedLanguages:t}}function fr(e){let n=D(e.language),t=I(n),r=$(n,e.projectRoot);if(!r&&!_(n)){if(e.skipAutoInstall){let a=`${t} not found on PATH (auto-install disabled). ${n.installUrl??""}`.trim();return e.onStatus(`Skipping ${e.language}: ${a}`),{skipped:{language:e.language,reason:a}}}if(e.onStatus(`${t} not found. Attempting auto-install...`),!U(n,e.onStatus)){let a=`${t} could not be auto-installed. ${n.installUrl?`Install manually from ${n.installUrl}`:`Install ${t} and put it on PATH.`}`;return e.onStatus(`Skipping ${e.language}: ${a}`),{skipped:{language:e.language,reason:a}}}}let i=r??x(n);if(!i){let a=`${t} was not found after installation checks.`;return e.onStatus(`Skipping ${e.language}: ${a}`),{skipped:{language:e.language,reason:a}}}let{binary:o,args:s}=n.indexArgs({projectRoot:e.projectRoot,outputPath:e.scipPath,pnpmWorkspaces:e.pnpmWorkspaces,indexerBinary:i});return{prepared:{language:e.language,scipPath:e.scipPath,config:n,resolvedBinary:i,binary:o,args:s,env:B(n,e.env,i)}}}function mr(e,n){let t=[];for(let r of e)r.skipped?n.push(r.skipped):t.push({language:r.language,scipPath:r.scipPath});return{indexedOutputs:t}}function hr(e,n,t,r,i){if(e.length===0){let o=n.map(s=>` - ${s.language}: ${s.reason}`).join(`
|
|
63
|
+
`);throw new Error(`No language indexers ran successfully. Install at least one indexer for the languages in this project.
|
|
64
|
+
`+o)}if(n.length!==0&&(i(`Indexed ${e.length} of ${t.length} languages; skipped ${n.map(o=>o.language).join(", ")}.`),!r))throw new Error(`Failed to index all required languages; preserving the previous index. Pass --allow-partial to intentionally write an incomplete index.
|
|
65
|
+
`+n.map(o=>` - ${o.language}: ${o.reason}`).join(`
|
|
66
|
+
`))}function br(e,n,t){e.length>1?(t(`Merging ${e.length} language indexes...`),F(e.map(r=>r.scipPath),n)):e[0].scipPath!==n&&K(e[0].scipPath,n)}function yr(e,n,t,r){if(r("Converting to SQLite..."),!q(e))throw new Error(`SCIP index not found at ${e} after indexing`);try{let i=de(e);i.removedDefinitionOccurrences>0&&r(`Sanitized ${i.removedDefinitionOccurrences} invalid definition occurrences across ${i.touchedDocuments} documents before SQLite conversion.`),er("scip",["expt-convert","--output",n,e],{env:t,stdio:"pipe",maxBuffer:50*1024*1024})}catch(i){let o=i instanceof Error?i.message:String(i);throw new Error(`Failed to convert SCIP index to SQLite: ${o}`,{cause:i})}}function xr(e,n,t){let r=or(e)||".scip",i=C(e,r);return f(b(e),`${i}.${t+1}.${n}${r}`)}function Sr(e){let n;try{n=rr(e,"wx")}catch(t){throw(typeof t=="object"&&t&&"code"in t?t.code:void 0)==="EEXIST"?new Error(`Another scip-query reindex is already running for ${b(e)}.`,{cause:t}):t}return Be(n,JSON.stringify({pid:process.pid,startedAt:new Date().toISOString()})+`
|
|
67
|
+
`),()=>{try{nr(n)}finally{X(e,{force:!0})}}}function vr(e){G(e.tempOutputScip,e.outputScip),G(e.tempOutputDb,e.outputDb),G(e.tempMetaPath,e.metaPath)}function G(e,n){X(`${n}.tmp-replace`,{force:!0}),K(e,`${n}.tmp-replace`),K(`${n}.tmp-replace`,n)}function Rr(e,n,t){return{version:1,languages:[...n].sort(),pnpmWorkspaces:t.pnpmWorkspaces===!0,files:v(e)}}function kr(e,n){try{let t=JSON.parse(ir(e,"utf-8"));return t.version===2&&t.status==="complete"&&P(t.fingerprint)===P(n)&&P([...t.indexedLanguages??[]].sort())===P(n.languages)}catch{return!1}}function Ir(e,n){Be(e,`${JSON.stringify(n,null,2)}
|
|
68
|
+
`)}function P(e){return JSON.stringify(e)}export{ae as INDEXER_CONFIGS,y as augmentAuxiliaryDocuments,Bt as augmentVueResolvedReferences,I as describeIndexerBinary,L as detectLanguages,D as getIndexerConfig,B as getIndexerExecutionEnv,m as isBinaryAvailable,_ as isIndexerInstalled,F as mergeScipFiles,ue as mergeScipIndexes,Bi as reindex,x as resolveIndexerBinary,$ as resolveProjectLocalIndexerBinary,U as tryInstallIndexer,w as tryInstallScipCli};
|
|
69
|
+
//# sourceMappingURL=reindex.js.map
|