scip-query 0.13.0 → 0.15.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/CHANGELOG.md +19 -0
- package/README.md +16 -2
- package/dist/augment-vue-worker.js +1 -1
- package/dist/{chunk-U3VMUDXJ.js → chunk-4SCMYKD6.js} +1 -1
- package/dist/{chunk-FERAXG6Y.js → chunk-X7CHWTZ2.js} +1 -1
- package/dist/chunk-YBGC7HTY.js +3 -0
- package/dist/cli.js +259 -251
- package/dist/{config-types-BrHl3Bge.d.ts → config-types-aCgyLrvE.d.ts} +2 -0
- package/dist/{db-_Bdx0E1W.d.ts → db-DwCdT3rv.d.ts} +1 -1
- package/dist/{health-BEZ1Rt0S.d.ts → health-nJUidasZ.d.ts} +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/queries/affected.d.ts +2 -2
- package/dist/queries/bottlenecks.d.ts +2 -2
- package/dist/queries/by-kind.d.ts +2 -2
- package/dist/queries/call-graph.d.ts +2 -2
- package/dist/queries/change-surface.d.ts +2 -2
- package/dist/queries/cleanup-plan.d.ts +2 -2
- package/dist/queries/co-change.d.ts +2 -2
- package/dist/queries/code.d.ts +2 -2
- package/dist/queries/complexity-hotspots.d.ts +2 -2
- package/dist/queries/complexity.d.ts +2 -2
- package/dist/queries/convergence.d.ts +2 -2
- package/dist/queries/coupling.d.ts +2 -2
- package/dist/queries/cycles.d.ts +2 -2
- package/dist/queries/dataflow.d.ts +2 -2
- package/dist/queries/dead.d.ts +2 -2
- package/dist/queries/decorative-checkers.d.ts +2 -2
- package/dist/queries/deep-chains.d.ts +2 -2
- package/dist/queries/deps.d.ts +2 -2
- package/dist/queries/diff-gate.d.ts +2 -2
- package/dist/queries/diff-gate.js +1 -1
- package/dist/queries/diff-impact.d.ts +2 -2
- package/dist/queries/doc-drift.d.ts +2 -2
- package/dist/queries/drift.d.ts +2 -2
- package/dist/queries/duplicate-bodies.d.ts +2 -2
- package/dist/queries/extract-candidates.d.ts +2 -2
- package/dist/queries/fan.d.ts +2 -2
- package/dist/queries/files.d.ts +2 -2
- package/dist/queries/health.d.ts +3 -3
- package/dist/queries/health.js +1 -1
- package/dist/queries/hierarchy.d.ts +2 -2
- package/dist/queries/hotspots.d.ts +2 -2
- package/dist/queries/imports.d.ts +2 -2
- package/dist/queries/incomplete-migration.d.ts +2 -2
- package/dist/queries/index.d.ts +3 -3
- package/dist/queries/index.js +1 -1
- package/dist/queries/isolated.d.ts +2 -2
- package/dist/queries/locality-candidates.d.ts +2 -2
- package/dist/queries/members.d.ts +2 -2
- package/dist/queries/methods.d.ts +2 -2
- package/dist/queries/not-implemented.d.ts +2 -2
- package/dist/queries/outline.d.ts +2 -2
- package/dist/queries/passthrough-candidates.d.ts +2 -2
- package/dist/queries/plan-context.d.ts +2 -2
- package/dist/queries/react-component-duplicates.d.ts +2 -2
- package/dist/queries/react-hook-candidates.d.ts +2 -2
- package/dist/queries/react-large-component-pressure.d.ts +2 -2
- package/dist/queries/recent-duplicates.d.ts +2 -2
- package/dist/queries/redundant-reexports.d.ts +2 -2
- package/dist/queries/refs.d.ts +2 -2
- package/dist/queries/self-audit.d.ts +2 -2
- package/dist/queries/similar-chains.d.ts +2 -2
- package/dist/queries/similar-files.d.ts +2 -2
- package/dist/queries/similar-signatures.d.ts +2 -2
- package/dist/queries/similar.d.ts +2 -2
- package/dist/queries/slice.d.ts +2 -2
- package/dist/queries/stale-abstractions.d.ts +2 -2
- package/dist/queries/stats.d.ts +2 -2
- package/dist/queries/surface.d.ts +2 -2
- package/dist/queries/symbols.d.ts +2 -2
- package/dist/queries/system.d.ts +2 -2
- package/dist/queries/test-quality.d.ts +2 -2
- package/dist/queries/trace.d.ts +2 -2
- package/dist/queries/twin-ab.d.ts +2 -2
- package/dist/queries/twin-drift.d.ts +2 -2
- package/dist/queries/unused-imports.d.ts +2 -2
- package/dist/queries/unused-params.d.ts +2 -2
- package/dist/queries/vue-component-duplicates.d.ts +2 -2
- package/dist/queries/vue-composable-candidates.d.ts +2 -2
- package/dist/queries/vue-large-view-pressure.d.ts +2 -2
- package/dist/queries/wrapper-candidates.d.ts +2 -2
- package/dist/reindex-worker.js +12 -11
- package/dist/reindex.d.ts +3 -3
- package/dist/reindex.js +20 -19
- package/dist/runtime.d.ts +3 -3
- package/dist/runtime.js +2 -2
- package/dist/{scip-cli-C7cg4ZHR.d.ts → scip-cli-DeAbuJ2b.d.ts} +1 -1
- package/docs/COMMAND_REFERENCE.md +2 -1
- package/package.json +1 -1
- package/skills/_shared/SKILL.md +3 -1
- package/skills/scip-calibrate/SKILL.md +7 -3
- package/skills/scip-verify/SKILL.md +6 -1
- package/dist/chunk-XC2PJOVM.js +0 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { S as ScipDatabase } from '../db-
|
|
1
|
+
import { S as ScipDatabase } from '../db-DwCdT3rv.js';
|
|
2
2
|
import 'better-sqlite3';
|
|
3
|
-
import '../config-types-
|
|
3
|
+
import '../config-types-aCgyLrvE.js';
|
|
4
4
|
|
|
5
5
|
type AuditQuestion = 'references' | 'callees';
|
|
6
6
|
type AuditOracleKind = 'semantic' | 'source';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { S as ScipDatabase } from '../db-
|
|
1
|
+
import { S as ScipDatabase } from '../db-DwCdT3rv.js';
|
|
2
2
|
import 'better-sqlite3';
|
|
3
|
-
import '../config-types-
|
|
3
|
+
import '../config-types-aCgyLrvE.js';
|
|
4
4
|
|
|
5
5
|
interface SimilarChainResult {
|
|
6
6
|
chainA: string[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { S as ScipDatabase } from '../db-
|
|
1
|
+
import { S as ScipDatabase } from '../db-DwCdT3rv.js';
|
|
2
2
|
import 'better-sqlite3';
|
|
3
|
-
import '../config-types-
|
|
3
|
+
import '../config-types-aCgyLrvE.js';
|
|
4
4
|
|
|
5
5
|
interface SimilarFileResult {
|
|
6
6
|
fileA: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { S as ScipDatabase } from '../db-
|
|
1
|
+
import { S as ScipDatabase } from '../db-DwCdT3rv.js';
|
|
2
2
|
import 'better-sqlite3';
|
|
3
|
-
import '../config-types-
|
|
3
|
+
import '../config-types-aCgyLrvE.js';
|
|
4
4
|
|
|
5
5
|
type SignatureLocBand = '<=5' | '6-20' | '>20';
|
|
6
6
|
type SimilarSignatureFunction = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { S as ScipDatabase } from '../db-
|
|
1
|
+
import { S as ScipDatabase } from '../db-DwCdT3rv.js';
|
|
2
2
|
import 'better-sqlite3';
|
|
3
|
-
import '../config-types-
|
|
3
|
+
import '../config-types-aCgyLrvE.js';
|
|
4
4
|
|
|
5
5
|
interface SimilarSymbolResult {
|
|
6
6
|
symbolA: string;
|
package/dist/queries/slice.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { S as ScipDatabase } from '../db-
|
|
1
|
+
import { S as ScipDatabase } from '../db-DwCdT3rv.js';
|
|
2
2
|
import 'better-sqlite3';
|
|
3
|
-
import '../config-types-
|
|
3
|
+
import '../config-types-aCgyLrvE.js';
|
|
4
4
|
|
|
5
5
|
type StaleAbstractionActionTier = 'direct' | 'signal';
|
|
6
6
|
type StalenessKind = 'unused-abstraction' | 'misplaced-single-consumer-type' | 'single-consumer-abstraction' | 'one-to-one-class-encapsulation';
|
package/dist/queries/stats.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { S as ScipDatabase } from '../db-
|
|
1
|
+
import { S as ScipDatabase } from '../db-DwCdT3rv.js';
|
|
2
2
|
import 'better-sqlite3';
|
|
3
|
-
import '../config-types-
|
|
3
|
+
import '../config-types-aCgyLrvE.js';
|
|
4
4
|
|
|
5
5
|
interface StatsResult {
|
|
6
6
|
documents: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { S as ScipDatabase } from '../db-
|
|
1
|
+
import { S as ScipDatabase } from '../db-DwCdT3rv.js';
|
|
2
2
|
import 'better-sqlite3';
|
|
3
|
-
import '../config-types-
|
|
3
|
+
import '../config-types-aCgyLrvE.js';
|
|
4
4
|
|
|
5
5
|
interface SurfaceResult {
|
|
6
6
|
consumer: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { S as ScipDatabase } from '../db-
|
|
1
|
+
import { S as ScipDatabase } from '../db-DwCdT3rv.js';
|
|
2
2
|
import 'better-sqlite3';
|
|
3
|
-
import '../config-types-
|
|
3
|
+
import '../config-types-aCgyLrvE.js';
|
|
4
4
|
|
|
5
5
|
interface SymbolResult {
|
|
6
6
|
startLine: number;
|
package/dist/queries/system.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { S as ScipDatabase } from '../db-
|
|
1
|
+
import { S as ScipDatabase } from '../db-DwCdT3rv.js';
|
|
2
2
|
import { SymbolResult } from './symbols.js';
|
|
3
3
|
import 'better-sqlite3';
|
|
4
|
-
import '../config-types-
|
|
4
|
+
import '../config-types-aCgyLrvE.js';
|
|
5
5
|
|
|
6
6
|
interface SystemResult {
|
|
7
7
|
files: string[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { S as ScipDatabase } from '../db-
|
|
1
|
+
import { S as ScipDatabase } from '../db-DwCdT3rv.js';
|
|
2
2
|
import 'better-sqlite3';
|
|
3
|
-
import '../config-types-
|
|
3
|
+
import '../config-types-aCgyLrvE.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* test-quality (D3): the biggest uncovered surface — test files are not
|
package/dist/queries/trace.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { S as ScipDatabase } from '../db-
|
|
1
|
+
import { S as ScipDatabase } from '../db-DwCdT3rv.js';
|
|
2
2
|
import 'better-sqlite3';
|
|
3
|
-
import '../config-types-
|
|
3
|
+
import '../config-types-aCgyLrvE.js';
|
|
4
4
|
|
|
5
5
|
interface TraceResult {
|
|
6
6
|
definitions: Array<{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { S as ScipDatabase } from '../db-
|
|
1
|
+
import { S as ScipDatabase } from '../db-DwCdT3rv.js';
|
|
2
2
|
import 'better-sqlite3';
|
|
3
|
-
import '../config-types-
|
|
3
|
+
import '../config-types-aCgyLrvE.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* twin-ab (Q4): mechanical support for scip-integrity-audit drill 5
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { S as ScipDatabase } from '../db-
|
|
1
|
+
import { S as ScipDatabase } from '../db-DwCdT3rv.js';
|
|
2
2
|
import 'better-sqlite3';
|
|
3
|
-
import '../config-types-
|
|
3
|
+
import '../config-types-aCgyLrvE.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Twin-drift: same leaf name (or a near-name variant like escapeRegex vs
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { S as ScipDatabase } from '../db-
|
|
1
|
+
import { S as ScipDatabase } from '../db-DwCdT3rv.js';
|
|
2
2
|
import 'better-sqlite3';
|
|
3
|
-
import '../config-types-
|
|
3
|
+
import '../config-types-aCgyLrvE.js';
|
|
4
4
|
|
|
5
5
|
interface UnusedParamsFinding {
|
|
6
6
|
symbol: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { S as ScipDatabase } from '../db-
|
|
1
|
+
import { S as ScipDatabase } from '../db-DwCdT3rv.js';
|
|
2
2
|
import { F as FrontendBehaviorEvidenceClass, a as FrontendBehaviorActionTier } from '../frontend-behavior-evidence-EfM4_9bc.js';
|
|
3
3
|
import 'better-sqlite3';
|
|
4
|
-
import '../config-types-
|
|
4
|
+
import '../config-types-aCgyLrvE.js';
|
|
5
5
|
|
|
6
6
|
interface VueComponentDuplicateResult {
|
|
7
7
|
fileA: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { S as ScipDatabase } from '../db-
|
|
1
|
+
import { S as ScipDatabase } from '../db-DwCdT3rv.js';
|
|
2
2
|
import { a as FrontendBehaviorActionTier, F as FrontendBehaviorEvidenceClass } from '../frontend-behavior-evidence-EfM4_9bc.js';
|
|
3
3
|
import 'better-sqlite3';
|
|
4
|
-
import '../config-types-
|
|
4
|
+
import '../config-types-aCgyLrvE.js';
|
|
5
5
|
|
|
6
6
|
type VueComposableEvidenceClass = FrontendBehaviorEvidenceClass;
|
|
7
7
|
type VueComposableActionTier = FrontendBehaviorActionTier;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { S as ScipDatabase } from '../db-
|
|
1
|
+
import { S as ScipDatabase } from '../db-DwCdT3rv.js';
|
|
2
2
|
import 'better-sqlite3';
|
|
3
|
-
import '../config-types-
|
|
3
|
+
import '../config-types-aCgyLrvE.js';
|
|
4
4
|
|
|
5
5
|
type VueLargeViewPressureAxis = 'template' | 'script' | 'style' | 'external-script' | 'custom-block' | 'total';
|
|
6
6
|
type VueLargeViewContextKind = 'component' | 'route-page';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { S as ScipDatabase } from '../db-
|
|
1
|
+
import { S as ScipDatabase } from '../db-DwCdT3rv.js';
|
|
2
2
|
import 'better-sqlite3';
|
|
3
|
-
import '../config-types-
|
|
3
|
+
import '../config-types-aCgyLrvE.js';
|
|
4
4
|
|
|
5
5
|
type WrapperActionTier = 'direct' | 'signal';
|
|
6
6
|
interface WrapperCandidate {
|
package/dist/reindex-worker.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import{a as
|
|
2
|
-
`)){if(!r)continue;let i=Z(r).toLowerCase();i&&n.add(i)}return n}catch{return null}}function Xe(e,t){return t?.length?t.some(n=>e.has(n)):!1}function Y(e,t){let n=e.indexOf(t);n!==-1&&e.splice(n,1)}import{existsSync as ne,readdirSync as He}from"fs";import{isAbsolute as Ke,join as D,resolve as Qe}from"path";var Ye={typescript:{language:"typescript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,pnpmWorkspaces:t,indexerBinary:n,projectPath:r})=>{let i=r?["index","--output",e,"--no-progress-bar",r]:["index","--infer-tsconfig","--output",e,"--no-progress-bar"];return t&&!r&&i.splice(1,0,"--pnpm-workspaces"),{binary:n,args:i}},markerFiles:["tsconfig.json"],installMethods:[{label:"npm",prerequisite:"npm",binary:"npm",args:["install","-g","@sourcegraph/scip-typescript"]}],installUrl:"https://github.com/sourcegraph/scip-typescript",bundledNpmPackage:"@sourcegraph/scip-typescript"},javascript:{language:"javascript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,indexerBinary:t})=>({binary:t,args:["index","--infer-tsconfig","--output",e,"--no-progress-bar"]}),markerFiles:["package.json"],installMethods:[{label:"npm",prerequisite:"npm",binary:"npm",args:["install","-g","@sourcegraph/scip-typescript"]}],installUrl:"https://github.com/sourcegraph/scip-typescript",bundledNpmPackage:"@sourcegraph/scip-typescript"},java:{language:"java",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:["pom.xml","build.gradle"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},scala:{language:"scala",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:["build.sbt"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},kotlin:{language:"kotlin",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:["build.gradle.kts"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},rust:{language:"rust",indexerBinary:"rust-analyzer",checkCommand:"rust-analyzer --version",indexArgs:({outputPath:e})=>({binary:"rust-analyzer",args:["scip",".","--output",e]}),markerFiles:["Cargo.toml"],installMethods:[{label:"rustup",prerequisite:"rustup",binary:"rustup",args:["component","add","rust-analyzer"]}],installUrl:"https://github.com/rust-lang/rust-analyzer"},python:{language:"python",indexerBinary:"scip-python-plus",binaryAliases:["scip-python"],checkCommand:"scip-python-plus --version",indexArgs:({outputPath:e,indexerBinary:t})=>({binary:t,args:["index","--output",e,"--project-name","project"]}),markerFiles:["pyproject.toml","setup.py"],installMethods:[{label:"npm",prerequisite:"npm",binary:"npm",args:["install","-g","scip-python-plus"]}],installUrl:"https://github.com/PlunderStruck/scip-python",bundledNpmPackage:"scip-python-plus"},clojure:{language:"clojure",indexerBinary:"scip-clojure",projectLocalBinaries:["node_modules/.bin/scip-clojure"],checkCommand:"scip-clojure -h",indexArgs:({projectRoot:e,outputPath:t,indexerBinary:n,configPath:r})=>{let i=["-root",e,"-output",t];return r&&i.push("-config",Ke(r)?r:Qe(e,r)),{binary:n,args:i}},markerFiles:["deps.edn","project.clj","bb.edn","shadow-cljs.edn"],installMethods:[],installUrl:"https://github.com/PlunderStruck/scip-clojure"},ruby:{language:"ruby",indexerBinary:"scip-ruby",checkCommand:"scip-ruby --version",indexArgs:({indexerBinary:e})=>({binary:e,args:["--dir","."]}),defaultOutputPath:"index.scip",markerFiles:["Gemfile"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-ruby/releases"},go:{language:"go",indexerBinary:"scip-go",checkCommand:"scip-go --version",indexArgs:({outputPath:e})=>({binary:"scip-go",args:["--output",e]}),markerFiles:["go.mod"],installMethods:[{label:"go install",prerequisite:"go",binary:"go",args:["install","github.com/sourcegraph/scip-go@latest"]}],installUrl:"https://github.com/sourcegraph/scip-go"},cpp:{language:"cpp",indexerBinary:"scip-clang",checkCommand:"scip-clang --version",indexArgs:({outputPath:e})=>({binary:"scip-clang",args:["--compdb-path","compile_commands.json","--index-output-path",e]}),markerFiles:["CMakeLists.txt","Makefile"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-clang/releases"},c:{language:"c",indexerBinary:"scip-clang",checkCommand:"scip-clang --version",indexArgs:({outputPath:e})=>({binary:"scip-clang",args:["--compdb-path","compile_commands.json","--index-output-path",e]}),markerFiles:["CMakeLists.txt","Makefile"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-clang/releases"},csharp:{language:"csharp",indexerBinary:"scip-dotnet",checkCommand:"scip-dotnet --version",indexArgs:({projectRoot:e,outputPath:t})=>({binary:"scip-dotnet",args:["index",re(e,[".sln",".csproj"])??e,"--output",t,"--working-directory",e]}),markerFiles:["*.csproj","*.sln"],installMethods:[{label:"dotnet",prerequisite:"dotnet",binary:"dotnet",args:["tool","install","--global","scip-dotnet"]}],installUrl:"https://github.com/sourcegraph/scip-dotnet/releases"},vb:{language:"vb",indexerBinary:"scip-dotnet",checkCommand:"scip-dotnet --version",indexArgs:({projectRoot:e,outputPath:t})=>({binary:"scip-dotnet",args:["index",re(e,[".sln",".vbproj"])??e,"--output",t,"--working-directory",e]}),markerFiles:["*.vbproj","*.sln"],installMethods:[{label:"dotnet",prerequisite:"dotnet",binary:"dotnet",args:["tool","install","--global","scip-dotnet"]}],installUrl:"https://github.com/sourcegraph/scip-dotnet/releases"},dart:{language:"dart",indexerBinary:"scip-dart",checkCommand:"scip-dart --version",indexArgs:({indexerBinary:e,outputPath:t})=>({binary:e,args:["--output",t]}),markerFiles:["pubspec.yaml"],installMethods:[{label:"dart pub",prerequisite:"dart",binary:"dart",args:["pub","global","activate","scip_dart"]}],installUrl:"https://github.com/Workiva/scip-dart/releases"},php:{language:"php",indexerBinary:"scip-php",projectLocalBinaries:["vendor/davidrjenni/scip-php/bin/scip-php","vendor/bin/scip-php"],checkCommand:"scip-php --version",indexArgs:({projectRoot:e,indexerBinary:t})=>{let n=D(e,"vendor","bin","scip-php"),r=D(e,"vendor","davidrjenni","scip-php","bin","scip-php");return{binary:"php",args:["-d","error_reporting=E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED",ne(r)?r:ne(n)?n:t]}},defaultOutputPath:"index.scip",markerFiles:["composer.json"],installMethods:[],installUrl:"https://github.com/davidrjenni/scip-php/releases"}};function O(e){return Ye[e]}function re(e,t){let n;try{n=He(e)}catch{return null}for(let r of t)for(let i of n)if(i.endsWith(r))return D(e,i);return null}import{readFileSync as Ve,writeFileSync as Ze}from"fs";import{create as E}from"@bufbuild/protobuf";import{deserializeSCIP as et,serializeSCIP as tt,DocumentSchema as nt,IndexSchema as rt,SymbolInformationSchema as it}from"@c4312/scip";function at(e){if(e.length===0)throw new Error("Cannot merge zero SCIP indexes");if(e.length===1)return e[0];let t=st(e),n=ot(e.flatMap(i=>i.documents??[])),r=ie(e.flatMap(i=>i.externalSymbols??[]));return E(rt,{metadata:t,documents:n,externalSymbols:r})}function $(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let n=e.map(i=>et(Ve(i))),r=at(n);return Ze(t,Buffer.from(tt(r))),{documentCount:r.documents.length,externalSymbolCount:r.externalSymbols.length,inputCount:e.length}}function st(e){let t=e[0]?.metadata;if(!t)return;let n=t.projectRoot;for(let r of e.slice(1)){let i=r.metadata?.projectRoot;if(n&&i&&i!==n)throw new Error(`Cannot merge SCIP indexes with different project roots: ${n} vs ${i}`)}return t}function ot(e){let t=new Map;for(let n of e){let r=t.get(n.relativePath);if(!r){t.set(n.relativePath,n);continue}t.set(n.relativePath,E(nt,{language:r.language||n.language,relativePath:r.relativePath||n.relativePath,occurrences:ut([...r.occurrences,...n.occurrences]),symbols:ie([...r.symbols,...n.symbols]),text:lt(r.text,n.text),positionEncoding:r.positionEncoding||n.positionEncoding}))}return[...t.values()]}function ut(e){let t=new Set,n=[];for(let r of e){let i=JSON.stringify(r);t.has(i)||(t.add(i),n.push(r))}return n}function ie(e){let t=new Map;for(let n of e){let r=t.get(n.symbol);if(!r){t.set(n.symbol,n);continue}t.set(n.symbol,E(it,{symbol:r.symbol,documentation:pt([...r.documentation,...n.documentation]),relationships:ct([...r.relationships,...n.relationships]),kind:r.kind||n.kind,displayName:r.displayName||n.displayName,enclosingSymbol:r.enclosingSymbol||n.enclosingSymbol,signatureDocumentation:r.signatureDocumentation??n.signatureDocumentation}))}return[...t.values()]}function ct(e){let t=new Set,n=[];for(let r of e){let i=[r.symbol,r.isReference?"1":"0",r.isImplementation?"1":"0",r.isTypeDefinition?"1":"0",r.isDefinition?"1":"0"].join("|");t.has(i)||(t.add(i),n.push(r))}return n}function lt(e,t){return e?t?e.length>=t.length?e:t:e:t}function pt(e){return[...new Set(e)]}import{readFileSync as gt,writeFileSync as dt}from"fs";import{create as ae}from"@bufbuild/protobuf";import{deserializeSCIP as ft,DocumentSchema as mt,IndexSchema as ht,serializeSCIP as yt,SymbolRole as xt}from"@c4312/scip";function se(e){let t;try{t=ft(gt(e))}catch{return{removedDefinitionOccurrences:0,touchedDocuments:0}}let n=bt(t);return n.removedDefinitionOccurrences>0&&dt(e,Buffer.from(yt(n.index))),{removedDefinitionOccurrences:n.removedDefinitionOccurrences,touchedDocuments:n.touchedDocuments}}function bt(e){let t=new Set;for(let a of e.documents)for(let s of a.symbols)s.symbol&&t.add(s.symbol);for(let a of e.externalSymbols)a.symbol&&t.add(a.symbol);let n=0,r=0,i=[];for(let a of e.documents){let s=a.occurrences.filter(o=>(o.symbolRoles&xt.Definition)===0||t.has(o.symbol)?!0:(n+=1,!1));if(s.length===a.occurrences.length){i.push(a);continue}r+=1,i.push(ae(mt,{language:a.language,relativePath:a.relativePath,occurrences:s,symbols:a.symbols,text:a.text,positionEncoding:a.positionEncoding}))}return{index:n===0?e:ae(ht,{metadata:e.metadata,documents:i,externalSymbols:e.externalSymbols}),removedDefinitionOccurrences:n,touchedDocuments:r}}import{existsSync as Rt,readFileSync as jt,readdirSync as vt,statSync as It}from"fs";import p from"path";import{isAbsolute as Pt,relative as St}from"path";function oe(e,t){let n=St(e,t);return n===""||!n.startsWith("..")&&!Pt(n)}var kt=new Set([".cache",".git",".next",".nuxt",".turbo",".nx","build","coverage","dist","node_modules","tmp","vendor"]);function ue(e,t=[]){let n=p.resolve(e),r=wt(n),i=t.flatMap(c=>Ct(n,c)),a=Mt([...r,...i]),s=Dt(n,a)?[n,...a]:a,o=s.length>0?s:[n];return[...new Set(o.map(c=>Et(n,c)))].sort((c,l)=>c.localeCompare(l))}function wt(e){let t=[],n=[e];for(;n.length>0;){let r=n.pop(),i;try{i=vt(r,{withFileTypes:!0})}catch{continue}for(let a of i){let s=p.join(r,a.name);if(a.isDirectory()){!kt.has(a.name)&&!a.name.startsWith(".")&&n.push(s);continue}a.isFile()&&Lt(s)&&t.push(p.dirname(s))}}return t}function Ct(e,t){let n=t.trim();if(!n)return[];let r=p.resolve(e,n);if(!oe(e,r))return[];try{let i=It(r);if(i.isDirectory())return[r];if(i.isFile()&&ce(p.basename(r)))return[p.dirname(r)]}catch{return[]}return[]}function Lt(e){if(!ce(p.basename(e)))return!1;let t=le(e);return t?p.basename(e)==="tsconfig.json"||"include"in t||"files"in t||"references"in t:!1}function ce(e){return e.startsWith("tsconfig")&&e.endsWith(".json")}function Mt(e){let t=[...new Set(e.map(n=>p.resolve(n)))].sort((n,r)=>n.localeCompare(r));return t.length<=1?t:t.filter(n=>!t.some(r=>r!==n&&$t(n,r)))}function Dt(e,t){if(t.length===0||t.some(r=>p.resolve(r)===e))return!1;let n=p.join(e,"tsconfig.json");return Rt(n)&&Ot(n)}function Ot(e){let n=le(e)?.include;return Array.isArray(n)?n.some(r=>typeof r=="string"&&r.trim()!==""&&!r.startsWith("!")&&(r.includes("/")||r.includes("**")||!p.extname(r))):!1}function le(e){try{let t=JSON.parse(jt(e,"utf-8"));return t&&typeof t=="object"&&!Array.isArray(t)?t:null}catch{return null}}function Et(e,t){let n=p.relative(e,t);return n?n.split(p.sep).join("/"):"."}function $t(e,t){let n=p.relative(e,t);return!!n&&!n.startsWith("..")&&!p.isAbsolute(n)}import{execFile as Nt}from"child_process";import{existsSync as P,renameSync as A,rmSync as F,statSync as At}from"fs";import{cpus as Ft}from"os";import{join as pe}from"path";function Tt(e,t,n){if(!e.defaultOutputPath)return;let r=pe(t,e.defaultOutputPath);n!==r&&P(r)&&A(r,n)}function Bt(e,t,n){if(!e.defaultOutputPath)return null;let r=pe(t,e.defaultOutputPath);if(r===n)return null;let i=`${n}.default-output-backup`;return F(i,{force:!0}),P(r)?(A(r,i),{defaultOutputPath:r,backupPath:i}):{defaultOutputPath:r,backupPath:null}}function _t(e){e&&(F(e.defaultOutputPath,{force:!0}),e.backupPath&&P(e.backupPath)&&A(e.backupPath,e.defaultOutputPath))}function Wt(e,t){if(e<=1)return 1;let n=Number(process.env.SCIP_QUERY_INDEXER_CONCURRENCY??0),r=Number.isFinite(t)&&t&&t>0?t:Number.isFinite(n)&&n>0?n:Math.min(8,Math.max(1,Ft().length));return Math.max(1,Math.min(e,Math.floor(r)))}async function ge(e,t,n,r){let i=e.filter(l=>l.config.defaultOutputPath),a=e.filter(l=>!l.config.defaultOutputPath),s=[],o=Wt(a.length,r),c=await qt(a,o,l=>N(l,t,n));if(o>1){let l=new Map;for(let g of c.filter(u=>u.skipped)){let u=a.find(m=>m.id===g.id);u&&(n(`Retrying ${u.label} indexer serially after parallel failure...`),l.set(u.id,await N(u,t,n)))}s.push(...c.map(g=>l.get(g.id)??g))}else s.push(...c);for(let l of i)s.push(await N(l,t,n));return s.sort((l,g)=>e.findIndex(u=>u.id===l.id)-e.findIndex(u=>u.id===g.id))}async function N(e,t,n){n(`Indexing ${e.label} with ${e.resolvedBinary}...`),F(e.scipPath,{force:!0});let r=Bt(e.config,t,e.scipPath),i=[e.binary,...e.args].join(" "),a=Date.now();try{await Ut(e.binary,e.args,{cwd:t,env:e.env,maxBuffer:50*1024*1024}),Tt(e.config,t,e.scipPath)}catch(o){let c=o instanceof Error?o.message:String(o),l=`${e.resolvedBinary} indexer failed: ${c.split(`
|
|
3
|
-
|
|
4
|
-
Install from: https://github.com/sourcegraph/scip/releases`);if(on()==="win32")throw new Error("The scip CLI was not found. On Windows it ships via the npm sidecar package scip-query-scip-windows (installed automatically with scip-query). Reinstall with optional dependencies enabled, run 'npm install -g scip-query-scip-windows', or set SCIP_QUERY_SCIP_BIN to a local scip.exe path.");if(t("scip CLI not found on PATH. Attempting auto-install..."),!Q(t))throw new Error(`The scip CLI is required but could not be installed.
|
|
5
|
-
Install
|
|
1
|
+
import{a as $,b as A,c as N,d as B}from"./chunk-X7CHWTZ2.js";import{a as v,b as E,c as ge}from"./chunk-TFWDJDGO.js";import{execFileSync as An}from"child_process";import{createHash as Nn}from"crypto";import{closeSync as Bn,copyFileSync as ae,existsSync as j,mkdirSync as D,mkdtempSync as _n,openSync as Wn,readdirSync as Un,readFileSync as O,renameSync as R,rmSync as x,statSync as Jn,writeFileSync as Xe}from"fs";import{basename as M,dirname as g,extname as qn,join as f}from"path";import{platform as zn}from"os";import{execFileSync as ct}from"child_process";import{existsSync as ut,readdirSync as me}from"fs";import{extname as he,join as ye}from"path";var pt=new Set([".git",".hg",".svn",".idea",".vscode","node_modules","vendor","dist","build","target","bin","obj",".dart_tool",".gradle",".next",".venv","venv","__pycache__"]),lt=[{language:"typescript",files:["tsconfig.json","tsconfig.base.json"],extensions:[".ts",".tsx",".mts",".cts"]},{language:"rust",files:["Cargo.toml"],extensions:[".rs"]},{language:"go",files:["go.mod"],extensions:[".go"]},{language:"java",files:["pom.xml","build.gradle","build.gradle.kts"],extensions:[".java"]},{language:"kotlin",files:["build.gradle.kts"],extensions:[".kt",".kts"]},{language:"scala",files:["build.sbt"],extensions:[".scala"]},{language:"clojure",files:["deps.edn","project.clj","bb.edn","shadow-cljs.edn"],extensions:[".clj",".cljs",".cljc"]},{language:"python",files:["pyproject.toml","setup.py","setup.cfg","Pipfile"],extensions:[".py",".pyi"]},{language:"ruby",files:["Gemfile"],extensions:[".rb"]},{language:"cpp",files:["compile_commands.json","CMakeLists.txt","Makefile"],extensions:[".cc",".cpp",".cxx",".hpp",".hh",".hxx"]},{language:"c",files:["compile_commands.json","CMakeLists.txt","Makefile"],extensions:[".c",".h"]},{language:"csharp",globs:["*.csproj","*.sln"],extensions:[".cs"]},{language:"vb",globs:["*.vbproj"],extensions:[".vb"]},{language:"dart",files:["pubspec.yaml"],extensions:[".dart"]},{language:"php",files:["composer.json"],extensions:[".php"]},{language:"javascript",files:["package.json"],extensions:[".js",".jsx",".mjs",".cjs"]}];function Pe(e){let t=[],n=dt(e),r=ht(e);for(let i of lt){if(gt(e,i.files)){t.push(i.language);continue}if(ft(n,i.globs)){t.push(i.language);continue}Pt(r,i.extensions)&&t.push(i.language)}return t.includes("typescript")&&fe(t,"javascript"),t.includes("cpp")&&!r.has(".c")&&fe(t,"c"),t}function dt(e){try{return me(e)}catch{return[]}}function gt(e,t){return t?.length?t.some(n=>ut(ye(e,n))):!1}function ft(e,t){return t?.length?e.some(n=>t.some(r=>mt(n,r))):!1}function mt(e,t){if(t==="*")return!0;if(!t.includes("*"))return e===t;let[n,r]=t.split("*");return e.startsWith(n??"")&&e.endsWith(r??"")}function ht(e){let t=yt(e);if(t)return t;let n=new Set,r=[e];for(;r.length>0;){let i=r.pop();if(!i)continue;let s;try{s=me(i,{withFileTypes:!0})}catch{continue}for(let a of s){if(a.name.startsWith(".")&&!a.name.endsWith("proj")&&!a.name.endsWith("sln")&&a.isDirectory())continue;let o=ye(i,a.name);if(a.isDirectory()){pt.has(a.name)||r.push(o);continue}let c=he(a.name).toLowerCase();c&&n.add(c)}}return n}function yt(e){try{let t=ct("git",["-C",e,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:26214400,stdio:["ignore","pipe","ignore"]}),n=new Set;for(let r of t.split(`
|
|
2
|
+
`)){if(!r)continue;let i=he(r).toLowerCase();i&&n.add(i)}return n}catch{return null}}function Pt(e,t){return t?.length?t.some(n=>e.has(n)):!1}function fe(e,t){let n=e.indexOf(t);n!==-1&&e.splice(n,1)}import{existsSync as xe,readdirSync as xt}from"fs";import{isAbsolute as St,join as _,resolve as bt}from"path";var jt={typescript:{language:"typescript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,pnpmWorkspaces:t,indexerBinary:n,projectPath:r})=>{let i=r?["index","--output",e,"--no-progress-bar",r]:["index","--infer-tsconfig","--output",e,"--no-progress-bar"];return t&&!r&&i.splice(1,0,"--pnpm-workspaces"),{binary:n,args:i}},markerFiles:["tsconfig.json"],installMethods:[{label:"npm",prerequisite:"npm",binary:"npm",args:["install","-g","@sourcegraph/scip-typescript"]}],installUrl:"https://github.com/sourcegraph/scip-typescript",bundledNpmPackage:"@sourcegraph/scip-typescript"},javascript:{language:"javascript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,indexerBinary:t})=>({binary:t,args:["index","--infer-tsconfig","--output",e,"--no-progress-bar"]}),markerFiles:["package.json"],installMethods:[{label:"npm",prerequisite:"npm",binary:"npm",args:["install","-g","@sourcegraph/scip-typescript"]}],installUrl:"https://github.com/sourcegraph/scip-typescript",bundledNpmPackage:"@sourcegraph/scip-typescript"},java:{language:"java",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:["pom.xml","build.gradle"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},scala:{language:"scala",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:["build.sbt"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},kotlin:{language:"kotlin",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:["build.gradle.kts"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},rust:{language:"rust",indexerBinary:"rust-analyzer",checkCommand:"rust-analyzer --version",indexArgs:({outputPath:e})=>({binary:"rust-analyzer",args:["scip",".","--output",e]}),markerFiles:["Cargo.toml"],installMethods:[{label:"rustup",prerequisite:"rustup",binary:"rustup",args:["component","add","rust-analyzer"]}],installUrl:"https://github.com/rust-lang/rust-analyzer"},python:{language:"python",indexerBinary:"scip-python-plus",binaryAliases:["scip-python"],checkCommand:"scip-python-plus --version",indexArgs:({outputPath:e,indexerBinary:t})=>({binary:t,args:["index","--output",e,"--project-name","project"]}),markerFiles:["pyproject.toml","setup.py"],installMethods:[{label:"npm",prerequisite:"npm",binary:"npm",args:["install","-g","scip-python-plus"]}],installUrl:"https://github.com/PlunderStruck/scip-python",bundledNpmPackage:"scip-python-plus"},clojure:{language:"clojure",indexerBinary:"scip-clojure",projectLocalBinaries:["node_modules/.bin/scip-clojure"],checkCommand:"scip-clojure -h",indexArgs:({projectRoot:e,outputPath:t,indexerBinary:n,configPath:r})=>{let i=["-root",e,"-output",t];return r&&i.push("-config",St(r)?r:bt(e,r)),{binary:n,args:i}},markerFiles:["deps.edn","project.clj","bb.edn","shadow-cljs.edn"],installMethods:[],installUrl:"https://github.com/PlunderStruck/scip-clojure"},ruby:{language:"ruby",indexerBinary:"scip-ruby",checkCommand:"scip-ruby --version",indexArgs:({indexerBinary:e})=>({binary:e,args:["--dir","."]}),defaultOutputPath:"index.scip",markerFiles:["Gemfile"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-ruby/releases"},go:{language:"go",indexerBinary:"scip-go",checkCommand:"scip-go --version",indexArgs:({outputPath:e})=>({binary:"scip-go",args:["--output",e]}),markerFiles:["go.mod"],installMethods:[{label:"go install",prerequisite:"go",binary:"go",args:["install","github.com/sourcegraph/scip-go@latest"]}],installUrl:"https://github.com/sourcegraph/scip-go"},cpp:{language:"cpp",indexerBinary:"scip-clang",checkCommand:"scip-clang --version",indexArgs:({outputPath:e})=>({binary:"scip-clang",args:["--compdb-path","compile_commands.json","--index-output-path",e]}),markerFiles:["CMakeLists.txt","Makefile"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-clang/releases"},c:{language:"c",indexerBinary:"scip-clang",checkCommand:"scip-clang --version",indexArgs:({outputPath:e})=>({binary:"scip-clang",args:["--compdb-path","compile_commands.json","--index-output-path",e]}),markerFiles:["CMakeLists.txt","Makefile"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-clang/releases"},csharp:{language:"csharp",indexerBinary:"scip-dotnet",checkCommand:"scip-dotnet --version",indexArgs:({projectRoot:e,outputPath:t})=>({binary:"scip-dotnet",args:["index",Se(e,[".sln",".csproj"])??e,"--output",t,"--working-directory",e]}),markerFiles:["*.csproj","*.sln"],installMethods:[{label:"dotnet",prerequisite:"dotnet",binary:"dotnet",args:["tool","install","--global","scip-dotnet"]}],installUrl:"https://github.com/sourcegraph/scip-dotnet/releases"},vb:{language:"vb",indexerBinary:"scip-dotnet",checkCommand:"scip-dotnet --version",indexArgs:({projectRoot:e,outputPath:t})=>({binary:"scip-dotnet",args:["index",Se(e,[".sln",".vbproj"])??e,"--output",t,"--working-directory",e]}),markerFiles:["*.vbproj","*.sln"],installMethods:[{label:"dotnet",prerequisite:"dotnet",binary:"dotnet",args:["tool","install","--global","scip-dotnet"]}],installUrl:"https://github.com/sourcegraph/scip-dotnet/releases"},dart:{language:"dart",indexerBinary:"scip-dart",checkCommand:"scip-dart --version",indexArgs:({indexerBinary:e,outputPath:t})=>({binary:e,args:["--output",t]}),markerFiles:["pubspec.yaml"],installMethods:[{label:"dart pub",prerequisite:"dart",binary:"dart",args:["pub","global","activate","scip_dart"]}],installUrl:"https://github.com/Workiva/scip-dart/releases"},php:{language:"php",indexerBinary:"scip-php",projectLocalBinaries:["vendor/davidrjenni/scip-php/bin/scip-php","vendor/bin/scip-php"],checkCommand:"scip-php --version",indexArgs:({projectRoot:e,indexerBinary:t})=>{let n=_(e,"vendor","bin","scip-php"),r=_(e,"vendor","davidrjenni","scip-php","bin","scip-php");return{binary:"php",args:["-d","error_reporting=E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED",xe(r)?r:xe(n)?n:t]}},defaultOutputPath:"index.scip",markerFiles:["composer.json"],installMethods:[],installUrl:"https://github.com/davidrjenni/scip-php/releases"}};function W(e){return jt[e]}function Se(e,t){let n;try{n=xt(e)}catch{return null}for(let r of t)for(let i of n)if(i.endsWith(r))return _(e,i);return null}import{readFileSync as Rt,writeFileSync as vt}from"fs";import{create as U}from"@bufbuild/protobuf";import{deserializeSCIP as kt,serializeSCIP as It,DocumentSchema as wt,IndexSchema as Ct,SymbolInformationSchema as Mt}from"@c4312/scip";function Dt(e){if(e.length===0)throw new Error("Cannot merge zero SCIP indexes");if(e.length===1)return e[0];let t=Lt(e),n=Ot(e.flatMap(i=>i.documents??[])),r=be(e.flatMap(i=>i.externalSymbols??[]));return U(Ct,{metadata:t,documents:n,externalSymbols:r})}function J(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let n=e.map(i=>kt(Rt(i))),r=Dt(n);return vt(t,Buffer.from(It(r))),{documentCount:r.documents.length,externalSymbolCount:r.externalSymbols.length,inputCount:e.length}}function Lt(e){let t=e[0]?.metadata;if(!t)return;let n=t.projectRoot;for(let r of e.slice(1)){let i=r.metadata?.projectRoot;if(n&&i&&i!==n)throw new Error(`Cannot merge SCIP indexes with different project roots: ${n} vs ${i}`)}return t}function Ot(e){let t=new Map;for(let n of e){let r=t.get(n.relativePath);if(!r){t.set(n.relativePath,n);continue}t.set(n.relativePath,U(wt,{language:r.language||n.language,relativePath:r.relativePath||n.relativePath,occurrences:Ft([...r.occurrences,...n.occurrences]),symbols:be([...r.symbols,...n.symbols]),text:Et(r.text,n.text),positionEncoding:r.positionEncoding||n.positionEncoding}))}return[...t.values()]}function Ft(e){let t=new Set,n=[];for(let r of e){let i=JSON.stringify(r);t.has(i)||(t.add(i),n.push(r))}return n}function be(e){let t=new Map;for(let n of e){let r=t.get(n.symbol);if(!r){t.set(n.symbol,n);continue}t.set(n.symbol,U(Mt,{symbol:r.symbol,documentation:$t([...r.documentation,...n.documentation]),relationships:Tt([...r.relationships,...n.relationships]),kind:r.kind||n.kind,displayName:r.displayName||n.displayName,enclosingSymbol:r.enclosingSymbol||n.enclosingSymbol,signatureDocumentation:r.signatureDocumentation??n.signatureDocumentation}))}return[...t.values()]}function Tt(e){let t=new Set,n=[];for(let r of e){let i=[r.symbol,r.isReference?"1":"0",r.isImplementation?"1":"0",r.isTypeDefinition?"1":"0",r.isDefinition?"1":"0"].join("|");t.has(i)||(t.add(i),n.push(r))}return n}function Et(e,t){return e?t?e.length>=t.length?e:t:e:t}function $t(e){return[...new Set(e)]}import{createHash as Bt}from"crypto";import{existsSync as q,readFileSync as _t,readdirSync as Wt}from"fs";import{dirname as z,join as k,relative as Ut,resolve as G,sep as je}from"path";import{isAbsolute as At,relative as Nt}from"path";function S(e,t){let n=Nt(e,t);return n===""||!n.startsWith("..")&&!At(n)}function Re(e,t){let n=t.includes("."),r={};for(let s of t)r[s]=[];let i=[];for(let s of e){let a=we(s.path,t);a?r[a].push(s):n?r["."].push(s):i.push(s)}return{files:r,shared:i}}function ve(e,t){let n=new Map;for(let i of e){let s=t[i]?.packageName;s&&n.set(s,i)}let r=new Map;for(let i of e)r.set(i,new Set);for(let i of e){let s=t[i],a=r.get(i);if(!s||s.parseFailed){for(let o of e)o!==i&&a.add(o);continue}for(let o of s.dependencyNames){let c=n.get(o);c&&c!==i&&a.add(c)}for(let o of[...s.pathsTargets,...s.referencesPaths]){let c=we(o,e);c&&c!==i&&a.add(c)}}return Jt(e,r)}function ke(e,t,n){let r={};for(let i of e){let s=new Map;for(let a of t.files[i]??[])s.set(a.path,a);for(let a of n[i]??[])for(let o of t.files[a]??[])s.set(o.path,o);for(let a of t.shared)s.set(a.path,a);r[i]={files:[...s.values()].sort((a,o)=>a.path.localeCompare(o.path))}}return r}function X(e){if(e===".")return"root";let t=Bt("sha256").update(e).digest("hex").slice(0,8);return`${e.split("/").join("__")}-${t}`}function Ie(e,t){let n=G(e),r={};for(let i of t)r[i]=qt(n,i);return r}function we(e,t){let n;for(let r of t)r!=="."&&(e===r||e.startsWith(`${r}/`))&&(!n||r.length>n.length)&&(n=r);return n}function Jt(e,t){let n={};for(let r of e){let i=new Set,s=[...t.get(r)??[]];for(;s.length>0;){let a=s.pop();if(!(a===r||i.has(a))){i.add(a);for(let o of t.get(a)??[])o!==r&&!i.has(o)&&s.push(o)}}n[r]=[...i].sort((a,o)=>a.localeCompare(o))}return n}function qt(e,t){let n=t==="."?e:k(e,t),r=zt(n),i=Gt(n),s=i?Xt(i,e):{pathsTargets:[],referencesPaths:[],failed:!1};return{packageName:r.name,dependencyNames:r.dependencyNames,pathsTargets:s.pathsTargets,referencesPaths:s.referencesPaths,parseFailed:r.failed||s.failed}}function zt(e){let t=k(e,"package.json");if(!q(t))return{name:void 0,dependencyNames:[],failed:!1};let n=H(t);if(!n.ok)return{name:void 0,dependencyNames:[],failed:!0};let r=typeof n.value.name=="string"?n.value.name:void 0,i=new Set;for(let s of["dependencies","devDependencies","peerDependencies"]){let a=n.value[s];if(a&&typeof a=="object"&&!Array.isArray(a))for(let o of Object.keys(a))i.add(o)}return{name:r,dependencyNames:[...i],failed:!1}}function Gt(e){let t=k(e,"tsconfig.json");if(q(t))return t;let n;try{n=Wt(e).filter(r=>/^tsconfig.*\.json$/.test(r))}catch{return}return n.sort((r,i)=>r.localeCompare(i)),n.length>0?k(e,n[0]):void 0}function Xt(e,t){let n=H(e);if(!n.ok)return{pathsTargets:[],referencesPaths:[],failed:!0};let r=Ht(n.value,e,t),i=Ce(e,n.value,t,0);return{pathsTargets:i.pathsTargets,referencesPaths:r,failed:i.failed}}function Ht(e,t,n){let r=e.references;if(!Array.isArray(r))return[];let i=z(t),s=new Set;for(let a of r){if(!a||typeof a!="object")continue;let o=a.path;if(typeof o!="string"||o.trim()==="")continue;let c=Me(o,i,n);c&&s.add(c)}return[...s]}function Ce(e,t,n,r){let i=Kt(t);if(i)return{pathsTargets:Qt(i,z(e),n),failed:!1};if(r>=5)return{pathsTargets:[],failed:!1};let s=Yt(t.extends,e,n);if(!s)return{pathsTargets:[],failed:!1};let a=H(s);return a.ok?Ce(s,a.value,n,r+1):{pathsTargets:[],failed:!0}}function Kt(e){let t=e.compilerOptions;if(!t||typeof t!="object"||Array.isArray(t))return;let n=t.paths;return n&&typeof n=="object"&&!Array.isArray(n)?n:void 0}function Qt(e,t,n){let r=new Set;for(let i of Object.values(e))if(Array.isArray(i))for(let s of i){if(typeof s!="string")continue;let a=Me(s,t,n);a&&r.add(a)}return[...r]}function Yt(e,t,n){let r=Array.isArray(e)?e.at(-1):e;if(typeof r!="string"||r.trim()===""||!r.startsWith(".")&&!r.startsWith("/"))return;let i=G(z(t),r);if(i.endsWith(".json")||(i=`${i}.json`),!i.split(je).includes("node_modules")&&S(n,i)&&q(i))return i}function Me(e,t,n){let r=e.replace(/\/?\*+$/,""),i=G(t,r===""?".":r);if(!S(n,i))return;let a=Ut(n,i).split(je).join("/");return a===""?".":a}function Zt(e){let t="",n=0,r=!1,i=e.length;for(;n<i;){let s=e[n];if(r){if(t+=s,s==="\\"&&n+1<i){t+=e[n+1],n+=2;continue}s==='"'&&(r=!1),n+=1;continue}if(s==='"'){r=!0,t+=s,n+=1;continue}if(s==="/"&&e[n+1]==="/"){for(n+=2;n<i&&e[n]!==`
|
|
3
|
+
`;)n+=1;continue}if(s==="/"&&e[n+1]==="*"){for(n+=2;n<i&&!(e[n]==="*"&&e[n+1]==="/");)n+=1;n+=2;continue}t+=s,n+=1}return t}function H(e){try{let t=_t(e,"utf-8"),n=JSON.parse(Zt(t));return n&&typeof n=="object"&&!Array.isArray(n)?{ok:!0,value:n}:{ok:!1}}catch{return{ok:!1}}}import{readFileSync as Vt,writeFileSync as en}from"fs";import{create as De}from"@bufbuild/protobuf";import{deserializeSCIP as tn,DocumentSchema as nn,IndexSchema as rn,serializeSCIP as sn,SymbolRole as an}from"@c4312/scip";function Le(e){let t;try{t=tn(Vt(e))}catch{return{removedDefinitionOccurrences:0,touchedDocuments:0}}let n=on(t);return n.removedDefinitionOccurrences>0&&en(e,Buffer.from(sn(n.index))),{removedDefinitionOccurrences:n.removedDefinitionOccurrences,touchedDocuments:n.touchedDocuments}}function on(e){let t=new Set;for(let s of e.documents)for(let a of s.symbols)a.symbol&&t.add(a.symbol);for(let s of e.externalSymbols)s.symbol&&t.add(s.symbol);let n=0,r=0,i=[];for(let s of e.documents){let a=s.occurrences.filter(o=>(o.symbolRoles&an.Definition)===0||t.has(o.symbol)?!0:(n+=1,!1));if(a.length===s.occurrences.length){i.push(s);continue}r+=1,i.push(De(nn,{language:s.language,relativePath:s.relativePath,occurrences:a,symbols:s.symbols,text:s.text,positionEncoding:s.positionEncoding}))}return{index:n===0?e:De(rn,{metadata:e.metadata,documents:i,externalSymbols:e.externalSymbols}),removedDefinitionOccurrences:n,touchedDocuments:r}}import{existsSync as cn,readFileSync as un,readdirSync as pn,statSync as ln}from"fs";import d from"path";var dn=new Set([".cache",".git",".next",".nuxt",".turbo",".nx","build","coverage","dist","node_modules","tmp","vendor"]);function K(e,t=[]){let n=d.resolve(e),r=t.flatMap(c=>fn(n,c));if(r.length>0)return Oe(n,Fe(r));let i=gn(n),s=Fe(i),a=hn(n,s)?[n,...s]:s,o=a.length>0?a:[n];return Oe(n,o)}function Oe(e,t){return[...new Set(t.map(n=>Pn(e,n)))].sort((n,r)=>n.localeCompare(r))}function gn(e){let t=[],n=[e];for(;n.length>0;){let r=n.pop(),i;try{i=pn(r,{withFileTypes:!0})}catch{continue}for(let s of i){let a=d.join(r,s.name);if(s.isDirectory()){!dn.has(s.name)&&!s.name.startsWith(".")&&n.push(a);continue}s.isFile()&&mn(a)&&t.push(d.dirname(a))}}return t}function fn(e,t){let n=t.trim();if(!n)return[];let r=d.resolve(e,n);if(!S(e,r))return[];try{let i=ln(r);if(i.isDirectory())return[r];if(i.isFile()&&Te(d.basename(r)))return[d.dirname(r)]}catch{return[]}return[]}function mn(e){if(!Te(d.basename(e)))return!1;let t=Ee(e);return t?d.basename(e)==="tsconfig.json"||"include"in t||"files"in t||"references"in t:!1}function Te(e){return e.startsWith("tsconfig")&&e.endsWith(".json")}function Fe(e){let t=[...new Set(e.map(n=>d.resolve(n)))].sort((n,r)=>n.localeCompare(r));return t.length<=1?t:t.filter(n=>!t.some(r=>r!==n&&xn(n,r)))}function hn(e,t){if(t.length===0||t.some(r=>d.resolve(r)===e))return!1;let n=d.join(e,"tsconfig.json");return cn(n)&&yn(n)}function yn(e){let n=Ee(e)?.include;return Array.isArray(n)?n.some(r=>typeof r=="string"&&r.trim()!==""&&!r.startsWith("!")&&(r.includes("/")||r.includes("**")||!d.extname(r))):!1}function Ee(e){try{let t=JSON.parse(un(e,"utf-8"));return t&&typeof t=="object"&&!Array.isArray(t)?t:null}catch{return null}}function Pn(e,t){let n=d.relative(e,t);return n?n.split(d.sep).join("/"):"."}function xn(e,t){let n=d.relative(e,t);return!!n&&!n.startsWith("..")&&!d.isAbsolute(n)}import{execFile as Sn}from"child_process";import{existsSync as I,renameSync as Y,rmSync as Z,statSync as bn}from"fs";import{cpus as jn}from"os";import{join as $e}from"path";function Rn(e,t,n){if(!e.defaultOutputPath)return;let r=$e(t,e.defaultOutputPath);n!==r&&I(r)&&Y(r,n)}function vn(e,t,n){if(!e.defaultOutputPath)return null;let r=$e(t,e.defaultOutputPath);if(r===n)return null;let i=`${n}.default-output-backup`;return Z(i,{force:!0}),I(r)?(Y(r,i),{defaultOutputPath:r,backupPath:i}):{defaultOutputPath:r,backupPath:null}}function kn(e){e&&(Z(e.defaultOutputPath,{force:!0}),e.backupPath&&I(e.backupPath)&&Y(e.backupPath,e.defaultOutputPath))}function In(e,t){if(e<=1)return 1;let n=Number(process.env.SCIP_QUERY_INDEXER_CONCURRENCY??0),r=Number.isFinite(t)&&t&&t>0?t:Number.isFinite(n)&&n>0?n:Math.min(8,Math.max(1,jn().length));return Math.max(1,Math.min(e,Math.floor(r)))}async function Ae(e,t,n,r){let i=e.filter(p=>p.config.defaultOutputPath),s=e.filter(p=>!p.config.defaultOutputPath),a=[],o=In(s.length,r),c=await Cn(s,o,p=>Q(p,t,n));if(o>1){let p=new Map;for(let l of c.filter(u=>u.skipped)){let u=s.find(P=>P.id===l.id);u&&(n(`Retrying ${u.label} indexer serially after parallel failure...`),p.set(u.id,await Q(u,t,n)))}a.push(...c.map(l=>p.get(l.id)??l))}else a.push(...c);for(let p of i)a.push(await Q(p,t,n));return a.sort((p,l)=>e.findIndex(u=>u.id===p.id)-e.findIndex(u=>u.id===l.id))}async function Q(e,t,n){n(`Indexing ${e.label} with ${e.resolvedBinary}...`),Z(e.scipPath,{force:!0});let r=vn(e.config,t,e.scipPath),i=[e.binary,...e.args].join(" "),s=Date.now();try{await wn(e.binary,e.args,{cwd:t,env:e.env,maxBuffer:50*1024*1024}),Rn(e.config,t,e.scipPath)}catch(o){let c=o instanceof Error?o.message:String(o),p=`${e.resolvedBinary} indexer failed: ${c.split(`
|
|
4
|
+
`)[0]}`,l=e.label===e.language?p:`${e.label}: ${p}`;return n(`Skipping ${e.label}: ${p}`),{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:Date.now()-s,command:i,skipped:{language:e.language,reason:l}}}finally{kn(r)}if(!I(e.scipPath)){let o=`${e.resolvedBinary} indexer completed but did not produce ${e.scipPath}`,c=e.label===e.language?o:`${e.label}: ${o}`;return n(`Skipping ${e.label}: ${o}`),{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:Date.now()-s,command:i,skipped:{language:e.language,reason:c}}}let a;try{a=bn(e.scipPath).size}catch{a=void 0}return{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:Date.now()-s,command:i,outputBytes:a}}function wn(e,t,n){return new Promise((r,i)=>{Sn(e,[...t],n,s=>{s?i(s):r()})})}async function Cn(e,t,n){if(e.length===0)return[];let r=new Array(e.length),i=0,s=Math.max(1,Math.min(e.length,t)),a=Array.from({length:s},async()=>{for(;i<e.length;){let o=i++;r[o]=await n(e[o])}});return await Promise.all(a),r}import{execFileSync as ee}from"child_process";import{existsSync as V,readFileSync as Mn}from"fs";import{createRequire as Dn}from"module";import{platform as Ln}from"os";import{dirname as Ne,join as w}from"path";var On=Dn(import.meta.url);function te(e){return[e.indexerBinary,...e.binaryAliases??[]]}function ne(e){let t=te(e);return t.length===1?t[0]:t.join(" or ")}function C(e){for(let t of te(e))if(v(t))return t;return Tn(e)}function Be(e){return C(e)!==null||Fn(e)}function Fn(e){return _e(e)!==null}function Tn(e){let t=_e(e);if(!t)return null;let r=JSON.parse(Mn(t,"utf8")).bin;if(!r)return null;if(typeof r=="string")return w(Ne(t),r);for(let i of te(e)){let s=r[i];if(s)return w(Ne(t),s)}return null}function _e(e){if(!e.bundledNpmPackage)return null;try{return On.resolve(`${e.bundledNpmPackage}/package.json`)}catch{return null}}function We(e,t){for(let n of e.projectLocalBinaries??[]){let r=w(t,n);if(V(r))return r}return null}function Ue(e,t=process.env,n=e.indexerBinary){if(e.indexerBinary!=="scip-dotnet"||qe(n,t))return t;let r=En(n,t);return r?{...t,DOTNET_ROOT:r}:t}function Je(e,t){let n=e.installMethods,r=ne(e);if(!n?.length)return t(`No auto-install method available for ${r}.`),e.installUrl&&t(`Install manually from: ${e.installUrl}`),!1;for(let i of n)if(v(i.prerequisite)){t(`Installing ${r} via ${i.label}...`);try{ee(i.binary,i.args,{stdio:"inherit",timeout:3e5,env:process.env});let s=C(e);if(s){let a=s===e.indexerBinary?"":` (using ${s})`;return t(`Successfully installed ${r} via ${i.label}${a}`),!0}t(`${i.label} command completed but ${r} was not found on PATH`)}catch(s){let a=s instanceof Error?s.message:String(s);t(`${i.label} install failed: ${a}`)}}return t(`Could not auto-install ${r}.`),e.installUrl&&t(`Install manually from: ${e.installUrl}`),!1}function En(e,t){for(let n of $n(t))if(qe(e,{...t,DOTNET_ROOT:n}))return n;return null}function $n(e){let t=[],n=e.DOTNET_ROOT;if(n&&V(n)&&t.push(n),Ln()==="darwin"&&v("brew"))try{let r=ee("brew",["--prefix","dotnet@9"],{stdio:"pipe",env:e}).toString().trim(),i=w(r,"libexec");V(i)&&!t.includes(i)&&t.push(i)}catch{}return t}function qe(e,t){try{return ee(e,["--version"],{stdio:"pipe",env:t}),!0}catch{return!1}}async function He(e){let{projectRoot:t,maxHeapMb:n=8192,onStatus:r=console.log,skipAutoInstall:i=!1}=e,s=Gn(e),a=Date.now();D(g(s.outputScip),{recursive:!0}),D(g(s.outputDb),{recursive:!0});let o=e.languages??Pe(t);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=vr(t,o,{pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:e.typescriptProjects,clojureConfigPath:e.clojureConfigPath}),p=await hr(f(g(s.outputDb),"index.lock"),{projectRoot:t,trigger:e.trigger,onStatus:r}),l=null;try{let u=Xn({opts:e,paths:s,languages:o,fingerprint:c,start:a,onStatus:r});if(u)return u;await ur(i,r);let P=Kn(s);return l=P.runDir,await Qn({opts:e,languages:o,projectRoot:t,paths:s,tempPaths:P,fingerprint:c,start:a,maxHeapMb:n,skipAutoInstall:i,onStatus:r})}catch(u){throw et(s.metaPath,le({trigger:e.trigger,result:"failed",start:a,error:u instanceof Error?u.message:String(u)})),u}finally{l&&x(l,{recursive:!0,force:!0}),p()}}function Gn(e){let t=e.outputScip??f(e.projectRoot,"index.scip"),n=e.outputDb??f(e.projectRoot,"index.db");return{outputScip:t,outputDb:n,metaPath:f(g(n),"meta.json")}}function Xn(e){if(e.opts.skipIfUnchanged===!1||!j(e.paths.outputScip)||!j(e.paths.outputDb)||!kr(e.paths.metaPath,e.fingerprint))return null;A($(),{projectRoot:e.opts.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus});let t=Date.now()-e.start,n=le({trigger:e.opts.trigger,result:"reused",start:e.start,languages:e.languages,skipped:[]});return et(e.paths.metaPath,n),e.onStatus(`Index unchanged; reused existing SQLite index in ${(t/1e3).toFixed(1)}s`),{languages:e.languages,indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:t,reused:!0,skipped:[],lastRefresh:n,shards:Hn(e.paths,e.opts.projectRoot,e.languages,e.opts)}}function Hn(e,t,n,r){let i=ce(t,n,r);return n.map(s=>({id:s,language:s,reused:!0,fingerprint:b(i[s]),outputBytes:L(ue(e.outputDb,s)),durationMs:0}))}function Kn(e){let t=_n(f(g(e.outputDb),"reindex-"));return{runDir:t,tempOutputScip:f(t,M(e.outputScip)),tempOutputDb:f(t,M(e.outputDb)),tempMetaPath:f(t,M(e.metaPath))}}async function Qn(e){let t={...process.env,NODE_OPTIONS:`--max-old-space-size=${e.maxHeapMb}`},{indexedOutputs:n,skippedLanguages:r,reusedLanguages:i,shards:s,typescriptProjectShardContext:a}=await Yn(e,t);i.length>0&&e.onStatus(`Reused ${i.length} cached language shard(s): ${i.join(", ")}`);let o=ir(e,t,n,r,i,a),c=o.durationMs;return e.onStatus(`Done in ${(c/1e3).toFixed(1)}s`),{languages:n.map(p=>p.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:c,reused:!1,skipped:r,lastRefresh:o,shards:s}}async function Yn(e,t){let n=nr({paths:e.paths,projectRoot:e.projectRoot,languages:e.languages,pnpmWorkspaces:e.opts.pnpmWorkspaces,typescriptProjectMode:e.opts.typescriptProjectMode,typescriptProjects:e.opts.typescriptProjects,clojureConfigPath:e.opts.clojureConfigPath}),r=[],i=new Set;for(let[h,de]of n)de.reused&&(r.push({language:h,scipPath:de.scipPath}),i.add(h));for(let h of i)e.onStatus(`Reusing cached ${h} SCIP shard (language inputs unchanged).`);let s=Zn(e,n),{preparedRuns:a,skippedLanguages:o,languageOutputScipPaths:c}=pr({languages:e.languages.filter(h=>!i.has(h)),tempOutputScip:e.tempPaths.tempOutputScip,projectRoot:e.projectRoot,env:t,skipAutoInstall:e.skipAutoInstall,pnpmWorkspaces:e.opts.pnpmWorkspaces,typescriptProjectMode:e.opts.typescriptProjectMode,typescriptProjects:e.opts.typescriptProjects,preDiscoveredTypeScriptProjects:s?.allProjects,clojureConfigPath:e.opts.clojureConfigPath,onStatus:e.onStatus}),p=s?a.filter(h=>h.language!=="typescript"||s.missedProjectIds.has(h.id)):a,l=await Ae(p,e.projectRoot,e.onStatus,e.opts.indexerConcurrency),u=[];if(s){er(e.paths.outputDb,l);let h=c.typescript??e.tempPaths.tempOutputScip;u=tr({outputDb:e.paths.outputDb,tempOutputScip:e.tempPaths.tempOutputScip,outputScipPath:h,reusedProjects:s.reusedProjects})}let P=[...l,...u],{indexedOutputs:T}=dr(P,o),m=[...r,...T];gr(m,o,e.languages,e.opts.allowPartial,e.onStatus);let ot=rr(n,l,s?{outputDb:e.paths.outputDb,classification:s.classification}:void 0);return{indexedOutputs:m,skippedLanguages:o,reusedLanguages:[...i],shards:ot,typescriptProjectShardContext:s?{projects:s.allProjects,fingerprints:s.fingerprints}:void 0}}function Zn(e,t){let n=t.get("typescript");if(!n||n.reused||e.opts.typescriptProjectMode!=="workspace")return;let r=K(e.projectRoot,e.opts.typescriptProjects);if(r.length===0)return;let i=Ie(e.projectRoot,r),s=Re(n.fingerprint.files,r),a=ve(r,i),o=ke(r,s,a),c=pe(e.paths.metaPath),l=Vn(c,o,m=>j(F(e.paths.outputDb,m))),u=[...l.entries()].filter(([,m])=>m.reused).map(([m])=>m),P=new Set(u),T=new Set(r.filter(m=>!P.has(m)).map(m=>`typescript:${m}`));return{allProjects:r,fingerprints:o,classification:l,reusedProjects:u,missedProjectIds:T}}function Vn(e,t,n){let r=new Map;for(let i of Object.keys(t)){let s=t[i];if(!e){r.set(i,{reused:!1,reason:"no reindex metadata found",fingerprint:s});continue}let a=e.typescriptProjectShards?.[i];if(!a){r.set(i,{reused:!1,reason:"no cached fingerprint for this project",fingerprint:s});continue}if(!n(i)){r.set(i,{reused:!1,reason:"cached shard file missing on disk",fingerprint:s});continue}if(y(a)!==y(s)){r.set(i,{reused:!1,reason:"project inputs changed since last index",fingerprint:s});continue}r.set(i,{reused:!0,fingerprint:s})}return r}function er(e,t){for(let n of t){if(n.skipped||!n.id.startsWith("typescript:"))continue;let r=n.id.slice(11),i=F(e,r);D(g(i),{recursive:!0}),ae(n.scipPath,i)}}function tr(e){return e.reusedProjects.map((t,n)=>{let r=F(e.outputDb,t),i=oe(e.tempOutputScip,"typescript-project-cached",n);return ae(r,i),{id:`typescript:${t}`,language:"typescript",label:`typescript (${t})`,scipPath:i,outputScipPath:e.outputScipPath,durationMs:0,command:"cached",outputBytes:L(i)??void 0}})}function nr(e){let t=pe(e.paths.metaPath),n=ce(e.projectRoot,e.languages,e),r=new Map;for(let i of e.languages){let s=ue(e.paths.outputDb,i),a=n[i];if(!t){r.set(i,{reused:!1,reason:"no reindex metadata found",fingerprint:a,scipPath:s});continue}if(t.version!==3){r.set(i,{reused:!1,reason:`metadata version ${String(t.version??"unknown")} predates per-language shard caching`,fingerprint:a,scipPath:s});continue}if(!t.languageFingerprints){r.set(i,{reused:!1,reason:"no per-language fingerprints recorded in metadata",fingerprint:a,scipPath:s});continue}let o=t.languageFingerprints[i];if(!o){r.set(i,{reused:!1,reason:"no cached fingerprint for this language",fingerprint:a,scipPath:s});continue}if(!j(s)){r.set(i,{reused:!1,reason:"cached shard file missing on disk",fingerprint:a,scipPath:s});continue}if(y(o)!==y(a)){r.set(i,{reused:!1,reason:"language inputs changed since last index",fingerprint:a,scipPath:s});continue}r.set(i,{reused:!0,fingerprint:a,scipPath:s})}return r}function rr(e,t,n){let r=[];for(let[i,s]of e)s.reused&&r.push({id:i,language:i,reused:!0,fingerprint:b(s.fingerprint),outputBytes:L(s.scipPath),durationMs:0});for(let i of t){let s=e.get(i.language),a=n&&i.id.startsWith("typescript:")?i.id.slice(11):null,o=a?n.classification.get(a):void 0;r.push({id:i.id,language:i.language,reused:!1,missReason:o?.reason??s?.reason??i.skipped?.reason,fingerprint:o?b(o.fingerprint):s?b(s.fingerprint):"unknown",outputBytes:i.outputBytes??null,durationMs:i.durationMs,command:i.command})}if(n)for(let[i,s]of n.classification)s.reused&&r.push({id:`typescript:${i}`,language:"typescript",reused:!0,fingerprint:b(s.fingerprint),outputBytes:L(F(n.outputDb,i)),durationMs:0});return r}function b(e){return Nn("sha256").update(y(e)).digest("hex").slice(0,16)}function L(e){try{return Jn(e).size}catch{return null}}function ir(e,t,n,r,i,s){cr(e.paths.outputDb,n),fr(n,e.tempPaths.tempOutputScip,e.onStatus),mr(e.tempPaths.tempOutputScip,e.tempPaths.tempOutputDb,t,e.onStatus),A($(),{projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,onStatus:e.onStatus});let a=sr({mode:e.opts.typescriptProjectMode,skippedLanguages:r,reusedLanguages:i,context:s,metaPath:e.paths.metaPath});ar(e.paths.outputDb,a.pruneProjects);let o=le({trigger:e.opts.trigger,result:"rebuilt",start:e.start,languages:n.map(c=>c.language),skipped:[...r]});return Ve(e.tempPaths.tempMetaPath,{version:3,status:r.length===0?"complete":"partial",updatedAt:new Date().toISOString(),fingerprint:e.fingerprint,languageFingerprints:ce(e.projectRoot,e.languages,{pnpmWorkspaces:e.opts.pnpmWorkspaces,typescriptProjectMode:e.opts.typescriptProjectMode,typescriptProjects:e.opts.typescriptProjects,clojureConfigPath:e.opts.clojureConfigPath}),typescriptProjectShards:a.field,requestedLanguages:e.languages,indexedLanguages:n.map(c=>c.language),skipped:[...r],lastRefresh:o}),Rr({tempOutputScip:e.tempPaths.tempOutputScip,tempOutputDb:e.tempPaths.tempOutputDb,tempMetaPath:e.tempPaths.tempMetaPath,outputScip:e.paths.outputScip,outputDb:e.paths.outputDb,metaPath:e.paths.metaPath}),o}function sr(e){if(e.mode!=="workspace")return{field:void 0,pruneProjects:null};if(e.skippedLanguages.some(t=>t.language==="typescript"))return{field:void 0,pruneProjects:null};if(e.reusedLanguages.includes("typescript")){let t=pe(e.metaPath)?.typescriptProjectShards;return{field:t,pruneProjects:t?Object.keys(t):[]}}return e.context?{field:e.context.fingerprints,pruneProjects:e.context.projects}:{field:void 0,pruneProjects:[]}}function ar(e,t){let n=Ze(e);if(t===null){x(n,{recursive:!0,force:!0});return}let r;try{r=Un(n)}catch{return}for(let i of or(r,t))x(f(n,i),{force:!0})}function or(e,t){let n=new Set(t.map(r=>`${X(r)}.scip`));return e.filter(r=>!n.has(r))}function cr(e,t){for(let n of t){let r=ue(e,n.language);D(g(r),{recursive:!0}),n.scipPath!==r&&ae(n.scipPath,r)}}async function ur(e,t){if(!E()){if(e)throw new Error(`The scip CLI is required but not found on PATH.
|
|
5
|
+
Install from: https://github.com/sourcegraph/scip/releases`);if(zn()==="win32")throw new Error("The scip CLI was not found. On Windows it ships via the npm sidecar package scip-query-scip-windows (installed automatically with scip-query). Reinstall with optional dependencies enabled, run 'npm install -g scip-query-scip-windows', or set SCIP_QUERY_SCIP_BIN to a local scip.exe path.");if(t("scip CLI not found on PATH. Attempting auto-install..."),!ge(t))throw new Error(`The scip CLI is required but could not be installed.
|
|
6
|
+
Install manually from: https://github.com/sourcegraph/scip/releases`)}}function pr(e){let t=[],n=[],r=e.languages.map((s,a)=>({language:s,scipPath:e.languages.length>1?oe(e.tempOutputScip,s,a):e.tempOutputScip})),i=Object.fromEntries(r.map(({language:s,scipPath:a})=>[s,a]));for(let{language:s,scipPath:a}of r){let o=lr({...e,language:s,scipPath:a});for(let c of o)"skipped"in c?Ke(n,c.skipped):t.push(c.prepared)}return{preparedRuns:t,skippedLanguages:n,languageOutputScipPaths:i}}function lr(e){if(e.language!=="typescript"||e.typescriptProjectMode!=="workspace")return[re({...e,id:e.language,label:e.language,outputScipPath:e.scipPath})];let t=e.preDiscoveredTypeScriptProjects??K(e.projectRoot,e.typescriptProjects);return t.length===0?[re({...e,id:e.language,label:e.language,outputScipPath:e.scipPath})]:(e.onStatus(`Indexing TypeScript workspace as ${t.length} project shard(s).`),t.map((n,r)=>re({...e,id:`typescript:${n}`,label:`typescript (${n})`,scipPath:oe(e.tempOutputScip,"typescript-project",r),outputScipPath:e.scipPath,pnpmWorkspaces:!1,projectPath:n})))}function re(e){let t=W(e.language),n=ne(t),r=We(t,e.projectRoot);if(!r&&!Be(t)){if(e.skipAutoInstall){let o=`${n} not found on PATH (auto-install disabled). ${t.installUrl??""}`.trim();return e.onStatus(`Skipping ${e.language}: ${o}`),{skipped:{language:e.language,reason:o}}}if(e.onStatus(`${n} not found. Attempting auto-install...`),!Je(t,e.onStatus)){let o=`${n} could not be auto-installed. ${t.installUrl?`Install manually from ${t.installUrl}`:`Install ${n} and put it on PATH.`}`;return e.onStatus(`Skipping ${e.language}: ${o}`),{skipped:{language:e.language,reason:o}}}}let i=r??C(t);if(!i){let o=`${n} was not found after installation checks.`;return e.onStatus(`Skipping ${e.language}: ${o}`),{skipped:{language:e.language,reason:o}}}let{binary:s,args:a}=t.indexArgs({projectRoot:e.projectRoot,outputPath:e.scipPath,pnpmWorkspaces:e.pnpmWorkspaces,indexerBinary:i,projectPath:e.projectPath,configPath:e.language==="clojure"?e.clojureConfigPath:void 0});return{prepared:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,config:t,resolvedBinary:i,binary:s,args:a,env:Ue(t,e.env,i)}}}function dr(e,t){let n=new Map;for(let i of e)if(i.skipped)Ke(t,i.skipped);else{let s=`${i.language}\0${i.outputScipPath}`,a=n.get(s)??{language:i.language,outputScipPath:i.outputScipPath,scipPaths:[]};a.scipPaths.push(i.scipPath),n.set(s,a)}let r=[];for(let i of n.values())if(i.scipPaths.length>1)J(i.scipPaths,i.outputScipPath),r.push({language:i.language,scipPath:i.outputScipPath});else{let s=i.scipPaths[0];s!==i.outputScipPath&&R(s,i.outputScipPath),r.push({language:i.language,scipPath:i.outputScipPath})}return{indexedOutputs:r}}function Ke(e,t){let n=e.find(r=>r.language===t.language);if(!n){e.push(t);return}n.reason.includes(t.reason)||(n.reason=`${n.reason}; ${t.reason}`)}function gr(e,t,n,r,i){if(e.length===0){let s=t.map(a=>` - ${a.language}: ${a.reason}`).join(`
|
|
6
7
|
`);throw new Error(`No language indexers ran successfully. Install at least one indexer for the languages in this project.
|
|
7
|
-
`+
|
|
8
|
-
`+t.map(
|
|
9
|
-
`))}function
|
|
10
|
-
`),()=>{try{
|
|
11
|
-
`),
|
|
12
|
-
`)}).then(()=>{process.exit(0)}).catch(e=>{console.error(`reindex-worker error: ${e}`),process.exit(1)});function
|
|
8
|
+
`+s)}if(t.length!==0&&(i(`Indexed ${e.length} language output(s); skipped or incomplete: ${t.map(s=>s.language).join(", ")}.`),!r))throw new Error(`Failed to index all required languages; preserving the previous index. Pass --allow-partial to intentionally write an incomplete index.
|
|
9
|
+
`+t.map(s=>` - ${s.language}: ${s.reason}`).join(`
|
|
10
|
+
`))}function fr(e,t,n){e.length>1?(n(`Merging ${e.length} language indexes...`),J(e.map(r=>r.scipPath),t)):e[0].scipPath!==t&&R(e[0].scipPath,t)}function mr(e,t,n,r){if(r("Converting to SQLite..."),!j(e))throw new Error(`SCIP index not found at ${e} after indexing`);try{let i=Le(e);i.removedDefinitionOccurrences>0&&r(`Sanitized ${i.removedDefinitionOccurrences} invalid definition occurrences across ${i.touchedDocuments} documents before SQLite conversion.`);let s=E();if(!s)throw new Error("scip CLI is not available");An(s,["expt-convert","--output",t,e],{env:n,stdio:"pipe",maxBuffer:50*1024*1024})}catch(i){let s=i instanceof Error?i.message:String(i);throw new Error(`Failed to convert SCIP index to SQLite: ${s}`,{cause:i})}}function oe(e,t,n){let r=qn(e)||".scip",i=M(e,r);return f(g(e),`${i}.${n+1}.${t}${r}`)}async function hr(e,t){for(let n=0;n<2;n++){let r=yr(e,t);if(r)return r;let i=Pr(e);if(i&&xr(t.trigger,i)){if(t.onStatus(`Manual reindex preempting watcher refresh started at ${i.startedAt}.`),!await br(i.pid))throw new Error(`Could not confirm the watcher's in-progress reindex (pid ${i.pid}) terminated for ${g(e)}; refusing to steal an active lock.`);x(e,{force:!0});continue}if(i&&!se(i.pid)){x(e,{force:!0});continue}throw new Error(`Another scip-query reindex is already running for ${g(e)}.`)}throw new Error(`Could not acquire scip-query reindex lock for ${g(e)}.`)}function yr(e,t){let n;try{n=Wn(e,"wx")}catch(i){if((typeof i=="object"&&i&&"code"in i?i.code:void 0)==="EEXIST")return null;throw i}let r={version:1,pid:process.pid,projectRoot:t.projectRoot,startedAt:new Date().toISOString(),trigger:t.trigger};return Xe(n,JSON.stringify(r)+`
|
|
11
|
+
`),()=>{try{Bn(n)}finally{x(e,{force:!0})}}}function Pr(e){try{let t=JSON.parse(O(e,"utf-8"));return typeof t.pid!="number"||!Number.isInteger(t.pid)||t.pid<=0?null:{version:1,pid:t.pid,projectRoot:typeof t.projectRoot=="string"?t.projectRoot:g(e),startedAt:typeof t.startedAt=="string"?t.startedAt:"unknown",trigger:t.trigger}}catch{return null}}function xr(e,t){return e?.kind==="manual-cli"&&Sr(t?.trigger)}function Sr(e){return e?.kind==="watch-source"||e?.kind==="watch-git-head"||e?.kind==="watch-git-index"||e?.kind==="watch-git-state"}async function br(e){return ze(e,"SIGTERM"),await Ge(e,2e3)?!0:(ze(e,"SIGKILL"),Ge(e,1e3))}function ze(e,t){try{process.kill(-e,t)}catch{try{process.kill(e,t)}catch{}}}async function Ge(e,t){let n=Date.now()+t;for(;Date.now()<n;){if(!se(e))return!0;await jr(50)}return!se(e)}function se(e){try{return process.kill(e,0),!0}catch{return!1}}function jr(e){return new Promise(t=>setTimeout(t,e))}function Rr(e){ie(e.tempOutputScip,e.outputScip),ie(e.tempOutputDb,e.outputDb),ie(e.tempMetaPath,e.metaPath)}function ie(e,t){x(`${t}.tmp-replace`,{force:!0}),R(e,`${t}.tmp-replace`),R(`${t}.tmp-replace`,t)}function vr(e,t,n){return{version:2,languages:[...t].sort(),pnpmWorkspaces:Ye(n),typescriptProjectMode:n.typescriptProjectMode??"single",typescriptProjects:N(n.typescriptProjects),clojureConfigPath:Qe(n.clojureConfigPath),files:B(e)}}function ce(e,t,n){return Object.fromEntries(t.map(r=>{let i=W(r).markerFiles,s=r==="typescript"?{typescriptProjectMode:n.typescriptProjectMode??"single",typescriptProjects:N(n.typescriptProjects)}:{typescriptProjectMode:"single",typescriptProjects:[]},a=r==="clojure"?Qe(n.clojureConfigPath):void 0;return[r,{version:2,languages:[r],pnpmWorkspaces:r==="typescript"&&Ye(n),...s,clojureConfigPath:a,files:B(e,{language:r,markerFiles:i})}]}))}function Qe(e){return e?.trim()||void 0}function Ye(e){return e.typescriptProjectMode!=="workspace"&&e.pnpmWorkspaces===!0}function ue(e,t){return f(g(e),"language-indexes",`${t}.scip`)}function Ze(e){return f(g(e),"language-indexes","typescript-projects")}function F(e,t){return f(Ze(e),`${X(t)}.scip`)}function pe(e){try{return JSON.parse(O(e,"utf-8"))}catch{return null}}function kr(e,t){try{let n=JSON.parse(O(e,"utf-8"));return(n.version===2||n.version===3)&&n.status==="complete"&&y(n.fingerprint)===y(t)&&y([...n.indexedLanguages??[]].sort())===y(t.languages)}catch{return!1}}function Ve(e,t){let n=`${e}.tmp-${process.pid}-${Date.now()}`;Xe(n,`${JSON.stringify(t,null,2)}
|
|
12
|
+
`),R(n,e)}function et(e,t){try{let n=JSON.parse(O(e,"utf-8"));if(n.version!==2&&n.version!==3)return;Ve(e,{...n,lastRefresh:t})}catch{}}function le(e){return{trigger:e.trigger??{kind:"unknown"},result:e.result,startedAt:new Date(e.start).toISOString(),completedAt:new Date().toISOString(),durationMs:Date.now()-e.start,indexedLanguages:e.languages?[...e.languages]:void 0,skipped:e.skipped?[...e.skipped]:void 0,error:e.error}}function y(e){return JSON.stringify(e)}var it=process.env.SCIP_REINDEX_PROJECT_ROOT,st=process.env.SCIP_REINDEX_OUTPUT_SCIP,at=process.env.SCIP_REINDEX_OUTPUT_DB,tt=process.env.SCIP_REINDEX_LANGUAGES,Ir=Fr(process.env.SCIP_REINDEX_INDEXER_CONCURRENCY),wr=process.env.SCIP_REINDEX_PNPM_WORKSPACES==="1",nt=Or(process.env.SCIP_REINDEX_TYPESCRIPT_CONFIG),Cr=process.env.SCIP_REINDEX_CLOJURE_CONFIG_PATH||void 0,Mr=Lr(process.env.SCIP_REINDEX_TRIGGER_KIND),Dr=process.env.SCIP_REINDEX_TRIGGER_DETAIL;(!it||!st||!at)&&(console.error("reindex-worker: missing required env vars"),process.exit(1));var rt=tt?tt.split(",").filter(Boolean):void 0;He({projectRoot:it,outputScip:st,outputDb:at,languages:rt?.length?rt:void 0,pnpmWorkspaces:wr,typescriptProjectMode:nt.projectMode,typescriptProjects:nt.projects,clojureConfigPath:Cr,indexerConcurrency:Ir,trigger:{kind:Mr,detail:Dr||void 0},onStatus:e=>process.stderr.write(`[reindex] ${e}
|
|
13
|
+
`)}).then(()=>{process.exit(0)}).catch(e=>{console.error(`reindex-worker error: ${e}`),process.exit(1)});function Lr(e){switch(e){case"manual-cli":case"setup":case"watch-source":case"watch-git-head":case"watch-git-index":case"watch-git-state":return e;default:return"unknown"}}function Or(e){if(!e)return{};try{let t=JSON.parse(e);if(!t||typeof t!="object"||Array.isArray(t))return{};let n=t,r=n.projectMode==="single"||n.projectMode==="workspace"?n.projectMode:void 0,i=Array.isArray(n.projects)?n.projects.filter(s=>typeof s=="string"&&s.trim()!==""):void 0;return{projectMode:r,projects:i&&i.length>0?i:void 0}}catch{return{}}}function Fr(e){if(!e)return;let t=Number(e);return Number.isInteger(t)&&t>0?t:void 0}
|
|
13
14
|
//# sourceMappingURL=reindex-worker.js.map
|
package/dist/reindex.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as SupportedLanguage, I as IndexerConfig, T as TypeScriptProjectMode } from './config-types-
|
|
2
|
-
import { R as RefreshTrigger, L as LastRefreshMetadata } from './scip-cli-
|
|
3
|
-
export { t as tryInstallScipCli } from './scip-cli-
|
|
1
|
+
import { a as SupportedLanguage, I as IndexerConfig, T as TypeScriptProjectMode } from './config-types-aCgyLrvE.js';
|
|
2
|
+
import { R as RefreshTrigger, L as LastRefreshMetadata } from './scip-cli-DeAbuJ2b.js';
|
|
3
|
+
export { t as tryInstallScipCli } from './scip-cli-DeAbuJ2b.js';
|
|
4
4
|
import { Index } from '@c4312/scip';
|
|
5
5
|
|
|
6
6
|
/**
|