scip-query 0.11.0 → 0.12.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 (117) hide show
  1. package/README.md +23 -0
  2. package/dist/{chunk-3KDUITBE.js → chunk-2LQWMYG4.js} +2 -2
  3. package/dist/{chunk-KKMOB3OJ.js → chunk-2QGE5AEP.js} +2 -2
  4. package/dist/{chunk-HINMXZ6J.js → chunk-4D54JIU3.js} +2 -2
  5. package/dist/{chunk-CMHYBXJB.js → chunk-52Q4JFDW.js} +2 -2
  6. package/dist/{chunk-UIKLA3F5.js → chunk-64PRNLKP.js} +2 -2
  7. package/dist/{chunk-QJ3FK4TB.js → chunk-72MFTCU5.js} +2 -2
  8. package/dist/{chunk-7HB3CZFD.js → chunk-7ITCOJGD.js} +2 -2
  9. package/dist/{chunk-ZEKBR4OK.js → chunk-AZLKLZ5S.js} +2 -2
  10. package/dist/{chunk-ODVITBYU.js → chunk-B4VYXRCQ.js} +2 -2
  11. package/dist/{chunk-STBXCPKY.js → chunk-BCNT6ODA.js} +2 -2
  12. package/dist/{chunk-WPSS37EW.js → chunk-BP2NAIAZ.js} +2 -2
  13. package/dist/{chunk-LWOOTRHC.js → chunk-BVNO67DB.js} +2 -2
  14. package/dist/{chunk-NBXK32I6.js → chunk-CW3KZ7UF.js} +2 -2
  15. package/dist/{chunk-UMPNL7T6.js → chunk-D64L53WX.js} +2 -2
  16. package/dist/{chunk-IFSX6YVU.js → chunk-D7J6GZAG.js} +2 -2
  17. package/dist/{chunk-WQHWIVA7.js → chunk-ECVXWZ4Q.js} +2 -2
  18. package/dist/{chunk-H4LUPLEJ.js → chunk-EDB7Y442.js} +2 -2
  19. package/dist/{chunk-QXGTGE2C.js → chunk-ETU2I5JM.js} +2 -2
  20. package/dist/{chunk-VXTNADIW.js → chunk-EXKLAEB4.js} +2 -2
  21. package/dist/{chunk-MNEJYEHW.js → chunk-EZ5WDZ2Q.js} +2 -2
  22. package/dist/{chunk-DRPAQAFM.js → chunk-F5BJSNU5.js} +2 -2
  23. package/dist/{chunk-343O6EVV.js → chunk-FBCOFKEC.js} +2 -2
  24. package/dist/{chunk-H56MGERE.js → chunk-G2UBOONK.js} +2 -2
  25. package/dist/{chunk-GCN2P4EJ.js → chunk-H2NMIZFD.js} +2 -2
  26. package/dist/{chunk-GHXRVCIY.js → chunk-HSU3M25J.js} +2 -2
  27. package/dist/{chunk-PYZZBIEU.js → chunk-IRJDYTNZ.js} +2 -2
  28. package/dist/{chunk-PZS6J5YG.js → chunk-KSUZS77X.js} +2 -2
  29. package/dist/{chunk-HZKMEXA3.js → chunk-L2CX5GHZ.js} +2 -2
  30. package/dist/{chunk-X6OGDTQH.js → chunk-LFM3O5KX.js} +2 -2
  31. package/dist/{chunk-TTS75UF2.js → chunk-M72ZFN6E.js} +2 -2
  32. package/dist/chunk-MBKJ7GHT.js +102 -0
  33. package/dist/{chunk-3T2FNHIU.js → chunk-MJKJMWIM.js} +2 -2
  34. package/dist/{chunk-WFGOH2UI.js → chunk-MKM7NBZK.js} +2 -2
  35. package/dist/{chunk-3V6JQQM5.js → chunk-NKT5EMEX.js} +2 -2
  36. package/dist/{chunk-BN5SXXQS.js → chunk-NQ75OVUU.js} +2 -2
  37. package/dist/{chunk-BDRBPG7Y.js → chunk-O3WDE26W.js} +2 -2
  38. package/dist/{chunk-N2Z3CU7X.js → chunk-OPE5YXFE.js} +2 -2
  39. package/dist/{chunk-XHWLNQVZ.js → chunk-OSWF3HSF.js} +2 -2
  40. package/dist/{chunk-Y6L4LXPG.js → chunk-OVMUVXKQ.js} +2 -2
  41. package/dist/{chunk-P36UR5II.js → chunk-PH7ZFK6L.js} +2 -2
  42. package/dist/chunk-PXHPCWX5.js +2 -0
  43. package/dist/{chunk-K2HYR5A7.js → chunk-Q3B3FNCU.js} +2 -2
  44. package/dist/{chunk-7XL7J7PT.js → chunk-Q7S2DADC.js} +2 -2
  45. package/dist/{chunk-FLJJLSGB.js → chunk-RA5MTIOO.js} +2 -2
  46. package/dist/{chunk-WZLPXFZU.js → chunk-RIQED5OU.js} +2 -2
  47. package/dist/{chunk-VGMUFW3J.js → chunk-T6NGEV5I.js} +2 -2
  48. package/dist/{chunk-XMR747CP.js → chunk-T7VQG55Q.js} +2 -2
  49. package/dist/{chunk-LZNLRE4X.js → chunk-TTMKELT7.js} +2 -2
  50. package/dist/{chunk-X4O6K47U.js → chunk-UAHZ57BR.js} +2 -2
  51. package/dist/{chunk-RJMXSHKM.js → chunk-V3Z3IOWO.js} +2 -2
  52. package/dist/{chunk-M2YXL62V.js → chunk-V7CVBPWX.js} +2 -2
  53. package/dist/{chunk-C4ICAIJ4.js → chunk-YDDGCJJG.js} +2 -2
  54. package/dist/{chunk-N7PNFLGY.js → chunk-YPKBZ77R.js} +2 -2
  55. package/dist/{chunk-WGA5BBTA.js → chunk-Z3IPJKJP.js} +2 -2
  56. package/dist/{chunk-ALHNAPS2.js → chunk-ZOIPAYRP.js} +2 -2
  57. package/dist/{chunk-6Q6OFLFQ.js → chunk-ZRIOGL7F.js} +2 -2
  58. package/dist/cli.js +243 -243
  59. package/dist/index.js +1 -1
  60. package/dist/queries/affected.js +1 -1
  61. package/dist/queries/bottlenecks.js +1 -1
  62. package/dist/queries/by-kind.js +1 -1
  63. package/dist/queries/call-graph.js +1 -1
  64. package/dist/queries/change-surface.js +1 -1
  65. package/dist/queries/cleanup-plan.js +1 -1
  66. package/dist/queries/code.js +1 -1
  67. package/dist/queries/complexity-hotspots.js +1 -1
  68. package/dist/queries/complexity.js +1 -1
  69. package/dist/queries/convergence.js +1 -1
  70. package/dist/queries/coupling.js +1 -1
  71. package/dist/queries/dataflow.js +1 -1
  72. package/dist/queries/dead.js +1 -1
  73. package/dist/queries/deps.js +1 -1
  74. package/dist/queries/diff-gate.js +1 -1
  75. package/dist/queries/diff-impact.js +1 -1
  76. package/dist/queries/drift.js +1 -1
  77. package/dist/queries/duplicate-bodies.js +1 -1
  78. package/dist/queries/extract-candidates.js +1 -1
  79. package/dist/queries/fan.js +1 -1
  80. package/dist/queries/health.js +1 -1
  81. package/dist/queries/hierarchy.js +1 -1
  82. package/dist/queries/hotspots.js +1 -1
  83. package/dist/queries/imports.js +1 -1
  84. package/dist/queries/incomplete-migration.js +1 -1
  85. package/dist/queries/index.js +1 -1
  86. package/dist/queries/isolated.js +1 -1
  87. package/dist/queries/locality-candidates.js +1 -1
  88. package/dist/queries/members.js +1 -1
  89. package/dist/queries/methods.js +1 -1
  90. package/dist/queries/outline.js +1 -1
  91. package/dist/queries/passthrough-candidates.js +1 -1
  92. package/dist/queries/plan-context.js +1 -1
  93. package/dist/queries/recent-duplicates.js +1 -1
  94. package/dist/queries/redundant-reexports.js +1 -1
  95. package/dist/queries/refs.js +1 -1
  96. package/dist/queries/self-audit.js +1 -1
  97. package/dist/queries/similar-signatures.js +1 -1
  98. package/dist/queries/similar.js +1 -1
  99. package/dist/queries/slice.js +1 -1
  100. package/dist/queries/stale-abstractions.js +1 -1
  101. package/dist/queries/surface.js +1 -1
  102. package/dist/queries/symbols.js +1 -1
  103. package/dist/queries/system.js +1 -1
  104. package/dist/queries/trace.js +1 -1
  105. package/dist/queries/twin-ab.js +1 -1
  106. package/dist/queries/twin-drift.js +1 -1
  107. package/dist/queries/unused-imports.js +1 -1
  108. package/dist/queries/unused-params.js +1 -1
  109. package/dist/queries/wrapper-candidates.js +1 -1
  110. package/dist/reindex-worker.js +9 -9
  111. package/dist/reindex.d.ts +20 -1
  112. package/dist/reindex.js +19 -19
  113. package/docs/COMMAND_REFERENCE.md +2 -2
  114. package/package.json +20 -2
  115. package/skills/scip-tla-model-system/SKILL.md +17 -5
  116. package/dist/chunk-2VSDXOG5.js +0 -2
  117. package/dist/chunk-R3JY4EZ4.js +0 -102
package/dist/reindex.js CHANGED
@@ -1,10 +1,10 @@
1
- import{a as R,b as E,f as V}from"./chunk-WIBFXSYB.js";import{a as ce}from"./chunk-YZXV3CU3.js";import{d as se,e as ae,f as ue}from"./chunk-GNG622H3.js";import"./chunk-64MNV6AB.js";import"./chunk-7S5E7KWT.js";import{execFileSync as Gr}from"child_process";import{closeSync as Hr,copyFileSync as zr,existsSync as M,mkdirSync as re,mkdtempSync as Kr,openSync as Xr,readFileSync as D,renameSync as k,rmSync as I,writeFileSync as ot}from"fs";import{basename as T,dirname as f,extname as Yr,join as m}from"path";import{platform as Qr}from"os";import mt from"better-sqlite3";import{execFileSync as ht}from"child_process";import{existsSync as yt,readdirSync as bt,readFileSync as xt}from"fs";import{extname as j,join as le}from"path";function x(e={}){return{id:"auxiliary-documents",facts:["auxiliary-document"],run:t=>ge({projectRoot:t.projectRoot,dbPath:t.dbPath,extensions:e.extensions,onStatus:t.onStatus})}}function ge(e){let t=new Set((e.extensions??ae).map(o=>o.toLowerCase()));if(t.size===0)return{scanned:0,inserted:0,existing:0};if(!yt(e.dbPath))throw new Error(`SCIP SQLite database not found at ${e.dbPath}`);let n=ce(e.projectRoot),r=St(e.projectRoot,t).filter(o=>!n.isIgnored(o)),i=new mt(e.dbPath);try{let o=Pt(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=xt(le(e.projectRoot,p),"utf-8"),ft=s.run(vt(p),p,h);l+=Number(ft.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 St(e,t){let n=Rt(e,t);if(n)return n;let r=[],i=o=>{let s=o?le(e,o):e,a;try{a=bt(s,{withFileTypes:!0})}catch{return}for(let u of a){if(ue.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 Rt(e,t){try{return ht("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 Pt(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 vt(e){return j(e).toLowerCase()===".vue"?"vue":j(e).replace(/^\./,"").toLowerCase()||"source"}import{execFileSync as kt}from"child_process";import{existsSync as It,readdirSync as de}from"fs";import{extname as fe,join as me}from"path";var jt=new Set([".git",".hg",".svn",".idea",".vscode","node_modules","vendor","dist","build","target","bin","obj",".dart_tool",".gradle",".next",".venv","venv","__pycache__"]),wt=[{language:"typescript",files:["tsconfig.json","tsconfig.base.json"],extensions:[".ts",".tsx",".mts",".cts"]},{language:"rust",files:["Cargo.toml"],extensions:[".rs"]},{language:"go",files:["go.mod"],extensions:[".go"]},{language:"java",files:["pom.xml","build.gradle","build.gradle.kts"],extensions:[".java"]},{language:"kotlin",files:["build.gradle.kts"],extensions:[".kt",".kts"]},{language:"scala",files:["build.sbt"],extensions:[".scala"]},{language:"clojure",files:["deps.edn","project.clj","bb.edn","shadow-cljs.edn"],extensions:[".clj",".cljs",".cljc"]},{language:"python",files:["pyproject.toml","setup.py","setup.cfg","Pipfile"],extensions:[".py",".pyi"]},{language:"ruby",files:["Gemfile"],extensions:[".rb"]},{language:"cpp",files:["compile_commands.json","CMakeLists.txt","Makefile"],extensions:[".cc",".cpp",".cxx",".hpp",".hh",".hxx"]},{language:"c",files:["compile_commands.json","CMakeLists.txt","Makefile"],extensions:[".c",".h"]},{language:"csharp",globs:["*.csproj","*.sln"],extensions:[".cs"]},{language:"vb",globs:["*.vbproj"],extensions:[".vb"]},{language:"dart",files:["pubspec.yaml"],extensions:[".dart"]},{language:"php",files:["composer.json"],extensions:[".php"]},{language:"javascript",files:["package.json"],extensions:[".js",".jsx",".mjs",".cjs"]}];function A(e){let t=[],n=Ct(e),r=Tt(e);for(let i of wt){if(Lt(e,i.files)){t.push(i.language);continue}if(Ot(n,i.globs)){t.push(i.language);continue}Dt(r,i.extensions)&&t.push(i.language)}return t.includes("typescript")&&pe(t,"javascript"),t.includes("cpp")&&!r.has(".c")&&pe(t,"c"),t}function Ct(e){try{return de(e)}catch{return[]}}function Lt(e,t){return t?.length?t.some(n=>It(me(e,n))):!1}function Ot(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=Mt(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=de(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=me(i,s.name);if(s.isDirectory()){jt.has(s.name)||r.push(a);continue}let u=fe(s.name).toLowerCase();u&&n.add(u)}}return n}function Mt(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=fe(r).toLowerCase();i&&n.add(i)}return n}catch{return null}}function Dt(e,t){return t?.length?t.some(n=>e.has(n)):!1}function pe(e,t){let n=e.indexOf(t);n!==-1&&e.splice(n,1)}import{existsSync as he,readdirSync as Et}from"fs";import{isAbsolute as Vt,join as N,resolve as At}from"path";var be={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",Vt(r)?r:At(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",ye(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",ye(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",he(r)?r:he(n)?n:t]}},defaultOutputPath:"index.scip",markerFiles:["composer.json"],installMethods:[],installUrl:"https://github.com/davidrjenni/scip-php/releases"}};function w(e){return be[e]}function ye(e,t){let n;try{n=Et(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 Nt,writeFileSync as $t}from"fs";import{create as $}from"@bufbuild/protobuf";import{deserializeSCIP as _t,serializeSCIP as Bt,DocumentSchema as Wt,IndexSchema as Ut,SymbolInformationSchema as Jt}from"@c4312/scip";function xe(e){if(e.length===0)throw new Error("Cannot merge zero SCIP indexes");if(e.length===1)return e[0];let t=qt(e),n=Gt(e.flatMap(i=>i.documents??[])),r=Se(e.flatMap(i=>i.externalSymbols??[]));return $(Ut,{metadata:t,documents:n,externalSymbols:r})}function C(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let n=e.map(i=>_t(Nt(i))),r=xe(n);return $t(t,Buffer.from(Bt(r))),{documentCount:r.documents.length,externalSymbolCount:r.externalSymbols.length,inputCount:e.length}}function qt(e){let t=e[0]?.metadata;if(!t)return;let n=t.projectRoot;for(let r of e.slice(1)){let i=r.metadata?.projectRoot;if(n&&i&&i!==n)throw new Error(`Cannot merge SCIP indexes with different project roots: ${n} vs ${i}`)}return t}function 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,$(Wt,{language:r.language||n.language,relativePath:r.relativePath||n.relativePath,occurrences:Ht([...r.occurrences,...n.occurrences]),symbols:Se([...r.symbols,...n.symbols]),text:Kt(r.text,n.text),positionEncoding:r.positionEncoding||n.positionEncoding}))}return[...t.values()]}function Ht(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 Se(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,$(Jt,{symbol:r.symbol,documentation:Xt([...r.documentation,...n.documentation]),relationships:zt([...r.relationships,...n.relationships]),kind:r.kind||n.kind,displayName:r.displayName||n.displayName,enclosingSymbol:r.enclosingSymbol||n.enclosingSymbol,signatureDocumentation:r.signatureDocumentation??n.signatureDocumentation}))}return[...t.values()]}function zt(e){let t=new Set,n=[];for(let r of e){let i=[r.symbol,r.isReference?"1":"0",r.isImplementation?"1":"0",r.isTypeDefinition?"1":"0",r.isDefinition?"1":"0"].join("|");t.has(i)||(t.add(i),n.push(r))}return n}function Kt(e,t){return e?t?e.length>=t.length?e:t:e:t}function Xt(e){return[...new Set(e)]}import{readFileSync as Yt,writeFileSync as Qt}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 Pe(e){let t=e.readFingerprint(),n=Zt(e.cachePath,t);if(n)return e.onCacheHit?.(n.result),n.result;let r=e.compute();return en(e.cachePath,e.readFingerprint(),r),r}function Zt(e,t){try{let n=JSON.parse(Yt(e,"utf-8"));return Re(n.fingerprint)===Re(t)?{result:n.result}:null}catch{return null}}function en(e,t,n){Qt(e,`${JSON.stringify({updatedAt:new Date().toISOString(),fingerprint:t,result:n},null,2)}
5
- `)}function Re(e){return JSON.stringify(e)}import{execFileSync as tn}from"child_process";import{createHash as nn}from"crypto";import{readdirSync as rn,readFileSync as on}from"fs";import{join as ke}from"path";function _(e){return[...new Set((e??[]).map(t=>t.trim()).filter(Boolean))].sort((t,n)=>t.localeCompare(n))}function ve(e){return(an(e)??un(e)).filter(t=>t&&!Ie(t)).sort()}function P(e,t={}){return(t.language?ve(e).filter(r=>sn(r,t.language,t.markerFiles)):ve(e)).map(r=>{let i=ke(e,r);try{let o=on(i);return{path:r,size:o.byteLength,hash:nn("sha256").update(o).digest("hex")}}catch{return{path:r,size:-1,hash:"unreadable"}}})}function sn(e,t,n){let r=e.split("/").at(-1)??e;if(n?.includes(e)||n?.includes(r)||ln.has(r))return!0;let i=e.includes(".")?`.${e.split(".").at(-1).toLowerCase()}`:"";return(gn[t]??[]).includes(i)}function an(e){try{return tn("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 un(e){let t=[],n=[""];for(;n.length>0;){let r=n.pop(),i=r?ke(e,r):e,o;try{o=rn(i,{withFileTypes:!0})}catch{continue}for(let s of o){let a=r?`${r}/${s.name}`:s.name;if(s.isDirectory()){Ie(a)||n.push(a);continue}t.push(a)}}return t}function Ie(e){let t=e.split("/");return e==="meta.json"||t.some(n=>cn.has(n))||e.endsWith(".db")||e.endsWith(".db-wal")||e.endsWith(".db-shm")||e.endsWith(".scip")}var cn=new Set([".git","node_modules",".scipquery-cache",".stryker-tmp","dist","build","coverage",".next",".nuxt","target"]),ln=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"]),gn={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 pn,writeFileSync as dn}from"fs";import{create as je}from"@bufbuild/protobuf";import{deserializeSCIP as fn,DocumentSchema as mn,IndexSchema as hn,serializeSCIP as yn,SymbolRole as bn}from"@c4312/scip";function we(e){let t;try{t=fn(pn(e))}catch{return{removedDefinitionOccurrences:0,touchedDocuments:0}}let n=xn(t);return n.removedDefinitionOccurrences>0&&dn(e,Buffer.from(yn(n.index))),{removedDefinitionOccurrences:n.removedDefinitionOccurrences,touchedDocuments:n.touchedDocuments}}function xn(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&bn.Definition)===0||t.has(a.symbol)?!0:(n+=1,!1));if(s.length===o.occurrences.length){i.push(o);continue}r+=1,i.push(je(mn,{language:o.language,relativePath:o.relativePath,occurrences:s,symbols:o.symbols,text:o.text,positionEncoding:o.positionEncoding}))}return{index:n===0?e:je(hn,{metadata:e.metadata,documents:i,externalSymbols:e.externalSymbols}),removedDefinitionOccurrences:n,touchedDocuments:r}}import{existsSync as Sn,readFileSync as Rn,readdirSync as Pn,statSync as vn}from"fs";import d from"path";var kn=new Set([".cache",".git",".next",".nuxt",".turbo",".nx","build","coverage","dist","node_modules","tmp","vendor"]);function Ce(e,t=[]){let n=d.resolve(e),r=In(n),i=t.flatMap(u=>jn(n,u)),o=Cn([...r,...i]),s=Ln(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 In(e){let t=[],n=[e];for(;n.length>0;){let r=n.pop(),i;try{i=Pn(r,{withFileTypes:!0})}catch{continue}for(let o of i){let s=d.join(r,o.name);if(o.isDirectory()){!kn.has(o.name)&&!o.name.startsWith(".")&&n.push(s);continue}o.isFile()&&wn(s)&&t.push(d.dirname(s))}}return t}function jn(e,t){let n=t.trim();if(!n)return[];let r=d.resolve(e,n);if(!se(e,r))return[];try{let i=vn(r);if(i.isDirectory())return[r];if(i.isFile()&&Le(d.basename(r)))return[d.dirname(r)]}catch{return[]}return[]}function wn(e){if(!Le(d.basename(e)))return!1;let t=Oe(e);return t?d.basename(e)==="tsconfig.json"||"include"in t||"files"in t||"references"in t:!1}function Le(e){return e.startsWith("tsconfig")&&e.endsWith(".json")}function Cn(e){let t=[...new Set(e.map(n=>d.resolve(n)))].sort((n,r)=>n.localeCompare(r));return t.length<=1?t:t.filter(n=>!t.some(r=>r!==n&&Tn(n,r)))}function Ln(e,t){if(t.length===0||t.some(r=>d.resolve(r)===e))return!1;let n=d.join(e,"tsconfig.json");return Sn(n)&&On(n)}function On(e){let n=Oe(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 Oe(e){try{let t=JSON.parse(Rn(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 Mn}from"child_process";import{existsSync as L,renameSync as W,rmSync as U}from"fs";import{cpus as Dn}from"os";import{join as Fe}from"path";function En(e,t,n){if(!e.defaultOutputPath)return;let r=Fe(t,e.defaultOutputPath);n!==r&&L(r)&&W(r,n)}function Vn(e,t,n){if(!e.defaultOutputPath)return null;let r=Fe(t,e.defaultOutputPath);if(r===n)return null;let i=`${n}.default-output-backup`;return U(i,{force:!0}),L(r)?(W(r,i),{defaultOutputPath:r,backupPath:i}):{defaultOutputPath:r,backupPath:null}}function An(e){e&&(U(e.defaultOutputPath,{force:!0}),e.backupPath&&L(e.backupPath)&&W(e.backupPath,e.defaultOutputPath))}function Nn(e,t){if(e<=1)return 1;let n=Number(process.env.SCIP_QUERY_INDEXER_CONCURRENCY??0),r=Number.isFinite(t)&&t&&t>0?t:Number.isFinite(n)&&n>0?n:Math.min(8,Math.max(1,Dn().length));return Math.max(1,Math.min(e,Math.floor(r)))}async function Te(e,t,n,r){let i=e.filter(c=>c.config.defaultOutputPath),o=e.filter(c=>!c.config.defaultOutputPath),s=[],a=Nn(o.length,r),u=await _n(o,a,c=>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=Vn(e.config,t,e.scipPath);try{await $n(e.binary,e.args,{cwd:t,env:e.env,maxBuffer:50*1024*1024}),En(e.config,t,e.scipPath)}catch(i){let o=i instanceof Error?i.message:String(i),s=`${e.resolvedBinary} indexer failed: ${o.split(`
7
- `)[0]}`,a=e.label===e.language?s:`${e.label}: ${s}`;return n(`Skipping ${e.label}: ${s}`),{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,skipped:{language:e.language,reason:a}}}finally{An(r)}if(!L(e.scipPath)){let i=`${e.resolvedBinary} indexer completed but did not produce ${e.scipPath}`,o=e.label===e.language?i:`${e.label}: ${i}`;return n(`Skipping ${e.label}: ${i}`),{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,skipped:{language:e.language,reason:o}}}return{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath}}function $n(e,t,n){return new Promise((r,i)=>{Mn(e,[...t],n,o=>{o?i(o):r()})})}async function _n(e,t,n){if(e.length===0)return[];let r=new Array(e.length),i=0,o=Math.max(1,Math.min(e.length,t)),s=Array.from({length:o},async()=>{for(;i<e.length;){let a=i++;r[a]=await n(e[a])}});return await Promise.all(s),r}import{execFileSync as q}from"child_process";import{existsSync as J,readFileSync as Bn}from"fs";import{createRequire as Wn}from"module";import{platform as Un}from"os";import{dirname as Me,join as O}from"path";var Jn=Wn(import.meta.url);function G(e){return[e.indexerBinary,...e.binaryAliases??[]]}function F(e){let t=G(e);return t.length===1?t[0]:t.join(" or ")}function v(e){for(let t of G(e))if(R(t))return t;return Gn(e)}function H(e){return v(e)!==null||qn(e)}function qn(e){return De(e)!==null}function Gn(e){let t=De(e);if(!t)return null;let r=JSON.parse(Bn(t,"utf8")).bin;if(!r)return null;if(typeof r=="string")return O(Me(t),r);for(let i of G(e)){let o=r[i];if(o)return O(Me(t),o)}return null}function De(e){if(!e.bundledNpmPackage)return null;try{return Jn.resolve(`${e.bundledNpmPackage}/package.json`)}catch{return null}}function z(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"||Ee(n,t))return t;let r=Hn(n,t);return r?{...t,DOTNET_ROOT:r}:t}function X(e,t){let n=e.installMethods,r=F(e);if(!n?.length)return t(`No auto-install method available for ${r}.`),e.installUrl&&t(`Install manually from: ${e.installUrl}`),!1;for(let i of n)if(R(i.prerequisite)){t(`Installing ${r} via ${i.label}...`);try{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 Hn(e,t){for(let n of zn(t))if(Ee(e,{...t,DOTNET_ROOT:n}))return n;return null}function zn(e){let t=[],n=e.DOTNET_ROOT;if(n&&J(n)&&t.push(n),Un()==="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 Ee(e,t){try{return q(e,["--version"],{stdio:"pipe",env:t}),!0}catch{return!1}}import Cr from"better-sqlite3";import{existsSync as Lr}from"fs";import{dirname as Or,join as Fr,resolve as Tr}from"path";import{readFileSync as Kn,rmSync as Xn,statSync as Yn,mkdtempSync as Qn}from"fs";import{cpus as Zn,tmpdir as er}from"os";import{join as Y}from"path";import{Worker as tr}from"worker_threads";function Ve(e){return e.length>=8&&Ne(e.length)>1}function Ae(e){let t=Ne(e.vueFiles.length),n=rr(e.vueFiles),r=or(n,t),i=new URL("./augment-vue-worker.js",import.meta.url),o=Qn(Y(er(),"scip-query-vue-workers-")),s=new SharedArrayBuffer(4),a=new Int32Array(s),u=nr(),c=Date.now();try{for(let l=0;l<r.length;l++)new tr(i,{workerData:{projectRoot:e.projectRoot,dbPath:e.dbPath,tsconfig:e.tsconfig,tasks:r[l],resultPath: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(Kn(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{Xn(o,{recursive:!0,force:!0})}}function Ne(e){let t=Number(process.env.SCIP_QUERY_AUGMENT_VUE_WORKERS??0),n=Number.isFinite(t)&&t>0?t:Math.min(8,Math.max(1,Zn().length-1));return Math.max(1,Math.min(e,n))}function nr(){let e=Number(process.env.SCIP_QUERY_AUGMENT_VUE_WORKER_TIMEOUT_MS??0);return Number.isFinite(e)&&e>0?e:3e5}function rr(e){let t=ir(),n=[];for(let r of e){let i=$e(r),o=Math.max(1,Math.ceil(i/t));for(let s=0;s<o;s++)n.push({fileName:r,startOffset:Math.floor(i*s/o),endOffset:s===o-1?Number.POSITIVE_INFINITY:Math.floor(i*(s+1)/o),countFileSkip:s===0})}return n}function ir(){return Number.POSITIVE_INFINITY}function or(e,t){let n=Array.from({length:t},()=>({tasks:[],weight:0})),r=e.map(i=>({task:i,weight:sr(i)})).sort((i,o)=>o.weight-i.weight);for(let i of r){let o=n.reduce((s,a)=>a.weight<s.weight?a:s);o.tasks.push(i.task),o.weight+=i.weight}return n.map(i=>i.tasks).filter(i=>i.length>0)}function sr(e){return Number.isFinite(e.endOffset)?Math.max(1,e.endOffset-e.startOffset):Math.max(1,$e(e.fileName)-e.startOffset)}function $e(e){try{return Yn(e).size}catch{return 1}}import{createRequire as ar}from"module";import{existsSync as ur,readFileSync as Z}from"fs";import{dirname as _e,extname as cr,join as Be,relative as lr,resolve as gr}from"path";import{pathToFileURL as pr}from"url";function dr(e){e.transaction(()=>{e.prepare(`
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(`
8
8
  DELETE FROM mentions
9
9
  WHERE chunk_id IN (
10
10
  SELECT c.id
@@ -19,12 +19,12 @@ import{a as R,b as E,f as V}from"./chunk-WIBFXSYB.js";import{a as ce}from"./chun
19
19
  FROM documents
20
20
  WHERE language = 'vue' OR relative_path LIKE '%.vue'
21
21
  )
22
- `).run()})()}function We(e,t){return e.prepare(`
22
+ `).run()})()}function qe(e,t){return e.prepare(`
23
23
  SELECT relative_path AS relativePath
24
24
  FROM documents
25
25
  WHERE language = 'vue' OR relative_path LIKE '%.vue'
26
26
  ORDER BY relative_path
27
- `).all().map(r=>gr(t,r.relativePath))}function Ue(e,t){let{vueCore:n,ts:r,volarTs:i}=fr(e),{parsed:o,vueOptions:s}=mr(n,r,t),a=_e(t),u=n.createVueLanguagePlugin(r,o.options,s,h=>h),c=hr(n,r,u),g=yr(a,o),{languageServiceHost:l}=i.createLanguageServiceHost(r,r.sys,c,h=>h,g),p=r.createLanguageService(l);return{ts:r,language:c,languageService:p,fileNames:o.fileNames,configDir:a}}function fr(e){let t=ar(pr(Be(e,"package.json")).href);return{vueCore:Q(t,"@vue/language-core",e),ts:Q(t,"typescript",e),volarTs:Q(t,"@volar/typescript",e)}}function mr(e,t,n){let r=t.readConfigFile(n,t.sys.readFile);if(r.error||!r.config)throw new Error(`Failed to read ${n}`);let o=e.createParsedCommandLine(t,t.sys,n).vueOptions;return typeof e.createGlobalTypesWriter=="function"&&(o.globalTypesPath=e.createGlobalTypesWriter(o,t.sys.writeFile)),{parsed:t.parseJsonConfigFileContent(r.config,t.sys,_e(n),void 0,n,void 0,e.getAllExtensions(o).map(s=>({extension:s.slice(1),isMixedContent:!0,scriptKind:t.ScriptKind.Deferred}))),vueOptions:o}}function hr(e,t,n){let r={},i=e.createLanguage([n],new Map,o=>{if(!ur(o))return;let s=Z(o,"utf-8");r.current?.scripts.set(o,t.ScriptSnapshot.fromString(s),n.getLanguageId(o)??vr(o))});return r.current=i,i}function yr(e,t){return{getCurrentDirectory:()=>e,getCompilationSettings:()=>t.options,getScriptFileNames:()=>t.fileNames,getProjectReferences:()=>t.projectReferences,getProjectVersion:()=>"0"}}function 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 Je(e,t,n){let r=br(e);return i=>{let o=b(t,i.fileName),s=n.get(i.fileName);if(!s)return null;let a=n.positionAt(s,i.textSpan.start),u=r.get(o);if(!u)return null;let c=u.containingByLine.get(a.line);return c!==void 0?c:xr(u.starts,a.line,2)}}function br(e){let t=e.prepare(`
27
+ `).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
28
  SELECT
29
29
  d.relative_path AS relativePath,
30
30
  der.start_line AS startLine,
@@ -33,22 +33,22 @@ import{a as R,b as E,f as V}from"./chunk-WIBFXSYB.js";import{a as ce}from"./chun
33
33
  FROM defn_enclosing_ranges der
34
34
  JOIN documents d ON d.id = der.document_id
35
35
  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 xr(e,t,n){let r=0,i=e.length-1;for(;r<=i;){let s=Math.floor((r+i)/2);e[s].line<t?r=s+1:i=s-1}let o=null;for(let s of[i,r]){let a=e[s];if(!a)continue;let u=Math.abs(a.line-t);u>n||(!o||u<o.distance)&&(o={distance:u,symbolId:a.symbolId})}return o?.symbolId??null}function qe(e,t,n){let r=jr(t),i=e.prepare("SELECT id FROM global_symbols WHERE symbol = ?"),o=e.prepare(`
36
+ `).all(),n=new Map;for(let r of t){let i=n.get(r.relativePath);i||(i={containingByLine:new Map,starts:[]},n.set(r.relativePath,i)),i.starts.push({line:r.startLine,symbolId:r.symbolId});for(let o=r.startLine;o<=r.endLine;o++)i.containingByLine.set(o,r.symbolId)}for(let r of n.values())r.starts.sort((i,o)=>i.line-o.line);return n}function 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
37
  INSERT OR IGNORE INTO global_symbols (symbol, display_name, kind, documentation)
38
38
  VALUES (?, ?, ?, ?)
39
- `),s=0,a=new Map;return e.transaction(()=>{for(let c of n){let g=b(t,c),l=et(r.name,r.version,g);o.run(l,"default",7,`Vue component|${g}`);let p=wr(i,r,t,c);p&&(s++,a.set(c,p))}})(),{get(c){return a.get(c)??null},syntheticSymbols:s}}function Ge(e,t,n,r,i){return e.transaction(()=>(dr(e),Sr(e,t,n,r),Rr(e,i)))()}function Sr(e,t,n,r){let i=e.prepare("SELECT id FROM documents WHERE relative_path = ?"),o=e.prepare(`
39
+ `),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
40
  INSERT INTO chunks (document_id, chunk_index, start_line, end_line, occurrences)
41
41
  VALUES (?, ?, ?, ?, X'00')
42
42
  `),s=e.prepare(`
43
43
  INSERT OR IGNORE INTO mentions (chunk_id, symbol_id, role)
44
44
  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 He(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 ze(e){let t=new Set,n=[];for(let r of e){let i=Ke(r);t.has(i)||(t.add(i),n.push(r))}return n}function Ke(e){return[e.sourceFile,e.sourceLine,e.sourceStartChar,e.sourceEndChar,e.symbolId].join(":")}function Rr(e,t){let n=Ir(e,[...new Set(t.map(u=>u.sourceFile))]),r=e.prepare(`
45
+ `);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
46
  INSERT INTO chunks (document_id, chunk_index, start_line, end_line, occurrences)
47
47
  VALUES (?, ?, ?, ?, X'00')
48
48
  `),i=e.prepare(`
49
49
  INSERT OR IGNORE INTO mentions (chunk_id, symbol_id, role)
50
50
  VALUES (?, ?, 0)
51
- `),o=new Set,s=0,a=0;for(let u of t){let c=Ke(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*Xe(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 Ye(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 Pr(e,t){let n=0,r=e.lineStarts.length-1;for(;n<=r;){let o=Math.floor((n+r)/2);e.lineStarts[o]<=t?n=o+1:r=o-1}let i=Math.max(0,r);return{line:i,character:t-e.lineStarts[i]}}function Qe(e,t){return b(e,t).startsWith("node_modules/")}function b(e,t){return lr(e,t).replaceAll("\\","/")}function vr(e){switch(cr(e)){case".vue":return"vue";case".tsx":return"typescriptreact";case".ts":case".mts":case".cts":return"typescript";case".jsx":return"javascriptreact";case".js":case".mjs":case".cjs":return"javascript";case".json":return"json";default:return"typescript"}}function Ze(){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:kr(n)};return e.set(t,r),r}catch{return e.set(t,null),null}},positionAt:Pr}}function kr(e){let t=[0];for(let n=0;n<e.length;n++)e.charCodeAt(n)===10&&t.push(n+1);return t}function Ir(e,t){let n=new Map,r=500;for(let i=0;i<t.length;i+=r){let o=t.slice(i,i+r),s=e.prepare(`SELECT id, relative_path AS relativePath FROM documents WHERE relative_path IN (${o.map(()=>"?").join(",")})`).all(...o);for(let a of s)n.set(a.relativePath,a.id)}return n}function jr(e){try{let t=JSON.parse(Z(Be(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 wr(e,t,n,r){let i=b(n,r),o=et(t.name,t.version,i);return e.get(o)?.id??null}function et(e,t,n){let r=n.split("/").map(i=>`\`${i.replaceAll("`","")}\``).join("/");return`scip-vue npm ${e} ${t} ${r}/default.`}function tt(e){return{id:"vue-resolved-references",facts:["synthetic-symbol","source-mapped-occurrence","definition-mention","replacement-chunk","fingerprint-cache"],run:t=>Dr({projectRoot:t.projectRoot,dbPath:t.dbPath,tsconfig:e.tsconfig,onStatus:t.onStatus})}}function Mr(e){return y(x(),{projectRoot:e.projectRoot,dbPath:e.dbPath}),y(tt({tsconfig:e.tsconfig}),{projectRoot:e.projectRoot,dbPath:e.dbPath,onStatus:e.onStatus}).result}function Dr(e){let t=Tr(e.projectRoot,e.tsconfig);if(!Lr(t))throw new Error(`Vue tsconfig not found at ${t}`);let n=new Cr(e.dbPath);try{let r=We(n,e.projectRoot),i=Fr(Or(e.dbPath),"augment-vue-meta.json");return Pe({cachePath:i,readFingerprint:()=>Ar(n,e.projectRoot,e.tsconfig),compute:()=>Er({db:n,projectRoot:e.projectRoot,dbPath:e.dbPath,tsconfig:e.tsconfig,configPath:t,vueFiles:r,onStatus:e.onStatus}),onCacheHit:o=>e.onStatus?.(`Vue references unchanged; reused ${o.resolvedReferences} cached resolved references.`)})}finally{n.close()}}function Er(e){let t=qe(e.db,e.projectRoot,e.vueFiles),n=Vr(e,t),r=ze(n.occurrences),i=Ge(e.db,e.projectRoot,e.vueFiles,t,r),o={vueFiles:e.vueFiles.length,resolvedReferences:r.length,insertedMentions:i,skippedReferences:n.skippedReferences,syntheticSymbols:t.syntheticSymbols};return e.onStatus?.(`Resolved ${o.resolvedReferences} Vue references with Volar; inserted ${o.insertedMentions} mentions.`),o}function Vr(e,t){if(Ve(e.vueFiles))return Ae({projectRoot:e.projectRoot,dbPath:e.dbPath,tsconfig:e.tsconfig,vueFiles:e.vueFiles});let n=Nr({db:e.db,projectRoot:e.projectRoot,configPath:e.configPath,vueSymbolLookup:t});return $r({...n,vueFiles:n.context.fileNames.filter(r=>r.endsWith(".vue"))})}function Ar(e,t,n){let r=e.prepare(`
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
52
  SELECT
53
53
  (SELECT COUNT(*) FROM documents) AS documents,
54
54
  (SELECT COUNT(*) FROM global_symbols) AS symbols,
@@ -57,13 +57,13 @@ import{a as R,b as E,f as V}from"./chunk-WIBFXSYB.js";import{a as ce}from"./chun
57
57
  (SELECT COUNT(*) FROM defn_enclosing_ranges) AS ranges,
58
58
  (SELECT MAX(id) FROM chunks) AS maxChunkId,
59
59
  (SELECT MAX(id) FROM global_symbols) AS maxSymbolId
60
- `).get();return{version:2,tsconfig:n,files:P(t),db:r}}function Nr(e){let t=Ze();return{projectRoot:e.projectRoot,context:Ue(e.projectRoot,e.configPath),symbolLookup:Je(e.db,e.projectRoot,t),vueSymbolLookup:e.vueSymbolLookup,sourceReader:t}}function $r(e){let t=[],n=0,r=e.tasks??e.vueFiles.map(i=>({fileName:i,startOffset:0,endOffset:Number.POSITIVE_INFINITY,countFileSkip:!0}));for(let i of r){let o=_r(e,i);t.push(...o.occurrences),n+=o.skippedReferences}return{occurrences:t,skippedReferences:n}}function _r(e,t){let n=e.context.language.scripts.get(t.fileName),r=n?.generated?.languagePlugin.typescript?.getServiceScript(n.generated.root)?.code;if(!n||!r)return{occurrences:[],skippedReferences:t.countFileSkip?1:0};let i=e.sourceReader.get(t.fileName);if(!i)return{occurrences:[],skippedReferences:t.countFileSkip?1:0};let o=e.context.language.maps.get(r,n),s=b(e.projectRoot,t.fileName),a=[...Xe(i.text)],u={tokens:a.filter(c=>c.start>=t.startOffset&&c.start<t.endOffset),tokenByStart:new Map(a.map(c=>[c.start,c])),tokenTextCounts:Ur(a),processedStarts:new Set};return Br({...e,fileName:t.fileName,sourceInfo:i,sourceFile:s,map:o,tokenContext:u})}function Br(e){let t=[],n=0;for(let r of e.tokenContext.tokens){if(e.tokenContext.processedStarts.has(r.start))continue;let i=Ye(e.map,r.start);if(i===null)continue;let s=(e.context.languageService.getDefinitionAtPosition(e.fileName,i+1)??[]).find(u=>!Qe(e.projectRoot,u.fileName));if(!s){n++;continue}let a=He(s,e.symbolLookup,e.vueSymbolLookup,e.context,e.projectRoot);if(a===null){n++;continue}nt(t,e.sourceReader,e.sourceInfo,e.sourceFile,r,a),e.tokenContext.processedStarts.add(r.start),Wr(t,e,r,i,a)}return{occurrences:t,skippedReferences:n}}function Wr(e,t,n,r,i){if(!((t.tokenContext.tokenTextCounts.get(n.text)??0)<=1))for(let o of Jr(t.context.languageService,t.fileName,r+1,t.map,n,t.tokenContext.tokenByStart)){if(t.tokenContext.processedStarts.has(o))continue;let s=t.tokenContext.tokenByStart.get(o);s&&(nt(e,t.sourceReader,t.sourceInfo,t.sourceFile,s,i),t.tokenContext.processedStarts.add(o))}}function nt(e,t,n,r,i,o){let s=t.positionAt(n,i.start);e.push({sourceFile:r,sourceLine:s.line,sourceStartChar:s.character,sourceEndChar:s.character+i.text.length,symbolId:o})}function Ur(e){let t=new Map;for(let n of e)t.set(n.text,(t.get(n.text)??0)+1);return t}function Jr(e,t,n,r,i,o){let s=e.getDocumentHighlights?.(t,n,[t])??[],a=[];for(let u of s)if(u.fileName===t)for(let c of u.highlightSpans){let g=qr(r,c.textSpan.start,o,i.text);g!==null&&a.push(g)}return a}function qr(e,t,n,r){let i=n.get(t);if(i?.text===r)return i.start;let o=ee(e,t);if(o===null)return null;let s=n.get(o);return s?.text===r?s.start:null}async function Yo(e){let{projectRoot:t,maxHeapMb:n=8192,onStatus:r=console.log,skipAutoInstall:i=!1}=e,o=Zr(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=Pi(t,a,{pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:e.typescriptProjects,clojureConfigPath:e.clojureConfigPath}),c=await fi(m(f(o.outputDb),"index.lock"),{projectRoot:t,trigger:e.trigger,onStatus:r}),g=null;try{let l=ei({opts:e,paths:o,languages:a,fingerprint:u,start:s,onStatus:r});if(l)return l;await ai(i,r);let p=ti(o);return g=p.runDir,await ni({opts:e,languages:a,projectRoot:t,paths:o,tempPaths:p,fingerprint:u,start:s,maxHeapMb:n,skipAutoInstall:i,onStatus:r})}catch(l){throw dt(o.metaPath,oe({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 Zr(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 ei(e){if(e.opts.skipIfUnchanged===!1||!M(e.paths.outputScip)||!M(e.paths.outputDb)||!vi(e.paths.metaPath,e.fingerprint))return null;y(x(),{projectRoot:e.opts.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus});let t=Date.now()-e.start,n=oe({trigger:e.opts.trigger,result:"reused",start:e.start,languages:e.languages,skipped:[]});return dt(e.paths.metaPath,n),e.onStatus(`Index unchanged; reused existing SQLite index in ${(t/1e3).toFixed(1)}s`),{languages:e.languages,indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:t,reused:!0,skipped:[],lastRefresh:n}}function ti(e){let t=Kr(m(f(e.outputDb),"reindex-"));return{runDir:t,tempOutputScip:m(t,T(e.outputScip)),tempOutputDb:m(t,T(e.outputDb)),tempMetaPath:m(t,T(e.metaPath))}}async function ni(e){let t={...process.env,NODE_OPTIONS:`--max-old-space-size=${e.maxHeapMb}`},{indexedOutputs:n,skippedLanguages:r,reusedLanguages:i}=await ri(e,t);i.length>0&&e.onStatus(`Reused ${i.length} cached language shard(s): ${i.join(", ")}`);let o=ii(e,t,n,r),s=o.durationMs;return e.onStatus(`Done in ${(s/1e3).toFixed(1)}s`),{languages:n.map(a=>a.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:s,reused:!1,skipped:r,lastRefresh:o}}async function ri(e,t){let n=oi(e),r=new Set(n.map(c=>c.language));for(let c of r)e.onStatus(`Reusing cached ${c} SCIP shard (language inputs unchanged).`);let{preparedRuns:i,skippedLanguages:o}=ui({languages:e.languages.filter(c=>!r.has(c)),tempOutputScip:e.tempPaths.tempOutputScip,projectRoot:e.projectRoot,env:t,skipAutoInstall:e.skipAutoInstall,pnpmWorkspaces:e.opts.pnpmWorkspaces,typescriptProjectMode:e.opts.typescriptProjectMode,typescriptProjects:e.opts.typescriptProjects,clojureConfigPath:e.opts.clojureConfigPath,onStatus:e.onStatus}),s=await Te(i,e.projectRoot,e.onStatus,e.opts.indexerConcurrency),{indexedOutputs:a}=li(s,o),u=[...n,...a];return gi(u,o,e.languages,e.opts.allowPartial,e.onStatus),{indexedOutputs:u,skippedLanguages:o,reusedLanguages:[...r]}}function ii(e,t,n,r){si(e.paths.outputDb,n),pi(n,e.tempPaths.tempOutputScip,e.onStatus),di(e.tempPaths.tempOutputScip,e.tempPaths.tempOutputDb,t,e.onStatus),y(x(),{projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,onStatus:e.onStatus});let i=oe({trigger:e.opts.trigger,result:"rebuilt",start:e.start,languages:n.map(o=>o.language),skipped:[...r]});return pt(e.tempPaths.tempMetaPath,{version:3,status:r.length===0?"complete":"partial",updatedAt:new Date().toISOString(),fingerprint:e.fingerprint,languageFingerprints:ut(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}),Ri({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 oi(e){let t;try{t=JSON.parse(D(e.paths.metaPath,"utf-8"))}catch{return[]}if(t.version!==3||!t.languageFingerprints)return[];let n=[],r=ut(e.projectRoot,e.languages,{pnpmWorkspaces:e.opts.pnpmWorkspaces,typescriptProjectMode:e.opts.typescriptProjectMode,typescriptProjects:e.opts.typescriptProjects,clojureConfigPath:e.opts.clojureConfigPath});for(let i of e.languages){let o=gt(e.paths.outputDb,i);M(o)&&S(t.languageFingerprints[i])===S(r[i])&&n.push({language:i,scipPath:o})}return n}function si(e,t){for(let n of t){let r=gt(e,n.language);re(f(r),{recursive:!0}),n.scipPath!==r&&zr(n.scipPath,r)}}async function ai(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(Qr()==="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 ui(e){let t=[],n=[],r=e.languages.map((i,o)=>({language:i,scipPath:e.languages.length>1?at(e.tempOutputScip,i,o):e.tempOutputScip}));for(let{language:i,scipPath:o}of r){let s=ci({...e,language:i,scipPath:o});for(let a of s)"skipped"in a?st(n,a.skipped):t.push(a.prepared)}return{preparedRuns:t,skippedLanguages:n}}function ci(e){if(e.language!=="typescript"||e.typescriptProjectMode!=="workspace")return[te({...e,id:e.language,label:e.language,outputScipPath:e.scipPath})];let t=Ce(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:at(e.tempOutputScip,"typescript-project",r),outputScipPath:e.scipPath,pnpmWorkspaces:!1,projectPath:n})))}function te(e){let t=w(e.language),n=F(t),r=z(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 li(e,t){let n=new Map;for(let i of e)if(i.skipped)st(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)C(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 st(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 gi(e,t,n,r,i){if(e.length===0){let o=t.map(s=>` - ${s.language}: ${s.reason}`).join(`
60
+ `).get();return{version:2,tsconfig:n,files:P(t),db:r}}function 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(`
63
63
  `);throw new Error(`No language indexers ran successfully. Install at least one indexer for the languages in this project.
64
64
  `+o)}if(t.length!==0&&(i(`Indexed ${e.length} language output(s); skipped or incomplete: ${t.map(o=>o.language).join(", ")}.`),!r))throw new Error(`Failed to index all required languages; preserving the previous index. Pass --allow-partial to intentionally write an incomplete index.
65
65
  `+t.map(o=>` - ${o.language}: ${o.reason}`).join(`
66
- `))}function pi(e,t,n){e.length>1?(n(`Merging ${e.length} language indexes...`),C(e.map(r=>r.scipPath),t)):e[0].scipPath!==t&&k(e[0].scipPath,t)}function di(e,t,n,r){if(r("Converting to SQLite..."),!M(e))throw new Error(`SCIP index not found at ${e} after indexing`);try{let i=we(e);i.removedDefinitionOccurrences>0&&r(`Sanitized ${i.removedDefinitionOccurrences} invalid definition occurrences across ${i.touchedDocuments} documents before SQLite conversion.`);let o=E();if(!o)throw new Error("scip CLI is not available");Gr(o,["expt-convert","--output",t,e],{env:n,stdio:"pipe",maxBuffer:50*1024*1024})}catch(i){let o=i instanceof Error?i.message:String(i);throw new Error(`Failed to convert SCIP index to SQLite: ${o}`,{cause:i})}}function at(e,t,n){let r=Yr(e)||".scip",i=T(e,r);return m(f(e),`${i}.${n+1}.${t}${r}`)}async function fi(e,t){for(let n=0;n<2;n++){let r=mi(e,t);if(r)return r;let i=hi(e);if(i&&yi(t.trigger,i)){if(t.onStatus(`Manual reindex preempting watcher refresh started at ${i.startedAt}.`),!await xi(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&&!ie(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 mi(e,t){let n;try{n=Xr(e,"wx")}catch(i){if((typeof i=="object"&&i&&"code"in i?i.code:void 0)==="EEXIST")return null;throw i}let r={version:1,pid:process.pid,projectRoot:t.projectRoot,startedAt:new Date().toISOString(),trigger:t.trigger};return ot(n,JSON.stringify(r)+`
67
- `),()=>{try{Hr(n)}finally{I(e,{force:!0})}}}function hi(e){try{let t=JSON.parse(D(e,"utf-8"));return typeof t.pid!="number"||!Number.isInteger(t.pid)||t.pid<=0?null:{version:1,pid:t.pid,projectRoot:typeof t.projectRoot=="string"?t.projectRoot:f(e),startedAt:typeof t.startedAt=="string"?t.startedAt:"unknown",trigger:t.trigger}}catch{return null}}function yi(e,t){return e?.kind==="manual-cli"&&bi(t?.trigger)}function bi(e){return e?.kind==="watch-source"||e?.kind==="watch-git-head"||e?.kind==="watch-git-index"||e?.kind==="watch-git-state"}async function xi(e){return rt(e,"SIGTERM"),await it(e,2e3)?!0:(rt(e,"SIGKILL"),it(e,1e3))}function rt(e,t){try{process.kill(-e,t)}catch{try{process.kill(e,t)}catch{}}}async function it(e,t){let n=Date.now()+t;for(;Date.now()<n;){if(!ie(e))return!0;await Si(50)}return!ie(e)}function ie(e){try{return process.kill(e,0),!0}catch{return!1}}function Si(e){return new Promise(t=>setTimeout(t,e))}function Ri(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 Pi(e,t,n){return{version:2,languages:[...t].sort(),pnpmWorkspaces:lt(n),typescriptProjectMode:n.typescriptProjectMode??"single",typescriptProjects:_(n.typescriptProjects),clojureConfigPath:ct(n.clojureConfigPath),files:P(e)}}function ut(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"?ct(n.clojureConfigPath):void 0;return[r,{version:2,languages:[r],pnpmWorkspaces:r==="typescript"&&lt(n),...o,clojureConfigPath:s,files:P(e,{language:r,markerFiles:i})}]}))}function ct(e){return e?.trim()||void 0}function lt(e){return e.typescriptProjectMode!=="workspace"&&e.pnpmWorkspaces===!0}function gt(e,t){return m(f(e),"language-indexes",`${t}.scip`)}function vi(e,t){try{let n=JSON.parse(D(e,"utf-8"));return(n.version===2||n.version===3)&&n.status==="complete"&&S(n.fingerprint)===S(t)&&S([...n.indexedLanguages??[]].sort())===S(t.languages)}catch{return!1}}function pt(e,t){let n=`${e}.tmp-${process.pid}-${Date.now()}`;ot(n,`${JSON.stringify(t,null,2)}
68
- `),k(n,e)}function dt(e,t){try{let n=JSON.parse(D(e,"utf-8"));if(n.version!==2&&n.version!==3)return;pt(e,{...n,lastRefresh:t})}catch{}}function oe(e){return{trigger:e.trigger??{kind:"unknown"},result:e.result,startedAt:new Date(e.start).toISOString(),completedAt:new Date().toISOString(),durationMs:Date.now()-e.start,indexedLanguages:e.languages?[...e.languages]:void 0,skipped:e.skipped?[...e.skipped]:void 0,error:e.error}}function S(e){return JSON.stringify(e)}export{be as INDEXER_CONFIGS,ge as augmentAuxiliaryDocuments,Mr as augmentVueResolvedReferences,x as auxiliaryDocumentsAugmentationStage,F as describeIndexerBinary,A as detectLanguages,w as getIndexerConfig,K as getIndexerExecutionEnv,R as isBinaryAvailable,H as isIndexerInstalled,C as mergeScipFiles,xe as mergeScipIndexes,Yo as reindex,v as resolveIndexerBinary,z as resolveProjectLocalIndexerBinary,y as runPostIndexAugmentation,X as tryInstallIndexer,V as tryInstallScipCli,tt as vueResolvedReferencesAugmentationStage};
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};
69
69
  //# sourceMappingURL=reindex.js.map
@@ -8,7 +8,7 @@ This syntax summary is generated from the CLI command descriptors. Keep workflow
8
8
 
9
9
  | Command | Description | Options |
10
10
  |---|---|---|
11
- | `reindex` | Index the codebase and convert to SQLite | `-l, --language <lang>`<br>`--pnpm-workspaces`<br>`--force`<br>`--allow-partial`<br>`--indexer-concurrency <n>` |
11
+ | `reindex` | Index the codebase and convert to SQLite | `-l, --language <lang>`<br>`--pnpm-workspaces`<br>`--force`<br>`--allow-partial`<br>`--indexer-concurrency <n>`<br>`--json` |
12
12
  | `augment-sources` | Add source files skipped by upstream SCIP indexers to the SQLite documents table | - |
13
13
  | `augment-vue` | Add compiler-resolved Vue SFC references to the SQLite index using Volar | `--project <tsconfig>` |
14
14
 
@@ -104,7 +104,7 @@ This syntax summary is generated from the CLI command descriptors. Keep workflow
104
104
 
105
105
  | Command | Description | Options |
106
106
  |---|---|---|
107
- | `tla <operation> [spec]` | TLA+ model workflow: verify a model and mapping contract, scaffold a draft model from indexed code, generate a trace recorder, or check a recorded trace against the next-state relation | `--map <file>`<br>`--config <file>`<br>`--checker <mode>`<br>`--tla-tools <jar>`<br>`--apalache <binary>`<br>`--length <n>`<br>`--timeout-ms <n>`<br>`--trace <file>`<br>`--next <operator>`<br>`--allow-unknown`<br>`--out <path>`<br>`--module-name <name>`<br>`--force`<br>`--full`<br>`--json` |
107
+ | `tla <operation> [spec]` | TLA+ model workflow: verify a model and mapping contract, scaffold a draft model from indexed code, generate a trace recorder, or check a recorded trace against the next-state relation | `--map <file>`<br>`--config <file>`<br>`--checker <mode>`<br>`--tla-tools <jar>`<br>`--apalache <binary>`<br>`--length <n>`<br>`--timeout-ms <n>`<br>`--trace <file>`<br>`--next <operator>`<br>`--coverage`<br>`--allow-unknown`<br>`--out <path>`<br>`--module-name <name>`<br>`--force`<br>`--full`<br>`--json` |
108
108
 
109
109
  ### Planning
110
110
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scip-query",
3
- "version": "0.11.0",
3
+ "version": "0.12.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",
@@ -346,7 +346,7 @@
346
346
  "optionalDependencies": {
347
347
  "@sourcegraph/scip-typescript": "^0.4.0",
348
348
  "scip-python-plus": "^0.7.4",
349
- "scip-query-scip-windows": "0.11.0",
349
+ "scip-query-scip-windows": "0.12.0",
350
350
  "tree-sitter": "0.21.1",
351
351
  "tree-sitter-c": "0.23.2",
352
352
  "tree-sitter-c-sharp": "0.23.1",
@@ -372,5 +372,23 @@
372
372
  "typescript": "^5.7.0",
373
373
  "typescript-eslint": "^8.58.1",
374
374
  "vitest": "^3.0.0"
375
+ },
376
+ "allowScripts": {
377
+ "better-sqlite3@12.9.0": true,
378
+ "esbuild@0.27.7": true,
379
+ "fsevents@2.3.3": true,
380
+ "tree-sitter@0.21.1": true,
381
+ "tree-sitter-c@0.23.2": true,
382
+ "tree-sitter-c-sharp@0.23.1": true,
383
+ "tree-sitter-cpp@0.23.4": true,
384
+ "tree-sitter-java@0.23.5": true,
385
+ "tree-sitter-javascript@0.23.1": true,
386
+ "tree-sitter-kotlin@0.3.8": true,
387
+ "tree-sitter-php@0.23.12": true,
388
+ "tree-sitter-python@0.23.4": true,
389
+ "tree-sitter-ruby@0.23.1": true,
390
+ "tree-sitter-rust@0.23.1": true,
391
+ "tree-sitter-scala@0.24.0": true,
392
+ "tree-sitter-typescript@0.23.2": true
375
393
  }
376
394
  }
@@ -40,14 +40,14 @@ Use this shortlist first. Open [`../_shared/SKILL.md`](../_shared/SKILL.md) only
40
40
 
41
41
  Model the part with the most dangerous interleavings — retries, concurrency, partial failure, money, state machines with guards. Never model a linear happy path: a model that cannot meaningfully fail verifies nothing. If the state space would exceed roughly a million states, the model is too concrete; collapse data you never branch on and replace unbounded values with small symbolic sets. `scaffold` requires the target file to own mutable module-level state (a `let`/const plus a writer function) or, failing that, a class whose instance fields a method of that same class writes; a file of pure functions or constants is rejected — pick the file that holds the state, not the file that only computes over it.
42
42
 
43
- **Known boundary: class fields on files with any indexed method are usually invisible to `scaffold`.** The write scanner can find `this.field = ...` writes fine, but the class-field fallback only ever sees candidates that `getDefinitionsForFile` actually returns and that catalog (`definition-catalog.ts`/`symbol-row-policy.ts`) deliberately drops class-member fallback rows whenever the file has any other primary-indexed (enclosing-range) definition, which any class with a constructor or a named method always has. So a concurrency class like a lock or connection pool exactly the shape this skill most wants to model will almost always report "no mutable state discovered", not because the state isn't there but because the shared definition catalog hides it one layer below scaffold. When you hit this: model by hand from `plan-context`/`trace` evidence instead of via `scaffold`, or narrow the target file so the class in question is the only indexed definition in it. Widening the catalog itself is out of scope for this skill's tooling it's a shared primitive nearly every other command depends on.
43
+ **Known boundary: files where the indexer emitted no member rows at all are invisible to `scaffold`.** `scaffold` calls `getDefinitionsForFile(db, file, { includeClassMemberFallbacks: true })`, which surfaces class-member fallback rows (`ClassName#field.` symbols with a real definition mention) alongside primary rows even when the file has other primary-indexed definitions a concurrency class like a lock, connection pool, or watcher (verified live: `Watcher` in `src/runtime/watch.ts` 26 instance fields and 10 state-writing actions discovered, previously 0) now scaffolds correctly. What remains genuinely invisible is narrower: a file where the indexer emitted **no** member row for a class at all — neither a primary `defn_enclosing_ranges` row nor a role=1 definition mention has nothing for either query to return, and `scaffold` reports "no mutable state discovered" because there is nothing in the index to find. When you hit that: model by hand from `plan-context`/`trace` evidence instead of via `scaffold`. See `docs/plans/2026-07-02-catalog-class-members.md` for the K3 survey of whether other commands (`members`, `refs`, `trace`, `health`, `dead`) should opt in too no decision has been made there yet, so this remains scaffold-only.
44
44
 
45
45
  ## Loop
46
46
 
47
47
  1. Explore the target with `scip-query plan-context <target>`, `system`, `trace`, `call-graph`, and `dataflow` until state and transitions are concrete.
48
48
  2. Run `scip-query tla scaffold <file>` to generate the draft spec, config, and mapping (`--out` must stay inside the project root). Resolve every `TODO` it emits: guards, domains, initial values. The scaffold derives _what_ changes; you supply _when_ it may. TRIAGE the output first: if the discovered variables are mostly constants and the system's real state lives in files or a database (locks, caches, published artifacts), keep the mapping referents but discard the scaffolded variable set — hand-model the protocol's conceptual state and bind it with `resource` aliases instead. `tla verify` does not detect unfilled `TODO`s and will report PASS on a placeholder model — grep the spec for `TODO` before trusting a green run.
49
49
  3. Strengthen the model per the quality rules below.
50
- 4. Run `scip-query tla verify <spec> --map <map> --config <cfg>`. Read the Proof line: every waiver must carry a reason you would defend in review.
50
+ 4. Run `scip-query tla verify <spec> --map <map> --config <cfg>`. Read the Proof line: every waiver must carry a reason you would defend in review. `--map` is usually unnecessary: if no `Spec.scip-tla.json` sits next to `Spec.tla`, `tla verify` scans sibling `*.scip-tla.json` files for one whose `module` field names this spec (the project-relative `.tla` path, bare filename, or the TLA `MODULE` identifier are all accepted) and uses it automatically, printing `(matched by module field)` — this is what makes bare `tla verify Foo.tla` work even when the only mapping on disk is named `FooHardened.scip-tla.json`. Two or more mappings naming the same module is a hard error listing every candidate; pass `--map` explicitly to disambiguate.
51
51
  5. Wire the recorder from `scip-query tla instrument`, run the existing tests with `SCIP_TLA_TRACE=<path>`, then run `scip-query tla trace-check <spec> --trace <path>`. Acceptance means the code's observed behavior is a behavior of the model; divergence names the step to investigate. Modeling a fix-vs-regression pair as two named `Next` relations in one spec (e.g. `NextCurrent`/`NextVulnerable`)? Pass `--next <operator>` to pick which one the trace must satisfy — the harness defaults to a bare `Next`, which such specs deliberately don't define.
52
52
  6. Classify every finding as code bug, model bug, mapping bug, insufficient trace/alias evidence, or accepted non-modeled behavior.
53
53
  7. Patch code, model, or mapping and rerun until only explicitly waived uncertainty remains.
@@ -88,6 +88,11 @@ A regression model is a small TLA+ module or checker config derived from a count
88
88
  "aliases": ["pid"],
89
89
  "resource": { "path": "lockPath" }
90
90
  },
91
+ "status": {
92
+ "code": ["src/queue/lock.ts/LockMetadata#lifecycleStage"],
93
+ "aliases": ["lifecycleStage"],
94
+ "selfAlias": false
95
+ },
91
96
  "phase": {
92
97
  "code": ["src/queue/lock.ts/__phase_no_stored_field__"],
93
98
  "aliases": ["__phase_unmatchable__"],
@@ -107,12 +112,18 @@ A regression model is a small TLA+ module or checker config derived from a count
107
112
  }
108
113
  ```
109
114
 
110
- `code` entries must resolve through `scip-query trace`; variables must map to value-like symbols (a const, let, field, or property holding runtime state — never a type). Waivers are per-fact and require a reason; blanket `allowUnknown` is legacy.
115
+ `code` entries must resolve through `scip-query trace`; variables must map to value-like symbols (a const, let, field, or property holding runtime state — never a type). Waivers are per-fact and require a reason; blanket `allowUnknown` is legacy. Waivers cover write facts symmetrically with reads: `actions.<name>.waive.writes` exempts `model-code-write`, `undeclared-write`, and `missing-write-evidence` findings the same way `waive.reads` exempts the read-side equivalents, and a variable-level `waive` on `actions.<name>.writes` also exempts the corresponding `model-mapping-write` mismatch against the SANY-derived model text. A waived write still shows up in the Proof line's waiver ledger with its reason — it never silently vanishes.
116
+
117
+ An action `code` entry can narrow itself to a line window, `"file#function@L<start>-L<end>"` (C3) — when several guard/branch actions share one function, whole-function `code` forces every sibling to claim every write in it; a window scopes fact collection to that sub-range instead, so each branch action attributes only its own write. The window must fall entirely inside the referent's actual resolved span or `tla verify` reports a hard `invalid-line-window` error naming the file, function, and actual span — never a silent clamp back to the whole function. Windows are line-number-brittle by design: a later refactor that shifts lines is caught loudly (the containment check plus `tla verify`'s referent resolution), not silently mis-scanned.
111
118
 
112
119
  `resource` binds a variable to filesystem state — a lock file, a published artifact — anything the model treats as owned state but that code only touches through path-taking calls, never a plain assignment. The conformance scanner classifies `writeFileSync`/`rmSync`/`renameSync`/`mkdirSync`/`unlinkSync` calls whose first argument's text contains the declared `path` as writes of the variable, and `readFileSync`/`existsSync`/`statSync` calls the same way as reads. The match is textual containment, not a resolved value — evidence tier stays `static-action`, and a resource-bound variable still needs a value-like `code` referent for the kind check.
113
120
 
114
121
  `statements` (Q2) binds a variable to SQL-backed state — prepared statements, table rows behind `db.prepare(...)`/`.exec(...)`/tagged templates. Each entry is `{ "pattern": "<substring or regex>" }`, compiled as a RegExp. Any call expression argument whose static string text (a string literal, or the static fragments of a template literal — `${...}` interpolations excluded) matches `pattern` is classified by its leading SQL verb: `INSERT`/`UPDATE`/`DELETE`/`REPLACE` is a write, `SELECT` is a read. Matching is not restricted to a callee allowlist (SQL APIs vary too much) — classification comes entirely from the matched text's leading verb. Two variables sharing a `statements` pattern is a mapping-load error, same as a shared `resource` path. Evidence tier stays `static-action`. Dynamic SQL built by string concatenation has no static text to match and still falls through to a waiver.
115
122
 
123
+ `ormCalls` (C1) binds a variable to ORM-backed state when there is no literal SQL text to match at all — Drizzle-style query builders (`db.update(t).set(...)`, `db.insert(t).values(...)`, `db.select().from(t)`, `db.delete(t)`). Each entry is `{ "table": "<identifier>", "methods"?: [...] }`. A call chain whose own method name is in the write set (`update`/`insert`/`delete` by default) or read set (`select`/`query`/`findFirst`/`findMany` by default) AND whose own table argument (or, for `select`, the `.from(t)` chain segment) names `table` attributes to the variable — matching never looks at the receiver (`db`, `tx`, ...), only the method + table-arg shape. `methods` narrows the effective set to a subset of that seven-name vocabulary; an unrecognized name fails to load. Two variables binding the same `(table, method)` pair is a mapping-load error, same category as a shared `statements` pattern — but a write-only binding and a read-only binding on the same table do not collide. Evidence tier stays `static-action`.
124
+
125
+ `variables.<v>.selfAlias: false` opts out of the automatic self-name alias (default `true`, fully backward compatible): normally a variable's own TLA+ name is always added to its alias list, which means an object-literal key or identifier that merely echoes the variable's name — but means something unrelated elsewhere in scope — becomes an unavoidable false write/read attribution. Set it `false` and give a precise, unambiguous alias instead (as `status` does above, aliased only to `lifecycleStage`); a `selfAlias: false` variable with no other alias, no `resource`, no `statements`, and no `waive` is a load error, since it would otherwise be silently unattributable.
126
+
116
127
  `variables.<v>.waive: {reason}` exempts that one variable's `missing-referent`/`invalid-referent-kind` findings — for state that genuinely has no code twin (a pure control-flow position, a derived decision, a value observable only through `process.exitCode`). It does not exempt read/write facts; those stay on the action's own `waive`. Prefer this over the old workaround of citing an unrelated real symbol just to satisfy the value-like-kind check — name a referent that plainly does not resolve (or does resolve but to the wrong kind) and waive it honestly; a reader should never have to guess that a `code[]` entry is a decoy.
117
128
 
118
129
  Top-level `"unmappedWriteScope": "actions" | "scope-files"` (default `"scope-files"`) controls how strictly `scope` is enforced: the default requires every function anywhere in `scope` that touches a modeled variable to be mapped as an action, or its write is a hard `unmapped-write` error. Set `"actions"` to opt out of that whole-file sweep when `scope` legitimately contains code the mapping was never meant to cover in full — only the per-action write/read checks still run.
@@ -122,10 +133,11 @@ Top-level `"init": { "codeRefs": ["file#function", ...], "waive"?: {"reason": ..
122
133
  ## Mapping Discipline
123
134
 
124
135
  - **Alias selection is the sharpest knife.** Never alias a variable to a ubiquitous local identifier (`connection`, `result`, `data`) — every function touching that local gets misattributed across actions. For state with no code twin, use a deliberately unmatchable alias (e.g. `evidenceRowsModelOnly`) so the static layer neither proves nor pollutes, and let the reasoned waiver carry the fact.
125
- - **Know the three state backings.** Program variables: normal aliases. Filesystem-backed state (locks, published artifacts): `resource: { "path": ... }` bindings make fs calls provable. Database/SQL-backed state (prepared statements, table rows): `statements: [{ "pattern": ... }]` bindings make it provable too (Q2)a call argument's static SQL text matching `pattern` is classified as a write or read by its leading verb. Only genuinely dynamic SQL (built by string concatenation, no static text to match) still needs a waiver naming the residual class; never fake attribution.
136
+ - **Turn off the forced self-alias when the variable's own name is a common word.** A TLA+ variable named `status`, `phase`, or `state` gets its own name auto-included as an alias by defaultand object literals elsewhere in scope (`{ status: 'ok' }` in an unrelated response shape) will match it. If the variable's own name is common enough to collide, set `selfAlias: false` and give a precise alias that names the actual stored field instead.
137
+ - **Know the four state backings.** Program variables: normal aliases. Filesystem-backed state (locks, published artifacts): `resource: { "path": ... }` bindings make fs calls provable. SQL-backed state (prepared statements, table rows behind literal SQL text): `statements: [{ "pattern": ... }]` bindings make it provable too (Q2) — a call argument's static SQL text matching `pattern` is classified as a write or read by its leading verb. ORM-backed state with no literal SQL to match (Drizzle-style query builders): `ormCalls: [{ "table": ... }]` bindings (C1) classify by the call chain's own method + table-arg shape instead. Only genuinely dynamic SQL (built by string concatenation, no static text to match) or an ORM shape the method/table matcher cannot see still needs a waiver naming the residual class; never fake attribution.
126
138
  - **Lazy initialization is Init, not an action.** A factory that lazily builds state corresponds to the model's `Init`. Top-level `"init": { "codeRefs": ["file#function", ...] }` (Q3) binds it: writes statically found inside an Init referent are Init-attributed and excluded from `unmapped-write` findings without needing `unmappedWriteScope: "actions"` as a whole-file workaround. `init.codeRefs` must not overlap any action's `code` referents — map the factory to `init`, never to an action.
127
139
  - **Design for traces early.** The trace encoder pins scalar (and scalar-array) variables only; a model whose state is all functions and tuple-sets cannot be trace-validated. If trace-check matters for the slice, add scalar projection variables (counts, last outcomes, a phase) alongside the structured state.
128
- - **Trace until covered.** One accepted trace proves one path, not the mapping. Record traces until every Current action with a code twin is exercised by at least one accepted trace, or is explicitly classified with why it cannot be (unreachable without fault injection, environment-gated, model-only). An action no trace ever exercises is a conformance claim resting on static mapping alone.
140
+ - **Trace until covered.** One accepted trace proves one path, not the mapping. Record traces until every Current action with a code twin is exercised by at least one accepted trace, or is explicitly classified with why it cannot be (unreachable without fault injection, environment-gated, model-only). An action no trace ever exercises is a conformance claim resting on static mapping alone. `tla trace-check ... --coverage` (C2) mechanizes the check: it reports steps-exercised-per-action, counted from accepted steps only (a step that never proved a legal transition — checker unavailable, or past the divergence point of a rejected trace — does not count), and names every action still unexercised. `--trace` is repeatable (merged and deduped with the mapping's own `traces` list) so recording another trace to cover a gap is additive, not a rewrite. Coverage is informational — it does not change `trace-check`'s exit code — so it never substitutes for actually closing the gap.
129
141
 
130
142
  ## Accuracy Rules
131
143
 
@@ -1,2 +0,0 @@
1
- import{b as r}from"./chunk-XHWLNQVZ.js";import{k as e}from"./chunk-R3JY4EZ4.js";function l(t,s){let o=r(t,s);return e(t,o).map(({relativePath:n,...a})=>a)}export{l as a};
2
- //# sourceMappingURL=chunk-2VSDXOG5.js.map