scip-query 0.19.0 → 0.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/augment-vue-worker.js +1 -1
- package/dist/{chunk-YHYTDWFT.js → chunk-24ET4VLC.js} +2 -2
- package/dist/{chunk-IXORBCMR.js → chunk-2NA6TYP4.js} +2 -2
- package/dist/{chunk-XKWEMFHP.js → chunk-2WCXKANA.js} +2 -2
- package/dist/{chunk-GJ3FR5WG.js → chunk-34MLC6UI.js} +2 -2
- package/dist/{chunk-PAZFJMXB.js → chunk-3WLRW5TC.js} +2 -2
- package/dist/{chunk-EZHARAL4.js → chunk-4BU54UJG.js} +2 -2
- package/dist/{chunk-XTSVYYAL.js → chunk-4CZJ4YJB.js} +2 -2
- package/dist/{chunk-TCVRJ56J.js → chunk-4FMT4HPC.js} +2 -2
- package/dist/{chunk-7FG5M53V.js → chunk-53SUJOJA.js} +2 -2
- package/dist/{chunk-YBAC3RON.js → chunk-5GOBZI34.js} +2 -2
- package/dist/{chunk-X36LKKVG.js → chunk-5OZCNAVM.js} +2 -2
- package/dist/{chunk-FMC3BI4I.js → chunk-5TEUKVSM.js} +2 -2
- package/dist/{chunk-WT7TOU2C.js → chunk-5W2VAEVR.js} +2 -2
- package/dist/{chunk-AWSRND4W.js → chunk-63P42UR6.js} +2 -2
- package/dist/{chunk-GNJHHPZE.js → chunk-64QITTX7.js} +2 -2
- package/dist/{chunk-XPYXEEDO.js → chunk-6O5JOS7T.js} +2 -2
- package/dist/{chunk-X65VYV2S.js → chunk-6PKO2TNZ.js} +2 -2
- package/dist/{chunk-X3OOU7CF.js → chunk-7SGOWD2Y.js} +2 -2
- package/dist/{chunk-ZXWFN7CK.js → chunk-7TJJY2C3.js} +2 -2
- package/dist/{chunk-OGHGTD6Z.js → chunk-AEM24WSF.js} +2 -2
- package/dist/{chunk-IWK562KR.js → chunk-AGTATREV.js} +2 -2
- package/dist/{chunk-SATRCB5O.js → chunk-AOSFSYEA.js} +2 -2
- package/dist/{chunk-3OSRXJKK.js → chunk-APLNTJPJ.js} +2 -2
- package/dist/{chunk-TDGCALH6.js → chunk-AYRHVJXW.js} +2 -2
- package/dist/{chunk-AM2LGOEX.js → chunk-B2WQKQKP.js} +2 -2
- package/dist/{chunk-F5L7WEZF.js → chunk-BBBKPOIT.js} +2 -2
- package/dist/{chunk-2FAJTZSX.js → chunk-BCMOTIB6.js} +2 -2
- package/dist/{chunk-RJLU7IMR.js → chunk-BMTBVMA3.js} +2 -2
- package/dist/{chunk-JFGUBZWE.js → chunk-C3KCSAQ4.js} +2 -2
- package/dist/{chunk-FLIF3JWA.js → chunk-CAKPEQZB.js} +2 -2
- package/dist/{chunk-PKAPOFF5.js → chunk-CIYUFF24.js} +2 -2
- package/dist/{chunk-7EI4MU5A.js → chunk-CKFMZE77.js} +2 -2
- package/dist/{chunk-A45K6VUK.js → chunk-DCDOGW32.js} +2 -2
- package/dist/{chunk-4ZCNFENR.js → chunk-DFQNE73Y.js} +2 -2
- package/dist/{chunk-J3U47L4Q.js → chunk-DO775SYA.js} +2 -2
- package/dist/{chunk-NEG77KKH.js → chunk-DRH3AD7W.js} +2 -2
- package/dist/{chunk-UVMME4FI.js → chunk-DZXFZAZO.js} +2 -2
- package/dist/{chunk-GMZYT44R.js → chunk-E3KWOHH7.js} +2 -2
- package/dist/{chunk-F334Z5UA.js → chunk-EMIIOOTM.js} +2 -2
- package/dist/{chunk-GBB2RUDN.js → chunk-ESNRT7QN.js} +130 -130
- package/dist/{chunk-RIGY5DDE.js → chunk-FB6IKAKZ.js} +2 -2
- package/dist/{chunk-BGUYAA3Q.js → chunk-FBUNGRKI.js} +2 -2
- package/dist/{chunk-M2TRDR25.js → chunk-FC5K7T35.js} +1 -1
- package/dist/{chunk-4ZHJAHLE.js → chunk-FHLYJVXF.js} +2 -2
- package/dist/{chunk-KWBA6FDD.js → chunk-FRXB74RQ.js} +2 -2
- package/dist/{chunk-BYPVNKJT.js → chunk-FTRNGQGR.js} +2 -2
- package/dist/{chunk-54UYBTZW.js → chunk-FUFNRZFJ.js} +2 -2
- package/dist/{chunk-QNMOZ3CJ.js → chunk-GAE7WCBK.js} +2 -2
- package/dist/{chunk-547VY366.js → chunk-GIHVWNKQ.js} +2 -2
- package/dist/{chunk-AEDB4WXE.js → chunk-HCS5LB6U.js} +2 -2
- package/dist/{chunk-UXOVHGT6.js → chunk-HFBNIIZX.js} +2 -2
- package/dist/{chunk-JHK2DMUQ.js → chunk-HGFDYOVB.js} +1 -1
- package/dist/{chunk-6SHX42QQ.js → chunk-IOOCKVUA.js} +2 -2
- package/dist/{chunk-XDVT7QPG.js → chunk-J4MYRIYT.js} +2 -2
- package/dist/{chunk-TAB7AWKO.js → chunk-J5XJWCB3.js} +2 -2
- package/dist/{chunk-PXJIEMND.js → chunk-JBZXJXIS.js} +2 -2
- package/dist/{chunk-UJL3N6TC.js → chunk-JJZRS2OP.js} +2 -2
- package/dist/chunk-KC2IFAAU.js +3 -0
- package/dist/{chunk-4XTPZ5CR.js → chunk-KMOMNTB4.js} +2 -2
- package/dist/{chunk-YYR7ADNB.js → chunk-KMUFGAIK.js} +2 -2
- package/dist/{chunk-DWN7QDTV.js → chunk-LF5CIKWZ.js} +2 -2
- package/dist/{chunk-ZL5Y23AJ.js → chunk-LM72NQ7T.js} +1 -1
- package/dist/{chunk-3KQOIXLO.js → chunk-LQUDSHLB.js} +2 -2
- package/dist/{chunk-VV5WJLRO.js → chunk-MP43RX4O.js} +1 -1
- package/dist/{chunk-D5OXYOJP.js → chunk-MQ2B33LQ.js} +1 -1
- package/dist/{chunk-EZGT3NJX.js → chunk-NTOBQK5H.js} +2 -2
- package/dist/{chunk-TOYQTO44.js → chunk-OLG2YPLS.js} +2 -2
- package/dist/{chunk-J65FQLDL.js → chunk-OOUJBAKJ.js} +2 -2
- package/dist/{chunk-PBADFBRR.js → chunk-OQ6TCHBB.js} +2 -2
- package/dist/{chunk-BOXAKNN6.js → chunk-PNESKY2Z.js} +2 -2
- package/dist/{chunk-TDZXQAH7.js → chunk-PYMZU5EG.js} +2 -2
- package/dist/{chunk-HOXI4F5I.js → chunk-Q2WEWIKX.js} +2 -2
- package/dist/{chunk-DQIJMKNE.js → chunk-QHKXGMOI.js} +2 -2
- package/dist/{chunk-MTFHE7ZO.js → chunk-RPEA7P5Z.js} +2 -2
- package/dist/{chunk-DV6B262O.js → chunk-SJ6XSCG7.js} +2 -2
- package/dist/{chunk-LJD7V7UO.js → chunk-SSXEYWN3.js} +2 -2
- package/dist/{chunk-XESK6725.js → chunk-SYGAA54M.js} +2 -2
- package/dist/{chunk-TC3X33N6.js → chunk-TYEGFDOP.js} +2 -2
- package/dist/chunk-UJKZQLDB.js +2 -0
- package/dist/{chunk-QB5WSOTY.js → chunk-US44MEVU.js} +2 -2
- package/dist/{chunk-2ZNZSNVW.js → chunk-V5WBVF6K.js} +2 -2
- package/dist/{chunk-S65OEY2G.js → chunk-V7J4A3AH.js} +2 -2
- package/dist/{chunk-J6BR4MD6.js → chunk-VIKEPD4D.js} +2 -2
- package/dist/{chunk-XDSB47KO.js → chunk-WAU7HVDI.js} +2 -2
- package/dist/{chunk-T5CSWYAZ.js → chunk-WCZAABYF.js} +2 -2
- package/dist/{chunk-KD6TPIXM.js → chunk-WFRET75Z.js} +2 -2
- package/dist/chunk-WWCZCH7W.js +3 -0
- package/dist/{chunk-G6RQVDTI.js → chunk-XCPE3G75.js} +2 -2
- package/dist/{chunk-QN67MWDU.js → chunk-XYBNOILR.js} +2 -2
- package/dist/{chunk-MFBXBLHA.js → chunk-XZXUMGAA.js} +2 -2
- package/dist/{chunk-QHOUNTDZ.js → chunk-YCSTKIYU.js} +2 -2
- package/dist/{chunk-ZNSLF5AC.js → chunk-YGQBJUS6.js} +2 -2
- package/dist/{chunk-6DHPQS72.js → chunk-YILKXTIY.js} +2 -2
- package/dist/{chunk-G6QQCX45.js → chunk-ZJGZCBYT.js} +2 -2
- package/dist/{chunk-MDDF67O2.js → chunk-ZNK6K3LB.js} +2 -2
- package/dist/cli.js +1 -1
- package/dist/{command-descriptors-SWFWGIFK.js → command-descriptors-3EJHQLQZ.js} +55 -55
- package/dist/direct-navigation-C2A44KFT.js +3 -0
- package/dist/index.js +1 -1
- package/dist/queries/affected.js +1 -1
- package/dist/queries/architecture.js +1 -1
- package/dist/queries/bottlenecks.js +1 -1
- package/dist/queries/by-kind.js +1 -1
- package/dist/queries/call-graph.js +1 -1
- package/dist/queries/change-surface.js +1 -1
- package/dist/queries/cleanup-plan.js +1 -1
- package/dist/queries/co-change.js +1 -1
- package/dist/queries/code.js +1 -1
- package/dist/queries/complexity-hotspots.js +1 -1
- package/dist/queries/complexity.js +1 -1
- package/dist/queries/convergence.js +1 -1
- package/dist/queries/coupling.js +1 -1
- package/dist/queries/cycles.js +1 -1
- package/dist/queries/dataflow.js +1 -1
- package/dist/queries/dead.js +1 -1
- package/dist/queries/decorative-checkers.js +1 -1
- package/dist/queries/deep-chains.js +1 -1
- package/dist/queries/deps.js +1 -1
- package/dist/queries/diff-gate.js +1 -1
- package/dist/queries/diff-impact.js +1 -1
- package/dist/queries/doc-drift.js +1 -1
- package/dist/queries/drift.js +1 -1
- package/dist/queries/duplicate-bodies.js +1 -1
- package/dist/queries/extract-candidates.js +1 -1
- package/dist/queries/fan.js +1 -1
- package/dist/queries/health.js +1 -1
- package/dist/queries/hierarchy.js +1 -1
- package/dist/queries/hotspots.js +1 -1
- package/dist/queries/imports.js +1 -1
- package/dist/queries/incomplete-migration.js +1 -1
- package/dist/queries/index.js +1 -1
- package/dist/queries/isolated.js +1 -1
- package/dist/queries/locality-candidates.js +1 -1
- package/dist/queries/members.js +1 -1
- package/dist/queries/methods.js +1 -1
- package/dist/queries/not-implemented.js +1 -1
- package/dist/queries/outline.js +1 -1
- package/dist/queries/passthrough-candidates.js +1 -1
- package/dist/queries/plan-context.js +1 -1
- package/dist/queries/react-component-duplicates.js +1 -1
- package/dist/queries/react-hook-candidates.js +1 -1
- package/dist/queries/react-large-component-pressure.js +1 -1
- package/dist/queries/recent-duplicates.js +1 -1
- package/dist/queries/redundant-reexports.js +1 -1
- package/dist/queries/refs.js +1 -1
- package/dist/queries/self-audit.js +1 -1
- package/dist/queries/similar-chains.js +1 -1
- package/dist/queries/similar-files.js +1 -1
- package/dist/queries/similar-signatures.js +1 -1
- package/dist/queries/similar.js +1 -1
- package/dist/queries/slice.js +1 -1
- package/dist/queries/stale-abstractions.js +1 -1
- package/dist/queries/surface.js +1 -1
- package/dist/queries/symbols.js +1 -1
- package/dist/queries/system.js +1 -1
- package/dist/queries/test-quality.js +1 -1
- package/dist/queries/trace.js +1 -1
- package/dist/queries/twin-ab.js +1 -1
- package/dist/queries/twin-drift.js +1 -1
- package/dist/queries/unused-imports.js +1 -1
- package/dist/queries/unused-params.js +1 -1
- package/dist/queries/vue-component-duplicates.js +1 -1
- package/dist/queries/vue-composable-candidates.js +1 -1
- package/dist/queries/vue-large-view-pressure.js +1 -1
- package/dist/queries/wrapper-candidates.js +1 -1
- package/dist/reindex-worker.js +5 -5
- package/dist/reindex.js +15 -15
- package/dist/runtime.js +1 -1
- package/dist/rust-semantic-session-server.js +1 -1
- package/dist/rust-semantic-session-worker.js +1 -1
- package/dist/rust-semantic-worker.js +1 -1
- package/dist/watch-server.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-42QYU6FD.js +0 -3
- package/dist/chunk-AERYQJ52.js +0 -3
- package/dist/chunk-OYYZLJVT.js +0 -2
- package/dist/direct-navigation-RKMPBXMI.js +0 -3
package/dist/runtime.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{b as O,c as D,d as N,i as m}from"./chunk-
|
|
1
|
+
import{b as O,c as D,d as N,i as m}from"./chunk-IOOCKVUA.js";import{a as b}from"./chunk-YZXV3CU3.js";import{e as f,f as x}from"./chunk-LM72NQ7T.js";import{readFileSync as G,writeFileSync as F,existsSync as P}from"fs";import{isAbsolute as ue,join as R,relative as pe,resolve as he}from"path";var g=".scipquery.json",k=250,j=0,E=10*6e4,W={enabled:!1,debounceMs:k,cooldownMs:j,gitPollMs:2e3,idleTimeoutMs:E,autoRefresh:!0,ignore:[]},U=["typescript","javascript","java","scala","kotlin","rust","python","ruby","go","cpp","c","csharp","vb","dart","php","clojure"];var de=new Set(U);function y(s){let e=R(s,g);if(!P(e))return{};try{let t=G(e,"utf-8");return JSON.parse(t)}catch(t){let r=t instanceof Error?t.message:String(t);throw t instanceof SyntaxError?new Error(`invalid ${g} at ${e}: ${r}`,{cause:t}):new Error(`unable to read ${g} at ${e}: ${r}`,{cause:t})}}function T(s){return{...W,...s.watch}}function q(s,e){let t=R(s,g);return P(t)||F(t,JSON.stringify({languages:e,watch:{enabled:!0,debounceMs:k,cooldownMs:j,gitPollMs:2e3,idleTimeoutMs:E,autoRefresh:!0}},null,2)+`
|
|
2
2
|
`),t}import{fork as L}from"child_process";import{statSync as Y}from"fs";import{isAbsolute as K,join as B,relative as H}from"path";import{watch as z}from"chokidar";import X from"ignore";var S=class{projectRoot;config;watchConfig;languages;pnpmWorkspaces;typescriptProjectMode;typescriptProjects;clojureConfigPath;indexerConcurrency;onStatus;onReindexComplete;onError;status={state:"idle"};debounceTimer=null;cooldownTimer=null;dirty=!1;changedFiles=0;pendingTrigger=null;reindexInFlight=!1;lastReindexEnd=0;fsWatchers=[];gitPollTimer=null;lastGitState=null;gitignoreFilter;extraIgnore;stopped=!1;constructor(e){this.projectRoot=e.projectRoot,this.config=e.config,this.watchConfig=T(e.config),this.languages=e.languages,this.pnpmWorkspaces=e.config.indexer?.typescript?.pnpmWorkspaces??!1,this.typescriptProjectMode=e.config.indexer?.typescript?.projectMode,this.typescriptProjects=e.config.indexer?.typescript?.projects,this.clojureConfigPath=e.config.indexer?.clojure?.configPath,this.indexerConcurrency=e.config.indexerConcurrency,this.onStatus=e.onStatus??(()=>{}),this.onReindexComplete=e.onReindexComplete??(()=>{}),this.onError=e.onError??(t=>console.error(t.message)),this.gitignoreFilter=b(e.projectRoot),this.extraIgnore=X(),this.watchConfig.ignore.length>0&&this.extraIgnore.add(this.watchConfig.ignore)}start(){this.stopped=!1,this.setStatus({state:"idle"}),this.startGitStatePolling();try{let e=z(this.projectRoot,{ignoreInitial:!0,ignored:(t,r)=>this.isIgnoredWatchPath(t,r?.isDirectory()??!1)});e.on("all",(t,r)=>{this.stopped||this.handleFileChange(r)}),e.on("error",t=>{this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(t)}`))}),this.fsWatchers.push(e)}catch(e){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(e)}`))}}stop(){this.stopped=!0;for(let e of this.fsWatchers)e.close();this.fsWatchers=[],this.clearDebounceTimer(),this.clearCooldownTimer(),this.clearGitPollTimer(),this.setStatus({state:"idle"})}requestRefresh(e,t={}){if(!t.immediate||this.reindexInFlight||this.status.state==="cooldown"){this.scheduleReindex(e);return}this.pendingTrigger=I(this.pendingTrigger,e),this.changedFiles+=1,this.clearDebounceTimer(),this.triggerReindex()}isIgnoredWatchPath(e,t){let r=this.relativeWatchPath(e);if(!r)return!1;let i=t?`${r}/`:r;return i===".git/"||i.startsWith(".git/")?!0:this.gitignoreFilter.isIgnored(i)||this.extraIgnore.ignores(i)}handleFileChange(e){let t=this.relativeWatchPath(e);!t||t===".."||t.startsWith("../")||t===".git"||t.startsWith(".git/")||this.gitignoreFilter.isIgnored(t)||this.extraIgnore.ignores(t)||t.endsWith("index.db")||t.endsWith("index.scip")||t.endsWith("index.db.tmp")||this.scheduleReindex({kind:"watch-source",detail:t})}relativeWatchPath(e){let t=K(e)?e:B(this.projectRoot,e);return H(this.projectRoot,t).replaceAll("\\","/")}scheduleReindex(e){if(this.pendingTrigger=I(this.pendingTrigger,e),this.changedFiles++,this.reindexInFlight){this.dirty=!0,this.setStatus({state:"indexing",startedAt:this.status.startedAt});return}if(this.status.state==="cooldown"){this.dirty=!0,this.setStatus({state:"cooldown",until:this.status.until,dirty:!0});return}this.clearDebounceTimer();let t=Date.now()+this.watchConfig.debounceMs;this.setStatus({state:"waiting",changedFiles:this.changedFiles,reindexAt:t}),this.debounceTimer=setTimeout(()=>{this.debounceTimer=null,this.triggerReindex()},this.watchConfig.debounceMs)}triggerReindex(){if(this.reindexInFlight||this.stopped)return;let e=Date.now()-this.lastReindexEnd;if(this.lastReindexEnd>0&&e<this.watchConfig.cooldownMs){let i=this.watchConfig.cooldownMs-e;this.dirty=!0;let o=Date.now()+i;this.setStatus({state:"cooldown",until:o,dirty:!0}),this.cooldownTimer=setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped&&(this.dirty=!1,this.triggerReindex())},i);return}this.reindexInFlight=!0,this.dirty=!1,this.changedFiles=0;let t=this.pendingTrigger??{kind:"watch-source"};this.pendingTrigger=null;let r=Date.now();this.setStatus({state:"indexing",startedAt:r}),this.runReindex(t).then(i=>{if(this.reindexInFlight=!1,this.lastReindexEnd=Date.now(),this.onReindexComplete(i),this.dirty&&!this.stopped){let o=Date.now()+this.watchConfig.cooldownMs;this.setStatus({state:"cooldown",until:o,dirty:!0}),this.cooldownTimer=setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped?(this.dirty=!1,this.triggerReindex()):this.setStatus({state:"idle"})},this.watchConfig.cooldownMs)}else this.setStatus({state:"idle"})}).catch(i=>{this.reindexInFlight=!1,this.lastReindexEnd=Date.now(),this.onError(i instanceof Error?i:new Error(String(i))),this.setStatus({state:"idle"})})}runReindex(e){return new Promise((t,r)=>{let i=Date.now(),o=y(this.projectRoot),n=Object.keys(o).length>0?o:this.config,c=m(this.projectRoot,n),a=n.indexer?.typescript,l=n.indexer?.clojure,p=L(new URL("./reindex-worker.js",import.meta.url).pathname,[],{detached:!0,env:{...process.env,SCIP_REINDEX_PROJECT_ROOT:this.projectRoot,SCIP_REINDEX_OUTPUT_SCIP:c.indexPath,SCIP_REINDEX_OUTPUT_DB:c.dbPath,SCIP_REINDEX_LANGUAGES:(n.languages??this.languages)?.join(",")??"",SCIP_REINDEX_INDEXER_CONCURRENCY:String(n.indexerConcurrency??this.indexerConcurrency??""),SCIP_REINDEX_PNPM_WORKSPACES:a?.pnpmWorkspaces??this.pnpmWorkspaces?"1":"",SCIP_REINDEX_TYPESCRIPT_CONFIG:JSON.stringify({projectMode:a?.projectMode??this.typescriptProjectMode,projects:a?.projects??this.typescriptProjects??[]}),SCIP_REINDEX_CLOJURE_CONFIG_PATH:l?.configPath??this.clojureConfigPath??"",SCIP_REINDEX_TRIGGER_KIND:e.kind,SCIP_REINDEX_TRIGGER_DETAIL:e.detail??""},stdio:"pipe"});p.on("exit",u=>{u===0?t(Date.now()-i):r(new Error(`Reindex worker exited with code ${u}`))}),p.on("error",r)})}setStatus(e){this.status=e,this.onStatus(e)}clearDebounceTimer(){this.debounceTimer&&(clearTimeout(this.debounceTimer),this.debounceTimer=null)}clearCooldownTimer(){this.cooldownTimer&&(clearTimeout(this.cooldownTimer),this.cooldownTimer=null)}startGitStatePolling(){this.lastGitState=this.readGitState(),this.lastGitState&&(this.gitPollTimer=setInterval(()=>this.pollGitState(),this.watchConfig.gitPollMs),this.gitPollTimer.unref?.())}pollGitState(){let e=this.lastGitState,t=this.readGitState();if(!e||!t||this.stopped){this.lastGitState=t;return}this.lastGitState=t;let r=e.head!==t.head,i=e.indexPath!==t.indexPath||e.indexMtimeMs!==t.indexMtimeMs||e.indexSize!==t.indexSize;r&&i?this.scheduleReindex({kind:"watch-git-state",detail:"HEAD and index changed"}):r?this.scheduleReindex({kind:"watch-git-head",detail:"HEAD changed"}):i&&this.scheduleReindex({kind:"watch-git-index",detail:t.indexPath??"index changed"})}readGitState(){let e=f(this.projectRoot,["rev-parse","--git-path","index"]);if(!e)return null;let t=x(this.projectRoot,e),r={head:f(this.projectRoot,["rev-parse","--verify","HEAD"]),indexPath:t};try{let i=Y(t);r.indexMtimeMs=i.mtimeMs,r.indexSize=i.size}catch{r.indexMtimeMs=void 0,r.indexSize=void 0}return r}clearGitPollTimer(){this.gitPollTimer&&(clearInterval(this.gitPollTimer),this.gitPollTimer=null)}};function I(s,e){return s?s.kind===e.kind?s.detail===e.detail?s:{kind:s.kind,detail:"multiple changes"}:{kind:"watch-git-state",detail:`${s.kind}, ${e.kind}`}:e}import{existsSync as v,mkdirSync as J,symlinkSync as V,readlinkSync as A,unlinkSync as $,readdirSync as Q}from"fs";import{join as h,dirname as w,resolve as d,relative as Z,isAbsolute as ee}from"path";import{homedir as C,platform as te}from"os";import{fileURLToPath as re}from"url";var ie=te()==="win32",_=["_shared","scip-query","scip-setup","scip-calibrate","scip-cleanup-audit","scip-cleanup-improve","scip-integrity-audit","scip-twin-drift","scip-claim-audit","scip-probe-reachability","scip-hyper-optimization","scip-api-impact","scip-concrete-plan","scip-conductor","scip-debug","scip-explore","scip-root-cause","scip-triage-issue","scip-diagram","scip-doc-reconcile","scip-directory-architecture","scip-maintainability","scip-react-maintainability","scip-vue-maintainability","scip-verify","scip-language-playbook","scip-tla-model-system"];function se(s={}){let e=s.quiet?()=>{}:console.log,t=re(import.meta.url),r=d(w(t),"..","skills"),i=[h(C(),".claude","skills"),h(C(),".codex","skills"),h(C(),".agents","skills")],o={installed:[],skipped:[],alreadyLinked:[],pruned:[]};for(let n of i){let c=w(n);if(!v(c))continue;J(n,{recursive:!0});let a=ae(n);ne(n,r,a,o,e);for(let l of _){let p=h(r,l),u=h(n,l);if(!v(p)){o.skipped.push(`${a}/${l}`);continue}if(v(u)){try{let M=A(u);if(d(M)===d(p)){o.alreadyLinked.push(`${a}/${l}`),e(` ok: ${l} \u2192 ${a} (already linked)`);continue}}catch{o.skipped.push(`${a}/${l}`),e(` skip: ${l} \u2192 ${a} (exists, not a symlink)`);continue}$(u)}V(p,u,ie?"junction":"dir"),o.installed.push(`${a}/${l}`),e(` done: ${l} \u2192 ${a}`)}}return o}function ne(s,e,t,r,i){let o=new Set(_);for(let n of Q(s)){if(o.has(n))continue;let c=h(s,n),a;try{a=d(w(c),A(c))}catch{continue}oe(a,e)&&($(c),r.pruned.push(`${t}/${n}`),i(` prune: ${n} \u2192 ${t} (removed stale scip-query skill link)`))}}function oe(s,e){let t=Z(d(e),d(s));return t===""||!t.startsWith("..")&&!ee(t)}function ae(s){return s.includes(".codex")?"Codex":s.includes(".agents")?"Agents":"Claude"}export{S as Watcher,D as getScipVersion,q as initProjectConfig,se as installSkills,O as isScipInstalled,y as loadProjectConfig,N as printScipInstallInstructions,m as resolveIndexStoragePaths};
|
|
3
3
|
//# sourceMappingURL=runtime.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"./chunk-P5XHIJHI.js";import{a as b,b as v}from"./chunk-KHE7J5ZN.js";import{a as w,g as k}from"./chunk-
|
|
1
|
+
import"./chunk-P5XHIJHI.js";import{a as b,b as v}from"./chunk-KHE7J5ZN.js";import{a as w,g as k}from"./chunk-HGFDYOVB.js";import d from"process";import{closeSync as ee,mkdirSync as y,openSync as re,readFileSync as O,readdirSync as ne,rmSync as h,writeFileSync as te}from"fs";import{dirname as se,resolve as c}from"path";import{pathToFileURL as oe}from"url";import{spawn as x}from"child_process";import{createHash as B,randomUUID as W}from"crypto";import{existsSync as L,mkdirSync as ge,readFileSync as he,realpathSync as Ee,rmSync as Ie}from"fs";import{tmpdir as _e}from"os";import{resolve as ke}from"path";var T=2;var g=class{constructor(r,n=z){this.createRequester=r;this.applyEnvironment=n}createRequester;applyEnvironment;requester=null;identityKey=null;semanticResponseCache=null;handle(r){this.applyEnvironment(r.workerEnvironment??{});let n;if(this.requester?this.identityKey!==r.identityKey?(this.semanticResponseCache=null,this.requester.shutdown(),this.requester=this.createRequester(),this.identityKey=r.identityKey,n="invalidated"):n="reused":(this.requester=this.createRequester(),this.identityKey=r.identityKey,n="created"),r.kind==="semantic"){let s=j(r.request),o=n==="reused"&&s!==null&&this.semanticResponseCache?.identityKey===r.identityKey&&this.semanticResponseCache.requestKey===s?this.semanticResponseCache.response:null;if(o)return M(!0,r.request.definitions.length),{session:n,response:o};let a=this.requester.requestSemantic(r.request,r.timeoutMs);return s!==null&&F(a)&&(this.semanticResponseCache={identityKey:r.identityKey,requestKey:s,response:a}),M(!1,r.request.definitions.length),{session:n,response:a}}return{session:n,response:this.requester.requestImportDefinitions(r.request,r.timeoutMs)}}shutdown(){this.requester?.shutdown(),this.requester=null,this.identityKey=null,this.semanticResponseCache=null}};function j(e){if(e.includeReferences===!1||e.includeCallees!==!0||e.includeSignatures===!0||(e.referenceDefinitions?.length??0)===0||(e.calleeDefinitions?.length??0)===0)return null;let{readinessDeadlineMs:r,...n}=e;return $(I(n))}function F(e){return e.available&&Array.isArray(e.callees)&&(e.incompleteReferenceSymbolIds?.length??0)===0}function M(e,r){w()&&k({type:"span",name:"rust.semantic.durable-session.response-cache",durationMs:0,ok:!0,hit:e,definitions:r})}function z(e){for(let r of Object.keys(process.env))Y(r)&&delete process.env[r];for(let[r,n]of Object.entries(e))n!==null&&(process.env[r]=n)}function K(e){return e==="HOME"||e==="PATH"||e.startsWith("CARGO_")||e.startsWith("RA_")||e.startsWith("RUST")}function Y(e){return K(e)||e.startsWith("SCIP_RUST_")||e==="SCIP_QUERY_PROFILE"||e==="SCIP_QUERY_PROFILE_CACHE_STATE"||e==="SCIP_QUERY_PROFILE_COMMAND"||e==="SCIP_QUERY_PROFILE_OUT"||e==="SCIP_QUERY_PROFILE_RUN_ID"||e==="SCIP_QUERY_PROFILE_WORKLOAD_IDENTITY"||e==="SCIP_QUERY_PROFILE_WORKLOAD_IDENTITY_KIND"||e==="SCIP_QUERY_PROFILE_MIN_MS"}var Ae={now:Date.now,randomId:W,isProcessAlive:b,spawnServer(e,r,n){if(!L(e))throw new Error(`Durable Rust semantic session helper was not found at ${e}. Run npm run build first.`);x(process.execPath,[e,r,n],{detached:!0,stdio:"ignore"}).unref()},sleep(e){let r=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(r,0,0,e)}};function I(e){return Array.isArray(e)?`[${e.map(I).join(",")}]`:e&&typeof e=="object"?`{${Object.entries(e).sort(([r],[n])=>r.localeCompare(n)).map(([r,n])=>`${JSON.stringify(r)}:${I(n)}`).join(",")}}`:JSON.stringify(e)}function $(e){return B("sha256").update(e).digest("hex")}import{existsSync as H,mkdtempSync as A,readFileSync as C,rmSync as D}from"fs";import{tmpdir as q}from"os";import{join as _}from"path";import{fileURLToPath as P,pathToFileURL as V}from"url";import{SHARE_ENV as J,Worker as Q}from"worker_threads";function U(e={}){let r=null,n=null,s=1,o=!1,a=()=>{n&&(D(n,{recursive:!0,force:!0}),n=null)},f=()=>{let t=r;r=null,t&&t.terminate(),a()},u=()=>{if(r)return r;let t=e.semanticWorkerPath?V(e.semanticWorkerPath):Z();if(!H(P(t)))throw new Error(`Rust semantic session worker was not found at ${P(t)}. Run npm run build before using built semantic Rust queries.`);return n=A(_(q(),"scip-query-rust-session-")),r=new Q(t,e.shareEnvironment?{env:J}:void 0),r.unref(),r},l=()=>{let t=n??A(_(q(),"scip-query-rust-session-"));return n=t,_(t,`${s++}.json`)};return{requestSemantic(t,i){if(o)throw new Error("Rust semantic session was already disposed.");let R=u(),p=l(),S=new SharedArrayBuffer(4),E=new Int32Array(S);if(R.postMessage({kind:"semantic",request:t,responsePath:p,sharedBuffer:S}),Atomics.wait(E,0,0,i)==="timed-out")throw f(),new Error(`Rust semantic session worker timed out after ${(i/1e3).toFixed(0)}s`);try{let m=G(C(p,"utf8"));if(!m.ok)throw new Error(m.error);return m.response}finally{D(p,{force:!0})}},requestImportDefinitions(t,i){if(o)throw new Error("Rust semantic session was already disposed.");let R=u(),p=l(),S=new SharedArrayBuffer(4),E=new Int32Array(S);if(R.postMessage({kind:"import-definitions",request:t,responsePath:p,sharedBuffer:S}),Atomics.wait(E,0,0,i)==="timed-out")throw f(),new Error(`Rust semantic import-definition session worker timed out after ${(i/1e3).toFixed(0)}s`);try{let m=X(C(p,"utf8"));if(!m.ok)throw new Error(m.error);return m.response}finally{D(p,{force:!0})}},shutdown(){if(o)return;if(o=!0,!r){a();return}let t=l(),i=new SharedArrayBuffer(4),R=new Int32Array(i);r.postMessage({kind:"shutdown",responsePath:t,sharedBuffer:i}),Atomics.wait(R,0,0,5e3),f()}}}function G(e){let r=JSON.parse(e);if(!r||typeof r!="object")return{ok:!1,error:"Rust semantic session worker wrote a non-object response."};let n=r;return n.ok===!0&&"response"in n?{ok:!0,response:n.response}:{ok:!1,error:typeof r.error=="string"?r.error:"Rust semantic session worker failed."}}function X(e){let r=JSON.parse(e);if(!r||typeof r!="object")return{ok:!1,error:"Rust semantic session worker wrote a non-object response."};let n=r;return n.ok===!0&&"response"in n?{ok:!0,response:n.response}:{ok:!1,error:typeof r.error=="string"?r.error:"Rust semantic session worker failed."}}function Z(){return new URL("./rust-semantic-session-worker.js",import.meta.url)}var ie=10*6e4,ae=10,ue=1e3;function le(e,r,n={}){let s=c(e,"requests"),o=c(e,"responses");y(s,{recursive:!0}),y(o,{recursive:!0});let a=0;for(let f of ne(s).filter(u=>u.endsWith(".json")).sort()){let u=c(s,f),l=null;try{l=fe(O(u,"utf8")),n.beforeRequest?.(l.request);let t=r.handle(l.request);v(c(o,`${l.id}.json`),{ok:!0,...t})}catch(t){let i=l?.id??f.slice(0,-5);v(c(o,`${i}.json`),{ok:!1,error:t instanceof Error?t.message:String(t)})}finally{h(u,{force:!0}),a+=1}}return a}async function ce(e,r){y(c(e,"requests"),{recursive:!0}),y(c(e,"responses"),{recursive:!0});let n=c(e,"server.lock");if(!Re(n))return;let s=new g(()=>U({semanticWorkerPath:r,shareEnvironment:!0})),o=!1,a=Date.now(),f=0,u,l=()=>{o=!0};d.once("SIGINT",l),d.once("SIGTERM",l);let t=(i=!1)=>{let R=Date.now();!i&&R-f<ue||(f=R,v(c(e,"server.json"),{protocolVersion:T,pid:d.pid,heartbeatAtMs:R,...u===void 0?{}:{busyUntilMs:u}}))};try{t(!0);let i=pe();for(;!o&&Date.now()-a<i;)le(e,s,{beforeRequest(p){u=Date.now()+p.timeoutMs+5e3,t(!0)}})>0?(a=Date.now(),u=void 0,t(!0)):t(),await me(ae)}finally{s.shutdown(),h(c(e,"server.json"),{force:!0}),h(n,{force:!0})}}function Re(e){y(se(e),{recursive:!0});for(let r=0;r<2;r+=1)try{let n=re(e,"wx");return te(n,String(d.pid)),ee(n),!0}catch{let n=de(e);if(n!==null&&b(n))return!1;h(e,{force:!0})}return!1}function de(e){try{let r=Number(O(e,"utf8"));return Number.isInteger(r)&&r>0?r:null}catch{return null}}function fe(e){let r=JSON.parse(e);if(typeof r.id!="string"||!r.request||typeof r.request!="object")throw new Error("Durable Rust semantic helper received an invalid mailbox request.");return{id:r.id,request:r.request}}function pe(){let e=Number(d.env.SCIP_RUST_SEMANTIC_DURABLE_IDLE_MS);return Number.isInteger(e)&&e>=0?e:ie}function me(e){return new Promise(r=>setTimeout(r,e))}var Se=d.argv[1]?oe(c(d.argv[1])).href:null;if(Se===import.meta.url){let e=d.argv[2],r=d.argv[3];!e||!r?(console.error("durable-rust-session: expected <session-dir> <semantic-worker-path>"),d.exitCode=1):await ce(e,r)}export{le as processDurableRustSessionRequests};
|
|
2
2
|
//# sourceMappingURL=rust-semantic-session-server.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{A as ue,B as de,C as b,D as S,a as A,b as q,c as ee,d as ne,e as te,f as ie,g as se,h as F,i as G,j as N,k as E,l as B,n as j,o as H,p as U,q as W,r as re,u as ae,v as oe,w as le,x as ce,y as k}from"./chunk-D5OXYOJP.js";import{a as O,f as d,g as D}from"./chunk-JHK2DMUQ.js";import _ from"process";import{existsSync as pe,readFileSync as we,writeFileSync as Pe}from"fs";import{isAbsolute as De,resolve as K}from"path";import{performance as L}from"perf_hooks";import{parentPort as ke}from"worker_threads";var be="SCIP_RUST_SEMANTIC_REFERENCE_TASK_PROFILE_MS",Se="SCIP_RUST_SEMANTIC_CALLEE_TASK_PROFILE_MS",P=new Map,fe=Promise.resolve();ke?.on("message",e=>{fe=fe.then(()=>Te(e)).catch(()=>{})});async function Te(e){if(e.kind==="shutdown"){await We(),g(e.responsePath,{ok:!0},e.sharedBuffer);return}if(e.kind==="import-definitions"){try{let t=await ze(e.request);g(e.responsePath,{ok:!0,response:t},e.sharedBuffer)}catch(t){let i=B(t);if(i){g(e.responsePath,i,e.sharedBuffer);return}let n={available:!1,reason:t instanceof Error?t.message:String(t),sourcePaths:e.request.positions.map(r=>[r.id,null])};g(e.responsePath,{ok:!0,response:n},e.sharedBuffer)}return}try{let t=await ve(e.request);g(e.responsePath,{ok:!0,response:t},e.sharedBuffer)}catch(t){let i=B(t);if(i){g(e.responsePath,i,e.sharedBuffer);return}let n=ye(e.request,t instanceof Error?t.message:String(t));g(e.responsePath,{ok:!0,response:n},e.sharedBuffer)}}async function ze(e){let t={timeoutMs:e.requestTimeoutMs,deadlineMs:e.readinessDeadlineMs},i=await d("rust.semantic.worker.session",()=>Re(e.projectRoot,e.rustAnalyzerBinary,[e.file],{requestTimeoutMs:e.requestTimeoutMs,readinessDeadlineMs:e.readinessDeadlineMs}),()=>({kind:"import-definitions",files:1,positions:e.positions.length}));if(!i.capabilities.definitionProvider)return{available:!1,reason:"rust-analyzer initialized without textDocument/definition support.",sourcePaths:e.positions.map(o=>[o.id,null])};let n=0;await E(()=>d("rust.semantic.worker.open-source-documents",async()=>{n=await Ae(i,e.projectRoot,[e.file],{diagnosticsTimeoutMs:e.diagnosticsTimeoutMs,settleDelayMs:e.settleDelayMs,readinessDeadlineMs:e.readinessDeadlineMs})},()=>({files:1,openedDocuments:n,positions:e.positions.length})),()=>ge(P,i,e.readinessDeadlineMs));let r=0;return{available:!0,sourcePaths:await d("rust.semantic.worker.import-definitions",()=>S(e.positions,e.concurrency??8,async o=>{let c=await i.client.definition({textDocument:{uri:A(e.projectRoot,o.file)},position:{line:o.line,character:o.column}},t),f=Fe(e.projectRoot,c);return f&&(r+=1),[o.id,f]}),()=>({positions:e.positions.length,resolvedPositions:r,concurrency:e.concurrency??8}))}}async function ve(e){let t={timeoutMs:e.requestTimeoutMs,deadlineMs:e.readinessDeadlineMs},i=e.includeReferences!==!1,n=e.includeCallees===!0,r=e.includeSignatures===!0,a=j(e),o=H(e),c=U(e),f=W(e),l=await d("rust.semantic.worker.session",()=>Ie(e),()=>({kind:"semantic",definitions:f.length,referenceDefinitions:a.length,calleeDefinitions:o.length,signatureDefinitions:c.length,references:i,callees:n,signatures:r})),p=Ee(l.capabilities,{references:i,callees:n,signatures:r});if(p)return ye(e,p);let u=0;await E(()=>d("rust.semantic.worker.open-definition-documents",async()=>{u=await Ce(l,e)},()=>({definitions:f.length,openedDocuments:u})),()=>ge(P,l,e.readinessDeadlineMs));let m=0,M=0,y=O(),J=y?new Map:null,T=y?me(_.env[be]):null,V=()=>i?d("rust.semantic.worker.references",()=>S(a,e.concurrency??8,async s=>{let w=y?L.now():0,h=await ue(l.client,ee(e.projectRoot,s,!1),{requestTimeoutMs:e.requestTimeoutMs,retryTimeoutMs:e.referenceRetryTimeoutMs,deadlineMs:e.readinessDeadlineMs}),R=te(ne(e.projectRoot,h.locations)),C=y?Math.round(L.now()-w):0;return _e(J,s.relativePath,{durationMs:C,references:R.length,hasReferences:R.length>0,slow:T!==null&&C>=T}),T!==null&&C>=T&&D({type:"span",name:"rust.semantic.worker.reference-task",durationMs:C,ok:!0,symbolId:s.symbolId,relativePath:s.relativePath,leaf:s.leaf,kind:s.kind,startLine:s.startLine,endLine:s.endLine,references:R.length,complete:h.complete}),R.length>0&&(M+=1),m+=R.length,{symbolId:s.symbolId,references:R,complete:h.complete}}),()=>({definitions:a.length,concurrency:e.concurrency??8,definitionsWithReferences:M,references:m})):Promise.resolve(a.map(s=>({symbolId:s.symbolId,references:[],complete:!0}))),Q=0,X=0,z=O(),Y=z?new Map:null,v=z?me(_.env[Se]):null,Z=()=>n?d("rust.semantic.worker.callees",()=>S(o,e.concurrency??8,async s=>{let w=z?L.now():0,h=await de(l.client,e.projectRoot,s,t),R=z?Math.round(L.now()-w):0;return Ge(Y,s.relativePath,{durationMs:R,callees:h.length,hasCallees:h.length>0,slow:v!==null&&R>=v}),v!==null&&R>=v&&D({type:"span",name:"rust.semantic.worker.callee-task",durationMs:R,ok:!0,symbolId:s.symbolId,relativePath:s.relativePath,leaf:s.leaf,kind:s.kind,startLine:s.startLine,endLine:s.endLine,callees:h.length}),h.length>0&&(X+=1),Q+=h.length,{symbolId:s.symbolId,callees:h}}),()=>({definitions:o.length,concurrency:e.concurrency??8,definitionsWithCallees:X,callees:Q})):Promise.resolve([]),I,x;i&&n&&a.length>0&&o.length>0&&je()?[I,x]=await Promise.all([V(),Z()]):(I=await V(),x=await Z()),xe(J),Ne(Y);let $=0,Me=r?await d("rust.semantic.worker.signatures",()=>S(c,e.concurrency??8,async s=>{let w=await re(l.client,e.projectRoot,s,t);return w&&($+=1),{symbolId:s.symbolId,signature:w}}),()=>({definitions:c.length,concurrency:e.concurrency??8,signaturesFound:$})):[];return{available:!0,references:I.filter(s=>s.complete).map(s=>[s.symbolId,s.references]),incompleteReferenceSymbolIds:I.filter(s=>!s.complete).map(s=>s.symbolId),...n?{callees:x.map(s=>[s.symbolId,s.callees])}:{},...r?{signatures:Me.map(s=>[s.symbolId,s.signature])}:{}}}async function Ie(e){return Re(e.projectRoot,e.rustAnalyzerBinary,W(e).map(t=>t.relativePath),{requestTimeoutMs:e.requestTimeoutMs,readinessDeadlineMs:e.readinessDeadlineMs})}async function Re(e,t,i,n){let r=le(e,i.map(M=>({relativePath:M}))),a=oe(e,r),o=Le(t,a,r),c=P.get(o);if(c)return c;let f=ae(r),l=new ie(se(t,a),{requestTimeoutMs:n.requestTimeoutMs,configuration:f}),p=n.readinessDeadlineMs===void 0?null:{afterGeneration:l.serverStatusGeneration(),deadlineMs:n.readinessDeadlineMs},u=await E(()=>d("rust.semantic.worker.initialize",()=>l.initialize({processId:_.pid,rootUri:A(a,"."),capabilities:{textDocument:{references:{dynamicRegistration:!1},definition:{dynamicRegistration:!1},callHierarchy:{dynamicRegistration:!1},hover:{dynamicRegistration:!1}}},initializationOptions:f},{timeoutMs:n.requestTimeoutMs,deadlineMs:n.readinessDeadlineMs}),()=>({linkedProjects:r.length,relativePaths:i.length})),()=>l.shutdown({deadlineMs:n.readinessDeadlineMs}).catch(()=>{})),m={key:o,client:l,capabilities:u.capabilities,openedPaths:new Set,initializationReadiness:p};return P.set(o,m),m}async function Ce(e,t){let i=W(t).filter(l=>e.openedPaths.has(l.relativePath)?!1:pe(K(t.projectRoot,l.relativePath)));if(i.length===0)return await he(e),0;let n=e.initializationReadiness,r=t.readinessDeadlineMs===void 0?null:{statusSnapshot:n?null:e.client.serverStatusSnapshot(),initializationGeneration:n?.afterGeneration,deadlineMs:t.readinessDeadlineMs},a=ce(e.client,t.projectRoot,i);for(let l of i)e.openedPaths.add(l.relativePath);let o=t.diagnosticsTimeoutMs??1e4,c=o;await d("rust.semantic.worker.diagnostics",()=>r?N(l=>(c=l,k(e.client,a,l)),o,r.deadlineMs):k(e.client,a,o),()=>({openedDocuments:a.length,timeoutMs:c}));let f=t.settleDelayMs??5e3;if(!r)await d("rust.semantic.worker.settle",()=>b(f),()=>({openedDocuments:a.length,settleDelayMs:f}));else{let l;await d("rust.semantic.worker.readiness",async()=>{let p=m=>d("rust.semantic.worker.settle",()=>b(m),()=>({openedDocuments:a.length,settleDelayMs:m})),u=r.initializationGeneration===void 0?await G(e.client,r.statusSnapshot,a.length,r.deadlineMs,f,Date.now,p):await F(e.client,r.initializationGeneration,a.length,r.deadlineMs,f,Date.now,p);r.initializationGeneration!==void 0&&(e.initializationReadiness=null),l=u?.health},()=>({phase:r.initializationGeneration===void 0?"didOpen":"initialize+didOpen",openedDocuments:a.length,health:l}))}return a.length}async function Ae(e,t,i,n){let r=i.filter(u=>e.openedPaths.has(u)?!1:pe(K(t,u)));if(r.length===0)return await he(e),0;let a=e.initializationReadiness,o=n.readinessDeadlineMs===void 0?null:{statusSnapshot:a?null:e.client.serverStatusSnapshot(),initializationGeneration:a?.afterGeneration,deadlineMs:n.readinessDeadlineMs},c=[];for(let u of r){let m=A(t,u);e.client.didOpenTextDocument({uri:m,languageId:"rust",version:1,text:we(K(t,u),"utf8")}),e.openedPaths.add(u),c.push(m)}let f=n.diagnosticsTimeoutMs??1e4,l=f;await d("rust.semantic.worker.diagnostics",()=>o?N(u=>(l=u,k(e.client,c,u)),f,o.deadlineMs):k(e.client,c,f),()=>({openedDocuments:c.length,timeoutMs:l}));let p=n.settleDelayMs??5e3;if(!o)await d("rust.semantic.worker.settle",()=>b(p),()=>({openedDocuments:c.length,settleDelayMs:p}));else{let u;await d("rust.semantic.worker.readiness",async()=>{let m=y=>d("rust.semantic.worker.settle",()=>b(y),()=>({openedDocuments:c.length,settleDelayMs:y})),M=o.initializationGeneration===void 0?await G(e.client,o.statusSnapshot,c.length,o.deadlineMs,p,Date.now,m):await F(e.client,o.initializationGeneration,c.length,o.deadlineMs,p,Date.now,m);o.initializationGeneration!==void 0&&(e.initializationReadiness=null),u=M?.health},()=>({phase:o.initializationGeneration===void 0?"didOpen":"initialize+didOpen",openedDocuments:c.length,health:u}))}return c.length}async function he(e){let t=e.initializationReadiness;if(!t)return;let i;await d("rust.semantic.worker.readiness",async()=>{i=(await F(e.client,t.afterGeneration,0,t.deadlineMs,0)).health,e.initializationReadiness=null},()=>({phase:"initialize",openedDocuments:0,health:i}))}function Fe(e,t){for(let i of t){let n=q(e,i.uri);if(!(!n||n===".."||n.startsWith("../")||De(n)))return n}return null}function Ee(e,t){return t.references&&!e.referencesProvider?"rust-analyzer initialized without textDocument/references support.":t.callees&&!e.callHierarchyProvider?"rust-analyzer initialized without call hierarchy support.":t.signatures&&!e.hoverProvider?"rust-analyzer initialized without hover support.":null}function ye(e,t){let i=j(e),n=H(e),r=U(e);return{available:!1,reason:t,references:i.map(a=>[a.symbolId,[]]),...e.includeCallees?{callees:n.map(a=>[a.symbolId,[]])}:{},...e.includeSignatures?{signatures:r.map(a=>[a.symbolId,null])}:{}}}async function We(){let e=[...P.values()];P.clear(),await Promise.all(e.map(t=>t.client.shutdown().catch(()=>{})))}async function ge(e,t,i){e.get(t.key)===t&&e.delete(t.key),await t.client.shutdown({deadlineMs:i}).catch(()=>{})}function Le(e,t,i){return JSON.stringify({binary:e,sessionRoot:t,linkedProjects:i})}function _e(e,t,i){if(!e)return;let n=Oe(e,t);n.definitions+=1,i.hasReferences&&(n.definitionsWithReferences+=1),n.references+=i.references,n.durationMs+=i.durationMs,n.maxDurationMs=Math.max(n.maxDurationMs,i.durationMs),i.slow&&(n.slowTasks+=1)}function xe(e){if(!e)return;let t=[...e.entries()].sort(([i,n],[r,a])=>a.durationMs-n.durationMs||i.localeCompare(r));for(let[i,n]of t)D({type:"span",name:"rust.semantic.worker.references.by-file",durationMs:n.durationMs,ok:!0,relativePath:i,definitions:n.definitions,definitionsWithReferences:n.definitionsWithReferences,references:n.references,maxDurationMs:n.maxDurationMs,slowTasks:n.slowTasks,aggregate:"sum-task-duration"})}function Oe(e,t){let i=e.get(t);if(i)return i;let n={definitions:0,definitionsWithReferences:0,references:0,durationMs:0,maxDurationMs:0,slowTasks:0};return e.set(t,n),n}function Ge(e,t,i){if(!e)return;let n=Be(e,t);n.definitions+=1,i.hasCallees&&(n.definitionsWithCallees+=1),n.callees+=i.callees,n.durationMs+=i.durationMs,n.maxDurationMs=Math.max(n.maxDurationMs,i.durationMs),i.slow&&(n.slowTasks+=1)}function Ne(e){if(!e)return;let t=[...e.entries()].sort(([i,n],[r,a])=>a.durationMs-n.durationMs||i.localeCompare(r));for(let[i,n]of t)D({type:"span",name:"rust.semantic.worker.callees.by-file",durationMs:n.durationMs,ok:!0,relativePath:i,definitions:n.definitions,definitionsWithCallees:n.definitionsWithCallees,callees:n.callees,maxDurationMs:n.maxDurationMs,slowTasks:n.slowTasks,aggregate:"sum-task-duration"})}function Be(e,t){let i=e.get(t);if(i)return i;let n={definitions:0,definitionsWithCallees:0,callees:0,durationMs:0,maxDurationMs:0,slowTasks:0};return e.set(t,n),n}function me(e){if(e===void 0||e==="")return null;let t=Number(e);return Number.isInteger(t)&&t>=0?t:null}function je(){let e=_.env.SCIP_RUST_SEMANTIC_PARALLEL_OPERATIONS;return e!=="0"&&e!=="false"}function g(e,t,i){Pe(e,JSON.stringify(t));let n=new Int32Array(i);Atomics.store(n,0,1),Atomics.notify(n,0)}export{ge as discardRustAnalyzerSession};
|
|
1
|
+
import{A as ue,B as de,C as b,D as S,a as A,b as q,c as ee,d as ne,e as te,f as ie,g as se,h as F,i as G,j as N,k as E,l as B,n as j,o as H,p as U,q as W,r as re,u as ae,v as oe,w as le,x as ce,y as k}from"./chunk-MQ2B33LQ.js";import{a as O,f as d,g as D}from"./chunk-HGFDYOVB.js";import _ from"process";import{existsSync as pe,readFileSync as we,writeFileSync as Pe}from"fs";import{isAbsolute as De,resolve as K}from"path";import{performance as L}from"perf_hooks";import{parentPort as ke}from"worker_threads";var be="SCIP_RUST_SEMANTIC_REFERENCE_TASK_PROFILE_MS",Se="SCIP_RUST_SEMANTIC_CALLEE_TASK_PROFILE_MS",P=new Map,fe=Promise.resolve();ke?.on("message",e=>{fe=fe.then(()=>Te(e)).catch(()=>{})});async function Te(e){if(e.kind==="shutdown"){await We(),g(e.responsePath,{ok:!0},e.sharedBuffer);return}if(e.kind==="import-definitions"){try{let t=await ze(e.request);g(e.responsePath,{ok:!0,response:t},e.sharedBuffer)}catch(t){let i=B(t);if(i){g(e.responsePath,i,e.sharedBuffer);return}let n={available:!1,reason:t instanceof Error?t.message:String(t),sourcePaths:e.request.positions.map(r=>[r.id,null])};g(e.responsePath,{ok:!0,response:n},e.sharedBuffer)}return}try{let t=await ve(e.request);g(e.responsePath,{ok:!0,response:t},e.sharedBuffer)}catch(t){let i=B(t);if(i){g(e.responsePath,i,e.sharedBuffer);return}let n=ye(e.request,t instanceof Error?t.message:String(t));g(e.responsePath,{ok:!0,response:n},e.sharedBuffer)}}async function ze(e){let t={timeoutMs:e.requestTimeoutMs,deadlineMs:e.readinessDeadlineMs},i=await d("rust.semantic.worker.session",()=>Re(e.projectRoot,e.rustAnalyzerBinary,[e.file],{requestTimeoutMs:e.requestTimeoutMs,readinessDeadlineMs:e.readinessDeadlineMs}),()=>({kind:"import-definitions",files:1,positions:e.positions.length}));if(!i.capabilities.definitionProvider)return{available:!1,reason:"rust-analyzer initialized without textDocument/definition support.",sourcePaths:e.positions.map(o=>[o.id,null])};let n=0;await E(()=>d("rust.semantic.worker.open-source-documents",async()=>{n=await Ae(i,e.projectRoot,[e.file],{diagnosticsTimeoutMs:e.diagnosticsTimeoutMs,settleDelayMs:e.settleDelayMs,readinessDeadlineMs:e.readinessDeadlineMs})},()=>({files:1,openedDocuments:n,positions:e.positions.length})),()=>ge(P,i,e.readinessDeadlineMs));let r=0;return{available:!0,sourcePaths:await d("rust.semantic.worker.import-definitions",()=>S(e.positions,e.concurrency??8,async o=>{let c=await i.client.definition({textDocument:{uri:A(e.projectRoot,o.file)},position:{line:o.line,character:o.column}},t),f=Fe(e.projectRoot,c);return f&&(r+=1),[o.id,f]}),()=>({positions:e.positions.length,resolvedPositions:r,concurrency:e.concurrency??8}))}}async function ve(e){let t={timeoutMs:e.requestTimeoutMs,deadlineMs:e.readinessDeadlineMs},i=e.includeReferences!==!1,n=e.includeCallees===!0,r=e.includeSignatures===!0,a=j(e),o=H(e),c=U(e),f=W(e),l=await d("rust.semantic.worker.session",()=>Ie(e),()=>({kind:"semantic",definitions:f.length,referenceDefinitions:a.length,calleeDefinitions:o.length,signatureDefinitions:c.length,references:i,callees:n,signatures:r})),p=Ee(l.capabilities,{references:i,callees:n,signatures:r});if(p)return ye(e,p);let u=0;await E(()=>d("rust.semantic.worker.open-definition-documents",async()=>{u=await Ce(l,e)},()=>({definitions:f.length,openedDocuments:u})),()=>ge(P,l,e.readinessDeadlineMs));let m=0,M=0,y=O(),J=y?new Map:null,T=y?me(_.env[be]):null,V=()=>i?d("rust.semantic.worker.references",()=>S(a,e.concurrency??8,async s=>{let w=y?L.now():0,h=await ue(l.client,ee(e.projectRoot,s,!1),{requestTimeoutMs:e.requestTimeoutMs,retryTimeoutMs:e.referenceRetryTimeoutMs,deadlineMs:e.readinessDeadlineMs}),R=te(ne(e.projectRoot,h.locations)),C=y?Math.round(L.now()-w):0;return _e(J,s.relativePath,{durationMs:C,references:R.length,hasReferences:R.length>0,slow:T!==null&&C>=T}),T!==null&&C>=T&&D({type:"span",name:"rust.semantic.worker.reference-task",durationMs:C,ok:!0,symbolId:s.symbolId,relativePath:s.relativePath,leaf:s.leaf,kind:s.kind,startLine:s.startLine,endLine:s.endLine,references:R.length,complete:h.complete}),R.length>0&&(M+=1),m+=R.length,{symbolId:s.symbolId,references:R,complete:h.complete}}),()=>({definitions:a.length,concurrency:e.concurrency??8,definitionsWithReferences:M,references:m})):Promise.resolve(a.map(s=>({symbolId:s.symbolId,references:[],complete:!0}))),Q=0,X=0,z=O(),Y=z?new Map:null,v=z?me(_.env[Se]):null,Z=()=>n?d("rust.semantic.worker.callees",()=>S(o,e.concurrency??8,async s=>{let w=z?L.now():0,h=await de(l.client,e.projectRoot,s,t),R=z?Math.round(L.now()-w):0;return Ge(Y,s.relativePath,{durationMs:R,callees:h.length,hasCallees:h.length>0,slow:v!==null&&R>=v}),v!==null&&R>=v&&D({type:"span",name:"rust.semantic.worker.callee-task",durationMs:R,ok:!0,symbolId:s.symbolId,relativePath:s.relativePath,leaf:s.leaf,kind:s.kind,startLine:s.startLine,endLine:s.endLine,callees:h.length}),h.length>0&&(X+=1),Q+=h.length,{symbolId:s.symbolId,callees:h}}),()=>({definitions:o.length,concurrency:e.concurrency??8,definitionsWithCallees:X,callees:Q})):Promise.resolve([]),I,x;i&&n&&a.length>0&&o.length>0&&je()?[I,x]=await Promise.all([V(),Z()]):(I=await V(),x=await Z()),xe(J),Ne(Y);let $=0,Me=r?await d("rust.semantic.worker.signatures",()=>S(c,e.concurrency??8,async s=>{let w=await re(l.client,e.projectRoot,s,t);return w&&($+=1),{symbolId:s.symbolId,signature:w}}),()=>({definitions:c.length,concurrency:e.concurrency??8,signaturesFound:$})):[];return{available:!0,references:I.filter(s=>s.complete).map(s=>[s.symbolId,s.references]),incompleteReferenceSymbolIds:I.filter(s=>!s.complete).map(s=>s.symbolId),...n?{callees:x.map(s=>[s.symbolId,s.callees])}:{},...r?{signatures:Me.map(s=>[s.symbolId,s.signature])}:{}}}async function Ie(e){return Re(e.projectRoot,e.rustAnalyzerBinary,W(e).map(t=>t.relativePath),{requestTimeoutMs:e.requestTimeoutMs,readinessDeadlineMs:e.readinessDeadlineMs})}async function Re(e,t,i,n){let r=le(e,i.map(M=>({relativePath:M}))),a=oe(e,r),o=Le(t,a,r),c=P.get(o);if(c)return c;let f=ae(r),l=new ie(se(t,a),{requestTimeoutMs:n.requestTimeoutMs,configuration:f}),p=n.readinessDeadlineMs===void 0?null:{afterGeneration:l.serverStatusGeneration(),deadlineMs:n.readinessDeadlineMs},u=await E(()=>d("rust.semantic.worker.initialize",()=>l.initialize({processId:_.pid,rootUri:A(a,"."),capabilities:{textDocument:{references:{dynamicRegistration:!1},definition:{dynamicRegistration:!1},callHierarchy:{dynamicRegistration:!1},hover:{dynamicRegistration:!1}}},initializationOptions:f},{timeoutMs:n.requestTimeoutMs,deadlineMs:n.readinessDeadlineMs}),()=>({linkedProjects:r.length,relativePaths:i.length})),()=>l.shutdown({deadlineMs:n.readinessDeadlineMs}).catch(()=>{})),m={key:o,client:l,capabilities:u.capabilities,openedPaths:new Set,initializationReadiness:p};return P.set(o,m),m}async function Ce(e,t){let i=W(t).filter(l=>e.openedPaths.has(l.relativePath)?!1:pe(K(t.projectRoot,l.relativePath)));if(i.length===0)return await he(e),0;let n=e.initializationReadiness,r=t.readinessDeadlineMs===void 0?null:{statusSnapshot:n?null:e.client.serverStatusSnapshot(),initializationGeneration:n?.afterGeneration,deadlineMs:t.readinessDeadlineMs},a=ce(e.client,t.projectRoot,i);for(let l of i)e.openedPaths.add(l.relativePath);let o=t.diagnosticsTimeoutMs??1e4,c=o;await d("rust.semantic.worker.diagnostics",()=>r?N(l=>(c=l,k(e.client,a,l)),o,r.deadlineMs):k(e.client,a,o),()=>({openedDocuments:a.length,timeoutMs:c}));let f=t.settleDelayMs??5e3;if(!r)await d("rust.semantic.worker.settle",()=>b(f),()=>({openedDocuments:a.length,settleDelayMs:f}));else{let l;await d("rust.semantic.worker.readiness",async()=>{let p=m=>d("rust.semantic.worker.settle",()=>b(m),()=>({openedDocuments:a.length,settleDelayMs:m})),u=r.initializationGeneration===void 0?await G(e.client,r.statusSnapshot,a.length,r.deadlineMs,f,Date.now,p):await F(e.client,r.initializationGeneration,a.length,r.deadlineMs,f,Date.now,p);r.initializationGeneration!==void 0&&(e.initializationReadiness=null),l=u?.health},()=>({phase:r.initializationGeneration===void 0?"didOpen":"initialize+didOpen",openedDocuments:a.length,health:l}))}return a.length}async function Ae(e,t,i,n){let r=i.filter(u=>e.openedPaths.has(u)?!1:pe(K(t,u)));if(r.length===0)return await he(e),0;let a=e.initializationReadiness,o=n.readinessDeadlineMs===void 0?null:{statusSnapshot:a?null:e.client.serverStatusSnapshot(),initializationGeneration:a?.afterGeneration,deadlineMs:n.readinessDeadlineMs},c=[];for(let u of r){let m=A(t,u);e.client.didOpenTextDocument({uri:m,languageId:"rust",version:1,text:we(K(t,u),"utf8")}),e.openedPaths.add(u),c.push(m)}let f=n.diagnosticsTimeoutMs??1e4,l=f;await d("rust.semantic.worker.diagnostics",()=>o?N(u=>(l=u,k(e.client,c,u)),f,o.deadlineMs):k(e.client,c,f),()=>({openedDocuments:c.length,timeoutMs:l}));let p=n.settleDelayMs??5e3;if(!o)await d("rust.semantic.worker.settle",()=>b(p),()=>({openedDocuments:c.length,settleDelayMs:p}));else{let u;await d("rust.semantic.worker.readiness",async()=>{let m=y=>d("rust.semantic.worker.settle",()=>b(y),()=>({openedDocuments:c.length,settleDelayMs:y})),M=o.initializationGeneration===void 0?await G(e.client,o.statusSnapshot,c.length,o.deadlineMs,p,Date.now,m):await F(e.client,o.initializationGeneration,c.length,o.deadlineMs,p,Date.now,m);o.initializationGeneration!==void 0&&(e.initializationReadiness=null),u=M?.health},()=>({phase:o.initializationGeneration===void 0?"didOpen":"initialize+didOpen",openedDocuments:c.length,health:u}))}return c.length}async function he(e){let t=e.initializationReadiness;if(!t)return;let i;await d("rust.semantic.worker.readiness",async()=>{i=(await F(e.client,t.afterGeneration,0,t.deadlineMs,0)).health,e.initializationReadiness=null},()=>({phase:"initialize",openedDocuments:0,health:i}))}function Fe(e,t){for(let i of t){let n=q(e,i.uri);if(!(!n||n===".."||n.startsWith("../")||De(n)))return n}return null}function Ee(e,t){return t.references&&!e.referencesProvider?"rust-analyzer initialized without textDocument/references support.":t.callees&&!e.callHierarchyProvider?"rust-analyzer initialized without call hierarchy support.":t.signatures&&!e.hoverProvider?"rust-analyzer initialized without hover support.":null}function ye(e,t){let i=j(e),n=H(e),r=U(e);return{available:!1,reason:t,references:i.map(a=>[a.symbolId,[]]),...e.includeCallees?{callees:n.map(a=>[a.symbolId,[]])}:{},...e.includeSignatures?{signatures:r.map(a=>[a.symbolId,null])}:{}}}async function We(){let e=[...P.values()];P.clear(),await Promise.all(e.map(t=>t.client.shutdown().catch(()=>{})))}async function ge(e,t,i){e.get(t.key)===t&&e.delete(t.key),await t.client.shutdown({deadlineMs:i}).catch(()=>{})}function Le(e,t,i){return JSON.stringify({binary:e,sessionRoot:t,linkedProjects:i})}function _e(e,t,i){if(!e)return;let n=Oe(e,t);n.definitions+=1,i.hasReferences&&(n.definitionsWithReferences+=1),n.references+=i.references,n.durationMs+=i.durationMs,n.maxDurationMs=Math.max(n.maxDurationMs,i.durationMs),i.slow&&(n.slowTasks+=1)}function xe(e){if(!e)return;let t=[...e.entries()].sort(([i,n],[r,a])=>a.durationMs-n.durationMs||i.localeCompare(r));for(let[i,n]of t)D({type:"span",name:"rust.semantic.worker.references.by-file",durationMs:n.durationMs,ok:!0,relativePath:i,definitions:n.definitions,definitionsWithReferences:n.definitionsWithReferences,references:n.references,maxDurationMs:n.maxDurationMs,slowTasks:n.slowTasks,aggregate:"sum-task-duration"})}function Oe(e,t){let i=e.get(t);if(i)return i;let n={definitions:0,definitionsWithReferences:0,references:0,durationMs:0,maxDurationMs:0,slowTasks:0};return e.set(t,n),n}function Ge(e,t,i){if(!e)return;let n=Be(e,t);n.definitions+=1,i.hasCallees&&(n.definitionsWithCallees+=1),n.callees+=i.callees,n.durationMs+=i.durationMs,n.maxDurationMs=Math.max(n.maxDurationMs,i.durationMs),i.slow&&(n.slowTasks+=1)}function Ne(e){if(!e)return;let t=[...e.entries()].sort(([i,n],[r,a])=>a.durationMs-n.durationMs||i.localeCompare(r));for(let[i,n]of t)D({type:"span",name:"rust.semantic.worker.callees.by-file",durationMs:n.durationMs,ok:!0,relativePath:i,definitions:n.definitions,definitionsWithCallees:n.definitionsWithCallees,callees:n.callees,maxDurationMs:n.maxDurationMs,slowTasks:n.slowTasks,aggregate:"sum-task-duration"})}function Be(e,t){let i=e.get(t);if(i)return i;let n={definitions:0,definitionsWithCallees:0,callees:0,durationMs:0,maxDurationMs:0,slowTasks:0};return e.set(t,n),n}function me(e){if(e===void 0||e==="")return null;let t=Number(e);return Number.isInteger(t)&&t>=0?t:null}function je(){let e=_.env.SCIP_RUST_SEMANTIC_PARALLEL_OPERATIONS;return e!=="0"&&e!=="false"}function g(e,t,i){Pe(e,JSON.stringify(t));let n=new Int32Array(i);Atomics.store(n,0,1),Atomics.notify(n,0)}export{ge as discardRustAnalyzerSession};
|
|
2
2
|
//# sourceMappingURL=rust-semantic-session-worker.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{A as o,B as p,C as q,D as r,m as a,n as b,o as c,p as d,q as e,r as f,s as g,t as h,u as i,v as j,w as k,x as l,y as m,z as n}from"./chunk-
|
|
1
|
+
import{A as o,B as p,C as q,D as r,m as a,n as b,o as c,p as d,q as e,r as f,s as g,t as h,u as i,v as j,w as k,x as l,y as m,z as n}from"./chunk-MQ2B33LQ.js";export{p as calleesForDefinition,k as cargoManifestsForDefinitions,h as hoverToRustSignature,g as hoverWithRetry,l as openDefinitionDocuments,o as referencesWithCompletion,n as referencesWithRetry,a as runRustAnalyzerReferenceBatch,r as runWithConcurrency,i as rustAnalyzerInitializationOptions,j as rustAnalyzerSessionRoot,c as rustRequestCalleeDefinitions,b as rustRequestReferenceDefinitions,e as rustRequestSessionDefinitions,d as rustRequestSignatureDefinitions,f as signatureForDefinition,q as sleep,m as waitForOpenedDocuments};
|
|
2
2
|
//# sourceMappingURL=rust-semantic-worker.js.map
|
package/dist/watch-server.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{A as Et,B as Q,C as Ft,D as At,E as je,G as H,H as Lt,I as le,J as de,K as pe,L as Nt,N as jt,O as _e,P as _t,Q as Ot,U as Oe,V as Wt,W as $t,X as B,a as ft,b as mt,c as ht,d as De,e as gt,f as Ee,g as yt,ga as Gt,h as St,i as vt,ja as We,k as Fe,l as Ae,m as xt,n as It,p as Rt,pa as qt,q as Ct,r as wt,ra as Ut,s as Mt,sa as fe,t as kt,ta as Ht,u as Pt,ua as Bt,va as Vt,w as Tt,x as Dt,y as Le,z as Ne}from"./chunk-IXORBCMR.js";import{b as dt,c as pt,f as bt,h as J,l as U,m as ue}from"./chunk-VV5WJLRO.js";import{a as j,b as F}from"./chunk-KHE7J5ZN.js";import{a as ce,c as ut,d as Te,e as N}from"./chunk-JHK2DMUQ.js";import P from"process";import{rmSync as Yr}from"fs";import{resolve as ro}from"path";import{pathToFileURL as no}from"url";import{readFileSync as Xr,writeFileSync as mo,existsSync as Zr}from"fs";import{isAbsolute as go,join as en,relative as yo,resolve as So}from"path";var $e=".scipquery.json",tn=250,rn=0,nn=10*6e4,on={enabled:!1,debounceMs:tn,cooldownMs:rn,gitPollMs:2e3,idleTimeoutMs:nn,autoRefresh:!0,ignore:[]},sn=["typescript","javascript","java","scala","kotlin","rust","python","ruby","go","cpp","c","csharp","vb","dart","php","clojure"];var bo=new Set(sn);function V(r){let e=en(r,$e);if(!Zr(e))return{};try{let t=Xr(e,"utf-8");return JSON.parse(t)}catch(t){let n=t instanceof Error?t.message:String(t);throw t instanceof SyntaxError?new Error(`invalid ${$e} at ${e}: ${n}`,{cause:t}):new Error(`unable to read ${$e} at ${e}: ${n}`,{cause:t})}}function me(r){return{...on,...r.watch}}import{existsSync as Kt,readFileSync as an}from"fs";function Ge(r,e,t){let n=new Date().toISOString();if(!Kt(t.dbPath))return{state:"missing",checkedAt:n,metaPath:t.metaPath,reason:"No SQLite index database exists.",remedy:"Run: scip-query reindex"};if(!Kt(t.metaPath))return{state:"unknown",checkedAt:n,metaPath:t.metaPath,reason:"No reindex metadata file exists next to the SQLite index.",remedy:"Run: scip-query reindex"};try{let i=JSON.parse(an(t.metaPath,"utf-8")),o=e.languages??Ot(r),a=cn(r,o,e),s=Array.isArray(i.indexedLanguages)?[...i.indexedLanguages].sort():[],c=(i.version===2||i.version===3)&&i.status==="complete"&&JSON.stringify(i.fingerprint)===JSON.stringify(a)&&JSON.stringify(s)===JSON.stringify(a.languages),l=Gt(t.dbPath,t.metaPath),d=l.state==="invalid"||l.state==="drifted",p=c&&!d;return{state:p?"fresh":"stale",checkedAt:n,metaPath:t.metaPath,updatedAt:i.updatedAt,lastRefresh:i.lastRefresh,reason:d?`SQLite generation requires repair: ${l.reason}`:c?"Index metadata fingerprint matches current source files.":"Index metadata fingerprint differs from current source files.",remedy:p?void 0:"Run: scip-query reindex"}}catch(i){return{state:"unknown",checkedAt:n,metaPath:t.metaPath,reason:`Could not read reindex metadata: ${i instanceof Error?i.message:String(i)}`,remedy:"Run: scip-query reindex"}}}function cn(r,e,t){return bt(r,e,{pnpmWorkspaces:t.indexer?.typescript?.pnpmWorkspaces,typescriptProjectMode:t.indexer?.typescript?.projectMode,typescriptProjects:t.indexer?.typescript?.projects,clojureConfigPath:t.indexer?.clojure?.configPath})}import{fork as ln}from"child_process";import{statSync as dn}from"fs";import{isAbsolute as pn,join as un,relative as fn}from"path";import{watch as mn}from"chokidar";import hn from"ignore";var he=class{projectRoot;config;watchConfig;languages;pnpmWorkspaces;typescriptProjectMode;typescriptProjects;clojureConfigPath;indexerConcurrency;onStatus;onReindexComplete;onError;status={state:"idle"};debounceTimer=null;cooldownTimer=null;dirty=!1;changedFiles=0;pendingTrigger=null;reindexInFlight=!1;lastReindexEnd=0;fsWatchers=[];gitPollTimer=null;lastGitState=null;gitignoreFilter;extraIgnore;stopped=!1;constructor(e){this.projectRoot=e.projectRoot,this.config=e.config,this.watchConfig=me(e.config),this.languages=e.languages,this.pnpmWorkspaces=e.config.indexer?.typescript?.pnpmWorkspaces??!1,this.typescriptProjectMode=e.config.indexer?.typescript?.projectMode,this.typescriptProjects=e.config.indexer?.typescript?.projects,this.clojureConfigPath=e.config.indexer?.clojure?.configPath,this.indexerConcurrency=e.config.indexerConcurrency,this.onStatus=e.onStatus??(()=>{}),this.onReindexComplete=e.onReindexComplete??(()=>{}),this.onError=e.onError??(t=>console.error(t.message)),this.gitignoreFilter=ue(e.projectRoot),this.extraIgnore=hn(),this.watchConfig.ignore.length>0&&this.extraIgnore.add(this.watchConfig.ignore)}start(){this.stopped=!1,this.setStatus({state:"idle"}),this.startGitStatePolling();try{let e=mn(this.projectRoot,{ignoreInitial:!0,ignored:(t,n)=>this.isIgnoredWatchPath(t,n?.isDirectory()??!1)});e.on("all",(t,n)=>{this.stopped||this.handleFileChange(n)}),e.on("error",t=>{this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(t)}`))}),this.fsWatchers.push(e)}catch(e){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(e)}`))}}stop(){this.stopped=!0;for(let e of this.fsWatchers)e.close();this.fsWatchers=[],this.clearDebounceTimer(),this.clearCooldownTimer(),this.clearGitPollTimer(),this.setStatus({state:"idle"})}requestRefresh(e,t={}){if(!t.immediate||this.reindexInFlight||this.status.state==="cooldown"){this.scheduleReindex(e);return}this.pendingTrigger=zt(this.pendingTrigger,e),this.changedFiles+=1,this.clearDebounceTimer(),this.triggerReindex()}isIgnoredWatchPath(e,t){let n=this.relativeWatchPath(e);if(!n)return!1;let i=t?`${n}/`:n;return i===".git/"||i.startsWith(".git/")?!0:this.gitignoreFilter.isIgnored(i)||this.extraIgnore.ignores(i)}handleFileChange(e){let t=this.relativeWatchPath(e);!t||t===".."||t.startsWith("../")||t===".git"||t.startsWith(".git/")||this.gitignoreFilter.isIgnored(t)||this.extraIgnore.ignores(t)||t.endsWith("index.db")||t.endsWith("index.scip")||t.endsWith("index.db.tmp")||this.scheduleReindex({kind:"watch-source",detail:t})}relativeWatchPath(e){let t=pn(e)?e:un(this.projectRoot,e);return fn(this.projectRoot,t).replaceAll("\\","/")}scheduleReindex(e){if(this.pendingTrigger=zt(this.pendingTrigger,e),this.changedFiles++,this.reindexInFlight){this.dirty=!0,this.setStatus({state:"indexing",startedAt:this.status.startedAt});return}if(this.status.state==="cooldown"){this.dirty=!0,this.setStatus({state:"cooldown",until:this.status.until,dirty:!0});return}this.clearDebounceTimer();let t=Date.now()+this.watchConfig.debounceMs;this.setStatus({state:"waiting",changedFiles:this.changedFiles,reindexAt:t}),this.debounceTimer=setTimeout(()=>{this.debounceTimer=null,this.triggerReindex()},this.watchConfig.debounceMs)}triggerReindex(){if(this.reindexInFlight||this.stopped)return;let e=Date.now()-this.lastReindexEnd;if(this.lastReindexEnd>0&&e<this.watchConfig.cooldownMs){let i=this.watchConfig.cooldownMs-e;this.dirty=!0;let o=Date.now()+i;this.setStatus({state:"cooldown",until:o,dirty:!0}),this.cooldownTimer=setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped&&(this.dirty=!1,this.triggerReindex())},i);return}this.reindexInFlight=!0,this.dirty=!1,this.changedFiles=0;let t=this.pendingTrigger??{kind:"watch-source"};this.pendingTrigger=null;let n=Date.now();this.setStatus({state:"indexing",startedAt:n}),this.runReindex(t).then(i=>{if(this.reindexInFlight=!1,this.lastReindexEnd=Date.now(),this.onReindexComplete(i),this.dirty&&!this.stopped){let o=Date.now()+this.watchConfig.cooldownMs;this.setStatus({state:"cooldown",until:o,dirty:!0}),this.cooldownTimer=setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped?(this.dirty=!1,this.triggerReindex()):this.setStatus({state:"idle"})},this.watchConfig.cooldownMs)}else this.setStatus({state:"idle"})}).catch(i=>{this.reindexInFlight=!1,this.lastReindexEnd=Date.now(),this.onError(i instanceof Error?i:new Error(String(i))),this.setStatus({state:"idle"})})}runReindex(e){return new Promise((t,n)=>{let i=Date.now(),o=V(this.projectRoot),a=Object.keys(o).length>0?o:this.config,s=B(this.projectRoot,a),c=a.indexer?.typescript,l=a.indexer?.clojure,d=ln(new URL("./reindex-worker.js",import.meta.url).pathname,[],{detached:!0,env:{...process.env,SCIP_REINDEX_PROJECT_ROOT:this.projectRoot,SCIP_REINDEX_OUTPUT_SCIP:s.indexPath,SCIP_REINDEX_OUTPUT_DB:s.dbPath,SCIP_REINDEX_LANGUAGES:(a.languages??this.languages)?.join(",")??"",SCIP_REINDEX_INDEXER_CONCURRENCY:String(a.indexerConcurrency??this.indexerConcurrency??""),SCIP_REINDEX_PNPM_WORKSPACES:c?.pnpmWorkspaces??this.pnpmWorkspaces?"1":"",SCIP_REINDEX_TYPESCRIPT_CONFIG:JSON.stringify({projectMode:c?.projectMode??this.typescriptProjectMode,projects:c?.projects??this.typescriptProjects??[]}),SCIP_REINDEX_CLOJURE_CONFIG_PATH:l?.configPath??this.clojureConfigPath??"",SCIP_REINDEX_TRIGGER_KIND:e.kind,SCIP_REINDEX_TRIGGER_DETAIL:e.detail??""},stdio:"pipe"});d.on("exit",p=>{p===0?t(Date.now()-i):n(new Error(`Reindex worker exited with code ${p}`))}),d.on("error",n)})}setStatus(e){this.status=e,this.onStatus(e)}clearDebounceTimer(){this.debounceTimer&&(clearTimeout(this.debounceTimer),this.debounceTimer=null)}clearCooldownTimer(){this.cooldownTimer&&(clearTimeout(this.cooldownTimer),this.cooldownTimer=null)}startGitStatePolling(){this.lastGitState=this.readGitState(),this.lastGitState&&(this.gitPollTimer=setInterval(()=>this.pollGitState(),this.watchConfig.gitPollMs),this.gitPollTimer.unref?.())}pollGitState(){let e=this.lastGitState,t=this.readGitState();if(!e||!t||this.stopped){this.lastGitState=t;return}this.lastGitState=t;let n=e.head!==t.head,i=e.indexPath!==t.indexPath||e.indexMtimeMs!==t.indexMtimeMs||e.indexSize!==t.indexSize;n&&i?this.scheduleReindex({kind:"watch-git-state",detail:"HEAD and index changed"}):n?this.scheduleReindex({kind:"watch-git-head",detail:"HEAD changed"}):i&&this.scheduleReindex({kind:"watch-git-index",detail:t.indexPath??"index changed"})}readGitState(){let e=De(this.projectRoot,["rev-parse","--git-path","index"]);if(!e)return null;let t=gt(this.projectRoot,e),n={head:De(this.projectRoot,["rev-parse","--verify","HEAD"]),indexPath:t};try{let i=dn(t);n.indexMtimeMs=i.mtimeMs,n.indexSize=i.size}catch{n.indexMtimeMs=void 0,n.indexSize=void 0}return n}clearGitPollTimer(){this.gitPollTimer&&(clearInterval(this.gitPollTimer),this.gitPollTimer=null)}};function zt(r,e){return r?r.kind===e.kind?r.detail===e.detail?r:{kind:r.kind,detail:"multiple changes"}:{kind:"watch-git-state",detail:`${r.kind}, ${e.kind}`}:e}import{existsSync as er,statSync as In}from"fs";import{join as Rn}from"path";import{createHash as gn}from"crypto";import{readFileSync as yn}from"fs";import{dirname as Sn,join as ge}from"path";var X=2,bn="typescript-semantic";function Jt(r){let e=ge(r,bn);return{rootDir:e,requestDir:ge(e,"requests"),responseDir:ge(e,"responses")}}function Z(r){try{let e=JSON.parse(yn(ge(Sn(r),"meta.json"),"utf8"));return e.version!==2&&e.version!==3||typeof e.status!="string"||typeof e.updatedAt!="string"||e.fingerprint===void 0?null:gn("sha256").update(JSON.stringify({version:e.version,status:e.status,updatedAt:e.updatedAt,fingerprint:e.fingerprint,indexedLanguages:e.indexedLanguages})).digest("hex")}catch{return null}}function Qt(r){let e=JSON.parse(r);if(e.protocolVersion!==X||typeof e.id!="string"||typeof e.generation!="string"||typeof e.deadlineAtMs!="number"||e.profileEnvironment!==void 0&&!vn(e.profileEnvironment)||!e.request||!xn(e.request))throw new Error("TypeScript semantic service received an invalid mailbox request.");return e}function vn(r){return!!r&&typeof r=="object"&&!Array.isArray(r)&&Object.values(r).every(e=>typeof e=="string"||e===null)}function xn(r){if(!r||typeof r!="object"||!("kind"in r))return!1;let e=r;switch(e.kind){case"availability":return!0;case"import-usage":return typeof e.file=="string";case"reference-fragments":return Et(e.files)!==null;case"references":return Yt(e.definitions)&&(e.exact===void 0||typeof e.exact=="boolean");case"callees":return Yt(e.definitions);case"signature":return Xt(e.definition);default:return!1}}function Yt(r){return Array.isArray(r)&&r.every(Xt)}function Xt(r){if(!r||typeof r!="object")return!1;let e=r;return typeof e.symbolId=="number"&&typeof e.documentId=="number"&&typeof e.symbol=="string"&&typeof e.relativePath=="string"&&typeof e.leaf=="string"&&typeof e.startLine=="number"&&typeof e.endLine=="number"}function Cn(){return process.env.SCIP_QUERY_PROJECT_ROOT??process.cwd()}var Zt;function wn(r=Cn(),e=void 0){if(e===void 0&&Zt?.projectRoot===r)return Zt;let t=V(r),n=B(r,t),i=process.env.SCIP_QUERY_INDEX_DB;if(i)return{projectRoot:r,config:t,paths:n,dbPath:i,dbPathSource:"env",gitContext:e};if(er(n.dbPath))return{projectRoot:r,config:t,paths:n,dbPath:n.dbPath,dbPathSource:"configured",gitContext:e};let o=Rn(r,"index.db");return{projectRoot:r,config:t,paths:n,dbPath:o,dbPathSource:"root-fallback",rootFallbackWarning:Mn(o,n.dbPath),gitContext:e}}function tr(r,e={}){let{config:t,paths:n,dbPath:i,dbPathSource:o,rootFallbackWarning:a,gitContext:s}=wn(r);if(!er(i))throw new Error("No index.db found. Run: scip-query reindex");e.warnOnRootFallback&&o==="root-fallback"&&a&&console.error(a);let c={dbPath:i,indexPath:process.env.SCIP_QUERY_INDEX_SCIP??n.indexPath,projectRoot:r,sharedEvidenceDbPath:We(r,t,s),entryRoots:t.entryRoots,semantic:t.semantic,suppressions:t.suppressions,declaredCouplings:t.declaredCouplings,locality:t.locality,architecture:t.architecture,coverageContracts:t.coverageContracts,docs:t.docs},l=ue(r);return new vt(c,l)}function Mn(r,e){let t="unknown time";try{t=In(r).mtime.toISOString()}catch{}return`warning: using legacy project-root index.db (${r}, modified ${t}) because the configured index was not found at ${e}. This fallback may be stale; run 'scip-query reindex' to refresh the configured index.`}import{mkdirSync as Pr,readFileSync as Tr,readdirSync as wi,rmSync as Mi}from"fs";import{resolve as Ie}from"path";import{resolve as kr}from"path";import{performance as y}from"perf_hooks";function ye(r){return{forFile(e,t){return rr(r,e,t)},forFiles(e,t){let n=new Map;for(let i of e)n.set(i,rr(r,i,t));return n}}}function rr(r,e,t){let n={file:e},i=t.facts||t.identifiers;if(t.text&&(n.text=Ct(r,e)),t.lines&&(n.lines=wt(r,e)),t.ast&&(n.ast=Mt(r,e)),t.imports&&(n.imports=At(r,e)),t.reexports&&(n.reexports=Ft(r,e)),i){let o=kt(r,e),a=o.facts;t.facts&&(n.facts=a),o.unavailable&&(n.sourceFactsUnavailable=o.unavailable),t.identifiers&&a&&(n.identifiers=a.fileIdentifiers,n.identifierLineMap=a.identifierLineMap)}return n}var kn={"/":"namespace","#":"type",".":"term","[":"type-param",":":"meta","!":"macro"};function Se(r){if(r.startsWith("local "))return{kind:"local",id:r.slice(6),raw:r};let e=r.split(" ");if(e.length<4)return{scheme:e[0]??"",manager:e[1]??"",packageName:e[2]??"",version:"",descriptors:[],raw:r};let t=e[0],n=e[1],i=r.slice(t.length+1+n.length+1),o;if(i.startsWith("`")){let l=i.indexOf("`",1);l===-1?(o=i.slice(1),i=""):(o=i.slice(1,l),i=i.slice(l+2))}else{let l=i.indexOf(" ");l===-1?(o=i,i=""):(o=i.slice(0,l),i=i.slice(l+1))}let a,s=i.indexOf(" ");s===-1?(a=i,i=""):(a=i.slice(0,s),i=i.slice(s+1));let c=Pn(i);return{scheme:t,manager:n,packageName:o,version:a,descriptors:c,raw:r}}function K(r){let e=Se(r);if("kind"in e)return null;for(let t=e.descriptors.length-2;t>=0;t--){let n=e.descriptors[t];if(n?.suffix==="type")return n.name}return null}function Pn(r){let e=[],t=0;for(;t<r.length;){if(r[t]==="["){let o=r.indexOf("]",t+1);if(o===-1){e.push({name:r.slice(t+1),suffix:"type-param"});break}e.push({name:r.slice(t+1,o),suffix:"type-param"}),t=o+1;continue}if(r[t]==="("&&(e.length===0||t===0||nr(r[t-1]))){let o=r.indexOf(")",t+1);if(o!==-1&&r[o+1]!=="."){e.push({name:r.slice(t+1,o),suffix:"parameter"}),t=o+1;continue}}let n;if(r[t]==="`"){let o=r.indexOf("`",t+1);if(o===-1){n=r.slice(t+1),e.push({name:n,suffix:"term"});break}n=r.slice(t+1,o),t=o+1}else{let o=t;for(;t<r.length&&!nr(r[t]);)t++;n=r.slice(o,t)}if(t>=r.length){n&&e.push({name:n,suffix:"term"});break}let i=r[t];if(i==="("){let o=r.indexOf(")",t+1);o!==-1&&r[o+1]==="."?(e.push({name:n,suffix:"method"}),t=o+2):o!==-1?(e.push({name:n,suffix:"method"}),t=o+1):(e.push({name:n,suffix:"term"}),t++)}else{let o=kn[i];o&&e.push({name:n,suffix:o}),t+=1}}return e}function nr(r){return r==="/"||r==="#"||r==="."||r==="("||r==="["||r===":"||r==="!"}function _(r){let e=Se(r);if("kind"in e&&e.kind==="local")return e.id;let t=e;return t.descriptors.length===0?"":t.descriptors[t.descriptors.length-1].name}function O(r){let e=Se(r);if("kind"in e&&e.kind==="local")return null;let t=e;return t.descriptors[t.descriptors.length-1]?.suffix??null}function ir(r){let e=O(r);return e==="method"?!0:e!=="term"?!1:r.endsWith("().")?!0:r.startsWith("rust-analyzer ")&&r.includes("#")?!1:r.startsWith("scip-typescript ")?!/#[A-Za-z0-9_$]+\.$/.test(r):!0}function Tn(r,e={}){if(K(r.symbol)!==null)return e.includeClassMemberFallbacks===!0;let i=(r.documentation??"").replace(/^```\w*\s*/,"").replace(/\s*```$/,"").trim();return/^(?:var|let|const|function|class|interface|type|enum)\b/.test(i)}function or(r,e,t={}){let n=new Map;for(let o of e)r.length>0&&!Tn(o,{includeClassMemberFallbacks:t.includeClassMemberFallbacks})||n.set(o.id,o);for(let o of r)n.set(o.id,o);let i=[...n.values()];return t.sort?i.sort((o,a)=>o.start_line-a.start_line||o.end_line-a.end_line||o.symbol.localeCompare(a.symbol)):i}var Dn=J("file-definitions",{clearGroups:["definition-catalog"]}),ys=J("file-function-like-definitions",{clearGroups:["definition-catalog"]});function W(r,e,t={}){return t.includeClassMemberFallbacks?sr(r,e,void 0,{includeClassMemberFallbacks:!0}):Dn.get(r,e,()=>{let n=En(r,e);if(n)return n;let i=sr(r,e),o=Ae(r),a=ye(r).forFile(e,{text:!0}).text;return o&&a&&cr.write(r,e,Fe(r,e,a),{projectFingerprint:o,definitions:i.map(s=>({...s}))}),i})}var cr=It({kind:"file-definitions",invalidation:Rt("file-definitions"),serialize:Fn,deserialize:An});function En(r,e){let t=Ae(r);if(!t)return null;let n=ye(r).forFile(e,{text:!0}).text;if(!n)return null;let i=cr.read(r,e,Fe(r,e,n));return i?Ln(i,t,e):null}function Fn(r){return JSON.stringify(r)}function An(r){try{let e=JSON.parse(r);return!Ne(e)||typeof e.projectFingerprint!="string"||!Array.isArray(e.definitions)?null:{projectFingerprint:e.projectFingerprint,definitions:e.definitions}}catch{return null}}function Ln(r,e,t){if(r.projectFingerprint!==e)return null;let n=[];for(let i of r.definitions){let o=Nn(i,t);if(!o)return null;n.push(o)}return n}function Nn(r,e){return!Ne(r)||typeof r.symbolId!="number"||typeof r.symbol!="string"||typeof r.documentId!="number"||typeof r.startLine!="number"||typeof r.startChar!="number"&&r.startChar!==void 0||typeof r.endLine!="number"||typeof r.endChar!="number"&&r.endChar!==void 0||r.relativePath!==e||typeof r.leaf!="string"||typeof r.parentTypeName!="string"&&r.parentTypeName!==null||typeof r.isFunctionLike!="boolean"||typeof r.isTypeLike!="boolean"||typeof r.kind!="number"&&r.kind!==null||typeof r.documentation!="string"&&r.documentation!==null||typeof r.enclosingSymbol!="string"&&r.enclosingSymbol!==null?null:{symbolId:r.symbolId,symbol:r.symbol,documentId:r.documentId,startLine:r.startLine,startChar:r.startChar,endLine:r.endLine,endChar:r.endChar,relativePath:r.relativePath,leaf:r.leaf,parentTypeName:r.parentTypeName,isFunctionLike:r.isFunctionLike,isTypeLike:r.isTypeLike,kind:r.kind,documentation:r.documentation,enclosingSymbol:r.enclosingSymbol}}function sr(r,e,t,n={}){let i=or(jn(r,e),_n(r,e),{sort:!0,includeClassMemberFallbacks:n.includeClassMemberFallbacks}).map(On);return t&&(i=i.filter(t)),$n(r,e,i)}function jn(r,e){return r.all(`SELECT
|
|
1
|
+
import{A as Et,B as Q,C as Ft,D as At,E as je,G as H,H as Lt,I as le,J as de,K as pe,L as Nt,N as jt,O as _e,P as _t,Q as Ot,U as Oe,V as Wt,W as $t,X as B,a as ft,b as mt,c as ht,d as De,e as gt,f as Ee,g as yt,ga as Gt,h as St,i as vt,ja as We,k as Fe,l as Ae,m as xt,n as It,p as Rt,pa as qt,q as Ct,r as wt,ra as Ut,s as Mt,sa as fe,t as kt,ta as Ht,u as Pt,ua as Bt,va as Vt,w as Tt,x as Dt,y as Le,z as Ne}from"./chunk-2NA6TYP4.js";import{b as dt,c as pt,f as bt,h as J,l as U,m as ue}from"./chunk-MP43RX4O.js";import{a as j,b as F}from"./chunk-KHE7J5ZN.js";import{a as ce,c as ut,d as Te,e as N}from"./chunk-HGFDYOVB.js";import P from"process";import{rmSync as Yr}from"fs";import{resolve as ro}from"path";import{pathToFileURL as no}from"url";import{readFileSync as Xr,writeFileSync as mo,existsSync as Zr}from"fs";import{isAbsolute as go,join as en,relative as yo,resolve as So}from"path";var $e=".scipquery.json",tn=250,rn=0,nn=10*6e4,on={enabled:!1,debounceMs:tn,cooldownMs:rn,gitPollMs:2e3,idleTimeoutMs:nn,autoRefresh:!0,ignore:[]},sn=["typescript","javascript","java","scala","kotlin","rust","python","ruby","go","cpp","c","csharp","vb","dart","php","clojure"];var bo=new Set(sn);function V(r){let e=en(r,$e);if(!Zr(e))return{};try{let t=Xr(e,"utf-8");return JSON.parse(t)}catch(t){let n=t instanceof Error?t.message:String(t);throw t instanceof SyntaxError?new Error(`invalid ${$e} at ${e}: ${n}`,{cause:t}):new Error(`unable to read ${$e} at ${e}: ${n}`,{cause:t})}}function me(r){return{...on,...r.watch}}import{existsSync as Kt,readFileSync as an}from"fs";function Ge(r,e,t){let n=new Date().toISOString();if(!Kt(t.dbPath))return{state:"missing",checkedAt:n,metaPath:t.metaPath,reason:"No SQLite index database exists.",remedy:"Run: scip-query reindex"};if(!Kt(t.metaPath))return{state:"unknown",checkedAt:n,metaPath:t.metaPath,reason:"No reindex metadata file exists next to the SQLite index.",remedy:"Run: scip-query reindex"};try{let i=JSON.parse(an(t.metaPath,"utf-8")),o=e.languages??Ot(r),a=cn(r,o,e),s=Array.isArray(i.indexedLanguages)?[...i.indexedLanguages].sort():[],c=(i.version===2||i.version===3)&&i.status==="complete"&&JSON.stringify(i.fingerprint)===JSON.stringify(a)&&JSON.stringify(s)===JSON.stringify(a.languages),l=Gt(t.dbPath,t.metaPath),d=l.state==="invalid"||l.state==="drifted",p=c&&!d;return{state:p?"fresh":"stale",checkedAt:n,metaPath:t.metaPath,updatedAt:i.updatedAt,lastRefresh:i.lastRefresh,reason:d?`SQLite generation requires repair: ${l.reason}`:c?"Index metadata fingerprint matches current source files.":"Index metadata fingerprint differs from current source files.",remedy:p?void 0:"Run: scip-query reindex"}}catch(i){return{state:"unknown",checkedAt:n,metaPath:t.metaPath,reason:`Could not read reindex metadata: ${i instanceof Error?i.message:String(i)}`,remedy:"Run: scip-query reindex"}}}function cn(r,e,t){return bt(r,e,{pnpmWorkspaces:t.indexer?.typescript?.pnpmWorkspaces,typescriptProjectMode:t.indexer?.typescript?.projectMode,typescriptProjects:t.indexer?.typescript?.projects,clojureConfigPath:t.indexer?.clojure?.configPath})}import{fork as ln}from"child_process";import{statSync as dn}from"fs";import{isAbsolute as pn,join as un,relative as fn}from"path";import{watch as mn}from"chokidar";import hn from"ignore";var he=class{projectRoot;config;watchConfig;languages;pnpmWorkspaces;typescriptProjectMode;typescriptProjects;clojureConfigPath;indexerConcurrency;onStatus;onReindexComplete;onError;status={state:"idle"};debounceTimer=null;cooldownTimer=null;dirty=!1;changedFiles=0;pendingTrigger=null;reindexInFlight=!1;lastReindexEnd=0;fsWatchers=[];gitPollTimer=null;lastGitState=null;gitignoreFilter;extraIgnore;stopped=!1;constructor(e){this.projectRoot=e.projectRoot,this.config=e.config,this.watchConfig=me(e.config),this.languages=e.languages,this.pnpmWorkspaces=e.config.indexer?.typescript?.pnpmWorkspaces??!1,this.typescriptProjectMode=e.config.indexer?.typescript?.projectMode,this.typescriptProjects=e.config.indexer?.typescript?.projects,this.clojureConfigPath=e.config.indexer?.clojure?.configPath,this.indexerConcurrency=e.config.indexerConcurrency,this.onStatus=e.onStatus??(()=>{}),this.onReindexComplete=e.onReindexComplete??(()=>{}),this.onError=e.onError??(t=>console.error(t.message)),this.gitignoreFilter=ue(e.projectRoot),this.extraIgnore=hn(),this.watchConfig.ignore.length>0&&this.extraIgnore.add(this.watchConfig.ignore)}start(){this.stopped=!1,this.setStatus({state:"idle"}),this.startGitStatePolling();try{let e=mn(this.projectRoot,{ignoreInitial:!0,ignored:(t,n)=>this.isIgnoredWatchPath(t,n?.isDirectory()??!1)});e.on("all",(t,n)=>{this.stopped||this.handleFileChange(n)}),e.on("error",t=>{this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(t)}`))}),this.fsWatchers.push(e)}catch(e){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(e)}`))}}stop(){this.stopped=!0;for(let e of this.fsWatchers)e.close();this.fsWatchers=[],this.clearDebounceTimer(),this.clearCooldownTimer(),this.clearGitPollTimer(),this.setStatus({state:"idle"})}requestRefresh(e,t={}){if(!t.immediate||this.reindexInFlight||this.status.state==="cooldown"){this.scheduleReindex(e);return}this.pendingTrigger=zt(this.pendingTrigger,e),this.changedFiles+=1,this.clearDebounceTimer(),this.triggerReindex()}isIgnoredWatchPath(e,t){let n=this.relativeWatchPath(e);if(!n)return!1;let i=t?`${n}/`:n;return i===".git/"||i.startsWith(".git/")?!0:this.gitignoreFilter.isIgnored(i)||this.extraIgnore.ignores(i)}handleFileChange(e){let t=this.relativeWatchPath(e);!t||t===".."||t.startsWith("../")||t===".git"||t.startsWith(".git/")||this.gitignoreFilter.isIgnored(t)||this.extraIgnore.ignores(t)||t.endsWith("index.db")||t.endsWith("index.scip")||t.endsWith("index.db.tmp")||this.scheduleReindex({kind:"watch-source",detail:t})}relativeWatchPath(e){let t=pn(e)?e:un(this.projectRoot,e);return fn(this.projectRoot,t).replaceAll("\\","/")}scheduleReindex(e){if(this.pendingTrigger=zt(this.pendingTrigger,e),this.changedFiles++,this.reindexInFlight){this.dirty=!0,this.setStatus({state:"indexing",startedAt:this.status.startedAt});return}if(this.status.state==="cooldown"){this.dirty=!0,this.setStatus({state:"cooldown",until:this.status.until,dirty:!0});return}this.clearDebounceTimer();let t=Date.now()+this.watchConfig.debounceMs;this.setStatus({state:"waiting",changedFiles:this.changedFiles,reindexAt:t}),this.debounceTimer=setTimeout(()=>{this.debounceTimer=null,this.triggerReindex()},this.watchConfig.debounceMs)}triggerReindex(){if(this.reindexInFlight||this.stopped)return;let e=Date.now()-this.lastReindexEnd;if(this.lastReindexEnd>0&&e<this.watchConfig.cooldownMs){let i=this.watchConfig.cooldownMs-e;this.dirty=!0;let o=Date.now()+i;this.setStatus({state:"cooldown",until:o,dirty:!0}),this.cooldownTimer=setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped&&(this.dirty=!1,this.triggerReindex())},i);return}this.reindexInFlight=!0,this.dirty=!1,this.changedFiles=0;let t=this.pendingTrigger??{kind:"watch-source"};this.pendingTrigger=null;let n=Date.now();this.setStatus({state:"indexing",startedAt:n}),this.runReindex(t).then(i=>{if(this.reindexInFlight=!1,this.lastReindexEnd=Date.now(),this.onReindexComplete(i),this.dirty&&!this.stopped){let o=Date.now()+this.watchConfig.cooldownMs;this.setStatus({state:"cooldown",until:o,dirty:!0}),this.cooldownTimer=setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped?(this.dirty=!1,this.triggerReindex()):this.setStatus({state:"idle"})},this.watchConfig.cooldownMs)}else this.setStatus({state:"idle"})}).catch(i=>{this.reindexInFlight=!1,this.lastReindexEnd=Date.now(),this.onError(i instanceof Error?i:new Error(String(i))),this.setStatus({state:"idle"})})}runReindex(e){return new Promise((t,n)=>{let i=Date.now(),o=V(this.projectRoot),a=Object.keys(o).length>0?o:this.config,s=B(this.projectRoot,a),c=a.indexer?.typescript,l=a.indexer?.clojure,d=ln(new URL("./reindex-worker.js",import.meta.url).pathname,[],{detached:!0,env:{...process.env,SCIP_REINDEX_PROJECT_ROOT:this.projectRoot,SCIP_REINDEX_OUTPUT_SCIP:s.indexPath,SCIP_REINDEX_OUTPUT_DB:s.dbPath,SCIP_REINDEX_LANGUAGES:(a.languages??this.languages)?.join(",")??"",SCIP_REINDEX_INDEXER_CONCURRENCY:String(a.indexerConcurrency??this.indexerConcurrency??""),SCIP_REINDEX_PNPM_WORKSPACES:c?.pnpmWorkspaces??this.pnpmWorkspaces?"1":"",SCIP_REINDEX_TYPESCRIPT_CONFIG:JSON.stringify({projectMode:c?.projectMode??this.typescriptProjectMode,projects:c?.projects??this.typescriptProjects??[]}),SCIP_REINDEX_CLOJURE_CONFIG_PATH:l?.configPath??this.clojureConfigPath??"",SCIP_REINDEX_TRIGGER_KIND:e.kind,SCIP_REINDEX_TRIGGER_DETAIL:e.detail??""},stdio:"pipe"});d.on("exit",p=>{p===0?t(Date.now()-i):n(new Error(`Reindex worker exited with code ${p}`))}),d.on("error",n)})}setStatus(e){this.status=e,this.onStatus(e)}clearDebounceTimer(){this.debounceTimer&&(clearTimeout(this.debounceTimer),this.debounceTimer=null)}clearCooldownTimer(){this.cooldownTimer&&(clearTimeout(this.cooldownTimer),this.cooldownTimer=null)}startGitStatePolling(){this.lastGitState=this.readGitState(),this.lastGitState&&(this.gitPollTimer=setInterval(()=>this.pollGitState(),this.watchConfig.gitPollMs),this.gitPollTimer.unref?.())}pollGitState(){let e=this.lastGitState,t=this.readGitState();if(!e||!t||this.stopped){this.lastGitState=t;return}this.lastGitState=t;let n=e.head!==t.head,i=e.indexPath!==t.indexPath||e.indexMtimeMs!==t.indexMtimeMs||e.indexSize!==t.indexSize;n&&i?this.scheduleReindex({kind:"watch-git-state",detail:"HEAD and index changed"}):n?this.scheduleReindex({kind:"watch-git-head",detail:"HEAD changed"}):i&&this.scheduleReindex({kind:"watch-git-index",detail:t.indexPath??"index changed"})}readGitState(){let e=De(this.projectRoot,["rev-parse","--git-path","index"]);if(!e)return null;let t=gt(this.projectRoot,e),n={head:De(this.projectRoot,["rev-parse","--verify","HEAD"]),indexPath:t};try{let i=dn(t);n.indexMtimeMs=i.mtimeMs,n.indexSize=i.size}catch{n.indexMtimeMs=void 0,n.indexSize=void 0}return n}clearGitPollTimer(){this.gitPollTimer&&(clearInterval(this.gitPollTimer),this.gitPollTimer=null)}};function zt(r,e){return r?r.kind===e.kind?r.detail===e.detail?r:{kind:r.kind,detail:"multiple changes"}:{kind:"watch-git-state",detail:`${r.kind}, ${e.kind}`}:e}import{existsSync as er,statSync as In}from"fs";import{join as Rn}from"path";import{createHash as gn}from"crypto";import{readFileSync as yn}from"fs";import{dirname as Sn,join as ge}from"path";var X=2,bn="typescript-semantic";function Jt(r){let e=ge(r,bn);return{rootDir:e,requestDir:ge(e,"requests"),responseDir:ge(e,"responses")}}function Z(r){try{let e=JSON.parse(yn(ge(Sn(r),"meta.json"),"utf8"));return e.version!==2&&e.version!==3||typeof e.status!="string"||typeof e.updatedAt!="string"||e.fingerprint===void 0?null:gn("sha256").update(JSON.stringify({version:e.version,status:e.status,updatedAt:e.updatedAt,fingerprint:e.fingerprint,indexedLanguages:e.indexedLanguages})).digest("hex")}catch{return null}}function Qt(r){let e=JSON.parse(r);if(e.protocolVersion!==X||typeof e.id!="string"||typeof e.generation!="string"||typeof e.deadlineAtMs!="number"||e.profileEnvironment!==void 0&&!vn(e.profileEnvironment)||!e.request||!xn(e.request))throw new Error("TypeScript semantic service received an invalid mailbox request.");return e}function vn(r){return!!r&&typeof r=="object"&&!Array.isArray(r)&&Object.values(r).every(e=>typeof e=="string"||e===null)}function xn(r){if(!r||typeof r!="object"||!("kind"in r))return!1;let e=r;switch(e.kind){case"availability":return!0;case"import-usage":return typeof e.file=="string";case"reference-fragments":return Et(e.files)!==null;case"references":return Yt(e.definitions)&&(e.exact===void 0||typeof e.exact=="boolean");case"callees":return Yt(e.definitions);case"signature":return Xt(e.definition);default:return!1}}function Yt(r){return Array.isArray(r)&&r.every(Xt)}function Xt(r){if(!r||typeof r!="object")return!1;let e=r;return typeof e.symbolId=="number"&&typeof e.documentId=="number"&&typeof e.symbol=="string"&&typeof e.relativePath=="string"&&typeof e.leaf=="string"&&typeof e.startLine=="number"&&typeof e.endLine=="number"}function Cn(){return process.env.SCIP_QUERY_PROJECT_ROOT??process.cwd()}var Zt;function wn(r=Cn(),e=void 0){if(e===void 0&&Zt?.projectRoot===r)return Zt;let t=V(r),n=B(r,t),i=process.env.SCIP_QUERY_INDEX_DB;if(i)return{projectRoot:r,config:t,paths:n,dbPath:i,dbPathSource:"env",gitContext:e};if(er(n.dbPath))return{projectRoot:r,config:t,paths:n,dbPath:n.dbPath,dbPathSource:"configured",gitContext:e};let o=Rn(r,"index.db");return{projectRoot:r,config:t,paths:n,dbPath:o,dbPathSource:"root-fallback",rootFallbackWarning:Mn(o,n.dbPath),gitContext:e}}function tr(r,e={}){let{config:t,paths:n,dbPath:i,dbPathSource:o,rootFallbackWarning:a,gitContext:s}=wn(r);if(!er(i))throw new Error("No index.db found. Run: scip-query reindex");e.warnOnRootFallback&&o==="root-fallback"&&a&&console.error(a);let c={dbPath:i,indexPath:process.env.SCIP_QUERY_INDEX_SCIP??n.indexPath,projectRoot:r,sharedEvidenceDbPath:We(r,t,s),entryRoots:t.entryRoots,semantic:t.semantic,suppressions:t.suppressions,declaredCouplings:t.declaredCouplings,locality:t.locality,architecture:t.architecture,coverageContracts:t.coverageContracts,docs:t.docs},l=ue(r);return new vt(c,l)}function Mn(r,e){let t="unknown time";try{t=In(r).mtime.toISOString()}catch{}return`warning: using legacy project-root index.db (${r}, modified ${t}) because the configured index was not found at ${e}. This fallback may be stale; run 'scip-query reindex' to refresh the configured index.`}import{mkdirSync as Pr,readFileSync as Tr,readdirSync as wi,rmSync as Mi}from"fs";import{resolve as Ie}from"path";import{resolve as kr}from"path";import{performance as y}from"perf_hooks";function ye(r){return{forFile(e,t){return rr(r,e,t)},forFiles(e,t){let n=new Map;for(let i of e)n.set(i,rr(r,i,t));return n}}}function rr(r,e,t){let n={file:e},i=t.facts||t.identifiers;if(t.text&&(n.text=Ct(r,e)),t.lines&&(n.lines=wt(r,e)),t.ast&&(n.ast=Mt(r,e)),t.imports&&(n.imports=At(r,e)),t.reexports&&(n.reexports=Ft(r,e)),i){let o=kt(r,e),a=o.facts;t.facts&&(n.facts=a),o.unavailable&&(n.sourceFactsUnavailable=o.unavailable),t.identifiers&&a&&(n.identifiers=a.fileIdentifiers,n.identifierLineMap=a.identifierLineMap)}return n}var kn={"/":"namespace","#":"type",".":"term","[":"type-param",":":"meta","!":"macro"};function Se(r){if(r.startsWith("local "))return{kind:"local",id:r.slice(6),raw:r};let e=r.split(" ");if(e.length<4)return{scheme:e[0]??"",manager:e[1]??"",packageName:e[2]??"",version:"",descriptors:[],raw:r};let t=e[0],n=e[1],i=r.slice(t.length+1+n.length+1),o;if(i.startsWith("`")){let l=i.indexOf("`",1);l===-1?(o=i.slice(1),i=""):(o=i.slice(1,l),i=i.slice(l+2))}else{let l=i.indexOf(" ");l===-1?(o=i,i=""):(o=i.slice(0,l),i=i.slice(l+1))}let a,s=i.indexOf(" ");s===-1?(a=i,i=""):(a=i.slice(0,s),i=i.slice(s+1));let c=Pn(i);return{scheme:t,manager:n,packageName:o,version:a,descriptors:c,raw:r}}function K(r){let e=Se(r);if("kind"in e)return null;for(let t=e.descriptors.length-2;t>=0;t--){let n=e.descriptors[t];if(n?.suffix==="type")return n.name}return null}function Pn(r){let e=[],t=0;for(;t<r.length;){if(r[t]==="["){let o=r.indexOf("]",t+1);if(o===-1){e.push({name:r.slice(t+1),suffix:"type-param"});break}e.push({name:r.slice(t+1,o),suffix:"type-param"}),t=o+1;continue}if(r[t]==="("&&(e.length===0||t===0||nr(r[t-1]))){let o=r.indexOf(")",t+1);if(o!==-1&&r[o+1]!=="."){e.push({name:r.slice(t+1,o),suffix:"parameter"}),t=o+1;continue}}let n;if(r[t]==="`"){let o=r.indexOf("`",t+1);if(o===-1){n=r.slice(t+1),e.push({name:n,suffix:"term"});break}n=r.slice(t+1,o),t=o+1}else{let o=t;for(;t<r.length&&!nr(r[t]);)t++;n=r.slice(o,t)}if(t>=r.length){n&&e.push({name:n,suffix:"term"});break}let i=r[t];if(i==="("){let o=r.indexOf(")",t+1);o!==-1&&r[o+1]==="."?(e.push({name:n,suffix:"method"}),t=o+2):o!==-1?(e.push({name:n,suffix:"method"}),t=o+1):(e.push({name:n,suffix:"term"}),t++)}else{let o=kn[i];o&&e.push({name:n,suffix:o}),t+=1}}return e}function nr(r){return r==="/"||r==="#"||r==="."||r==="("||r==="["||r===":"||r==="!"}function _(r){let e=Se(r);if("kind"in e&&e.kind==="local")return e.id;let t=e;return t.descriptors.length===0?"":t.descriptors[t.descriptors.length-1].name}function O(r){let e=Se(r);if("kind"in e&&e.kind==="local")return null;let t=e;return t.descriptors[t.descriptors.length-1]?.suffix??null}function ir(r){let e=O(r);return e==="method"?!0:e!=="term"?!1:r.endsWith("().")?!0:r.startsWith("rust-analyzer ")&&r.includes("#")?!1:r.startsWith("scip-typescript ")?!/#[A-Za-z0-9_$]+\.$/.test(r):!0}function Tn(r,e={}){if(K(r.symbol)!==null)return e.includeClassMemberFallbacks===!0;let i=(r.documentation??"").replace(/^```\w*\s*/,"").replace(/\s*```$/,"").trim();return/^(?:var|let|const|function|class|interface|type|enum)\b/.test(i)}function or(r,e,t={}){let n=new Map;for(let o of e)r.length>0&&!Tn(o,{includeClassMemberFallbacks:t.includeClassMemberFallbacks})||n.set(o.id,o);for(let o of r)n.set(o.id,o);let i=[...n.values()];return t.sort?i.sort((o,a)=>o.start_line-a.start_line||o.end_line-a.end_line||o.symbol.localeCompare(a.symbol)):i}var Dn=J("file-definitions",{clearGroups:["definition-catalog"]}),ys=J("file-function-like-definitions",{clearGroups:["definition-catalog"]});function W(r,e,t={}){return t.includeClassMemberFallbacks?sr(r,e,void 0,{includeClassMemberFallbacks:!0}):Dn.get(r,e,()=>{let n=En(r,e);if(n)return n;let i=sr(r,e),o=Ae(r),a=ye(r).forFile(e,{text:!0}).text;return o&&a&&cr.write(r,e,Fe(r,e,a),{projectFingerprint:o,definitions:i.map(s=>({...s}))}),i})}var cr=It({kind:"file-definitions",invalidation:Rt("file-definitions"),serialize:Fn,deserialize:An});function En(r,e){let t=Ae(r);if(!t)return null;let n=ye(r).forFile(e,{text:!0}).text;if(!n)return null;let i=cr.read(r,e,Fe(r,e,n));return i?Ln(i,t,e):null}function Fn(r){return JSON.stringify(r)}function An(r){try{let e=JSON.parse(r);return!Ne(e)||typeof e.projectFingerprint!="string"||!Array.isArray(e.definitions)?null:{projectFingerprint:e.projectFingerprint,definitions:e.definitions}}catch{return null}}function Ln(r,e,t){if(r.projectFingerprint!==e)return null;let n=[];for(let i of r.definitions){let o=Nn(i,t);if(!o)return null;n.push(o)}return n}function Nn(r,e){return!Ne(r)||typeof r.symbolId!="number"||typeof r.symbol!="string"||typeof r.documentId!="number"||typeof r.startLine!="number"||typeof r.startChar!="number"&&r.startChar!==void 0||typeof r.endLine!="number"||typeof r.endChar!="number"&&r.endChar!==void 0||r.relativePath!==e||typeof r.leaf!="string"||typeof r.parentTypeName!="string"&&r.parentTypeName!==null||typeof r.isFunctionLike!="boolean"||typeof r.isTypeLike!="boolean"||typeof r.kind!="number"&&r.kind!==null||typeof r.documentation!="string"&&r.documentation!==null||typeof r.enclosingSymbol!="string"&&r.enclosingSymbol!==null?null:{symbolId:r.symbolId,symbol:r.symbol,documentId:r.documentId,startLine:r.startLine,startChar:r.startChar,endLine:r.endLine,endChar:r.endChar,relativePath:r.relativePath,leaf:r.leaf,parentTypeName:r.parentTypeName,isFunctionLike:r.isFunctionLike,isTypeLike:r.isTypeLike,kind:r.kind,documentation:r.documentation,enclosingSymbol:r.enclosingSymbol}}function sr(r,e,t,n={}){let i=or(jn(r,e),_n(r,e),{sort:!0,includeClassMemberFallbacks:n.includeClassMemberFallbacks}).map(On);return t&&(i=i.filter(t)),$n(r,e,i)}function jn(r,e){return r.all(`SELECT
|
|
2
2
|
gs.id,
|
|
3
3
|
gs.symbol,
|
|
4
4
|
der.document_id,
|
package/package.json
CHANGED
package/dist/chunk-42QYU6FD.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{a as Re}from"./chunk-KD6TPIXM.js";import{a as Fe}from"./chunk-7EI4MU5A.js";import{a as se,b as F,e as ae}from"./chunk-KWBA6FDD.js";import{a as fe,c as ue,d as he,e as v}from"./chunk-YHYTDWFT.js";import{a as De}from"./chunk-MFBXBLHA.js";import{a as ke}from"./chunk-WT7TOU2C.js";import{a as ve}from"./chunk-C2QSK7E7.js";import{a as Se}from"./chunk-X3OOU7CF.js";import{a as Ce}from"./chunk-J65FQLDL.js";import{a as ye}from"./chunk-547VY366.js";import{a as be}from"./chunk-QHOUNTDZ.js";import{a as ge}from"./chunk-YBAC3RON.js";import{b as de}from"./chunk-7FG5M53V.js";import{a as ce,b as le}from"./chunk-AERYQJ52.js";import{a as ne,b as oe,c as re,g as L,h as _}from"./chunk-PAZFJMXB.js";import{b as me}from"./chunk-AM2LGOEX.js";import{a as P,c as ee,d as te,e as ie}from"./chunk-RIGY5DDE.js";import{a as Q}from"./chunk-4XTPZ5CR.js";import{a as $e,e as we}from"./chunk-UJL3N6TC.js";import{a as j,c as H,d as z,e as pe}from"./chunk-J3U47L4Q.js";import{a as Z}from"./chunk-ZXWFN7CK.js";import{f as x,g as G}from"./chunk-FLIF3JWA.js";import{e as X}from"./chunk-UVMME4FI.js";import{e as R,f as Y,g as M}from"./chunk-TDGCALH6.js";import{a as V}from"./chunk-QNMOZ3CJ.js";import{e as W}from"./chunk-XDSB47KO.js";import{s as J}from"./chunk-M2TRDR25.js";import{createHash as st}from"crypto";import{existsSync as K}from"fs";function O(e){let[t,i]=T(e,":"),o=t||"unknown",n=(a={})=>{let s=a.actionTier??Ue(o);return{sourceAnalyzer:o,actionTier:s,rootCauseKey:a.rootCauseKey??(i||e),label:a.label??`${o} finding`,relatedFiles:a.relatedFiles??[],why:a.why??[],remediation:a.remediation??qe(s,o),file:a.file}};if(!i)return n({rootCauseKey:e,why:["Baseline identity did not include analyzer payload."]});if(["dead","isolated","extract","wrapper","passthrough","stale"].includes(o)){let[a,s]=T(i,":");return n({file:a,relatedFiles:a?[a]:[],rootCauseKey:s?`${a}:${s}`:i,label:`${o} finding`,why:s?[`Baseline subject: ${s}.`]:[]})}if(o==="cycle"){let a=i.split(">").filter(Boolean);return n({relatedFiles:a,rootCauseKey:i,label:"cycle finding",why:a.length>0?[`Cycle path: ${a.join(" > ")}.`]:[]})}if(o==="similar"){let a=i.split("|").filter(Boolean);return n({relatedFiles:[],rootCauseKey:i,label:"similarity finding",why:a.length>0?[`Similar symbols: ${a.join(" | ")}.`]:[]})}if(o==="architecture"){let[a,s]=T(i,":");if(a==="forbidden-edge"){let[c,l]=T(s,":"),r=N(c),f=N(l);return n({actionTier:"direct",rootCauseKey:i,label:"architecture boundary violation",why:[`Declared boundary rule rejects ${r} -> ${f}.`],remediation:`Move the dependency behind an allowed boundary, or deliberately update the ${r} dependency rule and baseline.`})}if(a==="cycle"){let c=s.split("|").filter(Boolean).map(N);return n({actionTier:"direct",rootCauseKey:i,label:"forbidden architecture cycle",why:[`requireAcyclic rejects the connected boundary group: ${c.join(", ")}.`],remediation:"Break the boundary cycle, or deliberately revise the acyclicity rule and baseline."})}if(a==="missing-policy-row"){let c=N(s);return n({actionTier:"direct",rootCauseKey:i,label:"incomplete architecture policy",why:[`requireCompletePolicy rejects the missing outgoing dependency row for ${c}.`],remediation:`Declare the allowed outgoing dependencies for ${c}, including an empty row when it must depend on nothing.`})}}if(o==="drift"){let[a,s]=T(i,":"),[c,l]=T(s,":");return n({actionTier:a==="unused-import"?"direct":"signal",file:c,relatedFiles:[...new Set([c,l].filter(Boolean))],rootCauseKey:i,label:`${a||"drift"} finding`,why:[...a?[`Drift kind: ${a}.`]:[],...l?[`Related dependency: ${l}.`]:[]]})}return n({why:["Baseline analyzer prefix is not recognized by this diff-gate version."]})}function Ue(e){switch(e){case"dead":case"isolated":case"cycle":case"passthrough":case"architecture":return"direct";case"similar":case"extract":case"wrapper":case"stale":return"signal";default:return"signal"}}function qe(e,t){return e==="direct"?`Fix the new ${t} baseline finding, or knowingly accept it via health --write-baseline.`:`Review the new ${t} baseline signal; fix it if it reflects real debt, or knowingly accept it via health --write-baseline.`}function T(e,t){let i=e.indexOf(t);return i<0?[e,""]:[e.slice(0,i),e.slice(i+t.length)]}function N(e){try{return decodeURIComponent(e)}catch{return e}}import{existsSync as Te,readFileSync as Ae,writeFileSync as We}from"fs";import{isAbsolute as Je,join as Ve}from"path";var Ye=25e3,Xe=2500,Ze=2500;function Qe(e){let t=ve(e);return t.symbols>=Ye||t.documents>=Xe?Ze:void 0}var et=".scipquery-baseline.json";function A(e,t){return t&&Je(t)?t:Ve(e.config.projectRoot,t??et)}function xe(e,t={}){let{scope:i}=t,o=Qe(e),n=[],a=me(e,{scope:i,...v.dead,scanLimit:o});for(let s of a.symbols)x(e,s.relativePath)||G(e,s.symbol,s.relativePath)||s.kind==="dead-code"&&n.push(`dead:${s.relativePath}:${s.shortName}`);for(let s of Ce(e,{scope:i,...v.isolated,scanLimit:o}))x(e,s.relativePath)||G(e,s.symbol,s.relativePath)||n.push(`isolated:${s.relativePath}:${s.shortName}`);for(let s of ge(e,{scope:i}))s.kind==="real"&&n.push(`cycle:${tt(s.path)}`);for(let s of we(e,{scope:i,...v.similar,scanLimit:o}))n.push(`similar:${[s.symbolA,s.symbolB].sort().join("|")}`);for(let s of ce(e,{scope:i,...v.duplicateBodies,scanLimit:o}))n.push(`duplicate-bodies:${s.hash}:${s.functions.map(c=>c.symbol).sort().join("|")}`);for(let s of be(e,{scope:i,...v.extract,scanLimit:o}))n.push(`extract:${s.relativePath}:${s.shortName}`);for(let s of De(e,{scope:i,...v.wrappers,scanLimit:o}))n.push(`wrapper:${s.file}:${s.shortName}`);for(let s of Se(e,{scope:i,...v.passthroughs,scanLimit:o}))n.push(`passthrough:${s.file}:${s.shortName}`);for(let s of ke(e,{scope:i,...v.stale,scanLimit:o}))n.push(`stale:${s.file}:${s.shortName}`);for(let s of ye(e,{scope:i,...v.drift,includePatternDeviations:!1,limit:Number.POSITIVE_INFINITY}).results)s.kind!=="architecture-violation"&&n.push(`drift:${s.kind}:${s.file}:${s.dep}`);return n.push(...z(H(e,{scope:i}))),[...new Set(n)].sort()}function tt(e){if(e.length===0)return"";let t=0;for(let i=1;i<e.length;i++)e[i]<e[t]&&(t=i);return[...e.slice(t),...e.slice(0,t)].join(">")}function ei(e,t={}){let i=xe(e,{scope:t.scope}),o=A(e,t.path);return We(o,JSON.stringify({version:1,findings:i},null,2)+`
|
|
2
|
-
`),{path:o,findingCount:i.length}}function Ge(e,t={}){let i=A(e,t.path);if(!Te(i))throw new Error(`No baseline found at ${i}. Create one with: scip-query health --write-baseline`);let o=JSON.parse(Ae(i,"utf-8")),n=new Set(o.findings??[]),a=xe(e,{scope:t.scope}),s=new Set(a);return{baselinePath:i,baselineCount:n.size,current:a,newFindings:a.filter(c=>!n.has(c)),fixedFindings:[...n].filter(c=>!s.has(c))}}function Ee(e,t={}){let i=A(e,t.path);if(!Te(i))throw new Error(`No baseline found at ${i}. Create one with: scip-query health --write-baseline`);let o=JSON.parse(Ae(i,"utf-8")),n=new Set((o.findings??[]).filter(c=>c.startsWith(j))),a=z(H(e,{scope:t.scope})),s=new Set(a);return{baselinePath:i,baselineCount:n.size,current:a,newFindings:a.filter(c=>!n.has(c)),fixedFindings:[...n].filter(c=>!s.has(c))}}import{existsSync as it,mkdirSync as ni,readdirSync as nt,readFileSync as ot,writeFileSync as oi}from"fs";import{createHash as si}from"crypto";import{join as U}from"path";var E=U(".scipquery","suppressions");function rt(e){return U(e,E)}function Ie(e){let t=rt(e);if(!it(t))return{suppressions:[],warnings:[]};let i=[],o=[];for(let n of nt(t).sort()){if(!n.endsWith(".json"))continue;let a=U(t,n),s;try{s=JSON.parse(ot(a,"utf-8"))}catch{o.push(`${E}/${n}: malformed JSON \u2014 ignored`);continue}if(typeof s!="object"||s===null||Array.isArray(s)){o.push(`${E}/${n}: not a suppression object \u2014 ignored`);continue}let c=s;if(typeof c.reason!="string"||c.reason.trim()===""){o.push(`${E}/${n}: missing reason \u2014 ignored`);continue}if(!c.id&&!c.check){o.push(`${E}/${n}: needs an id or a check \u2014 ignored`);continue}i.push(c)}return{suppressions:i,warnings:o}}var Ii=["echo","incomplete-migration","co-change-partner","twin-partner","coverage-contract","architecture","doc-reference","unused-params","new-dead","baseline"];function ji(e,t={}){let i=t.base??"HEAD",{minTogether:o=6,minConfidence:n=.6,maxEchoChecks:a=Number.POSITIVE_INFINITY,maxHelpers:s=Number.POSITIVE_INFINITY,minSimilarity:c=.8,includeBaseline:l=!1,scanLimit:r}=t,f=t.semantic!==!1,p=t.historyMode??"bounded",u=new Set(t.skip??[]),h=re(e,{base:i}),m=oe(e,{base:i,plan:h}),y=m.changedFiles,S=new Set(y),d=new Set(h.changedFileLines),w=new Set([...S,...d]),$=L(e.config.projectRoot,i,_(h,y)),C=It(e.config.projectRoot,i,h,$),g={base:i,changedFiles:y,changedSymbols:m.changedSymbols.length,checksRun:[],skipped:[],suppressed:[],findings:[],attributionNotes:m.attributionNotes,rootCauseGroups:[],note:m.summary.note};if(y.length===0)return g;let k=(I,_e)=>{if(u.has(I)){g.skipped.push({check:I,reason:"skipped via --skip"});return}let He=g.findings.length,ze=g.skipped.length,Oe=g.checksRun.length;J(`diff-gate.check.${I}`,_e,()=>({check:I,changedFiles:y.length,changedSymbols:m.changedSymbols.length,findingsAdded:g.findings.length-He,skippedAdded:g.skipped.length-ze,checksRunAdded:g.checksRun.length-Oe}))};return k("echo",()=>dt(e,m.changedSymbols,S,C,a,c,r,f,g)),k("incomplete-migration",()=>mt(e,i,h,s,r,f,$,g)),k("co-change-partner",()=>yt(e,w,o,n,p,g)),k("twin-partner",()=>bt(e,m.changedSymbols,S,r,g)),k("coverage-contract",()=>Ct(e,w,g)),k("architecture",()=>Bt(e,g)),k("doc-reference",()=>vt(e,S,d,h.changedRanges,h.renamedFiles,g)),k("unused-params",()=>Tt(e,y,g)),k("new-dead",()=>At(e,m.changedSymbols,C,g)),l&&k("baseline",()=>Nt(e,g)),ct(g,[...e.config.suppressions??[],...Ie(e.config.projectRoot).suppressions]),g.rootCauseGroups=at(g.findings),g}function Ni(e){return e.checksRun.length===0&&e.note===ne}function Bi(e){return e.filter(t=>!t.advisory)}function at(e){let t=new Map;for(let i of e){let o=i.groupKey??`${i.check}:${i.id}`,n=t.get(o);n||(n={groupKey:o,check:i.check,severity:i.severity,actionTier:i.actionTier,sourceAnalyzer:i.sourceAnalyzer,rootCauseKey:i.rootCauseKey,count:0,findingIds:[],files:new Set,relatedFiles:new Set,message:i.message,remediation:i.remediation},t.set(o,n)),n.count+=1,n.findingIds.push(i.id),n.severity=Pe(n.severity,i.severity),n.actionTier=Le(n.actionTier,i.actionTier),i.file&&n.files.add(i.file);for(let a of i.relatedFiles??[])n.relatedFiles.add(a)}return[...t.values()].map(i=>({...i,files:[...i.files].sort(),relatedFiles:[...i.relatedFiles].sort()})).sort((i,o)=>o.count-i.count||B(o.severity)-B(i.severity)||i.groupKey.localeCompare(o.groupKey))}function Pe(e,t){return B(t)>B(e)?t:e}function B(e){return e==="error"?2:e==="warning"?1:0}function Le(e,t){return e?t&&je(t)>je(e)?t:e:t}function je(e){return e==="direct"?2:e==="signal"?1:0}function ct(e,t){if(t.length===0||e.findings.length===0)return;let i=[];for(let o of e.findings){let n=t.find(a=>lt(a,o));n?e.suppressed.push({finding:o,suppression:n}):i.push(o)}e.findings=i}function lt(e,t){return!e.reason||e.reason.trim()===""||e.expiresAt&&Date.parse(e.expiresAt)<=Date.now()||e.id&&e.id!==t.id&&!t.legacySuppressionIds?.includes(e.id)||e.check&&e.check!==t.check||e.file&&e.file!==t.file?!1:!!(e.id||e.check)}function D(e,t){e.findings.push({...t,suppressionHint:`scip-query: ignore ${t.check} ${t.id} -- <reason>`})}function dt(e,t,i,o,n,a,s,c,l){l.checksRun.push("echo");for(let r of t.slice(0,n)){if(!M(r.symbol)||o(r))continue;let f=le(e,r.symbol,{maxLoc:15,scanLimit:s}).filter(d=>!i.has(d.file)).slice(0,5).map(d=>({otherFile:d.file,otherShort:d.shortName,otherSymbol:d.symbol,similarity:1,similarityBasis:"exact-body",sharedEvidence:[`exact normalized body (${d.loc} LOC)`]}));if(f.length>0){let d=b("echo",r.symbol,r.file),w=b("echo",r.symbol,r.file,...f.map(C=>`${C.otherSymbol}|${C.otherFile}`).sort()),$=f[0];D(l,{id:d,legacySuppressionIds:w===d?void 0:[w],groupKey:d,actionTier:"direct",check:"echo",severity:"warning",evidence:"heuristic",confidence:1,file:r.file,symbol:r.symbol,relatedFiles:[...new Set(f.map(C=>C.otherFile))].sort(),sourceAnalyzer:"duplicate-bodies",rootCauseKey:`${r.symbol}:${$.otherSymbol}`,message:Be(r,f),why:Ke(r,f),remediation:Me("direct",r.shortName,$.otherShort)});continue}let p=$e(e,r.symbol,{minSimilarity:a,limit:5,scanLimit:s,semantic:c,sourceCandidateMode:"target-pruned"}),u=[];for(let d of p){let w=d.fileA===r.file?d.fileB:d.fileA,$=d.fileA===r.file?d.shortNameB:d.shortNameA,C=d.fileA===r.file?d.symbolB:d.symbolA;i.has(w)||u.push({otherFile:w,otherShort:$,otherSymbol:C,similarity:d.similarity,similarityBasis:d.similarityBasis??"callees",sharedEvidence:d.sharedCallees})}if(u.length===0)continue;let h=u[0],m=b("echo",r.symbol,r.file,...u.map(d=>`${d.otherSymbol}|${d.otherFile}`).sort()),y=b("echo",r.symbol,r.file),S=ft(r,u);D(l,{id:y,legacySuppressionIds:m===y?void 0:[m],groupKey:y,actionTier:S,check:"echo",severity:"warning",evidence:"heuristic",confidence:h.similarity,file:r.file,symbol:r.symbol,relatedFiles:[...new Set(u.map(d=>d.otherFile))].sort(),message:Be(r,u),why:Ke(r,u),remediation:Me(S,r.shortName,h.otherShort)})}t.length>n&&l.skipped.push({check:"echo",reason:`echo check capped at ${n} of ${t.length} changed symbols`})}function ft(e,t){return t.some(o=>ut(e.symbol,o))?"direct":"signal"}function ut(e,t){if(t.similarityBasis==="exact-body")return!0;if(t.similarityBasis!=="source-tokens"||t.similarity<.98||t.sharedEvidence.length>8)return!1;let i=R(e),o=R(t.otherSymbol);return!i||!o?!1:i===o?!0:pt(t.sharedEvidence)?!1:ht(i,o)}function ht(e,t){let i=Ne(e),o=Ne(t);if(i.length===0||o.length===0)return!1;let n=new Set(o),a=i.filter(s=>n.has(s)).length;return a>=2&&a/Math.min(i.length,o.length)>=.5}function Ne(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[^A-Za-z0-9]+/).map(t=>t.toLowerCase()).filter(t=>t.length>=2)}var gt=new Set(["bytes","crypto","hex","num","random","secret","to","token"]);function pt(e){return e.length>=3&&e.every(t=>gt.has(t.toLowerCase()))}function Be(e,t){let i=t[0],o=Math.round(i.similarity*100);return t.length===1?`${e.shortName} (${e.file}) is ${o}% similar to established ${i.otherShort} (${i.otherFile})`:`${e.shortName} (${e.file}) resembles ${t.length} established symbol(s); strongest is ${o}% similar to ${i.otherShort} (${i.otherFile})`}function Ke(e,t){let i=[`${e.shortName} was changed in this diff.`];for(let o of t.slice(0,3))i.push(`${o.otherShort} is outside this diff and scored ${Math.round(o.similarity*100)}% similar by ${o.similarityBasis} evidence.`),i.push(`Shared evidence: ${o.sharedEvidence.slice(0,5).join(", ")||"(none listed)"}.`);return t.length>3&&i.push(`${t.length-3} additional similar match(es) grouped into this finding.`),i}function Me(e,t,i){return e==="direct"?`Extract or reuse the shared behavior with ${i}, or keep the duplicate with a suppression reason.`:`Review whether ${t} is intentionally parallel to the established implementation(s); extract shared behavior only if the product semantics match.`}function mt(e,t,i,o,n,a,s,c){let l=Fe(e,{base:t,maxHelpers:o,diffPlan:i,scanLimit:n,semantic:a,baseContentAt:s});if(!l.available){c.skipped.push({check:"incomplete-migration",reason:"no git history"});return}c.checksRun.push("incomplete-migration"),l.note&&c.skipped.push({check:"incomplete-migration",reason:l.note});for(let r of l.findings){let f=r.leftovers.map(d=>`${d.shortName} (${d.file}, ${Math.round(d.containment*100)}% helper / ${Math.round(d.siteCoverage*100)}% site, ${d.migrationScope})`).join(", "),p=r.leftovers.map(d=>`${d.shortName}: ${d.migrationScope} (${d.migrationScopeReasons[0]})`).join("; "),u=[...r.migratedFiles,...r.leftovers.map(d=>d.file)],h=r.leftovers.length===0?void 0:Math.max(...r.leftovers.map(d=>Math.min(d.containment,d.siteCoverage))),m=r.leftovers.some(d=>d.migrationScope==="possible-subtype"),y=b("incomplete-migration",r.helperSymbol,r.helperFile,u.join("|")),S=b("incomplete-migration",r.helperSymbol,r.helperFile);D(c,{id:S,legacySuppressionIds:y===S?void 0:[y],check:"incomplete-migration",severity:"warning",evidence:"heuristic",confidence:h,file:r.helperFile,symbol:r.helperSymbol,relatedFiles:u,message:`new helper ${r.helperShortName} (${r.helperFile}) is wired into ${r.migratedFiles.length} file(s), but ${r.leftovers.length} similar un-migrated site(s) remain: ${f}`,why:[`${r.helperShortName} is new in this diff and already referenced by ${r.migratedFiles.join(", ")}.`,`Helper shape: ${r.helperShape}; ${r.specificHelperCalleeCount}/${r.helperCalleeCount} helper callees are specific enough to score.`,`Unchanged site(s) still contain the helper's callee pattern: ${f}.`,`Migration scope hints: ${p}.`],remediation:m?`Migrate same-scope sites to ${r.helperShortName}; review possible subtype/variant sites before applying the helper.`:`Migrate the remaining sites to ${r.helperShortName}, or confirm they are intentionally different.`})}}function yt(e,t,i,o,n,a){let s=Q(e,{historyMode:n}).directionalCoChangePairsForFiles(t,{minTogether:i,minConfidence:0,maxFilesPerCommit:20});if(!s){a.skipped.push({check:"co-change-partner",reason:"no git history"});return}a.checksRun.push("co-change-partner");let c=new Set,l;for(let r of s){let f=t.has(r.fileA),p=t.has(r.fileB);if(f===p)continue;let u=f?r.fileA:r.fileB,h=f?r.fileB:r.fileA,m=f?r.changesA:r.changesB,y=m>0?r.together/m:0;if(y<o||P(h)||P(u)||!K(`${e.config.projectRoot}/${h}`))continue;let S=`${u}|${h}`;if(c.has(S))continue;c.add(S);let d=b("co-change-partner",u,h,String(r.together)),w=b("co-change-partner",u,h),$=ee(u,h),C=te({fileA:u,fileB:h,together:r.together,confidence:y,commitScope:r.commitScope,recency:r.recency,subjectContext:r.subjectContext},$,(l??=ie(e))(u,h)),g=[u,h].sort().join("|");a.findings.push({id:w,legacySuppressionIds:d===w?void 0:[d],check:"co-change-partner",severity:"warning",evidence:"change-graph",actionTier:"signal",groupKey:`co-change-partner:${g}`,confidence:y,file:u,relatedFiles:[h],sourceAnalyzer:"co-change",rootCauseKey:g,partnerClass:$.partnerClass,partnerClassReasons:$.reasons,commitScope:r.commitScope,recency:r.recency,focusedTogether:r.focusedTogether,broadTogether:r.broadTogether,broadCommitRatio:r.broadCommitRatio,lastTogetherAt:r.lastTogetherAt,recentTogether:r.recentTogether,subjectContext:r.subjectContext,...C?{declaredCouplingSuggestion:C}:{},message:`${u} changed, but ${h} did not \u2014 they change together ${r.together}x (${Math.round(y*100)}% of the time)`,why:[`${u} is in this diff and ${h} is not.`,`Git history shows ${r.together} co-change(s), which is ${Math.round(y*100)}% of changes to the edited side.`,`History context: ${St(r)}.`,`Subject context: ${$t(r.subjectContext)}.`,...wt(r),`Partner class: ${$.partnerClass} (${$.reasons.join("; ")}).`],remediation:C?`Update ${h} alongside this change, declare the coupling "${C.name}", or confirm the coupling no longer holds.`:`Update ${h} alongside this change, or confirm the coupling no longer holds.`})}}function bt(e,t,i,o,n){n.checksRun.push("twin-partner");let a=de(e,{scanLimit:o}).filter(l=>l.relationship==="divergent"||l.relationship==="identical");if(a.length===0)return;let s=new Map;for(let l of a)for(let r of l.members)s.set(r.symbol,l);let c=new Set;for(let l of t){if(!M(l.symbol))continue;let r=s.get(l.symbol);if(!r)continue;let f=r.members.filter(m=>m.symbol!==l.symbol&&!i.has(m.file));if(f.length===0)continue;let p=[l.symbol,...f.map(m=>m.symbol)].sort().join("|");if(c.has(p))continue;c.add(p);let u=f[0],h=b("twin-partner",l.symbol,l.file,u.symbol);D(n,{id:h,groupKey:`twin-partner:${p}`,check:"twin-partner",severity:"warning",evidence:"heuristic",actionTier:"signal",advisory:!0,confidence:r.relationship==="identical"?1:Math.max(0,1-r.maxDivergence),file:l.file,symbol:l.symbol,relatedFiles:f.map(m=>m.file).sort(),sourceAnalyzer:"twin-drift",rootCauseKey:p,message:`${l.shortName} (${l.file}) changed but its same-name twin ${u.shortName} (${u.file}) did not \u2014 verify the change shouldn't apply to both, or consolidate them.`,why:[`${l.symbol} is in this diff.`,`${u.symbol} shares its (near-)name and is classified '${r.relationship}' with it, but ${u.file} is not in this diff.`,r.relationship==="divergent"?`The two bodies already diverge (~${Math.round(r.maxDivergence*100)}% token difference) \u2014 this diff may widen or narrow that drift.`:"The two bodies were byte-identical before this diff.","Advisory: twin-partner never fails the gate by itself \u2014 see the twin-partner entry in the diff-gate checks table."],remediation:`Update ${u.file} alongside this change, consolidate ${l.shortName}/${u.shortName} into one helper, or confirm the twin should diverge on purpose.`})}}function Ct(e,t,i){i.checksRun.push("coverage-contract");let o=e.config.coverageContracts??[];for(let n of o){if(!ue(n,t))continue;let a=fe(e,n);if(a.status==="ok")continue;let s=b("coverage-contract",n.name,n.file);D(i,{id:s,groupKey:`coverage-contract:${n.name}`,check:"coverage-contract",severity:a.status==="unavailable"?"warning":"error",evidence:"graph-fact",actionTier:"direct",file:n.file,sourceAnalyzer:"coverage-contracts",rootCauseKey:n.name,message:he(a),why:[`Contract "${n.name}" declares that ${n.file} (${n.keys.type}) must track ${n.mustEqual.type}.`,a.status==="unavailable"?`The declared side could not be evaluated: ${a.unavailableReason}.`:`Missing: ${a.missing.join(", ")||"none"}. Extra: ${a.extra.join(", ")||"none"}.`,"Either side of this contract changed in this diff."],remediation:a.status==="unavailable"?"Investigate why the declared key set could not be parsed (see the reason above) \u2014 do not treat this as a pass.":`Update ${n.file} so its ${n.keys.type==="object-literal-keys"||n.keys.type==="string-array"?n.keys.identifier:n.keys.marker} matches ${n.mustEqual.type}, or fix the ground-truth source if the declared set is right.`})}}function St(e){return`${e.commitScope}/${e.recency}; ${e.focusedTogether} focused, ${e.broadTogether} broad-sweep (${Math.round(e.broadCommitRatio*100)}% broad), ${e.recentTogether} recent, last ${kt(e.lastTogetherAt)}`}function $t(e){let t=e.subjectLabels.length>0?e.subjectLabels.slice(0,5).join(", "):"none inferred",i=e.issueRefs.length>0?e.issueRefs.slice(0,5).join(", "):"none",o=e.sampleSubjects.length>0?e.sampleSubjects.slice(0,3).map(n=>`"${n}"`).join("; "):"none";return`labels ${t}; refs ${i}; samples ${o}; external issue/PR labels ${e.externalIssueLabelStatus}`}function wt(e){let t=[];return e.commitScope==="broad-sweep"&&t.push("Broad-sweep history is weaker than focused co-edits; confirm this is a real coordination contract."),e.recency==="stale"&&t.push("The pair has no co-change in the recent history window; confirm the coupling still holds."),t}function kt(e){return e<=0?"unknown":new Date(e*1e3).toISOString().slice(0,10)}var q=3;function vt(e,t,i,o,n,a){a.checksRun.push("doc-reference");let s=F.referenceTargets(e,t,o);if(s.size===0)return;let c=new Set(n.map(r=>r.from)),l=[];for(let r of ae(e,s))i.has(r.doc)||se(e,r.doc)||l.push(Dt(e,r,c));for(let r of Ft(l))D(a,r)}function Dt(e,t,i){let o=t.citedClaims.length>0?t.citedClaims:F.citationContexts(e,t.doc,t.cited),n=F.classifyCitation(o),a=F.hasLineAnchoredCitation(t.citations),s=t.cited.some(p=>i.has(p)||!K(`${e.config.projectRoot}/${p}`)),c=!(a||s),l=t.cited[0]??"",r=b("doc-reference",t.doc,t.cited.join("|")),f=b("doc-reference",t.doc,l);return{id:f,legacySuppressionIds:r===f?void 0:[r],check:"doc-reference",severity:"warning",evidence:"change-graph",actionTier:n.actionTier,groupKey:`doc-reference:${l}`,rootCauseKey:l,confidence:1,file:t.doc,relatedFiles:t.cited,citationKind:n.citationKind,citationKindReasons:n.reasons,citedClaims:o,...c?{advisory:!0}:{},message:`${t.doc} cites ${t.cited.join(", ")} as ${F.citationKindLabel(n.citationKind)} \u2014 changed in this diff, doc untouched`,why:[`${t.cited.join(", ")} changed in this diff.`,`${t.doc} cites the changed file(s) but was not updated in the same diff.`,...n.reasons.map(p=>`Citation kind evidence: ${p}`),c?"Advisory: bare file-mention citation (no line anchor, cited file still present under the same path) \u2014 21.2 calibration found this citation shape low-precision; verify at your leisure.":a?"Blocking: citation includes a line anchor that may now point at the wrong lines.":"Blocking: the cited file was deleted or renamed in this diff \u2014 the citation almost certainly needs an update."],remediation:F.citationRemediation(n.citationKind,t.doc)}}function Ft(e){let t=new Map;for(let o of e){let n=o.rootCauseKey??"",a=t.get(n);a?a.push(o):t.set(n,[o])}let i=[];for(let[o,n]of t)n.length<=q?i.push(...n):i.push(Rt(o,n));return i}function Rt(e,t){let i=[...t].sort((f,p)=>(f.file??"").localeCompare(p.file??"")),o=i.slice(0,q).map(f=>({doc:f.file??"",citedClaims:f.citedClaims??[]})),n=i.length-o.length,a=i.every(f=>f.advisory===!0),s=i.reduce((f,p)=>Pe(f,p.severity),"info"),c=i.reduce((f,p)=>Le(f,p.actionTier),void 0),l=i.map(f=>f.file??"").filter(f=>f.length>0),r=[...new Set(i.flatMap(f=>[f.id,...f.legacySuppressionIds??[]]))];return{id:b("doc-reference","hub-cluster",e),memberFindingIds:r,check:"doc-reference",severity:s,evidence:"change-graph",actionTier:c,groupKey:`doc-reference:${e}`,rootCauseKey:e,confidence:1,file:o[0]?.doc,relatedFiles:[e],citationCount:i.length,citationExemplars:o,suppressedCount:n,...a?{advisory:!0}:{},message:`${e} is cited by ${i.length} doc(s) changed in this diff, doc(s) untouched \u2014 showing ${o.length} example(s), ${n} more damped`,why:[`${e} changed in this diff.`,`${i.length} doc(s) cite it but were not updated in the same diff: ${l.join(", ")}.`,...o.map(f=>`Example \u2014 ${f.doc}: ${f.citedClaims[0]??"(no captured citation text)"}`),`${n} additional doc(s) also cite this file, past the per-hub-file cascade cap (${q}) \u2014 not silently dropped: counted in citationCount/suppressedCount and individually addressable via memberFindingIds.`,a?"Advisory: every citation in this cluster is a bare file-mention (no line anchor, cited file still present).":"Blocking: at least one citation in this cluster is line-anchored or cites a deleted/renamed file."],remediation:`Review the ${o.length} example doc(s) above; ${i.length} total doc(s) cite ${e} the same way \u2014 see citationExemplars and memberFindingIds in --json for the complete list.`}}function Tt(e,t,i){i.checksRun.push("unused-params");for(let o of Re(e,{files:t,limit:50})){let n=b("unused-params",o.symbol,o.file,o.unusedTrailing.join("|")),a=b("unused-params",o.symbol,o.file);D(i,{id:a,legacySuppressionIds:n===a?void 0:[n],check:"unused-params",severity:"warning",evidence:"heuristic",confidence:.85,file:o.file,startLine:o.startLine,endLine:o.endLine,symbol:o.symbol,message:`${o.shortName} (${o.file}) has trailing unused parameter(s): ${o.unusedTrailing.join(", ")}`,why:[`${o.shortName} is in a changed file.`,`The trailing parameter(s) ${o.unusedTrailing.join(", ")} are not referenced in the function body.`],remediation:"Drop the unused trailing parameters and their call-site arguments."})}}function At(e,t,i,o){o.checksRun.push("new-dead");let n=new Z(e),a=W(e.config.projectRoot),s=a.length>1;for(let c of t){if(i(c)||c.fanIn>0||n.fileKind(c.file)==="test"||x(e,c.file)||G(e,c.symbol,c.file)||Et(c.symbol))continue;let l=b("new-dead",c.symbol,c.file),r=s&&xt(a,c.file)&&Gt(e,c.symbol);D(o,{id:l,check:"new-dead",severity:"warning",evidence:r?"heuristic":"graph-fact",confidence:r?.4:.9,file:c.file,symbol:c.symbol,message:r?`${c.shortName} (${c.file}) unconfirmed (cross-package ambiguous-name resolution gap): zero indexed consumers found, but this name is ambiguous project-wide and lives in a workspace package \u2014 verify manually before treating as dead`:`${c.shortName} (${c.file}) was changed but has zero indexed consumers`,why:r?[`${c.shortName} is a changed production symbol in a workspace package.`,"The index, semantic, and source-fallback layers all report zero consumers for this symbol.","Its leaf name is ambiguous project-wide (a same-named definition exists elsewhere), and cross-package consumers reached only through a re-exporting barrel are a known unresolvable shape for this tool \u2014 see docs/plans/2026-07-02-followups.md item 2."]:[`${c.shortName} is a changed production symbol.`,"The index reports zero consumers for this symbol.","The symbol is not in a detected entry surface or configured live root."],remediation:r?"Verify with a direct code search before deleting; this tool cannot confidently resolve this symbol.":"Wire it up, or remove it before it becomes permanent dead code."})}}function xt(e,t){return e.some(i=>t===i.relativeDir||t.startsWith(`${i.relativeDir}/`))}function Gt(e,t){let i=R(t);return i?(X(e).get(i)?.length??0)>1:!1}function Et(e){if(Y(e)!=="type")return!1;let t=R(e);return t.startsWith("_Assert")||t.startsWith("Assert")}function It(e,t,i,o){let n=new Map(i.renamedFiles.map(s=>[s.to,s.from])),a=o??L(e,t,_(i));return s=>{let c=n.get(s.file)??s.file,l=R(s.symbol);if(!l)return!1;let r=a(c);return r!==null&&jt(r,l)}}function jt(e,t){return new RegExp(`\\b${V(t)}\\b`).test(e)}function Nt(e,t){if(!K(A(e))){t.skipped.push({check:"baseline",reason:"no .scipquery-baseline.json \u2014 run health --write-baseline to enable"});return}t.checksRun.push("baseline");let i=Ge(e);for(let o of i.newFindings.filter(n=>!n.startsWith(j))){let n=O(o),a=b("baseline",o);D(t,{id:a,groupKey:`baseline:${n.sourceAnalyzer}:${n.rootCauseKey}`,check:"baseline",severity:"error",evidence:"baseline",actionTier:n.actionTier,confidence:1,file:n.file,relatedFiles:n.relatedFiles.length>0?n.relatedFiles:void 0,sourceAnalyzer:n.sourceAnalyzer,rootCauseKey:n.rootCauseKey,message:`new ${n.label} vs committed baseline: ${o}`,why:["A committed health baseline exists.","The current health result contains a finding not present in that baseline.",`Underlying analyzer: ${n.sourceAnalyzer}.`,`Inherited action tier: ${n.actionTier}.`,`Root cause key: ${n.rootCauseKey}.`,...n.why],remediation:n.remediation})}}function Bt(e,t){if(!pe(e.config.architecture)){t.skipped.push({check:"architecture",reason:"no closed architecture dependency rows, requireCompletePolicy rule, or requireAcyclic rule configured"});return}if(!K(A(e))){t.skipped.push({check:"architecture",reason:"no .scipquery-baseline.json \u2014 run health --write-baseline to enable"});return}t.checksRun.push("architecture");let i=Ee(e);for(let o of i.newFindings){let n=O(o),a=b("architecture",o);D(t,{id:a,groupKey:`architecture:${n.rootCauseKey}`,check:"architecture",severity:"error",evidence:"baseline",actionTier:"direct",confidence:1,sourceAnalyzer:"architecture",rootCauseKey:n.rootCauseKey,message:`new ${n.label} vs committed baseline: ${o}`,why:["The project declares an enforceable architecture rule.","The current boundary graph contains a violation not present in the committed baseline.",...n.why],remediation:n.remediation})}}function b(e,...t){return`SQ${st("sha256").update([e,...t].join("\0")).digest("hex").slice(0,12).toUpperCase()}`}export{xe as a,ei as b,Ge as c,Ii as d,ji as e,Ni as f,Bi as g,It as h};
|
|
3
|
-
//# sourceMappingURL=chunk-42QYU6FD.js.map
|
package/dist/chunk-AERYQJ52.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{c as p}from"./chunk-4XTPZ5CR.js";import{b as B}from"./chunk-B75HZHUP.js";import{a as m}from"./chunk-BGBBVSH4.js";import{d as f,t as g}from"./chunk-TDGCALH6.js";import{b as y}from"./chunk-QNMOZ3CJ.js";import{z as d}from"./chunk-M2TRDR25.js";import{createHash as C}from"crypto";var b=3;function w(n,t={}){let{scope:e,maxLoc:o=15,minLoc:i=b,limit:r,scanLimit:a}=t,l=p(n),u=L(n,{scope:e,maxLoc:o,scanLimit:a}).map(s=>h(n,s,l,i)).filter(s=>s!==null),c=I(u);return r?c.slice(0,r):c}function H(n,t,e={}){let{scope:o,maxLoc:i=15,minLoc:r=b,scanLimit:a}=e,l=p(n),u=L(n,{scope:o,maxLoc:i,scanLimit:a}).map(s=>h(n,s,l,r)).filter(s=>s!==null),c=u.find(s=>s.symbol===t);return c?u.filter(s=>s.symbol!==c.symbol&&s.normalizedBody===c.normalizedBody&&s.file!==c.file).sort(z).map(({normalizedBody:s,...S})=>S):[]}function A(n){let t=E(n);return y(t).replace(/\s+/g,"")}function I(n){let t=new Map;for(let o of n){if(o.normalizedBody.length<8)continue;let i=W(o.normalizedBody),r=t.get(i)??[];r.push(o),t.set(i,r)}let e=[];for(let[o,i]of t){let r=new Set(i.map(l=>l.file));if(i.length<2||r.size<2)continue;let a=[...i].sort(z).map(({normalizedBody:l,...u})=>u);e.push({hash:o,canonical:a[0],functions:a})}return e.sort((o,i)=>{let r=i.functions.length-o.functions.length;if(r!==0)return r;let a=D(i)-D(o);return a!==0?a:o.canonical.file.localeCompare(i.canonical.file)}),e}function L(n,t){let e=g(n,{scope:t.scope}).filter(o=>o.isFunctionLike&&!n.isIgnored(o.relativePath)).filter(o=>m(o)<=t.maxLoc);return e.sort((o,i)=>m(i)-m(o)||o.relativePath.localeCompare(i.relativePath)),B(e,t.scanLimit)}function h(n,t,e,o){let i=x(n,t);if(!i||P(i)<o)return null;let r=v(n,t);return r?{symbol:t.symbol,shortName:f(t.symbol),file:t.relativePath,startLine:t.startLine,endLine:t.endLine,loc:m(t),ageCommits:e?.get(t.relativePath)?.commitsAgo??null,normalizedBody:r}:null}function v(n,t){let e=x(n,t);return e&&A(e)||null}function x(n,t){let e=d(n,t.relativePath);return e.length===0?null:e.slice(t.startLine,t.endLine+1).join(`
|
|
2
|
-
`)}function E(n){let t=n.indexOf("{"),e=n.lastIndexOf("}");if(t>=0&&e>t)return n.slice(t+1,e);let o=n.indexOf("=>");return o>=0?n.slice(o+2).replace(/;+\s*$/,""):n}function P(n){return E(n).split(/\r?\n/).map(e=>e.trim()).filter(e=>e.length>0).length}function W(n){return C("sha256").update(n).digest("hex").slice(0,16)}function z(n,t){let e=n.ageCommits??-1;return(t.ageCommits??-1)-e||n.file.localeCompare(t.file)||n.startLine-t.startLine}function D(n){return n.functions.reduce((t,e)=>t+e.loc,0)}export{w as a,H as b,A as c,I as d,v as e,x as f,E as g};
|
|
3
|
-
//# sourceMappingURL=chunk-AERYQJ52.js.map
|
package/dist/chunk-OYYZLJVT.js
DELETED