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.
Files changed (93) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +16 -2
  3. package/dist/augment-vue-worker.js +1 -1
  4. package/dist/{chunk-U3VMUDXJ.js → chunk-4SCMYKD6.js} +1 -1
  5. package/dist/{chunk-FERAXG6Y.js → chunk-X7CHWTZ2.js} +1 -1
  6. package/dist/chunk-YBGC7HTY.js +3 -0
  7. package/dist/cli.js +259 -251
  8. package/dist/{config-types-BrHl3Bge.d.ts → config-types-aCgyLrvE.d.ts} +2 -0
  9. package/dist/{db-_Bdx0E1W.d.ts → db-DwCdT3rv.d.ts} +1 -1
  10. package/dist/{health-BEZ1Rt0S.d.ts → health-nJUidasZ.d.ts} +1 -1
  11. package/dist/index.d.ts +3 -3
  12. package/dist/queries/affected.d.ts +2 -2
  13. package/dist/queries/bottlenecks.d.ts +2 -2
  14. package/dist/queries/by-kind.d.ts +2 -2
  15. package/dist/queries/call-graph.d.ts +2 -2
  16. package/dist/queries/change-surface.d.ts +2 -2
  17. package/dist/queries/cleanup-plan.d.ts +2 -2
  18. package/dist/queries/co-change.d.ts +2 -2
  19. package/dist/queries/code.d.ts +2 -2
  20. package/dist/queries/complexity-hotspots.d.ts +2 -2
  21. package/dist/queries/complexity.d.ts +2 -2
  22. package/dist/queries/convergence.d.ts +2 -2
  23. package/dist/queries/coupling.d.ts +2 -2
  24. package/dist/queries/cycles.d.ts +2 -2
  25. package/dist/queries/dataflow.d.ts +2 -2
  26. package/dist/queries/dead.d.ts +2 -2
  27. package/dist/queries/decorative-checkers.d.ts +2 -2
  28. package/dist/queries/deep-chains.d.ts +2 -2
  29. package/dist/queries/deps.d.ts +2 -2
  30. package/dist/queries/diff-gate.d.ts +2 -2
  31. package/dist/queries/diff-gate.js +1 -1
  32. package/dist/queries/diff-impact.d.ts +2 -2
  33. package/dist/queries/doc-drift.d.ts +2 -2
  34. package/dist/queries/drift.d.ts +2 -2
  35. package/dist/queries/duplicate-bodies.d.ts +2 -2
  36. package/dist/queries/extract-candidates.d.ts +2 -2
  37. package/dist/queries/fan.d.ts +2 -2
  38. package/dist/queries/files.d.ts +2 -2
  39. package/dist/queries/health.d.ts +3 -3
  40. package/dist/queries/health.js +1 -1
  41. package/dist/queries/hierarchy.d.ts +2 -2
  42. package/dist/queries/hotspots.d.ts +2 -2
  43. package/dist/queries/imports.d.ts +2 -2
  44. package/dist/queries/incomplete-migration.d.ts +2 -2
  45. package/dist/queries/index.d.ts +3 -3
  46. package/dist/queries/index.js +1 -1
  47. package/dist/queries/isolated.d.ts +2 -2
  48. package/dist/queries/locality-candidates.d.ts +2 -2
  49. package/dist/queries/members.d.ts +2 -2
  50. package/dist/queries/methods.d.ts +2 -2
  51. package/dist/queries/not-implemented.d.ts +2 -2
  52. package/dist/queries/outline.d.ts +2 -2
  53. package/dist/queries/passthrough-candidates.d.ts +2 -2
  54. package/dist/queries/plan-context.d.ts +2 -2
  55. package/dist/queries/react-component-duplicates.d.ts +2 -2
  56. package/dist/queries/react-hook-candidates.d.ts +2 -2
  57. package/dist/queries/react-large-component-pressure.d.ts +2 -2
  58. package/dist/queries/recent-duplicates.d.ts +2 -2
  59. package/dist/queries/redundant-reexports.d.ts +2 -2
  60. package/dist/queries/refs.d.ts +2 -2
  61. package/dist/queries/self-audit.d.ts +2 -2
  62. package/dist/queries/similar-chains.d.ts +2 -2
  63. package/dist/queries/similar-files.d.ts +2 -2
  64. package/dist/queries/similar-signatures.d.ts +2 -2
  65. package/dist/queries/similar.d.ts +2 -2
  66. package/dist/queries/slice.d.ts +2 -2
  67. package/dist/queries/stale-abstractions.d.ts +2 -2
  68. package/dist/queries/stats.d.ts +2 -2
  69. package/dist/queries/surface.d.ts +2 -2
  70. package/dist/queries/symbols.d.ts +2 -2
  71. package/dist/queries/system.d.ts +2 -2
  72. package/dist/queries/test-quality.d.ts +2 -2
  73. package/dist/queries/trace.d.ts +2 -2
  74. package/dist/queries/twin-ab.d.ts +2 -2
  75. package/dist/queries/twin-drift.d.ts +2 -2
  76. package/dist/queries/unused-imports.d.ts +2 -2
  77. package/dist/queries/unused-params.d.ts +2 -2
  78. package/dist/queries/vue-component-duplicates.d.ts +2 -2
  79. package/dist/queries/vue-composable-candidates.d.ts +2 -2
  80. package/dist/queries/vue-large-view-pressure.d.ts +2 -2
  81. package/dist/queries/wrapper-candidates.d.ts +2 -2
  82. package/dist/reindex-worker.js +12 -11
  83. package/dist/reindex.d.ts +3 -3
  84. package/dist/reindex.js +20 -19
  85. package/dist/runtime.d.ts +3 -3
  86. package/dist/runtime.js +2 -2
  87. package/dist/{scip-cli-C7cg4ZHR.d.ts → scip-cli-DeAbuJ2b.d.ts} +1 -1
  88. package/docs/COMMAND_REFERENCE.md +2 -1
  89. package/package.json +1 -1
  90. package/skills/_shared/SKILL.md +3 -1
  91. package/skills/scip-calibrate/SKILL.md +7 -3
  92. package/skills/scip-verify/SKILL.md +6 -1
  93. package/dist/chunk-XC2PJOVM.js +0 -3
package/dist/reindex.js CHANGED
@@ -1,10 +1,11 @@
1
- import{a as R,b as E,f as V}from"./chunk-WIBFXSYB.js";import{a as pe}from"./chunk-YZXV3CU3.js";import{d as ce,e as le,f as ge}from"./chunk-GNG622H3.js";import"./chunk-64MNV6AB.js";import"./chunk-7S5E7KWT.js";import{execFileSync as Kr}from"child_process";import{createHash as Xr}from"crypto";import{closeSync as Yr,copyFileSync as Qr,existsSync as F,mkdirSync as re,mkdtempSync as Zr,openSync as ei,readFileSync as T,renameSync as k,rmSync as I,statSync as ti,writeFileSync as ut}from"fs";import{basename as D,dirname as f,extname as ni,join as m}from"path";import{platform as ri}from"os";import yt from"better-sqlite3";import{execFileSync as bt}from"child_process";import{existsSync as xt,readdirSync as St,readFileSync as Rt}from"fs";import{extname as j,join as de}from"path";function S(e={}){return{id:"auxiliary-documents",facts:["auxiliary-document"],run:t=>fe({projectRoot:t.projectRoot,dbPath:t.dbPath,extensions:e.extensions,onStatus:t.onStatus})}}function fe(e){let t=new Set((e.extensions??le).map(o=>o.toLowerCase()));if(t.size===0)return{scanned:0,inserted:0,existing:0};if(!xt(e.dbPath))throw new Error(`SCIP SQLite database not found at ${e.dbPath}`);let n=pe(e.projectRoot),r=Pt(e.projectRoot,t).filter(o=>!n.isIgnored(o)),i=new yt(e.dbPath);try{let o=kt(i,r),s=i.prepare(`INSERT OR IGNORE INTO documents (language, relative_path, position_encoding, text)
2
- VALUES (?, ?, NULL, ?)`),u=i.transaction(g=>{let l=0;for(let p of g){if(o.has(p))continue;let h=Rt(de(e.projectRoot,p),"utf-8"),ht=s.run(It(p),p,h);l+=Number(ht.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 Pt(e,t){let n=vt(e,t);if(n)return n;let r=[],i=o=>{let s=o?de(e,o):e,a;try{a=St(s,{withFileTypes:!0})}catch{return}for(let u of a){if(ge.has(u.name))continue;let c=o?`${o}/${u.name}`:u.name;if(u.isDirectory()){i(c);continue}t.has(j(u.name).toLowerCase())&&r.push(c)}};return i(""),r.sort()}function vt(e,t){try{return bt("git",["-C",e,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:26214400,stdio:["ignore","pipe","ignore"]}).split(`
3
- `).filter(r=>r&&t.has(j(r).toLowerCase())).sort()}catch{return null}}function kt(e,t){let n=new Set,r=500;for(let i=0;i<t.length;i+=r){let o=t.slice(i,i+r),s=e.prepare(`SELECT relative_path FROM documents WHERE relative_path IN (${o.map(()=>"?").join(",")})`).all(...o);for(let a of s)n.add(a.relative_path)}return n}function It(e){return j(e).toLowerCase()===".vue"?"vue":j(e).replace(/^\./,"").toLowerCase()||"source"}import{execFileSync as jt}from"child_process";import{existsSync as wt,readdirSync as he}from"fs";import{extname as ye,join as be}from"path";var Lt=new Set([".git",".hg",".svn",".idea",".vscode","node_modules","vendor","dist","build","target","bin","obj",".dart_tool",".gradle",".next",".venv","venv","__pycache__"]),Ct=[{language:"typescript",files:["tsconfig.json","tsconfig.base.json"],extensions:[".ts",".tsx",".mts",".cts"]},{language:"rust",files:["Cargo.toml"],extensions:[".rs"]},{language:"go",files:["go.mod"],extensions:[".go"]},{language:"java",files:["pom.xml","build.gradle","build.gradle.kts"],extensions:[".java"]},{language:"kotlin",files:["build.gradle.kts"],extensions:[".kt",".kts"]},{language:"scala",files:["build.sbt"],extensions:[".scala"]},{language:"clojure",files:["deps.edn","project.clj","bb.edn","shadow-cljs.edn"],extensions:[".clj",".cljs",".cljc"]},{language:"python",files:["pyproject.toml","setup.py","setup.cfg","Pipfile"],extensions:[".py",".pyi"]},{language:"ruby",files:["Gemfile"],extensions:[".rb"]},{language:"cpp",files:["compile_commands.json","CMakeLists.txt","Makefile"],extensions:[".cc",".cpp",".cxx",".hpp",".hh",".hxx"]},{language:"c",files:["compile_commands.json","CMakeLists.txt","Makefile"],extensions:[".c",".h"]},{language:"csharp",globs:["*.csproj","*.sln"],extensions:[".cs"]},{language:"vb",globs:["*.vbproj"],extensions:[".vb"]},{language:"dart",files:["pubspec.yaml"],extensions:[".dart"]},{language:"php",files:["composer.json"],extensions:[".php"]},{language:"javascript",files:["package.json"],extensions:[".js",".jsx",".mjs",".cjs"]}];function A(e){let t=[],n=Ot(e),r=Tt(e);for(let i of Ct){if(Mt(e,i.files)){t.push(i.language);continue}if(Dt(n,i.globs)){t.push(i.language);continue}Vt(r,i.extensions)&&t.push(i.language)}return t.includes("typescript")&&me(t,"javascript"),t.includes("cpp")&&!r.has(".c")&&me(t,"c"),t}function Ot(e){try{return he(e)}catch{return[]}}function Mt(e,t){return t?.length?t.some(n=>wt(be(e,n))):!1}function Dt(e,t){return t?.length?e.some(n=>t.some(r=>Ft(n,r))):!1}function Ft(e,t){if(t==="*")return!0;if(!t.includes("*"))return e===t;let[n,r]=t.split("*");return e.startsWith(n??"")&&e.endsWith(r??"")}function Tt(e){let t=Et(e);if(t)return t;let n=new Set,r=[e];for(;r.length>0;){let i=r.pop();if(!i)continue;let o;try{o=he(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=be(i,s.name);if(s.isDirectory()){Lt.has(s.name)||r.push(a);continue}let u=ye(s.name).toLowerCase();u&&n.add(u)}}return n}function Et(e){try{let t=jt("git",["-C",e,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:26214400,stdio:["ignore","pipe","ignore"]}),n=new Set;for(let r of t.split(`
4
- `)){if(!r)continue;let i=ye(r).toLowerCase();i&&n.add(i)}return n}catch{return null}}function Vt(e,t){return t?.length?t.some(n=>e.has(n)):!1}function me(e,t){let n=e.indexOf(t);n!==-1&&e.splice(n,1)}import{existsSync as xe,readdirSync as At}from"fs";import{isAbsolute as Nt,join as N,resolve as $t}from"path";var Re={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",Nt(r)?r:$t(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=N(e,"vendor","bin","scip-php"),r=N(e,"vendor","davidrjenni","scip-php","bin","scip-php");return{binary:"php",args:["-d","error_reporting=E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED",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 Re[e]}function Se(e,t){let n;try{n=At(e)}catch{return null}for(let r of t)for(let i of n)if(i.endsWith(r))return N(e,i);return null}import{readFileSync as _t,writeFileSync as Bt}from"fs";import{create as $}from"@bufbuild/protobuf";import{deserializeSCIP as Wt,serializeSCIP as Ut,DocumentSchema as Jt,IndexSchema as qt,SymbolInformationSchema as zt}from"@c4312/scip";function Pe(e){if(e.length===0)throw new Error("Cannot merge zero SCIP indexes");if(e.length===1)return e[0];let t=Ht(e),n=Gt(e.flatMap(i=>i.documents??[])),r=ve(e.flatMap(i=>i.externalSymbols??[]));return $(qt,{metadata:t,documents:n,externalSymbols:r})}function L(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let n=e.map(i=>Wt(_t(i))),r=Pe(n);return Bt(t,Buffer.from(Ut(r))),{documentCount:r.documents.length,externalSymbolCount:r.externalSymbols.length,inputCount:e.length}}function Ht(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 Gt(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,$(Jt,{language:r.language||n.language,relativePath:r.relativePath||n.relativePath,occurrences:Kt([...r.occurrences,...n.occurrences]),symbols:ve([...r.symbols,...n.symbols]),text:Yt(r.text,n.text),positionEncoding:r.positionEncoding||n.positionEncoding}))}return[...t.values()]}function Kt(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 ve(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,$(zt,{symbol:r.symbol,documentation:Qt([...r.documentation,...n.documentation]),relationships:Xt([...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 Xt(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 Yt(e,t){return e?t?e.length>=t.length?e:t:e:t}function Qt(e){return[...new Set(e)]}import{readFileSync as Zt,writeFileSync as en}from"fs";function y(e,t){let n=Date.now(),r=e.run(t);return{stageId:e.id,facts:e.facts,durationMs:Date.now()-n,result:r}}function Ie(e){let t=e.readFingerprint(),n=tn(e.cachePath,t);if(n)return e.onCacheHit?.(n.result),n.result;let r=e.compute();return nn(e.cachePath,e.readFingerprint(),r),r}function tn(e,t){try{let n=JSON.parse(Zt(e,"utf-8"));return ke(n.fingerprint)===ke(t)?{result:n.result}:null}catch{return null}}function nn(e,t,n){en(e,`${JSON.stringify({updatedAt:new Date().toISOString(),fingerprint:t,result:n},null,2)}
5
- `)}function ke(e){return JSON.stringify(e)}import{execFileSync as rn}from"child_process";import{createHash as on}from"crypto";import{readdirSync as sn,readFileSync as an}from"fs";import{join as we}from"path";function _(e){return[...new Set((e??[]).map(t=>t.trim()).filter(Boolean))].sort((t,n)=>t.localeCompare(n))}function je(e){return(cn(e)??ln(e)).filter(t=>t&&!Le(t)).sort()}function P(e,t={}){return(t.language?je(e).filter(r=>un(r,t.language,t.markerFiles)):je(e)).map(r=>{let i=we(e,r);try{let o=an(i);return{path:r,size:o.byteLength,hash:on("sha256").update(o).digest("hex")}}catch{return{path:r,size:-1,hash:"unreadable"}}})}function un(e,t,n){let r=e.split("/").at(-1)??e;if(n?.includes(e)||n?.includes(r)||pn.has(r))return!0;let i=e.includes(".")?`.${e.split(".").at(-1).toLowerCase()}`:"";return(dn[t]??[]).includes(i)}function cn(e){try{return rn("git",["-C",e,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:50*1024*1024,stdio:["ignore","pipe","ignore"]}).split(`
6
- `).filter(Boolean)}catch{return null}}function ln(e){let t=[],n=[""];for(;n.length>0;){let r=n.pop(),i=r?we(e,r):e,o;try{o=sn(i,{withFileTypes:!0})}catch{continue}for(let s of o){let a=r?`${r}/${s.name}`:s.name;if(s.isDirectory()){Le(a)||n.push(a);continue}t.push(a)}}return t}function Le(e){let t=e.split("/");return e==="meta.json"||t.some(n=>gn.has(n))||e.endsWith(".db")||e.endsWith(".db-wal")||e.endsWith(".db-shm")||e.endsWith(".scip")}var gn=new Set([".git","node_modules",".scipquery-cache",".stryker-tmp","dist","build","coverage",".next",".nuxt","target"]),pn=new Set(["package.json","package-lock.json","pnpm-lock.yaml","yarn.lock","bun.lockb","tsconfig.json","tsconfig.base.json","pyproject.toml","setup.py","setup.cfg","Cargo.toml","Cargo.lock","go.mod","go.sum","pom.xml","build.gradle","build.gradle.kts","build.sbt","compile_commands.json","CMakeLists.txt","Makefile","Gemfile","Gemfile.lock","composer.json","composer.lock","pubspec.yaml","pubspec.lock","deps.edn","project.clj","bb.edn","shadow-cljs.edn"]),dn={typescript:[".ts",".tsx",".mts",".cts"],javascript:[".js",".jsx",".mjs",".cjs"],java:[".java"],scala:[".scala"],kotlin:[".kt",".kts"],rust:[".rs"],python:[".py",".pyi"],ruby:[".rb"],go:[".go"],cpp:[".cc",".cpp",".cxx",".hpp",".hh",".hxx"],c:[".c",".h"],csharp:[".cs"],vb:[".vb"],dart:[".dart"],php:[".php"],clojure:[".clj",".cljs",".cljc"]};import{readFileSync as fn,writeFileSync as mn}from"fs";import{create as Ce}from"@bufbuild/protobuf";import{deserializeSCIP as hn,DocumentSchema as yn,IndexSchema as bn,serializeSCIP as xn,SymbolRole as Sn}from"@c4312/scip";function Oe(e){let t;try{t=hn(fn(e))}catch{return{removedDefinitionOccurrences:0,touchedDocuments:0}}let n=Rn(t);return n.removedDefinitionOccurrences>0&&mn(e,Buffer.from(xn(n.index))),{removedDefinitionOccurrences:n.removedDefinitionOccurrences,touchedDocuments:n.touchedDocuments}}function Rn(e){let t=new Set;for(let o of e.documents)for(let s of o.symbols)s.symbol&&t.add(s.symbol);for(let o of e.externalSymbols)o.symbol&&t.add(o.symbol);let n=0,r=0,i=[];for(let o of e.documents){let s=o.occurrences.filter(a=>(a.symbolRoles&Sn.Definition)===0||t.has(a.symbol)?!0:(n+=1,!1));if(s.length===o.occurrences.length){i.push(o);continue}r+=1,i.push(Ce(yn,{language:o.language,relativePath:o.relativePath,occurrences:s,symbols:o.symbols,text:o.text,positionEncoding:o.positionEncoding}))}return{index:n===0?e:Ce(bn,{metadata:e.metadata,documents:i,externalSymbols:e.externalSymbols}),removedDefinitionOccurrences:n,touchedDocuments:r}}import{existsSync as Pn,readFileSync as vn,readdirSync as kn,statSync as In}from"fs";import d from"path";var jn=new Set([".cache",".git",".next",".nuxt",".turbo",".nx","build","coverage","dist","node_modules","tmp","vendor"]);function Me(e,t=[]){let n=d.resolve(e),r=wn(n),i=t.flatMap(u=>Ln(n,u)),o=On([...r,...i]),s=Mn(n,o)?[n,...o]:o,a=s.length>0?s:[n];return[...new Set(a.map(u=>Fn(n,u)))].sort((u,c)=>u.localeCompare(c))}function wn(e){let t=[],n=[e];for(;n.length>0;){let r=n.pop(),i;try{i=kn(r,{withFileTypes:!0})}catch{continue}for(let o of i){let s=d.join(r,o.name);if(o.isDirectory()){!jn.has(o.name)&&!o.name.startsWith(".")&&n.push(s);continue}o.isFile()&&Cn(s)&&t.push(d.dirname(s))}}return t}function Ln(e,t){let n=t.trim();if(!n)return[];let r=d.resolve(e,n);if(!ce(e,r))return[];try{let i=In(r);if(i.isDirectory())return[r];if(i.isFile()&&De(d.basename(r)))return[d.dirname(r)]}catch{return[]}return[]}function Cn(e){if(!De(d.basename(e)))return!1;let t=Fe(e);return t?d.basename(e)==="tsconfig.json"||"include"in t||"files"in t||"references"in t:!1}function De(e){return e.startsWith("tsconfig")&&e.endsWith(".json")}function On(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&&Tn(n,r)))}function Mn(e,t){if(t.length===0||t.some(r=>d.resolve(r)===e))return!1;let n=d.join(e,"tsconfig.json");return Pn(n)&&Dn(n)}function Dn(e){let n=Fe(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 Fe(e){try{let t=JSON.parse(vn(e,"utf-8"));return t&&typeof t=="object"&&!Array.isArray(t)?t:null}catch{return null}}function Fn(e,t){let n=d.relative(e,t);return n?n.split(d.sep).join("/"):"."}function Tn(e,t){let n=d.relative(e,t);return!!n&&!n.startsWith("..")&&!d.isAbsolute(n)}import{execFile as En}from"child_process";import{existsSync as C,renameSync as W,rmSync as U,statSync as Vn}from"fs";import{cpus as An}from"os";import{join as Te}from"path";function Nn(e,t,n){if(!e.defaultOutputPath)return;let r=Te(t,e.defaultOutputPath);n!==r&&C(r)&&W(r,n)}function $n(e,t,n){if(!e.defaultOutputPath)return null;let r=Te(t,e.defaultOutputPath);if(r===n)return null;let i=`${n}.default-output-backup`;return U(i,{force:!0}),C(r)?(W(r,i),{defaultOutputPath:r,backupPath:i}):{defaultOutputPath:r,backupPath:null}}function _n(e){e&&(U(e.defaultOutputPath,{force:!0}),e.backupPath&&C(e.backupPath)&&W(e.backupPath,e.defaultOutputPath))}function Bn(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,An().length));return Math.max(1,Math.min(e,Math.floor(r)))}async function Ee(e,t,n,r){let i=e.filter(c=>c.config.defaultOutputPath),o=e.filter(c=>!c.config.defaultOutputPath),s=[],a=Bn(o.length,r),u=await Un(o,a,c=>B(c,t,n));if(a>1){let c=new Map;for(let g of u.filter(l=>l.skipped)){let l=o.find(p=>p.id===g.id);l&&(n(`Retrying ${l.label} indexer serially after parallel failure...`),c.set(l.id,await B(l,t,n)))}s.push(...u.map(g=>c.get(g.id)??g))}else s.push(...u);for(let c of i)s.push(await B(c,t,n));return s.sort((c,g)=>e.findIndex(l=>l.id===c.id)-e.findIndex(l=>l.id===g.id))}async function B(e,t,n){n(`Indexing ${e.label} with ${e.resolvedBinary}...`),U(e.scipPath,{force:!0});let r=$n(e.config,t,e.scipPath),i=[e.binary,...e.args].join(" "),o=Date.now();try{await Wn(e.binary,e.args,{cwd:t,env:e.env,maxBuffer:50*1024*1024}),Nn(e.config,t,e.scipPath)}catch(a){let u=a instanceof Error?a.message:String(a),c=`${e.resolvedBinary} indexer failed: ${u.split(`
7
- `)[0]}`,g=e.label===e.language?c:`${e.label}: ${c}`;return n(`Skipping ${e.label}: ${c}`),{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:Date.now()-o,command:i,skipped:{language:e.language,reason:g}}}finally{_n(r)}if(!C(e.scipPath)){let a=`${e.resolvedBinary} indexer completed but did not produce ${e.scipPath}`,u=e.label===e.language?a:`${e.label}: ${a}`;return n(`Skipping ${e.label}: ${a}`),{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:Date.now()-o,command:i,skipped:{language:e.language,reason:u}}}let s;try{s=Vn(e.scipPath).size}catch{s=void 0}return{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:Date.now()-o,command:i,outputBytes:s}}function Wn(e,t,n){return new Promise((r,i)=>{En(e,[...t],n,o=>{o?i(o):r()})})}async function Un(e,t,n){if(e.length===0)return[];let r=new Array(e.length),i=0,o=Math.max(1,Math.min(e.length,t)),s=Array.from({length:o},async()=>{for(;i<e.length;){let a=i++;r[a]=await n(e[a])}});return await Promise.all(s),r}import{execFileSync as q}from"child_process";import{existsSync as J,readFileSync as Jn}from"fs";import{createRequire as qn}from"module";import{platform as zn}from"os";import{dirname as Ve,join as O}from"path";var Hn=qn(import.meta.url);function z(e){return[e.indexerBinary,...e.binaryAliases??[]]}function M(e){let t=z(e);return t.length===1?t[0]:t.join(" or ")}function v(e){for(let t of z(e))if(R(t))return t;return Kn(e)}function H(e){return v(e)!==null||Gn(e)}function Gn(e){return Ae(e)!==null}function Kn(e){let t=Ae(e);if(!t)return null;let r=JSON.parse(Jn(t,"utf8")).bin;if(!r)return null;if(typeof r=="string")return O(Ve(t),r);for(let i of z(e)){let o=r[i];if(o)return O(Ve(t),o)}return null}function Ae(e){if(!e.bundledNpmPackage)return null;try{return Hn.resolve(`${e.bundledNpmPackage}/package.json`)}catch{return null}}function G(e,t){for(let n of e.projectLocalBinaries??[]){let r=O(t,n);if(J(r))return r}return null}function K(e,t=process.env,n=e.indexerBinary){if(e.indexerBinary!=="scip-dotnet"||Ne(n,t))return t;let r=Xn(n,t);return r?{...t,DOTNET_ROOT:r}:t}function X(e,t){let n=e.installMethods,r=M(e);if(!n?.length)return t(`No auto-install method available for ${r}.`),e.installUrl&&t(`Install manually from: ${e.installUrl}`),!1;for(let i of n)if(R(i.prerequisite)){t(`Installing ${r} via ${i.label}...`);try{q(i.binary,i.args,{stdio:"inherit",timeout:3e5,env:process.env});let o=v(e);if(o){let s=o===e.indexerBinary?"":` (using ${o})`;return t(`Successfully installed ${r} via ${i.label}${s}`),!0}t(`${i.label} command completed but ${r} was not found on PATH`)}catch(o){let s=o instanceof Error?o.message:String(o);t(`${i.label} install failed: ${s}`)}}return t(`Could not auto-install ${r}.`),e.installUrl&&t(`Install manually from: ${e.installUrl}`),!1}function Xn(e,t){for(let n of Yn(t))if(Ne(e,{...t,DOTNET_ROOT:n}))return n;return null}function Yn(e){let t=[],n=e.DOTNET_ROOT;if(n&&J(n)&&t.push(n),zn()==="darwin"&&R("brew"))try{let r=q("brew",["--prefix","dotnet@9"],{stdio:"pipe",env:e}).toString().trim(),i=O(r,"libexec");J(i)&&!t.includes(i)&&t.push(i)}catch{}return t}function Ne(e,t){try{return q(e,["--version"],{stdio:"pipe",env:t}),!0}catch{return!1}}import Mr from"better-sqlite3";import{existsSync as Dr}from"fs";import{dirname as Fr,join as Tr,resolve as Er}from"path";import{readFileSync as Qn,rmSync as Zn,statSync as er,mkdtempSync as tr}from"fs";import{cpus as nr,tmpdir as rr}from"os";import{join as Y}from"path";import{Worker as ir}from"worker_threads";function $e(e){return e.length>=8&&Be(e.length)>1}function _e(e){let t=Be(e.vueFiles.length),n=sr(e.vueFiles),r=ur(n,t),i=new URL("./augment-vue-worker.js",import.meta.url),o=tr(Y(rr(),"scip-query-vue-workers-")),s=new SharedArrayBuffer(4),a=new Int32Array(s),u=or(),c=Date.now();try{for(let l=0;l<r.length;l++)new ir(i,{workerData:{projectRoot:e.projectRoot,dbPath:e.dbPath,tsconfig:e.tsconfig,tasks:r[l],resultPath:Y(o,`${l}.json`),sharedBuffer:s}});for(;Atomics.load(a,0)<r.length;){if(Date.now()-c>u)throw new Error(`Vue reference workers timed out after ${(u/1e3).toFixed(0)}s`);Atomics.wait(a,0,Atomics.load(a,0),100)}let g=r.map((l,p)=>{let h=JSON.parse(Qn(Y(o,`${p}.json`),"utf-8"));if(!h.ok)throw new Error(`Vue reference worker failed: ${h.error}`);return h.result});return{occurrences:g.flatMap(l=>l.occurrences),skippedReferences:g.reduce((l,p)=>l+p.skippedReferences,0)}}finally{Zn(o,{recursive:!0,force:!0})}}function Be(e){let t=Number(process.env.SCIP_QUERY_AUGMENT_VUE_WORKERS??0),n=Number.isFinite(t)&&t>0?t:Math.min(8,Math.max(1,nr().length-1));return Math.max(1,Math.min(e,n))}function or(){let e=Number(process.env.SCIP_QUERY_AUGMENT_VUE_WORKER_TIMEOUT_MS??0);return Number.isFinite(e)&&e>0?e:3e5}function sr(e){let t=ar(),n=[];for(let r of e){let i=We(r),o=Math.max(1,Math.ceil(i/t));for(let s=0;s<o;s++)n.push({fileName:r,startOffset:Math.floor(i*s/o),endOffset:s===o-1?Number.POSITIVE_INFINITY:Math.floor(i*(s+1)/o),countFileSkip:s===0})}return n}function ar(){return Number.POSITIVE_INFINITY}function ur(e,t){let n=Array.from({length:t},()=>({tasks:[],weight:0})),r=e.map(i=>({task:i,weight:cr(i)})).sort((i,o)=>o.weight-i.weight);for(let i of r){let o=n.reduce((s,a)=>a.weight<s.weight?a:s);o.tasks.push(i.task),o.weight+=i.weight}return n.map(i=>i.tasks).filter(i=>i.length>0)}function cr(e){return Number.isFinite(e.endOffset)?Math.max(1,e.endOffset-e.startOffset):Math.max(1,We(e.fileName)-e.startOffset)}function We(e){try{return er(e).size}catch{return 1}}import{createRequire as lr}from"module";import{existsSync as gr,readFileSync as Z}from"fs";import{dirname as Ue,extname as pr,join as Je,relative as dr,resolve as fr}from"path";import{pathToFileURL as mr}from"url";function hr(e){e.transaction(()=>{e.prepare(`
1
+ import{a as k,b as U,f as J}from"./chunk-WIBFXSYB.js";import{a as we}from"./chunk-YZXV3CU3.js";import{d as v,e as ke,f as Ie}from"./chunk-GNG622H3.js";import"./chunk-64MNV6AB.js";import"./chunk-7S5E7KWT.js";import{execFileSync as Ti}from"child_process";import{createHash as Mi}from"crypto";import{closeSync as Di,copyFileSync as Se,existsSync as L,mkdirSync as $,mkdtempSync as Oi,openSync as Ei,readdirSync as Ai,readFileSync as B,renameSync as F,rmSync as R,statSync as Ni,writeFileSync as Mt}from"fs";import{basename as V,dirname as m,extname as Vi,join as y}from"path";import{platform as $i}from"os";import _t from"better-sqlite3";import{execFileSync as Bt}from"child_process";import{existsSync as Wt,readdirSync as Ut,readFileSync as Jt}from"fs";import{extname as T,join as Ce}from"path";function j(e={}){return{id:"auxiliary-documents",facts:["auxiliary-document"],run:t=>Le({projectRoot:t.projectRoot,dbPath:t.dbPath,extensions:e.extensions,onStatus:t.onStatus})}}function Le(e){let t=new Set((e.extensions??ke).map(o=>o.toLowerCase()));if(t.size===0)return{scanned:0,inserted:0,existing:0};if(!Wt(e.dbPath))throw new Error(`SCIP SQLite database not found at ${e.dbPath}`);let n=we(e.projectRoot),r=Gt(e.projectRoot,t).filter(o=>!n.isIgnored(o)),i=new _t(e.dbPath);try{let o=zt(i,r),s=i.prepare(`INSERT OR IGNORE INTO documents (language, relative_path, position_encoding, text)
2
+ VALUES (?, ?, NULL, ?)`),u=i.transaction(p=>{let l=0;for(let g of p){if(o.has(g))continue;let h=Jt(Ce(e.projectRoot,g),"utf-8"),f=s.run(Ht(g),g,h);l+=Number(f.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 Gt(e,t){let n=qt(e,t);if(n)return n;let r=[],i=o=>{let s=o?Ce(e,o):e,a;try{a=Ut(s,{withFileTypes:!0})}catch{return}for(let u of a){if(Ie.has(u.name))continue;let c=o?`${o}/${u.name}`:u.name;if(u.isDirectory()){i(c);continue}t.has(T(u.name).toLowerCase())&&r.push(c)}};return i(""),r.sort()}function qt(e,t){try{return Bt("git",["-C",e,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:26214400,stdio:["ignore","pipe","ignore"]}).split(`
3
+ `).filter(r=>r&&t.has(T(r).toLowerCase())).sort()}catch{return null}}function zt(e,t){let n=new Set,r=500;for(let i=0;i<t.length;i+=r){let o=t.slice(i,i+r),s=e.prepare(`SELECT relative_path FROM documents WHERE relative_path IN (${o.map(()=>"?").join(",")})`).all(...o);for(let a of s)n.add(a.relative_path)}return n}function Ht(e){return T(e).toLowerCase()===".vue"?"vue":T(e).replace(/^\./,"").toLowerCase()||"source"}import{execFileSync as Kt}from"child_process";import{existsSync as Xt,readdirSync as Te}from"fs";import{extname as Me,join as De}from"path";var Yt=new Set([".git",".hg",".svn",".idea",".vscode","node_modules","vendor","dist","build","target","bin","obj",".dart_tool",".gradle",".next",".venv","venv","__pycache__"]),Qt=[{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 G(e){let t=[],n=Zt(e),r=rn(e);for(let i of Qt){if(en(e,i.files)){t.push(i.language);continue}if(tn(n,i.globs)){t.push(i.language);continue}sn(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 Zt(e){try{return Te(e)}catch{return[]}}function en(e,t){return t?.length?t.some(n=>Xt(De(e,n))):!1}function tn(e,t){return t?.length?e.some(n=>t.some(r=>nn(n,r))):!1}function nn(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 rn(e){let t=on(e);if(t)return t;let n=new Set,r=[e];for(;r.length>0;){let i=r.pop();if(!i)continue;let o;try{o=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=De(i,s.name);if(s.isDirectory()){Yt.has(s.name)||r.push(a);continue}let u=Me(s.name).toLowerCase();u&&n.add(u)}}return n}function on(e){try{let t=Kt("git",["-C",e,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:26214400,stdio:["ignore","pipe","ignore"]}),n=new Set;for(let r of t.split(`
4
+ `)){if(!r)continue;let i=Me(r).toLowerCase();i&&n.add(i)}return n}catch{return null}}function sn(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 Oe,readdirSync as an}from"fs";import{isAbsolute as un,join as q,resolve as cn}from"path";var Ae={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",un(r)?r:cn(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",Ee(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",Ee(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=q(e,"vendor","bin","scip-php"),r=q(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(n)?n:t]}},defaultOutputPath:"index.scip",markerFiles:["composer.json"],installMethods:[],installUrl:"https://github.com/davidrjenni/scip-php/releases"}};function M(e){return Ae[e]}function Ee(e,t){let n;try{n=an(e)}catch{return null}for(let r of t)for(let i of n)if(i.endsWith(r))return q(e,i);return null}import{readFileSync as ln,writeFileSync as pn}from"fs";import{create as z}from"@bufbuild/protobuf";import{deserializeSCIP as gn,serializeSCIP as dn,DocumentSchema as fn,IndexSchema as mn,SymbolInformationSchema as hn}from"@c4312/scip";function Ne(e){if(e.length===0)throw new Error("Cannot merge zero SCIP indexes");if(e.length===1)return e[0];let t=yn(e),n=Sn(e.flatMap(i=>i.documents??[])),r=Ve(e.flatMap(i=>i.externalSymbols??[]));return z(mn,{metadata:t,documents:n,externalSymbols:r})}function D(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let n=e.map(i=>gn(ln(i))),r=Ne(n);return pn(t,Buffer.from(dn(r))),{documentCount:r.documents.length,externalSymbolCount:r.externalSymbols.length,inputCount:e.length}}function yn(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 Sn(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,z(fn,{language:r.language||n.language,relativePath:r.relativePath||n.relativePath,occurrences:bn([...r.occurrences,...n.occurrences]),symbols:Ve([...r.symbols,...n.symbols]),text:Pn(r.text,n.text),positionEncoding:r.positionEncoding||n.positionEncoding}))}return[...t.values()]}function bn(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 Ve(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,z(hn,{symbol:r.symbol,documentation:Rn([...r.documentation,...n.documentation]),relationships:xn([...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 xn(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 Pn(e,t){return e?t?e.length>=t.length?e:t:e:t}function Rn(e){return[...new Set(e)]}import{readFileSync as jn,writeFileSync as vn}from"fs";function x(e,t){let n=Date.now(),r=e.run(t);return{stageId:e.id,facts:e.facts,durationMs:Date.now()-n,result:r}}function _e(e){let t=e.readFingerprint(),n=kn(e.cachePath,t);if(n)return e.onCacheHit?.(n.result),n.result;let r=e.compute();return In(e.cachePath,e.readFingerprint(),r),r}function kn(e,t){try{let n=JSON.parse(jn(e,"utf-8"));return $e(n.fingerprint)===$e(t)?{result:n.result}:null}catch{return null}}function In(e,t,n){vn(e,`${JSON.stringify({updatedAt:new Date().toISOString(),fingerprint:t,result:n},null,2)}
5
+ `)}function $e(e){return JSON.stringify(e)}import{execFileSync as wn}from"child_process";import{createHash as Cn}from"crypto";import{readdirSync as Ln,readFileSync as Fn}from"fs";import{join as We}from"path";function H(e){return[...new Set((e??[]).map(t=>t.trim()).filter(Boolean))].sort((t,n)=>t.localeCompare(n))}function Be(e){return(Mn(e)??Dn(e)).filter(t=>t&&!Ue(t)).sort()}function I(e,t={}){return(t.language?Be(e).filter(r=>Tn(r,t.language,t.markerFiles)):Be(e)).map(r=>{let i=We(e,r);try{let o=Fn(i);return{path:r,size:o.byteLength,hash:Cn("sha256").update(o).digest("hex")}}catch{return{path:r,size:-1,hash:"unreadable"}}})}function Tn(e,t,n){let r=e.split("/").at(-1)??e;if(n?.includes(e)||n?.includes(r)||En.has(r))return!0;let i=e.includes(".")?`.${e.split(".").at(-1).toLowerCase()}`:"";return(An[t]??[]).includes(i)}function Mn(e){try{return wn("git",["-C",e,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:50*1024*1024,stdio:["ignore","pipe","ignore"]}).split(`
6
+ `).filter(Boolean)}catch{return null}}function Dn(e){let t=[],n=[""];for(;n.length>0;){let r=n.pop(),i=r?We(e,r):e,o;try{o=Ln(i,{withFileTypes:!0})}catch{continue}for(let s of o){let a=r?`${r}/${s.name}`:s.name;if(s.isDirectory()){Ue(a)||n.push(a);continue}t.push(a)}}return t}function Ue(e){let t=e.split("/");return e==="meta.json"||t.some(n=>On.has(n))||e.endsWith(".db")||e.endsWith(".db-wal")||e.endsWith(".db-shm")||e.endsWith(".scip")}var On=new Set([".git","node_modules",".scipquery-cache",".stryker-tmp","dist","build","coverage",".next",".nuxt","target"]),En=new Set(["package.json","package-lock.json","pnpm-lock.yaml","yarn.lock","bun.lockb","tsconfig.json","tsconfig.base.json","pyproject.toml","setup.py","setup.cfg","Cargo.toml","Cargo.lock","go.mod","go.sum","pom.xml","build.gradle","build.gradle.kts","build.sbt","compile_commands.json","CMakeLists.txt","Makefile","Gemfile","Gemfile.lock","composer.json","composer.lock","pubspec.yaml","pubspec.lock","deps.edn","project.clj","bb.edn","shadow-cljs.edn"]),An={typescript:[".ts",".tsx",".mts",".cts"],javascript:[".js",".jsx",".mjs",".cjs"],java:[".java"],scala:[".scala"],kotlin:[".kt",".kts"],rust:[".rs"],python:[".py",".pyi"],ruby:[".rb"],go:[".go"],cpp:[".cc",".cpp",".cxx",".hpp",".hh",".hxx"],c:[".c",".h"],csharp:[".cs"],vb:[".vb"],dart:[".dart"],php:[".php"],clojure:[".clj",".cljs",".cljc"]};import{createHash as Nn}from"crypto";import{existsSync as K,readFileSync as Vn,readdirSync as $n}from"fs";import{dirname as X,join as O,relative as _n,resolve as Y,sep as Je}from"path";function Ge(e,t){let n=t.includes("."),r={};for(let o of t)r[o]=[];let i=[];for(let o of e){let s=Ke(o.path,t);s?r[s].push(o):n?r["."].push(o):i.push(o)}return{files:r,shared:i}}function qe(e,t){let n=new Map;for(let i of e){let o=t[i]?.packageName;o&&n.set(o,i)}let r=new Map;for(let i of e)r.set(i,new Set);for(let i of e){let o=t[i],s=r.get(i);if(!o||o.parseFailed){for(let a of e)a!==i&&s.add(a);continue}for(let a of o.dependencyNames){let u=n.get(a);u&&u!==i&&s.add(u)}for(let a of[...o.pathsTargets,...o.referencesPaths]){let u=Ke(a,e);u&&u!==i&&s.add(u)}}return Bn(e,r)}function ze(e,t,n){let r={};for(let i of e){let o=new Map;for(let s of t.files[i]??[])o.set(s.path,s);for(let s of n[i]??[])for(let a of t.files[s]??[])o.set(a.path,a);for(let s of t.shared)o.set(s.path,s);r[i]={files:[...o.values()].sort((s,a)=>s.path.localeCompare(a.path))}}return r}function Q(e){if(e===".")return"root";let t=Nn("sha256").update(e).digest("hex").slice(0,8);return`${e.split("/").join("__")}-${t}`}function He(e,t){let n=Y(e),r={};for(let i of t)r[i]=Wn(n,i);return r}function Ke(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 Bn(e,t){let n={};for(let r of e){let i=new Set,o=[...t.get(r)??[]];for(;o.length>0;){let s=o.pop();if(!(s===r||i.has(s))){i.add(s);for(let a of t.get(s)??[])a!==r&&!i.has(a)&&o.push(a)}}n[r]=[...i].sort((s,a)=>s.localeCompare(a))}return n}function Wn(e,t){let n=t==="."?e:O(e,t),r=Un(n),i=Jn(n),o=i?Gn(i,e):{pathsTargets:[],referencesPaths:[],failed:!1};return{packageName:r.name,dependencyNames:r.dependencyNames,pathsTargets:o.pathsTargets,referencesPaths:o.referencesPaths,parseFailed:r.failed||o.failed}}function Un(e){let t=O(e,"package.json");if(!K(t))return{name:void 0,dependencyNames:[],failed:!1};let n=Z(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 o of["dependencies","devDependencies","peerDependencies"]){let s=n.value[o];if(s&&typeof s=="object"&&!Array.isArray(s))for(let a of Object.keys(s))i.add(a)}return{name:r,dependencyNames:[...i],failed:!1}}function Jn(e){let t=O(e,"tsconfig.json");if(K(t))return t;let n;try{n=$n(e).filter(r=>/^tsconfig.*\.json$/.test(r))}catch{return}return n.sort((r,i)=>r.localeCompare(i)),n.length>0?O(e,n[0]):void 0}function Gn(e,t){let n=Z(e);if(!n.ok)return{pathsTargets:[],referencesPaths:[],failed:!0};let r=qn(n.value,e,t),i=Xe(e,n.value,t,0);return{pathsTargets:i.pathsTargets,referencesPaths:r,failed:i.failed}}function qn(e,t,n){let r=e.references;if(!Array.isArray(r))return[];let i=X(t),o=new Set;for(let s of r){if(!s||typeof s!="object")continue;let a=s.path;if(typeof a!="string"||a.trim()==="")continue;let u=Ye(a,i,n);u&&o.add(u)}return[...o]}function Xe(e,t,n,r){let i=zn(t);if(i)return{pathsTargets:Hn(i,X(e),n),failed:!1};if(r>=5)return{pathsTargets:[],failed:!1};let o=Kn(t.extends,e,n);if(!o)return{pathsTargets:[],failed:!1};let s=Z(o);return s.ok?Xe(o,s.value,n,r+1):{pathsTargets:[],failed:!0}}function zn(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 Hn(e,t,n){let r=new Set;for(let i of Object.values(e))if(Array.isArray(i))for(let o of i){if(typeof o!="string")continue;let s=Ye(o,t,n);s&&r.add(s)}return[...r]}function Kn(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=Y(X(t),r);if(i.endsWith(".json")||(i=`${i}.json`),!i.split(Je).includes("node_modules")&&v(n,i)&&K(i))return i}function Ye(e,t,n){let r=e.replace(/\/?\*+$/,""),i=Y(t,r===""?".":r);if(!v(n,i))return;let s=_n(n,i).split(Je).join("/");return s===""?".":s}function Xn(e){let t="",n=0,r=!1,i=e.length;for(;n<i;){let o=e[n];if(r){if(t+=o,o==="\\"&&n+1<i){t+=e[n+1],n+=2;continue}o==='"'&&(r=!1),n+=1;continue}if(o==='"'){r=!0,t+=o,n+=1;continue}if(o==="/"&&e[n+1]==="/"){for(n+=2;n<i&&e[n]!==`
7
+ `;)n+=1;continue}if(o==="/"&&e[n+1]==="*"){for(n+=2;n<i&&!(e[n]==="*"&&e[n+1]==="/");)n+=1;n+=2;continue}t+=o,n+=1}return t}function Z(e){try{let t=Vn(e,"utf-8"),n=JSON.parse(Xn(t));return n&&typeof n=="object"&&!Array.isArray(n)?{ok:!0,value:n}:{ok:!1}}catch{return{ok:!1}}}import{readFileSync as Yn,writeFileSync as Qn}from"fs";import{create as Qe}from"@bufbuild/protobuf";import{deserializeSCIP as Zn,DocumentSchema as er,IndexSchema as tr,serializeSCIP as nr,SymbolRole as rr}from"@c4312/scip";function Ze(e){let t;try{t=Zn(Yn(e))}catch{return{removedDefinitionOccurrences:0,touchedDocuments:0}}let n=ir(t);return n.removedDefinitionOccurrences>0&&Qn(e,Buffer.from(nr(n.index))),{removedDefinitionOccurrences:n.removedDefinitionOccurrences,touchedDocuments:n.touchedDocuments}}function ir(e){let t=new Set;for(let o of e.documents)for(let s of o.symbols)s.symbol&&t.add(s.symbol);for(let o of e.externalSymbols)o.symbol&&t.add(o.symbol);let n=0,r=0,i=[];for(let o of e.documents){let s=o.occurrences.filter(a=>(a.symbolRoles&rr.Definition)===0||t.has(a.symbol)?!0:(n+=1,!1));if(s.length===o.occurrences.length){i.push(o);continue}r+=1,i.push(Qe(er,{language:o.language,relativePath:o.relativePath,occurrences:s,symbols:o.symbols,text:o.text,positionEncoding:o.positionEncoding}))}return{index:n===0?e:Qe(tr,{metadata:e.metadata,documents:i,externalSymbols:e.externalSymbols}),removedDefinitionOccurrences:n,touchedDocuments:r}}import{existsSync as or,readFileSync as sr,readdirSync as ar,statSync as ur}from"fs";import d from"path";var cr=new Set([".cache",".git",".next",".nuxt",".turbo",".nx","build","coverage","dist","node_modules","tmp","vendor"]);function ee(e,t=[]){let n=d.resolve(e),r=t.flatMap(u=>pr(n,u));if(r.length>0)return et(n,tt(r));let i=lr(n),o=tt(i),s=dr(n,o)?[n,...o]:o,a=s.length>0?s:[n];return et(n,a)}function et(e,t){return[...new Set(t.map(n=>mr(e,n)))].sort((n,r)=>n.localeCompare(r))}function lr(e){let t=[],n=[e];for(;n.length>0;){let r=n.pop(),i;try{i=ar(r,{withFileTypes:!0})}catch{continue}for(let o of i){let s=d.join(r,o.name);if(o.isDirectory()){!cr.has(o.name)&&!o.name.startsWith(".")&&n.push(s);continue}o.isFile()&&gr(s)&&t.push(d.dirname(s))}}return t}function pr(e,t){let n=t.trim();if(!n)return[];let r=d.resolve(e,n);if(!v(e,r))return[];try{let i=ur(r);if(i.isDirectory())return[r];if(i.isFile()&&nt(d.basename(r)))return[d.dirname(r)]}catch{return[]}return[]}function gr(e){if(!nt(d.basename(e)))return!1;let t=rt(e);return t?d.basename(e)==="tsconfig.json"||"include"in t||"files"in t||"references"in t:!1}function nt(e){return e.startsWith("tsconfig")&&e.endsWith(".json")}function tt(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&&hr(n,r)))}function dr(e,t){if(t.length===0||t.some(r=>d.resolve(r)===e))return!1;let n=d.join(e,"tsconfig.json");return or(n)&&fr(n)}function fr(e){let n=rt(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 rt(e){try{let t=JSON.parse(sr(e,"utf-8"));return t&&typeof t=="object"&&!Array.isArray(t)?t:null}catch{return null}}function mr(e,t){let n=d.relative(e,t);return n?n.split(d.sep).join("/"):"."}function hr(e,t){let n=d.relative(e,t);return!!n&&!n.startsWith("..")&&!d.isAbsolute(n)}import{execFile as yr}from"child_process";import{existsSync as E,renameSync as ne,rmSync as re,statSync as Sr}from"fs";import{cpus as br}from"os";import{join as it}from"path";function xr(e,t,n){if(!e.defaultOutputPath)return;let r=it(t,e.defaultOutputPath);n!==r&&E(r)&&ne(r,n)}function Pr(e,t,n){if(!e.defaultOutputPath)return null;let r=it(t,e.defaultOutputPath);if(r===n)return null;let i=`${n}.default-output-backup`;return re(i,{force:!0}),E(r)?(ne(r,i),{defaultOutputPath:r,backupPath:i}):{defaultOutputPath:r,backupPath:null}}function Rr(e){e&&(re(e.defaultOutputPath,{force:!0}),e.backupPath&&E(e.backupPath)&&ne(e.backupPath,e.defaultOutputPath))}function jr(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,br().length));return Math.max(1,Math.min(e,Math.floor(r)))}async function ot(e,t,n,r){let i=e.filter(c=>c.config.defaultOutputPath),o=e.filter(c=>!c.config.defaultOutputPath),s=[],a=jr(o.length,r),u=await kr(o,a,c=>te(c,t,n));if(a>1){let c=new Map;for(let p of u.filter(l=>l.skipped)){let l=o.find(g=>g.id===p.id);l&&(n(`Retrying ${l.label} indexer serially after parallel failure...`),c.set(l.id,await te(l,t,n)))}s.push(...u.map(p=>c.get(p.id)??p))}else s.push(...u);for(let c of i)s.push(await te(c,t,n));return s.sort((c,p)=>e.findIndex(l=>l.id===c.id)-e.findIndex(l=>l.id===p.id))}async function te(e,t,n){n(`Indexing ${e.label} with ${e.resolvedBinary}...`),re(e.scipPath,{force:!0});let r=Pr(e.config,t,e.scipPath),i=[e.binary,...e.args].join(" "),o=Date.now();try{await vr(e.binary,e.args,{cwd:t,env:e.env,maxBuffer:50*1024*1024}),xr(e.config,t,e.scipPath)}catch(a){let u=a instanceof Error?a.message:String(a),c=`${e.resolvedBinary} indexer failed: ${u.split(`
8
+ `)[0]}`,p=e.label===e.language?c:`${e.label}: ${c}`;return n(`Skipping ${e.label}: ${c}`),{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:Date.now()-o,command:i,skipped:{language:e.language,reason:p}}}finally{Rr(r)}if(!E(e.scipPath)){let a=`${e.resolvedBinary} indexer completed but did not produce ${e.scipPath}`,u=e.label===e.language?a:`${e.label}: ${a}`;return n(`Skipping ${e.label}: ${a}`),{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:Date.now()-o,command:i,skipped:{language:e.language,reason:u}}}let s;try{s=Sr(e.scipPath).size}catch{s=void 0}return{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:Date.now()-o,command:i,outputBytes:s}}function vr(e,t,n){return new Promise((r,i)=>{yr(e,[...t],n,o=>{o?i(o):r()})})}async function kr(e,t,n){if(e.length===0)return[];let r=new Array(e.length),i=0,o=Math.max(1,Math.min(e.length,t)),s=Array.from({length:o},async()=>{for(;i<e.length;){let a=i++;r[a]=await n(e[a])}});return await Promise.all(s),r}import{execFileSync as oe}from"child_process";import{existsSync as ie,readFileSync as Ir}from"fs";import{createRequire as wr}from"module";import{platform as Cr}from"os";import{dirname as st,join as A}from"path";var Lr=wr(import.meta.url);function se(e){return[e.indexerBinary,...e.binaryAliases??[]]}function N(e){let t=se(e);return t.length===1?t[0]:t.join(" or ")}function w(e){for(let t of se(e))if(k(t))return t;return Tr(e)}function ae(e){return w(e)!==null||Fr(e)}function Fr(e){return at(e)!==null}function Tr(e){let t=at(e);if(!t)return null;let r=JSON.parse(Ir(t,"utf8")).bin;if(!r)return null;if(typeof r=="string")return A(st(t),r);for(let i of se(e)){let o=r[i];if(o)return A(st(t),o)}return null}function at(e){if(!e.bundledNpmPackage)return null;try{return Lr.resolve(`${e.bundledNpmPackage}/package.json`)}catch{return null}}function ue(e,t){for(let n of e.projectLocalBinaries??[]){let r=A(t,n);if(ie(r))return r}return null}function ce(e,t=process.env,n=e.indexerBinary){if(e.indexerBinary!=="scip-dotnet"||ut(n,t))return t;let r=Mr(n,t);return r?{...t,DOTNET_ROOT:r}:t}function le(e,t){let n=e.installMethods,r=N(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(k(i.prerequisite)){t(`Installing ${r} via ${i.label}...`);try{oe(i.binary,i.args,{stdio:"inherit",timeout:3e5,env:process.env});let o=w(e);if(o){let s=o===e.indexerBinary?"":` (using ${o})`;return t(`Successfully installed ${r} via ${i.label}${s}`),!0}t(`${i.label} command completed but ${r} was not found on PATH`)}catch(o){let s=o instanceof Error?o.message:String(o);t(`${i.label} install failed: ${s}`)}}return t(`Could not auto-install ${r}.`),e.installUrl&&t(`Install manually from: ${e.installUrl}`),!1}function Mr(e,t){for(let n of Dr(t))if(ut(e,{...t,DOTNET_ROOT:n}))return n;return null}function Dr(e){let t=[],n=e.DOTNET_ROOT;if(n&&ie(n)&&t.push(n),Cr()==="darwin"&&k("brew"))try{let r=oe("brew",["--prefix","dotnet@9"],{stdio:"pipe",env:e}).toString().trim(),i=A(r,"libexec");ie(i)&&!t.includes(i)&&t.push(i)}catch{}return t}function ut(e,t){try{return oe(e,["--version"],{stdio:"pipe",env:t}),!0}catch{return!1}}import di from"better-sqlite3";import{existsSync as fi}from"fs";import{dirname as mi,join as hi,resolve as yi}from"path";import{readFileSync as Or,rmSync as Er,statSync as Ar,mkdtempSync as Nr}from"fs";import{cpus as Vr,tmpdir as $r}from"os";import{join as pe}from"path";import{Worker as _r}from"worker_threads";function ct(e){return e.length>=8&&pt(e.length)>1}function lt(e){let t=pt(e.vueFiles.length),n=Wr(e.vueFiles),r=Jr(n,t),i=new URL("./augment-vue-worker.js",import.meta.url),o=Nr(pe($r(),"scip-query-vue-workers-")),s=new SharedArrayBuffer(4),a=new Int32Array(s),u=Br(),c=Date.now();try{for(let l=0;l<r.length;l++)new _r(i,{workerData:{projectRoot:e.projectRoot,dbPath:e.dbPath,tsconfig:e.tsconfig,tasks:r[l],resultPath:pe(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 p=r.map((l,g)=>{let h=JSON.parse(Or(pe(o,`${g}.json`),"utf-8"));if(!h.ok)throw new Error(`Vue reference worker failed: ${h.error}`);return h.result});return{occurrences:p.flatMap(l=>l.occurrences),skippedReferences:p.reduce((l,g)=>l+g.skippedReferences,0)}}finally{Er(o,{recursive:!0,force:!0})}}function pt(e){let t=Number(process.env.SCIP_QUERY_AUGMENT_VUE_WORKERS??0),n=Number.isFinite(t)&&t>0?t:Math.min(8,Math.max(1,Vr().length-1));return Math.max(1,Math.min(e,n))}function Br(){let e=Number(process.env.SCIP_QUERY_AUGMENT_VUE_WORKER_TIMEOUT_MS??0);return Number.isFinite(e)&&e>0?e:3e5}function Wr(e){let t=Ur(),n=[];for(let r of e){let i=gt(r),o=Math.max(1,Math.ceil(i/t));for(let s=0;s<o;s++)n.push({fileName:r,startOffset:Math.floor(i*s/o),endOffset:s===o-1?Number.POSITIVE_INFINITY:Math.floor(i*(s+1)/o),countFileSkip:s===0})}return n}function Ur(){return Number.POSITIVE_INFINITY}function Jr(e,t){let n=Array.from({length:t},()=>({tasks:[],weight:0})),r=e.map(i=>({task:i,weight:Gr(i)})).sort((i,o)=>o.weight-i.weight);for(let i of r){let o=n.reduce((s,a)=>a.weight<s.weight?a:s);o.tasks.push(i.task),o.weight+=i.weight}return n.map(i=>i.tasks).filter(i=>i.length>0)}function Gr(e){return Number.isFinite(e.endOffset)?Math.max(1,e.endOffset-e.startOffset):Math.max(1,gt(e.fileName)-e.startOffset)}function gt(e){try{return Ar(e).size}catch{return 1}}import{createRequire as qr}from"module";import{existsSync as zr,readFileSync as de}from"fs";import{dirname as dt,extname as Hr,join as ft,relative as Kr,resolve as Xr}from"path";import{pathToFileURL as Yr}from"url";function Qr(e){e.transaction(()=>{e.prepare(`
8
9
  DELETE FROM mentions
9
10
  WHERE chunk_id IN (
10
11
  SELECT c.id
@@ -19,12 +20,12 @@ import{a as R,b as E,f as V}from"./chunk-WIBFXSYB.js";import{a as pe}from"./chun
19
20
  FROM documents
20
21
  WHERE language = 'vue' OR relative_path LIKE '%.vue'
21
22
  )
22
- `).run()})()}function qe(e,t){return e.prepare(`
23
+ `).run()})()}function mt(e,t){return e.prepare(`
23
24
  SELECT relative_path AS relativePath
24
25
  FROM documents
25
26
  WHERE language = 'vue' OR relative_path LIKE '%.vue'
26
27
  ORDER BY relative_path
27
- `).all().map(r=>fr(t,r.relativePath))}function ze(e,t){let{vueCore:n,ts:r,volarTs:i}=yr(e),{parsed:o,vueOptions:s}=br(n,r,t),a=Ue(t),u=n.createVueLanguagePlugin(r,o.options,s,h=>h),c=xr(n,r,u),g=Sr(a,o),{languageServiceHost:l}=i.createLanguageServiceHost(r,r.sys,c,h=>h,g),p=r.createLanguageService(l);return{ts:r,language:c,languageService:p,fileNames:o.fileNames,configDir:a}}function yr(e){let t=lr(mr(Je(e,"package.json")).href);return{vueCore:Q(t,"@vue/language-core",e),ts:Q(t,"typescript",e),volarTs:Q(t,"@volar/typescript",e)}}function br(e,t,n){let r=t.readConfigFile(n,t.sys.readFile);if(r.error||!r.config)throw new Error(`Failed to read ${n}`);let o=e.createParsedCommandLine(t,t.sys,n).vueOptions;return typeof e.createGlobalTypesWriter=="function"&&(o.globalTypesPath=e.createGlobalTypesWriter(o,t.sys.writeFile)),{parsed:t.parseJsonConfigFileContent(r.config,t.sys,Ue(n),void 0,n,void 0,e.getAllExtensions(o).map(s=>({extension:s.slice(1),isMixedContent:!0,scriptKind:t.ScriptKind.Deferred}))),vueOptions:o}}function xr(e,t,n){let r={},i=e.createLanguage([n],new Map,o=>{if(!gr(o))return;let s=Z(o,"utf-8");r.current?.scripts.set(o,t.ScriptSnapshot.fromString(s),n.getLanguageId(o)??jr(o))});return r.current=i,i}function Sr(e,t){return{getCurrentDirectory:()=>e,getCompilationSettings:()=>t.options,getScriptFileNames:()=>t.fileNames,getProjectReferences:()=>t.projectReferences,getProjectVersion:()=>"0"}}function Q(e,t,n){try{return e(t)}catch(r){throw(typeof r=="object"&&r!==null&&"code"in r?r.code:null)==="MODULE_NOT_FOUND"?new Error(`Vue augmentation requires ${t} to be installed in ${n}. Install Vue/Volar dependencies for that project, then rerun augment-vue.`,{cause:r}):r}}function He(e,t,n){let r=Rr(e);return i=>{let o=b(t,i.fileName),s=n.get(i.fileName);if(!s)return null;let a=n.positionAt(s,i.textSpan.start),u=r.get(o);if(!u)return null;let c=u.containingByLine.get(a.line);return c!==void 0?c:Pr(u.starts,a.line,2)}}function Rr(e){let t=e.prepare(`
28
+ `).all().map(r=>Xr(t,r.relativePath))}function ht(e,t){let{vueCore:n,ts:r,volarTs:i}=Zr(e),{parsed:o,vueOptions:s}=ei(n,r,t),a=dt(t),u=n.createVueLanguagePlugin(r,o.options,s,h=>h),c=ti(n,r,u),p=ni(a,o),{languageServiceHost:l}=i.createLanguageServiceHost(r,r.sys,c,h=>h,p),g=r.createLanguageService(l);return{ts:r,language:c,languageService:g,fileNames:o.fileNames,configDir:a}}function Zr(e){let t=qr(Yr(ft(e,"package.json")).href);return{vueCore:ge(t,"@vue/language-core",e),ts:ge(t,"typescript",e),volarTs:ge(t,"@volar/typescript",e)}}function ei(e,t,n){let r=t.readConfigFile(n,t.sys.readFile);if(r.error||!r.config)throw new Error(`Failed to read ${n}`);let o=e.createParsedCommandLine(t,t.sys,n).vueOptions;return typeof e.createGlobalTypesWriter=="function"&&(o.globalTypesPath=e.createGlobalTypesWriter(o,t.sys.writeFile)),{parsed:t.parseJsonConfigFileContent(r.config,t.sys,dt(n),void 0,n,void 0,e.getAllExtensions(o).map(s=>({extension:s.slice(1),isMixedContent:!0,scriptKind:t.ScriptKind.Deferred}))),vueOptions:o}}function ti(e,t,n){let r={},i=e.createLanguage([n],new Map,o=>{if(!zr(o))return;let s=de(o,"utf-8");r.current?.scripts.set(o,t.ScriptSnapshot.fromString(s),n.getLanguageId(o)??ui(o))});return r.current=i,i}function ni(e,t){return{getCurrentDirectory:()=>e,getCompilationSettings:()=>t.options,getScriptFileNames:()=>t.fileNames,getProjectReferences:()=>t.projectReferences,getProjectVersion:()=>"0"}}function ge(e,t,n){try{return e(t)}catch(r){throw(typeof r=="object"&&r!==null&&"code"in r?r.code:null)==="MODULE_NOT_FOUND"?new Error(`Vue augmentation requires ${t} to be installed in ${n}. Install Vue/Volar dependencies for that project, then rerun augment-vue.`,{cause:r}):r}}function yt(e,t,n){let r=ri(e);return i=>{let o=P(t,i.fileName),s=n.get(i.fileName);if(!s)return null;let a=n.positionAt(s,i.textSpan.start),u=r.get(o);if(!u)return null;let c=u.containingByLine.get(a.line);return c!==void 0?c:ii(u.starts,a.line,2)}}function ri(e){let t=e.prepare(`
28
29
  SELECT
29
30
  d.relative_path AS relativePath,
30
31
  der.start_line AS startLine,
@@ -33,22 +34,22 @@ import{a as R,b as E,f as V}from"./chunk-WIBFXSYB.js";import{a as pe}from"./chun
33
34
  FROM defn_enclosing_ranges der
34
35
  JOIN documents d ON d.id = der.document_id
35
36
  ORDER BY d.relative_path, (der.end_line - der.start_line) DESC
36
- `).all(),n=new Map;for(let r of t){let i=n.get(r.relativePath);i||(i={containingByLine:new Map,starts:[]},n.set(r.relativePath,i)),i.starts.push({line:r.startLine,symbolId:r.symbolId});for(let o=r.startLine;o<=r.endLine;o++)i.containingByLine.set(o,r.symbolId)}for(let r of n.values())r.starts.sort((i,o)=>i.line-o.line);return n}function Pr(e,t,n){let r=0,i=e.length-1;for(;r<=i;){let s=Math.floor((r+i)/2);e[s].line<t?r=s+1:i=s-1}let o=null;for(let s of[i,r]){let a=e[s];if(!a)continue;let u=Math.abs(a.line-t);u>n||(!o||u<o.distance)&&(o={distance:u,symbolId:a.symbolId})}return o?.symbolId??null}function Ge(e,t,n){let r=Cr(t),i=e.prepare("SELECT id FROM global_symbols WHERE symbol = ?"),o=e.prepare(`
37
+ `).all(),n=new Map;for(let r of t){let i=n.get(r.relativePath);i||(i={containingByLine:new Map,starts:[]},n.set(r.relativePath,i)),i.starts.push({line:r.startLine,symbolId:r.symbolId});for(let o=r.startLine;o<=r.endLine;o++)i.containingByLine.set(o,r.symbolId)}for(let r of n.values())r.starts.sort((i,o)=>i.line-o.line);return n}function ii(e,t,n){let r=0,i=e.length-1;for(;r<=i;){let s=Math.floor((r+i)/2);e[s].line<t?r=s+1:i=s-1}let o=null;for(let s of[i,r]){let a=e[s];if(!a)continue;let u=Math.abs(a.line-t);u>n||(!o||u<o.distance)&&(o={distance:u,symbolId:a.symbolId})}return o?.symbolId??null}function St(e,t,n){let r=pi(t),i=e.prepare("SELECT id FROM global_symbols WHERE symbol = ?"),o=e.prepare(`
37
38
  INSERT OR IGNORE INTO global_symbols (symbol, display_name, kind, documentation)
38
39
  VALUES (?, ?, ?, ?)
39
- `),s=0,a=new Map;return e.transaction(()=>{for(let c of n){let g=b(t,c),l=rt(r.name,r.version,g);o.run(l,"default",7,`Vue component|${g}`);let p=Or(i,r,t,c);p&&(s++,a.set(c,p))}})(),{get(c){return a.get(c)??null},syntheticSymbols:s}}function Ke(e,t,n,r,i){return e.transaction(()=>(hr(e),vr(e,t,n,r),kr(e,i)))()}function vr(e,t,n,r){let i=e.prepare("SELECT id FROM documents WHERE relative_path = ?"),o=e.prepare(`
40
+ `),s=0,a=new Map;return e.transaction(()=>{for(let c of n){let p=P(t,c),l=wt(r.name,r.version,p);o.run(l,"default",7,`Vue component|${p}`);let g=gi(i,r,t,c);g&&(s++,a.set(c,g))}})(),{get(c){return a.get(c)??null},syntheticSymbols:s}}function bt(e,t,n,r,i){return e.transaction(()=>(Qr(e),oi(e,t,n,r),si(e,i)))()}function oi(e,t,n,r){let i=e.prepare("SELECT id FROM documents WHERE relative_path = ?"),o=e.prepare(`
40
41
  INSERT INTO chunks (document_id, chunk_index, start_line, end_line, occurrences)
41
42
  VALUES (?, ?, ?, ?, X'00')
42
43
  `),s=e.prepare(`
43
44
  INSERT OR IGNORE INTO mentions (chunk_id, symbol_id, role)
44
45
  VALUES (?, ?, 1)
45
- `);for(let a of n){let u=r.get(a);if(!u)continue;let c=b(t,a),g=i.get(c);if(!g)continue;let l=o.run(g.id,-1,0,0);s.run(Number(l.lastInsertRowid),u)}}function Xe(e,t,n,r,i){if(e.fileName.endsWith(".vue")){let o=r.language.scripts.get(e.fileName),s=o?.generated?.languagePlugin.typescript?.getServiceScript(o.generated.root)?.code;if(o&&s){let a=r.language.maps.get(s,o);if(ee(a,e.textSpan.start)!==null)return n.get(e.fileName)}return e.fileName.startsWith(i)?n.get(e.fileName):null}return t(e)}function Ye(e){let t=new Set,n=[];for(let r of e){let i=Qe(r);t.has(i)||(t.add(i),n.push(r))}return n}function Qe(e){return[e.sourceFile,e.sourceLine,e.sourceStartChar,e.sourceEndChar,e.symbolId].join(":")}function kr(e,t){let n=Lr(e,[...new Set(t.map(u=>u.sourceFile))]),r=e.prepare(`
46
+ `);for(let a of n){let u=r.get(a);if(!u)continue;let c=P(t,a),p=i.get(c);if(!p)continue;let l=o.run(p.id,-1,0,0);s.run(Number(l.lastInsertRowid),u)}}function xt(e,t,n,r,i){if(e.fileName.endsWith(".vue")){let o=r.language.scripts.get(e.fileName),s=o?.generated?.languagePlugin.typescript?.getServiceScript(o.generated.root)?.code;if(o&&s){let a=r.language.maps.get(s,o);if(fe(a,e.textSpan.start)!==null)return n.get(e.fileName)}return e.fileName.startsWith(i)?n.get(e.fileName):null}return t(e)}function Pt(e){let t=new Set,n=[];for(let r of e){let i=Rt(r);t.has(i)||(t.add(i),n.push(r))}return n}function Rt(e){return[e.sourceFile,e.sourceLine,e.sourceStartChar,e.sourceEndChar,e.symbolId].join(":")}function si(e,t){let n=li(e,[...new Set(t.map(u=>u.sourceFile))]),r=e.prepare(`
46
47
  INSERT INTO chunks (document_id, chunk_index, start_line, end_line, occurrences)
47
48
  VALUES (?, ?, ?, ?, X'00')
48
49
  `),i=e.prepare(`
49
50
  INSERT OR IGNORE INTO mentions (chunk_id, symbol_id, role)
50
51
  VALUES (?, ?, 0)
51
- `),o=new Set,s=0,a=0;for(let u of t){let c=Qe(u);if(o.has(c))continue;o.add(c);let g=n.get(u.sourceFile);if(!g)continue;let l=r.run(g,a++,u.sourceLine,u.sourceLine),p=i.run(Number(l.lastInsertRowid),u.symbolId);s+=Number(p.changes)}return s}function*Ze(e){let t=/\b[A-Za-z_$][A-Za-z0-9_$]*\b/g,n=new Set(["script","setup","template","style","lang","scoped","true","false","null","undefined","const","let","var","import","from","export","return","if","else","for","while","function","class","type","interface","as","await","async"]),r;for(;r=t.exec(e);){let i=r[0];n.has(i)||(yield{text:i,start:r.index,end:r.index+i.length})}}function et(e,t){for(let[n]of e.toGeneratedLocation(t,r=>!!r.navigation))return n;return null}function ee(e,t){let n=e;for(let[r]of n.toSourceLocation(t,i=>!!i.navigation))return r;return null}function Ir(e,t){let n=0,r=e.lineStarts.length-1;for(;n<=r;){let o=Math.floor((n+r)/2);e.lineStarts[o]<=t?n=o+1:r=o-1}let i=Math.max(0,r);return{line:i,character:t-e.lineStarts[i]}}function tt(e,t){return b(e,t).startsWith("node_modules/")}function b(e,t){return dr(e,t).replaceAll("\\","/")}function jr(e){switch(pr(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 nt(){let e=new Map;return{get(t){if(e.has(t))return e.get(t)??null;try{let n=Z(t,"utf-8"),r={text:n,lineStarts:wr(n)};return e.set(t,r),r}catch{return e.set(t,null),null}},positionAt:Ir}}function wr(e){let t=[0];for(let n=0;n<e.length;n++)e.charCodeAt(n)===10&&t.push(n+1);return t}function Lr(e,t){let n=new Map,r=500;for(let i=0;i<t.length;i+=r){let o=t.slice(i,i+r),s=e.prepare(`SELECT id, relative_path AS relativePath FROM documents WHERE relative_path IN (${o.map(()=>"?").join(",")})`).all(...o);for(let a of s)n.set(a.relativePath,a.id)}return n}function Cr(e){try{let t=JSON.parse(Z(Je(e,"package.json"),"utf-8"));return{name:t.name??"workspace",version:t.version??"0.0.0"}}catch{return{name:"workspace",version:"0.0.0"}}}function Or(e,t,n,r){let i=b(n,r),o=rt(t.name,t.version,i);return e.get(o)?.id??null}function rt(e,t,n){let r=n.split("/").map(i=>`\`${i.replaceAll("`","")}\``).join("/");return`scip-vue npm ${e} ${t} ${r}/default.`}function it(e){return{id:"vue-resolved-references",facts:["synthetic-symbol","source-mapped-occurrence","definition-mention","replacement-chunk","fingerprint-cache"],run:t=>Ar({projectRoot:t.projectRoot,dbPath:t.dbPath,tsconfig:e.tsconfig,onStatus:t.onStatus})}}function Vr(e){return y(S(),{projectRoot:e.projectRoot,dbPath:e.dbPath}),y(it({tsconfig:e.tsconfig}),{projectRoot:e.projectRoot,dbPath:e.dbPath,onStatus:e.onStatus}).result}function Ar(e){let t=Er(e.projectRoot,e.tsconfig);if(!Dr(t))throw new Error(`Vue tsconfig not found at ${t}`);let n=new Mr(e.dbPath);try{let r=qe(n,e.projectRoot),i=Tr(Fr(e.dbPath),"augment-vue-meta.json");return Ie({cachePath:i,readFingerprint:()=>_r(n,e.projectRoot,e.tsconfig),compute:()=>Nr({db:n,projectRoot:e.projectRoot,dbPath:e.dbPath,tsconfig:e.tsconfig,configPath:t,vueFiles:r,onStatus:e.onStatus}),onCacheHit:o=>e.onStatus?.(`Vue references unchanged; reused ${o.resolvedReferences} cached resolved references.`)})}finally{n.close()}}function Nr(e){let t=Ge(e.db,e.projectRoot,e.vueFiles),n=$r(e,t),r=Ye(n.occurrences),i=Ke(e.db,e.projectRoot,e.vueFiles,t,r),o={vueFiles:e.vueFiles.length,resolvedReferences:r.length,insertedMentions:i,skippedReferences:n.skippedReferences,syntheticSymbols:t.syntheticSymbols};return e.onStatus?.(`Resolved ${o.resolvedReferences} Vue references with Volar; inserted ${o.insertedMentions} mentions.`),o}function $r(e,t){if($e(e.vueFiles))return _e({projectRoot:e.projectRoot,dbPath:e.dbPath,tsconfig:e.tsconfig,vueFiles:e.vueFiles});let n=Br({db:e.db,projectRoot:e.projectRoot,configPath:e.configPath,vueSymbolLookup:t});return Wr({...n,vueFiles:n.context.fileNames.filter(r=>r.endsWith(".vue"))})}function _r(e,t,n){let r=e.prepare(`
52
+ `),o=new Set,s=0,a=0;for(let u of t){let c=Rt(u);if(o.has(c))continue;o.add(c);let p=n.get(u.sourceFile);if(!p)continue;let l=r.run(p,a++,u.sourceLine,u.sourceLine),g=i.run(Number(l.lastInsertRowid),u.symbolId);s+=Number(g.changes)}return s}function*jt(e){let t=/\b[A-Za-z_$][A-Za-z0-9_$]*\b/g,n=new Set(["script","setup","template","style","lang","scoped","true","false","null","undefined","const","let","var","import","from","export","return","if","else","for","while","function","class","type","interface","as","await","async"]),r;for(;r=t.exec(e);){let i=r[0];n.has(i)||(yield{text:i,start:r.index,end:r.index+i.length})}}function vt(e,t){for(let[n]of e.toGeneratedLocation(t,r=>!!r.navigation))return n;return null}function fe(e,t){let n=e;for(let[r]of n.toSourceLocation(t,i=>!!i.navigation))return r;return null}function ai(e,t){let n=0,r=e.lineStarts.length-1;for(;n<=r;){let o=Math.floor((n+r)/2);e.lineStarts[o]<=t?n=o+1:r=o-1}let i=Math.max(0,r);return{line:i,character:t-e.lineStarts[i]}}function kt(e,t){return P(e,t).startsWith("node_modules/")}function P(e,t){return Kr(e,t).replaceAll("\\","/")}function ui(e){switch(Hr(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 It(){let e=new Map;return{get(t){if(e.has(t))return e.get(t)??null;try{let n=de(t,"utf-8"),r={text:n,lineStarts:ci(n)};return e.set(t,r),r}catch{return e.set(t,null),null}},positionAt:ai}}function ci(e){let t=[0];for(let n=0;n<e.length;n++)e.charCodeAt(n)===10&&t.push(n+1);return t}function li(e,t){let n=new Map,r=500;for(let i=0;i<t.length;i+=r){let o=t.slice(i,i+r),s=e.prepare(`SELECT id, relative_path AS relativePath FROM documents WHERE relative_path IN (${o.map(()=>"?").join(",")})`).all(...o);for(let a of s)n.set(a.relativePath,a.id)}return n}function pi(e){try{let t=JSON.parse(de(ft(e,"package.json"),"utf-8"));return{name:t.name??"workspace",version:t.version??"0.0.0"}}catch{return{name:"workspace",version:"0.0.0"}}}function gi(e,t,n,r){let i=P(n,r),o=wt(t.name,t.version,i);return e.get(o)?.id??null}function wt(e,t,n){let r=n.split("/").map(i=>`\`${i.replaceAll("`","")}\``).join("/");return`scip-vue npm ${e} ${t} ${r}/default.`}function Ct(e){return{id:"vue-resolved-references",facts:["synthetic-symbol","source-mapped-occurrence","definition-mention","replacement-chunk","fingerprint-cache"],run:t=>bi({projectRoot:t.projectRoot,dbPath:t.dbPath,tsconfig:e.tsconfig,onStatus:t.onStatus})}}function Si(e){return x(j(),{projectRoot:e.projectRoot,dbPath:e.dbPath}),x(Ct({tsconfig:e.tsconfig}),{projectRoot:e.projectRoot,dbPath:e.dbPath,onStatus:e.onStatus}).result}function bi(e){let t=yi(e.projectRoot,e.tsconfig);if(!fi(t))throw new Error(`Vue tsconfig not found at ${t}`);let n=new di(e.dbPath);try{let r=mt(n,e.projectRoot),i=hi(mi(e.dbPath),"augment-vue-meta.json");return _e({cachePath:i,readFingerprint:()=>Ri(n,e.projectRoot,e.tsconfig),compute:()=>xi({db:n,projectRoot:e.projectRoot,dbPath:e.dbPath,tsconfig:e.tsconfig,configPath:t,vueFiles:r,onStatus:e.onStatus}),onCacheHit:o=>e.onStatus?.(`Vue references unchanged; reused ${o.resolvedReferences} cached resolved references.`)})}finally{n.close()}}function xi(e){let t=St(e.db,e.projectRoot,e.vueFiles),n=Pi(e,t),r=Pt(n.occurrences),i=bt(e.db,e.projectRoot,e.vueFiles,t,r),o={vueFiles:e.vueFiles.length,resolvedReferences:r.length,insertedMentions:i,skippedReferences:n.skippedReferences,syntheticSymbols:t.syntheticSymbols};return e.onStatus?.(`Resolved ${o.resolvedReferences} Vue references with Volar; inserted ${o.insertedMentions} mentions.`),o}function Pi(e,t){if(ct(e.vueFiles))return lt({projectRoot:e.projectRoot,dbPath:e.dbPath,tsconfig:e.tsconfig,vueFiles:e.vueFiles});let n=ji({db:e.db,projectRoot:e.projectRoot,configPath:e.configPath,vueSymbolLookup:t});return vi({...n,vueFiles:n.context.fileNames.filter(r=>r.endsWith(".vue"))})}function Ri(e,t,n){let r=e.prepare(`
52
53
  SELECT
53
54
  (SELECT COUNT(*) FROM documents) AS documents,
54
55
  (SELECT COUNT(*) FROM global_symbols) AS symbols,
@@ -57,13 +58,13 @@ import{a as R,b as E,f as V}from"./chunk-WIBFXSYB.js";import{a as pe}from"./chun
57
58
  (SELECT COUNT(*) FROM defn_enclosing_ranges) AS ranges,
58
59
  (SELECT MAX(id) FROM chunks) AS maxChunkId,
59
60
  (SELECT MAX(id) FROM global_symbols) AS maxSymbolId
60
- `).get();return{version:2,tsconfig:n,files:P(t),db:r}}function Br(e){let t=nt();return{projectRoot:e.projectRoot,context:ze(e.projectRoot,e.configPath),symbolLookup:He(e.db,e.projectRoot,t),vueSymbolLookup:e.vueSymbolLookup,sourceReader:t}}function Wr(e){let t=[],n=0,r=e.tasks??e.vueFiles.map(i=>({fileName:i,startOffset:0,endOffset:Number.POSITIVE_INFINITY,countFileSkip:!0}));for(let i of r){let o=Ur(e,i);t.push(...o.occurrences),n+=o.skippedReferences}return{occurrences:t,skippedReferences:n}}function Ur(e,t){let n=e.context.language.scripts.get(t.fileName),r=n?.generated?.languagePlugin.typescript?.getServiceScript(n.generated.root)?.code;if(!n||!r)return{occurrences:[],skippedReferences:t.countFileSkip?1:0};let i=e.sourceReader.get(t.fileName);if(!i)return{occurrences:[],skippedReferences:t.countFileSkip?1:0};let o=e.context.language.maps.get(r,n),s=b(e.projectRoot,t.fileName),a=[...Ze(i.text)],u={tokens:a.filter(c=>c.start>=t.startOffset&&c.start<t.endOffset),tokenByStart:new Map(a.map(c=>[c.start,c])),tokenTextCounts:zr(a),processedStarts:new Set};return Jr({...e,fileName:t.fileName,sourceInfo:i,sourceFile:s,map:o,tokenContext:u})}function Jr(e){let t=[],n=0;for(let r of e.tokenContext.tokens){if(e.tokenContext.processedStarts.has(r.start))continue;let i=et(e.map,r.start);if(i===null)continue;let s=(e.context.languageService.getDefinitionAtPosition(e.fileName,i+1)??[]).find(u=>!tt(e.projectRoot,u.fileName));if(!s){n++;continue}let a=Xe(s,e.symbolLookup,e.vueSymbolLookup,e.context,e.projectRoot);if(a===null){n++;continue}ot(t,e.sourceReader,e.sourceInfo,e.sourceFile,r,a),e.tokenContext.processedStarts.add(r.start),qr(t,e,r,i,a)}return{occurrences:t,skippedReferences:n}}function qr(e,t,n,r,i){if(!((t.tokenContext.tokenTextCounts.get(n.text)??0)<=1))for(let o of Hr(t.context.languageService,t.fileName,r+1,t.map,n,t.tokenContext.tokenByStart)){if(t.tokenContext.processedStarts.has(o))continue;let s=t.tokenContext.tokenByStart.get(o);s&&(ot(e,t.sourceReader,t.sourceInfo,t.sourceFile,s,i),t.tokenContext.processedStarts.add(o))}}function ot(e,t,n,r,i,o){let s=t.positionAt(n,i.start);e.push({sourceFile:r,sourceLine:s.line,sourceStartChar:s.character,sourceEndChar:s.character+i.text.length,symbolId:o})}function zr(e){let t=new Map;for(let n of e)t.set(n.text,(t.get(n.text)??0)+1);return t}function Hr(e,t,n,r,i,o){let s=e.getDocumentHighlights?.(t,n,[t])??[],a=[];for(let u of s)if(u.fileName===t)for(let c of u.highlightSpans){let g=Gr(r,c.textSpan.start,o,i.text);g!==null&&a.push(g)}return a}function Gr(e,t,n,r){let i=n.get(t);if(i?.text===r)return i.start;let o=ee(e,t);if(o===null)return null;let s=n.get(o);return s?.text===r?s.start:null}async function os(e){let{projectRoot:t,maxHeapMb:n=8192,onStatus:r=console.log,skipAutoInstall:i=!1}=e,o=ii(e),s=Date.now();re(f(o.outputScip),{recursive:!0}),re(f(o.outputDb),{recursive:!0});let a=e.languages??A(t);if(a.length===0)throw new Error("No supported languages detected in this project. Looked for: tsconfig.json, Cargo.toml, go.mod, pyproject.toml, etc.");r(`Detected languages: ${a.join(", ")}`);let u=Ci(t,a,{pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:e.typescriptProjects,clojureConfigPath:e.clojureConfigPath}),c=await Ri(m(f(o.outputDb),"index.lock"),{projectRoot:t,trigger:e.trigger,onStatus:r}),g=null;try{let l=oi({opts:e,paths:o,languages:a,fingerprint:u,start:s,onStatus:r});if(l)return l;await fi(i,r);let p=ai(o);return g=p.runDir,await ui({opts:e,languages:a,projectRoot:t,paths:o,tempPaths:p,fingerprint:u,start:s,maxHeapMb:n,skipAutoInstall:i,onStatus:r})}catch(l){throw mt(o.metaPath,ue({trigger:e.trigger,result:"failed",start:s,error:l instanceof Error?l.message:String(l)})),l}finally{g&&I(g,{recursive:!0,force:!0}),c()}}function ii(e){let t=e.outputScip??m(e.projectRoot,"index.scip"),n=e.outputDb??m(e.projectRoot,"index.db");return{outputScip:t,outputDb:n,metaPath:m(f(n),"meta.json")}}function oi(e){if(e.opts.skipIfUnchanged===!1||!F(e.paths.outputScip)||!F(e.paths.outputDb)||!Oi(e.paths.metaPath,e.fingerprint))return null;y(S(),{projectRoot:e.opts.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus});let t=Date.now()-e.start,n=ue({trigger:e.opts.trigger,result:"reused",start:e.start,languages:e.languages,skipped:[]});return mt(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:si(e.paths,e.opts.projectRoot,e.languages,e.opts)}}function si(e,t,n,r){let i=se(t,n,r);return n.map(o=>({id:o,language:o,reused:!0,fingerprint:ie(i[o]),outputBytes:ct(ae(e.outputDb,o)),durationMs:0}))}function ai(e){let t=Zr(m(f(e.outputDb),"reindex-"));return{runDir:t,tempOutputScip:m(t,D(e.outputScip)),tempOutputDb:m(t,D(e.outputDb)),tempMetaPath:m(t,D(e.metaPath))}}async function ui(e){let t={...process.env,NODE_OPTIONS:`--max-old-space-size=${e.maxHeapMb}`},{indexedOutputs:n,skippedLanguages:r,reusedLanguages:i,shards:o}=await ci(e,t);i.length>0&&e.onStatus(`Reused ${i.length} cached language shard(s): ${i.join(", ")}`);let s=pi(e,t,n,r),a=s.durationMs;return e.onStatus(`Done in ${(a/1e3).toFixed(1)}s`),{languages:n.map(u=>u.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:a,reused:!1,skipped:r,lastRefresh:s,shards:o}}async function ci(e,t){let n=li({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[l,p]of n)p.reused&&(r.push({language:l,scipPath:p.scipPath}),i.add(l));for(let l of i)e.onStatus(`Reusing cached ${l} SCIP shard (language inputs unchanged).`);let{preparedRuns:o,skippedLanguages:s}=mi({languages:e.languages.filter(l=>!i.has(l)),tempOutputScip:e.tempPaths.tempOutputScip,projectRoot:e.projectRoot,env:t,skipAutoInstall:e.skipAutoInstall,pnpmWorkspaces:e.opts.pnpmWorkspaces,typescriptProjectMode:e.opts.typescriptProjectMode,typescriptProjects:e.opts.typescriptProjects,clojureConfigPath:e.opts.clojureConfigPath,onStatus:e.onStatus}),a=await Ee(o,e.projectRoot,e.onStatus,e.opts.indexerConcurrency),{indexedOutputs:u}=yi(a,s),c=[...r,...u];bi(c,s,e.languages,e.opts.allowPartial,e.onStatus);let g=gi(n,a);return{indexedOutputs:c,skippedLanguages:s,reusedLanguages:[...i],shards:g}}function li(e){let t;try{t=JSON.parse(T(e.paths.metaPath,"utf-8"))}catch{t=null}let n=se(e.projectRoot,e.languages,e),r=new Map;for(let i of e.languages){let o=ae(e.paths.outputDb,i),s=n[i];if(!t){r.set(i,{reused:!1,reason:"no reindex metadata found",fingerprint:s,scipPath:o});continue}if(t.version!==3){r.set(i,{reused:!1,reason:`metadata version ${String(t.version??"unknown")} predates per-language shard caching`,fingerprint:s,scipPath:o});continue}if(!t.languageFingerprints){r.set(i,{reused:!1,reason:"no per-language fingerprints recorded in metadata",fingerprint:s,scipPath:o});continue}let a=t.languageFingerprints[i];if(!a){r.set(i,{reused:!1,reason:"no cached fingerprint for this language",fingerprint:s,scipPath:o});continue}if(!F(o)){r.set(i,{reused:!1,reason:"cached shard file missing on disk",fingerprint:s,scipPath:o});continue}if(x(a)!==x(s)){r.set(i,{reused:!1,reason:"language inputs changed since last index",fingerprint:s,scipPath:o});continue}r.set(i,{reused:!0,fingerprint:s,scipPath:o})}return r}function gi(e,t){let n=[];for(let[r,i]of e)i.reused&&n.push({id:r,language:r,reused:!0,fingerprint:ie(i.fingerprint),outputBytes:ct(i.scipPath),durationMs:0});for(let r of t){let i=e.get(r.language);n.push({id:r.id,language:r.language,reused:!1,missReason:i?.reason??r.skipped?.reason,fingerprint:i?ie(i.fingerprint):"unknown",outputBytes:r.outputBytes??null,durationMs:r.durationMs,command:r.command})}return n}function ie(e){return Xr("sha256").update(x(e)).digest("hex").slice(0,16)}function ct(e){try{return ti(e).size}catch{return null}}function pi(e,t,n,r){di(e.paths.outputDb,n),xi(n,e.tempPaths.tempOutputScip,e.onStatus),Si(e.tempPaths.tempOutputScip,e.tempPaths.tempOutputDb,t,e.onStatus),y(S(),{projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,onStatus:e.onStatus});let i=ue({trigger:e.opts.trigger,result:"rebuilt",start:e.start,languages:n.map(o=>o.language),skipped:[...r]});return ft(e.tempPaths.tempMetaPath,{version:3,status:r.length===0?"complete":"partial",updatedAt:new Date().toISOString(),fingerprint:e.fingerprint,languageFingerprints:se(e.projectRoot,e.languages,{pnpmWorkspaces:e.opts.pnpmWorkspaces,typescriptProjectMode:e.opts.typescriptProjectMode,typescriptProjects:e.opts.typescriptProjects,clojureConfigPath:e.opts.clojureConfigPath}),requestedLanguages:e.languages,indexedLanguages:n.map(o=>o.language),skipped:[...r],lastRefresh:i}),Li({tempOutputScip:e.tempPaths.tempOutputScip,tempOutputDb:e.tempPaths.tempOutputDb,tempMetaPath:e.tempPaths.tempMetaPath,outputScip:e.paths.outputScip,outputDb:e.paths.outputDb,metaPath:e.paths.metaPath}),i}function di(e,t){for(let n of t){let r=ae(e,n.language);re(f(r),{recursive:!0}),n.scipPath!==r&&Qr(n.scipPath,r)}}async function fi(e,t){if(!E()){if(e)throw new Error(`The scip CLI is required but not found on PATH.
61
- Install from: https://github.com/sourcegraph/scip/releases`);if(ri()==="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..."),!V(t))throw new Error(`The scip CLI is required but could not be installed.
62
- Install manually from: https://github.com/sourcegraph/scip/releases`)}}function mi(e){let t=[],n=[],r=e.languages.map((i,o)=>({language:i,scipPath:e.languages.length>1?gt(e.tempOutputScip,i,o):e.tempOutputScip}));for(let{language:i,scipPath:o}of r){let s=hi({...e,language:i,scipPath:o});for(let a of s)"skipped"in a?lt(n,a.skipped):t.push(a.prepared)}return{preparedRuns:t,skippedLanguages:n}}function hi(e){if(e.language!=="typescript"||e.typescriptProjectMode!=="workspace")return[te({...e,id:e.language,label:e.language,outputScipPath:e.scipPath})];let t=Me(e.projectRoot,e.typescriptProjects);return t.length===0?[te({...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)=>te({...e,id:`typescript:${n}`,label:`typescript (${n})`,scipPath:gt(e.tempOutputScip,"typescript-project",r),outputScipPath:e.scipPath,pnpmWorkspaces:!1,projectPath:n})))}function te(e){let t=w(e.language),n=M(t),r=G(t,e.projectRoot);if(!r&&!H(t)){if(e.skipAutoInstall){let a=`${n} not found on PATH (auto-install disabled). ${t.installUrl??""}`.trim();return e.onStatus(`Skipping ${e.language}: ${a}`),{skipped:{language:e.language,reason:a}}}if(e.onStatus(`${n} not found. Attempting auto-install...`),!X(t,e.onStatus)){let a=`${n} could not be auto-installed. ${t.installUrl?`Install manually from ${t.installUrl}`:`Install ${n} and put it on PATH.`}`;return e.onStatus(`Skipping ${e.language}: ${a}`),{skipped:{language:e.language,reason:a}}}}let i=r??v(t);if(!i){let a=`${n} was not found after installation checks.`;return e.onStatus(`Skipping ${e.language}: ${a}`),{skipped:{language:e.language,reason:a}}}let{binary:o,args:s}=t.indexArgs({projectRoot:e.projectRoot,outputPath:e.scipPath,pnpmWorkspaces:e.pnpmWorkspaces,indexerBinary:i,projectPath:e.projectPath,configPath:e.language==="clojure"?e.clojureConfigPath:void 0});return{prepared:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,config:t,resolvedBinary:i,binary:o,args:s,env:K(t,e.env,i)}}}function yi(e,t){let n=new Map;for(let i of e)if(i.skipped)lt(t,i.skipped);else{let o=`${i.language}\0${i.outputScipPath}`,s=n.get(o)??{language:i.language,outputScipPath:i.outputScipPath,scipPaths:[]};s.scipPaths.push(i.scipPath),n.set(o,s)}let r=[];for(let i of n.values())if(i.scipPaths.length>1)L(i.scipPaths,i.outputScipPath),r.push({language:i.language,scipPath:i.outputScipPath});else{let o=i.scipPaths[0];o!==i.outputScipPath&&k(o,i.outputScipPath),r.push({language:i.language,scipPath:i.outputScipPath})}return{indexedOutputs:r}}function lt(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 bi(e,t,n,r,i){if(e.length===0){let o=t.map(s=>` - ${s.language}: ${s.reason}`).join(`
61
+ `).get();return{version:2,tsconfig:n,files:I(t),db:r}}function ji(e){let t=It();return{projectRoot:e.projectRoot,context:ht(e.projectRoot,e.configPath),symbolLookup:yt(e.db,e.projectRoot,t),vueSymbolLookup:e.vueSymbolLookup,sourceReader:t}}function vi(e){let t=[],n=0,r=e.tasks??e.vueFiles.map(i=>({fileName:i,startOffset:0,endOffset:Number.POSITIVE_INFINITY,countFileSkip:!0}));for(let i of r){let o=ki(e,i);t.push(...o.occurrences),n+=o.skippedReferences}return{occurrences:t,skippedReferences:n}}function ki(e,t){let n=e.context.language.scripts.get(t.fileName),r=n?.generated?.languagePlugin.typescript?.getServiceScript(n.generated.root)?.code;if(!n||!r)return{occurrences:[],skippedReferences:t.countFileSkip?1:0};let i=e.sourceReader.get(t.fileName);if(!i)return{occurrences:[],skippedReferences:t.countFileSkip?1:0};let o=e.context.language.maps.get(r,n),s=P(e.projectRoot,t.fileName),a=[...jt(i.text)],u={tokens:a.filter(c=>c.start>=t.startOffset&&c.start<t.endOffset),tokenByStart:new Map(a.map(c=>[c.start,c])),tokenTextCounts:Ci(a),processedStarts:new Set};return Ii({...e,fileName:t.fileName,sourceInfo:i,sourceFile:s,map:o,tokenContext:u})}function Ii(e){let t=[],n=0;for(let r of e.tokenContext.tokens){if(e.tokenContext.processedStarts.has(r.start))continue;let i=vt(e.map,r.start);if(i===null)continue;let s=(e.context.languageService.getDefinitionAtPosition(e.fileName,i+1)??[]).find(u=>!kt(e.projectRoot,u.fileName));if(!s){n++;continue}let a=xt(s,e.symbolLookup,e.vueSymbolLookup,e.context,e.projectRoot);if(a===null){n++;continue}Lt(t,e.sourceReader,e.sourceInfo,e.sourceFile,r,a),e.tokenContext.processedStarts.add(r.start),wi(t,e,r,i,a)}return{occurrences:t,skippedReferences:n}}function wi(e,t,n,r,i){if(!((t.tokenContext.tokenTextCounts.get(n.text)??0)<=1))for(let o of Li(t.context.languageService,t.fileName,r+1,t.map,n,t.tokenContext.tokenByStart)){if(t.tokenContext.processedStarts.has(o))continue;let s=t.tokenContext.tokenByStart.get(o);s&&(Lt(e,t.sourceReader,t.sourceInfo,t.sourceFile,s,i),t.tokenContext.processedStarts.add(o))}}function Lt(e,t,n,r,i,o){let s=t.positionAt(n,i.start);e.push({sourceFile:r,sourceLine:s.line,sourceStartChar:s.character,sourceEndChar:s.character+i.text.length,symbolId:o})}function Ci(e){let t=new Map;for(let n of e)t.set(n.text,(t.get(n.text)??0)+1);return t}function Li(e,t,n,r,i,o){let s=e.getDocumentHighlights?.(t,n,[t])??[],a=[];for(let u of s)if(u.fileName===t)for(let c of u.highlightSpans){let p=Fi(r,c.textSpan.start,o,i.text);p!==null&&a.push(p)}return a}function Fi(e,t,n,r){let i=n.get(t);if(i?.text===r)return i.start;let o=fe(e,t);if(o===null)return null;let s=n.get(o);return s?.text===r?s.start:null}async function ea(e){let{projectRoot:t,maxHeapMb:n=8192,onStatus:r=console.log,skipAutoInstall:i=!1}=e,o=_i(e),s=Date.now();$(m(o.outputScip),{recursive:!0}),$(m(o.outputDb),{recursive:!0});let a=e.languages??G(t);if(a.length===0)throw new Error("No supported languages detected in this project. Looked for: tsconfig.json, Cargo.toml, go.mod, pyproject.toml, etc.");r(`Detected languages: ${a.join(", ")}`);let u=bo(t,a,{pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:e.typescriptProjects,clojureConfigPath:e.clojureConfigPath}),c=await lo(y(m(o.outputDb),"index.lock"),{projectRoot:t,trigger:e.trigger,onStatus:r}),p=null;try{let l=Bi({opts:e,paths:o,languages:a,fingerprint:u,start:s,onStatus:r});if(l)return l;await ro(i,r);let g=Ui(o);return p=g.runDir,await Ji({opts:e,languages:a,projectRoot:t,paths:o,tempPaths:g,fingerprint:u,start:s,maxHeapMb:n,skipAutoInstall:i,onStatus:r})}catch(l){throw Vt(o.metaPath,je({trigger:e.trigger,result:"failed",start:s,error:l instanceof Error?l.message:String(l)})),l}finally{p&&R(p,{recursive:!0,force:!0}),c()}}function _i(e){let t=e.outputScip??y(e.projectRoot,"index.scip"),n=e.outputDb??y(e.projectRoot,"index.db");return{outputScip:t,outputDb:n,metaPath:y(m(n),"meta.json")}}function Bi(e){if(e.opts.skipIfUnchanged===!1||!L(e.paths.outputScip)||!L(e.paths.outputDb)||!xo(e.paths.metaPath,e.fingerprint))return null;x(j(),{projectRoot:e.opts.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus});let t=Date.now()-e.start,n=je({trigger:e.opts.trigger,result:"reused",start:e.start,languages:e.languages,skipped:[]});return Vt(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:Wi(e.paths,e.opts.projectRoot,e.languages,e.opts)}}function Wi(e,t,n,r){let i=xe(t,n,r);return n.map(o=>({id:o,language:o,reused:!0,fingerprint:C(i[o]),outputBytes:_(Pe(e.outputDb,o)),durationMs:0}))}function Ui(e){let t=Oi(y(m(e.outputDb),"reindex-"));return{runDir:t,tempOutputScip:y(t,V(e.outputScip)),tempOutputDb:y(t,V(e.outputDb)),tempMetaPath:y(t,V(e.metaPath))}}async function Ji(e){let t={...process.env,NODE_OPTIONS:`--max-old-space-size=${e.maxHeapMb}`},{indexedOutputs:n,skippedLanguages:r,reusedLanguages:i,shards:o,typescriptProjectShardContext:s}=await Gi(e,t);i.length>0&&e.onStatus(`Reused ${i.length} cached language shard(s): ${i.join(", ")}`);let a=Qi(e,t,n,r,i,s),u=a.durationMs;return e.onStatus(`Done in ${(u/1e3).toFixed(1)}s`),{languages:n.map(c=>c.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:u,reused:!1,skipped:r,lastRefresh:a,shards:o}}async function Gi(e,t){let n=Xi({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[S,ve]of n)ve.reused&&(r.push({language:S,scipPath:ve.scipPath}),i.add(S));for(let S of i)e.onStatus(`Reusing cached ${S} SCIP shard (language inputs unchanged).`);let o=qi(e,n),{preparedRuns:s,skippedLanguages:a,languageOutputScipPaths:u}=io({languages:e.languages.filter(S=>!i.has(S)),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:o?.allProjects,clojureConfigPath:e.opts.clojureConfigPath,onStatus:e.onStatus}),c=o?s.filter(S=>S.language!=="typescript"||o.missedProjectIds.has(S.id)):s,p=await ot(c,e.projectRoot,e.onStatus,e.opts.indexerConcurrency),l=[];if(o){Hi(e.paths.outputDb,p);let S=u.typescript??e.tempPaths.tempOutputScip;l=Ki({outputDb:e.paths.outputDb,tempOutputScip:e.tempPaths.tempOutputScip,outputScipPath:S,reusedProjects:o.reusedProjects})}let g=[...p,...l],{indexedOutputs:h}=so(g,a),f=[...r,...h];ao(f,a,e.languages,e.opts.allowPartial,e.onStatus);let $t=Yi(n,p,o?{outputDb:e.paths.outputDb,classification:o.classification}:void 0);return{indexedOutputs:f,skippedLanguages:a,reusedLanguages:[...i],shards:$t,typescriptProjectShardContext:o?{projects:o.allProjects,fingerprints:o.fingerprints}:void 0}}function qi(e,t){let n=t.get("typescript");if(!n||n.reused||e.opts.typescriptProjectMode!=="workspace")return;let r=ee(e.projectRoot,e.opts.typescriptProjects);if(r.length===0)return;let i=He(e.projectRoot,r),o=Ge(n.fingerprint.files,r),s=qe(r,i),a=ze(r,o,s),u=Re(e.paths.metaPath),p=zi(u,a,f=>L(W(e.paths.outputDb,f))),l=[...p.entries()].filter(([,f])=>f.reused).map(([f])=>f),g=new Set(l),h=new Set(r.filter(f=>!g.has(f)).map(f=>`typescript:${f}`));return{allProjects:r,fingerprints:a,classification:p,reusedProjects:l,missedProjectIds:h}}function zi(e,t,n){let r=new Map;for(let i of Object.keys(t)){let o=t[i];if(!e){r.set(i,{reused:!1,reason:"no reindex metadata found",fingerprint:o});continue}let s=e.typescriptProjectShards?.[i];if(!s){r.set(i,{reused:!1,reason:"no cached fingerprint for this project",fingerprint:o});continue}if(!n(i)){r.set(i,{reused:!1,reason:"cached shard file missing on disk",fingerprint:o});continue}if(b(s)!==b(o)){r.set(i,{reused:!1,reason:"project inputs changed since last index",fingerprint:o});continue}r.set(i,{reused:!0,fingerprint:o})}return r}function Hi(e,t){for(let n of t){if(n.skipped||!n.id.startsWith("typescript:"))continue;let r=n.id.slice(11),i=W(e,r);$(m(i),{recursive:!0}),Se(n.scipPath,i)}}function Ki(e){return e.reusedProjects.map((t,n)=>{let r=W(e.outputDb,t),i=be(e.tempOutputScip,"typescript-project-cached",n);return Se(r,i),{id:`typescript:${t}`,language:"typescript",label:`typescript (${t})`,scipPath:i,outputScipPath:e.outputScipPath,durationMs:0,command:"cached",outputBytes:_(i)??void 0}})}function Xi(e){let t=Re(e.paths.metaPath),n=xe(e.projectRoot,e.languages,e),r=new Map;for(let i of e.languages){let o=Pe(e.paths.outputDb,i),s=n[i];if(!t){r.set(i,{reused:!1,reason:"no reindex metadata found",fingerprint:s,scipPath:o});continue}if(t.version!==3){r.set(i,{reused:!1,reason:`metadata version ${String(t.version??"unknown")} predates per-language shard caching`,fingerprint:s,scipPath:o});continue}if(!t.languageFingerprints){r.set(i,{reused:!1,reason:"no per-language fingerprints recorded in metadata",fingerprint:s,scipPath:o});continue}let a=t.languageFingerprints[i];if(!a){r.set(i,{reused:!1,reason:"no cached fingerprint for this language",fingerprint:s,scipPath:o});continue}if(!L(o)){r.set(i,{reused:!1,reason:"cached shard file missing on disk",fingerprint:s,scipPath:o});continue}if(b(a)!==b(s)){r.set(i,{reused:!1,reason:"language inputs changed since last index",fingerprint:s,scipPath:o});continue}r.set(i,{reused:!0,fingerprint:s,scipPath:o})}return r}function Yi(e,t,n){let r=[];for(let[i,o]of e)o.reused&&r.push({id:i,language:i,reused:!0,fingerprint:C(o.fingerprint),outputBytes:_(o.scipPath),durationMs:0});for(let i of t){let o=e.get(i.language),s=n&&i.id.startsWith("typescript:")?i.id.slice(11):null,a=s?n.classification.get(s):void 0;r.push({id:i.id,language:i.language,reused:!1,missReason:a?.reason??o?.reason??i.skipped?.reason,fingerprint:a?C(a.fingerprint):o?C(o.fingerprint):"unknown",outputBytes:i.outputBytes??null,durationMs:i.durationMs,command:i.command})}if(n)for(let[i,o]of n.classification)o.reused&&r.push({id:`typescript:${i}`,language:"typescript",reused:!0,fingerprint:C(o.fingerprint),outputBytes:_(W(n.outputDb,i)),durationMs:0});return r}function C(e){return Mi("sha256").update(b(e)).digest("hex").slice(0,16)}function _(e){try{return Ni(e).size}catch{return null}}function Qi(e,t,n,r,i,o){no(e.paths.outputDb,n),uo(n,e.tempPaths.tempOutputScip,e.onStatus),co(e.tempPaths.tempOutputScip,e.tempPaths.tempOutputDb,t,e.onStatus),x(j(),{projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,onStatus:e.onStatus});let s=Zi({mode:e.opts.typescriptProjectMode,skippedLanguages:r,reusedLanguages:i,context:o,metaPath:e.paths.metaPath});eo(e.paths.outputDb,s.pruneProjects);let a=je({trigger:e.opts.trigger,result:"rebuilt",start:e.start,languages:n.map(u=>u.language),skipped:[...r]});return Nt(e.tempPaths.tempMetaPath,{version:3,status:r.length===0?"complete":"partial",updatedAt:new Date().toISOString(),fingerprint:e.fingerprint,languageFingerprints:xe(e.projectRoot,e.languages,{pnpmWorkspaces:e.opts.pnpmWorkspaces,typescriptProjectMode:e.opts.typescriptProjectMode,typescriptProjects:e.opts.typescriptProjects,clojureConfigPath:e.opts.clojureConfigPath}),typescriptProjectShards:s.field,requestedLanguages:e.languages,indexedLanguages:n.map(u=>u.language),skipped:[...r],lastRefresh:a}),So({tempOutputScip:e.tempPaths.tempOutputScip,tempOutputDb:e.tempPaths.tempOutputDb,tempMetaPath:e.tempPaths.tempMetaPath,outputScip:e.paths.outputScip,outputDb:e.paths.outputDb,metaPath:e.paths.metaPath}),a}function Zi(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=Re(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 eo(e,t){let n=At(e);if(t===null){R(n,{recursive:!0,force:!0});return}let r;try{r=Ai(n)}catch{return}for(let i of to(r,t))R(y(n,i),{force:!0})}function to(e,t){let n=new Set(t.map(r=>`${Q(r)}.scip`));return e.filter(r=>!n.has(r))}function no(e,t){for(let n of t){let r=Pe(e,n.language);$(m(r),{recursive:!0}),n.scipPath!==r&&Se(n.scipPath,r)}}async function ro(e,t){if(!U()){if(e)throw new Error(`The scip CLI is required but not found on PATH.
62
+ Install from: https://github.com/sourcegraph/scip/releases`);if($i()==="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..."),!J(t))throw new Error(`The scip CLI is required but could not be installed.
63
+ Install manually from: https://github.com/sourcegraph/scip/releases`)}}function io(e){let t=[],n=[],r=e.languages.map((o,s)=>({language:o,scipPath:e.languages.length>1?be(e.tempOutputScip,o,s):e.tempOutputScip})),i=Object.fromEntries(r.map(({language:o,scipPath:s})=>[o,s]));for(let{language:o,scipPath:s}of r){let a=oo({...e,language:o,scipPath:s});for(let u of a)"skipped"in u?Dt(n,u.skipped):t.push(u.prepared)}return{preparedRuns:t,skippedLanguages:n,languageOutputScipPaths:i}}function oo(e){if(e.language!=="typescript"||e.typescriptProjectMode!=="workspace")return[me({...e,id:e.language,label:e.language,outputScipPath:e.scipPath})];let t=e.preDiscoveredTypeScriptProjects??ee(e.projectRoot,e.typescriptProjects);return t.length===0?[me({...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)=>me({...e,id:`typescript:${n}`,label:`typescript (${n})`,scipPath:be(e.tempOutputScip,"typescript-project",r),outputScipPath:e.scipPath,pnpmWorkspaces:!1,projectPath:n})))}function me(e){let t=M(e.language),n=N(t),r=ue(t,e.projectRoot);if(!r&&!ae(t)){if(e.skipAutoInstall){let a=`${n} not found on PATH (auto-install disabled). ${t.installUrl??""}`.trim();return e.onStatus(`Skipping ${e.language}: ${a}`),{skipped:{language:e.language,reason:a}}}if(e.onStatus(`${n} not found. Attempting auto-install...`),!le(t,e.onStatus)){let a=`${n} could not be auto-installed. ${t.installUrl?`Install manually from ${t.installUrl}`:`Install ${n} and put it on PATH.`}`;return e.onStatus(`Skipping ${e.language}: ${a}`),{skipped:{language:e.language,reason:a}}}}let i=r??w(t);if(!i){let a=`${n} was not found after installation checks.`;return e.onStatus(`Skipping ${e.language}: ${a}`),{skipped:{language:e.language,reason:a}}}let{binary:o,args:s}=t.indexArgs({projectRoot:e.projectRoot,outputPath:e.scipPath,pnpmWorkspaces:e.pnpmWorkspaces,indexerBinary:i,projectPath:e.projectPath,configPath:e.language==="clojure"?e.clojureConfigPath:void 0});return{prepared:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,config:t,resolvedBinary:i,binary:o,args:s,env:ce(t,e.env,i)}}}function so(e,t){let n=new Map;for(let i of e)if(i.skipped)Dt(t,i.skipped);else{let o=`${i.language}\0${i.outputScipPath}`,s=n.get(o)??{language:i.language,outputScipPath:i.outputScipPath,scipPaths:[]};s.scipPaths.push(i.scipPath),n.set(o,s)}let r=[];for(let i of n.values())if(i.scipPaths.length>1)D(i.scipPaths,i.outputScipPath),r.push({language:i.language,scipPath:i.outputScipPath});else{let o=i.scipPaths[0];o!==i.outputScipPath&&F(o,i.outputScipPath),r.push({language:i.language,scipPath:i.outputScipPath})}return{indexedOutputs:r}}function Dt(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 ao(e,t,n,r,i){if(e.length===0){let o=t.map(s=>` - ${s.language}: ${s.reason}`).join(`
63
64
  `);throw new Error(`No language indexers ran successfully. Install at least one indexer for the languages in this project.
64
65
  `+o)}if(t.length!==0&&(i(`Indexed ${e.length} language output(s); skipped or incomplete: ${t.map(o=>o.language).join(", ")}.`),!r))throw new Error(`Failed to index all required languages; preserving the previous index. Pass --allow-partial to intentionally write an incomplete index.
65
66
  `+t.map(o=>` - ${o.language}: ${o.reason}`).join(`
66
- `))}function xi(e,t,n){e.length>1?(n(`Merging ${e.length} language indexes...`),L(e.map(r=>r.scipPath),t)):e[0].scipPath!==t&&k(e[0].scipPath,t)}function Si(e,t,n,r){if(r("Converting to SQLite..."),!F(e))throw new Error(`SCIP index not found at ${e} after indexing`);try{let i=Oe(e);i.removedDefinitionOccurrences>0&&r(`Sanitized ${i.removedDefinitionOccurrences} invalid definition occurrences across ${i.touchedDocuments} documents before SQLite conversion.`);let o=E();if(!o)throw new Error("scip CLI is not available");Kr(o,["expt-convert","--output",t,e],{env:n,stdio:"pipe",maxBuffer:50*1024*1024})}catch(i){let o=i instanceof Error?i.message:String(i);throw new Error(`Failed to convert SCIP index to SQLite: ${o}`,{cause:i})}}function gt(e,t,n){let r=ni(e)||".scip",i=D(e,r);return m(f(e),`${i}.${n+1}.${t}${r}`)}async function Ri(e,t){for(let n=0;n<2;n++){let r=Pi(e,t);if(r)return r;let i=vi(e);if(i&&ki(t.trigger,i)){if(t.onStatus(`Manual reindex preempting watcher refresh started at ${i.startedAt}.`),!await ji(i.pid))throw new Error(`Could not confirm the watcher's in-progress reindex (pid ${i.pid}) terminated for ${f(e)}; refusing to steal an active lock.`);I(e,{force:!0});continue}if(i&&!oe(i.pid)){I(e,{force:!0});continue}throw new Error(`Another scip-query reindex is already running for ${f(e)}.`)}throw new Error(`Could not acquire scip-query reindex lock for ${f(e)}.`)}function Pi(e,t){let n;try{n=ei(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 ut(n,JSON.stringify(r)+`
67
- `),()=>{try{Yr(n)}finally{I(e,{force:!0})}}}function vi(e){try{let t=JSON.parse(T(e,"utf-8"));return typeof t.pid!="number"||!Number.isInteger(t.pid)||t.pid<=0?null:{version:1,pid:t.pid,projectRoot:typeof t.projectRoot=="string"?t.projectRoot:f(e),startedAt:typeof t.startedAt=="string"?t.startedAt:"unknown",trigger:t.trigger}}catch{return null}}function ki(e,t){return e?.kind==="manual-cli"&&Ii(t?.trigger)}function Ii(e){return e?.kind==="watch-source"||e?.kind==="watch-git-head"||e?.kind==="watch-git-index"||e?.kind==="watch-git-state"}async function ji(e){return st(e,"SIGTERM"),await at(e,2e3)?!0:(st(e,"SIGKILL"),at(e,1e3))}function st(e,t){try{process.kill(-e,t)}catch{try{process.kill(e,t)}catch{}}}async function at(e,t){let n=Date.now()+t;for(;Date.now()<n;){if(!oe(e))return!0;await wi(50)}return!oe(e)}function oe(e){try{return process.kill(e,0),!0}catch{return!1}}function wi(e){return new Promise(t=>setTimeout(t,e))}function Li(e){ne(e.tempOutputScip,e.outputScip),ne(e.tempOutputDb,e.outputDb),ne(e.tempMetaPath,e.metaPath)}function ne(e,t){I(`${t}.tmp-replace`,{force:!0}),k(e,`${t}.tmp-replace`),k(`${t}.tmp-replace`,t)}function Ci(e,t,n){return{version:2,languages:[...t].sort(),pnpmWorkspaces:dt(n),typescriptProjectMode:n.typescriptProjectMode??"single",typescriptProjects:_(n.typescriptProjects),clojureConfigPath:pt(n.clojureConfigPath),files:P(e)}}function se(e,t,n){return Object.fromEntries(t.map(r=>{let i=w(r).markerFiles,o=r==="typescript"?{typescriptProjectMode:n.typescriptProjectMode??"single",typescriptProjects:_(n.typescriptProjects)}:{typescriptProjectMode:"single",typescriptProjects:[]},s=r==="clojure"?pt(n.clojureConfigPath):void 0;return[r,{version:2,languages:[r],pnpmWorkspaces:r==="typescript"&&dt(n),...o,clojureConfigPath:s,files:P(e,{language:r,markerFiles:i})}]}))}function pt(e){return e?.trim()||void 0}function dt(e){return e.typescriptProjectMode!=="workspace"&&e.pnpmWorkspaces===!0}function ae(e,t){return m(f(e),"language-indexes",`${t}.scip`)}function Oi(e,t){try{let n=JSON.parse(T(e,"utf-8"));return(n.version===2||n.version===3)&&n.status==="complete"&&x(n.fingerprint)===x(t)&&x([...n.indexedLanguages??[]].sort())===x(t.languages)}catch{return!1}}function ft(e,t){let n=`${e}.tmp-${process.pid}-${Date.now()}`;ut(n,`${JSON.stringify(t,null,2)}
68
- `),k(n,e)}function mt(e,t){try{let n=JSON.parse(T(e,"utf-8"));if(n.version!==2&&n.version!==3)return;ft(e,{...n,lastRefresh:t})}catch{}}function ue(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 x(e){return JSON.stringify(e)}export{Re as INDEXER_CONFIGS,fe as augmentAuxiliaryDocuments,Vr as augmentVueResolvedReferences,S as auxiliaryDocumentsAugmentationStage,M as describeIndexerBinary,A as detectLanguages,w as getIndexerConfig,K as getIndexerExecutionEnv,R as isBinaryAvailable,H as isIndexerInstalled,L as mergeScipFiles,Pe as mergeScipIndexes,os as reindex,v as resolveIndexerBinary,G as resolveProjectLocalIndexerBinary,y as runPostIndexAugmentation,X as tryInstallIndexer,V as tryInstallScipCli,it as vueResolvedReferencesAugmentationStage};
67
+ `))}function uo(e,t,n){e.length>1?(n(`Merging ${e.length} language indexes...`),D(e.map(r=>r.scipPath),t)):e[0].scipPath!==t&&F(e[0].scipPath,t)}function co(e,t,n,r){if(r("Converting to SQLite..."),!L(e))throw new Error(`SCIP index not found at ${e} after indexing`);try{let i=Ze(e);i.removedDefinitionOccurrences>0&&r(`Sanitized ${i.removedDefinitionOccurrences} invalid definition occurrences across ${i.touchedDocuments} documents before SQLite conversion.`);let o=U();if(!o)throw new Error("scip CLI is not available");Ti(o,["expt-convert","--output",t,e],{env:n,stdio:"pipe",maxBuffer:50*1024*1024})}catch(i){let o=i instanceof Error?i.message:String(i);throw new Error(`Failed to convert SCIP index to SQLite: ${o}`,{cause:i})}}function be(e,t,n){let r=Vi(e)||".scip",i=V(e,r);return y(m(e),`${i}.${n+1}.${t}${r}`)}async function lo(e,t){for(let n=0;n<2;n++){let r=po(e,t);if(r)return r;let i=go(e);if(i&&fo(t.trigger,i)){if(t.onStatus(`Manual reindex preempting watcher refresh started at ${i.startedAt}.`),!await ho(i.pid))throw new Error(`Could not confirm the watcher's in-progress reindex (pid ${i.pid}) terminated for ${m(e)}; refusing to steal an active lock.`);R(e,{force:!0});continue}if(i&&!ye(i.pid)){R(e,{force:!0});continue}throw new Error(`Another scip-query reindex is already running for ${m(e)}.`)}throw new Error(`Could not acquire scip-query reindex lock for ${m(e)}.`)}function po(e,t){let n;try{n=Ei(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 Mt(n,JSON.stringify(r)+`
68
+ `),()=>{try{Di(n)}finally{R(e,{force:!0})}}}function go(e){try{let t=JSON.parse(B(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:m(e),startedAt:typeof t.startedAt=="string"?t.startedAt:"unknown",trigger:t.trigger}}catch{return null}}function fo(e,t){return e?.kind==="manual-cli"&&mo(t?.trigger)}function mo(e){return e?.kind==="watch-source"||e?.kind==="watch-git-head"||e?.kind==="watch-git-index"||e?.kind==="watch-git-state"}async function ho(e){return Ft(e,"SIGTERM"),await Tt(e,2e3)?!0:(Ft(e,"SIGKILL"),Tt(e,1e3))}function Ft(e,t){try{process.kill(-e,t)}catch{try{process.kill(e,t)}catch{}}}async function Tt(e,t){let n=Date.now()+t;for(;Date.now()<n;){if(!ye(e))return!0;await yo(50)}return!ye(e)}function ye(e){try{return process.kill(e,0),!0}catch{return!1}}function yo(e){return new Promise(t=>setTimeout(t,e))}function So(e){he(e.tempOutputScip,e.outputScip),he(e.tempOutputDb,e.outputDb),he(e.tempMetaPath,e.metaPath)}function he(e,t){R(`${t}.tmp-replace`,{force:!0}),F(e,`${t}.tmp-replace`),F(`${t}.tmp-replace`,t)}function bo(e,t,n){return{version:2,languages:[...t].sort(),pnpmWorkspaces:Et(n),typescriptProjectMode:n.typescriptProjectMode??"single",typescriptProjects:H(n.typescriptProjects),clojureConfigPath:Ot(n.clojureConfigPath),files:I(e)}}function xe(e,t,n){return Object.fromEntries(t.map(r=>{let i=M(r).markerFiles,o=r==="typescript"?{typescriptProjectMode:n.typescriptProjectMode??"single",typescriptProjects:H(n.typescriptProjects)}:{typescriptProjectMode:"single",typescriptProjects:[]},s=r==="clojure"?Ot(n.clojureConfigPath):void 0;return[r,{version:2,languages:[r],pnpmWorkspaces:r==="typescript"&&Et(n),...o,clojureConfigPath:s,files:I(e,{language:r,markerFiles:i})}]}))}function Ot(e){return e?.trim()||void 0}function Et(e){return e.typescriptProjectMode!=="workspace"&&e.pnpmWorkspaces===!0}function Pe(e,t){return y(m(e),"language-indexes",`${t}.scip`)}function At(e){return y(m(e),"language-indexes","typescript-projects")}function W(e,t){return y(At(e),`${Q(t)}.scip`)}function Re(e){try{return JSON.parse(B(e,"utf-8"))}catch{return null}}function xo(e,t){try{let n=JSON.parse(B(e,"utf-8"));return(n.version===2||n.version===3)&&n.status==="complete"&&b(n.fingerprint)===b(t)&&b([...n.indexedLanguages??[]].sort())===b(t.languages)}catch{return!1}}function Nt(e,t){let n=`${e}.tmp-${process.pid}-${Date.now()}`;Mt(n,`${JSON.stringify(t,null,2)}
69
+ `),F(n,e)}function Vt(e,t){try{let n=JSON.parse(B(e,"utf-8"));if(n.version!==2&&n.version!==3)return;Nt(e,{...n,lastRefresh:t})}catch{}}function je(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 b(e){return JSON.stringify(e)}export{Ae as INDEXER_CONFIGS,Le as augmentAuxiliaryDocuments,Si as augmentVueResolvedReferences,j as auxiliaryDocumentsAugmentationStage,N as describeIndexerBinary,G as detectLanguages,M as getIndexerConfig,ce as getIndexerExecutionEnv,k as isBinaryAvailable,ae as isIndexerInstalled,D as mergeScipFiles,Ne as mergeScipIndexes,ea as reindex,w as resolveIndexerBinary,ue as resolveProjectLocalIndexerBinary,x as runPostIndexAugmentation,le as tryInstallIndexer,J as tryInstallScipCli,Ct as vueResolvedReferencesAugmentationStage};
69
70
  //# sourceMappingURL=reindex.js.map
package/dist/runtime.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { P as ProjectConfig, a as SupportedLanguage } from './config-types-BrHl3Bge.js';
2
- import { W as WatcherStatus } from './scip-cli-C7cg4ZHR.js';
3
- export { g as getScipVersion, i as isScipInstalled, p as printScipInstallInstructions } from './scip-cli-C7cg4ZHR.js';
1
+ import { P as ProjectConfig, a as SupportedLanguage } from './config-types-aCgyLrvE.js';
2
+ import { W as WatcherStatus } from './scip-cli-DeAbuJ2b.js';
3
+ export { g as getScipVersion, i as isScipInstalled, p as printScipInstallInstructions } from './scip-cli-DeAbuJ2b.js';
4
4
 
5
5
  /**
6
6
  * Load project config from .scipquery.json in the project root.
package/dist/runtime.js CHANGED
@@ -1,3 +1,3 @@
1
- import{c as $,d as M,e as A}from"./chunk-WIBFXSYB.js";import{a as k}from"./chunk-YZXV3CU3.js";import{readFileSync as O,writeFileSync as D,existsSync as P,mkdirSync as N}from"fs";import{isAbsolute as de,join as u,relative as he,resolve as R}from"path";import{createHash as G}from"crypto";import{homedir as F}from"os";var f=".scipquery.json",W={enabled:!1,debounceMs:3e4,cooldownMs:6e4,gitPollMs:2e3,autoRefresh:!0,ignore:[]},U=["typescript","javascript","java","scala","kotlin","rust","python","ruby","go","cpp","c","csharp","vb","dart","php","clojure"];var me=new Set(U);function y(r){let e=u(r,f);if(!P(e))return{};try{let t=O(e,"utf-8");return JSON.parse(t)}catch(t){let i=t instanceof Error?t.message:String(t);throw t instanceof SyntaxError?new Error(`invalid ${f} at ${e}: ${i}`,{cause:t}):new Error(`unable to read ${f} at ${e}: ${i}`,{cause:t})}}function E(r){return{...W,...r.watch}}function L(r,e){let t=process.env.SCIP_QUERY_CACHE_DIR;if(t)return m(t);if(e?.dbPath)return m(R(r,e.dbPath));let s=process.env.XDG_CACHE_HOME||u(F(),".cache"),o=G("sha256").update(R(r)).digest("hex").slice(0,12),n=u(s,"scip-query","projects",o);return m(n)}function S(r,e){let t=L(r,e);return{cacheDir:t,dbPath:u(t,"index.db"),indexPath:u(t,"index.scip"),metaPath:u(t,"meta.json")}}function q(r,e){let t=u(r,f);return P(t)||D(t,JSON.stringify({languages:e,watch:{enabled:!1,debounceMs:3e4,cooldownMs:6e4,gitPollMs:2e3,autoRefresh:!0}},null,2)+`
2
- `),t}function m(r){return N(r,{recursive:!0}),r}import{execFileSync as Y,fork as K}from"child_process";import{statSync as H,watch as X}from"fs";import{join as B,relative as V}from"path";import z from"ignore";var C=class{projectRoot;config;watchConfig;languages;pnpmWorkspaces;typescriptProjectMode;typescriptProjects;clojureConfigPath;indexerConcurrency;onStatus;onReindexComplete;onError;status={state:"idle"};debounceTimer=null;cooldownTimer=null;dirty=!1;changedFiles=0;pendingTrigger=null;reindexInFlight=!1;lastReindexEnd=0;fsWatchers=[];gitPollTimer=null;lastGitState=null;gitignoreFilter;extraIgnore;stopped=!1;constructor(e){this.projectRoot=e.projectRoot,this.config=e.config,this.watchConfig=E(e.config),this.languages=e.languages,this.pnpmWorkspaces=e.config.indexer?.typescript?.pnpmWorkspaces??!1,this.typescriptProjectMode=e.config.indexer?.typescript?.projectMode,this.typescriptProjects=e.config.indexer?.typescript?.projects,this.clojureConfigPath=e.config.indexer?.clojure?.configPath,this.indexerConcurrency=e.config.indexerConcurrency,this.onStatus=e.onStatus??(()=>{}),this.onReindexComplete=e.onReindexComplete??(()=>{}),this.onError=e.onError??(t=>console.error(t.message)),this.gitignoreFilter=k(e.projectRoot),this.extraIgnore=z(),this.watchConfig.ignore.length>0&&this.extraIgnore.add(this.watchConfig.ignore)}start(){this.stopped=!1,this.setStatus({state:"idle"}),this.startGitStatePolling();try{let e=X(this.projectRoot,{recursive:!0},(t,i)=>{i&&!this.stopped&&this.handleFileChange(i)});this.fsWatchers.push(e)}catch{this.onError(new Error("Failed to start file watcher. On Linux, you may need to increase inotify limits: sysctl -w fs.inotify.max_user_watches=524288"))}}stop(){this.stopped=!0;for(let e of this.fsWatchers)e.close();this.fsWatchers=[],this.clearDebounceTimer(),this.clearCooldownTimer(),this.clearGitPollTimer(),this.setStatus({state:"idle"})}handleFileChange(e){let t=V(this.projectRoot,B(this.projectRoot,e));t===".git"||t.startsWith(".git/")||this.gitignoreFilter.isIgnored(t)||this.extraIgnore.ignores(t)||e.endsWith("index.db")||e.endsWith("index.scip")||e.endsWith("index.db.tmp")||this.scheduleReindex({kind:"watch-source",detail:t})}scheduleReindex(e){if(this.pendingTrigger=J(this.pendingTrigger,e),this.changedFiles++,this.reindexInFlight){this.dirty=!0,this.setStatus({state:"indexing",startedAt:this.status.startedAt});return}if(this.status.state==="cooldown"){this.dirty=!0,this.setStatus({state:"cooldown",until:this.status.until,dirty:!0});return}this.clearDebounceTimer();let t=Date.now()+this.watchConfig.debounceMs;this.setStatus({state:"waiting",changedFiles:this.changedFiles,reindexAt:t}),this.debounceTimer=setTimeout(()=>{this.debounceTimer=null,this.triggerReindex()},this.watchConfig.debounceMs)}triggerReindex(){if(this.reindexInFlight||this.stopped)return;let e=Date.now()-this.lastReindexEnd;if(this.lastReindexEnd>0&&e<this.watchConfig.cooldownMs){let s=this.watchConfig.cooldownMs-e;this.dirty=!0;let o=Date.now()+s;this.setStatus({state:"cooldown",until:o,dirty:!0}),this.cooldownTimer=setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped&&(this.dirty=!1,this.triggerReindex())},s);return}this.reindexInFlight=!0,this.dirty=!1,this.changedFiles=0;let t=this.pendingTrigger??{kind:"watch-source"};this.pendingTrigger=null;let i=Date.now();this.setStatus({state:"indexing",startedAt:i}),this.runReindex(t).then(s=>{if(this.reindexInFlight=!1,this.lastReindexEnd=Date.now(),this.onReindexComplete(s),this.dirty&&!this.stopped){let o=Date.now()+this.watchConfig.cooldownMs;this.setStatus({state:"cooldown",until:o,dirty:!0}),this.cooldownTimer=setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped?(this.dirty=!1,this.triggerReindex()):this.setStatus({state:"idle"})},this.watchConfig.cooldownMs)}else this.setStatus({state:"idle"})}).catch(s=>{this.reindexInFlight=!1,this.lastReindexEnd=Date.now(),this.onError(s instanceof Error?s:new Error(String(s))),this.setStatus({state:"idle"})})}runReindex(e){return new Promise((t,i)=>{let s=Date.now(),o=y(this.projectRoot),n=Object.keys(o).length>0?o:this.config,c=S(this.projectRoot,n),a=n.indexer?.typescript,l=n.indexer?.clojure,d=K(new URL("./reindex-worker.js",import.meta.url).pathname,[],{detached:!0,env:{...process.env,SCIP_REINDEX_PROJECT_ROOT:this.projectRoot,SCIP_REINDEX_OUTPUT_SCIP:c.indexPath,SCIP_REINDEX_OUTPUT_DB:c.dbPath,SCIP_REINDEX_LANGUAGES:(n.languages??this.languages)?.join(",")??"",SCIP_REINDEX_INDEXER_CONCURRENCY:String(n.indexerConcurrency??this.indexerConcurrency??""),SCIP_REINDEX_PNPM_WORKSPACES:a?.pnpmWorkspaces??this.pnpmWorkspaces?"1":"",SCIP_REINDEX_TYPESCRIPT_CONFIG:JSON.stringify({projectMode:a?.projectMode??this.typescriptProjectMode,projects:a?.projects??this.typescriptProjects??[]}),SCIP_REINDEX_CLOJURE_CONFIG_PATH:l?.configPath??this.clojureConfigPath??"",SCIP_REINDEX_TRIGGER_KIND:e.kind,SCIP_REINDEX_TRIGGER_DETAIL:e.detail??""},stdio:"pipe"});d.on("exit",p=>{p===0?t(Date.now()-s):i(new Error(`Reindex worker exited with code ${p}`))}),d.on("error",i)})}setStatus(e){this.status=e,this.onStatus(e)}clearDebounceTimer(){this.debounceTimer&&(clearTimeout(this.debounceTimer),this.debounceTimer=null)}clearCooldownTimer(){this.cooldownTimer&&(clearTimeout(this.cooldownTimer),this.cooldownTimer=null)}startGitStatePolling(){this.lastGitState=this.readGitState(),this.lastGitState&&(this.gitPollTimer=setInterval(()=>this.pollGitState(),this.watchConfig.gitPollMs),this.gitPollTimer.unref?.())}pollGitState(){let e=this.lastGitState,t=this.readGitState();if(!e||!t||this.stopped){this.lastGitState=t;return}this.lastGitState=t;let i=e.head!==t.head,s=e.indexPath!==t.indexPath||e.indexMtimeMs!==t.indexMtimeMs||e.indexSize!==t.indexSize;i&&s?this.scheduleReindex({kind:"watch-git-state",detail:"HEAD and index changed"}):i?this.scheduleReindex({kind:"watch-git-head",detail:"HEAD changed"}):s&&this.scheduleReindex({kind:"watch-git-index",detail:t.indexPath??"index changed"})}readGitState(){let e=j(this.projectRoot,["rev-parse","--git-path","index"]);if(!e)return null;let t={head:j(this.projectRoot,["rev-parse","--verify","HEAD"]),indexPath:e};try{let i=H(e);t.indexMtimeMs=i.mtimeMs,t.indexSize=i.size}catch{t.indexMtimeMs=void 0,t.indexSize=void 0}return t}clearGitPollTimer(){this.gitPollTimer&&(clearInterval(this.gitPollTimer),this.gitPollTimer=null)}};function j(r,e){try{return Y("git",["-C",r,...e],{encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).trim()}catch{return}}function J(r,e){return r?r.kind===e.kind?r.detail===e.detail?r:{kind:r.kind,detail:"multiple changes"}:{kind:"watch-git-state",detail:`${r.kind}, ${e.kind}`}:e}import{existsSync as v,mkdirSync as Q,symlinkSync as Z,readlinkSync as b,unlinkSync as T,readdirSync as ee}from"fs";import{join as h,dirname as w,resolve as g,relative as te,isAbsolute as re}from"path";import{homedir as x,platform as ie}from"os";import{fileURLToPath as se}from"url";var ne=ie()==="win32",_=["_shared","scip-query","scip-setup","scip-calibrate","scip-cleanup-audit","scip-cleanup-improve","scip-integrity-audit","scip-twin-drift","scip-claim-audit","scip-probe-reachability","scip-hyper-optimization","scip-api-impact","scip-concrete-plan","scip-conductor","scip-debug","scip-explore","scip-triage-issue","scip-diagram","scip-doc-reconcile","scip-directory-architecture","scip-maintainability","scip-react-maintainability","scip-vue-maintainability","scip-verify","scip-language-playbook","scip-tla-model-system"];function oe(r={}){let e=r.quiet?()=>{}:console.log,t=se(import.meta.url),i=g(w(t),"..","skills"),s=[h(x(),".claude","skills"),h(x(),".codex","skills"),h(x(),".agents","skills")],o={installed:[],skipped:[],alreadyLinked:[],pruned:[]};for(let n of s){let c=w(n);if(!v(c))continue;Q(n,{recursive:!0});let a=ce(n);ae(n,i,a,o,e);for(let l of _){let d=h(i,l),p=h(n,l);if(!v(d)){o.skipped.push(`${a}/${l}`);continue}if(v(p)){try{let I=b(p);if(g(I)===g(d)){o.alreadyLinked.push(`${a}/${l}`),e(` ok: ${l} \u2192 ${a} (already linked)`);continue}}catch{o.skipped.push(`${a}/${l}`),e(` skip: ${l} \u2192 ${a} (exists, not a symlink)`);continue}T(p)}Z(d,p,ne?"junction":"dir"),o.installed.push(`${a}/${l}`),e(` done: ${l} \u2192 ${a}`)}}return o}function ae(r,e,t,i,s){let o=new Set(_);for(let n of ee(r)){if(o.has(n))continue;let c=h(r,n),a;try{a=g(w(c),b(c))}catch{continue}le(a,e)&&(T(c),i.pruned.push(`${t}/${n}`),s(` prune: ${n} \u2192 ${t} (removed stale scip-query skill link)`))}}function le(r,e){let t=te(g(e),g(r));return t===""||!t.startsWith("..")&&!re(t)}function ce(r){return r.includes(".codex")?"Codex":r.includes(".agents")?"Agents":"Claude"}export{C as Watcher,M as getScipVersion,q as initProjectConfig,oe as installSkills,$ as isScipInstalled,y as loadProjectConfig,A as printScipInstallInstructions,S as resolveIndexStoragePaths};
1
+ import{c as $,d as M,e as A}from"./chunk-WIBFXSYB.js";import{a as R}from"./chunk-YZXV3CU3.js";import{readFileSync as O,writeFileSync as D,existsSync as P,mkdirSync as N}from"fs";import{isAbsolute as ue,join as d,relative as he,resolve as k}from"path";import{createHash as G}from"crypto";import{homedir as F}from"os";var f=".scipquery.json",W={enabled:!1,debounceMs:3e4,cooldownMs:6e4,gitPollMs:2e3,autoRefresh:!0,ignore:[]},U=["typescript","javascript","java","scala","kotlin","rust","python","ruby","go","cpp","c","csharp","vb","dart","php","clojure"];var me=new Set(U);function y(r){let e=d(r,f);if(!P(e))return{};try{let t=O(e,"utf-8");return JSON.parse(t)}catch(t){let i=t instanceof Error?t.message:String(t);throw t instanceof SyntaxError?new Error(`invalid ${f} at ${e}: ${i}`,{cause:t}):new Error(`unable to read ${f} at ${e}: ${i}`,{cause:t})}}function E(r){return{...W,...r.watch}}function L(r,e){let t=process.env.SCIP_QUERY_CACHE_DIR;if(t)return m(t);if(e?.dbPath)return m(k(r,e.dbPath));let s=process.env.XDG_CACHE_HOME||d(F(),".cache"),o=G("sha256").update(k(r)).digest("hex").slice(0,12),n=d(s,"scip-query","projects",o);return m(n)}function S(r,e){let t=L(r,e);return{cacheDir:t,dbPath:d(t,"index.db"),indexPath:d(t,"index.scip"),metaPath:d(t,"meta.json")}}function q(r,e){let t=d(r,f);return P(t)||D(t,JSON.stringify({languages:e,watch:{enabled:!1,debounceMs:3e4,cooldownMs:6e4,gitPollMs:2e3,autoRefresh:!0}},null,2)+`
2
+ `),t}function m(r){return N(r,{recursive:!0}),r}import{execFileSync as Y,fork as K}from"child_process";import{statSync as H,watch as X}from"fs";import{join as B,relative as V}from"path";import z from"ignore";var v=class{projectRoot;config;watchConfig;languages;pnpmWorkspaces;typescriptProjectMode;typescriptProjects;clojureConfigPath;indexerConcurrency;onStatus;onReindexComplete;onError;status={state:"idle"};debounceTimer=null;cooldownTimer=null;dirty=!1;changedFiles=0;pendingTrigger=null;reindexInFlight=!1;lastReindexEnd=0;fsWatchers=[];gitPollTimer=null;lastGitState=null;gitignoreFilter;extraIgnore;stopped=!1;constructor(e){this.projectRoot=e.projectRoot,this.config=e.config,this.watchConfig=E(e.config),this.languages=e.languages,this.pnpmWorkspaces=e.config.indexer?.typescript?.pnpmWorkspaces??!1,this.typescriptProjectMode=e.config.indexer?.typescript?.projectMode,this.typescriptProjects=e.config.indexer?.typescript?.projects,this.clojureConfigPath=e.config.indexer?.clojure?.configPath,this.indexerConcurrency=e.config.indexerConcurrency,this.onStatus=e.onStatus??(()=>{}),this.onReindexComplete=e.onReindexComplete??(()=>{}),this.onError=e.onError??(t=>console.error(t.message)),this.gitignoreFilter=R(e.projectRoot),this.extraIgnore=z(),this.watchConfig.ignore.length>0&&this.extraIgnore.add(this.watchConfig.ignore)}start(){this.stopped=!1,this.setStatus({state:"idle"}),this.startGitStatePolling();try{let e=X(this.projectRoot,{recursive:!0},(t,i)=>{i&&!this.stopped&&this.handleFileChange(i)});this.fsWatchers.push(e)}catch{this.onError(new Error("Failed to start file watcher. On Linux, you may need to increase inotify limits: sysctl -w fs.inotify.max_user_watches=524288"))}}stop(){this.stopped=!0;for(let e of this.fsWatchers)e.close();this.fsWatchers=[],this.clearDebounceTimer(),this.clearCooldownTimer(),this.clearGitPollTimer(),this.setStatus({state:"idle"})}handleFileChange(e){let t=V(this.projectRoot,B(this.projectRoot,e));t===".git"||t.startsWith(".git/")||this.gitignoreFilter.isIgnored(t)||this.extraIgnore.ignores(t)||e.endsWith("index.db")||e.endsWith("index.scip")||e.endsWith("index.db.tmp")||this.scheduleReindex({kind:"watch-source",detail:t})}scheduleReindex(e){if(this.pendingTrigger=J(this.pendingTrigger,e),this.changedFiles++,this.reindexInFlight){this.dirty=!0,this.setStatus({state:"indexing",startedAt:this.status.startedAt});return}if(this.status.state==="cooldown"){this.dirty=!0,this.setStatus({state:"cooldown",until:this.status.until,dirty:!0});return}this.clearDebounceTimer();let t=Date.now()+this.watchConfig.debounceMs;this.setStatus({state:"waiting",changedFiles:this.changedFiles,reindexAt:t}),this.debounceTimer=setTimeout(()=>{this.debounceTimer=null,this.triggerReindex()},this.watchConfig.debounceMs)}triggerReindex(){if(this.reindexInFlight||this.stopped)return;let e=Date.now()-this.lastReindexEnd;if(this.lastReindexEnd>0&&e<this.watchConfig.cooldownMs){let s=this.watchConfig.cooldownMs-e;this.dirty=!0;let o=Date.now()+s;this.setStatus({state:"cooldown",until:o,dirty:!0}),this.cooldownTimer=setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped&&(this.dirty=!1,this.triggerReindex())},s);return}this.reindexInFlight=!0,this.dirty=!1,this.changedFiles=0;let t=this.pendingTrigger??{kind:"watch-source"};this.pendingTrigger=null;let i=Date.now();this.setStatus({state:"indexing",startedAt:i}),this.runReindex(t).then(s=>{if(this.reindexInFlight=!1,this.lastReindexEnd=Date.now(),this.onReindexComplete(s),this.dirty&&!this.stopped){let o=Date.now()+this.watchConfig.cooldownMs;this.setStatus({state:"cooldown",until:o,dirty:!0}),this.cooldownTimer=setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped?(this.dirty=!1,this.triggerReindex()):this.setStatus({state:"idle"})},this.watchConfig.cooldownMs)}else this.setStatus({state:"idle"})}).catch(s=>{this.reindexInFlight=!1,this.lastReindexEnd=Date.now(),this.onError(s instanceof Error?s:new Error(String(s))),this.setStatus({state:"idle"})})}runReindex(e){return new Promise((t,i)=>{let s=Date.now(),o=y(this.projectRoot),n=Object.keys(o).length>0?o:this.config,c=S(this.projectRoot,n),a=n.indexer?.typescript,l=n.indexer?.clojure,u=K(new URL("./reindex-worker.js",import.meta.url).pathname,[],{detached:!0,env:{...process.env,SCIP_REINDEX_PROJECT_ROOT:this.projectRoot,SCIP_REINDEX_OUTPUT_SCIP:c.indexPath,SCIP_REINDEX_OUTPUT_DB:c.dbPath,SCIP_REINDEX_LANGUAGES:(n.languages??this.languages)?.join(",")??"",SCIP_REINDEX_INDEXER_CONCURRENCY:String(n.indexerConcurrency??this.indexerConcurrency??""),SCIP_REINDEX_PNPM_WORKSPACES:a?.pnpmWorkspaces??this.pnpmWorkspaces?"1":"",SCIP_REINDEX_TYPESCRIPT_CONFIG:JSON.stringify({projectMode:a?.projectMode??this.typescriptProjectMode,projects:a?.projects??this.typescriptProjects??[]}),SCIP_REINDEX_CLOJURE_CONFIG_PATH:l?.configPath??this.clojureConfigPath??"",SCIP_REINDEX_TRIGGER_KIND:e.kind,SCIP_REINDEX_TRIGGER_DETAIL:e.detail??""},stdio:"pipe"});u.on("exit",p=>{p===0?t(Date.now()-s):i(new Error(`Reindex worker exited with code ${p}`))}),u.on("error",i)})}setStatus(e){this.status=e,this.onStatus(e)}clearDebounceTimer(){this.debounceTimer&&(clearTimeout(this.debounceTimer),this.debounceTimer=null)}clearCooldownTimer(){this.cooldownTimer&&(clearTimeout(this.cooldownTimer),this.cooldownTimer=null)}startGitStatePolling(){this.lastGitState=this.readGitState(),this.lastGitState&&(this.gitPollTimer=setInterval(()=>this.pollGitState(),this.watchConfig.gitPollMs),this.gitPollTimer.unref?.())}pollGitState(){let e=this.lastGitState,t=this.readGitState();if(!e||!t||this.stopped){this.lastGitState=t;return}this.lastGitState=t;let i=e.head!==t.head,s=e.indexPath!==t.indexPath||e.indexMtimeMs!==t.indexMtimeMs||e.indexSize!==t.indexSize;i&&s?this.scheduleReindex({kind:"watch-git-state",detail:"HEAD and index changed"}):i?this.scheduleReindex({kind:"watch-git-head",detail:"HEAD changed"}):s&&this.scheduleReindex({kind:"watch-git-index",detail:t.indexPath??"index changed"})}readGitState(){let e=j(this.projectRoot,["rev-parse","--git-path","index"]);if(!e)return null;let t={head:j(this.projectRoot,["rev-parse","--verify","HEAD"]),indexPath:e};try{let i=H(e);t.indexMtimeMs=i.mtimeMs,t.indexSize=i.size}catch{t.indexMtimeMs=void 0,t.indexSize=void 0}return t}clearGitPollTimer(){this.gitPollTimer&&(clearInterval(this.gitPollTimer),this.gitPollTimer=null)}};function j(r,e){try{return Y("git",["-C",r,...e],{encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).trim()}catch{return}}function J(r,e){return r?r.kind===e.kind?r.detail===e.detail?r:{kind:r.kind,detail:"multiple changes"}:{kind:"watch-git-state",detail:`${r.kind}, ${e.kind}`}:e}import{existsSync as C,mkdirSync as Q,symlinkSync as Z,readlinkSync as b,unlinkSync as T,readdirSync as ee}from"fs";import{join as h,dirname as w,resolve as g,relative as te,isAbsolute as re}from"path";import{homedir as x,platform as ie}from"os";import{fileURLToPath as se}from"url";var ne=ie()==="win32",_=["_shared","scip-query","scip-setup","scip-calibrate","scip-cleanup-audit","scip-cleanup-improve","scip-integrity-audit","scip-twin-drift","scip-claim-audit","scip-probe-reachability","scip-hyper-optimization","scip-api-impact","scip-concrete-plan","scip-conductor","scip-debug","scip-explore","scip-triage-issue","scip-diagram","scip-doc-reconcile","scip-directory-architecture","scip-maintainability","scip-react-maintainability","scip-vue-maintainability","scip-verify","scip-language-playbook","scip-tla-model-system"];function oe(r={}){let e=r.quiet?()=>{}:console.log,t=se(import.meta.url),i=g(w(t),"..","skills"),s=[h(x(),".claude","skills"),h(x(),".codex","skills"),h(x(),".agents","skills")],o={installed:[],skipped:[],alreadyLinked:[],pruned:[]};for(let n of s){let c=w(n);if(!C(c))continue;Q(n,{recursive:!0});let a=ce(n);ae(n,i,a,o,e);for(let l of _){let u=h(i,l),p=h(n,l);if(!C(u)){o.skipped.push(`${a}/${l}`);continue}if(C(p)){try{let I=b(p);if(g(I)===g(u)){o.alreadyLinked.push(`${a}/${l}`),e(` ok: ${l} \u2192 ${a} (already linked)`);continue}}catch{o.skipped.push(`${a}/${l}`),e(` skip: ${l} \u2192 ${a} (exists, not a symlink)`);continue}T(p)}Z(u,p,ne?"junction":"dir"),o.installed.push(`${a}/${l}`),e(` done: ${l} \u2192 ${a}`)}}return o}function ae(r,e,t,i,s){let o=new Set(_);for(let n of ee(r)){if(o.has(n))continue;let c=h(r,n),a;try{a=g(w(c),b(c))}catch{continue}le(a,e)&&(T(c),i.pruned.push(`${t}/${n}`),s(` prune: ${n} \u2192 ${t} (removed stale scip-query skill link)`))}}function le(r,e){let t=te(g(e),g(r));return t===""||!t.startsWith("..")&&!re(t)}function ce(r){return r.includes(".codex")?"Codex":r.includes(".agents")?"Agents":"Claude"}export{v as Watcher,M as getScipVersion,q as initProjectConfig,oe as installSkills,$ as isScipInstalled,y as loadProjectConfig,A as printScipInstallInstructions,S as resolveIndexStoragePaths};
3
3
  //# sourceMappingURL=runtime.js.map
@@ -1,4 +1,4 @@
1
- import { a as SupportedLanguage } from './config-types-BrHl3Bge.js';
1
+ import { a as SupportedLanguage } from './config-types-aCgyLrvE.js';
2
2
 
3
3
  type WatcherStatus = {
4
4
  state: 'idle';
@@ -135,7 +135,8 @@ This syntax summary is generated from the CLI command descriptors. Keep workflow
135
135
  | `capability-matrix` | Deprecated alias for capabilities --matrix | `--json` |
136
136
  | `init` | Create a .scipquery.json config file for this project | - |
137
137
  | `config-validate` | Validate .scipquery.json, including structured suppressions and declared coupling groups | `--json` |
138
- | `suppress <id>` | Record an accepted finding in .scipquery.json with a required reason | `--reason <text>`<br>`--check <check>`<br>`--file <path>`<br>`--expires-at <iso>`<br>`--json` |
138
+ | `suppress <id>` | Record an accepted finding as a file under .scipquery/suppressions/ with a required reason | `--reason <text>`<br>`--check <check>`<br>`--file <path>`<br>`--expires-at <iso>`<br>`--json` |
139
+ | `effectiveness` | Per-check effectiveness from the committed outcome ledger: findings caught, fixed by code changes, suppressed, precision, median time-to-fix | `--since <window>`<br>`--check <check>`<br>`--json` |
139
140
  | `doctor` | Diagnose config, index freshness, dependency readiness, and project capabilities | `--json` |
140
141
  | `setup` | Bootstrap this project: install agent skills, refresh the index, verify capabilities, and report health | `--git-hook`<br>`--no-hooks`<br>`--dossier-dir <path>`<br>`--json` |
141
142
  | `setup-agent` | Seed agent guidance for this project: AGENTS.md/CLAUDE.md block pointing agents at the scip-query skills and diff gate, plus an optional git pre-commit backstop | `--git-hook` |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scip-query",
3
- "version": "0.13.0",
3
+ "version": "0.15.0",
4
4
  "description": "Evidence and verification for AI coding agents: map code, reuse concepts, finish migrations, and gate diffs.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -181,7 +181,8 @@ scip-query capabilities # Report which evidence and verification capabilities ar
181
181
  scip-query capability-matrix # Deprecated alias for capabilities --matrix
182
182
  scip-query init # Create a .scipquery.json config file for this project
183
183
  scip-query config-validate # Validate .scipquery.json, including structured suppressions and declared coupling groups
184
- scip-query suppress <id> # Record an accepted finding in .scipquery.json with a required reason
184
+ scip-query suppress <id> # Record an accepted finding as a file under .scipquery/suppressions/ with a required reason
185
+ scip-query effectiveness # Per-check effectiveness from the committed outcome ledger: findings caught, fixed by code changes, suppressed, precision, median time-to-fix
185
186
  scip-query doctor # Diagnose config, index freshness, dependency readiness, and project capabilities
186
187
  scip-query setup # Bootstrap this project: install agent skills, refresh the index, verify capabilities, and report health
187
188
  scip-query setup-agent # Seed agent guidance for this project: AGENTS.md/CLAUDE.md block pointing agents at the scip-query skills and diff gate, plus an optional git pre-commit backstop
@@ -205,6 +206,7 @@ measured precision, not by volume:
205
206
  - **Advisory gate findings** (marked `(advisory)`) never block; they are context, not obligations.
206
207
  - **False-dead archetypes (2026-07-02 remediation, docs/plans/2026-07-02-followups.md items 1-3)**: `import type`-only consumers (incl. tsconfig `paths`-aliased specifiers) and pnpm/npm/yarn workspace cross-package consumers (incl. unbuilt `dist/` exports maps) are now resolved by the shared reference-counting layer that `dead`/`isolated`/`new-dead`/`stale-abstractions`/`production-callables` all consume; Vue `<script setup>` composable consumers were already correctly resolved (verified live, no code change needed). One narrow residual gap remains: a symbol with an **ambiguous leaf name** (a same-named definition exists elsewhere in the project) reached only through a **re-exporting barrel file** in a workspace package can still misattribute — `new-dead` labels that specific shape `unconfirmed (cross-package ambiguous-name resolution gap)` with `evidence: "heuristic"` and lowered confidence instead of asserting `dead`; treat those as "verify manually," not as a fact. Everything else in this class is a normal graph-fact `dead` claim again — confirm with `refs` when in doubt, same as any other finding.
207
208
  - **Ledger nudges**: when `diff-gate --hook` reports "this check is rarely acted on in this repo", either tune that check's config, suppress the standing findings with reasons, or consciously accept the noise — do not let unresolved findings accumulate as wallpaper.
209
+ - **Effectiveness ledger**: hook-mode gate runs append caught/resolved/suppressed transitions to `.scipquery/ledger/events.jsonl` (committed, conflict-free via a scoped `merge=union` gitattribute — commit it with your changes). Query it with `scip-query effectiveness [--since 30d] [--check <check>] [--json]`: per check it reports findings caught, fixed by code changes, suppressed, still open, `moved` (rename noise), precision (fixed ÷ concluded), and median days-to-fix. A finding that disappears without a suppression counts as fixed; a suppression counts against the detector's precision. Use it to decide which checks to trust, tune, or suppress in a given repo.
208
210
 
209
211
  ## Diff Gate Checks
210
212
 
@@ -8,6 +8,7 @@ commands:
8
8
  - scip-query dead --json
9
9
  - scip-query similar <symbol>
10
10
  - scip-query config-validate
11
+ - scip-query effectiveness --since 30d --json
11
12
  ---
12
13
 
13
14
  # scip-calibrate
@@ -116,9 +117,12 @@ filed upstream.
116
117
 
117
118
  The finding-outcome ledger keeps calibrating for you: once the repo uses
118
119
  diff-gate, per-detector precision is recomputed from real outcomes
119
- (`detectorPrecision` in `health --json`). Re-run this protocol only after
120
- major detector upgrades or when the ledger's precision numbers drift from
121
- what you measured. Write the calibration report to
120
+ (`detectorPrecision` in `health --json`), and the committed event ledger
121
+ makes those outcomes durable and queryable `scip-query effectiveness
122
+ --since 30d --json` reports per-check caught/fixed/suppressed counts,
123
+ precision, and median days-to-fix from `.scipquery/ledger/events.jsonl`.
124
+ Re-run this protocol only after major detector upgrades or when the
125
+ ledger's precision numbers drift from what you measured. Write the calibration report to
122
126
  `docs/validation/YYYY-MM-DD-external-calibration-<repo>.md` in the shape of
123
127
  the exemplars this skill was distilled from — battery table, retro-gate
124
128
  walls, per-detector verdicts, noise archetypes, caps and deviations.