scip-query 0.19.1 → 0.19.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/README.md +17 -1
- package/dist/{chunk-ESNRT7QN.js → chunk-26JI77AY.js} +108 -108
- package/dist/{chunk-XZXUMGAA.js → chunk-2E7QY4B5.js} +2 -2
- package/dist/{chunk-JBZXJXIS.js → chunk-2ROSOG2I.js} +2 -2
- package/dist/{chunk-NTOBQK5H.js → chunk-33RLKB6L.js} +2 -2
- package/dist/{chunk-XCPE3G75.js → chunk-4BUMNEYQ.js} +2 -2
- package/dist/{chunk-HCS5LB6U.js → chunk-5FUAFNMP.js} +2 -2
- package/dist/chunk-5GCAM4JE.js +122 -0
- package/dist/{chunk-SSXEYWN3.js → chunk-5OR4QRPR.js} +2 -2
- package/dist/{chunk-CKFMZE77.js → chunk-5TZ2MQBG.js} +2 -2
- package/dist/{chunk-Q2WEWIKX.js → chunk-6EWBPAA3.js} +2 -2
- package/dist/{chunk-4BU54UJG.js → chunk-6FIA5BEB.js} +2 -2
- package/dist/{chunk-DFQNE73Y.js → chunk-77IOFJVY.js} +2 -2
- package/dist/{chunk-WCZAABYF.js → chunk-AD7WUFFT.js} +2 -2
- package/dist/{chunk-V7J4A3AH.js → chunk-AFVU2GB2.js} +2 -2
- package/dist/{chunk-ZNK6K3LB.js → chunk-B26UX7ZD.js} +2 -2
- package/dist/{chunk-SYGAA54M.js → chunk-C3VQZFP2.js} +2 -2
- package/dist/{chunk-B2WQKQKP.js → chunk-EGKWRX5I.js} +2 -2
- package/dist/{chunk-3WLRW5TC.js → chunk-EHU4TZJJ.js} +2 -2
- package/dist/{chunk-KMUFGAIK.js → chunk-EII5ZHL2.js} +2 -2
- package/dist/{chunk-BBBKPOIT.js → chunk-EYF5HOUZ.js} +2 -2
- package/dist/{chunk-PYMZU5EG.js → chunk-FYE4PWWP.js} +2 -2
- package/dist/{chunk-V5WBVF6K.js → chunk-HAC5EI2T.js} +2 -2
- package/dist/{chunk-5W2VAEVR.js → chunk-HCSTQGQE.js} +2 -2
- package/dist/{chunk-JJZRS2OP.js → chunk-HHOJH3RJ.js} +2 -2
- package/dist/{chunk-6PKO2TNZ.js → chunk-HNTLCR4F.js} +2 -2
- package/dist/{chunk-BMTBVMA3.js → chunk-IICQP2DY.js} +2 -2
- package/dist/{chunk-OOUJBAKJ.js → chunk-IXAALOUP.js} +2 -2
- package/dist/{chunk-LF5CIKWZ.js → chunk-JFO2UVQP.js} +2 -2
- package/dist/{chunk-5TEUKVSM.js → chunk-JRCJEHRG.js} +2 -2
- package/dist/{chunk-FHLYJVXF.js → chunk-LSJDKJIB.js} +2 -2
- package/dist/{chunk-RPEA7P5Z.js → chunk-MRYPDVOS.js} +2 -2
- package/dist/{chunk-E3KWOHH7.js → chunk-NLNZK7RL.js} +5 -5
- package/dist/{chunk-7TJJY2C3.js → chunk-OAM22BCR.js} +2 -2
- package/dist/{chunk-LQUDSHLB.js → chunk-PCIFZHWS.js} +2 -2
- package/dist/{chunk-WFRET75Z.js → chunk-PJENL245.js} +2 -2
- package/dist/{chunk-EMIIOOTM.js → chunk-PLDIXTKR.js} +2 -2
- package/dist/{chunk-YCSTKIYU.js → chunk-PTYQQHZM.js} +2 -2
- package/dist/{chunk-BCMOTIB6.js → chunk-QKW7ISEW.js} +2 -2
- package/dist/{chunk-63P42UR6.js → chunk-QNO3QIMN.js} +2 -2
- package/dist/{chunk-6O5JOS7T.js → chunk-SOS256TP.js} +2 -2
- package/dist/{chunk-QHKXGMOI.js → chunk-TDUU63FC.js} +2 -2
- package/dist/chunk-TOIS2VAI.js +4 -0
- package/dist/chunk-V27BEQJN.js +7 -0
- package/dist/{chunk-KC2IFAAU.js → chunk-WFWQWQK6.js} +2 -2
- package/dist/{chunk-US44MEVU.js → chunk-XAMVIPE2.js} +2 -2
- package/dist/{chunk-DCDOGW32.js → chunk-XWE7PZQH.js} +2 -2
- package/dist/{chunk-GIHVWNKQ.js → chunk-XWJ3JYRG.js} +2 -2
- package/dist/{chunk-AGTATREV.js → chunk-XYNWAZ6J.js} +2 -2
- package/dist/{chunk-DZXFZAZO.js → chunk-YGBHQOB2.js} +2 -2
- package/dist/{chunk-7SGOWD2Y.js → chunk-Z7M7X3ZG.js} +2 -2
- package/dist/cli.js +1 -1
- package/dist/{command-descriptors-3EJHQLQZ.js → command-descriptors-QJEYYND2.js} +168 -166
- package/dist/direct-navigation-TT23TDBS.js +3 -0
- package/dist/index.js +1 -1
- package/dist/queries/affected.js +1 -1
- package/dist/queries/bottlenecks.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/complexity-hotspots.js +1 -1
- package/dist/queries/complexity.js +1 -1
- package/dist/queries/convergence.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/diff-gate.js +1 -1
- package/dist/queries/diff-impact.js +1 -1
- package/dist/queries/drift.js +1 -1
- package/dist/queries/extract-candidates.js +1 -1
- package/dist/queries/health.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/passthrough-candidates.js +1 -1
- package/dist/queries/plan-context.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-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/trace.js +1 -1
- package/dist/queries/twin-ab.js +1 -1
- package/dist/queries/unused-imports.js +1 -1
- package/dist/queries/unused-params.js +1 -1
- package/dist/queries/wrapper-candidates.js +1 -1
- package/dist/reindex-worker.js +24 -24
- package/dist/reindex.js +38 -38
- package/dist/runtime.d.ts +6 -1
- package/dist/runtime.js +2 -2
- package/dist/watch-server.js +5 -5
- package/package.json +1 -1
- package/dist/chunk-2NA6TYP4.js +0 -120
- package/dist/chunk-DRH3AD7W.js +0 -4
- package/dist/chunk-IOOCKVUA.js +0 -6
- package/dist/direct-navigation-C2A44KFT.js +0 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{a as j}from"./chunk-J5XJWCB3.js";import{a as N,b as g,c as R}from"./chunk-
|
|
1
|
+
import{a as j}from"./chunk-J5XJWCB3.js";import{a as N,b as g,c as R}from"./chunk-XYNWAZ6J.js";import{a as _}from"./chunk-FBUNGRKI.js";import{a as P}from"./chunk-OAM22BCR.js";import{a as E}from"./chunk-B75HZHUP.js";import{a as k}from"./chunk-BGBBVSH4.js";import{h as C}from"./chunk-PLDIXTKR.js";import{a as w}from"./chunk-YGBHQOB2.js";import{d,e as y,k as v,z as L}from"./chunk-AYRHVJXW.js";import{i as S}from"./chunk-GAE7WCBK.js";import{s as x}from"./chunk-FC5K7T35.js";import{basename as m,extname as b}from"path";function ae(t,n){let{scope:e,maxLoc:i=15,limit:a=30,scanLimit:o}=n??{},r=new P(t),s=z(r.fileDependencyGraph(e));return _({candidates:()=>B(t,r,e,i),orderCandidates:E,scanLimit:o,profile:{name:"wrapper-candidates"},prepare:l=>({callerFileMap:A(t,r,l,{semantic:n?.semantic!==!1}),reverseFanIn:s}),evaluate:(l,u)=>O(t,r,l,u),orderResults:(l,u)=>u.callerFanIn-l.callerFanIn||u.loc-l.loc,limit:a})}function A(t,n,e,i){let a=N(t,n),o=g(a.forDefinitions(e,{semantic:!1,sourceFallback:!1})),r=[];i.semantic&&x("wrapper.semantic-candidates",()=>{r=e.filter(c=>F(t,n,c,o).length<=1)},()=>({symbols:e.length,semanticCandidates:r.length}));let s=r.length===0?new Map:g(a.forDefinitions(r,{semantic:!0,sourceFallback:!1})),l=s.size===0?o:C(o,s),u=new Map(e.map(c=>[c.symbolId,c])),f=new Map;for(let c of e){let I=F(t,n,c,l);if(I.length>1||(f.set(c.symbolId,c),I.length!==1))continue;let D=I[0],M=T(t,c.symbolId,D);if(!M)continue;let p=W(n,t,D,c.symbol,M);p?.isFunctionLike&&u.has(p.symbolId)&&f.set(p.symbolId,u.get(p.symbolId))}let h=[...f.values()];return h.length===0?l:C(l,g(a.forDefinitions(h,{semantic:!1,sourceFallback:!0})))}function O(t,n,e,i){let a=F(t,n,e,i.callerFileMap);if(a.length!==1)return null;let o=a[0],r=T(t,e.symbolId,o);if(!r)return null;let s=W(n,t,o,e.symbol,r);if(s&&v(s.symbol))return null;let{fanIn:l,source:u}=J(i.callerFileMap,i.reverseFanIn,o,s);if(u==="function"?l<=3:l<=5)return null;let f=H(t,e,o,s);return{symbol:e.symbol,shortName:d(e.symbol),file:e.relativePath,startLine:e.startLine,endLine:e.endLine,loc:k(e),singleCaller:s?.symbol??"",singleCallerShort:s?.isFunctionLike?d(s.symbol):m(o),callerFanIn:l,actionTier:f.length>0?"signal":"direct",boundaryEvidence:f}}function B(t,n,e,i){return n.productionCallableDefinitions({scope:e,minLoc:2,maxLoc:i,requireFunctionLikeSymbol:!0,excludeRootedSymbols:!0,excludeRustTraitImplMembers:!0}).filter(a=>!S(t,a))}function F(t,n,e,i){let a=m(e.relativePath,b(e.relativePath)),o=[...i.get(e.symbolId)??[]].filter(r=>r!==e.relativePath).filter(r=>m(r,b(r))!==a).filter(r=>{let s=n.fileKind(r);return s!=="barrel"&&s!=="entry"&&s!=="test"});return R(t,e,o).realConsumers}function T(t,n,e){return t.get(`SELECT c.start_line, c.end_line
|
|
2
2
|
FROM mentions m
|
|
3
3
|
JOIN chunks c ON m.chunk_id = c.id
|
|
4
4
|
JOIN documents d ON c.document_id = d.id
|
|
5
5
|
WHERE m.symbol_id = ? AND m.role != 1 AND d.relative_path = ?
|
|
6
6
|
LIMIT 1`,n,e)}function W(t,n,e,i,a){let o=t.definitionsForFile(e),r=q(n,e,i,a.start_line,a.end_line);return L(o,r)}function J(t,n,e,i){if(i?.isFunctionLike){let a=[...t.get(i.symbolId)??[]].filter(o=>o!==i.relativePath);if(a.length>0)return{fanIn:a.length,source:"function"}}return{fanIn:G(n,e),source:"file"}}function q(t,n,e,i,a){let o=y(e);if(!o)return i;let r=w(t,n).get(o);if(!r||r.length===0)return i;for(let s of r)if(s>=i&&s<=a)return s;return i}function z(t){let n=new Map;for(let[e,i]of t){n.has(e)||n.set(e,n.get(e)??0);for(let a of i)n.set(a,(n.get(a)??0)+1)}return n}function G(t,n){let e=t.get(n)??0;if(e>0)return e;let i=m(n,b(n)),a=0;for(let[o,r]of t)o!==n&&m(o,b(o))===i&&r>a&&(a=r);return a}function H(t,n,e,i){return j(t,n.relativePath,n.startLine,"wrapper","explicit ignore-wrapper comment",[{label:"wrapper name",value:d(n.symbol)},{label:"caller name",value:i?.symbol?d(i.symbol):m(e)},{label:"wrapper path",value:n.relativePath},{label:"caller path",value:e}])}export{ae as a};
|
|
7
|
-
//# sourceMappingURL=chunk-
|
|
7
|
+
//# sourceMappingURL=chunk-2E7QY4B5.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as w}from"./chunk-
|
|
1
|
+
import{b as w}from"./chunk-Z7M7X3ZG.js";import{b as g}from"./chunk-HFBNIIZX.js";import{c as h,d as f}from"./chunk-MTDBHTSF.js";import{d as u,e as c,h as m,p as b,q as p}from"./chunk-AYRHVJXW.js";import{dirname as $,relative as T,resolve as k}from"path";var A=new Set(f());function O(t,n){return`tests/generated/twin-ab/${y(t)}-vs-${y(n)}.test.ts`}function y(t){return(t.split(/[/#]/).pop()||t).replace(/[^A-Za-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")||"symbol"}function I(t,n,a,e){let o=d(t,n);if(!o.ok)return o;let i=d(t,a);if(!i.ok)return i;let r=o.symbol.paramCount===null||i.symbol.paramCount===null?null:o.symbol.paramCount===i.symbol.paramCount,s=v(o.symbol,i.symbol,t.config.projectRoot,e,r);return{ok:!0,a:o.symbol,b:i.symbol,signatureCompatible:r,testSource:s}}function d(t,n){let e=g(t,n).match;if(!e)return{ok:!1,reason:`${n} does not resolve to an indexed symbol.`};let i=t.get("SELECT kind FROM global_symbols WHERE id = ?",e.symbolId)?.kind??null;if(!(i!==null?A.has(i):m(e.symbol)))return{ok:!1,reason:`${n} resolves to ${u(e.symbol)}${i!==null?` with SCIP kind ${h(i)}`:""} \u2014 twin-ab compares call outputs, so both referents must be functions or methods.`};if(!w(t,e))return{ok:!1,reason:`${n} (${u(e.symbol)} at ${e.relativePath}:${e.startLine+1}) is not exported \u2014 twin-ab needs an importable named binding for both twins.`};let s=t.get("SELECT documentation FROM global_symbols WHERE id = ?",e.symbolId),l=b(p(s?.documentation??null));return{ok:!0,symbol:{ref:n,symbol:e.symbol,shortName:c(e.symbol)||u(e.symbol),file:e.relativePath,startLine:e.startLine,signature:l,paramCount:l?x(l):null}}}function x(t){let n=t.indexOf("(");if(n===-1)return null;let a=0,e=-1;for(let s=n;s<t.length;s+=1){let l=t[s];if(l==="(")a+=1;else if(l===")"&&(a-=1,a===0)){e=s;break}}if(e===-1)return null;let o=t.slice(n+1,e).trim();if(!o)return 0;let i=1,r=0;for(let s of o)s==="("||s==="["||s==="{"?r+=1:s===")"||s==="]"||s==="}"?r=Math.max(0,r-1):s===","&&r===0&&(i+=1);return i}function S(t,n,a){let e=$(n),o=k(t,a),r=T(e,o).replace(/\\/g,"/").replace(/\.tsx?$/,".js");return r.startsWith(".")?r:`./${r}`}function v(t,n,a,e,o){let i=S(a,e,t.file),r=S(a,e,n.file),s=o===null?"Signature comparison: unknown (one or both signatures unavailable in the index) \u2014 check by hand.":o?"Signature comparison: param counts match.":"Signature comparison: param counts DIFFER \u2014 twins may not be directly comparable; check by hand.";return`/**
|
|
2
2
|
* Generated by 'scip-query twin-ab'. scip-integrity-audit drill 5
|
|
3
3
|
* ("cross-examine same-concept twins"): where one concept is computed in
|
|
4
4
|
* more than one place, feed both the same input and require the same
|
|
@@ -37,4 +37,4 @@ describe.skipIf(inputs.length === 0)('twin-ab: ${t.shortName} vs ${n.shortName}'
|
|
|
37
37
|
});
|
|
38
38
|
});
|
|
39
39
|
`}export{O as a,I as b};
|
|
40
|
-
//# sourceMappingURL=chunk-
|
|
40
|
+
//# sourceMappingURL=chunk-2ROSOG2I.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as M}from"./chunk-FBUNGRKI.js";import{c as C}from"./chunk-
|
|
1
|
+
import{a as M}from"./chunk-FBUNGRKI.js";import{c as C}from"./chunk-QNO3QIMN.js";import{a as I}from"./chunk-OAM22BCR.js";import{h as f}from"./chunk-PLDIXTKR.js";import{f as d}from"./chunk-XAMVIPE2.js";import{d as h}from"./chunk-MTDBHTSF.js";import{d as g}from"./chunk-AYRHVJXW.js";import{f as y}from"./chunk-GAE7WCBK.js";var x=new Set(h());function N(e,n){let{scope:o,minLoc:r=10,limit:i=30,scanLimit:t}=n??{},s=new I(e);return M({candidates:()=>s.productionCallableDefinitions({scope:o,minLoc:r,requireFunctionLikeSymbol:!0,includeSuppressed:!0,sortByLocDesc:typeof t=="number"&&t>0}),scanLimit:t,filterCandidate:S,profile:{name:"complexity-hotspots"},prepare:a=>{let l=B(e,a),m=n?.semantic!==!1,c=m?d(e):null;c?.materializeReferences(a,{prefetchCallees:!0});let u=s.crossFileCallerMap(a,{semantic:!1});return{callerMap:c?f(u,c.callerMap(a)):u,calleeMap:s.calleeMap(a,{semantic:m}),languageByFile:l,clojureCallableIds:D(e,a,l),branchEstimates:C(e,a)}},evaluate:(a,l)=>L(a,l,r),orderResults:(a,l)=>l.score-a.score||l.loc-a.loc,limit:i})}function S(e){return e.symbol.startsWith("rust-analyzer ")?typeof e.kind=="number"&&x.has(e.kind):!0}function L(e,n,o){if(n.languageByFile.get(e.relativePath)==="clojure"&&!n.clojureCallableIds.has(e.symbolId))return null;let r=e.endLine-e.startLine+1;if(r<o)return null;let i=n.callerMap.get(e.symbolId)?.size??0,t=n.calleeMap.get(e.symbolId)??[],s=new Set,a=new Set;for(let p of t){let b=`${p.symbol}|${p.file}`;s.add(b),p.file!==e.relativePath&&a.add(b)}let l=a.size,m=s.size,c=n.branchEstimates.get(e.symbolId)??{branches:0,estimateBasis:"regex-fallback"},u=c.branches+1;return{symbol:e.symbol,shortName:g(e.symbol),file:e.relativePath,startLine:e.startLine,endLine:e.endLine,loc:r,fanIn:i,fanOut:l,calleeCount:m,branches:c.branches,estimateBasis:c.estimateBasis,score:Math.round(r/50*(i/5)*Math.max(l/5,1)*Math.max(u/5,1)*100)/100}}function B(e,n){let o=[...new Set(n.map(t=>t.relativePath))];if(o.length===0)return new Map;let r=o.map(()=>"?").join(", "),i=e.all(`SELECT relative_path, language
|
|
2
2
|
FROM documents
|
|
3
3
|
WHERE relative_path IN (${r})`,...o);return new Map(i.map(t=>[t.relative_path,t.language?.toLowerCase()??null]))}function D(e,n,o){let r=new Set,i=new Map;for(let t of n){if(o.get(t.relativePath)!=="clojure")continue;let s=i.get(t.relativePath);s||(s=new Set((y(e,t.relativePath)?.callables??[]).map(a=>`${a.name}:${a.startLine}`)),i.set(t.relativePath,s)),s.has(`${t.leaf}:${t.startLine}`)&&r.add(t.symbolId)}return r}export{N as a};
|
|
4
|
-
//# sourceMappingURL=chunk-
|
|
4
|
+
//# sourceMappingURL=chunk-33RLKB6L.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as i}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{b as i}from"./chunk-HHOJH3RJ.js";function l(n,o,s,t={}){let e=i(n,o,s,t);return e?{symbolA:e.symbolA,symbolB:e.symbolB,similarity:e.similarity,sharedCallees:e.sharedEvidence,uniqueToA:e.uniqueToA,uniqueToB:e.uniqueToB,consolidationStrategy:e.consolidationStrategy}:null}export{l as a};
|
|
2
|
+
//# sourceMappingURL=chunk-4BUMNEYQ.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as y}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as y}from"./chunk-HNTLCR4F.js";import{a as F}from"./chunk-LSJDKJIB.js";import{a as B}from"./chunk-YILKXTIY.js";import{a as j}from"./chunk-6EWBPAA3.js";import{a as z}from"./chunk-TYEGFDOP.js";import{a as $}from"./chunk-JRCJEHRG.js";import{a as v,b as G}from"./chunk-OLG2YPLS.js";import{a as O}from"./chunk-HAC5EI2T.js";import{b as k}from"./chunk-FB6IKAKZ.js";import{a as T}from"./chunk-KMOMNTB4.js";import{a as E}from"./chunk-QNO3QIMN.js";import{a as I}from"./chunk-IICQP2DY.js";import{a as H}from"./chunk-XWE7PZQH.js";import{s as A}from"./chunk-FC5K7T35.js";function ne(n,e,o={}){let i=o.impactDepth??3,r=o.sliceDepth??3,c=o.semantic,a=!N(e),u=a?l("trace",e,()=>j(n,e,{semantic:c}),t=>({definitions:t.definitions.length,references:t.referencedBy.length})):{definitions:[],referencedBy:[]},s=a?l("call-graph",e,()=>H(n,e,{semantic:c}),t=>({callers:t?.callers.length??0,callees:t?.callees.length??0})):null,d=a?l("complexity",e,()=>E(n,e,{semantic:c}),t=>({callees:t?.calleeCount??0})):null,g=a?l("dataflow",e,()=>$(n,e,{semantic:c}),t=>({references:t?.usageSites.length??0,producers:t?.producers.length??0,consumers:t?.consumers.length??0})):null,C=a?l("backward-slice",e,()=>y(n,e,{direction:"backward",maxDepth:r,semantic:c}),t=>({maxDepth:r,connectedSymbols:t?.connectedSymbols.length??0})):null,x=a?l("forward-slice",e,()=>y(n,e,{direction:"forward",maxDepth:r,semantic:c}),t=>({maxDepth:r,connectedSymbols:t?.connectedSymbols.length??0})):null,R=a?l("affected",e,()=>I(n,e,{maxDepth:i,scope:o.scope}),t=>({maxDepth:i,affectedSymbols:t.length})):[],h=l("change-surface",e,()=>O(n,e,{semantic:c}),t=>({symbols:t?.symbols.length??0,externalConsumers:t?.totalExternalConsumers??0})),p=l("system",e,()=>B(n,e),t=>({files:t.files.length,symbols:t.symbols.length})),m=p.files.length===1,b=l("deps",e,()=>m?p.dependsOn.map(t=>({relativePath:t})):v(n,e),t=>({files:t.length,reusedSystem:m})),S=l("rdeps",e,()=>m?p.dependedOnBy.map(t=>({relativePath:t})):G(n,e),t=>({files:t.length,reusedSystem:m})),w=l("surface",e,()=>F(n,e),t=>({consumers:t.length})),f={symbol:u.definitions.length>0||u.referencedBy.length>0||s!==null||d!==null||g!==null||C!==null||x!==null||R.length>0,file:h!==null||b.length>0||S.length>0,module:p.files.length>0||p.symbols.length>0||w.length>0},D=[];!f.symbol&&!f.file&&!f.module&&D.push("No symbol, file, or module matched target.");let P=h?.file??u.definitions[0]?.relativePath??null;return{target:e,matched:f,history:l("history",P??e,()=>L(n,P,o.gitHead)),trace:u,callGraph:s,complexity:d,dataflow:g,backwardSlice:C,forwardSlice:x,affected:R,changeSurface:h,deps:b,rdeps:S,system:p,surface:w,warnings:D}}function l(n,e,o,i=()=>({})){let r;return A(`plan-context.${n}`,()=>(r=o(),r),()=>({target:e,...i(r)}))}function L(n,e,o){let i={available:!1,file:e,churn:null,coChangePartners:[],suppressionsInFile:0};if(!e)return i;let r=T(n,o?{head:o}:{}),c=l("history.churn",e,()=>r.fileChurn(),s=>({files:s?.size??0}));if(!c)return i;let a=l("history.co-change",e,()=>k(n,e,{limit:5,...o?{head:o}:{}}),s=>({commits:s.commitsAnalyzed,partners:s.findings.length})),u=l("history.suppressions",e,()=>z(n).byFile.get(e)??0,s=>({suppressions:s}));return{available:!0,file:e,churn:c.get(e)??{changes:0,fixChanges:0,lastChangedAt:0},coChangePartners:a.findings.map(s=>({file:s.fileA===e?s.fileB:s.fileA,together:s.together,confidence:s.confidence,subjectContext:s.subjectContext})),suppressionsInFile:u}}function N(n){return n.includes("/")||n.includes("\\")||/\.[A-Za-z0-9]+(?::\d+(?:-\d+)?)?$/.test(n)}export{ne as a};
|
|
2
|
+
//# sourceMappingURL=chunk-5FUAFNMP.js.map
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import{g as Tn,h as b,i as pt,j as wn,k as Re,l as Rn}from"./chunk-MP43RX4O.js";import{a as we,b as $}from"./chunk-KHE7J5ZN.js";import{a as er,b as tr,e as rr}from"./chunk-HGFDYOVB.js";import{readFileSync as ms}from"fs";import{join as nr}from"path";var jd=4,Md=5e3,gs="watch.lock",ys="watch-state.json",hs="watch-activity.json";function $d(e){return{lockPath:nr(e,gs),statePath:nr(e,ys),activityPath:nr(e,hs)}}function Gd(e){try{return Ss(JSON.parse(ms(e,"utf8")))}catch{return null}}function Ss(e){if(!e||typeof e!="object")return null;let t=e;return t.version!==1||typeof t.protocolVersion!="number"||typeof t.pid!="number"||!Number.isInteger(t.pid)||t.pid<=0||typeof t.projectRoot!="string"||t.worktreeId!==void 0&&(typeof t.worktreeId!="string"||t.worktreeId.length===0)||typeof t.cliVersion!="string"||!N(t.startedAt)||!N(t.heartbeatAt)||!N(t.lastActivityAt)||!xs(t.watcher)||t.idleDeadlineAt!==void 0&&!N(t.idleDeadlineAt)||t.indexGeneration!==void 0&&!/^[a-f0-9]{64}$/.test(t.indexGeneration)||t.lastError!==void 0&&!bs(t.lastError)||t.lastRefresh!==void 0&&!Is(t.lastRefresh)||t.reindexActivity!==void 0&&!Es(t.reindexActivity)||t.typescriptSemantic!==void 0&&!vs(t.typescriptSemantic)||t.typescriptIndex!==void 0&&!Ts(t.typescriptIndex)?null:t}function N(e){return typeof e=="string"&&Number.isFinite(Date.parse(e))}function xs(e){if(!e||typeof e!="object"||!("state"in e))return!1;let t=e;switch(t.state){case"idle":return!0;case"waiting":return C(t.changedFiles)&&C(t.reindexAt);case"indexing":return C(t.startedAt);case"cooldown":return C(t.until)&&typeof t.dirty=="boolean";default:return!1}}function bs(e){if(!e||typeof e!="object")return!1;let t=e;return N(t.at)&&typeof t.message=="string"}function Is(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.trigger?.kind=="string"&&typeof t.result=="string"&&N(t.startedAt)&&N(t.completedAt)&&C(t.durationMs)}function Es(e){if(!e||typeof e!="object")return!1;let t=e;return!N(t.windowStartedAt)||!N(t.windowEndedAt)||!k(t.runs)||!k(t.rebuilt)||!k(t.reused)||!k(t.failed)||!k(t.suppressed)||!C(t.estimatedLogicalOutputBytes)||t.estimatedLogicalOutputBytes<0||!t.byTrigger||typeof t.byTrigger!="object"?!1:Object.values(t.byTrigger).every(r=>r===void 0||k(r))}function vs(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.protocolVersion=="number"&&(t.state==="idle"||t.state==="ready"||t.state==="unavailable"||t.state==="error")&&C(t.requests)&&C(t.sessionsCreated)&&C(t.sessionsReused)&&C(t.sessionsRefreshed)&&C(t.sessionsReplaced)&&C(t.projectsCreated)&&(t.lastRequestAt===void 0||N(t.lastRequestAt))&&(t.lastError===void 0||typeof t.lastError=="string")&&(t.busyUntil===void 0||N(t.busyUntil))}function Ts(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.protocolVersion=="number"&&(t.state==="idle"||t.state==="ready"||t.state==="unavailable"||t.state==="error")&&k(t.requests)&&k(t.sessionsCreated)&&k(t.sessionsReplaced)&&k(t.initializations)&&k(t.programUpdates)&&k(t.documentsEmitted)&&k(t.documentsRemoved)&&(t.lastRequestAt===void 0||N(t.lastRequestAt))&&(t.lastDurationMs===void 0||C(t.lastDurationMs)&&t.lastDurationMs>=0)&&(t.lastError===void 0||typeof t.lastError=="string")&&(t.busyUntil===void 0||N(t.busyUntil))}function C(e){return typeof e=="number"&&Number.isFinite(e)}function k(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0}import{appendFileSync as ws,existsSync as Rs,mkdirSync as ks,readFileSync as Cs,renameSync as Ns,rmSync as Ps,statSync as Nn}from"fs";import{dirname as Pn,join as Ds}from"path";var _s="reindex-activity.jsonl",Dn=".previous",As=1024*1024,Fs=1440*60*1e3,Os={appendFile:ws,exists:Rs,mkdir:e=>ks(e,{recursive:!0}),rename:Ns,remove:e=>Ps(e,{force:!0}),size:e=>Nn(e).size};function ut(e){return Ds(Pn(e),_s)}function Ls(e){if(e.reused)return 0;let t=Cn(e.indexPath)+Cn(e.dbPath);for(let r of e.shards??[])!r.reused&&r.outputBytes!==null&&(t+=r.outputBytes);return t}function Ud(e,t){let r=t.lastRefresh;r&&ir(ut(e),{version:1,event:"run",recordedAt:r.completedAt,trigger:r.trigger,result:r.result,durationMs:r.durationMs,estimatedLogicalOutputBytes:Ls(t)})}function Hd(e,t){ir(ut(e),{version:1,event:"run",recordedAt:t.completedAt,trigger:t.trigger,result:"failed",durationMs:t.durationMs,estimatedLogicalOutputBytes:0})}function zd(e,t,r=new Date){ir(ut(e),{version:1,event:"suppressed",recordedAt:r.toISOString(),trigger:t,reason:"completed-index-is-fresh"})}function js(e,t,r=As,n=Os){let i=`${JSON.stringify(t)}
|
|
2
|
+
`,o=Math.max(1,Math.floor(r)),s=`${e}${Dn}`;if(n.mkdir(Pn(e)),n.exists(e)){let a=n.size(e);a>o?(n.remove(e),n.remove(s)):a+Buffer.byteLength(i)>o&&(n.remove(s),n.rename(e,s))}n.appendFile(e,i)}function qd(e,t=new Date,r=Fs,n=i=>Cs(i,"utf8")){let i=t.getTime(),o=i-r,s={windowStartedAt:new Date(o).toISOString(),windowEndedAt:t.toISOString(),runs:0,rebuilt:0,reused:0,failed:0,suppressed:0,estimatedLogicalOutputBytes:0,byTrigger:{}},a=ut(e);for(let c of[`${a}${Dn}`,a]){let l;try{l=n(c)}catch{continue}for(let p of l.split(`
|
|
3
|
+
`)){if(!p)continue;let u=Ms(p);if(!u)continue;let d=Date.parse(u.recordedAt);if(!(d<o||d>i)){if(s.byTrigger[u.trigger.kind]=(s.byTrigger[u.trigger.kind]??0)+1,u.event==="suppressed"){s.suppressed+=1;continue}s.runs+=1,s[u.result]+=1,s.estimatedLogicalOutputBytes+=u.estimatedLogicalOutputBytes}}}return s}function ir(e,t){try{js(e,t)}catch{}}function Ms(e){try{let t=JSON.parse(e);if(!t||typeof t!="object")return null;let r=t;return r.version!==1||!Gs(r.recordedAt)||!r.trigger||!$s(r.trigger.kind)?null:r.event==="suppressed"?r.reason==="completed-index-is-fresh"?r:null:r.event!=="run"||r.result!=="rebuilt"&&r.result!=="reused"&&r.result!=="failed"||!kn(r.durationMs)||!kn(r.estimatedLogicalOutputBytes)?null:r}catch{return null}}function $s(e){return e==="manual-cli"||e==="setup"||e==="watch-source"||e==="watch-startup"||e==="watch-demand"||e==="watch-git-head"||e==="watch-git-index"||e==="watch-git-state"||e==="unknown"}function Gs(e){return typeof e=="string"&&Number.isFinite(Date.parse(e))}function kn(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0}function Cn(e){try{return Nn(e).size}catch{return 0}}import{createHash as Ws}from"crypto";import{mkdirSync as Bs,realpathSync as Vs}from"fs";import{homedir as Us}from"os";import{join as ce,resolve as _n}from"path";function Hs(e,t){let r=process.env.SCIP_QUERY_CACHE_DIR;if(r)return or(r);if(t?.dbPath)return or(_n(e,t.dbPath));let n=sr(e);return or(n)}function An(){let e=process.env.XDG_CACHE_HOME;return ce(e||ce(Us(),".cache"),"scip-query")}function sr(e){let t=_n(e);try{t=Vs(t)}catch{}let r=Ws("sha256").update(t).digest("hex").slice(0,12);return ce(An(),"projects",r)}function ar(e){if(!/^[a-f0-9]{24}$/.test(e))throw new Error(`invalid repository cache identity: ${e}`);return ce(An(),"repositories",e)}function cr(e){return process.env.SCIP_QUERY_SHARED_CACHE!=="0"&&!process.env.SCIP_QUERY_CACHE_DIR&&!process.env.SCIP_QUERY_INDEX_DB&&!e?.dbPath}function Zd(e,t){let r=Hs(e,t);return{cacheDir:r,dbPath:ce(r,"index.db"),indexPath:ce(r,"index.scip"),metaPath:ce(r,"meta.json")}}function or(e){return Bs(e,{recursive:!0}),e}import{createHash as zs}from"crypto";import{readFileSync as qs}from"fs";import{dirname as Js,join as dt}from"path";var Xs=2,Ys="typescript-index";function of(e){let t=dt(e,Ys);return{rootDir:t,requestDir:dt(t,"requests"),responseDir:dt(t,"responses")}}function sf(e){let t=JSON.parse(e);if(t.protocolVersion!==Xs||typeof t.id!="string"||!t.id||typeof t.baseGeneration!="string"||!t.baseGeneration||typeof t.deadlineAtMs!="number"||!Number.isFinite(t.deadlineAtMs)||!Ks(t.request))throw new Error("TypeScript index service received an invalid mailbox request.");return t}function af(e){try{let t=JSON.parse(qs(dt(Js(e),"meta.json"),"utf8"));return t.version!==2&&t.version!==3||t.status!=="complete"||typeof t.updatedAt!="string"||t.fingerprint===void 0?null:zs("sha256").update(JSON.stringify({version:t.version,status:t.status,updatedAt:t.updatedAt,fingerprint:t.fingerprint,indexedLanguages:t.indexedLanguages})).digest("hex")}catch{return null}}function Ks(e){if(!e||typeof e!="object")return!1;let t=e,r=Fn(t.modifiedFiles)?t.modifiedFiles:null,n=Fn(t.affectedFiles)?t.affectedFiles:null;return t.kind==="emit-documents"&&typeof t.tsconfigPath=="string"&&!!t.tsconfigPath&&typeof t.projectArgument=="string"&&!!t.projectArgument&&typeof t.projectIdentity=="string"&&!!t.projectIdentity&&typeof t.producerIdentity=="string"&&!!t.producerIdentity&&r!==null&&r.length>0&&new Set(r).size===r.length&&n!==null&&n.length>0&&new Set(n).size===n.length&&r.every(i=>n.includes(i))}function Fn(e){return Array.isArray(e)&&e.every(t=>typeof t=="string"&&t.length>0)}import{spawnSync as Qs}from"child_process";import{createHash as Zs}from"crypto";import{existsSync as ea,lstatSync as ta,realpathSync as ra}from"fs";import{dirname as na,isAbsolute as ia,join as oa,resolve as mt}from"path";var gt={run(e,t){let r=Ln(e,t);return r.kind==="success"?r.output:void 0},runResult:Ln},sa=["rev-parse","--show-toplevel","--absolute-git-dir","--git-common-dir","HEAD","HEAD^{tree}"],On=/^[0-9a-f]{40,64}$/;function jn(e,t=gt){let r=t.runResult(e,sa);if(r.kind==="success"){let n=aa(r.output);if(n)return ca(n,t)}return la(e,t)}function aa(e){let t=e.split(`
|
|
4
|
+
`).map(c=>c.trim());if(t.length!==5)return;let[r,n,i,o,s]=t;if(!r||!n||!i||!o||!s||!On.test(o)||!On.test(s))return;let a=le(r);return{root:a,gitDir:le(ft(a,n)),commonDir:le(ft(a,i)),headCommit:o,treeOid:s}}function ca(e,t){let r=t.run(e.root,["status","--porcelain=v1","-z","--untracked-files=all"]);return r===void 0?void 0:{...Mn(e.root,e.gitDir),commonDir:e.commonDir,repositoryId:pr("repository",e.commonDir),headCommit:e.headCommit,treeOid:e.treeOid,clean:r.length===0}}function la(e,t){let r=pa(e,t);if(r.kind!=="worktree")return;let n=r.identity,i=n.projectRoot,o=t.run(i,["rev-parse","--git-common-dir"])?.trim();if(!o)return;let s=le(ft(i,o)),a=lr(t.run(i,["rev-parse","--verify","HEAD"])),c=lr(t.run(i,["rev-parse","--verify","HEAD^{tree}"])),l=t.run(i,["status","--porcelain=v1","-z","--untracked-files=all"]);if(l!==void 0)return{...n,commonDir:s,repositoryId:pr("repository",s),headCommit:a,treeOid:c,clean:l.length===0}}function pa(e,t=gt){let r=t.runResult(e,["rev-parse","--show-toplevel"]);if(r.kind==="not-repository")return{kind:"non-git"};if(r.kind==="error")return r;let n=r.output.trim();if(!n)return{kind:"error",message:"Git returned an empty worktree root."};let i=le(n),o=t.run(i,["rev-parse","--absolute-git-dir"])?.trim();if(!o)return{kind:"error",message:"Git did not return an absolute worktree directory."};let s=le(ft(i,o));return{kind:"worktree",identity:Mn(i,s)}}function Mn(e,t){return{projectRoot:e,gitDir:t,worktreeId:pr("worktree",`${e}\0${t}`)}}function ua(e,t=gt){let r=t.run(e,["worktree","list","--porcelain","-z"]);return r===void 0?[]:da(r)}function da(e){let t=[],r;for(let n of e.split("\0")){if(n===""){r&&t.push(r),r=void 0;continue}let i=n.indexOf(" "),o=i<0?n:n.slice(0,i),s=i<0?"":n.slice(i+1);if(o==="worktree"){r&&t.push(r),r={path:le(s),detached:!1,bare:!1,prunable:!1,locked:!1};continue}r&&(o==="HEAD"?r.head=s:o==="branch"?r.branch=s:o==="detached"?r.detached=!0:o==="bare"?r.bare=!0:o==="prunable"?r.prunable=!0:o==="locked"&&(r.locked=!0))}return r&&t.push(r),t}function ff(e,t,r=gt){return lr(r.run(e,t))}function ft(e,t){return ia(t)?t:mt(e,t)}function le(e){try{return ra(e)}catch{return mt(e)}}function pr(e,t){return Zs("sha256").update(`${e}\0${t}`).digest("hex").slice(0,24)}function lr(e){return e?.trim()||void 0}function Ln(e,t){let r=Qs("git",["-C",e,...t],{encoding:"utf-8",env:{...process.env,LC_ALL:"C"},maxBuffer:52428800,stdio:["ignore","pipe","pipe"]});if(r.status===0)return{kind:"success",output:r.stdout.trimEnd()};let i=(typeof r.stderr=="string"?r.stderr.trim():"")||r.error?.message||`git exited with status ${r.status??"unknown"}`,o=r.error?.code;return(/not a git repository/i.test(i)||o==="ENOENT"&&ea(mt(e)))&&!fa(e)?{kind:"not-repository"}:{kind:"error",message:i}}function fa(e){if(process.env.GIT_DIR||process.env.GIT_COMMON_DIR)return!0;let t=mt(e);for(;;){try{return ta(oa(t,".git")),!0}catch(n){let i=n.code;if(i!=="ENOENT"&&i!=="ENOTDIR")return!0}let r=na(t);if(r===t)return!1;t=r}}import{randomUUID as $n}from"crypto";import{closeSync as Gn,mkdirSync as ma,openSync as Wn,readFileSync as Bn,unlinkSync as Vn,writeFileSync as Un}from"fs";import{dirname as ga,join as ya}from"path";function Hn(e,t={}){return ur(ya(e,"gc.lock"),t)}function ur(e,t={}){let r=t.waitMs??0,n=t.pollMs??10,i=t.now??Date.now,o=Date.now()+r;ma(ga(e),{recursive:!0});do{let s=$n();try{let a=Wn(e,"wx");try{let c={version:1,pid:process.pid,token:s,startedAt:new Date(i()).toISOString()};Un(a,`${JSON.stringify(c)}
|
|
5
|
+
`)}finally{Gn(a)}return{release:()=>qn(e,s)}}catch(a){if(a.code!=="EEXIST")return null;let c=zn(e);if(c&&(c.pid===void 0||!we(c.pid))){ha(e,c);continue}if(Date.now()>=o)return null;Sa(Math.min(n,Math.max(1,o-Date.now())))}}while(Date.now()<=o);return null}function zn(e){try{let t=Bn(e,"utf8"),r=JSON.parse(t),n=typeof r.pid=="number"&&Number.isSafeInteger(r.pid)&&r.pid>0?r.pid:void 0;return{raw:t,...n===void 0?{}:{pid:n}}}catch{return null}}function ha(e,t){let r=`${e}.reclaim`,n=$n(),i;try{i=Wn(r,"wx")}catch{return!1}try{Un(i,`${JSON.stringify({version:1,pid:process.pid,token:n,startedAt:new Date().toISOString()})}
|
|
6
|
+
`)}finally{Gn(i)}try{let o=zn(e);return!o||o.raw!==t.raw||o.pid!==void 0&&we(o.pid)?!1:(Vn(e),!0)}catch{return!1}finally{qn(r,n)}}function qn(e,t){try{let r=JSON.parse(Bn(e,"utf8"));r.pid===process.pid&&r.token===t&&Vn(e)}catch{}}function Sa(e){let t=new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));Atomics.wait(t,0,0,e)}import xa from"better-sqlite3";var ba=["node_modules",".git","dist","build","out","coverage","target",".next",".nuxt",".cache",".turbo",".nbb",".cpcache",".shadow-cljs",".scipquery-cache","__pycache__",".venv","venv"],Jn=class{db;config;pathFilter;statementCache=new Map;constructor(t,r){this.config=t,this.pathFilter=r??null,this.db=new xa(t.dbPath,{readonly:!0}),this.db.pragma("busy_timeout = 5000"),this.db.pragma("query_only = ON"),this.db.pragma("temp_store = MEMORY"),this.db.pragma("cache_size = -64000"),this.db.pragma("mmap_size = 268435456")}isIgnored(t){return this.pathFilter?.isIgnored(t)??!1}get localSymbolPredicate(){return`(
|
|
7
|
+
EXISTS (
|
|
8
|
+
SELECT 1
|
|
9
|
+
FROM defn_enclosing_ranges local_der
|
|
10
|
+
JOIN documents local_d ON local_der.document_id = local_d.id
|
|
11
|
+
WHERE local_der.symbol_id = gs.id
|
|
12
|
+
${this.pathExclusionsFor("local_d").trimStart()}
|
|
13
|
+
)
|
|
14
|
+
OR EXISTS (
|
|
15
|
+
SELECT 1
|
|
16
|
+
FROM mentions local_m
|
|
17
|
+
JOIN chunks local_c ON local_m.chunk_id = local_c.id
|
|
18
|
+
JOIN documents local_d ON local_c.document_id = local_d.id
|
|
19
|
+
WHERE local_m.symbol_id = gs.id
|
|
20
|
+
AND local_m.role = 1
|
|
21
|
+
${this.pathExclusionsFor("local_d").trimStart()}
|
|
22
|
+
)
|
|
23
|
+
)`}get pathExclusions(){return this.pathExclusionsFor("d")}get symbolNoise(){return this.symbolNoiseFor("gs")}pathExclusionsFor(...t){return t.flatMap(r=>ba.flatMap(n=>[`AND ${r}.relative_path NOT LIKE '${n}/%'`,`AND ${r}.relative_path NOT LIKE '%/${n}/%'`])).join(`
|
|
24
|
+
`)}symbolNoiseFor(t){return`AND ${t}.symbol NOT LIKE '%().(%' AND ${t}.symbol NOT LIKE '%typeLiteral%'`}all(t,...r){return this.statement(t).all(...r)}get(t,...r){return this.statement(t).get(...r)}close(){this.statementCache.clear(),this.db.close()}statement(t){let r=this.statementCache.get(t);return r||(r=this.db.prepare(t),this.statementCache.set(t,r)),r}};import{createHash as Ia}from"crypto";import{existsSync as Ea,mkdirSync as va,readFileSync as Ta}from"fs";import{dirname as dr,join as Xn}from"path";import fr from"better-sqlite3";var wa="evidence.db";var Ra=["source-facts","definition-exclusions","doc-path-tokens","react-component-behavior-profiles"],mr=new Set(Ra),ka=25e4,Ca=512*1024*1024;var yt=new WeakMap,Na=b("evidence-content-hash",{clearGroups:["whole-project","source-file"]}),Pa=b("evidence-project-fingerprint",{clearGroups:["whole-project"]}),K="evidence-v1",ke="version NOT LIKE 'evidence-%'";function ht(e){return Ia("sha256").update(e).digest("hex")}function je(e,t,r){return Na.get(e,t,()=>ht(r))}function Yn(e){return Pa.get(e,"current",()=>{try{let t=JSON.parse(Ta(Xn(dr(e.config.dbPath),"meta.json"),"utf-8"));if(t.version!==2&&t.version!==3||t.status!=="complete"&&t.status!=="partial"||t.fingerprint===void 0)return null;let r=Array.isArray(t.indexedLanguages)?[...t.indexedLanguages].sort():[];return ht(JSON.stringify({fingerprint:t.fingerprint,indexedLanguages:r,status:t.status}))}catch(t){return Ce("project fingerprint unavailable",t),null}})}function Ce(e,t){process.env.SCIP_QUERY_DEBUG&&console.error(`evidence-cache: ${e}: ${t instanceof Error?t.message:String(t)}`)}function Me(e){if(yt.has(e))return yt.get(e)??null;let t=null;try{let r=new fr(Xn(dr(e.config.dbPath),wa));r.pragma("journal_mode = WAL"),r.pragma("busy_timeout = 5000"),r.pragma("synchronous = NORMAL"),r.exec(`
|
|
25
|
+
CREATE TABLE IF NOT EXISTS file_evidence (
|
|
26
|
+
kind TEXT NOT NULL,
|
|
27
|
+
relative_path TEXT NOT NULL,
|
|
28
|
+
content_hash TEXT NOT NULL,
|
|
29
|
+
version TEXT NOT NULL,
|
|
30
|
+
payload TEXT NOT NULL,
|
|
31
|
+
PRIMARY KEY (kind, relative_path)
|
|
32
|
+
);
|
|
33
|
+
CREATE TABLE IF NOT EXISTS project_evidence (
|
|
34
|
+
kind TEXT NOT NULL,
|
|
35
|
+
cache_key TEXT NOT NULL,
|
|
36
|
+
project_fingerprint TEXT NOT NULL,
|
|
37
|
+
version TEXT NOT NULL,
|
|
38
|
+
payload TEXT NOT NULL,
|
|
39
|
+
PRIMARY KEY (kind, cache_key)
|
|
40
|
+
);
|
|
41
|
+
CREATE TABLE IF NOT EXISTS semantic_callees (
|
|
42
|
+
relative_path TEXT NOT NULL,
|
|
43
|
+
symbol TEXT NOT NULL,
|
|
44
|
+
content_hash TEXT NOT NULL,
|
|
45
|
+
deps_digest TEXT NOT NULL,
|
|
46
|
+
version TEXT NOT NULL,
|
|
47
|
+
payload TEXT NOT NULL,
|
|
48
|
+
PRIMARY KEY (relative_path, symbol)
|
|
49
|
+
);
|
|
50
|
+
CREATE TABLE IF NOT EXISTS semantic_references (
|
|
51
|
+
relative_path TEXT NOT NULL,
|
|
52
|
+
symbol TEXT NOT NULL,
|
|
53
|
+
project_fingerprint TEXT NOT NULL,
|
|
54
|
+
version TEXT NOT NULL,
|
|
55
|
+
payload TEXT NOT NULL,
|
|
56
|
+
PRIMARY KEY (relative_path, symbol)
|
|
57
|
+
);
|
|
58
|
+
CREATE TABLE IF NOT EXISTS finding_outcome_ledger (
|
|
59
|
+
check_name TEXT NOT NULL,
|
|
60
|
+
finding_id TEXT NOT NULL,
|
|
61
|
+
first_seen INTEGER NOT NULL,
|
|
62
|
+
last_seen INTEGER NOT NULL,
|
|
63
|
+
times_shown INTEGER NOT NULL,
|
|
64
|
+
outcome TEXT NOT NULL,
|
|
65
|
+
PRIMARY KEY (check_name, finding_id)
|
|
66
|
+
);
|
|
67
|
+
`),t={evidence:r,shared:Da(e.config.sharedEvidenceDbPath),readFileEvidence:r.prepare("SELECT payload FROM file_evidence WHERE kind = ? AND relative_path = ? AND content_hash = ? AND version = ?"),readLegacyFileEvidence:r.prepare(`SELECT payload FROM file_evidence
|
|
68
|
+
WHERE kind = ? AND relative_path = ? AND content_hash = ? AND ${ke}
|
|
69
|
+
ORDER BY version DESC
|
|
70
|
+
LIMIT 1`),writeFileEvidence:r.prepare("INSERT OR REPLACE INTO file_evidence (kind, relative_path, content_hash, version, payload) VALUES (?, ?, ?, ?, ?)"),readProjectEvidence:r.prepare("SELECT payload FROM project_evidence WHERE kind = ? AND cache_key = ? AND project_fingerprint = ? AND version = ?"),readLegacyProjectEvidence:r.prepare(`SELECT payload FROM project_evidence
|
|
71
|
+
WHERE kind = ? AND cache_key = ? AND project_fingerprint = ? AND ${ke}
|
|
72
|
+
ORDER BY version DESC
|
|
73
|
+
LIMIT 1`),writeProjectEvidence:r.prepare("INSERT OR REPLACE INTO project_evidence (kind, cache_key, project_fingerprint, version, payload) VALUES (?, ?, ?, ?, ?)"),readCallees:r.prepare(`SELECT payload FROM semantic_callees
|
|
74
|
+
WHERE relative_path = ? AND symbol = ? AND content_hash = ? AND deps_digest = ? AND version = ?`),readLegacyCallees:r.prepare(`SELECT payload FROM semantic_callees
|
|
75
|
+
WHERE relative_path = ? AND symbol = ? AND content_hash = ? AND deps_digest = ? AND ${ke}
|
|
76
|
+
ORDER BY version DESC
|
|
77
|
+
LIMIT 1`),readCalleesForFile:r.prepare(`SELECT symbol, payload FROM semantic_callees
|
|
78
|
+
WHERE relative_path = ? AND content_hash = ? AND deps_digest = ? AND version = ?`),readLegacyCalleesForFile:r.prepare(`SELECT symbol, payload FROM semantic_callees
|
|
79
|
+
WHERE relative_path = ? AND content_hash = ? AND deps_digest = ? AND ${ke}
|
|
80
|
+
ORDER BY symbol, version DESC`),writeCallees:r.prepare(`INSERT OR REPLACE INTO semantic_callees
|
|
81
|
+
(relative_path, symbol, content_hash, deps_digest, version, payload) VALUES (?, ?, ?, ?, ?, ?)`),dropStaleCallees:r.prepare("DELETE FROM semantic_callees WHERE relative_path = ? AND content_hash != ?"),readReferences:r.prepare(`SELECT payload FROM semantic_references
|
|
82
|
+
WHERE relative_path = ? AND symbol = ? AND project_fingerprint = ? AND version = ?`),readLegacyReferences:r.prepare(`SELECT payload FROM semantic_references
|
|
83
|
+
WHERE relative_path = ? AND symbol = ? AND project_fingerprint = ? AND ${ke}
|
|
84
|
+
ORDER BY version DESC
|
|
85
|
+
LIMIT 1`),readReferencesForFile:r.prepare(`SELECT symbol, payload FROM semantic_references
|
|
86
|
+
WHERE relative_path = ? AND project_fingerprint = ? AND version = ?`),readLegacyReferencesForFile:r.prepare(`SELECT symbol, payload FROM semantic_references
|
|
87
|
+
WHERE relative_path = ? AND project_fingerprint = ? AND ${ke}
|
|
88
|
+
ORDER BY symbol, version DESC`),writeReferences:r.prepare(`INSERT OR REPLACE INTO semantic_references
|
|
89
|
+
(relative_path, symbol, project_fingerprint, version, payload) VALUES (?, ?, ?, ?, ?)`),dropStaleReferences:r.prepare("DELETE FROM semantic_references WHERE relative_path = ? AND project_fingerprint != ?"),readFindingOutcomeLedger:r.prepare("SELECT check_name, finding_id, first_seen, last_seen, times_shown, outcome FROM finding_outcome_ledger"),deleteFindingOutcomeLedgerForCheck:r.prepare("DELETE FROM finding_outcome_ledger WHERE check_name = ?"),writeFindingOutcomeLedgerRow:r.prepare(`INSERT INTO finding_outcome_ledger
|
|
90
|
+
(check_name, finding_id, first_seen, last_seen, times_shown, outcome) VALUES (?, ?, ?, ?, ?, ?)`)}}catch(r){Ce("disabled (open failed)",r)}return yt.set(e,t),t}function $e(e,t,r){Ce(`disabled (${t})`,r),yt.set(e,null)}function Da(e){if(!e)return null;try{va(dr(e),{recursive:!0});let t=new fr(e);return t.pragma("journal_mode = WAL"),t.pragma("busy_timeout = 250"),t.pragma("synchronous = NORMAL"),t.exec(`
|
|
91
|
+
CREATE TABLE IF NOT EXISTS file_evidence (
|
|
92
|
+
kind TEXT NOT NULL,
|
|
93
|
+
relative_path TEXT NOT NULL,
|
|
94
|
+
content_hash TEXT NOT NULL,
|
|
95
|
+
version TEXT NOT NULL,
|
|
96
|
+
payload TEXT NOT NULL,
|
|
97
|
+
last_accessed_at INTEGER NOT NULL,
|
|
98
|
+
PRIMARY KEY (kind, relative_path, content_hash, version)
|
|
99
|
+
);
|
|
100
|
+
`),{evidence:t,readFileEvidence:t.prepare("SELECT payload FROM file_evidence WHERE kind = ? AND relative_path = ? AND content_hash = ? AND version = ?"),writeFileEvidence:t.prepare(`INSERT INTO file_evidence (kind, relative_path, content_hash, version, payload, last_accessed_at)
|
|
101
|
+
VALUES (?, ?, ?, ?, ?, ?)
|
|
102
|
+
ON CONFLICT(kind, relative_path, content_hash, version)
|
|
103
|
+
DO UPDATE SET payload = excluded.payload, last_accessed_at = excluded.last_accessed_at`)}}catch(t){return Ce("shared cache disabled (open failed)",t),null}}function gr(e,t,r){Ce(`shared cache disabled (${t})`,r);try{e.shared?.evidence.close()}catch{}e.shared=null}function kf(e,t={}){if(!Ea(e))return null;let r;try{r=new fr(e),r.pragma("busy_timeout = 50"),r.pragma("wal_checkpoint(TRUNCATE)");let n=r.prepare("SELECT COUNT(*) AS count FROM file_evidence").get().count,i=t.maxRows??ka,o=t.budgetBytes??Ca,s=Number(r.pragma("page_size",{simple:!0})),a=Number(r.pragma("page_count",{simple:!0})),c=Number(r.pragma("freelist_count",{simple:!0})),l=Math.max(0,a-c)*s,p=n>0&&l>o?Math.min(n,Math.ceil((l-o)/Math.max(1,l/n))):0,u=Math.max(n-i,p);return u>0&&(r.prepare(`DELETE FROM file_evidence WHERE rowid IN (
|
|
104
|
+
SELECT rowid FROM file_evidence ORDER BY last_accessed_at ASC, rowid ASC LIMIT ?
|
|
105
|
+
)`).run(u),r.pragma("wal_checkpoint(TRUNCATE)")),{deletedRows:u,remainingRows:n-u}}catch(n){return Ce("shared cache maintenance skipped",n),null}finally{try{r?.close()}catch{}}}function Kn(e,t,r,n){let i=Me(e);if(!i)return null;try{let o=i.readFileEvidence.get(t,r,n,K)??i.readLegacyFileEvidence.get(t,r,n);if(o?.payload!==void 0)return o.payload;if(!mr.has(t)||!i.shared)return null;try{return i.shared.readFileEvidence.get(t,r,n,K)?.payload??null}catch(s){return gr(i,"file_evidence read",s),null}}catch(o){return $e(e,"file_evidence read",o),null}}function Qn(e,t,r,n,i){let o=Me(e);if(o)try{if(o.writeFileEvidence.run(t,r,n,K,i),mr.has(t)&&o.shared)try{o.shared.writeFileEvidence.run(t,r,n,K,i,Date.now())}catch(s){gr(o,"file_evidence write",s)}}catch(s){$e(e,"file_evidence write",s)}}function Zn(e,t){if(t.length===0)return;let r=Me(e);if(r)try{r.evidence.transaction(()=>{for(let i of t)r.writeFileEvidence.run(i.kind,i.relativePath,i.contentHash,K,i.payload)})();let n=t.filter(i=>mr.has(i.kind));if(n.length>0&&r.shared)try{r.shared.evidence.transaction(()=>{for(let i of n)r.shared.writeFileEvidence.run(i.kind,i.relativePath,i.contentHash,K,i.payload,Date.now())})()}catch(i){gr(r,"file_evidence batch write",i)}}catch(n){$e(e,"file_evidence batch write",n)}}function ei(e,t,r,n){let i=Me(e);if(!i)return null;try{return(i.readProjectEvidence.get(t,r,n,K)??i.readLegacyProjectEvidence.get(t,r,n))?.payload??null}catch(o){return $e(e,"project_evidence read",o),null}}function ti(e,t,r,n,i){let o=Me(e);if(o)try{o.writeProjectEvidence.run(t,r,n,K,i)}catch(s){$e(e,"project_evidence write",s)}}function yr(e){return typeof e=="object"&&e!==null}function Nf(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")?e:null}import{execFileSync as _a}from"child_process";import{existsSync as Aa,readdirSync as ni}from"fs";import{extname as ii,join as oi}from"path";var si=new Set([".git",".hg",".svn",".idea",".vscode","node_modules","vendor","dist","build","target","bin","obj",".dart_tool",".gradle",".next",".venv","venv","__pycache__"]),Fa=[{language:"typescript",files:["tsconfig.json","tsconfig.base.json"],extensions:[".ts",".tsx",".mts",".cts"]},{language:"rust",files:["Cargo.toml"],extensions:[".rs"]},{language:"go",files:["go.mod"],extensions:[".go"]},{language:"java",files:["pom.xml","build.gradle","build.gradle.kts"],extensions:[".java"]},{language:"kotlin",files:["build.gradle.kts"],extensions:[".kt",".kts"]},{language:"scala",files:["build.sbt"],extensions:[".scala"]},{language:"clojure",files:["deps.edn","project.clj","bb.edn","shadow-cljs.edn"],extensions:[".clj",".cljs",".cljc"]},{language:"python",files:["pyproject.toml","setup.py","setup.cfg","Pipfile"],extensions:[".py",".pyi"]},{language:"ruby",files:["Gemfile"],extensions:[".rb"]},{language:"cpp",files:["compile_commands.json","CMakeLists.txt","Makefile"],extensions:[".cc",".cpp",".cxx",".hpp",".hh",".hxx"]},{language:"c",files:["compile_commands.json","CMakeLists.txt","Makefile"],extensions:[".c",".h"]},{language:"csharp",globs:["*.csproj","*.sln"],extensions:[".cs"]},{language:"vb",globs:["*.vbproj"],extensions:[".vb"]},{language:"dart",files:["pubspec.yaml"],extensions:[".dart"]},{language:"php",files:["composer.json"],extensions:[".php"]},{language:"javascript",files:["package.json"],extensions:[".js",".jsx",".mjs",".cjs"]}];function Ff(e){let t=[],r=Oa(e),n=$a(e);for(let i of Fa){if(La(e,i.files)){t.push(i.language);continue}if(ja(r,i.globs)){t.push(i.language);continue}Wa(n,i.extensions)&&t.push(i.language)}return t.includes("typescript")&&ri(t,"javascript"),t.includes("cpp")&&!n.has(".c")&&ri(t,"c"),t}function Oa(e){try{return ni(e)}catch{return[]}}function La(e,t){return t?.length?t.some(r=>Aa(oi(e,r))):!1}function ja(e,t){return t?.length?e.some(r=>t.some(n=>Ma(r,n))):!1}function Ma(e,t){if(t==="*")return!0;if(!t.includes("*"))return e===t;let[r,n]=t.split("*");return e.startsWith(r??"")&&e.endsWith(n??"")}function $a(e){let t=Ga(e);if(t)return t;let r=new Set,n=[e];for(;n.length>0;){let i=n.pop();if(!i)continue;let o;try{o=ni(i,{withFileTypes:!0})}catch{continue}for(let s of o){if(s.name.startsWith(".")&&!s.name.endsWith("proj")&&!s.name.endsWith("sln")&&s.isDirectory())continue;let a=oi(i,s.name);if(s.isDirectory()){si.has(s.name)||n.push(a);continue}let c=ii(s.name).toLowerCase();c&&r.add(c)}}return r}function Ga(e){try{let t=_a("git",["-C",e,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:26214400,stdio:["ignore","pipe","ignore"]}),r=new Set;for(let n of t.split(`
|
|
106
|
+
`)){if(!n||n.split("/").some(o=>si.has(o)))continue;let i=ii(n).toLowerCase();i&&r.add(i)}return r}catch{return null}}function Wa(e,t){return t?.length?t.some(r=>e.has(r)):!1}function ri(e,t){let r=e.indexOf(t);r!==-1&&e.splice(r,1)}import{readFileSync as Ba,writeFileSync as Va}from"fs";import{create as ai}from"@bufbuild/protobuf";import{deserializeSCIP as Ua,DocumentSchema as Ha,IndexSchema as za,serializeSCIP as qa,SymbolRole as Ja}from"@c4312/scip";function $f(e){let t;try{t=Ua(Ba(e))}catch{return{removedDefinitionOccurrences:0,touchedDocuments:0}}let r=hr(t);return r.removedDefinitionOccurrences>0&&Va(e,Buffer.from(qa(r.index))),{removedDefinitionOccurrences:r.removedDefinitionOccurrences,touchedDocuments:r.touchedDocuments}}function hr(e){let t=new Set;for(let o of e.documents)for(let s of o.symbols)s.symbol&&t.add(s.symbol);for(let o of e.externalSymbols)o.symbol&&t.add(o.symbol);let r=0,n=0,i=[];for(let o of e.documents){let s=o.occurrences.filter(a=>(a.symbolRoles&Ja.Definition)===0||t.has(a.symbol)?!0:(r+=1,!1));if(s.length===o.occurrences.length){i.push(o);continue}n+=1,i.push(ai(Ha,{language:o.language,relativePath:o.relativePath,occurrences:s,symbols:o.symbols,text:o.text,positionEncoding:o.positionEncoding}))}return{index:r===0?e:ai(za,{metadata:e.metadata,documents:i,externalSymbols:e.externalSymbols}),removedDefinitionOccurrences:r,touchedDocuments:n}}import{readFileSync as Sr,writeFileSync as xr}from"fs";import{create as Ge}from"@bufbuild/protobuf";import{deserializeSCIP as br,serializeSCIP as Ir,DocumentSchema as Xa,IndexSchema as ci,MetadataSchema as Ya,SymbolInformationSchema as Ka}from"@c4312/scip";function li(e){if(e.length===0)throw new Error("Cannot merge zero SCIP indexes");if(e.length===1)return e[0];let t=Za(e),r=ec(e.flatMap(i=>i.documents??[])),n=ui(e.flatMap(i=>i.externalSymbols??[]));return Ge(ci,{metadata:t,documents:r,externalSymbols:n})}function Hf(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let r=e.map(i=>br(Sr(i))),n=li(r);return xr(t,Buffer.from(Ir(n))),{documentCount:n.documents.length,externalSymbolCount:n.externalSymbols.length,inputCount:e.length}}function zf(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let r=e.map(i=>br(Sr(i))),n=hr(li(r));return xr(t,Buffer.from(Ir(n.index))),{documentCount:n.index.documents.length,externalSymbolCount:n.index.externalSymbols.length,inputCount:e.length,removedDefinitionOccurrences:n.removedDefinitionOccurrences,touchedDocuments:n.touchedDocuments}}function Qa(e,t,r){let n=e.metadata;if(!n)throw new Error("Cannot rebase a SCIP index without metadata");if(n.projectRoot!==t)throw new Error(`Cannot rebase SCIP project root: expected ${t}, got ${n.projectRoot}`);return Ge(ci,{metadata:Ge(Ya,{...n,projectRoot:r}),documents:e.documents,externalSymbols:e.externalSymbols})}function pi(e,t,r){let n=br(Sr(e)),i=Qa(n,t,r);xr(e,Buffer.from(Ir(i)))}function Za(e){let t=e[0]?.metadata;if(!t)return;let r=t.projectRoot;for(let n of e.slice(1)){let i=n.metadata?.projectRoot;if(r&&i&&i!==r)throw new Error(`Cannot merge SCIP indexes with different project roots: ${r} vs ${i}`)}return t}function ec(e){let t=new Map;for(let r of e){let n=t.get(r.relativePath);if(!n){t.set(r.relativePath,r);continue}t.set(r.relativePath,Ge(Xa,{language:n.language||r.language,relativePath:n.relativePath||r.relativePath,occurrences:tc([...n.occurrences,...r.occurrences]),symbols:ui([...n.symbols,...r.symbols]),text:nc(n.text,r.text),positionEncoding:n.positionEncoding||r.positionEncoding}))}return[...t.values()]}function tc(e){let t=new Set,r=[];for(let n of e){let i=JSON.stringify(n);t.has(i)||(t.add(i),r.push(n))}return r}function ui(e){let t=new Map;for(let r of e){let n=t.get(r.symbol);if(!n){t.set(r.symbol,r);continue}t.set(r.symbol,Ge(Ka,{symbol:n.symbol,documentation:ic([...n.documentation,...r.documentation]),relationships:rc([...n.relationships,...r.relationships]),kind:n.kind||r.kind,displayName:n.displayName||r.displayName,enclosingSymbol:n.enclosingSymbol||r.enclosingSymbol,signatureDocumentation:n.signatureDocumentation??r.signatureDocumentation}))}return[...t.values()]}function rc(e){let t=new Set,r=[];for(let n of e){let i=[n.symbol,n.isReference?"1":"0",n.isImplementation?"1":"0",n.isTypeDefinition?"1":"0",n.isDefinition?"1":"0"].join("|");t.has(i)||(t.add(i),r.push(n))}return r}function nc(e,t){return e?t?e.length>=t.length?e:t:e:t}function ic(e){return[...new Set(e)]}import{createHash as fc}from"crypto";import{existsSync as Be,mkdirSync as mc,readFileSync as Ue,readdirSync as Rr,renameSync as gc,rmSync as ki,writeFileSync as yc}from"fs";import{join as G}from"path";import{createHash as oc}from"crypto";import{existsSync as vr,mkdirSync as sc,readFileSync as St,readdirSync as Yf,renameSync as ac,rmSync as Kf,writeFileSync as cc}from"fs";import{join as Ne}from"path";import{create as fi,fromBinary as mi,toBinary as lc}from"@bufbuild/protobuf";import{deserializeSCIP as xt,DocumentSchema as Tr,IndexSchema as gi,serializeSCIP as yi}from"@c4312/scip";var bt=1,We="typescript-scip-fragments";function rm(e){if(e.length===0)throw new Error("affected TypeScript mini index requires documents");let t=new Set,r=[];for(let o of e){let s=pe(o.relativePath);if(t.has(s))throw new Error(`duplicate TypeScript fragment replacement: ${s}`);if(t.add(s),o.bytes===null)throw new Error(`affected TypeScript mini index cannot contain a deleted document: ${s}`);let a=mi(Tr,o.bytes);if(a.relativePath!==s)throw new Error(`TypeScript fragment path mismatch: expected ${s}, got ${a.relativePath}`);r.push(a)}let n=yi(fi(gi,{documents:r,externalSymbols:[]})),i=xt(n);if(i.documents.length!==r.length||i.externalSymbols.length!==0)throw new Error("affected TypeScript SCIP index failed structural verification");return n}function It(e){let t=Ne(e,We);return{rootDir:t,blobDir:Ne(t,"blobs"),generationDir:Ne(t,"generations")}}function pc(e){let t=xt(e.indexBytes);wi(t.metadata,Ri(e)),Ti(t.externalSymbols);let r=new Set,n=[];for(let o of t.documents){let s=pe(o.relativePath);if(r.has(s))throw new Error(`duplicate TypeScript SCIP document path: ${s}`);r.add(s);let a=lc(Tr,o),c=e.documentIdentities.get(s)??(e.allowUntrackedDocuments?ue(JSON.stringify({version:1,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,untrackedDocument:s,contentHash:ue(a)})):null);if(!c)throw new Error(`missing TypeScript document identity: ${s}`);n.push(bi(e.cacheDir,{relativePath:s,bytes:a,occurrences:o.occurrences.length,symbols:o.symbols.length,referenceFragments:[]},c))}let i=Ii(e,n);return Ei(e.cacheDir,i),i}function nm(e){let t=It(e.cacheDir);if(!vr(wr(t,e.generationIdentity)))return pc(e);let r=hi({cacheDir:e.cacheDir,generationIdentity:e.generationIdentity,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity});if(!e.allowUntrackedDocuments&&r.manifest.documents.length!==e.documentIdentities.size)throw new Error("TypeScript fragment generation document identities changed");for(let n of r.manifest.documents){let i=e.documentIdentities.get(n.relativePath);if(!(i===void 0&&e.allowUntrackedDocuments)&&i!==n.documentIdentity)throw new Error(`TypeScript fragment generation document identity changed: ${n.relativePath}`)}return r.manifest}function im(e){let t=hi({cacheDir:e.cacheDir,generationIdentity:e.previousGenerationIdentity,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity}).manifest,r=new Map(t.documents.map(o=>[o.relativePath,o])),n=new Set;for(let o of e.fragments){let s=pe(o.relativePath);if(n.has(s))throw new Error(`duplicate TypeScript fragment replacement: ${s}`);if(n.add(s),!r.has(s))throw new Error(`TypeScript fragment replacement has no prior document: ${s}`);let a=e.documentIdentities.get(s);if(!a)throw new Error(`missing TypeScript document identity: ${s}`);o.bytes===null?r.delete(s):r.set(s,bi(e.cacheDir,o,a))}if(n.size===0)throw new Error("TypeScript fragment generation requires at least one replacement");let i=Ii(e,[...r.values()]);return Ei(e.cacheDir,i),i}function hi(e){let t=It(e.cacheDir),r=wr(t,e.generationIdentity),n;try{n=vi(St(r,"utf8"))}catch(o){throw new Error(`TypeScript fragment generation is unavailable: ${o instanceof Error?o.message:String(o)}`,{cause:o})}if(n.generationIdentity!==e.generationIdentity)throw new Error("TypeScript fragment generation identity does not match its manifest path");if(e.producerIdentity&&n.producerIdentity!==e.producerIdentity)throw new Error("TypeScript fragment producer identity changed");if(e.projectIdentity&&n.projectIdentity!==e.projectIdentity)throw new Error("TypeScript fragment project identity changed");let i=new Map;for(let o of n.documents){let s=Ne(t.blobDir,`${o.blobHash}.scipdoc`),a=St(s);if(a.byteLength!==o.byteLength||ue(a)!==o.blobHash)throw new Error(`TypeScript fragment blob is corrupt: ${o.relativePath}`);i.set(o.relativePath,a)}return{manifest:n,fragments:i}}function Si(e){let t=xi(e);return Er(t.baseIndex,t.completeDocuments,"assembled")}function om(e){let t=xi(e);return uc(t.deletedAffectedPaths),{completeIndexBytes:Er(t.baseIndex,t.completeDocuments,"assembled"),affectedIndexBytes:Er(t.baseIndex,t.affectedDocuments,"affected")}}function xi(e){let t=xt(e.baseIndexBytes);wi(t.metadata,Ri(e)),Ti(t.externalSymbols);let r=new Map;for(let a of e.fragments){let c=pe(a.relativePath);if(r.has(c))throw new Error(`duplicate TypeScript fragment replacement: ${c}`);r.set(c,a)}if(r.size===0)throw new Error("TypeScript index assembly requires at least one replacement");let n=new Set,i=[],o=[],s=[];for(let a of t.documents){let c=pe(a.relativePath);if(n.has(c))throw new Error(`duplicate TypeScript SCIP document path: ${c}`);n.add(c);let l=r.get(c);if(!l){i.push(a);continue}if(r.delete(c),l.bytes===null){s.push(c);continue}let p=mi(Tr,l.bytes);if(p.relativePath!==c)throw new Error(`TypeScript fragment path mismatch: expected ${c}, got ${p.relativePath}`);i.push(p),o.push(p)}if(r.size>0)throw new Error(`TypeScript fragment replacement has no prior document: ${[...r.keys()].sort()[0]}`);return{baseIndex:t,completeDocuments:i,affectedDocuments:o,deletedAffectedPaths:s}}function Er(e,t,r){let n=yi(fi(gi,{metadata:e.metadata,documents:t,externalSymbols:[]})),i=xt(n);if(i.documents.length!==t.length||i.externalSymbols.length!==0)throw new Error(`${r} TypeScript SCIP index failed structural verification`);return n}function uc(e){if(e.length>0)throw new Error(`affected TypeScript mini index cannot contain a deleted document: ${e[0]}`)}function bi(e,t,r){if(t.bytes===null)throw new Error(`cannot persist an empty TypeScript fragment: ${t.relativePath}`);let n=pe(t.relativePath),i=Buffer.from(t.bytes),o=ue(i),s=It(e);sc(s.blobDir,{recursive:!0});let a=Ne(s.blobDir,`${o}.scipdoc`);if(vr(a)){let c=St(a);if(c.byteLength!==i.byteLength||ue(c)!==o)throw new Error(`existing TypeScript fragment blob is corrupt: ${n}`)}else{let c=`${a}.${process.pid}.${Date.now()}.tmp`;cc(c,i),ac(c,a)}return{relativePath:n,blobHash:o,byteLength:i.byteLength,documentIdentity:r}}function Ii(e,t){if(!e.producerIdentity||!e.projectIdentity||!e.generationIdentity)throw new Error("TypeScript fragment generation identities must be non-empty");let r=[...t].sort((n,i)=>n.relativePath.localeCompare(i.relativePath));if(new Set(r.map(n=>n.relativePath)).size!==r.length)throw new Error("TypeScript fragment generation contains duplicate document paths");return{version:bt,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,generationIdentity:e.generationIdentity,createdAt:(e.now??(()=>new Date))().toISOString(),documents:r}}function Ei(e,t){let r=It(e),n=wr(r,t.generationIdentity);if(vr(n)){let i=vi(St(n,"utf8"));if(di(i)!==di(t))throw new Error(`TypeScript fragment generation is immutable: ${t.generationIdentity}`);return}$(n,t,{spacing:2,trailingNewline:!0})}function di(e){return ue(JSON.stringify({version:e.version,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,generationIdentity:e.generationIdentity,documents:e.documents}))}function vi(e){let t=JSON.parse(e);if(t.version!==bt||typeof t.producerIdentity!="string"||typeof t.projectIdentity!="string"||typeof t.generationIdentity!="string"||typeof t.createdAt!="string"||!Number.isFinite(Date.parse(t.createdAt))||!Array.isArray(t.documents))throw new Error("invalid TypeScript fragment generation manifest");let r=new Set;for(let n of t.documents){if(!n||typeof n.relativePath!="string"||typeof n.blobHash!="string"||!/^[a-f0-9]{64}$/.test(n.blobHash)||typeof n.byteLength!="number"||!Number.isInteger(n.byteLength)||n.byteLength<0||typeof n.documentIdentity!="string"||!n.documentIdentity)throw new Error("invalid TypeScript fragment record");if(pe(n.relativePath),r.has(n.relativePath))throw new Error("duplicate TypeScript fragment record");r.add(n.relativePath)}return t}function wr(e,t){return Ne(e.generationDir,dc(t))}function dc(e){if(!e)throw new Error("TypeScript fragment generation identity must be non-empty");return`${ue(e)}.json`}function Ti(e){if(e.length>0)throw new Error("scip-typescript emitted external symbols; incremental document assembly is unsupported")}function wi(e,t){if(!e||typeof e!="object")throw new Error("TypeScript SCIP shard has no producer metadata");let r=e,n=r.toolInfo??r.tool_info;if(!n||typeof n!="object")throw new Error("TypeScript SCIP shard has no producer tool identity");let i=n;if(i.name!=="scip-typescript"||i.version!==t)throw new Error("TypeScript SCIP shard producer identity changed")}function Ri(e){let t=e.packageVersion??e.runtime?.packageVersion;if(!t)throw new Error("scip-typescript package version is unavailable");return t}function pe(e){if(!e||e.startsWith("/")||e.startsWith("\\")||e.includes("\\"))throw new Error(`invalid TypeScript SCIP document path: ${e}`);let t=e.split("/");if(t.includes("")||t.includes(".")||t.includes(".."))throw new Error(`invalid TypeScript SCIP document path: ${e}`);return e}function ue(e){return oc("sha256").update(e).digest("hex")}var Et=1,dm=64*1024*1024,He="typescript-scip-overlays";function fm(e){let t=Ni(e.cacheDir,e.previousGenerationIdentity);if(!t&&!e.baseShardCurrent)throw new Error("deferred TypeScript SCIP base has no matching overlay generation");if(t&&(t.producerIdentity!==e.producerIdentity||t.projectIdentity!==e.projectIdentity))throw new Error("TypeScript overlay producer or project identity changed");let r=new Map((t?.overlays??[]).map(o=>[o.relativePath,o])),n=new Set;for(let o of e.fragments){let s=Nr(o.relativePath);if(n.has(s))throw new Error(`duplicate TypeScript overlay: ${s}`);n.add(s),r.set(s,hc(e.cacheDir,o))}if(n.size===0)throw new Error("TypeScript overlay generation requires affected documents");let i={version:Et,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,baseGenerationIdentity:t?.baseGenerationIdentity??e.previousGenerationIdentity,generationIdentity:e.nextGenerationIdentity,createdAt:(e.now??(()=>new Date))().toISOString(),overlays:[...r.values()].sort((o,s)=>o.relativePath.localeCompare(s.relativePath))};return Sc(e.cacheDir,i),i}function mm(e){let t=Ni(e.cacheDir,e.generationIdentity);if(!t)throw new Error("TypeScript overlay generation is unavailable");let r=t.overlays.map(n=>{if(n.blobHash===null)return{relativePath:n.relativePath,bytes:null,occurrences:0,symbols:0,referenceFragments:[]};let i=Ue(G(ze(e.cacheDir),"blobs",`${n.blobHash}.scipdoc`));if(i.byteLength!==n.byteLength||Ve(i)!==n.blobHash)throw new Error(`TypeScript overlay blob is corrupt: ${n.relativePath}`);return{relativePath:n.relativePath,bytes:i,occurrences:0,symbols:0,referenceFragments:[]}});return Si({packageVersion:e.packageVersion,baseIndexBytes:e.baseIndexBytes,fragments:r})}function gm(e,t){let r=ze(e),n=G(r,"generations");if(!Be(n))return;let i=new Set(t.map(Cr)),o=new Set;for(let a of Rr(n).filter(c=>i.has(c))){let c=kr(Ue(G(n,a),"utf8"));for(let l of c.overlays)l.blobHash&&o.add(`${l.blobHash}.scipdoc`)}for(let a of Rr(n))i.has(a)||ki(G(n,a),{force:!0});let s=G(r,"blobs");if(Be(s))for(let a of Rr(s))o.has(a)||ki(G(s,a),{force:!0})}function Ni(e,t){let r=G(ze(e),"generations",Cr(t));if(!Be(r))return null;let n=kr(Ue(r,"utf8"));if(n.generationIdentity!==t)throw new Error("TypeScript overlay generation identity does not match its path");return n}function hc(e,t){let r=Nr(t.relativePath);if(t.bytes===null)return{relativePath:r,blobHash:null,byteLength:0};let n=Buffer.from(t.bytes),i=Ve(n),o=G(ze(e),"blobs");mc(o,{recursive:!0});let s=G(o,`${i}.scipdoc`);if(Be(s)){let a=Ue(s);if(a.byteLength!==n.byteLength||Ve(a)!==i)throw new Error(`existing TypeScript overlay blob is corrupt: ${r}`)}else{let a=`${s}.${process.pid}.${Date.now()}.tmp`;yc(a,n),gc(a,s)}return{relativePath:r,blobHash:i,byteLength:n.byteLength}}function Sc(e,t){let r=G(ze(e),"generations",Cr(t.generationIdentity));if(Be(r)){let n=kr(Ue(r,"utf8"));if(Ci(n)!==Ci(t))throw new Error(`TypeScript overlay generation is immutable: ${t.generationIdentity}`);return}$(r,t,{spacing:2,trailingNewline:!0})}function kr(e){let t=JSON.parse(e);if(t.version!==Et||typeof t.producerIdentity!="string"||!t.producerIdentity||typeof t.projectIdentity!="string"||!t.projectIdentity||typeof t.baseGenerationIdentity!="string"||!t.baseGenerationIdentity||typeof t.generationIdentity!="string"||!t.generationIdentity||typeof t.createdAt!="string"||!Number.isFinite(Date.parse(t.createdAt))||!Array.isArray(t.overlays))throw new Error("invalid TypeScript overlay manifest");let r=new Set;for(let n of t.overlays){if(!n||typeof n.relativePath!="string"||n.blobHash!==null&&(typeof n.blobHash!="string"||!/^[a-f0-9]{64}$/.test(n.blobHash))||!Number.isInteger(n.byteLength)||n.byteLength<0||n.blobHash===null&&n.byteLength!==0)throw new Error("invalid TypeScript overlay record");if(Nr(n.relativePath),r.has(n.relativePath))throw new Error("duplicate TypeScript overlay record");r.add(n.relativePath)}return t}function ze(e){return G(e,He)}function Cr(e){if(!e)throw new Error("TypeScript overlay generation identity must be non-empty");return`${Ve(e)}.json`}function Ci(e){return Ve(JSON.stringify({version:e.version,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,baseGenerationIdentity:e.baseGenerationIdentity,generationIdentity:e.generationIdentity,overlays:e.overlays}))}function Nr(e){if(!e||e.startsWith("/")||e.includes("\\")||e.split("/").some(t=>!t||t==="."))throw new Error(`invalid TypeScript overlay path: ${e}`);if(e.split("/").includes(".."))throw new Error(`invalid TypeScript overlay path: ${e}`);return e}function Ve(e){return fc("sha256").update(e).digest("hex")}import{createHash as xc}from"crypto";import{copyFileSync as Pi,existsSync as Q,linkSync as bc,mkdirSync as Di,readFileSync as Fi,readdirSync as _i,renameSync as Dr,rmSync as Tt,statSync as Ic}from"fs";import{basename as vt,dirname as qe,join as E,relative as Ai}from"path";var Pe=1,wt=".scipquery-generations";function Oi(e){let t=Rt(e.outputDb),r=Ec(e,t);e.onStage?.("after-recovery-retained"),e.preserveOutputScip||Pr(e.tempOutputScip,e.outputScip),e.onStage?.("after-scip-handoff"),Pr(e.tempOutputDb,e.outputDb),e.onStage?.("after-database-handoff"),Pr(e.tempMetaPath,e.metaPath),e.onStage?.("after-metadata-handoff");let n=kt(e.metaPath,e.outputDb),i={version:Pe,currentGeneration:n,...r?{previousGeneration:r}:{},...e.publication?{publication:e.publication}:{},publishedAt:(e.now??(()=>new Date))().toISOString()};return $(E(t,"state.json"),i,{spacing:2,trailingNewline:!0}),{currentGeneration:n,...r?{previousGeneration:r}:{}}}function Li(e){try{let t=JSON.parse(Fi(E(Rt(e),"state.json"),"utf8"));return t.version!==Pe||typeof t.currentGeneration!="string"||!t.currentGeneration||typeof t.publishedAt!="string"||!Number.isFinite(Date.parse(t.publishedAt))||!wc(t.previousGeneration)||!Rc(t.publication)?null:t}catch{return null}}function Im(e,t,r=()=>new Date){if(!Q(e)||!Q(t))throw new Error("metadata-only generation refresh requires stable database and metadata files");let n=Li(e),i={version:Pe,currentGeneration:kt(t,e),...n?.previousGeneration?{previousGeneration:n.previousGeneration}:{},...n?.publication?{publication:n.publication}:{},publishedAt:r().toISOString()};return $(E(Rt(e),"state.json"),i,{spacing:2,trailingNewline:!0}),i}function _r(e,t=E(qe(e),"meta.json")){let r=E(Rt(e),"state.json");if(!Q(r))return{state:"legacy",statePath:r};let n=Li(e);if(!n)return{state:"invalid",statePath:r,reason:"generation state is malformed"};try{let i=kt(t,e),o=n.currentGeneration===i,s=n.previousGeneration?Q(E(qe(e),n.previousGeneration.databasePath)):!0;return!o||!s?{state:"drifted",statePath:r,currentMatches:o,recoveryExists:s,generation:n,reason:o?"retained recovery database is missing":"stable database or metadata no longer matches the published generation"}:{state:"current",statePath:r,currentMatches:o,recoveryExists:s,generation:n}}catch(i){return{state:"drifted",statePath:r,currentMatches:!1,recoveryExists:!1,generation:n,reason:i instanceof Error?i.message:String(i)}}}function Rt(e){return E(qe(e),wt)}function Ec(e,t){if(!Q(e.outputDb))return;let r=kt(e.metaPath,e.outputDb),n=E(t,r),i=E(n,vt(e.outputDb)),o=Q(e.metaPath)?E(n,vt(e.metaPath)):void 0;if(!Q(i)){let s=`${n}.${process.pid}.${Date.now()}.tmp`;Tt(s,{recursive:!0,force:!0}),Di(s,{recursive:!0});let a=E(s,vt(e.outputDb));try{bc(e.outputDb,a)}catch{Pi(e.outputDb,a)}o&&Pi(e.metaPath,E(s,vt(e.metaPath))),Di(t,{recursive:!0}),Dr(s,n)}return vc(t,r),{generationIdentity:r,databasePath:Ai(qe(e.outputDb),i),...o?{metadataPath:Ai(qe(e.outputDb),o)}:{}}}function vc(e,t){for(let r of _i(e,{withFileTypes:!0}))!r.isDirectory()||r.name===t||r.name.endsWith(".tmp")||Tt(E(e,r.name),{recursive:!0,force:!0});for(let r of _i(e,{withFileTypes:!0}))r.isDirectory()&&r.name.endsWith(".tmp")&&Tt(E(e,r.name),{recursive:!0,force:!0})}function kt(e,t){let r=xc("sha256").update(`sqlite-generation-v${Pe}\0`);Q(e)&&r.update(Tc(Fi(e,"utf8")));let n=Ic(t);return r.update(`\0${n.size}`),r.digest("hex")}function Tc(e){try{let t=JSON.parse(e);if((t.version===2||t.version===3)&&t.status==="complete"&&typeof t.updatedAt=="string"&&t.fingerprint!==void 0)return JSON.stringify({version:t.version,status:t.status,updatedAt:t.updatedAt,fingerprint:t.fingerprint,indexedLanguages:t.indexedLanguages,scipCompanion:t.scipCompanion})}catch{}return e}function Pr(e,t){Tt(`${t}.tmp-replace`,{force:!0}),Dr(e,`${t}.tmp-replace`),Dr(`${t}.tmp-replace`,t)}function wc(e){if(e===void 0)return!0;if(!e||typeof e!="object")return!1;let t=e;return typeof t.generationIdentity=="string"&&!!t.generationIdentity&&typeof t.databasePath=="string"&&!!t.databasePath&&(t.metadataPath===void 0||typeof t.metadataPath=="string"&&!!t.metadataPath)}function Rc(e){if(e===void 0)return!0;if(!e||typeof e!="object")return!1;let t=e,r=[t.converterDurationMs,t.affectedDocumentCount,t.changedDocumentCount,t.producerDurationMs,t.materializationDurationMs,t.patchDurationMs].filter(n=>n!==void 0);return(t.mode==="incremental"||t.mode==="full")&&t.validation==="passed"&&t.converterDurationMs!==void 0&&r.every(n=>typeof n=="number"&&Number.isFinite(n)&&n>=0)&&(t.scipCompanion===void 0||t.scipCompanion==="current"||t.scipCompanion==="deferred")&&(t.typescriptOverlayGeneration===void 0||typeof t.typescriptOverlayGeneration=="string"&&!!t.typescriptOverlayGeneration)&&(t.scipCompanion!=="deferred"||!!t.typescriptOverlayGeneration)&&(t.fallbackReason===void 0||typeof t.fallbackReason=="string")}import{createHash as Hi,randomUUID as jr}from"crypto";import{closeSync as zi,constants as Lc,copyFileSync as Wi,existsSync as ee,lstatSync as jc,mkdirSync as H,mkdtempSync as qi,openSync as Ji,readdirSync as Mc,readFileSync as W,realpathSync as $c,renameSync as de,rmSync as Z,statSync as Gc,unlinkSync as Or,writeFileSync as Xi}from"fs";import{dirname as Yi,join as f,resolve as Ke}from"path";import{setTimeout as Wc}from"timers/promises";import{pathToFileURL as Bi}from"url";import{deserializeSCIP as Ki}from"@c4312/scip";import Bc from"better-sqlite3";import{createRequire as kc}from"module";var Cc=kc(import.meta.url),ji=Nc().version;function Nc(){for(let e of["../package.json","../../package.json"])try{return Cc(e)}catch{}return{version:"0.0.0"}}import{lstatSync as Pc,readdirSync as Dc}from"fs";import{join as _c,relative as Ac,resolve as Ar,sep as Fc}from"path";var Je=1,Fr="language-indexes",Mi=["index.db","index.scip","meta.json"],$i=[Fr,We,He];function Ct(e){let t=[];for(let r of Mi)Oc(e,r),t.push(r);for(let r of $i)Gi(e,r,t);return{version:Je,files:t.sort()}}function Nt(e){if(!e||e.includes("\0")||e.startsWith("/")||e.includes("\\"))throw new Error(`invalid index artifact path: ${e||"<empty>"}`);let t=e.split("/");if(t.some(n=>!n||n==="."||n===".."))throw new Error(`invalid index artifact path: ${e}`);let r=t[0];if(!Mi.includes(e)&&!$i.includes(r))throw new Error(`index artifact path is not shareable: ${e}`);return e}function V(e,t){let r=Nt(t),n=Ar(e),i=Ar(n,...r.split("/"));if(i!==n&&!i.startsWith(`${n}${Fc}`))throw new Error(`index artifact escapes cache: ${t}`);return i}function Gi(e,t,r){let n=_c(e,t),i;try{i=Dc(n,{withFileTypes:!0,encoding:"utf8"})}catch{return}for(let o of i){let s=`${t}/${o.name}`;if(o.isSymbolicLink())throw new Error(`index artifact cannot be a symlink: ${s}`);o.isDirectory()?Gi(e,s,r):o.isFile()&&r.push(Nt(s))}}function Oc(e,t){let r=V(e,t),n;try{n=Pc(r)}catch{throw new Error(`required index artifact is missing: ${t}`)}if(!n.isFile()||n.isSymbolicLink())throw new Error(`required index artifact is not a regular file: ${t}`);if(Ac(Ar(e),r).startsWith(".."))throw new Error(`index artifact escapes cache: ${t}`)}var Mr=1,Vi="SCIP_QUERY_SHARED_CACHE",Lr=JSON.stringify({cliVersion:ji,artifactCatalogVersion:Je,sqliteGenerationStoreVersion:Pe,typescriptFragmentStoreVersion:bt,typescriptOverlayStoreVersion:Et}),Qi="manifest.json",Vc="shared-cache.json",$r=[Fr,We,He];function Jm(e,t){if(!e.clean||!e.treeOid)return;let r=Ze(JSON.stringify({version:Mr,repositoryId:e.repositoryId,treeOid:e.treeOid,fingerprint:t,producerIdentity:Lr}));return{repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,fingerprint:t,producerIdentity:Lr,generationId:r,repositoryCacheDir:ar(e.repositoryId)}}function Xm(e,t,r){if(process.env[Vi]==="0")return`${Vi}=0`;if(!cr(r))return"explicit cache or database override";if(Ke(t)!==Ke(f(sr(e),"index.db")))return"index database is outside the managed worktree cache"}function Ym(e,t,r){if(!cr(t))return;let n=r??jn(e);return n?f(ar(n.repositoryId),"evidence.db"):void 0}function Ye(e,t=!0){let r=Gr(e),n;try{n=zc(W(f(r,Qi),"utf8"))}catch{return null}if(n.generationId!==e.generationId||n.repositoryId!==e.repositoryId||n.treeOid!==e.treeOid||n.producerIdentity!==e.producerIdentity||JSON.stringify(n.fingerprint)!==JSON.stringify(e.fingerprint))return null;if(!t)return n;try{for(let i of n.artifacts){let o=V(r,i.path),s=Gc(o);if(!s.isFile()||s.size!==i.size||Ze(W(o))!==i.sha256)return null}}catch{return null}return n}function Km(e){let t=Ye(e.snapshot);if(t)return t;if(!to(e.sourceCacheDir,e.sourceProjectRoot,e.snapshot.fingerprint))throw new Error("source index is incomplete, incompatible, or corrupt");let r=Ui(e.sourceCacheDir);if(!r)throw new Error("source index artifacts are incomplete");let n=Ct(e.sourceCacheDir),i=f(e.snapshot.repositoryCacheDir,"generations");H(i,{recursive:!0});let o=qi(f(i,`.tmp-${process.pid}-`));try{let s=[];for(let u of n.files){let d=V(e.sourceCacheDir,u),m=V(o,u);Qe(d,m);let y=W(m);s.push({path:u,size:y.byteLength,sha256:Ze(y)})}let a=Ki(W(f(o,"index.scip"))).metadata?.projectRoot;if(!a)throw new Error("shared SCIP generation has no project root metadata");let c=Wr(e.sourceProjectRoot);if(a!==c)throw new Error("shared SCIP generation root does not match its source worktree");if(Ui(e.sourceCacheDir)!==r||e.sourceStillValid&&!e.sourceStillValid())throw new Error("source index changed while staging a shared generation");let l={version:Mr,artifactCatalogVersion:Je,generationId:e.snapshot.generationId,repositoryId:e.snapshot.repositoryId,treeOid:e.snapshot.treeOid,fingerprint:e.snapshot.fingerprint,producerIdentity:e.snapshot.producerIdentity,sourceProjectRoot:e.sourceProjectRoot,scipProjectRoot:a,createdAt:(e.now??(()=>new Date))().toISOString(),artifacts:s.sort((u,d)=>u.path.localeCompare(d.path))};$(f(o,Qi),l,{spacing:2,trailingNewline:!0});let p=Gr(e.snapshot);try{if(ee(p)&&!Ye(e.snapshot)){let u=`${p}.corrupt-${process.pid}-${Date.now()}`;de(p,u),Z(u,{recursive:!0,force:!0})}de(o,p)}catch(u){let d=Ye(e.snapshot);if(d)return d;throw u}return l}finally{Z(o,{recursive:!0,force:!0})}}function Qm(e){let t=Gr(e.snapshot);H(e.targetCacheDir,{recursive:!0});let r=ur(f(e.targetCacheDir,"cache-lifecycle.lock"),{waitMs:3e4});if(!r)throw new Error("timed out waiting for another cache hydration");let n,i,o=!1;try{n=qi(f(e.targetCacheDir,".shared-hydrate-")),el(e.manifest,e.snapshot);for(let c of e.manifest.artifacts){let l=V(t,c.path),p=V(n,c.path);Qe(l,p);let u=W(p);if(u.byteLength!==c.size||Ze(u)!==c.sha256)throw new Error(`shared artifact is corrupt: ${c.path}`)}let s=Wr(e.targetProjectRoot);if(s!==e.manifest.scipProjectRoot)for(let c of e.manifest.artifacts)c.path.endsWith(".scip")&&pi(V(n,c.path),e.manifest.scipProjectRoot,s);if(!to(n,e.targetProjectRoot,e.snapshot.fingerprint,!1))throw new Error("staged shared generation failed completeness or integrity validation");i=Kc(e.targetCacheDir,n),o=!0,Qc(n,e.targetCacheDir,i),Oi({tempOutputScip:f(n,"index.scip"),tempOutputDb:f(n,"index.db"),tempMetaPath:f(n,"meta.json"),outputScip:f(e.targetCacheDir,"index.scip"),outputDb:f(e.targetCacheDir,"index.db"),metaPath:f(e.targetCacheDir,"meta.json"),now:e.now});let a=_r(f(e.targetCacheDir,"index.db"),f(e.targetCacheDir,"meta.json"));if(a.state==="invalid"||a.state==="drifted")throw new Error(`hydrated SQLite generation failed validation: ${a.reason}`);Uc(e.snapshot,e.targetCacheDir,e.action??"attached",e.now)}catch(s){throw o&&i&&Zc(e.targetCacheDir,i),s}finally{n&&Z(n,{recursive:!0,force:!0}),r.release()}}async function Zm(e,t={}){let r=t.timeoutMs??3e4,n=t.pollMs??100,i=t.now??Date.now,o=i()+r,s=f(e.repositoryCacheDir,"locks"),a=f(s,`${e.generationId}.lock`);for(H(s,{recursive:!0});i()<=o;){if(Ye(e))return{kind:"generation-ready"};let c=jr();try{let l=Ji(a,"wx");try{Xi(l,`${JSON.stringify({version:1,pid:process.pid,token:c,generationId:e.generationId,startedAt:new Date(i()).toISOString()})}
|
|
107
|
+
`)}finally{zi(l)}return{kind:"owner",release:()=>{try{let p=JSON.parse(W(a,"utf8"));p.pid===process.pid&&p.token===c&&Or(a)}catch{}}}}catch(l){if(l.code!=="EEXIST")return{kind:"timeout"};let p=Zi(a);if(p&&(p.pid===void 0||!we(p.pid))){Xc(a,p);continue}await Wc(n)}}return Ye(e)?{kind:"generation-ready"}:{kind:"timeout"}}function Uc(e,t,r,n=void 0){let i={version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,localCacheDir:t,baseGenerationId:e.generationId,activeGenerationId:e.generationId,lastAction:r,lastSeenAt:(n??(()=>new Date))().toISOString()},o={...i,ownershipChecksum:Hc(i)};return Yc(e.repositoryCacheDir,o,!0),o}function Hc(e){return Ze(JSON.stringify({version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:Ke(e.projectRoot),localCacheDir:Ke(e.localCacheDir)}))}function zc(e){let t=JSON.parse(e);if(t.version!==Mr||t.artifactCatalogVersion!==Je||typeof t.generationId!="string"||!/^[a-f0-9]{64}$/.test(t.generationId)||typeof t.repositoryId!="string"||!/^[a-f0-9]{24}$/.test(t.repositoryId)||typeof t.treeOid!="string"||!t.treeOid||typeof t.producerIdentity!="string"||t.producerIdentity!==Lr||typeof t.sourceProjectRoot!="string"||typeof t.scipProjectRoot!="string"||typeof t.createdAt!="string"||!Number.isFinite(Date.parse(t.createdAt))||!t.fingerprint||!Array.isArray(t.artifacts))throw new Error("invalid shared generation manifest");let r=new Set;for(let n of t.artifacts){if(!n||typeof n.path!="string"||typeof n.size!="number"||n.size<0||typeof n.sha256!="string"||!/^[a-f0-9]{64}$/.test(n.sha256))throw new Error("invalid shared generation artifact");if(Nt(n.path),r.has(n.path))throw new Error(`duplicate shared generation artifact: ${n.path}`);r.add(n.path)}for(let n of["index.db","index.scip","meta.json"])if(!r.has(n))throw new Error(`shared generation is missing ${n}`);return t}function Qe(e,t){H(Yi(t),{recursive:!0});try{Wi(e,t,Lc.COPYFILE_FICLONE)}catch{Wi(e,t)}}function qc(e,t,r){H(e,{recursive:!0}),$(f(e,Vc),{version:1,repositoryId:t,worktreeId:r},{spacing:2,trailingNewline:!0})}function Ui(e){try{let t=Ct(e),r=Hi("sha256");for(let n of t.files){let i=W(V(e,n));r.update(n).update("\0").update(String(i.byteLength)).update("\0").update(i).update("\0")}return r.digest("hex")}catch{return null}}function Jc(e){try{return JSON.parse(W(f(e,"meta.json"),"utf8"))}catch{return}}function Gr(e){return f(e.repositoryCacheDir,"generations",e.generationId)}function Zi(e){try{let t=W(e,"utf8"),r=JSON.parse(t),n=typeof r.pid=="number"&&Number.isSafeInteger(r.pid)&&r.pid>0?r.pid:void 0;return{raw:t,...n===void 0?{}:{pid:n}}}catch{return null}}function Xc(e,t){let r=`${e}.reclaim`,n=jr(),i;try{i=Ji(r,"wx")}catch{return!1}try{Xi(i,`${JSON.stringify({version:1,pid:process.pid,token:n,startedAt:new Date().toISOString()})}
|
|
108
|
+
`)}finally{zi(i)}try{let o=Zi(e);return!o||o.raw!==t.raw||o.pid!==void 0&&we(o.pid)?!1:(Or(e),!0)}catch{return!1}finally{try{let o=JSON.parse(W(r,"utf8"));o.pid===process.pid&&o.token===n&&Or(r)}catch{}}}function Yc(e,t,r){let n=Hn(e,{waitMs:5e3});if(!n)throw new Error("repository cache cleanup is busy");try{if(r){let o=t.activeGenerationId;if(!o||!ee(f(e,"generations",o)))throw new Error("shared generation disappeared before its lease was attached")}let i=f(e,"worktrees");H(i,{recursive:!0}),$(f(i,`${t.worktreeId}.json`),t,{spacing:2,trailingNewline:!0}),qc(t.localCacheDir,t.repositoryId,t.worktreeId)}finally{n.release()}}function Kc(e,t){let r=f(t,".rollback"),n=new Map,i=new Map;H(r,{recursive:!0});for(let a of["index.scip","index.db","meta.json"]){let c=f(e,a),l=ee(c);n.set(a,l),l&&Qe(c,f(r,"stable",a))}for(let a of $r){let c=f(e,a),l=ee(c);if(l){let p=jc(c);if(!p.isDirectory()||p.isSymbolicLink())throw new Error(`managed artifact path is not a directory: ${a}`)}i.set(a,l)}let o=f(e,wt),s=ee(o);return s&&eo(o,f(r,"sqlite-generations")),{root:r,stableFiles:n,managedDirectories:i,generationStoreExisted:s}}function Qc(e,t,r){for(let n of $r){let i=f(t,n);if(r.managedDirectories.get(n)){let s=f(r.root,"managed",n);H(Yi(s),{recursive:!0}),de(i,s)}let o=f(e,n);ee(o)&&de(o,i)}}function Zc(e,t){for(let i of $r){let o=f(e,i),s=f(t.root,"managed",i);t.managedDirectories.get(i)?ee(s)&&(Z(o,{recursive:!0,force:!0}),de(s,o)):Z(o,{recursive:!0,force:!0})}for(let[i,o]of t.stableFiles){let s=f(e,i);if(!o){Z(s,{force:!0});continue}let a=`${s}.shared-restore-${jr()}`;Qe(f(t.root,"stable",i),a),Z(s,{force:!0}),de(a,s)}let r=f(e,wt);Z(r,{recursive:!0,force:!0});let n=f(t.root,"sqlite-generations");t.generationStoreExisted&&ee(n)&&de(n,r)}function eo(e,t){H(t,{recursive:!0});for(let r of Mc(e,{withFileTypes:!0})){let n=f(e,r.name),i=f(t,r.name);if(r.isSymbolicLink())throw new Error(`managed cache backup cannot contain a symlink: ${n}`);r.isDirectory()?eo(n,i):r.isFile()&&Qe(n,i)}}function el(e,t){if(e.generationId!==t.generationId||e.repositoryId!==t.repositoryId||e.treeOid!==t.treeOid||e.producerIdentity!==t.producerIdentity||JSON.stringify(e.fingerprint)!==JSON.stringify(t.fingerprint))throw new Error("shared generation manifest does not match the requested snapshot")}function to(e,t,r,n=!0,i=!0){try{let o=Jc(e);if(o?.status!=="complete"||JSON.stringify(o.fingerprint)!==JSON.stringify(r)||JSON.stringify([...o.indexedLanguages??[]].sort())!==JSON.stringify([...r.languages].sort()))return Xe("source validation rejected metadata"),!1;let s=Ct(e),a=_r(f(e,"index.db"),f(e,"meta.json"));if(n?a.state!=="current":a.state==="invalid"||a.state==="drifted")return Xe(`source validation rejected SQLite generation state ${a.state}`),!1;let c=new Bc(f(e,"index.db"),{readonly:!0,fileMustExist:!0});try{if(i){if(c.pragma("quick_check(1)",{simple:!0})!=="ok")return!1}else c.pragma("schema_version",{simple:!0})}finally{c.close()}let l=Wr(t),u=(i?s.files.filter(d=>d.endsWith(".scip")):["index.scip"]).every(d=>{let m=Ki(W(V(e,d))).metadata?.projectRoot;return m!==l&&Xe(`source validation rejected SCIP root for ${d}: ${String(m)}`),m===l});return u||Xe("source validation rejected SCIP project roots"),u}catch(o){return Xe(`source validation failed: ${o instanceof Error?o.message:String(o)}`),!1}}function Xe(e){process.env.SCIP_QUERY_DEBUG&&console.error(`shared-cache: ${e}`)}function Wr(e){try{return Bi($c(e)).href}catch{return Bi(Ke(e)).href}}function Ze(e){return Hi("sha256").update(e).digest("hex")}import{readFileSync as ro}from"fs";import{createRequire as tl}from"module";import{dirname as Hr,isAbsolute as rl,relative as so,resolve as re,sep as Br}from"path";var te=tl(import.meta.url),nl=1,no="0.4.0";function il(){try{let e=ao();if(!e.available)return e;let{packageRoot:t}=e,r=te.resolve("typescript",{paths:[t]}),n=te(r),{FileIndexer:i}=te(re(t,"dist/src/FileIndexer.js")),{Input:o}=te(re(t,"dist/src/Input.js")),{Packages:s}=te(re(t,"dist/src/Packages.js")),a=te(re(t,"dist/src/scip.js"));if(!i||!o||!s||!a.scip?.Document||!a.scip.Index)return{available:!1,reason:"scip-typescript document runtime has an unsupported module shape"};let c={packageVersion:e.packageVersion,typescript:n,Document:a.scip.Document,Index:a.scip.Index,FileIndexer:i,Input:o,Packages:s};return{available:!0,runtime:c,producerIdentity:zr(c)}}catch(e){return{available:!1,reason:`scip-typescript document runtime unavailable: ${e instanceof Error?e.message:String(e)}`}}}function ig(){let e=ao();return e.available?{available:!0,packageVersion:e.packageVersion,typescriptVersion:e.typescriptVersion,producerIdentity:e.producerIdentity}:e}function ao(){try{let e=te.resolve("@sourcegraph/scip-typescript/package.json"),t=JSON.parse(ro(e,"utf8"));if(t.version!==no)return{available:!1,reason:`unsupported scip-typescript version ${String(t.version??"unknown")}; expected ${no}`};let r=Hr(e),n=te.resolve("typescript/package.json",{paths:[r]}),i=JSON.parse(ro(n,"utf8"));return typeof i.version!="string"||!i.version?{available:!1,reason:"scip-typescript TypeScript compiler version is unavailable"}:{available:!0,packageRoot:r,packageVersion:t.version,typescriptVersion:i.version,producerIdentity:co(t.version,i.version)}}catch(e){return{available:!1,reason:`scip-typescript document producer unavailable: ${e instanceof Error?e.message:String(e)}`}}}function og(e){let t=e.runtime===void 0?il():e.runtime===null?{available:!1,reason:"scip-typescript document runtime unavailable"}:{available:!0,runtime:e.runtime,producerIdentity:zr(e.runtime)};return t.available?{available:!0,emitter:new Vr(e,t.runtime)}:t}var Vr=class{producerIdentity;workspaceRoot;tsconfigPath;projectRoot;maxFileByteSize;runtime;host;config=null;includedFiles=new Set;program=null;checker=null;symbolTable=new Map;constructorTable=new Map;packages;fragments=new Map;stats={initializations:0,programUpdates:0,documentsEmitted:0,documentsRemoved:0,sourceNodesReused:0,sourceNodesReplaced:0,symbolEntriesPruned:0};constructor(t,r){this.workspaceRoot=re(t.workspaceRoot),this.tsconfigPath=re(this.workspaceRoot,t.tsconfigPath),this.projectRoot=t.projectRoot??sl(this.workspaceRoot,Hr(this.tsconfigPath)),this.maxFileByteSize=t.maxFileByteSize??1024*1024,this.runtime=r,this.producerIdentity=zr(r);let n=io(r.typescript,this.tsconfigPath);this.config=n,this.host=new Ur(r.typescript,n.options,this.workspaceRoot),this.packages=new r.Packages(this.projectRoot)}initialize(){let t=performance.now(),r=this.config??io(this.runtime.typescript,this.tsconfigPath);this.includedFiles=new Set(r.fileNames.map(De)),this.program=this.runtime.typescript.createProgram(r.fileNames,r.options,this.host.compilerHost),this.checker=this.program.getTypeChecker(),this.stats.initializations+=1;let n=[];for(let i of this.program.getSourceFiles())this.includedFiles.has(De(i.fileName))&&n.push(this.emitSourceFile(i));return this.result(n,t)}advance(t){if(!this.program||!this.checker||!this.config)return this.initializeAndAdvance(t);let r=performance.now(),n=Pt(t.modifiedFiles),i=Pt(t.affectedFiles);this.validateIncrementalPaths(n,i);let o=this.program,s=new Map;for(let c of n){let l=et(this.workspaceRoot,c),p=o.getSourceFile(l);if(!p)throw new Error(`modified TypeScript source is unavailable: ${c}`);s.set(c,p),this.stats.symbolEntriesPruned+=oo(this.symbolTable,p),this.stats.symbolEntriesPruned+=oo(this.constructorTable,p),this.host.invalidate(l)}this.program=this.runtime.typescript.createProgram(this.config.fileNames,this.config.options,this.host.compilerHost,o),this.checker=this.program.getTypeChecker(),this.stats.programUpdates+=1;for(let[c,l]of s)this.program.getSourceFile(et(this.workspaceRoot,c))===l?this.stats.sourceNodesReused+=1:this.stats.sourceNodesReplaced+=1;let a=i.map(c=>{let l=et(this.workspaceRoot,c),p=this.program.getSourceFile(l);if(!p)throw new Error(`affected TypeScript source is unavailable: ${c}`);return this.emitSourceFile(p)});return this.result(a,r)}fragment(t){return this.fragments.get(Dt(t))??null}snapshotStats(){return{...this.stats}}initializeAndAdvance(t){let r=this.initialize(),n=Pt(t.modifiedFiles),i=Pt(t.affectedFiles);this.validateIncrementalPaths(n,i);let o=new Set(i);return{...r,fragments:r.fragments.filter(s=>o.has(s.relativePath))}}validateIncrementalPaths(t,r){if(t.length===0)throw new Error("incremental TypeScript document update requires a modified file");if(r.length===0)throw new Error("incremental TypeScript document update requires an affected file");for(let n of t){let i=et(this.workspaceRoot,n);if(!this.includedFiles.has(De(i)))throw new Error(`modified TypeScript file is outside the configured project: ${n}`)}for(let n of r){let i=et(this.workspaceRoot,n);if(!this.includedFiles.has(De(i)))throw new Error(`affected TypeScript file is outside the configured project: ${n}`)}}emitSourceFile(t){if(!this.checker)throw new Error("TypeScript document emitter is not initialized");let r=Dt(so(this.workspaceRoot,t.fileName)),n=new this.runtime.Document({relative_path:r,occurrences:[]});if(new this.runtime.FileIndexer(this.checker,{cwd:this.workspaceRoot,projectRoot:this.projectRoot,projectDisplayName:this.projectRoot,maxFileByteSizeNumber:this.maxFileByteSize},new this.runtime.Input(t.fileName,t.getText()),n,this.symbolTable,this.constructorTable,this.packages,t).index(),this.stats.documentsEmitted+=1,n.occurrences.length===0)return this.fragments.delete(r),this.stats.documentsRemoved+=1,{relativePath:r,bytes:null,occurrences:0,symbols:n.symbols.length,referenceFragments:[]};let o=n.serializeBinary();return this.fragments.set(r,o),{relativePath:r,bytes:o,occurrences:n.occurrences.length,symbols:n.symbols.length,referenceFragments:ol(r,n)}}result(t,r){return{producerIdentity:this.producerIdentity,fragments:t,durationMs:performance.now()-r,stats:this.snapshotStats()}}};function ol(e,t){let r=new Map;for(let n of t.occurrences){if(!n.symbol||(n.symbol_roles&1)!==0||n.range.length<3)continue;let i=n.range[0],o=n.range[1];if(!Number.isInteger(i)||!Number.isInteger(o))continue;let s={targetSymbol:n.symbol,location:{file:e,line:i,column:o}};r.set(`${n.symbol}\0${i}\0${o}`,s)}return[...r.values()].sort((n,i)=>n.targetSymbol.localeCompare(i.targetSymbol)||n.location.line-i.location.line||n.location.column-i.location.column)}var Ur=class{compilerHost;sourceFiles=new Map;constructor(t,r,n){let i=t.createCompilerHost(r),o=i.getSourceFile.bind(i);this.compilerHost={...i,getCurrentDirectory:()=>n,getSourceFile:(s,a,c,l)=>{let p=De(s);if(this.sourceFiles.has(p))return this.sourceFiles.get(p);let u=o(s,a,c,l);return this.sourceFiles.set(p,u),u}}}invalidate(t){this.sourceFiles.delete(De(t))}};function io(e,t){let r=e.readConfigFile(t,e.sys.readFile);if(r.error)throw new Error(e.formatDiagnostics([r.error],e.createCompilerHost({})));let n=e.parseJsonConfigFileContent(r.config,e.sys,Hr(t)),i=n.errors.filter(o=>o.code!==18003);if(i.length>0)throw new Error(e.formatDiagnostics(i,e.createCompilerHost({})));return n}function zr(e){return co(e.packageVersion,e.typescript.version)}function co(e,t){return`scip-typescript:${e}:typescript:${t}:document-adapter:${nl}`}function sl(e,t){return Dt(so(e,t))||"."}function et(e,t){if(rl(t))throw new Error(`expected a project-relative path: ${t}`);let r=re(e,t),n=e.endsWith(Br)?e:`${e}${Br}`;if(r!==e&&!r.startsWith(n))throw new Error(`path escapes the project root: ${t}`);return r}function Pt(e){return[...new Set(e.map(Dt))].sort()}function Dt(e){return e.split(Br).join("/").replace(/^\.\//,"")}function De(e){return re(e)}function oo(e,t){let r=0;for(let n of e.keys())if(al(n)){try{if(n.getSourceFile()!==t)continue}catch{continue}e.delete(n),r+=1}return r}function al(e){return!!(e&&typeof e=="object"&&"kind"in e&&"getSourceFile"in e)}var cl=[v("source-facts",{dependsOn:["content-hash","tool-version"],keyParts:["kind","relativePath","contentHash","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/source/source-facts.ts"}),v("file-definitions",{dependsOn:["content-hash","project-fingerprint","indexed-language-set","tool-version"],keyParts:["kind","relativePath","contentHash","projectFingerprint","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/symbols/definition-catalog.ts"}),v("definition-exclusions",{dependsOn:["content-hash","tool-version"],keyParts:["kind","relativePath","contentHash","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/analysis/framework-patterns.ts"}),v("doc-path-tokens",{dependsOn:["content-hash","tool-version"],keyParts:["kind","relativePath","contentHash","payloadVersion"],stalenessTest:"tests/storage/evidence-products.test.ts",owner:"tests/storage/evidence-cache.test.ts"}),v("doc-path-evidence",{dependsOn:["content-hash","git-history","git-head","tool-version"],keyParts:["kind","relativePath","contentHash","trackedFiles","historyWindow","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/queries/cleanup/doc-drift.ts"}),v("source-imports",{dependsOn:["content-hash","import-resolution-fingerprint","config","tool-version"],keyParts:["kind","relativePath","contentHash","importResolutionFingerprint","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/language-parsers/index.ts"}),v("source-reexports",{dependsOn:["content-hash","import-resolution-fingerprint","config","tool-version"],keyParts:["kind","relativePath","contentHash","importResolutionFingerprint","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/language-parsers/index.ts"}),v("source-fingerprints",{dependsOn:["content-hash","project-fingerprint","indexed-language-set","tool-version"],keyParts:["kind","relativePath","contentHash","projectFingerprint","payloadVersion"],stalenessTest:"tests/symbols/definition-catalog.test.ts",owner:"src/queries/cleanup/similar.ts"}),v("consumer-file-usage",{dependsOn:["content-hash","project-fingerprint","indexed-language-set","tool-version"],keyParts:["kind","relativePath","contentHash","projectFingerprint","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/queries/internal/consumer-evidence.ts"}),v("react-component-behavior-profiles",{dependsOn:["content-hash","tool-version"],keyParts:["kind","relativePath","contentHash","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/source/react-profile.ts"}),v("git-file-adds",{dependsOn:["git-head","git-history","tool-version"],keyParts:["kind","cacheKey","head","historyWindow","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/analysis/git-history.ts"}),v("typescript-reference-fragments",{dependsOn:["content-hash","transitive-deps-digest","config","tool-version"],keyParts:["kind","relativePath","semanticIdentity","payloadVersion"],stalenessTest:"tests/semantic/typescript/typescript-reference-fragments.test.ts",owner:"src/semantic/typescript/reference-fragment-shadow.ts"}),v("typescript-import-usage",{dependsOn:["content-hash","transitive-deps-digest","config","tool-version"],keyParts:["kind","relativePath","semanticIdentity","payloadVersion"],stalenessTest:"tests/semantic/typescript/typescript-semantic-provider.test.ts",owner:"src/semantic/shared-primitives.ts"}),v("typescript-signatures",{dependsOn:["content-hash","transitive-deps-digest","config","tool-version"],keyParts:["kind","relativePath","semanticIdentity","payloadVersion"],stalenessTest:"tests/semantic/typescript/typescript-semantic-provider.test.ts",owner:"src/semantic/shared-primitives.ts"}),_t("file-dependency-graph",{dependsOn:["project-fingerprint","indexed-language-set","import-resolution-fingerprint","tool-version"],keyParts:["kind","scope","projectFingerprint","payloadVersion"],stalenessTest:"tests/symbols/file-dep-graph.test.ts",owner:"src/symbols/graph/file-dep-graph.ts"}),_t("semantic-import-usage",{dependsOn:["project-fingerprint","indexed-language-set","import-resolution-fingerprint","tool-version"],keyParts:["kind","relativePath","projectFingerprint","language","semanticEngine","payloadVersion"],stalenessTest:"tests/semantic/rust/rust-semantic-cache-gate.test.ts",owner:"src/semantic/shared-primitives.ts"}),_t("semantic-signatures",{dependsOn:["project-fingerprint","indexed-language-set","tool-version"],keyParts:["kind","relativePath","symbol","projectFingerprint","language","semanticEngine","payloadVersion"],stalenessTest:"tests/semantic/rust/rust-semantic-cache-gate.test.ts",owner:"src/semantic/shared-primitives.ts"}),_t("health-semantic-prewarm",{dependsOn:["project-fingerprint","indexed-language-set","tool-version"],keyParts:["kind","scope","cliVersion","projectFingerprint","payloadVersion"],stalenessTest:"tests/runtime/cli-support.test.ts",owner:"src/runtime/cli-support.ts"})];function tt(e){let t=new Map;return{kind:e.kind,read(r,n,i){let o=!1,s=0,a;if(er()){let c=Yn(r);if(c){let l=`${c}\0${n}\0${i}`;a=t.get(l),a||(a=tr(["evidence-product-file-read-v1",e.kind,c,n,i]),t.set(l,a))}}return rr("evidence-product.file.read",()=>{let c=Kn(r,e.kind,n,i);if(c===null)return null;s=c.length;try{let l=e.deserialize(c);return o=l!==null,l}catch{return null}},()=>({...a?{workIdentity:a,workOutcome:"computed"}:{},scope:"file",kind:e.kind,available:!0,hit:o,payloadBytes:s}))},write(r,n,i,o){Qn(r,e.kind,n,i,e.serialize(o))},writeBatch(r,n){Zn(r,n.map(i=>({kind:e.kind,relativePath:i.relativePath,contentHash:i.contentHash,payload:e.serialize(i.value)})))}}}function ug(e){let t=new Map;return{kind:e.kind,read(r,n,i){let o=!1,s=0,a;if(er()){let c=`${i}\0${n}`;a=t.get(c),a||(a=tr(["evidence-product-project-read-v1",e.kind,i,n]),t.set(c,a))}return rr("evidence-product.project.read",()=>{let c=ei(r,e.kind,n,i);if(c===null)return null;s=c.length;try{let l=e.deserialize(c);return o=l!==null,l}catch{return null}},()=>({...a?{workIdentity:a,workOutcome:"computed"}:{},scope:"project",kind:e.kind,available:!0,hit:o,payloadBytes:s}))},write(r,n,i,o){ti(r,e.kind,n,i,e.serialize(o))}}}function rt(e){let t=cl.find(r=>r.kind===e);if(!t)throw new Error(`missing evidence product manifest entry for ${e}`);return t.invalidation}function v(e,t){return{scope:"file",kind:e,invalidation:{scope:"file",...t}}}function _t(e,t){return{scope:"project",kind:e,invalidation:{scope:"project",...t}}}import{isAbsolute as ll,relative as pl}from"path";function T(e){return e.replace(/\\/g,"/")}function mg(e,t){let r=pl(e,t);return r===""||!r.startsWith("..")&&!ll(r)}var ul=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"];function yg(e){let t=e.toLowerCase();return ul.some(r=>t.endsWith(r))}import{createRequire as dl}from"module";var lo=dl(import.meta.url),nt,At;function fl(){if(nt!==void 0)return nt;try{nt=lo("ts-morph")}catch{nt=null}return nt}function xg(){if(At)return At;let e=fl();if(!e)return"ts-morph:unavailable";let t="unknown";try{t=lo("ts-morph/package.json").version??"unknown"}catch{}return At=`ts-morph:${t}:typescript:${e.ts.version}`,At}function bg(e,t){return t.map(r=>({tsconfigPath:r,project:new e.Project({tsConfigFilePath:r,skipFileDependencyResolution:!0})}))}function Ig(e,t,r){return{language:"typescript",availability:()=>({available:!1,reason:e,tsconfigPath:t,tsconfigPaths:r}),importUsage:()=>[],referencesFor:()=>[],calleesFor:()=>[],signatureFor:()=>null}}function vg(e,t,r){let n=new Set(r),i=new Map(r.map(o=>[o,[]]));for(let o of e)for(let s of t.get(o.symbolId)??[])n.has(s.file)&&i.get(s.file).push({targetSymbol:o.symbol,location:s});for(let[o,s]of i)i.set(o,ml(s));return i}function ml(e){let t=new Map;for(let r of e){let{location:n}=r;t.set(`${r.targetSymbol}\0${n.file}\0${n.line}\0${n.column}`,r)}return[...t.values()].sort((r,n)=>r.targetSymbol.localeCompare(n.targetSymbol)||gl(r.location,n.location))}function gl(e,t){return e.file.localeCompare(t.file)||e.line-t.line||e.column-t.column}import{existsSync as Jr,readFileSync as Xr,readdirSync as yl,statSync as hl}from"fs";import{join as _e,relative as Sl}from"path";function po(e){let t=xl(e)??vl(e);if(!t||t.length===0)return[];let r=[],n=new Set;for(let i of t)for(let o of Tl(e,i)){if(n.has(o))continue;n.add(o);let s=wl(e,o);s&&r.push(s)}return r}function xl(e){let t=_e(e,"pnpm-workspace.yaml");if(!Jr(t))return null;try{return bl(Xr(t,"utf8"))}catch{return null}}function bl(e){let t=[],r=!1;for(let n of e.split(/\r?\n/)){let i=Il(n);if(!r){/^packages\s*:\s*$/.test(i.trim())&&(r=!0);continue}let o=/^\s+-\s*(.+)$/.exec(i);if(o){let s=El(o[1].trim());s&&t.push(s);continue}if(i.trim()!=="")break}return t}function Il(e){let t=e.indexOf("#");return t===-1?e:e.slice(0,t)}function El(e){return e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'")?e.slice(1,-1):e}function vl(e){let t=_e(e,"package.json");if(!Jr(t))return null;try{let r=JSON.parse(Xr(t,"utf8"));return r.workspaces?Array.isArray(r.workspaces)?r.workspaces:r.workspaces.packages??[]:null}catch{return null}}function Tl(e,t){if(!t||t.startsWith("!")||t.includes("node_modules"))return[];if(!t.includes("*")){let s=_e(e,t);return qr(s)?[s]:[]}let r=t.indexOf("*"),n=t.slice(0,r).replace(/\/$/,""),i=t.slice(r+1).replace(/^\//,""),o=_e(e,n||".");return qr(o)?yl(o).map(s=>_e(o,s,i)).filter(qr):[]}function qr(e){try{return hl(e).isDirectory()}catch{return!1}}function wl(e,t){let r=_e(t,"package.json");if(!Jr(r))return null;try{let n=JSON.parse(Xr(r,"utf8"));return typeof n.name!="string"||n.name.length===0?null:{name:n.name,relativeDir:Sl(e,t).replace(/\\/g,"/"),exports:n.exports}}catch{return null}}import{createRequire as Rl}from"module";import{existsSync as ge}from"fs";import{basename as uo,dirname as P,extname as z,join as F,relative as fe,resolve as x,sep as kl}from"path";var Cl=pt("indexed-paths",{clearGroups:[]}),Nl=pt("indexed-path-digest",{clearGroups:[]}),Pl=b("tsconfig-alias-config",{clearGroups:["whole-project"]}),Dl=b("tsconfig-alias-config-for-dir",{clearGroups:["whole-project"]}),_l=Rl(import.meta.url),it;function Al(){if(it!==void 0)return it;try{it=_l("typescript")}catch{it=null}return it}var Fl=["tsconfig.json","tsconfig.app.json","tsconfig.node.json","tsconfig.base.json"],Ol=pt("workspace-packages",{clearGroups:["whole-project"]}),me=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs",".vue"],Ft=[".py",".pyi"],D=[".java",".scala",".kt",".kts"],Ot=[".rs"],Lt=[".rb"],jt=[".c",".h",".cc",".cpp",".cxx",".hpp",".hh",".hxx"],ne=[".cs",".vb"],Mt=[".dart"],ye=[".php"],Ae=[".clj",".cljs",".cljc"],Ll=new Set(me),Yr=new Set(Ft),fo=new Set(D),Kr=new Set(Ot),Qr=new Set(Lt),mo=new Set(jt),go=new Set(ne),Zr=new Set(Mt),yo=new Set(ye),ho=new Set(Ae),jl=[{extensions:me,lookup:Ll},{extensions:Ft,lookup:Yr},{extensions:D,lookup:fo},{extensions:Ot,lookup:Kr},{extensions:Lt,lookup:Qr},{extensions:jt,lookup:mo},{extensions:ne,lookup:go},{extensions:Mt,lookup:Zr},{extensions:ye,lookup:yo},{extensions:Ae,lookup:ho}];function q(e,t){return t.has(z(e).toLowerCase())}function Ml(e){return q(e,Yr)}function $l(e){return q(e,fo)}function Gl(e){return q(e,Kr)}function Wl(e){return q(e,Qr)}function Bl(e){return q(e,mo)}function Vl(e){return q(e,go)}function So(e){return z(e).toLowerCase()===".vb"}function Ul(e){return q(e,Zr)}function Hl(e){return q(e,yo)}function zl(e){return q(e,ho)}function en(e){let t=z(e).toLowerCase();for(let r of jl)if(r.lookup.has(t))return r.extensions;return me}function ql(e){return $l(e)||Vl(e)||Hl(e)}function ie(e,t,r){return Ml(t)?Fe(e,t,r):Gl(t)?J(e,t,r):Wl(t)?$t(e,t,r):Bl(t)?Gt(e,t,r):ql(t)?h(e,r.replace(/\\/g,"."),en(t)):Ul(t)?Wt(e,t,r):zl(t)?tn(e,r):Jl(e,t,r)}function Jl(e,t,r){if(!r.startsWith(".")&&!r.startsWith("/"))return Xl(e,t,r)??Kl(e,r);let n=P(F(e.config.projectRoot,t)),i=x(n,r),o=X(e);for(let s of nn(i)){let a=T(fe(e.config.projectRoot,s));if(o.has(a)||ge(s))return a}return T(fe(e.config.projectRoot,i))}function Xl(e,t,r){let n=np(e,t);if(!n)return null;let i=X(e);for(let o of Yl(n,r)){let s=x(n.baseUrl,o);for(let a of nn(s)){let c=T(fe(e.config.projectRoot,a));if(i.has(c)||ge(a))return c}}return null}function Yl(e,t){let r=[];for(let[n,i]of Object.entries(e.paths)){let o=n.indexOf("*");if(o===-1){if(t!==n)continue;r.push(...i);continue}let s=n.slice(0,o),a=n.slice(o+1);if(!t.startsWith(s)||!t.endsWith(a)||t.length<s.length+a.length)continue;let c=t.slice(s.length,t.length-a.length);for(let l of i)r.push(l.includes("*")?l.replace("*",c):l)}return r}function Kl(e,t){let r=Zl(Ql(e),t);if(!r)return null;let n=X(e);for(let i of ep(r)){let o=x(e.config.projectRoot,r.pkg.relativeDir,i);for(let s of nn(o)){let a=T(fe(e.config.projectRoot,s));if(n.has(a)||ge(s))return a}}return null}function Ql(e){return Ol.get(e,()=>po(e.config.projectRoot))}function Zl(e,t){let r=null;for(let n of e){let i=null;t===n.name?i="":t.startsWith(`${n.name}/`)&&(i=t.slice(n.name.length+1)),i!==null&&(!r||n.name.length>r.pkg.name.length)&&(r={pkg:n,subpath:i})}return r}function ep(e){let t=[],r=tp(e.pkg.exports,e.subpath);if(r){let n=rp(r);n&&t.push(n)}return t.push(e.subpath?`src/${e.subpath}`:"src/index"),t}function tp(e,t){if(!e||typeof e!="object")return null;let r=t===""?".":`./${t}`;return xo(e[r])}function xo(e){if(typeof e=="string")return e;if(!e||typeof e!="object")return null;let t=e;for(let r of["types","import","default","require","node"]){let n=xo(t[r]);if(n)return n}return null}function rp(e){let t=e.replace(/^\.\//,"");return t.startsWith("dist/")?`src/${t.slice(5)}`:null}function np(e,t){let r=T(P(t));return Dl.get(e,r,()=>ip(e,r))}function ip(e,t){let r=Al();if(!r)return null;let n=x(e.config.projectRoot),i=x(n,t);for(;i===n||i.startsWith(n+kl);){for(let s of Fl){let a=F(i,s);if(!ge(a))continue;let c=Pl.get(e,a,()=>op(r,a));if(c)return c}let o=P(i);if(o===i)break;i=o}return null}function op(e,t){try{let r=e.readConfigFile(t,e.sys.readFile);if(r.error||!r.config)return null;let n=e.parseJsonConfigFileContent(r.config,e.sys,P(t)),i=n.options.paths;return!i||Object.keys(i).length===0?null:{baseUrl:n.options.baseUrl?x(P(t),n.options.baseUrl):P(t),paths:i}}catch{return null}}function Fe(e,t,r){let n=X(e),i;if(r.startsWith(".")){let o=r.match(/^(\.+)(.*)$/);if(!o)return null;let s=o[1].length,a=o[2].replace(/^\./,""),c=P(F(e.config.projectRoot,t));for(let l=1;l<s;l++)c=P(c);i=a?x(c,a.replace(/\./g,"/")):c}else i=x(e.config.projectRoot,r.replace(/\./g,"/"));for(let o of sp(i)){let s=T(fe(e.config.projectRoot,o));if(n.has(s)||ge(o))return s}return null}function J(e,t,r){if(!r)return null;let n=r.replace(/\s+as\s+.+$/,"").trim();if(!n.startsWith("crate::")&&!n.startsWith("self::")&&!n.startsWith("super::"))return null;let i=P(F(e.config.projectRoot,t)),o;return n.startsWith("crate::")?o=x(e.config.projectRoot,"src",n.slice(7).replace(/::/g,"/")):n.startsWith("self::")?o=x(i,n.slice(6).replace(/::/g,"/")):o=x(P(i),n.slice(7).replace(/::/g,"/")),rn(e,ap(o))}function $t(e,t,r){let n=P(F(e.config.projectRoot,t)),i=x(n,r);return rn(e,cp(i))}function Gt(e,t,r){let n=P(F(e.config.projectRoot,t)),i=[x(n,r),x(e.config.projectRoot,r),x(e.config.projectRoot,"include",r),x(e.config.projectRoot,"src",r)];return rn(e,i)}function h(e,t,r){let n=X(e),i=t.replace(/\\/g,".").replace(/::/g,".").replace(/^global::/,""),o=i.replace(/\./g,"/"),s=i.split(".").pop()??i;for(let c of r){let l=`${o}${c}`,p=[...n].find(u=>u.endsWith(l));if(p)return p}for(let c of r){let l=[...n].find(p=>uo(p)===`${s}${c}`);if(l)return l}let a=[...n].filter(c=>r.includes(z(c).toLowerCase())).filter(c=>c.includes(`/${o}/`)||c.includes(`/${s}/`)).sort((c,l)=>c.localeCompare(l));return a.length===1?a[0]:null}function Wt(e,t,r){let n=X(e);if(r.startsWith("package:")){let s=r.slice(8),a=s.indexOf("/");if(a<0)return null;let c=s.slice(a+1),l=T(c.startsWith("lib/")?c:`lib/${c}`);return n.has(l)?l:null}let i=P(F(e.config.projectRoot,t)),o=x(i,r);for(let s of lp(o)){let a=T(fe(e.config.projectRoot,s));if(n.has(a)||ge(s))return a}return null}function tn(e,t){let r=t.replace(/-/g,"_").replace(/\./g,"/"),n=X(e);for(let i of Ae){let o=`${r}${i}`,s=[...n].find(a=>a.endsWith(o));if(s)return s}for(let i of Ae){let o=[...n].find(s=>uo(s)===`${r.split("/").pop()}${i}`);if(o)return o}return null}function sp(e){let t=z(e);return Yr.has(t)?[e]:[`${e}.py`,`${e}.pyi`,F(e,"__init__.py"),F(e,"__init__.pyi")]}function rn(e,t){let r=X(e);for(let n of t){let i=T(fe(e.config.projectRoot,n));if(r.has(i)||ge(n))return i}return null}function ap(e){let t=z(e);return Kr.has(t)?[e]:[`${e}.rs`,F(e,"mod.rs")]}function cp(e){let t=z(e);return Qr.has(t)?[e]:[`${e}.rb`,F(e,"index.rb")]}function lp(e){let t=z(e);return Zr.has(t)?[e]:[`${e}.dart`,e]}function nn(e){let t=z(e),r=new Set;if(t){r.add(e);for(let n of me)r.add(e.slice(0,-t.length)+n)}else for(let n of me)r.add(`${e}${n}`),r.add(F(e,`index${n}`));return[...r]}function X(e){return Cl.get(e,()=>new Set(Rn(e,{includeIgnored:!1}).map(T)))}function on(e){return Nl.get(e,()=>ht([...X(e)].sort().join(`
|
|
109
|
+
`)))}import{readFileSync as pp}from"fs";import{join as up}from"path";var dp=b("source-text",{clearGroups:["whole-project","source-file"]}),fp=b("source-lines",{clearGroups:["whole-project","source-file"]});function _(e,t){let r=t.replace(/\\/g,"/");return dp.get(e,r,()=>{let n=up(e.config.projectRoot,r);try{return pp(n,"utf-8")}catch(i){if(mp(i))return"";throw i}})}function mp(e){return typeof e=="object"&&e!==null&&"code"in e&&(e.code==="ENOENT"||e.code==="ENOTDIR")}function Gg(e,t){let r=t.replace(/\\/g,"/");return fp.get(e,r,()=>{let n=_(e,r);return n?n.split(`
|
|
110
|
+
`):[]})}import{basename as Ho}from"path";function he(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function gp(e){return e.replace(/'''[\s\S]*?'''/g,oe).replace(/"""[\s\S]*?"""/g,oe).replace(/#.*$/gm,oe).replace(/\/\/.*$/gm,oe).replace(/\/\*[\s\S]*?\*\//g,oe).replace(/`(?:\\[\s\S]|[^`])*`/g,oe).replace(/'(?:\\.|[^'\\\r\n])*'/g,oe).replace(/"(?:\\.|[^"\\\r\n])*"/g,oe)}function oe(e){return e.replace(/[^\r\n]/g," ")}var zg=Re("stripped-lines",{clearGroups:["whole-project","source-file"]});Tn({name:"stripped-source-singleton",groups:["whole-project","source-file"],clearAll:()=>{Bt=null,ot=""},clearFile:()=>{Bt=null,ot=""}});var Bt=null,ot="";function yp(e){return Bt===e||(Bt=e,ot=gp(e)),ot}function se(e,t,r){let n=yp(e);return`${n.slice(0,t)}${" ".repeat(r-t)}${n.slice(r)}`}function w(e,t){return new RegExp(`\\b${he(t)}\\b`,"m").test(e)}function Oe(e,t){let r=new Set,n=new RegExp(`\\b${he(t)}\\s*\\.\\s*([A-Za-z_$][\\w$]*)`,"g");for(let i of e.matchAll(n)){let o=i[1];o&&r.add(o)}return[...r]}function sn(e){let t=0;for(let r of e)r==="("&&(t+=1),r===")"&&(t-=1);return t}import{extname as bo}from"path";var hp={".rs":"rust",".ts":"typescript",".mts":"typescript",".cts":"typescript",".tsx":"tsx",".js":"javascript",".jsx":"javascript",".mjs":"javascript",".cjs":"javascript",".py":"python",".pyi":"python",".java":"java",".kt":"kotlin",".kts":"kotlin",".scala":"scala",".sc":"scala",".rb":"ruby",".c":"c",".h":"c",".cc":"cpp",".cpp":"cpp",".cxx":"cpp",".hpp":"cpp",".hh":"cpp",".hxx":"cpp",".cs":"csharp",".php":"php",".vb":"vb",".clj":"clojure",".cljs":"clojure",".cljc":"clojure"};function Se(e){return hp[bo(e).toLowerCase()]??null}function xe(e){return bo(e).toLowerCase()===".vue"}import{createRequire as Sp}from"module";var I=Sp(import.meta.url),Vt=null,Io=!1;function xp(){if(Io)return null;if(Vt)return Vt;try{return Vt=I("tree-sitter"),Vt}catch{return Io=!0,null}}var Eo=new Map,Ut=new Set;function bp(e){if(Ut.has(e))return null;let t=Eo.get(e);if(t)return t;let r;try{switch(e){case"rust":r=I("tree-sitter-rust");break;case"typescript":r=I("tree-sitter-typescript").typescript;break;case"tsx":r=I("tree-sitter-typescript").tsx;break;case"javascript":r=I("tree-sitter-javascript");break;case"python":r=I("tree-sitter-python");break;case"java":r=I("tree-sitter-java");break;case"kotlin":r=I("tree-sitter-kotlin");break;case"scala":r=I("tree-sitter-scala");break;case"ruby":r=I("tree-sitter-ruby");break;case"c":r=I("tree-sitter-c");break;case"cpp":r=I("tree-sitter-cpp");break;case"csharp":r=I("tree-sitter-c-sharp");break;case"php":r=I("tree-sitter-php").php;break;case"vb":{let n=I("tree-sitter-vb-dotnet");r=n.language??n;break}case"clojure":return Ut.add(e),null}}catch{return Ut.add(e),null}return Eo.set(e,r),r}var vo=new Map;function Ip(e){let t=vo.get(e);if(t)return t;let r=bp(e);if(!r)return null;let n=xp();if(!n)return null;let i=new n;try{i.setLanguage(r)}catch{return Ut.add(e),null}return vo.set(e,i),i}function Ep(e,t){return e.parse(n=>n>=t.length?null:t.slice(n,Math.min(t.length,n+16384)))}function an(e,t){let r=Ip(e);if(!r)return null;try{return Ep(r,t)}catch{return null}}import{posix as cn}from"path";import{parse as vp}from"@vue/compiler-sfc";var ry=wn("vue-sfc-units");function Tp(e){return e.replace(/\\/g,"/").replace(/^\.\//,"")}function wp(e){let t=e?.toLowerCase();return!t||t==="js"||t==="javascript"||t==="jsx"?"javascript":t==="ts"||t==="typescript"?"typescript":t==="tsx"?"tsx":null}function Ro(e,t,r){let n={relativePath:t,template:null,scripts:[],styles:[],customBlocks:[],errors:[]};if(!r)return n;let i;try{i=vp(r,{filename:t})}catch(s){return n.errors.push(wo(s)),n}n.errors.push(...i.errors.map(wo));let{descriptor:o}=i;return o.template&&(n.template=Ht(e,t,"template",o.template)),o.script&&n.scripts.push(To(e,t,o.script,!1)),o.scriptSetup&&n.scripts.push(To(e,t,o.scriptSetup,!0)),n.styles=o.styles.map(s=>Ht(e,t,"style",s)),n.customBlocks=o.customBlocks.map(s=>Ht(e,t,"custom",s)),n.errors.push(...[n.template,...n.scripts,...n.styles,...n.customBlocks].flatMap(s=>s?.errors??[])),n}function To(e,t,r,n){let i=Ht(e,t,"script",r);return{...i,kind:"script",setup:n,astLanguage:wp(i.lang)}}function Ht(e,t,r,n){let i=kp(n.attrs),o=typeof i.lang=="string"?i.lang:null,s=typeof i.src=="string"?i.src:typeof n.src=="string"?n.src:void 0;if(s){let c=Rp(t,s);if(!c)return{kind:r,ownerPath:t,sourcePath:t,external:!0,src:s,attrs:i,lang:o,body:"",startLine:0,endLine:0,errors:[`Could not resolve Vue ${r} block source: ${s}`]};let l=_(e,c),p=l?Math.max(0,l.split(`
|
|
111
|
+
`).length-1):0;return{kind:r,ownerPath:t,sourcePath:c,external:!0,src:s,attrs:i,lang:o,body:l,startLine:0,endLine:p,errors:l?[]:[`Vue ${r} block source not found: ${c}`]}}let a=Math.max(0,n.loc.start.line-1);return{kind:r,ownerPath:t,sourcePath:t,external:!1,attrs:i,lang:o,body:n.content,startLine:a,endLine:Math.max(a,n.loc.end.line-1),errors:[]}}function Rp(e,t){let r=t.split(/[?#]/,1)[0];if(!r||r.startsWith("/")||r.includes("://"))return null;let n=Tp(cn.normalize(cn.join(cn.dirname(e),r)));return n===".."||n.startsWith("../")?null:n}function kp(e){return{...e}}function wo(e){return e instanceof Error?e.message:String(e)}function zt(e,t,r){let i=Ro(e,t,r).scripts.filter(s=>s.astLanguage&&s.body.length>0),o=i[0]?.astLanguage;return o?{body:i.map(s=>`${`
|
|
112
|
+
`.repeat(s.startLine)}${s.body}`).join(`
|
|
113
|
+
`),startLine:0,language:o}:null}var ko=Re("ast-trees",{clearGroups:["whole-project","source-file"]});function U(e,t){if(xe(t))return Cp(e,t);let r=Se(t);if(!r)return null;let n=_(e,t);return n?ko.get(e,t,n,()=>an(r,n)):null}function Cp(e,t){let r=_(e,t);return r?ko.get(e,t,r,()=>{let n=zt(e,t,r);if(!n)return null;let i=`
|
|
114
|
+
`.repeat(n.startLine)+n.body;return an(n.language,i)}):null}function Co(e,t){let r=Np(e,t);if(!r)return null;let n=be(r);return n?{calleeLeaf:n,memberAccess:Pp(r),line:e.startPosition.row}:null}function Np(e,t){if(t==="rust")return e.type==="call_expression"?e.childForFieldName("function")??e.namedChild(0):e.type==="macro_invocation"?e.childForFieldName("macro")??e.namedChild(0):null;if(t==="python")return e.type!=="call"?null:e.childForFieldName("function")??e.namedChild(0);if(t==="typescript"||t==="tsx"||t==="javascript"){if(e.type==="call_expression")return e.childForFieldName("function")??e.namedChild(0);if(e.type==="new_expression")return e.childForFieldName("constructor")??e.namedChild(0)}return null}function Pp(e){switch(e.type){case"field_expression":case"member_expression":case"attribute":return!0;default:return!1}}function be(e){switch(e.type){case"identifier":case"type_identifier":case"field_identifier":case"property_identifier":case"shorthand_property_identifier":return e.text;case"field_expression":case"member_expression":case"attribute":{let t=e.namedChild(e.namedChildCount-1);return t?be(t):null}case"generic_function":{let t=e.childForFieldName("function")??e.namedChild(0);return t?be(t):null}case"scoped_identifier":{let t=e.childForFieldName("name")??e.namedChild(e.namedChildCount-1);return t?be(t):null}case"super":case"self":case"this":return null;default:return null}}function st(e){return e.type==="comment"||e.type==="line_comment"||e.type==="block_comment"}var Dp=new Set(["function_declaration","method_definition","method_signature","function_signature"]);function Ao(e,t){let r=Ap(e,t);if(r)return{name:r.name,startLine:r.definitionNode.startPosition.row,endLine:r.definitionNode.endPosition.row,paramCount:Do(r.functionNode),params:No(r.functionNode),paramsEndLine:Po(r.functionNode),isLiteralPassthrough:_o(r.functionNode,t)};if(!_p(e.type,t))return null;let n=e.childForFieldName("name")??e.namedChildren.find(i=>i.type==="identifier"||i.type==="property_identifier");return n?{name:n.text,startLine:e.startPosition.row,endLine:e.endPosition.row,paramCount:Do(e),params:No(e),paramsEndLine:Po(e),isLiteralPassthrough:_o(e,t)}:null}function Fo(e){return e.namedChildren.find(t=>t.type==="parameters"||t.type==="formal_parameters")}function No(e){let t=Fo(e);if(!t)return[];let r=[];for(let n of t.namedChildren){if(st(n))continue;if(n.type==="identifier"){r.push({name:n.text,simple:!0});continue}let i=n.namedChildren.some(a=>a.type.endsWith("_modifier"))||/^\s*(?:public|private|protected|readonly|override)\b/.test(n.text),o=n.childForFieldName("pattern");if(!i&&o&&o.type==="identifier"){r.push({name:o.text,simple:!0});continue}let s=n.namedChildren.find(a=>a.type==="identifier");r.push({name:o?.type==="identifier"?o.text:s?.text??"",simple:!1})}return r}function Po(e){let t=Fo(e);return t?t.endPosition.row:e.startPosition.row}function _p(e,t){return t==="rust"?e==="function_item"||e==="function_signature_item":t==="python"?e==="function_definition":t==="typescript"||t==="tsx"||t==="javascript"?Dp.has(e):!1}function Ap(e,t){if(t!=="typescript"&&t!=="tsx"&&t!=="javascript")return null;if(e.type==="variable_declarator"){let r=e.childForFieldName("name")??e.namedChild(0),n=e.childForFieldName("value")??e.namedChild(1);return!r||!n||n.type!=="arrow_function"&&n.type!=="function_expression"?null:{name:r.text,definitionNode:e,functionNode:n}}if(e.type==="public_field_definition"){let r=e.childForFieldName("name")??e.namedChild(0),n=e.childForFieldName("value")??e.namedChild(1);return!r||!n||n.type!=="arrow_function"&&n.type!=="function_expression"?null:{name:r.text,definitionNode:e,functionNode:n}}return null}function Do(e){let t=e.namedChildren.find(n=>n.type==="parameters"||n.type==="formal_parameters");if(!t)return 0;let r=0;for(let n of t.namedChildren)st(n)||(r+=1);return r}function _o(e,t){let r=e.namedChildren.find(u=>u.type==="block"||u.type==="statement_block");if(!r)return!1;let n=r.namedChildren.filter(u=>!st(u));if(n.length!==1)return!1;let i=n[0],o=null;if(i.type==="return_statement"||i.type==="expression_statement"?o=i.namedChild(0)??null:t==="rust"&&(i.type==="call_expression"||i.type==="macro_invocation")&&(o=i),!o)return!1;let s=t==="python"?"call":"call_expression";if(o.type!==s)return!1;let a=o.namedChildren.find(u=>u.type==="arguments"||u.type==="argument_list");if(!a)return!1;let c=a.namedChildren.filter(u=>!st(u)),l=e.namedChildren.find(u=>u.type==="parameters"||u.type==="formal_parameters");if(!l)return!1;let p=[];for(let u of l.namedChildren){if(u.type==="identifier"){p.push(u.text);continue}let d=u.namedChildren.find(m=>m.type==="identifier");d&&p.push(d.text)}if(c.length!==p.length)return!1;for(let u=0;u<p.length;u+=1){let d=c[u];if(d.type!=="identifier"||d.text!==p[u])return!1}return!0}var Fp=new Set(["identifier","type_identifier","field_identifier"]),Op=new Set(["identifier"]),Lp=new Set(["identifier","property_identifier","type_identifier","shorthand_property_identifier","shorthand_property_identifier_pattern"]),jp=new Set(["rust","python"]),Mp=/\{([^{}]*)\}/g,$p=/\b([A-Za-z_][\w]*)\b/g;function Oo(e,t){return Gp(t).has(e.type)}function Lo(e,t){return jp.has(t)&&e.type==="string_content"}function ln(e){let t=0;for(let n of e.values()){let i=n[n.length-1];i!==void 0&&i>t&&(t=i)}let r=new Array(t+1);for(let n=0;n<=t;n+=1)r[n]=new Set;for(let[n,i]of e)for(let o of i)r[o].add(n);return r}function Gp(e){return e==="rust"?Fp:e==="python"?Op:Lp}function jo(e,t){let r=e.startPosition.row;for(let n of e.text.matchAll(Mp)){let i=n[1]??"";for(let o of i.matchAll($p))o[1]&&t(o[1],r)}}var Wp=[/\bdefault\s*=\s*"([^"]+)"/g,/\bwith\s*=\s*"([^"]+)"/g,/\bserialize_with\s*=\s*"([^"]+)"/g,/\bdeserialize_with\s*=\s*"([^"]+)"/g,/\bskip_serializing_if\s*=\s*"([^"]+)"/g,/\bgetter\s*=\s*"([^"]+)"/g,/\brename_all_with\s*=\s*"([^"]+)"/g,/\bschema_with\s*=\s*"([^"]+)"/g],Bp=/^#!?\[\s*serde\s*\(/,Vp=/^#!?\[\s*schemars\s*\(/,Up=/^#!?\[\s*validate\s*\(/,Hp=new Set(["invoke","invokeTauriCommand","listen","once","emit","subscribe","dispatch","sendCommand","callRust"]);function Mo(e,t,r){if(t!=="typescript"&&t!=="tsx"&&t!=="javascript"||e.type!=="call_expression")return;let n=e.childForFieldName("function")??e.namedChild(0);if(!n)return;let i=be(n);if(!i||!Hp.has(i))return;let o=e.namedChildren.find(c=>c.type==="arguments");if(!o)return;let s=o.namedChild(0);if(!s||s.type!=="string")return;let a=s.namedChildren.find(c=>c.type==="string_fragment");a&&r.add(a.text)}function $o(e,t){let r=Bp.test(e),n=Vp.test(e),i=Up.test(e);if(!(!r&&!n&&!i))for(let o of Wp){o.lastIndex=0;let s;for(;(s=o.exec(e))!==null;){let a=s[1],c=a.split("::").pop()??a;c==="is_none"&&/\bOption\b/.test(a)||c==="is_empty"&&/\b(String|Vec|HashMap|BTreeMap|HashSet|BTreeSet)\b/.test(a)||c&&t.add(c)}}}function Go(e,t){let r=new Map,n=(s,a)=>{if(s===a)return;let c=r.get(s);c||(c=new Set,r.set(s,c)),c.add(a)},i=t==="python"?new Set(["identifier"]):new Set(["type_identifier"]),o=(s,a)=>{let c=l=>{i.has(l.type)&&l.text!==a&&n(l.text,a);for(let p of l.children)c(p)};for(let l of s.children)c(l)};if(t==="rust")for(let s of e.rootNode.descendantsOfType(["struct_item","enum_item","union_item","type_item"])){let a=s.namedChildren.find(l=>l.type==="type_identifier")?.text;if(!a)continue;let c=s.namedChildren.find(l=>l.type==="field_declaration_list"||l.type==="enum_variant_list"||l.type==="ordered_field_declaration_list");c&&o(c,a),s.type==="type_item"&&o(s,a)}else if(t==="python")for(let s of e.rootNode.descendantsOfType("class_definition")){let a=s.namedChildren.find(p=>p.type==="identifier")?.text;if(!a)continue;let c=s.childForFieldName("superclasses");c&&o(c,a);let l=s.namedChildren.find(p=>p.type==="block");if(l)for(let p of l.descendantsOfType("type"))for(let u of p.descendantsOfType("identifier"))u.text!==a&&n(u.text,a)}else for(let s of e.rootNode.descendantsOfType(["interface_declaration","type_alias_declaration","class_declaration"])){let a=s.namedChildren.find(c=>c.type==="type_identifier")?.text;a&&o(s,a)}return r}var zp=new Map([["defn","function"],["defn-","function"],["defmacro","macro"],["defmacro-","macro"],["defmethod","method"]]),pn=new Set(["catch","comment","def","defprotocol","defrecord","deftype","defmethod","defmacro","defmacro-","defn","defn-","do","doseq","dotimes","fn","for","if","let","loop","ns","quote","recur","throw","try","extend-protocol","extend-type","when","when-let","when-not"]);function Wo(e){let t=[],r=[],n=[],i=new Map,o=[],s=0,a=0,c=(l,p)=>{let u=i.get(l);if(!u){i.set(l,[p]);return}u[u.length-1]!==p&&u.push(p)};for(;a<e.length;){let l=e[a];if(l===`
|
|
115
|
+
`){s+=1,a+=1;continue}if(/\s|,/.test(l)){a+=1;continue}if(l===";"){a=Jt(e,a);continue}if(l==='"'){let y=ct(e,a,s);s=y.line,a=y.index;continue}if(l==="("||l==="["||l==="{"){o.push({kind:l,startLine:s,endLine:s,headTokens:[],tokens:[],children:[]}),a+=1;continue}if(l===")"||l==="]"||l==="}"){let y=o.pop();y&&(y.endLine=s,qp(y,{callables:t,callSites:r,clojureMembers:n,recordIdentifier:c}),o[o.length-1]?.children.push(y)),a+=1;continue}if(un(l)){a+=1;continue}let p=s,u=a;for(;a<e.length&&!dn(e[a]);)a+=1;let d=e.slice(u,a);if(!d)continue;let m={text:d,line:p};Jp(o[o.length-1],m),c(O(d),p)}return{language:"clojure",callables:t,callSites:r,clojureMembers:n,typeContainerMap:new Map,identifierLineMap:i,identifiersByLine:Zp(i),fileIdentifiers:new Set(i.keys()),rustAttrReferencedNames:new Set,crossLanguageDispatchNames:new Set}}function qp(e,t){if(e.kind!=="("||e.headTokens.length===0)return;let r=e.headTokens[0],n=O(r.text),i=zp.get(r.text);if(i){let s=e.headTokens[1];if(s){let a=O(s.text);t.recordIdentifier(a,s.line),t.callables.push({name:a,startLine:e.startLine,endLine:e.endLine,paramCount:0,params:[],paramsEndLine:s.line,isLiteralPassthrough:!1,clojureKind:i})}}if(Xp(e,t),!n||pn.has(r.text)||pn.has(n)||n.startsWith(":"))return;let o=Qp(r.text);t.callSites.push({calleeLeaf:o.leaf,calleeQualifier:o.qualifier,calleeText:o.text,memberAccess:!1,line:r.line})}function Jp(e,t){e&&(e.headTokens.length<2&&e.headTokens.push(t),e.tokens.length<200&&e.tokens.push(t))}function Xp(e,t){let r=O(e.tokens[0]?.text??"");if(r==="defprotocol"){let n=O(e.tokens[1]?.text??"");if(!n)return;for(let i of qt(e))at(t,n,"protocol",i,"protocol-method");return}if(r==="defrecord"||r==="deftype"){let n=O(e.tokens[1]?.text??"");if(!n)return;let i=r==="defrecord"?"record":"type",o=r==="defrecord"?"record-method":"type-method";for(let s of qt(e))at(t,n,i,s,o);return}if(r==="extend-type"){let n=O(e.tokens[1]?.text??"");if(!n)return;for(let i of qt(e))at(t,n,"extension",i,"extension-method");return}if(r==="extend-protocol"){let n=O(e.tokens[1]?.text??"");for(let i of qt(e)){n&&at(t,n,"extension",i,"extension-method");let o=Kp(e,i.startLine);o&&o!==n&&at(t,o,"extension",i,"extension-method")}}}function qt(e){return e.children.filter(Yp)}function Yp(e){if(e.kind!=="(")return!1;let t=O(e.tokens[0]?.text??"");return!!(t&&!pn.has(t)&&!t.startsWith(":"))}function at(e,t,r,n,i){let o=n.tokens[0],s=O(o?.text??"");!o||!s||(e.recordIdentifier(s,o.line),e.clojureMembers.push({ownerName:t,ownerKind:r,memberName:s,memberKind:i,startLine:n.startLine,endLine:n.endLine}))}function Kp(e,t){let r=null;for(let n=2;n<e.tokens.length;n+=1){let i=e.tokens[n];if(i.line>t)break;let o=O(i.text);o&&!o.startsWith(":")&&(r=o)}return r}function O(e){return e.replace(/^#?['`~@]+/,"").split("/").pop()?.replace(/^\./,"")??""}function Qp(e){let t=e.replace(/^#?['`~@]+/,""),r=t.lastIndexOf("/"),n=O(t);if(r<=0)return{leaf:n,text:t};let i=t.slice(0,r);return{leaf:n,qualifier:i,text:t}}function Jt(e,t){let r=t;for(;r<e.length&&e[r]!==`
|
|
116
|
+
`;)r+=1;return r}function ct(e,t,r){let n=t+1,i=r;for(;n<e.length;){let o=e[n];if(o==="\\"){n+=2;continue}if(o===`
|
|
117
|
+
`&&(i+=1),n+=1,o==='"')break}return{index:n,line:i}}function un(e){return e==="'"||e==="`"||e==="~"||e==="@"||e==="^"||e==="#"}function dn(e){return/\s|,/.test(e)||e==="("||e===")"||e==="["||e==="]"||e==="{"||e==="}"||e==='"'||e===";"}function Zp(e){let t=[];for(let[r,n]of e)for(let i of n)t[i]??=new Set,t[i].add(r);return t}var Bo=3,eu=Re("source-facts",{clearGroups:["whole-project","source-file"]}),fn=tt({kind:"source-facts",invalidation:rt("source-facts"),serialize:iu,deserialize:ou});function Vo(e,t){return tu(e,t).facts}function tu(e,t){let r=_(e,t);if(!r)return{facts:null};let n=ru(e,t,r);return n?eu.get(e,t,r,()=>nu(e,t,n,r)):{facts:null}}function ru(e,t,r){return xe(t)?zt(e,t,r)?.language??null:Se(t)}function nu(e,t,r,n){let i=je(e,t,n),o=fn.read(e,t,i);if(o&&o.language===r)return{facts:o};if(r==="clojure"){let c=Wo(n);return fn.write(e,t,i,c),{facts:c}}let s=U(e,t);if(!s)return{facts:null,unavailable:{language:r,reason:"parser-unavailable"}};let a=su(s,r);return fn.write(e,t,i,a),{facts:a}}function iu(e){let t={version:Bo,language:e.language,callables:e.callables,callSites:e.callSites,clojureMembers:e.clojureMembers,typeContainerMap:[...e.typeContainerMap.entries()].map(([r,n])=>[r,[...n]]),identifierLineMap:[...e.identifierLineMap.entries()],rustAttrReferencedNames:[...e.rustAttrReferencedNames],crossLanguageDispatchNames:[...e.crossLanguageDispatchNames]};return JSON.stringify(t)}function ou(e){try{let t=JSON.parse(e);if(t.version!==Bo||t.language==="clojure"&&(t.clojureMembers===void 0||t.callSites.some(n=>n.calleeText===void 0)))return null;let r=new Map(t.identifierLineMap);return{language:t.language,callables:t.callables,callSites:t.callSites,clojureMembers:t.clojureMembers??[],typeContainerMap:new Map(t.typeContainerMap.map(([n,i])=>[n,new Set(i)])),identifierLineMap:r,identifiersByLine:ln(r),fileIdentifiers:new Set(r.keys()),rustAttrReferencedNames:new Set(t.rustAttrReferencedNames),crossLanguageDispatchNames:new Set(t.crossLanguageDispatchNames)}}catch{return null}}function su(e,t){let r=[],n=[],i=new Set,o=new Set,s=new Map,a=(l,p)=>{let u=s.get(l);if(!u){s.set(l,[p]);return}u[u.length-1]!==p&&u.push(p)},c=l=>{let p=Ao(l,t);p&&r.push(p);let u=Co(l,t);u&&n.push(u),Mo(l,t,o),t==="rust"&&(l.type==="attribute_item"||l.type==="inner_attribute_item")&&$o(l.text,i),Oo(l,t)&&a(l.text,l.startPosition.row),Lo(l,t)&&jo(l,a);for(let d of l.children)c(d)};return c(e.rootNode),{language:t,callables:r,callSites:n,clojureMembers:[],typeContainerMap:Go(e,t),identifierLineMap:s,identifiersByLine:ln(s),fileIdentifiers:new Set(s.keys()),rustAttrReferencedNames:i,crossLanguageDispatchNames:o}}var au=new Set(["rust","typescript","tsx","javascript","python","clojure"]);function cu(e,t){let r=Vo(e,t);return!r||!au.has(r.language)?null:r.callables.map(n=>({name:n.name,startLine:n.startLine,endLine:n.endLine}))}function Uo(e,t){return e.split(t).filter(Boolean).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join("")}var lu=new Set(["identifier","type_identifier","property_identifier","shorthand_property_identifier","field_identifier"]);function R(e){let t=[],r=0,n=0;for(let i=0;i<e.length;i++){let o=e[i];(o==="{"||o==="["||o==="(")&&r++,(o==="}"||o==="]"||o===")")&&r--,o===","&&r===0&&(t.push(e.slice(n,i)),n=i+1)}return t.push(e.slice(n)),t}function A(e,t){for(let r of e.namedChildren)if(r.type===t)return r;return null}function S(e,t){let r=new Set,n=(i,o)=>{let s=o||t.has(i.type);!s&&lu.has(i.type)&&r.add(i.text);for(let a of i.children)n(a,s)};return n(e.rootNode,!1),r}function B(e,t,r,n,i,o,s){return{importedName:i,localName:o,sourcePath:s??h(e,n,en(t)),kind:"named",used:w(r,o),usedMembers:[]}}function g(e,t,r,n,i="named",o={}){return{importedName:e,localName:t,sourcePath:r,kind:i,used:n.has(t),usedMembers:[],isTypeOnly:o.isTypeOnly}}function Y(e,t,r,n,i="named",o=[],s={}){return{importedName:e,localName:t,sourcePath:r,kind:i,used:n,usedMembers:o,isTypeOnly:s.isTypeOnly}}function Ie(e,t){return{importedName:e,localName:null,sourcePath:t,kind:"side-effect",used:!0,usedMembers:[]}}function Ee(e,t,r={}){return{importedName:e,localName:r.localName??null,sourcePath:t,kind:"namespace",used:r.used??!0,usedMembers:r.usedMembers??[],isTypeOnly:r.isTypeOnly}}function L(e,t,r){let n=[];for(let i of e.matchAll(t)){let o=i[0];if(!o||typeof i.index!="number")continue;let s=se(e,i.index,i.index+o.length);for(let a of r(i,s))n.push(a)}return n}function j(e,t,r,n){let i=U(e,t);if(i){let o=r(i);if(o)return o}return n()}function Xt(e,t,r,n){let i=U(e,t),o=Se(t),s=o?r[o]:void 0;return i&&s?s(i):n()}function zo(e,t,r){return j(e,t,n=>uu(e,t,n),()=>pu(e,t,r))}function pu(e,t,r){return L(r,/^[ \t]*#include\s+[<"]([^">]+)[">]\s*$/gm,(n,i)=>{let o=n[1]?.trim();if(!o)return[];let s=Ho(o).replace(/\.[^.]+$/,"");return[Y(o,s,Gt(e,t,o),w(i,s))]})}function uu(e,t,r){let n=S(r,new Set(["preproc_include"])),i=[];for(let o of r.rootNode.descendantsOfType("preproc_include")){let s=null;for(let c of o.namedChildren){if(c.type==="system_lib_string"){s=c.text.replace(/^<|>$/g,"");break}if(c.type==="string_literal"){s=c.namedChildren.find(p=>p.type==="string_content")?.text??c.text.replace(/^"|"$/g,"");break}}if(!s)continue;let a=Ho(s).replace(/\.[^.]+$/,"");i.push(g(s,a,Gt(e,t,s),n))}return i}var du=new Set([":require",":require-macros",":use"]),yn=String.raw`A-Za-z0-9_$*+!?.<>=-`;function Jo(e,t,r){let n=vu(r);if(!n)return[];let i=Eu(r,n.start,n.end),o=[];for(let s of n.children.slice(2)){if(s.type!=="list"||s.children.length===0)continue;let a=M(s.children[0]);if(a){if(du.has(a)){for(let c of gu(s.children.slice(1)))o.push(...mu(e,c,i));continue}if(a===":import")for(let c of hu(s.children.slice(1)))o.push(c)}}return o}function fu(e){return e.type==="list"&&M(e.children[0])==="ns"}function mu(e,t,r){let n=tn(e,t.namespace),i=t.alias??t.namespace,o=xu(r,i),s=[{importedName:t.namespace,localName:i,sourcePath:n,kind:"namespace",used:t.refers.length>0||t.referAll||o.length>0||bu(r,t.namespace),usedMembers:o}];t.referAll&&s.push({importedName:"*",localName:null,sourcePath:n,kind:"side-effect",used:!0,usedMembers:[]});for(let a of t.refers)s.push({importedName:a,localName:a,sourcePath:n,kind:"named",used:Iu(r,a),usedMembers:[]});return s}function gu(e){return e.flatMap(t=>Yt(t,null))}function Yt(e,t){if(e.type==="atom")return e.text.startsWith(":")?[]:[{namespace:gn(t,e.text),alias:null,refers:[],referAll:!1}];if(e.type==="vector")return e.children.length>0&&M(e.children[0])===null?e.children.flatMap(r=>Yt(r,t)):yu(e,t);if(e.type==="list"&&e.children.length>0){let r=M(e.children[0]);return r?!r||r.startsWith(":")?[]:e.children.slice(1).flatMap(n=>Yt(n,gn(t,r))):e.children.flatMap(n=>Yt(n,t))}return[]}function yu(e,t){let r=M(e.children[0]);if(!r||r.startsWith(":"))return[];let n={namespace:gn(t,r),alias:null,refers:[],referAll:!1};for(let i=1;i<e.children.length;i+=1){let o=M(e.children[i]);if(!o?.startsWith(":"))continue;let s=e.children[i+1];if((o===":as"||o===":as-alias")&&s){n.alias=M(s),i+=1;continue}o===":refer"&&s&&(M(s)===":all"?n.referAll=!0:(s.type==="vector"||s.type==="list")&&n.refers.push(...s.children.map(M).filter(Su)),i+=1)}return[n]}function hu(e){let t=[];for(let r of e){if(r.type==="atom"){let i=r.text.split(".").pop()??r.text;t.push(Y(i,i,null,!0));continue}if(r.type!=="vector")continue;let n=M(r.children[0]);if(n)for(let i of r.children.slice(1)){let o=M(i);o&&t.push(Y(`${n}.${o}`,o,null,!0))}}return t}function gn(e,t){return e?`${e}.${t}`:t}function M(e){return e?.type==="atom"?e.text:null}function Su(e){return!!(e&&!e.startsWith(":"))}function xu(e,t){let r=new Set,n=new RegExp(`${hn()}${he(t)}\\s*/\\s*([${yn}]+)`,"g");for(let i of e.matchAll(n)){let o=i[1];o&&r.add(o)}return[...r]}function bu(e,t){return new RegExp(`${hn()}${he(t)}\\s*/`,"m").test(e)}function Iu(e,t){return new RegExp(`${hn()}${he(t)}(?![${yn}])`,"m").test(e)}function hn(){return`(?<![${yn}])`}function Eu(e,t,r){let n="",i=0;for(;i<e.length;){if(i>=t&&i<r){n+=e[i]===`
|
|
118
|
+
`?`
|
|
119
|
+
`:" ",i+=1;continue}let o=e[i];if(o===";"){let s=Jt(e,i);n+=qo(e.slice(i,s)),i=s;continue}if(o==='"'){let s=ct(e,i,0).index;n+=qo(e.slice(i,s)),i=s;continue}n+=o,i+=1}return n}function vu(e){let t=0;for(;t<e.length&&(t=Sn(e,t),!(t>=e.length));){let r=Kt(e,t);if(!r){t+=1;continue}if(fu(r.form))return r.form;t=r.index}return null}function Kt(e,t){let r=Sn(e,t);if(e.startsWith("#?@",r)||e.startsWith("#?",r))return Tu(e,r);if(e.startsWith("#_",r)){let i=Kt(e,r+2);return i?{form:{type:"atom",text:"",start:r,end:i.index},index:i.index}:null}for(;un(e[r]);)r+=1;let n=e[r];return n?n==="("?mn(e,r,"list",")"):n==="["?mn(e,r,"vector","]"):n==="{"?mn(e,r,"map","}"):n==='"'?{form:{type:"atom",text:"",start:r,end:ct(e,r,0).index},index:ct(e,r,0).index}:Ru(e,r):null}function Tu(e,t){let r=e.startsWith("#?@",t)?3:2,n=Kt(e,t+r);return n?{form:{type:"list",children:n.form.type==="list"||n.form.type==="vector"||n.form.type==="map"?wu(n.form.children):[],start:t,end:n.index},index:n.index}:null}function wu(e){let t=[];for(let r=0;r<e.length;r+=2){let n=M(e[r]),i=e[r+1];n?.startsWith(":")&&i&&t.push(i)}return t}function mn(e,t,r,n){let i=[],o=t+1;for(;o<e.length;){if(o=Sn(e,o),e[o]===n)return{form:{type:r,children:i,start:t,end:o+1},index:o+1};let s=Kt(e,o);if(!s){o+=1;continue}s.form.type==="atom"&&s.form.text===""||i.push(s.form),o=s.index}return{form:{type:r,children:i,start:t,end:e.length},index:e.length}}function Ru(e,t){let r=t;for(;r<e.length&&!dn(e[r]);)r+=1;return{form:{type:"atom",text:e.slice(t,r),start:t,end:r},index:r}}function Sn(e,t){let r=t;for(;r<e.length;){let n=e[r];if(/\s|,/.test(n)){r+=1;continue}if(n===";"){r=Jt(e,r);continue}break}return r}function qo(e){return e.replace(/[^\r\n]/g," ")}function Xo(e,t,r){let n=[];for(let i of r.matchAll(/^[ \t]*import\s+['"]([^'"]+)['"](?:\s+as\s+([A-Za-z_]\w*))?[\s\S]*?;$/gm)){let o=i[1]?.trim(),s=i[2]?.trim()??null,a=i[0];if(!o||!a||typeof i.index!="number")continue;let c=se(r,i.index,i.index+a.length);n.push({importedName:o,localName:s,sourcePath:Wt(e,t,o),kind:s?"namespace":"side-effect",used:s?w(c,s):!0,usedMembers:s?Oe(c,s):[]})}return n}function Yo(e,t,r){let n=[];for(let i of r.matchAll(/^[ \t]*export\s+['"]([^'"]+)['"][\s\S]*?;$/gm)){let o=i[1]?.trim();o&&n.push({specifier:o,sourcePath:Wt(e,t,o)})}return n}function Ko(e,t,r){return Xt(e,t,{csharp:n=>Cu(e,t,n),vb:n=>ku(e,t,n)},()=>{let n=So(t)?/^[ \t]*Imports\s+(.+?)\s*$/gm:/^[ \t]*using\s+(.+?)\s*;$/gm;return L(r,n,(i,o)=>{let s=i[1]?.trim();if(!s)return[];let[a,c]=s.split(/\s*=\s*/),l=!!c,p=(l?c:a)?.trim()??s,u=p.split(".").pop()??p,d=l?a?.trim()??u:u;return[B(e,t,o,p,u,d,h(e,p,ne))]})})}function ku(e,t,r){let n=S(r,new Set(["imports_statement"])),i=[];for(let o of r.rootNode.descendantsOfType("imports_statement")){let s=o.namedChildren.filter(d=>d.type==="namespace_name");if(s.length===0)continue;let a=s[s.length-1],c=s.length>1?s[0]:null,l=a.text,p=l.split(".").pop()??l,u=c?.text??p;i.push(g(p,u,h(e,l,ne),n,c?"namespace":"named"))}return i}function Cu(e,t,r){let n=S(r,new Set(["using_directive"])),i=[];for(let o of r.rootNode.descendantsOfType("using_directive")){let s=o.namedChildren;if(s.length===0)continue;let a=null,c;s.length>=2&&s[0].type==="identifier"&&(s[1].type==="qualified_name"||s[1].type==="identifier")?(a=s[0],c=s[1]):c=s[s.length-1];let l=c.text,p=l.split(".").pop()??l,u=a?.text??p;i.push(g(p,u,h(e,l,ne),n,a?"namespace":"named"))}return i}var Nu=b("vue-non-script-identifiers",{clearGroups:["whole-project","source-file"]});function Qo(e,t){return Nu.get(e,t,()=>{let r=new Set,n=_(e,t);if(!n)return r;let o=n.replace(/<script\b[^>]*>[\s\S]*?<\/script>/g,s=>s.replace(/[^\r\n]/g," ")).replace(/<!--[\s\S]*?-->/g,s=>s.replace(/[^\r\n]/g," ")).replace(/\/\*[\s\S]*?\*\//g,s=>s.replace(/[^\r\n]/g," "));for(let s of o.matchAll(/[A-Za-z_$][\w$]*/g))r.add(s[0]);return r})}function xn(e,t,r){return j(e,t,n=>Du(e,t,n),()=>Pu(e,t,r))}function Pu(e,t,r){return Bu(r).flatMap(n=>Vu(e,t,n.clause,n.specifier,n.start,n.end,r))}function Du(e,t,r){let n=_u(e,t,r),i=[];for(let o of r.rootNode.descendantsOfType("import_statement"))i.push(...Au(e,t,r,o,n));return i}function _u(e,t,r){let n=S(r,new Set(["import_statement"]));if(xe(t))for(let i of Qo(e,t))n.add(i);return n}function Au(e,t,r,n,i){let o=Mu(n);if(!o)return[];let s=ie(e,t,o),a=A(n,"import_clause");return a?Fu(r,a,s,i,$u(n.text)):[Ie("*",s)]}function Fu(e,t,r,n,i){let o=[];for(let s of t.namedChildren)if(s.type==="identifier")o.push(Ou(s.text,r,n,i));else if(s.type==="namespace_import"){let a=Lu(e,s,r,n,i);a&&o.push(a)}else s.type==="named_imports"&&o.push(...ju(s,r,n,i));return o}function Ou(e,t,r,n){return g("default",e,t,r,"default",{isTypeOnly:n})}function Lu(e,t,r,n,i){let s=A(t,"identifier")?.text??"";if(!s)return null;let a=Wu(e,s);return Ee("*",r,{localName:s,usedMembers:a,isTypeOnly:i,used:a.length>0||n.has(s)})}function ju(e,t,r,n){let i=[];for(let o of e.namedChildren){if(o.type!=="import_specifier")continue;let s=o.namedChild(0),a=o.namedChild(1);if(!s)continue;let c=s.text,l=a?.text??c;i.push(g(c,l,t,r,"named",{isTypeOnly:n||Gu(o.text)}))}return i}function Mu(e){let t=A(e,"string");if(!t)return null;let r=A(t,"string_fragment");return r?r.text:null}function $u(e){return/^\s*import\s+type\b/.test(e)}function Gu(e){return/^\s*type\b/.test(e.trim())}function Wu(e,t){let r=new Set;for(let n of e.rootNode.descendantsOfType("member_expression")){let i=n.namedChild(0),o=n.namedChild(1);!i||!o||i.type!=="identifier"||i.text!==t||(o.type==="property_identifier"||o.type==="identifier")&&r.add(o.text)}return[...r]}function Bu(e){let t=[],r=/^[ \t]*import\s+([\s\S]*?)\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let i of e.matchAll(r)){let o=i[0],s=i[1],a=i[2];!o||!a||typeof i.index!="number"||t.push({clause:s,specifier:a,start:i.index,end:i.index+o.length})}let n=/^[ \t]*import\s+['"]([^'"]+)['"]\s*;?/gm;for(let i of e.matchAll(n)){let o=i[0],s=i[1];!o||!s||typeof i.index!="number"||t.push({clause:null,specifier:s,start:i.index,end:i.index+o.length})}return t.sort((i,o)=>i.start-o.start)}function Vu(e,t,r,n,i,o,s){let a=ie(e,t,n),c=se(s,i,o);return r?Uu(r).map(p=>({...p,sourcePath:a})).map(p=>{if(p.kind==="namespace"){let u=Oe(c,p.localName);return Ee(p.importedName,p.sourcePath,{localName:p.localName,usedMembers:u,used:u.length>0||w(c,p.localName),isTypeOnly:p.isTypeOnly})}return p.kind==="side-effect"?Ie(p.importedName,p.sourcePath):Y(p.importedName,p.localName??"",p.sourcePath,p.localName?w(c,p.localName):!1,p.kind,[],{isTypeOnly:p.isTypeOnly})}):[Ie("*",a)]}function Uu(e){let t=e.trim(),r=/^type\b/.test(t),n=t.replace(/^type\s+/,""),[i,o]=Hu(n),s=[];return i&&s.push(...Zo(i,r)),o&&s.push(...Zo(o,r)),s}function Zo(e,t){let r=e.trim();if(!r)return[];if(r.startsWith("{")){let n=r.slice(1,-1).trim();return n?R(n).map(i=>{let o=i.trim(),s=t||/^type\b/.test(o),a=o.replace(/^type\s+/,""),[c,l]=a.split(/\s+as\s+/);return{importedName:c.trim(),localName:(l??c).trim(),kind:"named",isTypeOnly:s}}):[]}return r.startsWith("* as ")?[{importedName:"*",localName:r.slice(5).trim(),kind:"namespace",isTypeOnly:t}]:[{importedName:"default",localName:r,kind:"default",isTypeOnly:t}]}function Hu(e){let t=0;for(let r=0;r<e.length;r++){let n=e[r];if(n==="{"&&t++,n==="}"&&t--,n===","&&t===0)return[e.slice(0,r).trim(),e.slice(r+1).trim()]}return[e.trim(),null]}function bn(e,t,r){let n=U(e,t);return n?Ku(e,t,n):zu(e,t,r)}function zu(e,t,r){return[...qu(e,t,r),...Ju(e,t,r),...Xu(e,t,r)]}function qu(e,t,r){let n=[],i=/^[ \t]*export\s+(?:type\s+)?\{([\s\S]*?)\}\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let o of r.matchAll(i)){if(typeof o.index!="number")continue;let s=o[1]??"",a=o[2]??"",c=R(s).map(u=>Yu(u.trim())).filter(u=>!!u),l=Le(r,o.index),p=Le(r,o.index+o[0].length-1);n.push({kind:"named",sourcePath:ie(e,t,a),names:c,startLine:l,endLine:p})}return n}function Ju(e,t,r){let n=[],i=/^[ \t]*export\s+\*\s+as\s+(\w+)\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let o of r.matchAll(i)){if(typeof o.index!="number")continue;let s=o[2]??"",a=Le(r,o.index),c=Le(r,o.index+o[0].length-1);n.push({kind:"star-as",sourcePath:ie(e,t,s),names:[],startLine:a,endLine:c})}return n}function Xu(e,t,r){let n=[],i=/^[ \t]*export\s+\*\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let o of r.matchAll(i)){if(typeof o.index!="number")continue;let s=o[1]??"",a=Le(r,o.index),c=Le(r,o.index+o[0].length-1);n.push({kind:"star",sourcePath:ie(e,t,s),names:[],startLine:a,endLine:c})}return n}function Yu(e){if(!e)return null;let t=e.replace(/^type\s+/,"").trim();if(!t)return null;let r=t.match(/^(\w+)\s+as\s+(\w+)$/);if(r)return r[2]??null;let n=t.match(/^(\w+)$/);return n?n[1]??null:null}function Le(e,t){let r=0;for(let n=0;n<t&&n<e.length;n++)e.charCodeAt(n)===10&&r++;return r}function Ku(e,t,r){let n=[];for(let i of r.rootNode.descendantsOfType("export_statement")){let o=Qu(e,t,i);if(o===void 0)continue;let s=i.startPosition.row,a=i.endPosition.row,c=Zu(i,o,s,a);n.push(c)}return n}function Qu(e,t,r){let n=A(r,"string");if(!n)return;let i=A(n,"string_fragment");if(i)return ie(e,t,i.text)}function Zu(e,t,r,n){let i=A(e,"export_clause");if(i){let s=[];for(let a of i.namedChildren){if(a.type!=="export_specifier")continue;let c=a.namedChild(0),l=a.namedChild(1);c&&s.push((l??c).text)}return{kind:"named",sourcePath:t,names:s,startLine:r,endLine:n}}return A(e,"namespace_export")?{kind:"star-as",sourcePath:t,names:[],startLine:r,endLine:n}:{kind:"star",sourcePath:t,names:[],startLine:r,endLine:n}}function es(e,t,r){return Xt(e,t,{java:n=>ed(e,t,n),kotlin:n=>td(e,t,n),scala:n=>rd(e,t,n)},()=>L(r,/^[ \t]*import\s+(?:static\s+)?(.+?)\s*;?$/gm,(n,i)=>{let o=n[1]?.trim();return o?nd(e,t,o,i):[]}))}function ed(e,t,r){let n=S(r,new Set(["import_declaration"])),i=[];for(let o of r.rootNode.descendantsOfType("import_declaration")){let s=o.children.some(u=>u.type==="asterisk"),c=o.namedChildren.find(u=>u.type==="scoped_identifier")??o.namedChildren.find(u=>u.type==="identifier");if(!c)continue;let l=c.text;if(s){i.push(Ee("*",h(e,l,D)));continue}let p=l.split(".").pop()??l;i.push(g(p,p,h(e,l,D),n))}return i}function td(e,t,r){let n=S(r,new Set(["import_header","import_list"])),i=[];for(let o of r.rootNode.descendantsOfType("import_header")){let s=o.namedChildren.find(m=>m.type==="identifier");if(!s)continue;let a=o.namedChildren.some(m=>m.type==="wildcard_import"),c=o.namedChildren.find(m=>m.type==="import_alias");if(a){i.push(Ee("*",h(e,s.text,D)));continue}let l=s.text,p=l.split(".").pop()??l,d=c?.namedChild(0)?.text??p;i.push(g(p,d,h(e,l,D),n))}return i}function rd(e,t,r){let n=S(r,new Set(["import_declaration"])),i=[];for(let o of r.rootNode.descendantsOfType("import_declaration")){let s=o.namedChildren.find(u=>u.type==="namespace_selectors"||u.type==="namespace_wildcard"),a=o.namedChildren.filter(u=>u!==s&&(u.type==="identifier"||u.type==="stable_identifier")),c=a.map(u=>u.text).join(".");if(!c)continue;if(s?.type==="namespace_wildcard"){i.push(Ee("*",h(e,c,D)));continue}if(s?.type==="namespace_selectors"){for(let u of s.namedChildren)if(u.type==="arrow_renamed_identifier"){let[d,m]=u.namedChildren;if(!d)continue;let y=d.text,ve=m?.text??y;if(y==="_")continue;i.push(g(y,ve,h(e,`${c}.${y}`,D),n))}else if(u.type==="identifier"){let d=u.text;i.push(g(d,d,h(e,`${c}.${d}`,D),n))}continue}let l=a[a.length-1]?.text??c,p=a.slice(0,-1).map(u=>u.text).join(".")||c;i.push(g(l,l,h(e,p&&a.length>1?`${p}.${l}`:c,D),n))}return i}function nd(e,t,r,n){if(r.includes("{")&&r.includes("}")){let i=r.slice(0,r.indexOf("{")).replace(/\.$/,"").trim(),o=r.slice(r.indexOf("{")+1,r.lastIndexOf("}")).trim();return R(o).flatMap(s=>{let a=s.trim();if(!a)return[];let[c,l]=a.includes("=>")?a.split(/\s*=>\s*/):a.split(/\s+as\s+/),p=c?.trim();if(!p||p==="_")return[];let u=(l??p.split(".").pop()??p).trim(),d=p==="_"?i:`${i}.${p}`.replace(/\.\./g,".");return[B(e,t,n,d,p,u)]})}return[B(e,t,n,r,r.split(".").pop()??r,r.split(".").pop()??r)]}function rs(e,t,r){return j(e,t,n=>id(e,t,n),()=>L(r,/^[ \t]*use\s+(.+?)\s*;$/gm,(n,i)=>{let o=n[1]?.trim();return o?R(o).flatMap(s=>{let a=s.trim();if(!a)return[];let[c,l]=a.split(/\s+as\s+/i),p=c?.trim()??a,u=p.split("\\").pop()??p,d=(l??u).trim();return[B(e,t,i,p,u,d,h(e,p.replace(/\\/g,"."),ye))]}):[]}))}function id(e,t,r){let n=S(r,new Set(["namespace_use_declaration"])),i=[],o=(s,a,c)=>{i.push(g(a,c,h(e,s.replace(/\\/g,"."),ye),n))};for(let s of r.rootNode.descendantsOfType("namespace_use_declaration")){let a=s.namedChildren.find(c=>c.type==="namespace_use_group");if(a){let c=s.namedChildren.find(l=>l.type==="namespace_name")?.text??"";for(let l of a.namedChildren){if(l.type!=="namespace_use_clause")continue;let{importedName:p,localName:u,qualified:d}=ts(l,c);p&&o(d,p,u)}continue}for(let c of s.namedChildren){if(c.type!=="namespace_use_clause")continue;let{importedName:l,localName:p,qualified:u}=ts(c,"");l&&o(u,l,p)}}return i}function ts(e,t){let r=e.namedChildren.find(l=>l.type==="qualified_name"),n=e.namedChildren.filter(l=>l.type==="name"),i="";r?i=r.text:n.length>=1&&(i=n[0].text);let o=r&&n.length>0?n[n.length-1]:null,s=i.split("\\").pop()??i,a=o?.text??s,c=t?`${t}\\${i}`:i;return{importedName:s,localName:a,qualified:c}}function is(e,t,r){return j(e,t,n=>od(e,t,n),()=>ad(r).flatMap(n=>ld(e,t,n,r)))}function od(e,t,r){let n=S(r,new Set(["import_statement","import_from_statement"])),i=[];for(let o of r.rootNode.descendantsOfType("import_statement"))for(let s of o.namedChildren){let a=ns(s);if(!a)continue;let c=Fe(e,t,a.qualifiedName);i.push({importedName:a.qualifiedName,localName:a.localName,sourcePath:c,kind:"namespace",used:n.has(a.localName),usedMembers:[]})}for(let o of r.rootNode.descendantsOfType("import_from_statement")){let s=o.namedChild(0);if(!s)continue;let a=sd(s);if(a===null)continue;let c=Fe(e,t,a);for(let l=1;l<o.namedChildCount;l+=1){let p=o.namedChild(l);if(p.type==="wildcard_import"){i.push({importedName:"*",localName:null,sourcePath:c,kind:"side-effect",used:!0,usedMembers:[]});continue}let u=ns(p);u&&i.push({importedName:u.qualifiedName,localName:u.localName,sourcePath:c,kind:"named",used:n.has(u.localName),usedMembers:[]})}}return i}function ns(e){if(e.type==="aliased_import"){let t=e.namedChild(0),r=e.namedChild(1);return!t||!r?null:{qualifiedName:t.text,localName:r.text}}if(e.type==="dotted_name"){let t=e.text;return{qualifiedName:t,localName:t.split(".")[0]??t}}return e.type==="identifier"?{qualifiedName:e.text,localName:e.text}:null}function sd(e){if(e.type==="dotted_name")return e.text;if(e.type==="relative_import"){let t=A(e,"import_prefix")?.text??"",r=A(e,"dotted_name")?.text??"";return`${t}${r}`}return null}function ad(e){let t=e.split(`
|
|
120
|
+
`),r=[],n=0;for(let i=0;i<t.length;i++){let o=t[i],s=o.trimStart(),a=n;if(n+=o.length+1,!s.startsWith("import ")&&!s.startsWith("from "))continue;let c=o,l=a+o.length,p=sn(o);for(;i+1<t.length&&(p>0||c.trimEnd().endsWith("\\"));){i++;let d=t[i];c+=`
|
|
121
|
+
${d}`,l+=1+d.length,p+=sn(d),n+=d.length+1}let u=cd(c);u&&r.push({...u,start:a,end:l})}return r}function cd(e){let t=e.replace(/\\\s*\n/g," ").trim();if(t.startsWith("import "))return{kind:"import",module:null,clause:t.slice(7).trim()};let r=t.match(/^from\s+([.\w]+)\s+import\s+([\s\S]+)$/);if(!r)return null;let n=r[2].trim();return n.startsWith("(")&&n.endsWith(")")&&(n=n.slice(1,-1).trim()),{kind:"from",module:r[1],clause:n}}function ld(e,t,r,n){let i=se(n,r.start,r.end),o=r.clause.replace(/\n/g," ").trim();if(r.kind==="import")return R(o).flatMap(c=>{let l=c.trim().replace(/,$/,"");if(!l)return[];let[p,u]=l.split(/\s+as\s+/),d=p.trim(),m=(u??d.split(".")[0]??d).trim(),y=Fe(e,t,d),ve=Oe(i,m);return[{importedName:d,localName:m,sourcePath:y,kind:"namespace",used:w(i,m)||ve.length>0,usedMembers:ve}]});let s=r.module?Fe(e,t,r.module):null,a=[];for(let c of R(o)){let l=c.trim().replace(/,$/,"");if(!l)continue;if(l==="*"){a.push({importedName:"*",localName:null,sourcePath:s,kind:"side-effect",used:!0,usedMembers:[]});continue}let[p,u]=l.split(/\s+as\s+/),d=(u??p).trim();a.push({importedName:p.trim(),localName:d,sourcePath:s,kind:"named",used:w(i,d),usedMembers:[]})}return a}import{basename as pd}from"path";function os(e,t,r){return j(e,t,n=>dd(e,t,n),()=>ud(e,t,r))}function ud(e,t,r){return L(r,/^[ \t]*(require_relative|require)\s+["']([^"']+)["']\s*$/gm,(n,i)=>{let o=n[1],s=n[2];if(!o||!s)return[];let a=o==="require_relative"?$t(e,t,s):null;if(a){let c=ss(s);return[Y(c,c,a,w(i,c))]}return[Ie(s,a)]})}function dd(e,t,r){let n=S(r,new Set([])),i=[],o=new Set(["require","require_relative","load"]);for(let s of r.rootNode.descendantsOfType("call")){let a=s.namedChild(0);if(!a||a.type!=="identifier"||!o.has(a.text))continue;let l=s.namedChildren.find(m=>m.type==="argument_list")?.namedChild(0);if(!l||l.type!=="string")continue;let u=l.namedChildren.find(m=>m.type==="string_content")?.text;if(!u)continue;let d=a.text==="require_relative"?$t(e,t,u):null;if(d){let m=ss(u);i.push(g(m,m,d,n))}else i.push(Ie(u,d))}return i}function ss(e){return Uo(pd(e).replace(/\.[^.]+$/,""),/_/)}function as(e,t,r){return j(e,t,n=>fd(e,t,n),()=>L(r,/^[ \t]*use\s+(.+?)\s*;$/gm,(n,i)=>{let o=n[1]?.trim();return o?md(e,t,o,i):[]}))}function fd(e,t,r){let n=S(r,new Set(["use_declaration"])),i=[];for(let o of r.rootNode.descendantsOfType("use_declaration")){let s=o.namedChild(0);if(s)for(let a of lt(s,"")){if(!a.importedName||a.importedName==="*")continue;let c=J(e,t,a.qualifiedName)??J(e,t,a.qualifiedName.split("::").slice(0,-1).join("::"));i.push(g(a.importedName,a.localName,c,n))}}return i}function lt(e,t){switch(e.type){case"identifier":case"super":case"crate":{let r=e.text;return[{qualifiedName:Qt(t,r),importedName:r,localName:r}]}case"self":{let r=t.split("::").filter(Boolean).pop()??"self";return[{qualifiedName:t||"self",importedName:r,localName:r}]}case"scoped_identifier":{let r=e.text,n=r.split("::").pop()??r;return[{qualifiedName:Qt(t,r),importedName:n,localName:n}]}case"scoped_use_list":{let r=e.namedChild(0),n=e.namedChild(1);if(!r||!n)return[];let i=Qt(t,r.text),o=[];for(let s of n.namedChildren)o.push(...lt(s,i));return o}case"use_list":{let r=[];for(let n of e.namedChildren)r.push(...lt(n,t));return r}case"use_as_clause":{let r=e.namedChild(0),n=e.namedChild(1);if(!r||!n)return[];let i=lt(r,t),o=n.text;return i.map(s=>({...s,localName:o}))}case"use_wildcard":{let r=e.namedChild(0),n=r?r.text:"";return[{qualifiedName:Qt(t,`${n}::*`),importedName:"*",localName:"*"}]}default:return[]}}function Qt(e,t){return e?t?`${e}::${t}`:e:t}function md(e,t,r,n){let i=r.trim();if(i.includes("{")&&i.includes("}")){let p=i.slice(0,i.indexOf("{")).replace(/::$/,"").trim(),u=i.slice(i.indexOf("{")+1,i.lastIndexOf("}")).trim();return R(u).flatMap(d=>{let m=d.trim();if(!m)return[];if(m==="self"){let Zt=p.split("::").filter(Boolean).pop();return Zt?[B(e,t,n,p,Zt,Zt)]:[]}let[y,ve]=m.split(/\s+as\s+/),Te=y?.trim();if(!Te)return[];let ds=(ve??Te.split("::").pop()??Te).trim(),fs=`${p}::${Te}`.replace(/::::/g,"::");return[B(e,t,n,fs,Te.split("::").pop()??Te,ds,J(e,t,p))]})}let[o,s]=i.split(/\s+as\s+/),a=o?.trim()??i,c=(s??a.split("::").pop()??a).trim(),l=J(e,t,a)??J(e,t,a.split("::").slice(0,-1).join("::"));return[B(e,t,n,a,a.split("::").pop()??a,c,l)]}function cs(e,t,r){let n=U(e,t);if(n)return gd(e,t,n);let i=[];for(let o of r.matchAll(/^[ \t]*pub\s+use\s+(.+?)\s*;$/gm)){let s=o[1]?.trim();s&&i.push(...hd(e,t,s))}return i}function gd(e,t,r){let n=[];for(let i of r.rootNode.descendantsOfType("use_declaration")){if(!yd(i))continue;let o=i.namedChildren.find(s=>s.type!=="visibility_modifier");if(o)for(let s of lt(o,""))s.importedName&&n.push(In(e,t,s.qualifiedName))}return n}function yd(e){for(let t of e.children)if(t.type==="visibility_modifier"&&t.text.startsWith("pub"))return!0;return!1}function hd(e,t,r){let n=r.trim();if(n.includes("{")&&n.includes("}")){let i=n.slice(0,n.indexOf("{")).replace(/::$/,"").trim(),o=n.slice(n.indexOf("{")+1,n.lastIndexOf("}")).trim();return R(o).flatMap(s=>{let a=s.trim();if(!a||a==="self")return[];let[c]=a.split(/\s+as\s+/),l=`${i}::${c?.trim()??a}`.replace(/::::/g,"::");return[In(e,t,l)]})}return[In(e,t,n)]}function In(e,t,r){return{specifier:r,sourcePath:J(e,t,r)??J(e,t,r.split("::").slice(0,-1).join("::"))}}function ae({language:e,extensions:t,imports:r,parseImports:n}){return{language:e,extensions:t,capabilities:{imports:r},parseImports:n}}function ls(e,t){let r=t.toLowerCase();for(let n of e)for(let i of n.extensions)if(r.endsWith(i))return n;return null}var Sd={language:"javascript",extensions:me,capabilities:{imports:"ast-with-regex-fallback",reExports:"ast-with-regex-fallback"},parseImports:xn,parseReExports:bn},xd=ae({language:"python",extensions:Ft,imports:"ast-with-regex-fallback",parseImports:is}),bd=ae({language:"jvm",extensions:D,imports:"ast-dispatch-with-regex-fallback",parseImports:es}),Id={language:"rust",extensions:Ot,capabilities:{imports:"ast-with-regex-fallback",exports:"ast-with-regex-fallback"},parseImports:as,parseExports:cs},Ed=ae({language:"ruby",extensions:Lt,imports:"ast-with-regex-fallback",parseImports:os}),vd=ae({language:"c/cpp",extensions:jt,imports:"ast-with-regex-fallback",parseImports:zo}),Td=ae({language:"dotnet",extensions:ne,imports:"ast-dispatch-with-regex-fallback",parseImports:Ko}),wd={language:"dart",extensions:Mt,capabilities:{imports:"regex-only",exports:"regex-only"},parseImports:Xo,parseExports:Yo},Rd=ae({language:"php",extensions:ye,imports:"ast-with-regex-fallback",parseImports:rs}),kd=ae({language:"clojure",extensions:Ae,imports:"regex-only",parseImports:Jo}),Cd=[Sd,xd,bd,Id,Ed,vd,Td,wd,Rd,kd];function En(e){return ls(Cd,e)}var vn={clearGroups:["whole-project","source-file"]},Nd=b("source-imports",vn),mS=b("source-exports",vn),Pd=b("source-reexports",vn),ps=tt({kind:"source-imports",invalidation:rt("source-imports"),serialize:Dd,deserialize:_d}),us=tt({kind:"source-reexports",invalidation:rt("source-reexports"),serialize:Ad,deserialize:Fd});function gS(e,t){let r=T(t);return Pd.get(e,r,()=>{let n=En(r);if(!n?.parseReExports)return[];let i=_(e,r);if(!i)return[];let o=je(e,r,i),s=on(e),a=us.read(e,r,o);if(a?.resolutionFingerprint===s)return a.reExports;let c=n.parseReExports(e,r,i);return us.write(e,r,o,{resolutionFingerprint:s,reExports:c}),c})}function yS(e,t){let r=T(t);return Nd.get(e,r,()=>{let n=En(r);if(!n)return[];let i=_(e,r);if(!i)return[];let o=je(e,r,i),s=on(e),a=ps.read(e,r,o);if(a?.resolutionFingerprint===s)return a.imports;let c=n.parseImports(e,r,i);return ps.write(e,r,o,{resolutionFingerprint:s,imports:c}),c})}function Dd(e){return JSON.stringify(e)}function _d(e){try{let t=JSON.parse(e);return!yr(t)||typeof t.resolutionFingerprint!="string"||!Array.isArray(t.imports)?null:{resolutionFingerprint:t.resolutionFingerprint,imports:t.imports}}catch{return null}}function Ad(e){return JSON.stringify(e)}function Fd(e){try{let t=JSON.parse(e);return!yr(t)||typeof t.resolutionFingerprint!="string"||!Array.isArray(t.reExports)?null:{resolutionFingerprint:t.resolutionFingerprint,reExports:t.reExports}}catch{return null}}export{jn as a,pa as b,ua as c,ff as d,ft as e,le as f,Hn as g,ur as h,Jn as i,ht as j,je as k,Yn as l,kf as m,tt as n,ug as o,rt as p,_ as q,Gg as r,U as s,tu as t,cu as u,mg as v,po as w,Tl as x,ie as y,yr as z,Nf as A,he as B,gS as C,yS as D,jd as E,Md as F,$d as G,Gd as H,N as I,ul as J,yg as K,fl as L,xg as M,bg as N,Ig as O,vg as P,Ff as Q,$f as R,Hf as S,zf as T,_s as U,Ud as V,Hd as W,zd as X,qd as Y,An as Z,sr as _,cr as $,Zd as aa,rm as ba,nm as ca,im as da,om as ea,dm as fa,fm as ga,mm as ha,gm as ia,Oi as ja,Im as ka,_r as la,Jm as ma,Xm as na,Ym as oa,Ye as pa,Km as qa,Qm as ra,Zm as sa,Uc as ta,Hc as ua,ig as va,og as wa,Xs as xa,of as ya,sf as za,af as Aa};
|
|
122
|
+
//# sourceMappingURL=chunk-5GCAM4JE.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as g}from"./chunk-SJ6XSCG7.js";import{h as p}from"./chunk-
|
|
1
|
+
import{a as g}from"./chunk-SJ6XSCG7.js";import{h as p}from"./chunk-XAMVIPE2.js";import{a as f}from"./chunk-HFBNIIZX.js";import{d as u,e as _,i as N}from"./chunk-AYRHVJXW.js";import{p as d}from"./chunk-GAE7WCBK.js";import{B as l,b as c}from"./chunk-WAU7HVDI.js";import{y as b}from"./chunk-FC5K7T35.js";import{a as I}from"./chunk-64MNV6AB.js";function Y(e,t,r={}){return T(e,t,r)?.map(s=>({symbol:s.symbol,shortName:s.shortName,fromFile:s.fromFile}))??[]}function Z(e,t){let r=f(e,t),s=O(e,t);if(s.length>0&&!x(r))return s;let o=k(e,t,r);return h(t)&&o.length>0?o:D([...s,...o])}function G(e,t,r={}){let s=g(e,t);if(!s)return[];let o=S(e,s),n=r.semantic===!1?null:E(e,s);return(n?R(n,o):o).filter(m=>!m.used).map(m=>({symbol:m.symbol,shortName:m.shortName,importedIn:m.importer}))}function R(e,t){let r=new Map;for(let o of t){let n=r.get(o.shortName);n?n.push(o):r.set(o.shortName,[o])}let s=e.map(o=>{let n=r.get(o.shortName),i=n?.shift();return n?.length===0&&r.delete(o.shortName),i?{...o,used:o.used||i.used}:o});return s.push(...[...r.values()].flat()),s}function O(e,t){return e.all(`SELECT DISTINCT gs.symbol, d.relative_path AS importer
|
|
2
2
|
FROM mentions m
|
|
3
3
|
JOIN chunks c ON m.chunk_id = c.id
|
|
4
4
|
JOIN documents d ON c.document_id = d.id
|
|
@@ -32,4 +32,4 @@ import{a as g}from"./chunk-SJ6XSCG7.js";import{h as p}from"./chunk-US44MEVU.js";
|
|
|
32
32
|
WHERE imp_d.relative_path = ?
|
|
33
33
|
AND m.role = 2
|
|
34
34
|
ORDER BY def_d.relative_path, gs.symbol`,t).filter(n=>!e.isIgnored(n.importer));if(o.length>0){let n=r.semantic===!1?[]:p(e,t);return o.map(i=>({symbol:i.symbol,shortName:u(i.symbol),fromFile:i.from_file??"(external)",importer:i.importer,used:i.used!==0||n.some(m=>m.isUsed&&m.sourcePath===i.from_file)}))}return null}function E(e,t){let r=p(e,t);return r.length>0?r.map(s=>{let o=y(s.importedName,s.localName,s.kind);return{symbol:o,shortName:o,fromFile:s.sourcePath??"(external)",importer:t,used:s.kind==="side-effect"?!0:s.isUsed}}):null}function S(e,t){let r=A(t,b(e,t));return d(e,t).map(s=>{let o=y(s.importedName,s.localName,s.kind),n=s.kind==="side-effect"||v(t,s)||r.has(s.localName??s.importedName)?!0:s.used;return{symbol:o,shortName:o,fromFile:s.sourcePath??"(external)",importer:t,used:n}})}function A(e,t){let r=new Set;if(l(e)!=="python")return r;let s=/(?:^|\n)\s*__all__\s*(?:\+?=)\s*[[(]([\s\S]*?)[\])]/g;for(let o of t.matchAll(s)){let n=o[1]??"";for(let i of n.matchAll(/(['"])([A-Za-z_]\w*)\1/g))r.add(i[2])}return r}function v(e,t){if(l(e)!=="rust"||t.used||t.kind==="side-effect")return!1;let r=t.localName??t.importedName;return r==="_"||/^[A-Z]/.test(r)}function y(e,t,r){return r==="namespace"&&e==="*"&&t?`* as ${t}`:r==="default"&&t?`default as ${t}`:r==="side-effect"?"(side effect import)":t&&t!==e?`${e} as ${t}`:e}function $(e){return/\.(?:c|h|cc|cpp|cxx|hpp|hh|hxx)$/i.test(e)}export{Y as a,Z as b,G as c};
|
|
35
|
-
//# sourceMappingURL=chunk-
|
|
35
|
+
//# sourceMappingURL=chunk-5OR4QRPR.js.map
|