@omfalos/mokosh 0.1.9 → 0.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.mjs CHANGED
@@ -1,39 +1,40 @@
1
1
  #!/usr/bin/env node
2
- var at=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var m=(t,e)=>()=>(t&&(e=t(t=0)),e);var ra=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);import sa from"path";import{fileURLToPath as na}from"url";var oa,ia,f,c=m(()=>{"use strict";oa=()=>na(import.meta.url),ia=()=>sa.dirname(oa()),f=ia()});function Fe(t){Vr.push(t)}function Xr(t){return[...aa,...Vr].some(e=>typeof e=="string"?t.includes(e):e instanceof RegExp?e.test(t):e(t))}function Pe(t){qr.push(t)}function ne(){return[...ca,...qr]}function Te(t){Yr.push(t)}function ct(){return[...pa,...Yr]}function pt(t){Zr=t}function lt(){return Zr}var aa,Vr,ca,qr,pa,Yr,Zr,B=m(()=>{"use strict";c();aa=[".config.","biome.json","tsconfig.json","package.json",".prettierrc",".eslintrc"],Vr=[];ca=[".test.",".spec.","-test.","-spec."],qr=[];pa=["jest","vitest","playwright","cypress","@testing-library/"],Yr=[];Zr=.8});import ft from"fs";import es from"path";function J(t,{allowJs:e=!0,isExplicitPath:r=!1}={}){if(r){let s=es.resolve(t);return ft.existsSync(s)?s.endsWith(".json")?ts(s):e?rs(s):{}:{}}for(let s of la){let n=es.resolve(t,s);if(ft.existsSync(n)){if(s.endsWith(".json"))return ts(n);if(e)return rs(n)}}return{}}function ts(t){return JSON.parse(ft.readFileSync(t,"utf-8"))}function rs(t){let e=at(t);return e&&typeof e=="object"&&"default"in e&&(e=e.default),typeof e=="function"?e({}):e}function mt(t){for(let e of t.configMatchers??[])Fe(e);for(let e of t.testPatterns??[])Pe(e);for(let e of t.testLibraries??[])Te(e);t.barrelThreshold!==void 0&&pt(t.barrelThreshold)}function k(t){return{gitStats:t?.gitStats??!1,parallelParsing:t?.parallelParsing,pathAliases:t?.pathAliases}}var la,ut=m(()=>{"use strict";c();B();la=["mokosh.config.js","mokosh.config.cjs","mokosh.config.json"]});var gt,dt,ht=m(()=>{"use strict";c();gt=["node_modules",".git","dist","build",".next",".cache","mokosh-cache","coverage"],dt=[".ts",".tsx",".js",".jsx",".mjs",".cjs",".css",".scss",".sass",".less",".styl",".coffee",".ls",".lua",".py",".go",".feature",".md",".mdx"]});import ff from"fs";import uf from"path";var ss=m(()=>{"use strict";c()});var Ne,ns=m(()=>{"use strict";c();Ne={serialize(t){let e=["graph TD"],r=new Set;for(let s of t.nodes.values()){let n=`"${s.path}"`;for(let o of s.imports){if(!o.toPath)continue;let i=`"${o.toPath}"`,a=`${s.path} -> ${o.toPath}`;if(!r.has(a)){let p=o.isStyle?"-- styles -->":"-->";e.push(` ${n} ${p} ${i}`),r.add(a)}}}return e.join(`
3
- `)}}});var os=m(()=>{"use strict";c();ns()});import is from"fs";import ma from"path";function yt(t,e){let r=t.replace(/^\.\//,"");if(e.nodes.has(r))return r;let s=r.replace(/^dist\//,"src/").replace(/\.(js|mjs|cjs)$/,".ts");return e.nodes.has(s)?s:null}function as(t,e){if(typeof t=="string")return yt(t,e);if(t&&typeof t=="object"){let r=t;for(let s of["import","require","default"]){let n=as(r[s],e);if(n)return n}}return null}function ua(t){if(!t)return"unknown";let e=t.trimStart();return e.startsWith("interface ")?"interface":e.startsWith("class ")?"class":e.startsWith("enum ")?"enum":e.startsWith("type ")?"type":e.startsWith("namespace ")?"namespace":e.startsWith("const ")||e.startsWith("let ")||e.startsWith("var ")||e.startsWith("readonly ")?"const":e.startsWith("(")||e.startsWith("async ")||e.startsWith("function ")||e.includes("=>")?"function":"unknown"}function ga(t,e){let r=new Set,s=new Set,n=[...e];for(;n.length;){let o=n.shift();if(s.has(o))continue;s.add(o);let i=t.nodes.get(o);if(i){for(let a of i.exports)r.add(a.name);for(let a of i.imports){if(a.type!=="re-export"||a.isExternal||!a.toPath)continue;if(!a.symbols?.length||a.symbols.includes("*")){let l=t.nodes.get(a.toPath);if(l)for(let d of l.exports)r.add(d.name);n.push(a.toPath)}else for(let l of a.symbols)r.add(l)}}}return r}function xt(t,e){let r=[],s=ma.join(e,"package.json");if(is.existsSync(s))try{let n=JSON.parse(is.readFileSync(s,"utf8"));if(n.exports&&typeof n.exports=="object"&&!Array.isArray(n.exports))for(let o of Object.values(n.exports)){let i=as(o,t);i&&!r.includes(i)&&r.push(i)}else if(typeof n.exports=="string"){let o=yt(n.exports,t);o&&r.push(o)}if(r.length===0)for(let o of[n.main,n.module].filter(Boolean)){let i=yt(o,t);i&&!r.includes(i)&&r.push(i)}}catch{}if(r.length===0){for(let n of["src/index.ts","src/index.js","index.ts","index.js"])if(t.nodes.has(n)){r.push(n);break}}return r}function da(t,e){let r=new Set(e);for(let s of e)t.traverse(s,n=>(r.add(n.path),!0),{direction:"outgoing"});return r}function ha(t,e,r){let s=new Map;for(let n of e){if(r.includes(n))continue;let o=t.nodes.get(n);if(!o)continue;let i=o.category==="barrel";for(let a of o.exports){let p=s.get(a.name),l=!!(a.signature||a.doc);(!p||l&&!i)&&s.set(a.name,{file:n,symbol:a})}}return s}function ya(t,e,r,s){let n=[];for(let o of t){let i=e.get(o),a=s.flatMap(h=>r.nodes.get(h)?.exports??[]).find(h=>h.name===o),p=i?.symbol??a,l=i?.file??s.find(h=>r.nodes.get(h)?.exports.some(x=>x.name===o))??s[0],d={name:o,definedIn:l,kind:ua(p?.signature)};p?.doc&&(d.doc=p.doc),p?.signature&&(d.signature=p.signature),n.push(d)}return n.sort((o,i)=>o.name.localeCompare(i.name)),n}function xa(t,e,r){let s=p=>t.nodes.get(p)?.category==="test",n=[...e].filter(p=>!r.includes(p)&&!s(p)),o=[...t.nodes.keys()].filter(p=>!e.has(p)),i=o.filter(p=>!s(p)),a=o.filter(p=>s(p));return{internalFiles:n,unreachableFromEntry:i,testFiles:a}}function St(t,e){if(e.length===0)throw new Error("buildApiSurface requires at least one entry point");for(let l of e)if(!t.nodes.has(l))throw new Error(`Entry point not found in graph: ${l}`);let r=da(t,e),s=ha(t,r,e),n=ga(t,e),o=ya(n,s,t,e),{internalFiles:i,unreachableFromEntry:a,testFiles:p}=xa(t,r,e);return{entryPoints:e,publicExports:o,internalFiles:i,unreachableFromEntry:a,testFiles:p}}var bt=m(()=>{"use strict";c()});function Ct(t,e){let r=null,s=[];for(let o of t.nodes.values()){o.exports.some(i=>i.name===e)&&(r=o.path);for(let i of o.callEdges??[])i.to===e&&s.push({file:o.path,callerFunction:i.from})}let n=[];if(r){let o=t.nodes.get(r);for(let i of o?.callEdges??[])i.from===e&&n.push({file:i.toFile,calleeFunction:i.to})}return{functionName:e,definedIn:r,callers:s,callees:n}}var vt=m(()=>{"use strict";c()});import Tf from"fs";import If from"path";function cs(t){let e=[...t.nodes.entries()].sort(([s],[n])=>s.localeCompare(n)).map(([s,n])=>`${s}:${n.mtime}:${n.size}`).join("|"),r=2166136261;for(let s=0;s<e.length;s++)r^=e.charCodeAt(s),r=Math.imul(r,16777619)>>>0;return r.toString(16).padStart(8,"0")}function kt(t){let e=new Map;for(let r of t.nodes.keys()){let s=[];t.traverse(r,n=>(n.path!==r&&s.push(n.path),!0),{direction:"incoming"}),e.set(r,s)}return{impact:e,graphHash:cs(t)}}function wt(t,e){return t.impact.get(e)??[]}var Et=m(()=>{"use strict";c()});import Ie from"path";function Sa(t){let e=new Map;for(let[r,s]of t){let n=s.imports.filter(o=>o.toPath&&!o.isExternal).length;n>0&&e.set(r,n)}return e}function ba(t,e,r){let s=new Map;for(let[n,o]of e){if(o<r)continue;let i=t.get(n);if(!i||i.category==="test"||i.category==="barrel")continue;let a=Ie.extname(n),p=Ie.basename(n,a),l=p==="index"?Ie.basename(Ie.dirname(n)):p;s.set(n,{path:n,outDegree:o,tag:`feature:${l}`})}return s}function W(t,e){let r=e?.minOutDegree??5;return ba(t,Sa(t),r)}var Me=m(()=>{"use strict";c()});function va(t,e){let r=new Map;for(let s of e.values()){let n=new Set;t.traverse(s.path,o=>(o.path!==s.path&&n.add(o.path),!0),{direction:"outgoing"}),r.set(s.path,n)}return r}function ka(t,e,r,s){let n=new Map;for(let[o]of t){if(e.has(o))continue;let i=null;for(let a of e.values())r.get(a.path)?.has(o)&&(!i||s(a,i)<0)&&(i=a);i&&n.set(o,i.path)}return n}function wa(t,e){let r=new Map;for(let s of t.values()){let n=s.tag.replace("feature:",""),o=[];for(let[i,a]of e)a===s.path&&o.push(i);r.set(n,{hub:s.path,outDegree:s.outDegree,files:o})}return r}function Ea(t,e,r){let s=[];for(let n of t.keys())!e.has(n)&&!r.has(n)&&s.push(n);return s}function oe(t,e){let r=e?.detectFn??W,s=e?.hubComparator??Ca,n=r(t.nodes,e),o=va(t,n),i=ka(t.nodes,n,o,s);return{features:wa(n,i),unassigned:Ea(t.nodes,n,i)}}var Ca,De=m(()=>{"use strict";c();Me();Ca=(t,e)=>t.outDegree-e.outDegree});var ie,ps=m(()=>{"use strict";c();ie=class{constructor(e){this.nodes=e}nodes;findUnusedFiles(e){let r=new Set(this.nodes.keys());return e.filter(s=>!r.has(s))}findHighExportUsage(e){let r=[];for(let s of this.nodes.values()){if(s.maxExportUsage===void 0||s.maxExportUsage<e)continue;let n=s.imports.reduce((o,i)=>(i.exportUsageRatio??0)>(o?.exportUsageRatio??0)?i:o,null);r.push({path:s.path,maxExportUsage:s.maxExportUsage,tightestDep:n?.toPath??""})}return r.sort((s,n)=>n.maxExportUsage-s.maxExportUsage)}findCycles(){let e=[],r=new Set,s=new Set,n=[],o=i=>{r.add(i),s.add(i),n.push(i);let a=this.nodes.get(i);if(a){for(let p of a.imports)if(!(!p.toPath||p.isExternal))if(s.has(p.toPath)){let l=n.indexOf(p.toPath);e.push([...n.slice(l),p.toPath])}else r.has(p.toPath)||o(p.toPath)}s.delete(i),n.pop()};for(let i of this.nodes.keys())r.has(i)||o(i);return e}}});var P,ae=m(()=>{"use strict";c();ps();P=class t{constructor(e){this.nodes=e}nodes;_incomingEdgesCache=null;_callIncomingCache=null;serialize(){return{nodes:Array.from(this.nodes.values())}}static deserialize(e){let r=new Map;for(let s of e.nodes)r.set(s.path,s);return new t(r)}getIncomingEdgesMap(){if(this._incomingEdgesCache)return this._incomingEdgesCache;let e=new Map;for(let r of this.nodes.values())for(let s of r.imports)if(s.toPath){let n=e.get(s.toPath)||[];n.push(r.path),e.set(s.toPath,n)}return this._incomingEdgesCache=e,e}dfs(e,r,s,n){let o=new Set,i=s.maxDepth??1/0,a=(p,l,d)=>{if(l>i||o.has(p))return;let h=this.nodes.get(p);if(h&&(o.add(p),r(h,l,d)!==!1))for(let x of n(p))a(x,l+1,p)};a(e,0,null)}traverse(e,r,s={}){let n=s.direction??"outgoing",o=n==="incoming"?this.getIncomingEdgesMap():null;this.dfs(e,r,s,i=>n==="outgoing"?this.nodes.get(i)?.imports.map(a=>a.toPath).filter(Boolean)??[]:o?.get(i)??[])}getCallIncomingCache(){if(this._callIncomingCache)return this._callIncomingCache;let e=new Map;for(let r of this.nodes.values())for(let s of r.callEdges??[]){let n=e.get(s.toFile)??[];n.push(r.path),e.set(s.toFile,n)}return this._callIncomingCache=e,e}traverseCalls(e,r,s={}){let n=s.direction??"outgoing",o=n==="incoming"?this.getCallIncomingCache():null;this.dfs(e,r,s,i=>n==="outgoing"?this.nodes.get(i)?.callEdges?.map(a=>a.toFile)??[]:o?.get(i)??[])}getCallers(e){let r=[];return this.traverseCalls(e,s=>(s.path!==e&&r.push(s.path),!0),{direction:"incoming",maxDepth:1}),r}getCallEdgesFor(e){return this.nodes.get(e)?.callEdges??[]}getNeighbors(e){let r=this.nodes.get(e);return r?r.imports.map(s=>this.nodes.get(s.toPath)).filter(s=>s!==void 0):[]}findUnusedFiles(e){return new ie(this.nodes).findUnusedFiles(e)}findCycles(){return new ie(this.nodes).findCycles()}}});var z,Ae=m(()=>{"use strict";c();z=class{affectedSymbols=new Map;constructor(e,r){this.affectedSymbols.set(e,new Set(["default",...r]))}updateAffectedSymbols(e,r){let s=this.affectedSymbols.get(r)||new Set,n=e.imports.find(p=>p.toPath===r);if(!n)return!1;let o=n.symbols||["*"],i=new Set;for(let p of o)(p==="*"||s.has("*")||s.has(p))&&i.add("*");if(i.size===0)return!1;let a=this.affectedSymbols.get(e.path)||new Set;for(let p of i)a.add(p);return this.affectedSymbols.set(e.path,a),!0}}});function Ft(t,e,r=1){let s=[];return t.traverse(e,(n,o,i)=>{if(n.path===e)return!0;let a=i?t.nodes.get(i)?.imports.find(p=>p.toPath===n.path):void 0;return s.push({path:n.path,...a?.symbols?{symbols:a.symbols}:{}}),!0},{direction:"outgoing",maxDepth:r}),s}function Pt(t,e){let r=[];return t.traverse(e,s=>{if(s.path===e)return!0;let n=s.imports.find(o=>o.toPath===e);return r.push({path:s.path,...n?.symbols?{symbols:n.symbols}:{}}),!0},{direction:"incoming",maxDepth:1}),r}function Tt(t,e,r={}){let{testsOnly:s=!1,changedSymbols:n}=r,o=n?new z(e,n):null,i=[];return t.traverse(e,(a,p,l)=>{if(a.path===e)return!0;if(o&&l&&!o.updateAffectedSymbols(a,l))return!1;let d=a.category==="test"||a.tags.some(h=>h.name==="test");return(!s||d)&&i.push(a.path),!0},{direction:"incoming"}),i}function Nt(t,e,r={}){let{depth:s=1,withEdgeDetail:n=!1}=r,o=[];return t.traverseCalls(e,i=>{if(i.path===e)return!0;let a={file:i.path};return n&&(a.edges=(i.callEdges??[]).filter(p=>p.toFile===e).map(p=>({from:p.from,to:p.to}))),o.push(a),!0},{direction:"incoming",maxDepth:s}),o}function It(t,e={}){let{metric:r="cognitiveComplexity",threshold:s=10,limit:n=20}=e;return[...t.nodes.values()].flatMap(o=>(o.functions??[]).filter(i=>i[r]>=s).map(i=>({file:o.path,name:i.name,line:i.line,complexity:i.complexity,cognitiveComplexity:i.cognitiveComplexity}))).sort((o,i)=>i[r]-o[r]).slice(0,n)}function Mt(t){return{nodes:t.nodes.map(r=>({path:r.path,type:r.type,category:r.category,exports:r.exports.map(s=>s.name),tags:r.tags.filter(s=>s.kind==="comment-marker"||s.kind==="import").map(s=>s.name),importsFiles:r.imports.filter(s=>!s.isExternal&&s.toPath).map(s=>s.toPath),...r.description!==void 0&&{description:r.description},...r.testedBy!==void 0&&{testedBy:r.testedBy},...r.coveragePct!==void 0&&{coveragePct:r.coveragePct},...r.avgExportUsage!==void 0&&{avgExportUsage:r.avgExportUsage},...r.maxExportUsage!==void 0&&{maxExportUsage:r.maxExportUsage}})),cycles:t.cycles}}function Dt(t){let e=t.getPackageDependencies(),r=Array.from(t.packages.values()).map(({graph:s,pkg:n})=>({name:n.name,relativeRoot:n.relativeRoot,nodeCount:s.nodes.size,dependsOn:e.get(n.name)??[]}));return{monorepoType:t.type,packageCount:r.length,packages:r}}function At(t){return[...t.nodes.values()].some(e=>e.coveragePct!==void 0)}var ls=m(()=>{"use strict";c();Ae()});function fs(t){if(t.category==="test")return"test";if(t.category==="config")return"config";if(t.category==="type-only")return"types";let e=t.path;return S(e,"component")||S(e,"components")?"component":S(e,"controller")||S(e,"controllers")?"controller":S(e,"middleware")?"middleware":S(e,"router")||S(e,"routes")||S(e,"route")?"router":S(e,"store")||S(e,"stores")?"store":S(e,"service")||S(e,"services")?"service":S(e,"handler")||S(e,"handlers")?"handler":S(e,"adapter")||S(e,"adapters")?"adapter":S(e,"plugin")||S(e,"plugins")?"plugin":S(e,"api")?"api":S(e,"cli")||S(e,"commands")||ce(e)==="cli"?"cli":S(e,"util")||S(e,"utils")||S(e,"helper")||S(e,"helpers")?"util":S(e,"model")||S(e,"models")||ce(e)==="model"?"model":S(e,"parser")||S(e,"parsers")||ce(e)==="parser"?"parser":ce(e)==="builder"?"builder":ce(e)==="resolver"?"resolver":"other"}function S(t,e){return t.includes(`/${e}/`)||t.includes(`/${e}.`)}function ce(t){let e=t.slice(t.lastIndexOf("/")+1);return e.slice(0,e.lastIndexOf("."))||e}var ms=m(()=>{"use strict";c()});function Rt(t,e){let r=oe(t,e),s=new Map;for(let[o,i]of r.features){for(let a of i.files)s.set(a,o);s.set(i.hub,o)}let n=new Map;for(let o of t.nodes.values()){let i=s.get(o.path);n.set(o.path,{path:o.path,role:fs(o),...o.description?{description:o.description}:{},exports:o.exports.map(a=>a.name),...i?{featureHub:i}:{}})}return n}var Ot=m(()=>{"use strict";c();De();ms()});function Fa(t){return t?t.startsWith("interface ")?"interface":t.startsWith("class ")?"class":t.startsWith("enum ")?"enum":"type":"type"}function Pa(t,e){if(e==="type-only")return!0;let r=t.signature??"";return r.startsWith("interface ")||r.startsWith("class ")||r.startsWith("enum ")}function Gt(t){let e=new Map;for(let s of t.nodes.values())if(!(s.type!=="typescript"&&s.type!=="javascript"))for(let n of s.exports){if(!Pa(n,s.category))continue;let o=`${s.path}::${n.name}`;e.set(o,{name:n.name,file:s.path,kind:Fa(n.signature),...n.doc?{doc:n.doc}:{}})}let r=[];for(let s of t.nodes.values())if(!(s.type!=="typescript"&&s.type!=="javascript")){for(let n of s.imports)if(!(!n.toPath||n.isExternal||!n.symbols?.length))for(let o of n.symbols)e.has(`${n.toPath}::${o}`)&&r.push({fromFile:s.path,toType:o,toFile:n.toPath})}return{types:e,edges:r}}function Lt(t,e){let r=null;for(let o of t.types.values())if(o.name===e){r=o;break}if(!r)return{type:null,usedByFiles:[],uses:[]};let s=new Set,n=new Map;for(let o of t.edges)if(o.toType===e&&o.toFile===r.file&&s.add(o.fromFile),o.fromFile===r.file){let i=t.types.get(`${o.toFile}::${o.toType}`);i&&n.set(`${i.file}::${i.name}`,i)}return{type:r,usedByFiles:Array.from(s),uses:Array.from(n.values())}}var jt=m(()=>{"use strict";c()});import us from"fs";import om from"path";function gs(t){try{return us.statSync(t,{throwIfNoEntry:!1})?.isDirectory()===!0}catch{return!1}}function Re(t){try{return us.statSync(t,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}var Oe=m(()=>{"use strict";c()});import pe from"fs";import T from"path";function _t(t,e){let r=T.join(e,"package.json");if(!pe.existsSync(r))return null;let s={};try{s=JSON.parse(pe.readFileSync(r,"utf-8"))}catch{return null}let n=s.name;return n?{name:n,root:e,relativeRoot:T.relative(t,e),entryPoints:Ta(e,s)}:null}function Ta(t,e){let r=[];if(e.exports){let n=e.exports;if(typeof n=="string")r.push(T.join(t,n));else if(typeof n=="object"&&n!==null){let o=n["."];if(typeof o=="string")r.push(T.join(t,o));else if(typeof o=="object"&&o!==null){let i=o.import??o.require??o.default;typeof i=="string"&&r.push(T.join(t,i))}}}e.main&&r.push(T.join(t,e.main));for(let n of["src/index.ts","src/index.tsx","index.ts","index.tsx","index.js"])r.push(T.join(t,n));let s=r.filter(Re);return s.length>0?s.slice(0,1):r.slice(0,1)}function K(t,e){let r=[],s=new Set;for(let n of e){let o=n.replace(/\/$/,"").replace(/^\.\//,"");Na(t,o,s,r)}return r}function Na(t,e,r,s){if(!e.includes("*")){Ia(t,e,r,s);return}let n=e.split("/");n.includes("**")?Ma(t,n,r,s):Da(t,n,r,s)}function Ia(t,e,r,s){let n=T.join(t,e);if(r.has(n)||!gs(n))return;r.add(n);let o=_t(t,n);o&&s.push(o)}function Ma(t,e,r,s){let n=T.join(t,e[0]==="**"?"":e[0]??"");ds(t,n,r,s)}function Da(t,e,r,s){let n=e.findIndex(a=>a.includes("*")),o=T.join(t,...e.slice(0,n)),i;try{i=pe.readdirSync(o,{withFileTypes:!0})}catch{return}for(let a of i){if(!a.isDirectory())continue;let p=T.join(o,a.name);if(r.has(p))continue;r.add(p);let l=_t(t,p);l&&s.push(l)}}function ds(t,e,r,s){let n;try{n=pe.readdirSync(e,{withFileTypes:!0})}catch{return}for(let o of n){if(!o.isDirectory()||o.name==="node_modules"||o.name.startsWith("."))continue;let i=T.join(e,o.name);if(pe.existsSync(T.join(i,"package.json"))&&!r.has(i)){r.add(i);let a=_t(t,i);a&&s.push(a)}else ds(t,i,r,s)}}var Ge=m(()=>{"use strict";c();Oe();Oe()});import Wt from"fs";import hs from"path";var ys,xs=m(()=>{"use strict";c();Ge();ys={type:"npm",detect(t){let e=hs.join(t,"package.json");if(!Wt.existsSync(e))return null;let r;try{r=JSON.parse(Wt.readFileSync(e,"utf-8")).workspaces}catch{return null}if(!r||Wt.existsSync(hs.join(t,"yarn.lock")))return null;let s=Array.isArray(r)?r:r.packages??[];return s.length===0?null:K(t,s)}}});import H from"fs";import w from"path";function bs(t,e,r,s){if(s>4)return[];let n;try{n=H.readdirSync(e,{withFileTypes:!0})}catch{return[]}let o=[];for(let i of n){if(!i.isDirectory())continue;let a=i.name;if(a.startsWith(".")||a==="node_modules"||a==="dist"||a===".nx")continue;let p=w.join(e,a);H.existsSync(w.join(p,"project.json"))&&!r.has(p)?(r.add(p),o.push(p)):o.push(...bs(t,p,r,s+1))}return o}function Aa(t,e,r){let s={};try{s=JSON.parse(H.readFileSync(r,"utf-8"))}catch{return null}let n=s.name,o,i,a=w.join(e,"package.json");if(H.existsSync(a))try{let p=JSON.parse(H.readFileSync(a,"utf-8"));n=p.name??n,o=p.main,i=p.exports}catch{}return n?{name:n,root:e,relativeRoot:w.relative(t,e),entryPoints:Ra(e,s,o,i)}:null}function Ra(t,e,r,s){let n=[],o=e.targets?.build?.options?.main??e.targets?.build?.options?.entryFile;if(o){let a=w.resolve(t,"../..");n.push(w.resolve(a,o)),n.push(w.resolve(t,o))}if(s){let a=s;if(typeof a=="string")n.push(w.join(t,a));else if(typeof a=="object"&&a!==null){let p=a["."];typeof p=="string"&&n.push(w.join(t,p))}}if(r&&n.push(w.join(t,r)),e.sourceRoot){let a=w.resolve(t,"../.."),p=w.resolve(a,e.sourceRoot);n.push(w.join(p,"index.ts"),w.join(p,"index.tsx"))}for(let a of["src/index.ts","src/index.tsx","index.ts","index.tsx"])n.push(w.join(t,a));let i=n.filter(Re);return i.length>0?i.slice(0,1):n.slice(0,1)}var Ss,Cs=m(()=>{"use strict";c();Oe();Ss={type:"nx",detect(t){return H.existsSync(w.join(t,"nx.json"))?bs(t,t,new Set,0).map(r=>Aa(t,r,w.join(r,"project.json"))).filter(r=>r!==null):null}}});import vs from"fs";import Oa from"path";import{load as Ga}from"js-yaml";var ks,ws=m(()=>{"use strict";c();Ge();ks={type:"pnpm",detect(t){let e=Oa.join(t,"pnpm-workspace.yaml");if(!vs.existsSync(e))return null;let r=[];try{r=Ga(vs.readFileSync(e,"utf-8"))?.packages??[]}catch{return null}return K(t,r)}}});import La from"fs";import ja from"path";var Es,Fs=m(()=>{"use strict";c();Es={type:"turborepo",detect(t){return La.existsSync(ja.join(t,"turbo.json"))?[]:null}}});import zt from"fs";import Ps from"path";var Ts,Ns=m(()=>{"use strict";c();Ge();Ts={type:"yarn",detect(t){if(!zt.existsSync(Ps.join(t,"yarn.lock")))return null;let e=Ps.join(t,"package.json");if(!zt.existsSync(e))return null;let r;try{r=JSON.parse(zt.readFileSync(e,"utf-8")).workspaces}catch{return null}if(!r)return null;let s=Array.isArray(r)?r:r.packages??[];return s.length===0?null:K(t,s)}}});function G(t){Is.push(t)}function Ms(){return Is}var Is,Le=m(()=>{"use strict";c();Is=[]});import _a from"path";function $t(t,e=Ms()){let r=_a.resolve(t),s=new Map,n=[];for(let i of e){let a=i.detect(r);if(a!==null){n.push(i.type);for(let p of a)s.has(p.name)||s.set(p.name,p)}}if(n.length===0)return{root:r,type:"none",types:[],packages:[],packageMap:new Map};let o=Array.from(s.values());return{root:r,type:n[0],types:n,packages:o,packageMap:new Map(o.map(i=>[i.name,i]))}}var Ut=m(()=>{"use strict";c();xs();Cs();ws();Fs();Ns();Le();Le();G(Es);G(Ss);G(ks);G(Ts);G(ys)});var le,Bt=m(()=>{"use strict";c();ae();le=class t{constructor(e,r){this.monorepoRoot=e;this.type=r}monorepoRoot;type;packages=new Map;addPackage(e,r){this.packages.set(e.name,{graph:r,pkg:e})}getPackageForFile(e){for(let{pkg:r}of this.packages.values())if(e===r.relativeRoot||e.startsWith(`${r.relativeRoot}/`))return r}getPackageDependencies(){let e=new Map;for(let{graph:r,pkg:s}of this.packages.values()){let n=new Set;for(let o of r.nodes.values())for(let i of o.imports)i.isWorkspace&&i.workspacePackage&&n.add(i.workspacePackage);e.set(s.name,[...n])}return e}getAffectedAcrossPackages(e){let r=this.getPackageForFile(e);if(!r)return[];let s=this.packages.get(r.name);if(!s)return[];let n=[];s.graph.traverse(e,o=>(o.path!==e&&n.push({file:o.path,package:r.name}),!0),{direction:"incoming"});for(let{graph:o,pkg:i}of this.packages.values())if(i.name!==r.name)for(let a of o.nodes.values())a.imports.some(l=>l.isWorkspace&&l.workspacePackage===r.name)&&n.push({file:a.path,package:i.name});return n}serialize(){return{monorepoRoot:this.monorepoRoot,type:this.type,packages:Array.from(this.packages.values()).map(({graph:e,pkg:r})=>({pkg:{name:r.name,relativeRoot:r.relativeRoot,entryPoints:r.entryPoints},nodes:Array.from(e.nodes.values())}))}}static deserialize(e){let r=new t(e.monorepoRoot,e.type);for(let{pkg:s,nodes:n}of e.packages){let o=new Map(n.map(a=>[a.path,a])),i=new P(o);r.packages.set(s.name,{graph:i,pkg:{...s,root:""}})}return r}}});function Q(t,e){Ds.set(t,e)}function As(t){return Ds.get(t)}var Ds,fe=m(()=>{"use strict";c();Ds=new Map});function Rs(t,e){return e.startsWith("!")?t!==e.slice(1):t===e}function Wa(t,e){return e.startsWith("!")?!t.includes(e.slice(1)):t.includes(e)}function me(t,e,r){return gc.every(s=>s(t,e,r))}var za,$a,Ua,Ba,Ja,Ka,Ha,Qa,Va,Xa,qa,Ya,Za,ec,tc,rc,sc,nc,oc,ic,ac,cc,pc,lc,fc,mc,uc,gc,Jt=m(()=>{"use strict";c();za=(t,e)=>!e.category||Rs(t.category,e.category),$a=(t,e)=>!e.type||Rs(t.type,e.type),Ua=(t,e)=>e.lastAuthor?e.lastAuthor.startsWith("!")?t.lastAuthor!==e.lastAuthor.slice(1):t.lastAuthor!==void 0&&t.lastAuthor===e.lastAuthor:!0,Ba=(t,e)=>!e.path||Wa(t.path,e.path),Ja=(t,e)=>e.isExternal===void 0?!0:t.imports.some(s=>s.isExternal)===e.isExternal,Ka=(t,e)=>{if(!e.tags||e.tags.length===0)return!0;let r=e.tags.filter(n=>!n.startsWith("!")),s=e.tags.filter(n=>n.startsWith("!")).map(n=>n.slice(1));return!(r.length>0&&!r.some(n=>t.tags.some(o=>o.name===n))||s.some(n=>t.tags.some(o=>o.name===n)))},Ha=(t,e)=>!e.allTags?.length||e.allTags.every(r=>t.tags.some(s=>s.name===r)),Qa=(t,e)=>!e.importsFile||t.imports.some(r=>r.toPath?.includes(e.importsFile)),Va=(t,e,r)=>e.importedBy===void 0?!0:(r?.get(t.path)??[]).some(n=>n.includes(e.importedBy)),Xa=(t,e)=>e.minImports===void 0||t.imports.length>=e.minImports,qa=(t,e)=>e.maxImports===void 0||t.imports.length<=e.maxImports,Ya=(t,e)=>e.minSize===void 0||t.size>=e.minSize,Za=(t,e)=>e.maxSize===void 0||t.size<=e.maxSize,ec=(t,e)=>e.hasDocstring===void 0||!!t.description===e.hasDocstring,tc=(t,e)=>e.isDocumented===void 0||!!t.documentedBy?.length===e.isDocumented,rc=(t,e)=>e.isStale===void 0||!!t.staleFor?.length===e.isStale,sc=(t,e)=>e.minCoverage===void 0||(t.coveragePct??101)>=e.minCoverage,nc=(t,e)=>e.maxCoverage===void 0||(t.coveragePct??0)<=e.maxCoverage,oc=(t,e)=>e.minExportUsage===void 0||(t.avgExportUsage??-1)>=e.minExportUsage,ic=(t,e)=>e.maxExportUsage===void 0||(t.avgExportUsage??0)<=e.maxExportUsage,ac=(t,e)=>e.minComplexity===void 0||(t.complexity??-1/0)>=e.minComplexity,cc=(t,e)=>e.maxComplexity===void 0||(t.complexity??0)<=e.maxComplexity,pc=(t,e)=>e.minCognitiveComplexity===void 0||(t.cognitiveComplexity??-1/0)>=e.minCognitiveComplexity,lc=(t,e)=>e.maxCognitiveComplexity===void 0||(t.cognitiveComplexity??0)<=e.maxCognitiveComplexity,fc=(t,e)=>e.minCommits===void 0||(t.commitCount90d??-1/0)>=e.minCommits,mc=(t,e)=>e.maxCommits===void 0||(t.commitCount90d??0)<=e.maxCommits,uc=(t,e,r)=>!e.any?.length||e.any.some(s=>me(t,s,r)),gc=[za,$a,Ua,Ba,Ja,Ka,Ha,Qa,Va,Xa,qa,Ya,Za,ec,tc,rc,sc,nc,oc,ic,ac,cc,pc,lc,fc,mc,uc]});function je(t,e){let r=new Map;if(e.importedBy!==void 0){for(let i of t.nodes)for(let a of i.imports)if(a.toPath){let p=r.get(a.toPath)??[];p.push(i.path),r.set(a.toPath,p)}}let s=t.nodes.filter(i=>me(i,e,r)),n=new Set(s.map(i=>i.path)),o=s.map(i=>({...i,imports:i.imports.filter(a=>!a.toPath||n.has(a.toPath))}));if(e.sort){let i=e.sortDir==="asc"?-1:1;o.sort((a,p)=>{let l=0;return e.sort==="size"?l=p.size-a.size:e.sort==="imports"?l=p.imports.length-a.imports.length:e.sort==="commitCount90d"?l=(p.commitCount90d??0)-(a.commitCount90d??0):e.sort==="exportUsage"?l=(p.avgExportUsage??0)-(a.avgExportUsage??0):e.sort==="complexity"?l=(p.complexity??0)-(a.complexity??0):e.sort==="cognitiveComplexity"&&(l=(p.cognitiveComplexity??0)-(a.cognitiveComplexity??0)),l*i})}return e.limit!==void 0&&o.splice(e.limit),{nodes:o,cycles:t.cycles?.filter(i=>i.every(a=>n.has(a)))??void 0}}var Os=m(()=>{"use strict";c();Jt();Jt()});function Gs(t,e){let r=e.indexOf(":");if(r===-1)return;let s=e.slice(0,r).trim().toLowerCase(),n=e.slice(r+1).trim();if(!(!s||!n))switch(s){case"category":t.category=n;break;case"type":t.type=n;break;case"tag":case"tags":n.includes("+")?t.allTags=[...t.allTags??[],...n.split("+")]:t.tags=[...t.tags??[],n];break;case"path":t.path=n;break;case"external":t.isExternal=n.toLowerCase()==="true";break;case"importsfile":t.importsFile=n;break;case"importedby":t.importedBy=n;break;case"minimports":t.minImports=parseInt(n,10);break;case"maximports":t.maxImports=parseInt(n,10);break;case"minsize":t.minSize=parseInt(n,10);break;case"maxsize":t.maxSize=parseInt(n,10);break;case"sort":t.sort=n;break;case"sortdir":t.sortDir=n.toLowerCase()==="asc"?"asc":"desc";break;case"limit":t.limit=parseInt(n,10);break;case"hasdocstring":t.hasDocstring=n.toLowerCase()!=="false";break;case"mincoverage":t.minCoverage=parseInt(n,10);break;case"maxcoverage":t.maxCoverage=parseInt(n,10);break;case"minexportusage":t.minExportUsage=parseFloat(n);break;case"maxexportusage":t.maxExportUsage=parseFloat(n);break;case"mincomplexity":t.minComplexity=parseInt(n,10);break;case"maxcomplexity":t.maxComplexity=parseInt(n,10);break;case"mincognitivecomplexity":t.minCognitiveComplexity=parseInt(n,10);break;case"maxcognitivecomplexity":t.maxCognitiveComplexity=parseInt(n,10);break;case"mincommits":t.minCommits=parseInt(n,10);break;case"maxcommits":t.maxCommits=parseInt(n,10);break;case"isdocumented":t.isDocumented=n.toLowerCase()!=="false";break;case"isstale":t.isStale=n.toLowerCase()!=="false";break;case"lastauthor":t.lastAuthor=n;break}}function dc(t){let e=[];for(let r of t.split("|")){let s=r.trim();if(!s)continue;let n={};Gs(n,s),Object.keys(n).length>0&&e.push(n)}return e}function _e(t){let e={},r=t.split(",");for(let s of r){let n=s.trim();if(n.toLowerCase().startsWith("any(")&&n.endsWith(")")){let o=n.slice(4,-1),i=dc(o);i.length>0&&(e.any=[...e.any??[],...i]);continue}Gs(e,s)}return e}var Ls=m(()=>{"use strict";c()});var js=m(()=>{"use strict";c();Os();Ls()});import E from"typescript";function V(t){let e=[];for(let r of t.statements){if(!E.isExpressionStatement(r))continue;let s=r.expression;if(!E.isCallExpression(s))continue;let n=s.expression;E.isIdentifier(n)&&_s.has(n.text)&&e.push(s),E.isPropertyAccessExpression(n)&&E.isIdentifier(n.expression)&&_s.has(n.expression.text)&&e.push(s)}return e}function X(t,e,r){for(let s of t.arguments){if(!E.isObjectLiteralExpression(s))continue;let n=s.properties.find(o=>E.isPropertyAssignment(o)&&E.isIdentifier(o.name)&&o.name.text===e);if(!(!n||!E.isArrayLiteralExpression(n.initializer)))return n.initializer.elements.filter(E.isStringLiteral).map(o=>o.text)}return null}function q(t,e,r,s){if(t.arguments.length===0)return null;for(let o=1;o<t.arguments.length;o++){let i=t.arguments[o];if(!E.isObjectLiteralExpression(i))continue;let a=i.properties.find(l=>E.isPropertyAssignment(l)&&E.isIdentifier(l.name)&&l.name.text===e);if(a)return{start:a.initializer.getStart(s),end:a.initializer.getEnd(),text:r};let p=i.getEnd()-1;return{start:p,end:p,text:`${i.properties.length>0?", ":""}${e}: ${r}`}}let n=t.arguments[t.arguments.length-1];return{start:n.getStart(s),end:n.getStart(s),text:`{ ${e}: ${r} }, `}}function Y(t,e,r){let s=t.arguments;for(let n=1;n<s.length;n++){let o=s[n];if(!E.isObjectLiteralExpression(o))continue;let i=o.properties.findIndex(p=>E.isPropertyAssignment(p)&&E.isIdentifier(p.name)&&p.name.text===e);if(i<0)continue;if(o.properties.length===1)return{start:s[n-1].getEnd(),end:o.getEnd(),text:""};let a=o.properties[i];return i===o.properties.length-1?{start:o.properties[i-1].getEnd(),end:a.getEnd(),text:""}:{start:a.getStart(r),end:o.properties[i+1].getStart(r),text:""}}return null}function Z(t,e){let r=[...e].sort((n,o)=>o.start-n.start),s=t;for(let n of r)s=s.slice(0,n.start)+n.text+s.slice(n.end);return s}function ee(t){return`[${t.map(e=>JSON.stringify(e)).join(", ")}]`}var _s,A,te=m(()=>{"use strict";c();_s=new Set(["describe","test","it"]);A=new Set([".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"])});import Ws from"path";import zs from"typescript";function hc(t){return ee(t.map(e=>`@${e}`))}function yc(t){return t.map(e=>e.startsWith("@")?e.slice(1):e)}var We,$s=m(()=>{"use strict";c();te();We=class{name="cypress";canHandle(e){return A.has(Ws.extname(e).toLowerCase())}apply(e,r,s){let n=zs.createSourceFile(Ws.basename(e),r,zs.ScriptTarget.Latest,!0),o=V(n);if(o.length===0)return r;let i=X(o[0],"tags",n),a=[...s].sort();if(i!==null&&JSON.stringify(yc(i).sort())===JSON.stringify(a))return r;let p=o.flatMap(l=>{let d=s.length===0?Y(l,"tags",n):q(l,"tags",hc(a),n);return d?[d]:[]});return p.length>0?Z(r,p):r}}});import xc from"path";function Sc(t){return["# <mokosh-tags>",...t.map(e=>`@${e}`),"# </mokosh-tags>"].join(`
2
+ var it=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var m=(t,e)=>()=>(t&&(e=t(t=0)),e);var Ii=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);import Mi from"path";import{fileURLToPath as Ai}from"url";var Di,Ri,f,c=m(()=>{"use strict";Di=()=>Ai(import.meta.url),Ri=()=>Mi.dirname(Di()),f=Ri()});function Fe(t){jr.push(t)}function _r(t){return[...Oi,...jr].some(e=>typeof e=="string"?t.includes(e):e instanceof RegExp?e.test(t):e(t))}function Pe(t){Wr.push(t)}function se(){return[...Gi,...Wr]}function Te(t){zr.push(t)}function at(){return[...Li,...zr]}function ct(t){$r=t}function lt(){return $r}var Oi,jr,Gi,Wr,Li,zr,$r,U=m(()=>{"use strict";c();Oi=[".config.","biome.json","tsconfig.json","package.json",".prettierrc",".eslintrc"],jr=[];Gi=[".test.",".spec.","-test.","-spec."],Wr=[];Li=["jest","vitest","playwright","cypress","@testing-library/"],zr=[];$r=.8});import pt from"fs";import Ur from"path";function B(t,{allowJs:e=!0,isExplicitPath:r=!1}={}){if(r){let s=Ur.resolve(t);return pt.existsSync(s)?s.endsWith(".json")?Br(s):e?Jr(s):{}:{}}for(let s of ji){let n=Ur.resolve(t,s);if(pt.existsSync(n)){if(s.endsWith(".json"))return Br(n);if(e)return Jr(n)}}return{}}function Br(t){return JSON.parse(pt.readFileSync(t,"utf-8"))}function Jr(t){let e=it(t);return e&&typeof e=="object"&&"default"in e&&(e=e.default),typeof e=="function"?e({}):e}function ft(t){for(let e of t.configMatchers??[])Fe(e);for(let e of t.testPatterns??[])Pe(e);for(let e of t.testLibraries??[])Te(e);t.barrelThreshold!==void 0&&ct(t.barrelThreshold)}function k(t){return{gitStats:t?.gitStats??!1,parallelParsing:t?.parallelParsing,pathAliases:t?.pathAliases}}var ji,mt=m(()=>{"use strict";c();U();ji=["mokosh.config.js","mokosh.config.cjs","mokosh.config.json"]});var ut,gt,dt=m(()=>{"use strict";c();ut=["node_modules",".git","dist","build",".next",".cache","mokosh-cache","coverage"],gt=[".ts",".tsx",".js",".jsx",".mjs",".cjs",".css",".scss",".sass",".less",".styl",".coffee",".ls",".lua",".py",".go",".feature",".md",".mdx"]});import $p from"fs";import Bp from"path";var Kr=m(()=>{"use strict";c()});var Ne,Hr=m(()=>{"use strict";c();Ne={serialize(t){let e=["graph TD"],r=new Set;for(let s of t.nodes.values()){let n=`"${s.path}"`;for(let o of s.imports){if(!o.toPath)continue;let i=`"${o.toPath}"`,a=`${s.path} -> ${o.toPath}`;if(!r.has(a)){let l=o.isStyle?"-- styles -->":"-->";e.push(` ${n} ${l} ${i}`),r.add(a)}}}return e.join(`
3
+ `)}}});var Qr=m(()=>{"use strict";c();Hr()});import Vr from"fs";import Wi from"path";function ht(t,e){let r=t.replace(/^\.\//,"");if(e.nodes.has(r))return r;let s=r.replace(/^dist\//,"src/").replace(/\.(js|mjs|cjs)$/,".ts");return e.nodes.has(s)?s:null}function Xr(t,e){if(typeof t=="string")return ht(t,e);if(t&&typeof t=="object"){let r=t;for(let s of["import","require","default"]){let n=Xr(r[s],e);if(n)return n}}return null}function zi(t){if(!t)return"unknown";let e=t.trimStart();return e.startsWith("interface ")?"interface":e.startsWith("class ")?"class":e.startsWith("enum ")?"enum":e.startsWith("type ")?"type":e.startsWith("namespace ")?"namespace":e.startsWith("const ")||e.startsWith("let ")||e.startsWith("var ")||e.startsWith("readonly ")?"const":e.startsWith("(")||e.startsWith("async ")||e.startsWith("function ")||e.includes("=>")?"function":"unknown"}function $i(t,e){let r=new Set,s=new Set,n=[...e];for(;n.length;){let o=n.shift();if(s.has(o))continue;s.add(o);let i=t.nodes.get(o);if(i){for(let a of i.exports)r.add(a.name);for(let a of i.imports){if(a.type!=="re-export"||a.isExternal||!a.toPath)continue;if(!a.symbols?.length||a.symbols.includes("*")){let p=t.nodes.get(a.toPath);if(p)for(let h of p.exports)r.add(h.name);n.push(a.toPath)}else for(let p of a.symbols)r.add(p)}}}return r}function yt(t,e){let r=[],s=Wi.join(e,"package.json");if(Vr.existsSync(s))try{let n=JSON.parse(Vr.readFileSync(s,"utf8"));if(n.exports&&typeof n.exports=="object"&&!Array.isArray(n.exports))for(let o of Object.values(n.exports)){let i=Xr(o,t);i&&!r.includes(i)&&r.push(i)}else if(typeof n.exports=="string"){let o=ht(n.exports,t);o&&r.push(o)}if(r.length===0)for(let o of[n.main,n.module].filter(Boolean)){let i=ht(o,t);i&&!r.includes(i)&&r.push(i)}}catch{}if(r.length===0){for(let n of["src/index.ts","src/index.js","index.ts","index.js"])if(t.nodes.has(n)){r.push(n);break}}return r}function Ui(t,e){let r=new Set(e);for(let s of e)t.traverse(s,n=>(r.add(n.path),!0),{direction:"outgoing"});return r}function Bi(t,e,r){let s=new Map;for(let n of e){if(r.includes(n))continue;let o=t.nodes.get(n);if(!o)continue;let i=o.category==="barrel";for(let a of o.exports){let l=s.get(a.name),p=!!(a.signature||a.doc);(!l||p&&!i)&&s.set(a.name,{file:n,symbol:a})}}return s}function Ji(t,e,r,s){let n=[];for(let o of t){let i=e.get(o),a=s.flatMap(d=>r.nodes.get(d)?.exports??[]).find(d=>d.name===o),l=i?.symbol??a,p=i?.file??s.find(d=>r.nodes.get(d)?.exports.some(S=>S.name===o))??s[0],h={name:o,definedIn:p,kind:zi(l?.signature)};l?.doc&&(h.doc=l.doc),l?.signature&&(h.signature=l.signature),n.push(h)}return n.sort((o,i)=>o.name.localeCompare(i.name)),n}function Ki(t,e,r){let s=l=>t.nodes.get(l)?.category==="test",n=[...e].filter(l=>!r.includes(l)&&!s(l)),o=[...t.nodes.keys()].filter(l=>!e.has(l)),i=o.filter(l=>!s(l)),a=o.filter(l=>s(l));return{internalFiles:n,unreachableFromEntry:i,testFiles:a}}function xt(t,e){if(e.length===0)throw new Error("buildApiSurface requires at least one entry point");for(let p of e)if(!t.nodes.has(p))throw new Error(`Entry point not found in graph: ${p}`);let r=Ui(t,e),s=Bi(t,r,e),n=$i(t,e),o=Ji(n,s,t,e),{internalFiles:i,unreachableFromEntry:a,testFiles:l}=Ki(t,r,e);return{entryPoints:e,publicExports:o,internalFiles:i,unreachableFromEntry:a,testFiles:l}}var St=m(()=>{"use strict";c()});function bt(t,e){let r=null,s=[];for(let o of t.nodes.values()){o.exports.some(i=>i.name===e)&&(r=o.path);for(let i of o.callEdges??[])i.to===e&&s.push({file:o.path,callerFunction:i.from})}let n=[];if(r){let o=t.nodes.get(r);for(let i of o?.callEdges??[])i.from===e&&n.push({file:i.toFile,calleeFunction:i.to})}return{functionName:e,definedIn:r,callers:s,callees:n}}var Ct=m(()=>{"use strict";c()});import of from"fs";import cf from"path";function Yr(t){let e=[...t.nodes.entries()].sort(([s],[n])=>s.localeCompare(n)).map(([s,n])=>`${s}:${n.mtime}:${n.size}`).join("|"),r=2166136261;for(let s=0;s<e.length;s++)r^=e.charCodeAt(s),r=Math.imul(r,16777619)>>>0;return r.toString(16).padStart(8,"0")}function vt(t){let e=new Map;for(let r of t.nodes.keys()){let s=[];t.traverse(r,n=>(n.path!==r&&s.push(n.path),!0),{direction:"incoming"}),e.set(r,s)}return{impact:e,graphHash:Yr(t)}}function kt(t,e){return t.impact.get(e)??[]}var Et=m(()=>{"use strict";c()});import Ie from"path";function Hi(t){let e=new Map;for(let[r,s]of t){let n=s.imports.filter(o=>o.toPath&&!o.isExternal).length;n>0&&e.set(r,n)}return e}function Qi(t,e,r){let s=new Map;for(let[n,o]of e){if(o<r)continue;let i=t.get(n);if(!i||i.category==="test"||i.category==="barrel")continue;let a=Ie.extname(n),l=Ie.basename(n,a),p=l==="index"?Ie.basename(Ie.dirname(n)):l;s.set(n,{path:n,outDegree:o,tag:`feature:${p}`})}return s}function j(t,e){let r=e?.minOutDegree??5;return Qi(t,Hi(t),r)}var Me=m(()=>{"use strict";c()});function Xi(t,e){let r=new Map;for(let s of e.values()){let n=new Set;t.traverse(s.path,o=>(o.path!==s.path&&n.add(o.path),!0),{direction:"outgoing"}),r.set(s.path,n)}return r}function Yi(t,e,r,s){let n=new Map;for(let[o]of t){if(e.has(o))continue;let i=null;for(let a of e.values())r.get(a.path)?.has(o)&&(!i||s(a,i)<0)&&(i=a);i&&n.set(o,i.path)}return n}function qi(t,e){let r=new Map;for(let s of t.values()){let n=s.tag.replace("feature:",""),o=[];for(let[i,a]of e)a===s.path&&o.push(i);r.set(n,{hub:s.path,outDegree:s.outDegree,files:o})}return r}function Zi(t,e,r){let s=[];for(let n of t.keys())!e.has(n)&&!r.has(n)&&s.push(n);return s}function ne(t,e){let r=e?.detectFn??j,s=e?.hubComparator??Vi,n=r(t.nodes,e),o=Xi(t,n),i=Yi(t.nodes,n,o,s);return{features:qi(n,i),unassigned:Zi(t.nodes,n,i)}}var Vi,Ae=m(()=>{"use strict";c();Me();Vi=(t,e)=>t.outDegree-e.outDegree});function wt(t){let e=new Map;for(let r of t.nodes.values())e.set(r.type,(e.get(r.type)??0)+1);return[...e.entries()].map(([r,s])=>({type:r,fileCount:s,exportsTracked:qr.has(r),importSymbolsTracked:De.has(r),callEdgesTracked:Re.has(r)})).sort((r,s)=>s.fileCount-r.fileCount)}var qr,De,Re,Ft=m(()=>{"use strict";c();qr=new Set(["typescript","javascript","python","go"]),De=new Set(["typescript","javascript","python"]),Re=new Set(["typescript","javascript"])});var oe,Zr=m(()=>{"use strict";c();oe=class{constructor(e){this.nodes=e}nodes;findUnusedFiles(e){let r=new Set(this.nodes.keys());return e.filter(s=>!r.has(s))}findHighExportUsage(e){let r=[];for(let s of this.nodes.values()){if(s.maxExportUsage===void 0||s.maxExportUsage<e)continue;let n=s.imports.reduce((o,i)=>(i.exportUsageRatio??0)>(o?.exportUsageRatio??0)?i:o,null);r.push({path:s.path,maxExportUsage:s.maxExportUsage,tightestDep:n?.toPath??""})}return r.sort((s,n)=>n.maxExportUsage-s.maxExportUsage)}findCycles(){let e=[],r=new Set,s=new Set,n=[],o=i=>{r.add(i),s.add(i),n.push(i);let a=this.nodes.get(i);if(a){for(let l of a.imports)if(!(!l.toPath||l.isExternal))if(s.has(l.toPath)){let p=n.indexOf(l.toPath);e.push([...n.slice(p),l.toPath])}else r.has(l.toPath)||o(l.toPath)}s.delete(i),n.pop()};for(let i of this.nodes.keys())r.has(i)||o(i);return e}}});var P,ie=m(()=>{"use strict";c();Zr();P=class t{constructor(e){this.nodes=e}nodes;_incomingEdgesCache=null;_callIncomingCache=null;serialize(){return{nodes:Array.from(this.nodes.values())}}static deserialize(e){let r=new Map;for(let s of e.nodes)r.set(s.path,s);return new t(r)}getIncomingEdgesMap(){if(this._incomingEdgesCache)return this._incomingEdgesCache;let e=new Map;for(let r of this.nodes.values())for(let s of r.imports)if(s.toPath){let n=e.get(s.toPath)||[];n.push(r.path),e.set(s.toPath,n)}return this._incomingEdgesCache=e,e}dfs(e,r,s,n){let o=new Set,i=s.maxDepth??1/0,a=(l,p,h)=>{if(p>i||o.has(l))return;let d=this.nodes.get(l);if(d&&(o.add(l),r(d,p,h)!==!1))for(let S of n(l))a(S,p+1,l)};a(e,0,null)}traverse(e,r,s={}){let n=s.direction??"outgoing",o=n==="incoming"?this.getIncomingEdgesMap():null;this.dfs(e,r,s,i=>n==="outgoing"?this.nodes.get(i)?.imports.map(a=>a.toPath).filter(Boolean)??[]:o?.get(i)??[])}getCallIncomingCache(){if(this._callIncomingCache)return this._callIncomingCache;let e=new Map;for(let r of this.nodes.values())for(let s of r.callEdges??[]){let n=e.get(s.toFile)??[];n.push(r.path),e.set(s.toFile,n)}return this._callIncomingCache=e,e}traverseCalls(e,r,s={}){let n=s.direction??"outgoing",o=n==="incoming"?this.getCallIncomingCache():null;this.dfs(e,r,s,i=>n==="outgoing"?this.nodes.get(i)?.callEdges?.map(a=>a.toFile)??[]:o?.get(i)??[])}getCallers(e){let r=[];return this.traverseCalls(e,s=>(s.path!==e&&r.push(s.path),!0),{direction:"incoming",maxDepth:1}),r}getCallEdgesFor(e){return this.nodes.get(e)?.callEdges??[]}getNeighbors(e){let r=this.nodes.get(e);return r?r.imports.map(s=>this.nodes.get(s.toPath)).filter(s=>s!==void 0):[]}findUnusedFiles(e){return new oe(this.nodes).findUnusedFiles(e)}findCycles(){return new oe(this.nodes).findCycles()}}});var _,Oe=m(()=>{"use strict";c();_=class{affectedSymbols=new Map;constructor(e,r){this.affectedSymbols.set(e,new Set(["default",...r]))}updateAffectedSymbols(e,r){let s=this.affectedSymbols.get(r)||new Set,n=e.imports.find(l=>l.toPath===r);if(!n)return!1;let o=n.symbols||["*"],i=new Set;for(let l of o)(l==="*"||s.has("*")||s.has(l))&&i.add("*");if(i.size===0)return!1;let a=this.affectedSymbols.get(e.path)||new Set;for(let l of i)a.add(l);return this.affectedSymbols.set(e.path,a),!0}}});function W(t,e){let r=t.nodes.get(e);if(r)return{category:r.category,exports:r.exports.map(s=>s.name)}}function Pt(t,e,r=1){let s=[];return t.traverse(e,(n,o,i)=>{if(n.path===e)return!0;let a=i?t.nodes.get(i)?.imports.find(l=>l.toPath===n.path):void 0;return s.push({path:n.path,...a?.symbols?{symbols:a.symbols}:{}}),!0},{direction:"outgoing",maxDepth:r}),s}function ae(t,e){let r=[];return t.traverse(e,s=>{if(s.path===e)return!0;let n=s.imports.find(o=>o.toPath===e);return r.push({path:s.path,...n?.symbols?{symbols:n.symbols}:{}}),!0},{direction:"incoming",maxDepth:1}),r}function Tt(t,e,r={}){let{testsOnly:s=!1,changedSymbols:n}=r,o=n?new _(e,n):null,i=[];return t.traverse(e,(a,l,p)=>{if(a.path===e)return!0;if(o&&p&&!o.updateAffectedSymbols(a,p))return!1;let h=a.category==="test"||a.tags.some(d=>d.name==="test");return(!s||h)&&i.push(a.path),!0},{direction:"incoming"}),i}function Nt(t,e,r={}){let{depth:s=1,withEdgeDetail:n=!1}=r,o=[];return t.traverseCalls(e,i=>{if(i.path===e)return!0;let a={file:i.path};return n&&(a.edges=(i.callEdges??[]).filter(l=>l.toFile===e).map(l=>({from:l.from,to:l.to}))),o.push(a),!0},{direction:"incoming",maxDepth:s}),o}function It(t,e={}){let{metric:r="cognitiveComplexity",threshold:s=10,limit:n=20}=e;return[...t.nodes.values()].flatMap(o=>(o.functions??[]).filter(i=>i[r]>=s).map(i=>({file:o.path,name:i.name,line:i.line,complexity:i.complexity,cognitiveComplexity:i.cognitiveComplexity}))).sort((o,i)=>i[r]-o[r]).slice(0,n)}function Mt(t){return{nodes:t.nodes.map(r=>({path:r.path,type:r.type,category:r.category,exports:r.exports.map(s=>s.name),tags:r.tags.filter(s=>s.kind==="comment-marker"||s.kind==="import").map(s=>s.name),importsFiles:r.imports.filter(s=>!s.isExternal&&s.toPath).map(s=>s.toPath),...r.description!==void 0&&{description:r.description},...r.testedBy!==void 0&&{testedBy:r.testedBy},...r.coveragePct!==void 0&&{coveragePct:r.coveragePct},...r.avgExportUsage!==void 0&&{avgExportUsage:r.avgExportUsage},...r.maxExportUsage!==void 0&&{maxExportUsage:r.maxExportUsage}})),cycles:t.cycles}}function At(t){let e=t.getPackageDependencies(),r=Array.from(t.packages.values()).map(({graph:s,pkg:n})=>({name:n.name,relativeRoot:n.relativeRoot,nodeCount:s.nodes.size,dependsOn:e.get(n.name)??[]}));return{monorepoType:t.type,packageCount:r.length,packages:r}}function Dt(t){return[...t.nodes.values()].some(e=>e.coveragePct!==void 0)}var Rt=m(()=>{"use strict";c();Oe()});function es(t){if(t.category==="test")return"test";if(t.category==="config")return"config";if(t.category==="type-only")return"types";let e=t.path;return x(e,"component")||x(e,"components")?"component":x(e,"controller")||x(e,"controllers")?"controller":x(e,"middleware")?"middleware":x(e,"router")||x(e,"routes")||x(e,"route")?"router":x(e,"store")||x(e,"stores")?"store":x(e,"service")||x(e,"services")?"service":x(e,"handler")||x(e,"handlers")?"handler":x(e,"adapter")||x(e,"adapters")?"adapter":x(e,"plugin")||x(e,"plugins")?"plugin":x(e,"api")?"api":x(e,"cli")||x(e,"commands")||ce(e)==="cli"?"cli":x(e,"util")||x(e,"utils")||x(e,"helper")||x(e,"helpers")?"util":x(e,"model")||x(e,"models")||ce(e)==="model"?"model":x(e,"parser")||x(e,"parsers")||ce(e)==="parser"?"parser":ce(e)==="builder"?"builder":ce(e)==="resolver"?"resolver":"other"}function x(t,e){return t.includes(`/${e}/`)||t.includes(`/${e}.`)}function ce(t){let e=t.slice(t.lastIndexOf("/")+1);return e.slice(0,e.lastIndexOf("."))||e}var ts=m(()=>{"use strict";c()});function Ot(t,e){let r=ne(t,e),s=new Map;for(let[o,i]of r.features){for(let a of i.files)s.set(a,o);s.set(i.hub,o)}let n=new Map;for(let o of t.nodes.values()){let i=s.get(o.path);n.set(o.path,{path:o.path,role:es(o),...o.description?{description:o.description}:{},exports:o.exports.map(a=>a.name),...i?{featureHub:i}:{}})}return n}var Gt=m(()=>{"use strict";c();Ae();ts()});function Lt(t,e){let r=[];for(let s of t.nodes.values())if(s.exports.some(n=>n.name===e))if(Re.has(s.type)){let n=[];for(let o of t.nodes.values())for(let i of o.callEdges??[])i.to===e&&n.push({file:o.path,callerFunction:i.from});r.push({path:s.path,category:s.category,precision:"call",callers:n})}else if(De.has(s.type)){let n=[];for(let o of t.nodes.values())for(let i of o.imports)i.toPath===s.path&&i.symbols?.includes(e)&&n.push({file:o.path,symbols:i.symbols});r.push({path:s.path,category:s.category,precision:"import-symbol",importers:n})}else{let n=ae(t,s.path).map(o=>({file:o.path,...o.symbols?{symbols:o.symbols}:{}}));r.push({path:s.path,category:s.category,precision:"file-level",importers:n})}return r}var rs=m(()=>{"use strict";c();Ft();Rt()});function ea(t){return t?t.startsWith("interface ")?"interface":t.startsWith("class ")?"class":t.startsWith("enum ")?"enum":"type":"type"}function ta(t,e){if(e==="type-only")return!0;let r=t.signature??"";return r.startsWith("interface ")||r.startsWith("class ")||r.startsWith("enum ")}function jt(t){let e=new Map;for(let s of t.nodes.values())if(!(s.type!=="typescript"&&s.type!=="javascript"))for(let n of s.exports){if(!ta(n,s.category))continue;let o=`${s.path}::${n.name}`;e.set(o,{name:n.name,file:s.path,kind:ea(n.signature),...n.doc?{doc:n.doc}:{}})}let r=[];for(let s of t.nodes.values())if(!(s.type!=="typescript"&&s.type!=="javascript")){for(let n of s.imports)if(!(!n.toPath||n.isExternal||!n.symbols?.length))for(let o of n.symbols)e.has(`${n.toPath}::${o}`)&&r.push({fromFile:s.path,toType:o,toFile:n.toPath})}return{types:e,edges:r}}function _t(t,e){let r=null;for(let o of t.types.values())if(o.name===e){r=o;break}if(!r)return{type:null,usedByFiles:[],uses:[]};let s=new Set,n=new Map;for(let o of t.edges)if(o.toType===e&&o.toFile===r.file&&s.add(o.fromFile),o.fromFile===r.file){let i=t.types.get(`${o.toFile}::${o.toType}`);i&&n.set(`${i.file}::${i.name}`,i)}return{type:r,usedByFiles:Array.from(s),uses:Array.from(n.values())}}var Wt=m(()=>{"use strict";c()});import ss from"fs";import Uf from"path";function ns(t){try{return ss.statSync(t,{throwIfNoEntry:!1})?.isDirectory()===!0}catch{return!1}}function Ge(t){try{return ss.statSync(t,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}var Le=m(()=>{"use strict";c()});import le from"fs";import T from"path";function zt(t,e){let r=T.join(e,"package.json");if(!le.existsSync(r))return null;let s={};try{s=JSON.parse(le.readFileSync(r,"utf-8"))}catch{return null}let n=s.name;return n?{name:n,root:e,relativeRoot:T.relative(t,e),entryPoints:ra(e,s)}:null}function ra(t,e){let r=[];if(e.exports){let n=e.exports;if(typeof n=="string")r.push(T.join(t,n));else if(typeof n=="object"&&n!==null){let o=n["."];if(typeof o=="string")r.push(T.join(t,o));else if(typeof o=="object"&&o!==null){let i=o.import??o.require??o.default;typeof i=="string"&&r.push(T.join(t,i))}}}e.main&&r.push(T.join(t,e.main));for(let n of["src/index.ts","src/index.tsx","index.ts","index.tsx","index.js"])r.push(T.join(t,n));let s=r.filter(Ge);return s.length>0?s.slice(0,1):r.slice(0,1)}function J(t,e){let r=[],s=new Set;for(let n of e){let o=n.replace(/\/$/,"").replace(/^\.\//,"");sa(t,o,s,r)}return r}function sa(t,e,r,s){if(!e.includes("*")){na(t,e,r,s);return}let n=e.split("/");n.includes("**")?oa(t,n,r,s):ia(t,n,r,s)}function na(t,e,r,s){let n=T.join(t,e);if(r.has(n)||!ns(n))return;r.add(n);let o=zt(t,n);o&&s.push(o)}function oa(t,e,r,s){let n=T.join(t,e[0]==="**"?"":e[0]??"");os(t,n,r,s)}function ia(t,e,r,s){let n=e.findIndex(a=>a.includes("*")),o=T.join(t,...e.slice(0,n)),i;try{i=le.readdirSync(o,{withFileTypes:!0})}catch{return}for(let a of i){if(!a.isDirectory())continue;let l=T.join(o,a.name);if(r.has(l))continue;r.add(l);let p=zt(t,l);p&&s.push(p)}}function os(t,e,r,s){let n;try{n=le.readdirSync(e,{withFileTypes:!0})}catch{return}for(let o of n){if(!o.isDirectory()||o.name==="node_modules"||o.name.startsWith("."))continue;let i=T.join(e,o.name);if(le.existsSync(T.join(i,"package.json"))&&!r.has(i)){r.add(i);let a=zt(t,i);a&&s.push(a)}else os(t,i,r,s)}}var je=m(()=>{"use strict";c();Le();Le()});import $t from"fs";import is from"path";var as,cs=m(()=>{"use strict";c();je();as={type:"npm",detect(t){let e=is.join(t,"package.json");if(!$t.existsSync(e))return null;let r;try{r=JSON.parse($t.readFileSync(e,"utf-8")).workspaces}catch{return null}if(!r||$t.existsSync(is.join(t,"yarn.lock")))return null;let s=Array.isArray(r)?r:r.packages??[];return s.length===0?null:J(t,s)}}});import K from"fs";import E from"path";function ps(t,e,r,s){if(s>4)return[];let n;try{n=K.readdirSync(e,{withFileTypes:!0})}catch{return[]}let o=[];for(let i of n){if(!i.isDirectory())continue;let a=i.name;if(a.startsWith(".")||a==="node_modules"||a==="dist"||a===".nx")continue;let l=E.join(e,a);K.existsSync(E.join(l,"project.json"))&&!r.has(l)?(r.add(l),o.push(l)):o.push(...ps(t,l,r,s+1))}return o}function aa(t,e,r){let s={};try{s=JSON.parse(K.readFileSync(r,"utf-8"))}catch{return null}let n=s.name,o,i,a=E.join(e,"package.json");if(K.existsSync(a))try{let l=JSON.parse(K.readFileSync(a,"utf-8"));n=l.name??n,o=l.main,i=l.exports}catch{}return n?{name:n,root:e,relativeRoot:E.relative(t,e),entryPoints:ca(e,s,o,i)}:null}function ca(t,e,r,s){let n=[],o=e.targets?.build?.options?.main??e.targets?.build?.options?.entryFile;if(o){let a=E.resolve(t,"../..");n.push(E.resolve(a,o)),n.push(E.resolve(t,o))}if(s){let a=s;if(typeof a=="string")n.push(E.join(t,a));else if(typeof a=="object"&&a!==null){let l=a["."];typeof l=="string"&&n.push(E.join(t,l))}}if(r&&n.push(E.join(t,r)),e.sourceRoot){let a=E.resolve(t,"../.."),l=E.resolve(a,e.sourceRoot);n.push(E.join(l,"index.ts"),E.join(l,"index.tsx"))}for(let a of["src/index.ts","src/index.tsx","index.ts","index.tsx"])n.push(E.join(t,a));let i=n.filter(Ge);return i.length>0?i.slice(0,1):n.slice(0,1)}var ls,fs=m(()=>{"use strict";c();Le();ls={type:"nx",detect(t){return K.existsSync(E.join(t,"nx.json"))?ps(t,t,new Set,0).map(r=>aa(t,r,E.join(r,"project.json"))).filter(r=>r!==null):null}}});import ms from"fs";import la from"path";import{load as pa}from"js-yaml";var us,gs=m(()=>{"use strict";c();je();us={type:"pnpm",detect(t){let e=la.join(t,"pnpm-workspace.yaml");if(!ms.existsSync(e))return null;let r=[];try{r=pa(ms.readFileSync(e,"utf-8"))?.packages??[]}catch{return null}return J(t,r)}}});import fa from"fs";import ma from"path";var ds,hs=m(()=>{"use strict";c();ds={type:"turborepo",detect(t){return fa.existsSync(ma.join(t,"turbo.json"))?[]:null}}});import Ut from"fs";import ys from"path";var xs,Ss=m(()=>{"use strict";c();je();xs={type:"yarn",detect(t){if(!Ut.existsSync(ys.join(t,"yarn.lock")))return null;let e=ys.join(t,"package.json");if(!Ut.existsSync(e))return null;let r;try{r=JSON.parse(Ut.readFileSync(e,"utf-8")).workspaces}catch{return null}if(!r)return null;let s=Array.isArray(r)?r:r.packages??[];return s.length===0?null:J(t,s)}}});function D(t){bs.push(t)}function Cs(){return bs}var bs,_e=m(()=>{"use strict";c();bs=[]});import ua from"path";function Bt(t,e=Cs()){let r=ua.resolve(t),s=new Map,n=[];for(let i of e){let a=i.detect(r);if(a!==null){n.push(i.type);for(let l of a)s.has(l.name)||s.set(l.name,l)}}if(n.length===0)return{root:r,type:"none",types:[],packages:[],packageMap:new Map};let o=Array.from(s.values());return{root:r,type:n[0],types:n,packages:o,packageMap:new Map(o.map(i=>[i.name,i]))}}var Jt=m(()=>{"use strict";c();cs();fs();gs();hs();Ss();_e();_e();D(ds);D(ls);D(us);D(xs);D(as)});var pe,Kt=m(()=>{"use strict";c();ie();pe=class t{constructor(e,r){this.monorepoRoot=e;this.type=r}monorepoRoot;type;packages=new Map;addPackage(e,r){this.packages.set(e.name,{graph:r,pkg:e})}getPackageForFile(e){for(let{pkg:r}of this.packages.values())if(e===r.relativeRoot||e.startsWith(`${r.relativeRoot}/`))return r}getPackageDependencies(){let e=new Map;for(let{graph:r,pkg:s}of this.packages.values()){let n=new Set;for(let o of r.nodes.values())for(let i of o.imports)i.isWorkspace&&i.workspacePackage&&n.add(i.workspacePackage);e.set(s.name,[...n])}return e}getAffectedAcrossPackages(e){let r=this.getPackageForFile(e);if(!r)return[];let s=this.packages.get(r.name);if(!s)return[];let n=[];s.graph.traverse(e,o=>(o.path!==e&&n.push({file:o.path,package:r.name}),!0),{direction:"incoming"});for(let{graph:o,pkg:i}of this.packages.values())if(i.name!==r.name)for(let a of o.nodes.values())a.imports.some(p=>p.isWorkspace&&p.workspacePackage===r.name)&&n.push({file:a.path,package:i.name});return n}serialize(){return{monorepoRoot:this.monorepoRoot,type:this.type,packages:Array.from(this.packages.values()).map(({graph:e,pkg:r})=>({pkg:{name:r.name,relativeRoot:r.relativeRoot,entryPoints:r.entryPoints},nodes:Array.from(e.nodes.values())}))}}static deserialize(e){let r=new t(e.monorepoRoot,e.type);for(let{pkg:s,nodes:n}of e.packages){let o=new Map(n.map(a=>[a.path,a])),i=new P(o);r.packages.set(s.name,{graph:i,pkg:{...s,root:""}})}return r}}});function H(t,e){vs.set(t,e)}function ks(t){return vs.get(t)}var vs,fe=m(()=>{"use strict";c();vs=new Map});function Es(t,e){return e.startsWith("!")?t!==e.slice(1):t===e}function ga(t,e){return e.startsWith("!")?!t.includes(e.slice(1)):t.includes(e)}function me(t,e,r){return $a.every(s=>s(t,e,r))}var da,ha,ya,xa,Sa,ba,Ca,va,ka,Ea,wa,Fa,Pa,Ta,Na,Ia,Ma,Aa,Da,Ra,Oa,Ga,La,ja,_a,Wa,za,$a,Ht=m(()=>{"use strict";c();da=(t,e)=>!e.category||Es(t.category,e.category),ha=(t,e)=>!e.type||Es(t.type,e.type),ya=(t,e)=>e.lastAuthor?e.lastAuthor.startsWith("!")?t.lastAuthor!==e.lastAuthor.slice(1):t.lastAuthor!==void 0&&t.lastAuthor===e.lastAuthor:!0,xa=(t,e)=>!e.path||ga(t.path,e.path),Sa=(t,e)=>e.isExternal===void 0?!0:t.imports.some(s=>s.isExternal)===e.isExternal,ba=(t,e)=>{if(!e.tags||e.tags.length===0)return!0;let r=e.tags.filter(n=>!n.startsWith("!")),s=e.tags.filter(n=>n.startsWith("!")).map(n=>n.slice(1));return!(r.length>0&&!r.some(n=>t.tags.some(o=>o.name===n))||s.some(n=>t.tags.some(o=>o.name===n)))},Ca=(t,e)=>!e.allTags?.length||e.allTags.every(r=>t.tags.some(s=>s.name===r)),va=(t,e)=>!e.importsFile||t.imports.some(r=>r.toPath?.includes(e.importsFile)),ka=(t,e,r)=>e.importedBy===void 0?!0:(r?.get(t.path)??[]).some(n=>n.includes(e.importedBy)),Ea=(t,e)=>e.minImports===void 0||t.imports.length>=e.minImports,wa=(t,e)=>e.maxImports===void 0||t.imports.length<=e.maxImports,Fa=(t,e)=>e.minSize===void 0||t.size>=e.minSize,Pa=(t,e)=>e.maxSize===void 0||t.size<=e.maxSize,Ta=(t,e)=>e.hasDocstring===void 0||!!t.description===e.hasDocstring,Na=(t,e)=>e.isDocumented===void 0||!!t.documentedBy?.length===e.isDocumented,Ia=(t,e)=>e.isStale===void 0||!!t.staleFor?.length===e.isStale,Ma=(t,e)=>e.minCoverage===void 0||(t.coveragePct??101)>=e.minCoverage,Aa=(t,e)=>e.maxCoverage===void 0||(t.coveragePct??0)<=e.maxCoverage,Da=(t,e)=>e.minExportUsage===void 0||(t.avgExportUsage??-1)>=e.minExportUsage,Ra=(t,e)=>e.maxExportUsage===void 0||(t.avgExportUsage??0)<=e.maxExportUsage,Oa=(t,e)=>e.minComplexity===void 0||(t.complexity??-1/0)>=e.minComplexity,Ga=(t,e)=>e.maxComplexity===void 0||(t.complexity??0)<=e.maxComplexity,La=(t,e)=>e.minCognitiveComplexity===void 0||(t.cognitiveComplexity??-1/0)>=e.minCognitiveComplexity,ja=(t,e)=>e.maxCognitiveComplexity===void 0||(t.cognitiveComplexity??0)<=e.maxCognitiveComplexity,_a=(t,e)=>e.minCommits===void 0||(t.commitCount90d??-1/0)>=e.minCommits,Wa=(t,e)=>e.maxCommits===void 0||(t.commitCount90d??0)<=e.maxCommits,za=(t,e,r)=>!e.any?.length||e.any.some(s=>me(t,s,r)),$a=[da,ha,ya,xa,Sa,ba,Ca,va,ka,Ea,wa,Fa,Pa,Ta,Na,Ia,Ma,Aa,Da,Ra,Oa,Ga,La,ja,_a,Wa,za]});function We(t,e){let r=new Map;if(e.importedBy!==void 0){for(let i of t.nodes)for(let a of i.imports)if(a.toPath){let l=r.get(a.toPath)??[];l.push(i.path),r.set(a.toPath,l)}}let s=t.nodes.filter(i=>me(i,e,r)),n=new Set(s.map(i=>i.path)),o=s.map(i=>({...i,imports:i.imports.filter(a=>!a.toPath||n.has(a.toPath))}));if(e.sort){let i=e.sortDir==="asc"?-1:1;o.sort((a,l)=>{let p=0;return e.sort==="size"?p=l.size-a.size:e.sort==="imports"?p=l.imports.length-a.imports.length:e.sort==="commitCount90d"?p=(l.commitCount90d??0)-(a.commitCount90d??0):e.sort==="exportUsage"?p=(l.avgExportUsage??0)-(a.avgExportUsage??0):e.sort==="complexity"?p=(l.complexity??0)-(a.complexity??0):e.sort==="cognitiveComplexity"&&(p=(l.cognitiveComplexity??0)-(a.cognitiveComplexity??0)),p*i})}return e.limit!==void 0&&o.splice(e.limit),{nodes:o,cycles:t.cycles?.filter(i=>i.every(a=>n.has(a)))??void 0}}var ws=m(()=>{"use strict";c();Ht();Ht()});function Fs(t,e){let r=e.indexOf(":");if(r===-1)return;let s=e.slice(0,r).trim().toLowerCase(),n=e.slice(r+1).trim();if(!(!s||!n))switch(s){case"category":t.category=n;break;case"type":t.type=n;break;case"tag":case"tags":n.includes("+")?t.allTags=[...t.allTags??[],...n.split("+")]:t.tags=[...t.tags??[],n];break;case"path":t.path=n;break;case"external":t.isExternal=n.toLowerCase()==="true";break;case"importsfile":t.importsFile=n;break;case"importedby":t.importedBy=n;break;case"minimports":t.minImports=parseInt(n,10);break;case"maximports":t.maxImports=parseInt(n,10);break;case"minsize":t.minSize=parseInt(n,10);break;case"maxsize":t.maxSize=parseInt(n,10);break;case"sort":t.sort=n;break;case"sortdir":t.sortDir=n.toLowerCase()==="asc"?"asc":"desc";break;case"limit":t.limit=parseInt(n,10);break;case"hasdocstring":t.hasDocstring=n.toLowerCase()!=="false";break;case"mincoverage":t.minCoverage=parseInt(n,10);break;case"maxcoverage":t.maxCoverage=parseInt(n,10);break;case"minexportusage":t.minExportUsage=parseFloat(n);break;case"maxexportusage":t.maxExportUsage=parseFloat(n);break;case"mincomplexity":t.minComplexity=parseInt(n,10);break;case"maxcomplexity":t.maxComplexity=parseInt(n,10);break;case"mincognitivecomplexity":t.minCognitiveComplexity=parseInt(n,10);break;case"maxcognitivecomplexity":t.maxCognitiveComplexity=parseInt(n,10);break;case"mincommits":t.minCommits=parseInt(n,10);break;case"maxcommits":t.maxCommits=parseInt(n,10);break;case"isdocumented":t.isDocumented=n.toLowerCase()!=="false";break;case"isstale":t.isStale=n.toLowerCase()!=="false";break;case"lastauthor":t.lastAuthor=n;break}}function Ua(t){let e=[];for(let r of t.split("|")){let s=r.trim();if(!s)continue;let n={};Fs(n,s),Object.keys(n).length>0&&e.push(n)}return e}function ze(t){let e={},r=t.split(",");for(let s of r){let n=s.trim();if(n.toLowerCase().startsWith("any(")&&n.endsWith(")")){let o=n.slice(4,-1),i=Ua(o);i.length>0&&(e.any=[...e.any??[],...i]);continue}Fs(e,s)}return e}var Ps=m(()=>{"use strict";c()});var Ts=m(()=>{"use strict";c();ws();Ps()});import w from"typescript";function Q(t){let e=[];for(let r of t.statements){if(!w.isExpressionStatement(r))continue;let s=r.expression;if(!w.isCallExpression(s))continue;let n=s.expression;w.isIdentifier(n)&&Ns.has(n.text)&&e.push(s),w.isPropertyAccessExpression(n)&&w.isIdentifier(n.expression)&&Ns.has(n.expression.text)&&e.push(s)}return e}function V(t,e,r){for(let s of t.arguments){if(!w.isObjectLiteralExpression(s))continue;let n=s.properties.find(o=>w.isPropertyAssignment(o)&&w.isIdentifier(o.name)&&o.name.text===e);if(!(!n||!w.isArrayLiteralExpression(n.initializer)))return n.initializer.elements.filter(w.isStringLiteral).map(o=>o.text)}return null}function X(t,e,r,s){if(t.arguments.length===0)return null;for(let o=1;o<t.arguments.length;o++){let i=t.arguments[o];if(!w.isObjectLiteralExpression(i))continue;let a=i.properties.find(p=>w.isPropertyAssignment(p)&&w.isIdentifier(p.name)&&p.name.text===e);if(a)return{start:a.initializer.getStart(s),end:a.initializer.getEnd(),text:r};let l=i.getEnd()-1;return{start:l,end:l,text:`${i.properties.length>0?", ":""}${e}: ${r}`}}let n=t.arguments[t.arguments.length-1];return{start:n.getStart(s),end:n.getStart(s),text:`{ ${e}: ${r} }, `}}function Y(t,e,r){let s=t.arguments;for(let n=1;n<s.length;n++){let o=s[n];if(!w.isObjectLiteralExpression(o))continue;let i=o.properties.findIndex(l=>w.isPropertyAssignment(l)&&w.isIdentifier(l.name)&&l.name.text===e);if(i<0)continue;if(o.properties.length===1)return{start:s[n-1].getEnd(),end:o.getEnd(),text:""};let a=o.properties[i];return i===o.properties.length-1?{start:o.properties[i-1].getEnd(),end:a.getEnd(),text:""}:{start:a.getStart(r),end:o.properties[i+1].getStart(r),text:""}}return null}function q(t,e){let r=[...e].sort((n,o)=>o.start-n.start),s=t;for(let n of r)s=s.slice(0,n.start)+n.text+s.slice(n.end);return s}function Z(t){return`[${t.map(e=>JSON.stringify(e)).join(", ")}]`}var Ns,A,ee=m(()=>{"use strict";c();Ns=new Set(["describe","test","it"]);A=new Set([".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"])});import Is from"path";import Ms from"typescript";function Ba(t){return Z(t.map(e=>`@${e}`))}function Ja(t){return t.map(e=>e.startsWith("@")?e.slice(1):e)}var $e,As=m(()=>{"use strict";c();ee();$e=class{name="cypress";canHandle(e){return A.has(Is.extname(e).toLowerCase())}apply(e,r,s){let n=Ms.createSourceFile(Is.basename(e),r,Ms.ScriptTarget.Latest,!0),o=Q(n);if(o.length===0)return r;let i=V(o[0],"tags",n),a=[...s].sort();if(i!==null&&JSON.stringify(Ja(i).sort())===JSON.stringify(a))return r;let l=o.flatMap(p=>{let h=s.length===0?Y(p,"tags",n):X(p,"tags",Ba(a),n);return h?[h]:[]});return l.length>0?q(r,l):r}}});import Ka from"path";function Ha(t){return["# <mokosh-tags>",...t.map(e=>`@${e}`),"# </mokosh-tags>"].join(`
4
4
  `)+`
5
5
 
6
- `}function bc(t){let e=new Set;Ht.lastIndex=0;let r=Ht.exec(t);for(;r!==null;)r[1]&&e.add(r[1]),r=Ht.exec(t);return e}var Kt,Ht,ze,Us=m(()=>{"use strict";c();Kt=/# <mokosh-tags>[\s\S]*?# <\/mokosh-tags>\n*/,Ht=/^@([a-zA-Z0-9_-]+)/gm;ze=class{name="gherkin";canHandle(e){return xc.extname(e).toLowerCase()===".feature"}apply(e,r,s){let n=r.replace(Kt,""),o=bc(n),i=s.filter(p=>!o.has(p)),a=i.length>0?Sc(i):"";return Kt.test(r)?r.replace(Kt,a):a?r.replace(/^(Feature:)/m,`${a}$1`):r}}});function Bs(t,e){let r=t.replace(/\\/g,"/"),s=e.replace(/\\/g,"/"),n="";for(let o=0;o<r.length;o++){let i=r[o];i==="*"?r[o+1]==="*"?(n+=".*",o++):n+="[^/]*":i==="?"?n+="[^/]":i!==void 0&&(n+=i.replace(/[.+^${}()|[\]\\]/g,"\\$&"))}return new RegExp(`^${n}$`).test(s)}var Js=m(()=>{"use strict";c()});import Cc from"path";function kc(t){return`//go:build ${t.map(r=>`mokosh_${r}`).join(" || ")}
7
- `}function wc(t){let e=Qt.exec(t);if(!e)return null;let r=e[0],s=/mokosh_([a-zA-Z0-9_-]+)/g,n=[],o=s.exec(r);for(;o!==null;)o[1]&&n.push(o[1]),o=s.exec(r);return n}var Qt,vc,$e,Ks=m(()=>{"use strict";c();Qt=/^\/\/go:build mokosh_[^\n]+\n/m,vc=/^package\s+\S+/m;$e=class{name="go";canHandle(e){return Cc.basename(e).endsWith("_test.go")}apply(e,r,s){let n=wc(r),o=[...s].sort();if(n!==null&&JSON.stringify([...n].sort())===JSON.stringify(o))return r;if(s.length===0)return r.replace(Qt,"");let i=kc(o);if(n!==null)return r.replace(Qt,i);let a=vc.exec(r);if(!a)return r;let p=a.index;return r.slice(0,p)+i+`
8
- `+r.slice(p)}}});import Ec from"path";function Pc(t){return["/**",...t.map(e=>` * @group ${e}`)," */"].join(`
6
+ `}function Qa(t){let e=new Set;Vt.lastIndex=0;let r=Vt.exec(t);for(;r!==null;)r[1]&&e.add(r[1]),r=Vt.exec(t);return e}var Qt,Vt,Ue,Ds=m(()=>{"use strict";c();Qt=/# <mokosh-tags>[\s\S]*?# <\/mokosh-tags>\n*/,Vt=/^@([a-zA-Z0-9_-]+)/gm;Ue=class{name="gherkin";canHandle(e){return Ka.extname(e).toLowerCase()===".feature"}apply(e,r,s){let n=r.replace(Qt,""),o=Qa(n),i=s.filter(l=>!o.has(l)),a=i.length>0?Ha(i):"";return Qt.test(r)?r.replace(Qt,a):a?r.replace(/^(Feature:)/m,`${a}$1`):r}}});function Rs(t,e){let r=t.replace(/\\/g,"/"),s=e.replace(/\\/g,"/"),n="";for(let o=0;o<r.length;o++){let i=r[o];i==="*"?r[o+1]==="*"?(n+=".*",o++):n+="[^/]*":i==="?"?n+="[^/]":i!==void 0&&(n+=i.replace(/[.+^${}()|[\]\\]/g,"\\$&"))}return new RegExp(`^${n}$`).test(s)}var Os=m(()=>{"use strict";c()});import Va from"path";function Ya(t){return`//go:build ${t.map(r=>`mokosh_${r}`).join(" || ")}
7
+ `}function qa(t){let e=Xt.exec(t);if(!e)return null;let r=e[0],s=/mokosh_([a-zA-Z0-9_-]+)/g,n=[],o=s.exec(r);for(;o!==null;)o[1]&&n.push(o[1]),o=s.exec(r);return n}var Xt,Xa,Be,Gs=m(()=>{"use strict";c();Xt=/^\/\/go:build mokosh_[^\n]+\n/m,Xa=/^package\s+\S+/m;Be=class{name="go";canHandle(e){return Va.basename(e).endsWith("_test.go")}apply(e,r,s){let n=qa(r),o=[...s].sort();if(n!==null&&JSON.stringify([...n].sort())===JSON.stringify(o))return r;if(s.length===0)return r.replace(Xt,"");let i=Ya(o);if(n!==null)return r.replace(Xt,i);let a=Xa.exec(r);if(!a)return r;let l=a.index;return r.slice(0,l)+i+`
8
+ `+r.slice(l)}}});import Za from"path";function tc(t){return["/**",...t.map(e=>` * @group ${e}`)," */"].join(`
9
9
  `)+`
10
10
 
11
- `}function Tc(t){let e=[];Vt.lastIndex=0;let r=Vt.exec(t);for(;r!==null;)r[1]&&e.push(r[1]),r=Vt.exec(t);return e}var Fc,Vt,Ue,Hs=m(()=>{"use strict";c();te();Fc=/^\/\*\*\n(?: \* @group .+\n)+ \*\/\n+/,Vt=/^ \* @group (.+)$/gm;Ue=class{name="jest";canHandle(e){return A.has(Ec.extname(e).toLowerCase())}apply(e,r,s){let n=Fc.exec(r),o=n?Tc(n[0]):null,i=[...s].sort();if(o!==null&&JSON.stringify([...o].sort())===JSON.stringify(i))return r;let a=n?r.slice(n[0].length):r;return s.length===0?a:Pc(i)+a}}});import Qs from"path";import Vs from"typescript";function Nc(t){return ee(t.map(e=>`@${e}`))}function Ic(t){return t.map(e=>e.startsWith("@")?e.slice(1):e)}var Be,Xs=m(()=>{"use strict";c();te();Be=class{name="playwright";canHandle(e){return A.has(Qs.extname(e).toLowerCase())}apply(e,r,s){let n=Vs.createSourceFile(Qs.basename(e),r,Vs.ScriptTarget.Latest,!0),o=V(n);if(o.length===0)return r;let i=X(o[0],"tag",n),a=[...s].sort();if(i!==null&&JSON.stringify(Ic(i).sort())===JSON.stringify(a))return r;let p=o.flatMap(l=>{let d=s.length===0?Y(l,"tag",n):q(l,"tag",Nc(a),n);return d?[d]:[]});return p.length>0?Z(r,p):r}}});import Mc from"path";function Ac(t){let e=t.map(r=>`pytest.mark.${r}`).join(", ");return t.length===1?`pytestmark = pytest.mark.${t[0]}`:`pytestmark = [${e}]`}function Rc(t){let e=Xt.exec(t);if(!e)return null;let r=e[0],s=[],n=/pytest\.mark\.([a-zA-Z0-9_-]+)/g,o=n.exec(r);for(;o!==null;)o[1]&&s.push(o[1]),o=n.exec(r);return s}function Oc(t){let e=t.split(`
12
- `),r=-1;for(let n=0;n<e.length;n++){let o=e[n].trimStart();(o.startsWith("import ")||o.startsWith("from "))&&(r=n)}if(r<0)return 0;let s=0;for(let n=0;n<=r;n++)s+=e[n].length+1;return s}var Xt,Dc,Je,qs=m(()=>{"use strict";c();Xt=/^pytestmark\s*=\s*.+$/m,Dc=/^import pytest\s*$/m;Je=class{name="pytest";canHandle(e){return Mc.extname(e).toLowerCase()===".py"}apply(e,r,s){let n=Rc(r),o=[...s].sort();if(n!==null&&JSON.stringify([...n].sort())===JSON.stringify(o))return r;if(s.length===0)return r.replace(Xt,"").replace(/\n{3,}/g,`
11
+ `}function rc(t){let e=[];Yt.lastIndex=0;let r=Yt.exec(t);for(;r!==null;)r[1]&&e.push(r[1]),r=Yt.exec(t);return e}var ec,Yt,Je,Ls=m(()=>{"use strict";c();ee();ec=/^\/\*\*\n(?: \* @group .+\n)+ \*\/\n+/,Yt=/^ \* @group (.+)$/gm;Je=class{name="jest";canHandle(e){return A.has(Za.extname(e).toLowerCase())}apply(e,r,s){let n=ec.exec(r),o=n?rc(n[0]):null,i=[...s].sort();if(o!==null&&JSON.stringify([...o].sort())===JSON.stringify(i))return r;let a=n?r.slice(n[0].length):r;return s.length===0?a:tc(i)+a}}});import js from"path";import _s from"typescript";function sc(t){return Z(t.map(e=>`@${e}`))}function nc(t){return t.map(e=>e.startsWith("@")?e.slice(1):e)}var Ke,Ws=m(()=>{"use strict";c();ee();Ke=class{name="playwright";canHandle(e){return A.has(js.extname(e).toLowerCase())}apply(e,r,s){let n=_s.createSourceFile(js.basename(e),r,_s.ScriptTarget.Latest,!0),o=Q(n);if(o.length===0)return r;let i=V(o[0],"tag",n),a=[...s].sort();if(i!==null&&JSON.stringify(nc(i).sort())===JSON.stringify(a))return r;let l=o.flatMap(p=>{let h=s.length===0?Y(p,"tag",n):X(p,"tag",sc(a),n);return h?[h]:[]});return l.length>0?q(r,l):r}}});import oc from"path";function ac(t){let e=t.map(r=>`pytest.mark.${r}`).join(", ");return t.length===1?`pytestmark = pytest.mark.${t[0]}`:`pytestmark = [${e}]`}function cc(t){let e=qt.exec(t);if(!e)return null;let r=e[0],s=[],n=/pytest\.mark\.([a-zA-Z0-9_-]+)/g,o=n.exec(r);for(;o!==null;)o[1]&&s.push(o[1]),o=n.exec(r);return s}function lc(t){let e=t.split(`
12
+ `),r=-1;for(let n=0;n<e.length;n++){let o=e[n].trimStart();(o.startsWith("import ")||o.startsWith("from "))&&(r=n)}if(r<0)return 0;let s=0;for(let n=0;n<=r;n++)s+=e[n].length+1;return s}var qt,ic,He,zs=m(()=>{"use strict";c();qt=/^pytestmark\s*=\s*.+$/m,ic=/^import pytest\s*$/m;He=class{name="pytest";canHandle(e){return oc.extname(e).toLowerCase()===".py"}apply(e,r,s){let n=cc(r),o=[...s].sort();if(n!==null&&JSON.stringify([...n].sort())===JSON.stringify(o))return r;if(s.length===0)return r.replace(qt,"").replace(/\n{3,}/g,`
13
13
 
14
- `);let i=Ac(o);if(n!==null)return r.replace(Xt,i);let a=Dc.test(r),p=Oc(r),l=r.slice(0,p),d=r.slice(p),h=a?"":`import pytest
15
- `,x=l.endsWith(`
14
+ `);let i=ac(o);if(n!==null)return r.replace(qt,i);let a=ic.test(r),l=lc(r),p=r.slice(0,l),h=r.slice(l),d=a?"":`import pytest
15
+ `,S=p.endsWith(`
16
16
 
17
17
  `)?"":`
18
- `;return l+x+h+i+`
19
- `+d}}});import Ys from"path";import Zs from"typescript";var Gc,Ke,en=m(()=>{"use strict";c();te();Gc=/\/\/ <mokosh-tags>[\s\S]*?\/\/ <\/mokosh-tags>\n*/,Ke=class{name="vitest";canHandle(e){return A.has(Ys.extname(e).toLowerCase())}apply(e,r,s){let n=r.replace(Gc,""),o=Zs.createSourceFile(Ys.basename(e),n,Zs.ScriptTarget.Latest,!0),i=V(o);if(i.length===0)return n;let a=X(i[0],"tags",o),p=[...s].sort();if(a!==null&&JSON.stringify([...a].sort())===JSON.stringify(p))return n;let l=i.flatMap(d=>{let h=s.length===0?Y(d,"tags",o):q(d,"tags",ee(p),o);return h?[h]:[]});return l.length>0?Z(n,l):n}}});import qt from"path";import He from"typescript";function jc(t){let e=He.createSourceFile("detect.ts",t,He.ScriptTarget.Latest,!0);for(let r of e.statements){if(!He.isImportDeclaration(r)||!He.isStringLiteral(r.moduleSpecifier))continue;let s=Lc[r.moduleSpecifier.text];if(s)return s}return null}function rn(t="vitest",e={},r=process.cwd()){return[new ze,new Je,new $e,new Yt(r,t,Object.entries(e))]}function sn(t,e){return e.find(r=>r.canHandle(t))??null}var tn,Lc,Yt,nn=m(()=>{"use strict";c();$s();Us();Js();Ks();Hs();Xs();qs();te();en();tn={vitest:()=>new Ke,playwright:()=>new Be,cypress:()=>new We,jest:()=>new Ue},Lc={"@playwright/test":"playwright",cypress:"cypress","@jest/globals":"jest",vitest:"vitest"};Yt=class{constructor(e,r,s){this.rootDir=e;this.defaultFramework=r;this.frameworkOverrides=s}rootDir;defaultFramework;frameworkOverrides;name="auto";canHandle(e){return A.has(qt.extname(e).toLowerCase())}apply(e,r,s){let n=jc(r)??this.matchOverride(e)??this.defaultFramework;return(tn[n]??tn.vitest)().apply(e,r,s)}matchOverride(e){let r=qt.relative(this.rootDir,e).split(qt.sep).join("/");for(let[s,n]of this.frameworkOverrides)if(Bs(s,r))return n;return null}}});import on from"fs/promises";import _c from"path";async function Uc(t,e,r,s){let n;try{n=await on.readFile(t,"utf8")}catch(a){return{path:t,status:"error",error:String(a)}}let o=sn(t,s);if(!o)return{path:t,status:"unchanged"};let i=o.apply(t,n,e);return i===n?{path:t,status:"unchanged"}:(r||await on.writeFile(t,i,"utf8"),{path:t,status:"updated"})}async function Zt(t,e,r){let s=J(e),n=s.tagApplier?.framework??"vitest",o=s.tagApplier?.frameworkOverrides??{},i=rn(n,o,e),a={updated:0,unchanged:0,errors:0,files:[]};for(let p of t.nodes.values()){if(p.category!=="test")continue;let l=new Set,d=[];for(let C of p.tags)zc.has(C.kind)&&Wc.test(C.name)&&($c.has(C.name.toLowerCase())||l.has(C.name)||(l.add(C.name),d.push(C.name)));d.sort();let h=_c.resolve(e,p.path),x=await Uc(h,d,r.dryRun,i);x.path=p.path,a.files.push(x),x.status==="updated"?a.updated++:x.status==="unchanged"?a.unchanged++:a.errors++}return a}var Wc,zc,$c,an=m(()=>{"use strict";c();ut();nn();Wc=/^[a-zA-Z][a-zA-Z0-9_-]{1,}$/,zc=new Set(["import"]),$c=new Set(["common","fixture","fixtures","helper","helpers","index","main","mock","mocks","setup","shared","spec","test","tests","types","util","utils"])});var Qe,er=m(()=>{"use strict";c();Qe=class{isTestNode(e){return e.category==="test"||e.tags.some(r=>r.name==="test")}}});import{execFileSync as tr}from"child_process";function ln(t,e){let r="",s=0;for(let n of t.split(`
20
- `)){if(n.startsWith("\0")){let[,p,l]=n.slice(1).split(" ");r=p??"",s=l?Number(l)*1e3:0;continue}if(n==="")continue;let o=n.split(" "),i=o[0];if(!i)continue;let a=i.startsWith("R")||i.startsWith("C")?o[2]:o[1];a&&e(a,r,s)}}function fn(t){let e=new Map;try{let r=tr("git",["-C",t,"log","--since=90 days ago","--name-status","-M",`--format=${cn}`],{encoding:"utf-8",stdio:["ignore","pipe","ignore"],maxBuffer:pn});ln(r,(s,n,o)=>{let i=e.get(s);if(i){i.commitCount90d+=1;return}e.set(s,{commitCount90d:1,lastAuthor:n||void 0,lastCommitAt:o||void 0})})}catch{return e}try{let r=tr("git",["-C",t,"log","--name-status","-M",`--format=${cn}`],{encoding:"utf-8",stdio:["ignore","pipe","ignore"],maxBuffer:pn});ln(r,(s,n,o)=>{e.has(s)||e.set(s,{commitCount90d:0,lastAuthor:void 0,lastCommitAt:o||void 0})})}catch{}return e}var Ve,cn,pn,rr=m(()=>{"use strict";c();Ve=class{getChangedFiles(){try{let r=[["diff","--name-only"],["diff","--cached","--name-only"],["ls-files","--others","--exclude-standard"]].flatMap(s=>{try{return tr("git",s,{encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).split(`
21
- `).map(o=>o.trim()).filter(o=>o!=="")}catch{return[]}});return Array.from(new Set(r))}catch(e){return console.error("Error getting git diff:",e),[]}}},cn="%x00%H%x09%ae%x09%at",pn=256*1024*1024});import Xe from"fs";import Bc from"path";import{load as mn}from"js-yaml";function un(t){let e=t.lastIndexOf("@");return e>0?t.substring(0,e):t}function Jc(t){return t.replace(/:$/,"").split(",").map(e=>{let r=e.trim();return r.startsWith('"')&&(r=r.slice(1)),r.endsWith('"')&&(r=r.slice(0,-1)),un(r)}).filter(Boolean)}function Kc(t,e){let r=t.startsWith("/")?t.slice(1):t,s=r.lastIndexOf("@");return s>0?{name:r.substring(0,s),version:e||r.substring(s+1)}:{name:r,version:e}}function Hc(t){try{let e=mn(t),r={dependencies:{}};for(let[s,n]of Object.entries(e))if(!(s==="__metadata"||!n?.version))for(let o of s.split(", ")){let i=un(o);i&&(r.dependencies[i]={version:n.version,...n.dependencies!==void 0&&{dependencies:n.dependencies}})}return r}catch{return null}}function Qc(t){let e={dependencies:{}};for(let r of t.split(/\n\n+/)){let s=r.split(`
22
- `).filter(p=>p.trim().length>0&&!p.trim().startsWith("#"));if(s.length<2)continue;let n=s[0];if(!n||n.startsWith(" "))continue;let o=Jc(n);if(o.length===0)continue;let a=s.find(p=>p.trim().startsWith('version "'))?.match(/version "(.*?)"/)?.[1]??"";for(let p of o)e.dependencies[p]={version:a}}return e}function Vc(t){let e=Xe.readFileSync(t,"utf-8"),r=JSON.parse(e),s={dependencies:{}};if(r.packages)for(let[n,o]of Object.entries(r.packages)){if(!n.startsWith("node_modules/"))continue;let i=n.replace("node_modules/","");i.includes("node_modules/")||(s.dependencies[i]={version:o.version,...o.dependencies!==void 0&&{dependencies:o.dependencies}})}else if(r.dependencies)for(let[n,o]of Object.entries(r.dependencies))s.dependencies[n]={version:o.version,...o.dependencies!==void 0&&{dependencies:o.dependencies}};return s}function Xc(t){let e=Xe.readFileSync(t,"utf-8");if(e.includes("__metadata:")){let r=Hc(e);if(r!==null)return r}return Qc(e)}function qc(t){let e=Xe.readFileSync(t,"utf-8"),r={dependencies:{}};try{let s=mn(e);if(s.packages)for(let[n,o]of Object.entries(s.packages)){let{name:i,version:a}=Kc(n,o.version);i&&(r.dependencies[i]={version:a,...o.dependencies!==void 0&&{dependencies:o.dependencies}})}if(s.dependencies)for(let[n,o]of Object.entries(s.dependencies)){if(r.dependencies[n])continue;let i=typeof o=="string"?o:o.version;r.dependencies[n]={version:i||""}}}catch{}return r}function gn(t){let e=[["package-lock.json",Vc],["yarn.lock",Xc],["pnpm-lock.yaml",qc]];for(let[r,s]of e){let n=Bc.join(t,r);if(Xe.existsSync(n))return s(n)}return null}var dn=m(()=>{"use strict";c()});import hn from"path";function L(t){switch(hn.extname(t).toLowerCase()){case".js":case".jsx":case".mjs":case".cjs":return"javascript";case".ts":case".tsx":return"typescript";case".css":return"css";case".scss":case".sass":return"scss";case".less":return"less";case".styl":return"stylus";case".coffee":return"coffeescript";case".ls":return"livescript";case".lua":return"lua";case".py":return"python";case".go":return"go";case".java":case".cpp":case".cc":case".cxx":case".c":return"unknown";case".feature":return"gherkin";case".md":case".mdx":return"markdown";default:return"unknown"}}function N(t){let e=hn.extname(t).toLowerCase();return[".css",".scss",".sass",".less",".styl"].includes(e)}var j=m(()=>{"use strict";c()});import Yc from"coffeescript";function Zc(t){let e=new Set,r=/@tag\s+([a-zA-Z0-9_-]+)/g,s=r.exec(t);for(;s!==null;)s[1]&&e.add(s[1]),s=r.exec(t);return e}function ep(t,e){let r=t.toLowerCase();return r.includes(".test.")||r.includes(".spec.")||e.has("test")?"test":"logic"}function tp(t,e){let r=e.source?.value;return r?{fromPath:t,toPath:"",rawSpecifier:r,isStyle:N(r),type:"static"}:null}function rp(t,e){let r=e.variable?.base?.value==="require",s=e.args?.[0]?.base?.value;return!r||!s?null:{fromPath:t,toPath:"",rawSpecifier:s,isStyle:N(s),type:"require"}}function sp(t,e,r){let s=e.constructor?.name;if(s==="ImportDeclaration"){let n=tp(t,e);n&&r.push(n)}else if(s==="Call"){let n=rp(t,e);n&&r.push(n)}}function sr(t,e,r){if(!(!e||typeof e!="object")){sp(t,e,r);for(let s in e){if(s==="locationData")continue;let n=e[s];if(!(!n||typeof n!="object"))if(Array.isArray(n))for(let o of n)sr(t,o,r);else sr(t,n,r)}}}function yn(t,e){let r=Zc(e),s=ep(t,r),n=[];try{sr(t,Yc.nodes(e),n)}catch{}return{imports:n,exports:[],tags:Array.from(r).map(o=>({name:o,kind:"comment-marker"})),category:s}}var xn=m(()=>{"use strict";c();j()});import{AstBuilder as np,GherkinClassicTokenMatcher as op,Parser as ip}from"@cucumber/gherkin";import{IdGenerator as ap}from"@cucumber/messages";function nr(t,e){let r=new Set;try{let s=new np(cp),n=new op,i=new ip(s,n).parse(e);i.feature&&(i.feature.tags.forEach(a=>{r.add(a.name.startsWith("@")?a.name.slice(1):a.name)}),i.feature.children.forEach(a=>{a.scenario&&(a.scenario.tags.forEach(p=>{r.add(p.name.startsWith("@")?p.name.slice(1):p.name)}),a.scenario.examples.forEach(p=>{p.tags.forEach(l=>{r.add(l.name.startsWith("@")?l.name.slice(1):l.name)})})),a.rule&&a.rule.children.forEach(p=>{p.scenario&&p.scenario.tags.forEach(l=>{r.add(l.name.startsWith("@")?l.name.slice(1):l.name)})})}))}catch(s){console.warn(`[GherkinParser] Failed to parse ${t}:`,s)}return{imports:[],exports:[],tags:Array.from(r).map(s=>({name:s,kind:"comment-marker"})),category:"test"}}var cp,Sn=m(()=>{"use strict";c();fe();cp=ap.uuid();Q("gherkin",nr)});import pp from"path";import{parser as lp}from"@lezer/go";function Cn(t,e){let r=[],s=new Map,n=new Set,o=new Set,a=lp.parse(e).cursor();do switch(a.name){case"LineComment":{let h=e.slice(a.from,a.to),x=h.match(fp);x?.[1]&&n.add(x[1]);let C=h.match(mp);C&&bn(C[1],o);let I=h.match(up);I&&bn(I[1],o);break}case"ImportSpec":{let h=a.node.getChild("String");if(h){let C=e.slice(h.from,h.to).slice(1,-1);r.push({fromPath:t,toPath:"",rawSpecifier:C,isExternal:!0,isStyle:!1,type:"static"})}break}case"FunctionDecl":case"TypeDecl":case"VarDecl":case"ConstDecl":{let h=a.node.getChild("DefName")??a.node.getChild("TypeSpec")?.getChild("DefName")??a.node.getChild("VarSpec")?.getChild("DefName")??a.node.getChild("ConstSpec")?.getChild("DefName");if(h){let x=e.slice(h.from,h.to);x!=="_"&&/^[A-Z]/.test(x)&&!s.has(x)&&s.set(x,{name:x})}break}}while(a.next());let p=r.some(h=>h.rawSpecifier==="testing"),l=pp.basename(t).endsWith("_test.go")||n.has("test")||p?"test":"logic",d=new Set([...n,...o]);return{imports:r,exports:Array.from(s.values()),tags:Array.from(d).map(h=>({name:h,kind:"comment-marker"})),category:l}}function bn(t,e){for(let r of t.split(/[\s,&|!()]+/)){let s=r.trim();s&&s!=="ignore"&&e.add(s)}}var fp,mp,up,vn=m(()=>{"use strict";c();fp=/\/\/\s*@tag\s+([a-zA-Z0-9_-]+)/,mp=/^\/\/go:build\s+(.+)$/,up=/^\/\/\s*\+build\s+(.+)$/});function re(t){return t.startsWith("'")||t.startsWith('"')?t.slice(1,-1):t}var or=m(()=>{"use strict";c()});import gp from"livescript";function dp(t){let e=new Set,r=/@tag\s+([a-zA-Z0-9_-]+)/g,s=r.exec(t);for(;s!==null;)s[1]&&e.add(s[1]),s=r.exec(t);return e}function hp(t,e){let r=t.toLowerCase();return r.includes(".test.")||r.includes(".spec.")||e.has("test")?"test":"logic"}function xp(t,e){let r=t.constructor?.name||t.type;if(r==="Import"){let s=t.right?.value;if(typeof s=="string"){let n=re(s);return{fromPath:e,toPath:"",rawSpecifier:n,isStyle:N(n),type:"static"}}}if(r==="Chain"&&t.head?.value==="require"){let s=t.tails?.[0];if(s?.constructor?.name==="Call"||s?.type==="Call"){let n=s.args?.[0]?.value;if(typeof n=="string"){let o=re(n);return{fromPath:e,toPath:"",rawSpecifier:o,isStyle:N(o),type:"require"}}}}return null}function ir(t,e){if(!t||typeof t!="object")return[];let r=[],s=xp(t,e);s&&r.push(s);for(let n in t){if(yp.has(n))continue;let o=t[n];if(!(!o||typeof o!="object"))if(Array.isArray(o))for(let i of o)r.push(...ir(i,e));else r.push(...ir(o,e))}return r}function kn(t,e){let r=dp(e),s=hp(t,r),n=[];try{n=ir(gp.ast(e),t)}catch{}return{imports:n,exports:[],tags:Array.from(r).map(o=>({name:o,kind:"comment-marker"})),category:s}}var yp,wn=m(()=>{"use strict";c();j();or();yp=new Set(["first_line","first_column","last_line","last_column","line","column"])});import Sp from"luaparse";function bp(t){let e=new Set,r=/@tag\s+([a-zA-Z0-9_-]+)/g,s=r.exec(t);for(;s!==null;)s[1]&&e.add(s[1]),s=r.exec(t);return e}function Cp(t,e){let r=t.toLowerCase();return r.includes(".test.")||r.includes(".spec.")||e.has("test")?"test":"logic"}function vp(t,e){let r=[];function s(n){if(!(!n||typeof n!="object")){if((n.type==="CallExpression"||n.type==="StringCallExpression")&&n.base?.type==="Identifier"&&n.base?.name==="require"){let o;if(n.type==="CallExpression"){let i=n.arguments?.[0];i?.type==="StringLiteral"&&(o=re(i.raw))}else if(n.type==="StringCallExpression"){let i=n.argument;i?.type==="StringLiteral"&&(o=re(i.raw))}o&&r.push({fromPath:e,toPath:"",rawSpecifier:o,isStyle:N(o),type:"require"})}for(let o in n){if(o==="loc")continue;let i=n[o];if(i&&typeof i=="object")if(Array.isArray(i))for(let a of i)s(a);else s(i)}}}return s(t),r}function En(t,e){let r=bp(e),s=Cp(t,r),n=[];try{let o=Sp.parse(e);n=vp(o,t)}catch{}return{imports:n,exports:[],tags:Array.from(r).map(o=>({name:o,kind:"comment-marker"})),category:s}}var Fn=m(()=>{"use strict";c();j();or()});async function Fp(){return Pn??=(async()=>{let{unified:t}=await import("unified"),e=(await import("remark-parse")).default;return t().use(e)})(),Pn}function Pp(t){let e=t.trim();return e.length===0||e.startsWith("#")||kp.some(r=>e.startsWith(r))}function Tp(t,e){let r=t.match(Ep);return r?r.map(s=>({fromPath:e,toPath:"",rawSpecifier:s,isStyle:!1,type:"static"})):[]}function Tn(t,e,r){if(t.type==="link"&&typeof t.url=="string"&&!Pp(t.url)&&r.push({fromPath:e,toPath:"",rawSpecifier:t.url,isStyle:!1,type:"static"}),(t.type==="code"||t.type==="inlineCode")&&typeof t.value=="string"&&r.push(...Tp(t.value,e)),Array.isArray(t.children))for(let s of t.children)Tn(s,e,r)}async function Nn(t,e){let s=(await Fp()).parse(e),n=[];Tn(s,t,n);let o=new Set;return{imports:n.filter(a=>o.has(a.rawSpecifier)?!1:(o.add(a.rawSpecifier),!0)),exports:[],tags:[],category:"other"}}var kp,wp,Ep,Pn,In=m(()=>{"use strict";c();kp=["http://","https://","mailto:","//"],wp="ts|tsx|js|jsx|mjs|cjs|py|go|lua|css|scss|less|styl|coffee|ls|feature|md|mdx|json",Ep=new RegExp(`(?:\\.{1,2}/)?[\\w.-]+(?:/[\\w.-]+)*\\.(?:${wp})\\b`,"g")});import Np from"path";import{parser as Ip}from"@lezer/python";function Mn(t,e){let r=[],s=[],n=new Set,o=Np.basename(t).toLowerCase(),a=Ip.parse(e).cursor();do switch(a.name){case"Comment":{let l=e.slice(a.from,a.to).match(/#\s*@tag\s+([a-zA-Z0-9_-]+)/);l?.[1]&&n.add(l[1]);break}case"ImportStatement":{for(let l of Dp(a.node,e,t))r.push(l);break}case"FunctionDefinition":case"ClassDefinition":{let l=a.node.parent;if(l?.name==="Script"||l?.name==="DecoratedStatement"&&l.parent?.name==="Script"){let h=a.node.getChild("VariableName");h&&s.push({name:e.slice(h.from,h.to)})}break}case"AssignStatement":{if(a.node.parent?.name==="Script"){let l=a.node.firstChild;l?.name==="VariableName"&&s.push({name:e.slice(l.from,l.to)})}break}}while(a.next());let p=Gp(o,r,n);return p==="test"&&n.add("test"),{imports:r,exports:s,tags:Array.from(n).map(l=>({name:l,kind:"comment-marker"})),category:p}}function Dp(t,e,r){let s=t.firstChild;return s?s.name==="from"?Ap(t,e,r):Rp(t,e,r):[]}function Ap(t,e,r){let s=t.firstChild;if(!s)return[];let n=s.nextSibling;for(;n&&n.name!=="import";)n=n.nextSibling;if(!n)return[];let o=e.slice(s.to,n.from).trim(),i=Op(n.nextSibling,e);if(!i.length)return[];let a=0;for(;a<o.length&&o[a]===".";)a++;let p=o.slice(a);if(a===0)return[ue(r,o,i,!0)];let l=a===1?"./":"../".repeat(a-1);return p?[ue(r,l+p.replace(/\./g,"/"),i,!1)]:i[0]==="*"?[ue(r,l.slice(0,-1),["*"],!1)]:i.map(d=>ue(r,l+d,[d],!1))}function Rp(t,e,r){let s=[],n=t.firstChild?.nextSibling??null;for(;n;){if(n.name==="VariableName"){let o=e.slice(n.from,n.to);for(;n.nextSibling?.name==="."&&n.nextSibling.nextSibling?.name==="VariableName";)n=n.nextSibling.nextSibling,o+=`.${e.slice(n.from,n.to)}`;n.nextSibling?.name==="as"&&(n=n.nextSibling.nextSibling??n.nextSibling),s.push(ue(r,o,["*"],!0))}n=n.nextSibling}return s}function Op(t,e){let r=[],s=t;for(;s;)s.name==="*"?r.push("*"):s.name==="VariableName"&&(r.push(e.slice(s.from,s.to)),s.nextSibling?.name==="as"&&(s=s.nextSibling.nextSibling??s.nextSibling)),s=s.nextSibling;return r}function ue(t,e,r,s){return{fromPath:t,toPath:"",rawSpecifier:e,isStyle:!1,isExternal:s,type:"static",symbols:r.length>0?r:void 0}}function Gp(t,e,r){return t.startsWith("test_")||t.endsWith("_test.py")?"test":t==="conftest.py"||t==="setup.py"?"config":r.has("test")||e.some(s=>Mp.has(s.rawSpecifier))?"test":"logic"}var Mp,Dn=m(()=>{"use strict";c();Mp=new Set(["pytest","unittest","nose","hypothesis"])});import y from"typescript";function Lp(t){let e=1;function r(s){switch(s.kind){case y.SyntaxKind.IfStatement:case y.SyntaxKind.ConditionalExpression:case y.SyntaxKind.ForStatement:case y.SyntaxKind.ForInStatement:case y.SyntaxKind.ForOfStatement:case y.SyntaxKind.WhileStatement:case y.SyntaxKind.DoStatement:case y.SyntaxKind.CatchClause:case y.SyntaxKind.CaseClause:e++;break;case y.SyntaxKind.BinaryExpression:{let n=s.operatorToken.kind;(n===y.SyntaxKind.AmpersandAmpersandToken||n===y.SyntaxKind.BarBarToken||n===y.SyntaxKind.QuestionQuestionToken)&&e++;break}}y.forEachChild(s,r)}return r(t),e}function jp(t){let e=0;function r(s,n,o){if(y.isIfStatement(s)){e+=o?1:1+n;let a=o?n:n+1;r(s.expression,a,!1),r(s.thenStatement,a,!1),s.elseStatement&&(y.isIfStatement(s.elseStatement)?r(s.elseStatement,n,!0):(e+=1,r(s.elseStatement,n+1,!1)));return}if(y.isForStatement(s)||y.isForInStatement(s)||y.isForOfStatement(s)||y.isWhileStatement(s)||y.isDoStatement(s)||y.isSwitchStatement(s)){e+=1+n,y.forEachChild(s,a=>r(a,n+1,!1));return}if(y.isCatchClause(s)){e+=1+n,y.forEachChild(s,a=>r(a,n,!1));return}if(y.isConditionalExpression(s)&&(e+=1),y.isBinaryExpression(s)){let a=s.operatorToken.kind;(a===y.SyntaxKind.AmpersandAmpersandToken||a===y.SyntaxKind.BarBarToken||a===y.SyntaxKind.QuestionQuestionToken)&&(e+=1)}if(n>0&&(y.isFunctionDeclaration(s)||y.isFunctionExpression(s)||y.isArrowFunction(s))){e+=1+n,y.forEachChild(s,a=>r(a,n+1,!1));return}y.forEachChild(s,a=>r(a,n,!1))}return r(t,0,!1),e}function ar(t){return{complexity:Lp(t),cognitiveComplexity:jp(t)}}var An=m(()=>{"use strict";c()});import v from"typescript";function Rn(t,e){_p(t,e),zp(t,e),$p(t,e),Up(t,e)}function _p(t,e){if((v.isFunctionDeclaration(t)||v.isVariableDeclaration(t))&&t.name&&v.isIdentifier(t.name)&&Wp(t)){let r;if(v.isFunctionDeclaration(t))r="function";else{let s=t.initializer;r=s&&(v.isArrowFunction(s)||v.isFunctionExpression(s))?"function":"variable"}e.tags.add({name:t.name.text,kind:r})}}function Wp(t){if(v.isFunctionDeclaration(t))return v.isSourceFile(t.parent);let e=t.parent?.parent;return!!e&&v.isSourceFile(e.parent)}function zp(t,e){if(!v.isStringLiteral(t))return;let r=t.text.match(/@[\w-]+/g);if(r)for(let s of r)e.tags.add({name:s.substring(1),kind:"comment-marker"})}function $p(t,e){if(!v.isSourceFile(t))return;let r=/@tag\s+([a-zA-Z0-9_-]+)/g,s=t.getFullText(),n=r.exec(s);for(;n!==null;)n[1]&&e.tags.add({name:n[1],kind:"comment-marker"}),n=r.exec(s)}function Up(t,e){if(v.isCallExpression(t)&&Bp(t.expression))for(let r of t.arguments)v.isObjectLiteralExpression(r)&&Jp(r,e)}function Bp(t){return v.isIdentifier(t)?cr.has(t.text):!!(v.isPropertyAccessExpression(t)&&(cr.has(t.name.text)||v.isIdentifier(t.expression)&&cr.has(t.expression.text)))}function Jp(t,e){for(let r of t.properties){if(!v.isPropertyAssignment(r)||!v.isIdentifier(r.name)||r.name.text!=="tags"&&r.name.text!=="tag")continue;let{initializer:s}=r,n=v.isArrayLiteralExpression(s)?s.elements.filter(v.isStringLiteral):r.name.text==="tag"&&v.isStringLiteral(s)?[s]:[];for(let o of n)e.tags.add({name:o.text.replace(/^@/,""),kind:"comment-marker"})}}var cr,On=m(()=>{"use strict";c();cr=new Set(["test","describe","it"])});import Gn from"path";import g from"typescript";function pr(t,e,r){let s=[],n=new Map,o=new Set,i=g.createSourceFile(t,e,g.ScriptTarget.Latest,!0,r==="typescript"?g.ScriptKind.TSX:g.ScriptKind.JSX),a={filePath:t,imports:s,exports:n,tags:o,rawCallEdges:[],sourceFile:i,hasUI:!1,hasTypesOnly:!0,totalStatements:0,exportStatements:0},p=R=>{Vp(R,a),g.forEachChild(R,p)};p(i);let l=il(t,a);(l==="test"||l==="barrel")&&o.add({name:l,kind:"comment-marker"}),l!=="test"&&al(a,i);let d=i.statements[0],h=d?jn(d):void 0,{complexity:x,cognitiveComplexity:C}=ar(i),I=Kp(i);return{imports:s,exports:Array.from(n.values()),tags:Array.from(o),category:l,rawCallEdges:a.rawCallEdges??[],complexity:x,cognitiveComplexity:C,...I.length>0?{functions:I}:{},...h!==void 0?{description:h}:{}}}function Kp(t){let e=[],r=(n,o)=>{let{complexity:i,cognitiveComplexity:a}=ar(o),p=t.getLineAndCharacterOfPosition(o.getStart(t)).line+1;e.push({name:n,line:p,complexity:i,cognitiveComplexity:a})},s=(n,o)=>{if(g.isFunctionDeclaration(n)&&n.name&&n.body?r(n.name.text,n):g.isVariableDeclaration(n)&&g.isIdentifier(n.name)&&n.initializer&&(g.isArrowFunction(n.initializer)||g.isFunctionExpression(n.initializer))?r(n.name.text,n.initializer):o&&g.isMethodDeclaration(n)&&g.isIdentifier(n.name)&&n.body?r(`${o}.${n.name.text}`,n):o&&g.isConstructorDeclaration(n)&&n.body?r(`${o}.constructor`,n):o&&g.isGetAccessorDeclaration(n)&&g.isIdentifier(n.name)&&n.body?r(`${o}.get ${n.name.text}`,n):o&&g.isSetAccessorDeclaration(n)&&g.isIdentifier(n.name)&&n.body&&r(`${o}.set ${n.name.text}`,n),g.isClassDeclaration(n)&&n.name){let i=n.name.text;g.forEachChild(n,a=>s(a,i));return}g.forEachChild(n,i=>s(i,o))};return s(t,void 0),e}function Ln(t,e,r,s){let n={name:t},o=jn(r);o!==void 0&&(n.doc=o);let i=Hp(e);i!==void 0&&(n.flags=i);let a=Qp(e,s);return a!==void 0&&(n.signature=a),n}function jn(t){let e=g.getJSDocCommentsAndTags(t);for(let r of e)if(g.isJSDoc(r)&&r.comment)return g.getTextOfJSDocComment(r.comment)||void 0}function Hp(t){let e=new Set(["deprecated","internal","public","alpha","beta"]),r=g.getJSDocTags(t).map(s=>s.tagName.text).filter(s=>e.has(s));return r.length>0?r:void 0}function Qp(t,e){let r=g.createPrinter({removeComments:!0}),s=n=>r.printNode(g.EmitHint.Unspecified,n,e);if(g.isFunctionDeclaration(t)||g.isMethodDeclaration(t)){let n=t.parameters.map(s).join(", "),o=t.type?s(t.type):"void";return`${t.typeParameters?`<${t.typeParameters.map(a=>a.name.text).join(", ")}>`:""}(${n}) => ${o}`}if(g.isVariableDeclaration(t)){if(t.type)return s(t.type);if(t.initializer&&(g.isArrowFunction(t.initializer)||g.isFunctionExpression(t.initializer))){let n=t.initializer,o=n.parameters.map(s).join(", "),i=n.type?s(n.type):"unknown";return`(${o}) => ${i}`}return}if(g.isClassDeclaration(t)&&t.name)return`class ${t.name.text}`;if(g.isInterfaceDeclaration(t))return`interface ${t.name.text}`;if(g.isTypeAliasDeclaration(t))return s(t.type);if(g.isEnumDeclaration(t))return`enum ${t.name.text}`}function Vp(t,e){Xp(t,e),qp(t,e),Zp(t,e),el(t,e),ol(t,e),Rn(t,e)}function Xp(t,e){if(!g.isSourceFile(t))return;let r=t.statements.filter(s=>!g.isEmptyStatement(s));e.totalStatements=r.length,e.exportStatements=r.filter(s=>g.isExportDeclaration(s)||g.isExportAssignment(s)||lr(s)).length}function qp(t,e){if(g.isJsxElement(t)||g.isJsxSelfClosingElement(t)||g.isJsxFragment(t)){e.hasUI=!0,e.hasTypesOnly=!1;return}if(g.isFunctionDeclaration(t)||g.isMethodDeclaration(t)||g.isArrowFunction(t)||g.isClassDeclaration(t)||g.isVariableStatement(t)||g.isEnumDeclaration(t)){e.hasTypesOnly=!1;return}g.isExportDeclaration(t)&&!Yp(t)&&(e.hasTypesOnly=!1)}function Yp(t){return t.isTypeOnly?!0:!t.exportClause||!g.isNamedExports(t.exportClause)?!1:t.exportClause.elements.every(e=>e.isTypeOnly)}function Zp(t,e){if(!g.isImportDeclaration(t)||!t.moduleSpecifier||!g.isStringLiteral(t.moduleSpecifier))return;let r=[];if(t.importClause&&(t.importClause.name&&r.push("default"),t.importClause.namedBindings))if(g.isNamedImports(t.importClause.namedBindings))for(let n of t.importClause.namedBindings.elements)r.push(n.name.text);else g.isNamespaceImport(t.importClause.namedBindings)&&r.push("*");let s=r.length>0?"static":"side-effect";e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:t.moduleSpecifier.text,isStyle:N(t.moduleSpecifier.text),type:s,symbols:r.length>0?r:void 0})}function el(t,e){g.isExportDeclaration(t)?tl(t,e):g.isExportAssignment(t)?e.exports.set("default",{name:"default"}):lr(t)&&nl(t,e)}function tl(t,e){if(t.moduleSpecifier&&g.isStringLiteral(t.moduleSpecifier))rl(t,t.moduleSpecifier.text,e);else if(t.exportClause&&g.isNamedExports(t.exportClause))for(let r of t.exportClause.elements){let s=r.name.text;e.exports.set(s,{name:s})}}function rl(t,e,r){let s=sl(t),n={fromPath:r.filePath,toPath:"",rawSpecifier:e,isStyle:N(e),type:"re-export"};s.length>0&&(n.symbols=s),r.imports.push(n)}function sl(t){return t.exportClause?g.isNamedExports(t.exportClause)?t.exportClause.elements.map(e=>e.name.text):[]:["*"]}function nl(t,e){if((g.isFunctionDeclaration(t)||g.isClassDeclaration(t)||g.isInterfaceDeclaration(t)||g.isTypeAliasDeclaration(t)||g.isEnumDeclaration(t))&&t.name){let s=t.name.text;e.exports.set(s,Ln(s,t,t,e.sourceFile));return}if(g.isVariableStatement(t)){for(let s of t.declarationList.declarations)if(g.isIdentifier(s.name)){let n=s.name.text;e.exports.set(n,Ln(n,s,t,e.sourceFile))}}}function ol(t,e){if(!g.isCallExpression(t))return;let r=t.arguments[0];!r||!g.isStringLiteral(r)||(t.expression.kind===g.SyntaxKind.ImportKeyword?e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:r.text,isStyle:N(r.text),type:"dynamic"}):g.isIdentifier(t.expression)&&t.expression.text==="require"&&e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:r.text,isStyle:N(r.text),type:"require"}))}function il(t,e){let r=Gn.basename(t).toLowerCase(),s=Gn.extname(t).toLowerCase();return ne().some(o=>r.includes(o))?"test":Xr(r)?"config":e.imports.some(o=>ct().some(i=>o.rawSpecifier.includes(i)))?"test":s===".tsx"||s===".jsx"||e.hasUI?"ui":e.hasTypesOnly&&e.totalStatements>0?"type-only":e.totalStatements>0&&e.exportStatements/e.totalStatements>lt()?"barrel":"logic"}function lr(t){return g.canHaveModifiers(t)&&g.getModifiers(t)?.some(e=>e.kind===g.SyntaxKind.ExportKeyword)===!0}function al(t,e){let r=t.rawCallEdges??[];t.rawCallEdges=r;let s=new Map;for(let n of e.statements){if(!g.isImportDeclaration(n)||!g.isStringLiteral(n.moduleSpecifier))continue;let o=n.moduleSpecifier.text,i=n.importClause;if(i&&(i.name&&s.set(i.name.text,o),i.namedBindings&&g.isNamedImports(i.namedBindings)))for(let a of i.namedBindings.elements)s.set(a.name.text,o)}if(s.size!==0)for(let n of e.statements){let o=pl(n);if(o){let i=ll(n);i&&qe(i,o,s,r);continue}g.isClassDeclaration(n)&&n.name&&cl(n,s,r)}}function cl(t,e,r){let s=t.name.text;for(let n of t.members)g.isMethodDeclaration(n)&&n.body&&g.isIdentifier(n.name)?qe(n.body,`${s}.${n.name.text}`,e,r):g.isConstructorDeclaration(n)&&n.body&&qe(n.body,`${s}.constructor`,e,r)}function pl(t){if(lr(t)){if(g.isFunctionDeclaration(t)&&t.name)return t.name.text;if(g.isVariableStatement(t)){for(let e of t.declarationList.declarations)if(g.isIdentifier(e.name)&&e.initializer&&(g.isArrowFunction(e.initializer)||g.isFunctionExpression(e.initializer)))return e.name.text}}}function ll(t){if(g.isFunctionDeclaration(t))return t.body;if(g.isVariableStatement(t)){for(let e of t.declarationList.declarations)if(e.initializer&&(g.isArrowFunction(e.initializer)||g.isFunctionExpression(e.initializer)))return e.initializer}}function qe(t,e,r,s){if(g.isCallExpression(t)&&g.isIdentifier(t.expression)){let n=t.expression.text,o=r.get(n);o&&!s.some(i=>i.from===e&&i.to===n&&i.toSpecifier===o)&&s.push({from:e,to:n,toSpecifier:o})}g.forEachChild(t,n=>qe(n,e,r,s))}var _n=m(()=>{"use strict";c();B();An();j();On()});function Ye(t,e){if(e.length===0)return"ui";let r=!1;return t.walk(s=>{if(s.type==="rule")return r=!0,!1}),r?"ui":"barrel"}var Wn=m(()=>{"use strict";c()});import $n from"postcss";import*as fl from"postcss-less";function zn(t){return t.startsWith("~")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//")||t.startsWith("data:")}function ul(t){let e=t.trim();return e.length>0&&!e.startsWith("http://")&&!e.startsWith("https://")&&!e.startsWith("//")&&!e.startsWith("data:")&&!e.startsWith("#")}function gl(t,e){let r=t.match(/^\(([^)]+)\)\s+['"]([^'"]+)['"]/);if(r){let o=r[1]?.trim()??"",i=r[2]??"";if(!i)return null;let a=Un.has(o)?"side-effect":"static";return{fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:a,...zn(i)?{isExternal:!0}:{}}}let s=t.match(/^url\(['"]?([^'")]+)['"]?\)/),n=s?s[1]?.trim()??"":t.match(/^['"]([^'"]+)['"]/)?.[1]??"";return n?{fromPath:e,toPath:"",rawSpecifier:n,isStyle:!0,type:"static",...zn(n)?{isExternal:!0}:{}}:null}function dl(t,e){let r=[],s=/url\(['"]?([^'")]+)['"]?\)/g,n=s.exec(t);for(;n!==null;){let o=n[1]?.trim()??"";ul(o)&&r.push({fromPath:e,toPath:"",rawSpecifier:o,isStyle:!0,type:"static"}),n=s.exec(t)}return r}function Bn(t,e){let r=[];return t.walk(s=>{if(s.type==="atrule"&&s.name==="import"){let n=gl(s.params,e);n&&r.push(n)}s.type==="decl"&&r.push(...dl(s.value,e))}),r}function hl(t){return t.replace(/(?<!:)\/\/.*/g,"")}function yl(t,e){let r=[],s=/@import\s+(?:\(([^)]+)\)\s+)?['"]([^'"]+)['"]/g,n=s.exec(t);for(;n!==null;){let o=n[1]?.trim()??"",i=n[2]??"";if(i){let a=Un.has(o)?"side-effect":"static";r.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:a})}n=s.exec(t)}return r}function Jn(t,e){let r=$n.parse(hl(t));return{imports:Bn(r,e),root:r}}function Kn(t,e){try{let r=ml.parse(t);return{imports:Bn(r,e),root:r}}catch{return{imports:yl(t,e),root:$n.parse("")}}}var ml,Un,Hn=m(()=>{"use strict";c();ml=fl,Un=new Set(["reference","inline"])});import{parse as xl}from"postcss-scss";function Sl(t){return!!(t.startsWith("sass:")||t.startsWith("~")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//")||!t.startsWith(".")&&!t.startsWith("/")&&!t.startsWith("_"))}function bl(t){let e=t.match(/^['"]([^'"]+)['"]/);if(!e?.[1])return{specifier:""};let r=e[1],n=t.match(/\bas\s+(\S+)/)?.[1];return n!==void 0?{specifier:r,alias:n}:{specifier:r}}function Qn(t,e){let r=xl(t),s=[];return r.walk(n=>{if(n.type!=="atrule")return;let{name:o,params:i}=n;if(o!=="import"&&o!=="use"&&o!=="forward")return;let{specifier:a,alias:p}=bl(i);if(!a)return;let l={fromPath:e,toPath:"",rawSpecifier:a,isStyle:!0,type:o==="forward"?"re-export":"static",...Sl(a)?{isExternal:!0}:{}};p&&(l.symbols=[p]),s.push(l)}),{imports:s,root:r}}var Vn=m(()=>{"use strict";c()});function Xn(t,e){let r=[],s=/@require\s+['"]([^'"]+)['"]/g,n=s.exec(t);for(;n!==null;){let i=n[1];i&&r.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:"require"}),n=s.exec(t)}let o=/(?<!@)(?:import|require)\s*\(?\s*['"]([^'"]+)['"]/g;for(n=o.exec(t);n!==null;){let i=n[1];i&&r.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:"static"}),n=o.exec(t)}return r}function qn(t,e){if(e.length===0)return"ui";try{let r=at("stylus");return new r.Parser(t).parse().nodes.some(o=>o.constructor.name!=="Import")?"ui":"barrel"}catch{return t.replace(/^\s*@?(?:require|import)\b.*/gm,"").trim().length>0?"ui":"barrel"}}var Yn=m(()=>{"use strict";c()});function ge(t,e){let r=L(t);if(r==="stylus"){let o=Xn(e,t);return{imports:o,exports:[],tags:[],category:qn(e,o)}}if(r==="scss"){let{imports:o,root:i}=Qn(e,t);return{imports:o,exports:[],tags:[],category:Ye(i,o)}}if(r==="less"){let{imports:o,root:i}=Kn(e,t);return{imports:o,exports:[],tags:[],category:Ye(i,o)}}let{imports:s,root:n}=Jn(e,t);return{imports:s,exports:[],tags:[],category:Ye(n,s)}}var Zn=m(()=>{"use strict";c();j();Wn();Hn();Vn();Yn()});async function eo(t,e){let r=L(t),s=As(r);return s?s(t,e):{imports:[],exports:[],tags:[],category:"other"}}var to=m(()=>{"use strict";c();j();xn();Sn();vn();wn();Fn();In();Dn();_n();fe();Zn();B();j();fe();for(let[t,e]of[["javascript",(r,s)=>pr(r,s,"javascript")],["typescript",(r,s)=>pr(r,s,"typescript")],["css",ge],["scss",ge],["less",ge],["stylus",ge],["coffeescript",yn],["livescript",kn],["lua",En],["python",Mn],["go",Cn],["gherkin",nr],["markdown",Nn]])Q(t,e)});import ro from"path";function no(t,e){for(let r of t.values()){let s=e.get(r.path);s!==void 0&&(r.coveragePct=s)}}function oo(t,e){for(let r of t)if(r.isExternal){let s=r.rawSpecifier.startsWith("@")?r.rawSpecifier.split("/").slice(0,2).join("/"):r.rawSpecifier.split("/")[0];s&&!e.some(n=>n.name===s)&&e.push({name:s,kind:"library"})}}function io(t){for(let e of t.values())if(e.category==="test")for(let r of e.imports){if(r.isExternal||!r.toPath)continue;let s=t.get(r.toPath);s&&(s.category!=="logic"&&s.category!=="barrel"||(s.testedBy??=[],s.testedBy.includes(e.path)||s.testedBy.push(e.path)))}}function ao(t){for(let e of t.values())if(e.type==="markdown")for(let r of e.imports){if(r.isExternal||!r.toPath)continue;let s=t.get(r.toPath);!s||s===e||(s.documentedBy??=[],s.documentedBy.includes(e.path)||s.documentedBy.push(e.path),s.category==="logic"&&(s.lastCommitAt??0)>(e.lastCommitAt??0)&&(e.staleFor??=[],e.staleFor.includes(s.path)||e.staleFor.push(s.path)))}}function so(t){return Math.round(t*1e4)/1e4}function co(t){for(let e of t.values()){let r=[];for(let s of e.imports){if(s.isExternal||!s.toPath)continue;let n=t.get(s.toPath);if(!n||n.exports.length===0)continue;let o;if(s.symbols===void 0){if(s.type==="side-effect")continue;o=1}else s.symbols.includes("*")?o=1:o=s.symbols.length/n.exports.length;s.exportUsageRatio=so(Math.min(1,o)),r.push(s.exportUsageRatio)}r.length>0&&(e.avgExportUsage=so(r.reduce((s,n)=>s+n,0)/r.length),e.maxExportUsage=Math.max(...r))}}function fr(t,e,r){e&&(t.some(s=>s.name===e&&s.kind===r)||t.push({name:e,kind:r}))}function Cl(t,e){let r=e.toPath,s=ro.basename(r,ro.extname(r)).replace(/\.(test|spec)$/,"");fr(t.tags,s,"import")}function vl(t,e){if(!(!e.symbols||e.symbols.includes("*")))for(let r of e.symbols)fr(t.tags,r,"import")}function kl(t,e,r){let s=r.get(e.toPath);if(!(!s||s.category==="test"))for(let n of s.tags)n.kind==="comment-marker"&&fr(t.tags,n.name,"comment-marker")}function po(t){for(let e of t.values())if(e.category==="test")for(let r of e.imports)!r.toPath||r.isExternal||(Cl(e,r),vl(e,r),kl(e,r,t))}var lo=m(()=>{"use strict";c()});import uo from"fs";import se from"path";function wl(t,e){let r=t.split(`
23
- `),s=null,n=new Map,o=!1;for(let i of r){let a=i.trim();if(a.startsWith("module ")){s=a.slice(7).trim();continue}if(/^replace\s*\(/.test(a)){o=!0;continue}if(o&&a===")"){o=!1;continue}if(o&&a.includes("=>")){fo(a,e,n);continue}!o&&/^replace\s+/.test(a)&&a.includes("=>")&&fo(a.replace(/^replace\s+/,""),e,n)}return{mod:s,replaces:n}}function fo(t,e,r){let[s,n]=t.split("=>").map(a=>a.trim());if(!s||!n)return;let o=s.split(/\s+/)[0];if(!n.startsWith(".")&&!n.startsWith("/"))return;let i=se.isAbsolute(n)?n:se.resolve(e,n);r.set(o,i)}function mo(t){let e;try{e=uo.readdirSync(t,{withFileTypes:!0})}catch{return null}let r=e.filter(s=>s.isFile()&&s.name.endsWith(".go")&&!s.name.endsWith("_test.go")).map(s=>({path:se.join(t,s.name),isExternal:!1})).sort((s,n)=>s.path.localeCompare(n.path));return r.length>0?r:null}var de,go=m(()=>{"use strict";c();de=class{extensions=[".go"];goModCache=new Map;resolve(e,r,s,n){let{mod:o,replaces:i}=this.readGoMod(s);if(!o)return null;let a=this.applyReplace(r,i,s);if(a!==void 0)return mo(a);if(r!==o&&!r.startsWith(`${o}/`))return null;let p=r.slice(o.length).replace(/^\//,"");return p?mo(se.join(s,p)):null}readGoMod(e){let r=this.goModCache.get(e);if(r!==void 0)return r;let s={mod:null,replaces:new Map};try{let n=uo.readFileSync(se.join(e,"go.mod"),"utf-8"),o=wl(n,e);return this.goModCache.set(e,o),o}catch{return this.goModCache.set(e,s),s}}applyReplace(e,r,s){for(let[n,o]of r){if(e===n)return o;if(e.startsWith(`${n}/`)){let i=e.slice(n.length+1);return se.join(o,i)}}}}});import El from"fs";import mr from"path";var he,ho=m(()=>{"use strict";c();he=class{extensions=[".lua"];resolve(e,r,s,n){let o=r.replace(/\./g,mr.sep),i=[s,mr.join(s,"lib")];for(let a of i){if(!El.existsSync(a))continue;let p=n(mr.join(a,"_dummy.lua"),o);if(p)return[p]}return null}}});import Fl from"path";var ye,yo=m(()=>{"use strict";c();ye=class{extensions=[".md",".mdx"];resolve(e,r,s,n){let o=n(Fl.join(s,"_dummy"),`./${r}`);return o?[o]:null}}});import Pl from"fs";import ur from"path";function xo(t){try{return Pl.statSync(t,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}var xe,So=m(()=>{"use strict";c();xe=class{extensions=[".py"];resolve(e,r,s,n){let o=r.replace(/\./g,ur.sep),i=ur.join(s,`${o}.py`);if(xo(i))return[{path:i,isExternal:!1}];let a=ur.join(s,o,"__init__.py");return xo(a)?[{path:a,isExternal:!1}]:null}}});import bo from"path";var Tl,Se,Co=m(()=>{"use strict";c();Tl=["~","http://","https://","//","data:","sass:"],Se=class{extensions=[".css",".scss",".sass",".less",".styl"];resolve(e,r,s,n){if(Tl.some(d=>r.startsWith(d)))return null;let o=n(e,r);if(o)return[o];let i=bo.dirname(r),a=bo.basename(r),p=i==="."?`_${a}`:`${i}/_${a}`,l=n(e,p);return l?[l]:null}}});var vo=m(()=>{"use strict";c();go();ho();yo();So();Co()});import Ze from"fs";import _ from"path";var $,gr=m(()=>{"use strict";c();vo();$=class{constructor(e,r={}){this.rootDir=e;this.workspaceMap=r.workspaceMap??new Map,this.tsconfigSearchPaths=r.tsconfigSearchPaths??[e],this.pathAliases=r.pathAliases,this.langResolvers=r.langResolvers??[new xe,new he,new de,new Se,new ye]}rootDir;workspaceMap;tsconfigSearchPaths;pathAliases;langResolvers;resolveAll(e,r){let s=this.resolvePathAlias(r);if(s)return[s];if(r.startsWith(".")||r.startsWith("/")){let i=this.resolveLocalPath(e,r);return i?[i]:[]}let n=(i,a)=>this.resolveLocalPath(i,a);for(let i of this.langResolvers)if(i.extensions.some(a=>e.endsWith(a))){let a=i.resolve(e,r,this.rootDir,n);if(a)return a}let o=this.resolveWorkspaceImport(r);return o?[o]:[{path:r,isExternal:!0}]}resolve(e,r){let s=this.resolvePathAlias(r);if(s)return s;if(r.startsWith(".")||r.startsWith("/"))return this.resolveLocalPath(e,r);let n=(i,a)=>this.resolveLocalPath(i,a);for(let i of this.langResolvers)if(i.extensions.some(a=>e.endsWith(a))){let a=i.resolve(e,r,this.rootDir,n);if(a)return a[0]??null}let o=this.resolveWorkspaceImport(r);return o||{path:r,isExternal:!0}}resolveLocalPath(e,r){let s=_.dirname(e),n=r.startsWith("/")?r:_.resolve(s,r),o=!n.startsWith(this.rootDir),i=["",".ts",".tsx",".js",".jsx",".mjs",".cjs",".css",".scss",".sass",".less",".styl",".coffee",".ls",".lua",".py",".feature",".md",".mdx"],a=n.match(/\.(js|mjs|cjs)$/);if(a){let p=n.slice(0,-a[0].length);for(let l of[".ts",".tsx"]){let d=this.tryExtensions(p,l,o);if(d)return d}}for(let p of i){let l=this.tryExtensions(n,p,o);if(l)return l}return o?{path:n,isExternal:!0}:null}tryExtensions(e,r,s){let n=e+r;if(this.isFile(n))return{path:n,isExternal:s};let o=_.join(e,`index${r}`);if(this.isFile(o))return{path:o,isExternal:s};if(r===".py"){let i=_.join(e,"__init__.py");if(this.isFile(i))return{path:i,isExternal:s}}return null}isFile(e){try{return Ze.statSync(e,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}resolvePathAlias(e){if(this.pathAliases)for(let r in this.pathAliases){let s=this.matchAliasPattern(r,e),n=this.pathAliases[r];if(s&&n){let o=this.tryAliasSubstitutions(n,s[1]||"");if(o)return o}}for(let r of this.tsconfigSearchPaths){let s=_.join(r,"tsconfig.json");if(Ze.existsSync(s))try{let o=JSON.parse(Ze.readFileSync(s,"utf-8")).compilerOptions?.paths;if(!o)continue;for(let i in o){let a=this.matchAliasPattern(i,e);if(a){let p=this.tryAliasSubstitutions(o[i],a[1]||"",r);if(p)return p}}}catch{}}return null}aliasRegexCache=new Map;matchAliasPattern(e,r){let s=this.aliasRegexCache.get(e);if(!s){let n=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace("\\*","(.*)");s=new RegExp(`^${n}$`),this.aliasRegexCache.set(e,s)}return r.match(s)}tryAliasSubstitutions(e,r,s=this.rootDir){let n=["",".ts",".tsx",".js",".jsx",".coffee",".ls",".lua",".feature"];for(let o of e){let i=o.replace("*",r),a=_.resolve(s,i);for(let p of n){let l=this.tryExtensions(a,p,!1);if(l)return l}}return null}resolveWorkspaceImport(e){if(this.workspaceMap.size===0)return null;for(let[r,s]of this.workspaceMap){if(e!==r&&!e.startsWith(`${r}/`))continue;let n=e.slice(r.length),o={path:"",isExternal:!1,isWorkspace:!0,workspacePackage:r};if(!n){for(let a of["src/index.ts","src/index.tsx","index.ts","index.tsx","index.js"]){let p=_.join(s,a);try{if(Ze.statSync(p,{throwIfNoEntry:!1})?.isFile())return{...o,path:p}}catch{}}return{...o,path:s}}let i=this.resolveLocalPath(_.join(s,"_dummy"),n.slice(1));return i?{...o,path:i.path}:null}return null}}});import be from"fs";import F from"path";import Nl from"piscina";function Dl(t,e){if(t.length===0)return e;let r=t.map(i=>F.dirname(i).split(F.sep)),s=r[0];for(let i of r.slice(1)){let a=0;for(;a<s.length&&a<i.length&&s[a]===i[a];)a++;s=s.slice(0,a)}let n=s.join(F.sep)||F.sep,o=F.relative(e,n);return o.startsWith("..")||F.isAbsolute(o)?e:n}var Il,ko,Ml,Ce,wo=m(()=>{"use strict";c();rr();B();dn();to();lo();ae();gr();Il=["tests","test","__tests__","specs","spec"],ko=new Set(["node_modules",".git","dist","build",".next",".cache","mokosh-cache","coverage"]),Ml=20;Ce=class{constructor(e,r=null,s,n,o=!1,i=new Map,a=!0){this.rootDir=e;this.enableGitStats=o;this.coverageMap=i;this.parallelParsing=a;this.previousGraph=r,this.resolver=s||new $(e),this.lockFile=gn(e),n&&(this.progressCallback=n)}rootDir;enableGitStats;coverageMap;parallelParsing;graph={nodes:new Map};visited=new Set;queue=[];previousGraph=null;resolver;lockFile=null;progressCallback;pool=null;gitStatsMap=null;async build(e){let r=e.map(s=>F.isAbsolute(s)?s:F.resolve(this.rootDir,s));await this.initPool(),this.enableGitStats&&(this.gitStatsMap=fn(this.rootDir));try{for(let s of r)this.enqueue(s);return await this.drain(),await this.processTestFiles(Dl(r,this.rootDir)),await this.processDocFiles(),this.progressCallback&&this.visited.size>=100&&process.stderr.write(`
18
+ `;return p+S+d+i+`
19
+ `+h}}});import $s from"path";import Us from"typescript";var pc,Qe,Bs=m(()=>{"use strict";c();ee();pc=/\/\/ <mokosh-tags>[\s\S]*?\/\/ <\/mokosh-tags>\n*/,Qe=class{name="vitest";canHandle(e){return A.has($s.extname(e).toLowerCase())}apply(e,r,s){let n=r.replace(pc,""),o=Us.createSourceFile($s.basename(e),n,Us.ScriptTarget.Latest,!0),i=Q(o);if(i.length===0)return n;let a=V(i[0],"tags",o),l=[...s].sort();if(a!==null&&JSON.stringify([...a].sort())===JSON.stringify(l))return n;let p=i.flatMap(h=>{let d=s.length===0?Y(h,"tags",o):X(h,"tags",Z(l),o);return d?[d]:[]});return p.length>0?q(n,p):n}}});import Zt from"path";import Ve from"typescript";function mc(t){let e=Ve.createSourceFile("detect.ts",t,Ve.ScriptTarget.Latest,!0);for(let r of e.statements){if(!Ve.isImportDeclaration(r)||!Ve.isStringLiteral(r.moduleSpecifier))continue;let s=fc[r.moduleSpecifier.text];if(s)return s}return null}function Ks(t="vitest",e={},r=process.cwd()){return[new Ue,new He,new Be,new er(r,t,Object.entries(e))]}function Hs(t,e){return e.find(r=>r.canHandle(t))??null}var Js,fc,er,Qs=m(()=>{"use strict";c();As();Ds();Os();Gs();Ls();Ws();zs();ee();Bs();Js={vitest:()=>new Qe,playwright:()=>new Ke,cypress:()=>new $e,jest:()=>new Je},fc={"@playwright/test":"playwright",cypress:"cypress","@jest/globals":"jest",vitest:"vitest"};er=class{constructor(e,r,s){this.rootDir=e;this.defaultFramework=r;this.frameworkOverrides=s}rootDir;defaultFramework;frameworkOverrides;name="auto";canHandle(e){return A.has(Zt.extname(e).toLowerCase())}apply(e,r,s){let n=mc(r)??this.matchOverride(e)??this.defaultFramework;return(Js[n]??Js.vitest)().apply(e,r,s)}matchOverride(e){let r=Zt.relative(this.rootDir,e).split(Zt.sep).join("/");for(let[s,n]of this.frameworkOverrides)if(Rs(s,r))return n;return null}}});import Vs from"fs/promises";import uc from"path";async function yc(t,e,r,s){let n;try{n=await Vs.readFile(t,"utf8")}catch(a){return{path:t,status:"error",error:String(a)}}let o=Hs(t,s);if(!o)return{path:t,status:"unchanged"};let i=o.apply(t,n,e);return i===n?{path:t,status:"unchanged"}:(r||await Vs.writeFile(t,i,"utf8"),{path:t,status:"updated"})}async function tr(t,e,r){let s=B(e),n=s.tagApplier?.framework??"vitest",o=s.tagApplier?.frameworkOverrides??{},i=Ks(n,o,e),a={updated:0,unchanged:0,errors:0,files:[]};for(let l of t.nodes.values()){if(l.category!=="test")continue;let p=new Set,h=[];for(let v of l.tags)dc.has(v.kind)&&gc.test(v.name)&&(hc.has(v.name.toLowerCase())||p.has(v.name)||(p.add(v.name),h.push(v.name)));h.sort();let d=uc.resolve(e,l.path),S=await yc(d,h,r.dryRun,i);S.path=l.path,a.files.push(S),S.status==="updated"?a.updated++:S.status==="unchanged"?a.unchanged++:a.errors++}return a}var gc,dc,hc,Xs=m(()=>{"use strict";c();mt();Qs();gc=/^[a-zA-Z][a-zA-Z0-9_-]{1,}$/,dc=new Set(["import"]),hc=new Set(["common","fixture","fixtures","helper","helpers","index","main","mock","mocks","setup","shared","spec","test","tests","types","util","utils"])});var Xe,rr=m(()=>{"use strict";c();Xe=class{isTestNode(e){return e.category==="test"||e.tags.some(r=>r.name==="test")}}});import{execFileSync as sr}from"child_process";function Zs(t,e){let r="",s=0;for(let n of t.split(`
20
+ `)){if(n.startsWith("\0")){let[,l,p]=n.slice(1).split(" ");r=l??"",s=p?Number(p)*1e3:0;continue}if(n==="")continue;let o=n.split(" "),i=o[0];if(!i)continue;let a=i.startsWith("R")||i.startsWith("C")?o[2]:o[1];a&&e(a,r,s)}}function en(t){let e=new Map;try{let r=sr("git",["-C",t,"log","--since=90 days ago","--name-status","-M",`--format=${Ys}`],{encoding:"utf-8",stdio:["ignore","pipe","ignore"],maxBuffer:qs});Zs(r,(s,n,o)=>{let i=e.get(s);if(i){i.commitCount90d+=1;return}e.set(s,{commitCount90d:1,lastAuthor:n||void 0,lastCommitAt:o||void 0})})}catch{return e}try{let r=sr("git",["-C",t,"log","--name-status","-M",`--format=${Ys}`],{encoding:"utf-8",stdio:["ignore","pipe","ignore"],maxBuffer:qs});Zs(r,(s,n,o)=>{e.has(s)||e.set(s,{commitCount90d:0,lastAuthor:void 0,lastCommitAt:o||void 0})})}catch{}return e}var Ye,Ys,qs,nr=m(()=>{"use strict";c();Ye=class{getChangedFiles(){try{let r=[["diff","--name-only"],["diff","--cached","--name-only"],["ls-files","--others","--exclude-standard"]].flatMap(s=>{try{return sr("git",s,{encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).split(`
21
+ `).map(o=>o.trim()).filter(o=>o!=="")}catch{return[]}});return Array.from(new Set(r))}catch(e){return console.error("Error getting git diff:",e),[]}}},Ys="%x00%H%x09%ae%x09%at",qs=256*1024*1024});import qe from"fs";import xc from"path";import{load as tn}from"js-yaml";function rn(t){let e=t.lastIndexOf("@");return e>0?t.substring(0,e):t}function Sc(t){return t.replace(/:$/,"").split(",").map(e=>{let r=e.trim();return r.startsWith('"')&&(r=r.slice(1)),r.endsWith('"')&&(r=r.slice(0,-1)),rn(r)}).filter(Boolean)}function bc(t,e){let r=t.startsWith("/")?t.slice(1):t,s=r.lastIndexOf("@");return s>0?{name:r.substring(0,s),version:e||r.substring(s+1)}:{name:r,version:e}}function Cc(t){try{let e=tn(t),r={dependencies:{}};for(let[s,n]of Object.entries(e))if(!(s==="__metadata"||!n?.version))for(let o of s.split(", ")){let i=rn(o);i&&(r.dependencies[i]={version:n.version,...n.dependencies!==void 0&&{dependencies:n.dependencies}})}return r}catch{return null}}function vc(t){let e={dependencies:{}};for(let r of t.split(/\n\n+/)){let s=r.split(`
22
+ `).filter(l=>l.trim().length>0&&!l.trim().startsWith("#"));if(s.length<2)continue;let n=s[0];if(!n||n.startsWith(" "))continue;let o=Sc(n);if(o.length===0)continue;let a=s.find(l=>l.trim().startsWith('version "'))?.match(/version "(.*?)"/)?.[1]??"";for(let l of o)e.dependencies[l]={version:a}}return e}function kc(t){let e=qe.readFileSync(t,"utf-8"),r=JSON.parse(e),s={dependencies:{}};if(r.packages)for(let[n,o]of Object.entries(r.packages)){if(!n.startsWith("node_modules/"))continue;let i=n.replace("node_modules/","");i.includes("node_modules/")||(s.dependencies[i]={version:o.version,...o.dependencies!==void 0&&{dependencies:o.dependencies}})}else if(r.dependencies)for(let[n,o]of Object.entries(r.dependencies))s.dependencies[n]={version:o.version,...o.dependencies!==void 0&&{dependencies:o.dependencies}};return s}function Ec(t){let e=qe.readFileSync(t,"utf-8");if(e.includes("__metadata:")){let r=Cc(e);if(r!==null)return r}return vc(e)}function wc(t){let e=qe.readFileSync(t,"utf-8"),r={dependencies:{}};try{let s=tn(e);if(s.packages)for(let[n,o]of Object.entries(s.packages)){let{name:i,version:a}=bc(n,o.version);i&&(r.dependencies[i]={version:a,...o.dependencies!==void 0&&{dependencies:o.dependencies}})}if(s.dependencies)for(let[n,o]of Object.entries(s.dependencies)){if(r.dependencies[n])continue;let i=typeof o=="string"?o:o.version;r.dependencies[n]={version:i||""}}}catch{}return r}function sn(t){let e=[["package-lock.json",kc],["yarn.lock",Ec],["pnpm-lock.yaml",wc]];for(let[r,s]of e){let n=xc.join(t,r);if(qe.existsSync(n))return s(n)}return null}var nn=m(()=>{"use strict";c()});import on from"path";function R(t){switch(on.extname(t).toLowerCase()){case".js":case".jsx":case".mjs":case".cjs":return"javascript";case".ts":case".tsx":return"typescript";case".css":return"css";case".scss":case".sass":return"scss";case".less":return"less";case".styl":return"stylus";case".coffee":return"coffeescript";case".ls":return"livescript";case".lua":return"lua";case".py":return"python";case".go":return"go";case".java":case".cpp":case".cc":case".cxx":case".c":return"unknown";case".feature":return"gherkin";case".md":case".mdx":return"markdown";default:return"unknown"}}function N(t){let e=on.extname(t).toLowerCase();return[".css",".scss",".sass",".less",".styl"].includes(e)}var O=m(()=>{"use strict";c()});import Fc from"coffeescript";function Pc(t){let e=new Set,r=/@tag\s+([a-zA-Z0-9_-]+)/g,s=r.exec(t);for(;s!==null;)s[1]&&e.add(s[1]),s=r.exec(t);return e}function Tc(t,e){let r=t.toLowerCase();return r.includes(".test.")||r.includes(".spec.")||e.has("test")?"test":"logic"}function Nc(t,e){let r=e.source?.value;return r?{fromPath:t,toPath:"",rawSpecifier:r,isStyle:N(r),type:"static"}:null}function Ic(t,e){let r=e.variable?.base?.value==="require",s=e.args?.[0]?.base?.value;return!r||!s?null:{fromPath:t,toPath:"",rawSpecifier:s,isStyle:N(s),type:"require"}}function Mc(t,e,r){let s=e.constructor?.name;if(s==="ImportDeclaration"){let n=Nc(t,e);n&&r.push(n)}else if(s==="Call"){let n=Ic(t,e);n&&r.push(n)}}function or(t,e,r){if(!(!e||typeof e!="object")){Mc(t,e,r);for(let s in e){if(s==="locationData")continue;let n=e[s];if(!(!n||typeof n!="object"))if(Array.isArray(n))for(let o of n)or(t,o,r);else or(t,n,r)}}}function an(t,e){let r=Pc(e),s=Tc(t,r),n=[];try{or(t,Fc.nodes(e),n)}catch{}return{imports:n,exports:[],tags:Array.from(r).map(o=>({name:o,kind:"comment-marker"})),category:s}}var cn=m(()=>{"use strict";c();O()});import{AstBuilder as Ac,GherkinClassicTokenMatcher as Dc,Parser as Rc}from"@cucumber/gherkin";import{IdGenerator as Oc}from"@cucumber/messages";function ir(t,e){let r=new Set;try{let s=new Ac(Gc),n=new Dc,i=new Rc(s,n).parse(e);i.feature&&(i.feature.tags.forEach(a=>{r.add(a.name.startsWith("@")?a.name.slice(1):a.name)}),i.feature.children.forEach(a=>{a.scenario&&(a.scenario.tags.forEach(l=>{r.add(l.name.startsWith("@")?l.name.slice(1):l.name)}),a.scenario.examples.forEach(l=>{l.tags.forEach(p=>{r.add(p.name.startsWith("@")?p.name.slice(1):p.name)})})),a.rule&&a.rule.children.forEach(l=>{l.scenario&&l.scenario.tags.forEach(p=>{r.add(p.name.startsWith("@")?p.name.slice(1):p.name)})})}))}catch(s){console.warn(`[GherkinParser] Failed to parse ${t}:`,s)}return{imports:[],exports:[],tags:Array.from(r).map(s=>({name:s,kind:"comment-marker"})),category:"test"}}var Gc,ln=m(()=>{"use strict";c();fe();Gc=Oc.uuid();H("gherkin",ir)});import Lc from"path";import{parser as jc}from"@lezer/go";function fn(t,e){let r=[],s=new Map,n=new Set,o=new Set,a=jc.parse(e).cursor();do switch(a.name){case"LineComment":{let d=e.slice(a.from,a.to),S=d.match(_c);S?.[1]&&n.add(S[1]);let v=d.match(Wc);v&&pn(v[1],o);let L=d.match(zc);L&&pn(L[1],o);break}case"ImportSpec":{let d=a.node.getChild("String");if(d){let v=e.slice(d.from,d.to).slice(1,-1);r.push({fromPath:t,toPath:"",rawSpecifier:v,isExternal:!0,isStyle:!1,type:"static"})}break}case"FunctionDecl":case"TypeDecl":case"VarDecl":case"ConstDecl":{let d=a.node.getChild("DefName")??a.node.getChild("TypeSpec")?.getChild("DefName")??a.node.getChild("VarSpec")?.getChild("DefName")??a.node.getChild("ConstSpec")?.getChild("DefName");if(d){let S=e.slice(d.from,d.to);S!=="_"&&/^[A-Z]/.test(S)&&!s.has(S)&&s.set(S,{name:S})}break}}while(a.next());let l=r.some(d=>d.rawSpecifier==="testing"),p=Lc.basename(t).endsWith("_test.go")||n.has("test")||l?"test":"logic",h=new Set([...n,...o]);return{imports:r,exports:Array.from(s.values()),tags:Array.from(h).map(d=>({name:d,kind:"comment-marker"})),category:p}}function pn(t,e){for(let r of t.split(/[\s,&|!()]+/)){let s=r.trim();s&&s!=="ignore"&&e.add(s)}}var _c,Wc,zc,mn=m(()=>{"use strict";c();_c=/\/\/\s*@tag\s+([a-zA-Z0-9_-]+)/,Wc=/^\/\/go:build\s+(.+)$/,zc=/^\/\/\s*\+build\s+(.+)$/});function te(t){return t.startsWith("'")||t.startsWith('"')?t.slice(1,-1):t}var ar=m(()=>{"use strict";c()});import $c from"livescript";function Uc(t){let e=new Set,r=/@tag\s+([a-zA-Z0-9_-]+)/g,s=r.exec(t);for(;s!==null;)s[1]&&e.add(s[1]),s=r.exec(t);return e}function Bc(t,e){let r=t.toLowerCase();return r.includes(".test.")||r.includes(".spec.")||e.has("test")?"test":"logic"}function Kc(t,e){let r=t.constructor?.name||t.type;if(r==="Import"){let s=t.right?.value;if(typeof s=="string"){let n=te(s);return{fromPath:e,toPath:"",rawSpecifier:n,isStyle:N(n),type:"static"}}}if(r==="Chain"&&t.head?.value==="require"){let s=t.tails?.[0];if(s?.constructor?.name==="Call"||s?.type==="Call"){let n=s.args?.[0]?.value;if(typeof n=="string"){let o=te(n);return{fromPath:e,toPath:"",rawSpecifier:o,isStyle:N(o),type:"require"}}}}return null}function cr(t,e){if(!t||typeof t!="object")return[];let r=[],s=Kc(t,e);s&&r.push(s);for(let n in t){if(Jc.has(n))continue;let o=t[n];if(!(!o||typeof o!="object"))if(Array.isArray(o))for(let i of o)r.push(...cr(i,e));else r.push(...cr(o,e))}return r}function un(t,e){let r=Uc(e),s=Bc(t,r),n=[];try{n=cr($c.ast(e),t)}catch{}return{imports:n,exports:[],tags:Array.from(r).map(o=>({name:o,kind:"comment-marker"})),category:s}}var Jc,gn=m(()=>{"use strict";c();O();ar();Jc=new Set(["first_line","first_column","last_line","last_column","line","column"])});import Hc from"luaparse";function Qc(t){let e=new Set,r=/@tag\s+([a-zA-Z0-9_-]+)/g,s=r.exec(t);for(;s!==null;)s[1]&&e.add(s[1]),s=r.exec(t);return e}function Vc(t,e){let r=t.toLowerCase();return r.includes(".test.")||r.includes(".spec.")||e.has("test")?"test":"logic"}function Xc(t,e){let r=[];function s(n){if(!(!n||typeof n!="object")){if((n.type==="CallExpression"||n.type==="StringCallExpression")&&n.base?.type==="Identifier"&&n.base?.name==="require"){let o;if(n.type==="CallExpression"){let i=n.arguments?.[0];i?.type==="StringLiteral"&&(o=te(i.raw))}else if(n.type==="StringCallExpression"){let i=n.argument;i?.type==="StringLiteral"&&(o=te(i.raw))}o&&r.push({fromPath:e,toPath:"",rawSpecifier:o,isStyle:N(o),type:"require"})}for(let o in n){if(o==="loc")continue;let i=n[o];if(i&&typeof i=="object")if(Array.isArray(i))for(let a of i)s(a);else s(i)}}}return s(t),r}function dn(t,e){let r=Qc(e),s=Vc(t,r),n=[];try{let o=Hc.parse(e);n=Xc(o,t)}catch{}return{imports:n,exports:[],tags:Array.from(r).map(o=>({name:o,kind:"comment-marker"})),category:s}}var hn=m(()=>{"use strict";c();O();ar()});async function el(){return yn??=(async()=>{let{unified:t}=await import("unified"),e=(await import("remark-parse")).default;return t().use(e)})(),yn}function tl(t){let e=t.trim();return e.length===0||e.startsWith("#")||Yc.some(r=>e.startsWith(r))}function rl(t,e){let r=t.match(Zc);return r?r.map(s=>({fromPath:e,toPath:"",rawSpecifier:s,isStyle:!1,type:"static"})):[]}function xn(t,e,r){if(t.type==="link"&&typeof t.url=="string"&&!tl(t.url)&&r.push({fromPath:e,toPath:"",rawSpecifier:t.url,isStyle:!1,type:"static"}),(t.type==="code"||t.type==="inlineCode")&&typeof t.value=="string"&&r.push(...rl(t.value,e)),Array.isArray(t.children))for(let s of t.children)xn(s,e,r)}async function Sn(t,e){let s=(await el()).parse(e),n=[];xn(s,t,n);let o=new Set;return{imports:n.filter(a=>o.has(a.rawSpecifier)?!1:(o.add(a.rawSpecifier),!0)),exports:[],tags:[],category:"other"}}var Yc,qc,Zc,yn,bn=m(()=>{"use strict";c();Yc=["http://","https://","mailto:","//"],qc="ts|tsx|js|jsx|mjs|cjs|py|go|lua|css|scss|less|styl|coffee|ls|feature|md|mdx|json",Zc=new RegExp(`(?:\\.{1,2}/)?[\\w.-]+(?:/[\\w.-]+)*\\.(?:${qc})\\b`,"g")});import sl from"path";import{parser as nl}from"@lezer/python";function Cn(t,e){let r=[],s=[],n=new Set,o=sl.basename(t).toLowerCase(),a=nl.parse(e).cursor();do switch(a.name){case"Comment":{let p=e.slice(a.from,a.to).match(/#\s*@tag\s+([a-zA-Z0-9_-]+)/);p?.[1]&&n.add(p[1]);break}case"ImportStatement":{for(let p of il(a.node,e,t))r.push(p);break}case"FunctionDefinition":case"ClassDefinition":{let p=a.node.parent;if(p?.name==="Script"||p?.name==="DecoratedStatement"&&p.parent?.name==="Script"){let d=a.node.getChild("VariableName");d&&s.push({name:e.slice(d.from,d.to)})}break}case"AssignStatement":{if(a.node.parent?.name==="Script"){let p=a.node.firstChild;p?.name==="VariableName"&&s.push({name:e.slice(p.from,p.to)})}break}}while(a.next());let l=pl(o,r,n);return l==="test"&&n.add("test"),{imports:r,exports:s,tags:Array.from(n).map(p=>({name:p,kind:"comment-marker"})),category:l}}function il(t,e,r){let s=t.firstChild;return s?s.name==="from"?al(t,e,r):cl(t,e,r):[]}function al(t,e,r){let s=t.firstChild;if(!s)return[];let n=s.nextSibling;for(;n&&n.name!=="import";)n=n.nextSibling;if(!n)return[];let o=e.slice(s.to,n.from).trim(),i=ll(n.nextSibling,e);if(!i.length)return[];let a=0;for(;a<o.length&&o[a]===".";)a++;let l=o.slice(a);if(a===0)return[ue(r,o,i,!0)];let p=a===1?"./":"../".repeat(a-1);return l?[ue(r,p+l.replace(/\./g,"/"),i,!1)]:i[0]==="*"?[ue(r,p.slice(0,-1),["*"],!1)]:i.map(h=>ue(r,p+h,[h],!1))}function cl(t,e,r){let s=[],n=t.firstChild?.nextSibling??null;for(;n;){if(n.name==="VariableName"){let o=e.slice(n.from,n.to);for(;n.nextSibling?.name==="."&&n.nextSibling.nextSibling?.name==="VariableName";)n=n.nextSibling.nextSibling,o+=`.${e.slice(n.from,n.to)}`;n.nextSibling?.name==="as"&&(n=n.nextSibling.nextSibling??n.nextSibling),s.push(ue(r,o,["*"],!0))}n=n.nextSibling}return s}function ll(t,e){let r=[],s=t;for(;s;)s.name==="*"?r.push("*"):s.name==="VariableName"&&(r.push(e.slice(s.from,s.to)),s.nextSibling?.name==="as"&&(s=s.nextSibling.nextSibling??s.nextSibling)),s=s.nextSibling;return r}function ue(t,e,r,s){return{fromPath:t,toPath:"",rawSpecifier:e,isStyle:!1,isExternal:s,type:"static",symbols:r.length>0?r:void 0}}function pl(t,e,r){return t.startsWith("test_")||t.endsWith("_test.py")?"test":t==="conftest.py"||t==="setup.py"?"config":r.has("test")||e.some(s=>ol.has(s.rawSpecifier))?"test":"logic"}var ol,vn=m(()=>{"use strict";c();ol=new Set(["pytest","unittest","nose","hypothesis"])});import y from"typescript";function fl(t){let e=1;function r(s){switch(s.kind){case y.SyntaxKind.IfStatement:case y.SyntaxKind.ConditionalExpression:case y.SyntaxKind.ForStatement:case y.SyntaxKind.ForInStatement:case y.SyntaxKind.ForOfStatement:case y.SyntaxKind.WhileStatement:case y.SyntaxKind.DoStatement:case y.SyntaxKind.CatchClause:case y.SyntaxKind.CaseClause:e++;break;case y.SyntaxKind.BinaryExpression:{let n=s.operatorToken.kind;(n===y.SyntaxKind.AmpersandAmpersandToken||n===y.SyntaxKind.BarBarToken||n===y.SyntaxKind.QuestionQuestionToken)&&e++;break}}y.forEachChild(s,r)}return r(t),e}function ml(t){let e=0;function r(s,n,o){if(y.isIfStatement(s)){e+=o?1:1+n;let a=o?n:n+1;r(s.expression,a,!1),r(s.thenStatement,a,!1),s.elseStatement&&(y.isIfStatement(s.elseStatement)?r(s.elseStatement,n,!0):(e+=1,r(s.elseStatement,n+1,!1)));return}if(y.isForStatement(s)||y.isForInStatement(s)||y.isForOfStatement(s)||y.isWhileStatement(s)||y.isDoStatement(s)||y.isSwitchStatement(s)){e+=1+n,y.forEachChild(s,a=>r(a,n+1,!1));return}if(y.isCatchClause(s)){e+=1+n,y.forEachChild(s,a=>r(a,n,!1));return}if(y.isConditionalExpression(s)&&(e+=1),y.isBinaryExpression(s)){let a=s.operatorToken.kind;(a===y.SyntaxKind.AmpersandAmpersandToken||a===y.SyntaxKind.BarBarToken||a===y.SyntaxKind.QuestionQuestionToken)&&(e+=1)}if(n>0&&(y.isFunctionDeclaration(s)||y.isFunctionExpression(s)||y.isArrowFunction(s))){e+=1+n,y.forEachChild(s,a=>r(a,n+1,!1));return}y.forEachChild(s,a=>r(a,n,!1))}return r(t,0,!1),e}function lr(t){return{complexity:fl(t),cognitiveComplexity:ml(t)}}var kn=m(()=>{"use strict";c()});import C from"typescript";function En(t,e){ul(t,e),dl(t,e),hl(t,e),yl(t,e)}function ul(t,e){if((C.isFunctionDeclaration(t)||C.isVariableDeclaration(t))&&t.name&&C.isIdentifier(t.name)&&gl(t)){let r;if(C.isFunctionDeclaration(t))r="function";else{let s=t.initializer;r=s&&(C.isArrowFunction(s)||C.isFunctionExpression(s))?"function":"variable"}e.tags.add({name:t.name.text,kind:r})}}function gl(t){if(C.isFunctionDeclaration(t))return C.isSourceFile(t.parent);let e=t.parent?.parent;return!!e&&C.isSourceFile(e.parent)}function dl(t,e){if(!C.isStringLiteral(t))return;let r=t.text.match(/@[\w-]+/g);if(r)for(let s of r)e.tags.add({name:s.substring(1),kind:"comment-marker"})}function hl(t,e){if(!C.isSourceFile(t))return;let r=/@tag\s+([a-zA-Z0-9_-]+)/g,s=t.getFullText(),n=r.exec(s);for(;n!==null;)n[1]&&e.tags.add({name:n[1],kind:"comment-marker"}),n=r.exec(s)}function yl(t,e){if(C.isCallExpression(t)&&xl(t.expression))for(let r of t.arguments)C.isObjectLiteralExpression(r)&&Sl(r,e)}function xl(t){return C.isIdentifier(t)?pr.has(t.text):!!(C.isPropertyAccessExpression(t)&&(pr.has(t.name.text)||C.isIdentifier(t.expression)&&pr.has(t.expression.text)))}function Sl(t,e){for(let r of t.properties){if(!C.isPropertyAssignment(r)||!C.isIdentifier(r.name)||r.name.text!=="tags"&&r.name.text!=="tag")continue;let{initializer:s}=r,n=C.isArrayLiteralExpression(s)?s.elements.filter(C.isStringLiteral):r.name.text==="tag"&&C.isStringLiteral(s)?[s]:[];for(let o of n)e.tags.add({name:o.text.replace(/^@/,""),kind:"comment-marker"})}}var pr,wn=m(()=>{"use strict";c();pr=new Set(["test","describe","it"])});import Fn from"path";import g from"typescript";function fr(t,e,r){let s=[],n=new Map,o=new Set,i=g.createSourceFile(t,e,g.ScriptTarget.Latest,!0,r==="typescript"?g.ScriptKind.TSX:g.ScriptKind.JSX),a={filePath:t,imports:s,exports:n,tags:o,rawCallEdges:[],sourceFile:i,hasUI:!1,hasTypesOnly:!0,totalStatements:0,exportStatements:0},l=Lr=>{kl(Lr,a),g.forEachChild(Lr,l)};l(i);let p=Rl(t,a);(p==="test"||p==="barrel")&&o.add({name:p,kind:"comment-marker"}),p!=="test"&&Ol(a,i);let h=i.statements[0],d=h?Tn(h):void 0,{complexity:S,cognitiveComplexity:v}=lr(i),L=bl(i);return{imports:s,exports:Array.from(n.values()),tags:Array.from(o),category:p,rawCallEdges:a.rawCallEdges??[],complexity:S,cognitiveComplexity:v,...L.length>0?{functions:L}:{},...d!==void 0?{description:d}:{}}}function bl(t){let e=[],r=(n,o)=>{let{complexity:i,cognitiveComplexity:a}=lr(o),l=t.getLineAndCharacterOfPosition(o.getStart(t)).line+1;e.push({name:n,line:l,complexity:i,cognitiveComplexity:a})},s=(n,o)=>{if(g.isFunctionDeclaration(n)&&n.name&&n.body?r(n.name.text,n):g.isVariableDeclaration(n)&&g.isIdentifier(n.name)&&n.initializer&&(g.isArrowFunction(n.initializer)||g.isFunctionExpression(n.initializer))?r(n.name.text,n.initializer):o&&g.isMethodDeclaration(n)&&g.isIdentifier(n.name)&&n.body?r(`${o}.${n.name.text}`,n):o&&g.isConstructorDeclaration(n)&&n.body?r(`${o}.constructor`,n):o&&g.isGetAccessorDeclaration(n)&&g.isIdentifier(n.name)&&n.body?r(`${o}.get ${n.name.text}`,n):o&&g.isSetAccessorDeclaration(n)&&g.isIdentifier(n.name)&&n.body&&r(`${o}.set ${n.name.text}`,n),g.isClassDeclaration(n)&&n.name){let i=n.name.text;g.forEachChild(n,a=>s(a,i));return}g.forEachChild(n,i=>s(i,o))};return s(t,void 0),e}function Pn(t,e,r,s){let n={name:t},o=Tn(r);o!==void 0&&(n.doc=o);let i=Cl(e);i!==void 0&&(n.flags=i);let a=vl(e,s);return a!==void 0&&(n.signature=a),n}function Tn(t){let e=g.getJSDocCommentsAndTags(t);for(let r of e)if(g.isJSDoc(r)&&r.comment)return g.getTextOfJSDocComment(r.comment)||void 0}function Cl(t){let e=new Set(["deprecated","internal","public","alpha","beta"]),r=g.getJSDocTags(t).map(s=>s.tagName.text).filter(s=>e.has(s));return r.length>0?r:void 0}function vl(t,e){let r=g.createPrinter({removeComments:!0}),s=n=>r.printNode(g.EmitHint.Unspecified,n,e);if(g.isFunctionDeclaration(t)||g.isMethodDeclaration(t)){let n=t.parameters.map(s).join(", "),o=t.type?s(t.type):"void";return`${t.typeParameters?`<${t.typeParameters.map(a=>a.name.text).join(", ")}>`:""}(${n}) => ${o}`}if(g.isVariableDeclaration(t)){if(t.type)return s(t.type);if(t.initializer&&(g.isArrowFunction(t.initializer)||g.isFunctionExpression(t.initializer))){let n=t.initializer,o=n.parameters.map(s).join(", "),i=n.type?s(n.type):"unknown";return`(${o}) => ${i}`}return}if(g.isClassDeclaration(t)&&t.name)return`class ${t.name.text}`;if(g.isInterfaceDeclaration(t))return`interface ${t.name.text}`;if(g.isTypeAliasDeclaration(t))return s(t.type);if(g.isEnumDeclaration(t))return`enum ${t.name.text}`}function kl(t,e){El(t,e),wl(t,e),Pl(t,e),Tl(t,e),Dl(t,e),En(t,e)}function El(t,e){if(!g.isSourceFile(t))return;let r=t.statements.filter(s=>!g.isEmptyStatement(s));e.totalStatements=r.length,e.exportStatements=r.filter(s=>g.isExportDeclaration(s)||g.isExportAssignment(s)||mr(s)).length}function wl(t,e){if(g.isJsxElement(t)||g.isJsxSelfClosingElement(t)||g.isJsxFragment(t)){e.hasUI=!0,e.hasTypesOnly=!1;return}if(g.isFunctionDeclaration(t)||g.isMethodDeclaration(t)||g.isArrowFunction(t)||g.isClassDeclaration(t)||g.isVariableStatement(t)||g.isEnumDeclaration(t)){e.hasTypesOnly=!1;return}g.isExportDeclaration(t)&&!Fl(t)&&(e.hasTypesOnly=!1)}function Fl(t){return t.isTypeOnly?!0:!t.exportClause||!g.isNamedExports(t.exportClause)?!1:t.exportClause.elements.every(e=>e.isTypeOnly)}function Pl(t,e){if(!g.isImportDeclaration(t)||!t.moduleSpecifier||!g.isStringLiteral(t.moduleSpecifier))return;let r=[];if(t.importClause&&(t.importClause.name&&r.push("default"),t.importClause.namedBindings))if(g.isNamedImports(t.importClause.namedBindings))for(let n of t.importClause.namedBindings.elements)r.push(n.name.text);else g.isNamespaceImport(t.importClause.namedBindings)&&r.push("*");let s=r.length>0?"static":"side-effect";e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:t.moduleSpecifier.text,isStyle:N(t.moduleSpecifier.text),type:s,symbols:r.length>0?r:void 0})}function Tl(t,e){g.isExportDeclaration(t)?Nl(t,e):g.isExportAssignment(t)?e.exports.set("default",{name:"default"}):mr(t)&&Al(t,e)}function Nl(t,e){if(t.moduleSpecifier&&g.isStringLiteral(t.moduleSpecifier))Il(t,t.moduleSpecifier.text,e);else if(t.exportClause&&g.isNamedExports(t.exportClause))for(let r of t.exportClause.elements){let s=r.name.text;e.exports.set(s,{name:s})}}function Il(t,e,r){let s=Ml(t),n={fromPath:r.filePath,toPath:"",rawSpecifier:e,isStyle:N(e),type:"re-export"};s.length>0&&(n.symbols=s),r.imports.push(n)}function Ml(t){return t.exportClause?g.isNamedExports(t.exportClause)?t.exportClause.elements.map(e=>e.name.text):[]:["*"]}function Al(t,e){if((g.isFunctionDeclaration(t)||g.isClassDeclaration(t)||g.isInterfaceDeclaration(t)||g.isTypeAliasDeclaration(t)||g.isEnumDeclaration(t))&&t.name){let s=t.name.text;e.exports.set(s,Pn(s,t,t,e.sourceFile));return}if(g.isVariableStatement(t)){for(let s of t.declarationList.declarations)if(g.isIdentifier(s.name)){let n=s.name.text;e.exports.set(n,Pn(n,s,t,e.sourceFile))}}}function Dl(t,e){if(!g.isCallExpression(t))return;let r=t.arguments[0];!r||!g.isStringLiteral(r)||(t.expression.kind===g.SyntaxKind.ImportKeyword?e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:r.text,isStyle:N(r.text),type:"dynamic"}):g.isIdentifier(t.expression)&&t.expression.text==="require"&&e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:r.text,isStyle:N(r.text),type:"require"}))}function Rl(t,e){let r=Fn.basename(t).toLowerCase(),s=Fn.extname(t).toLowerCase();return se().some(o=>r.includes(o))?"test":_r(r)?"config":e.imports.some(o=>at().some(i=>o.rawSpecifier.includes(i)))?"test":s===".tsx"||s===".jsx"||e.hasUI?"ui":e.hasTypesOnly&&e.totalStatements>0?"type-only":e.totalStatements>0&&e.exportStatements/e.totalStatements>lt()?"barrel":"logic"}function mr(t){return g.canHaveModifiers(t)&&g.getModifiers(t)?.some(e=>e.kind===g.SyntaxKind.ExportKeyword)===!0}function Ol(t,e){let r=t.rawCallEdges??[];t.rawCallEdges=r;let s=new Map;for(let n of e.statements){if(!g.isImportDeclaration(n)||!g.isStringLiteral(n.moduleSpecifier))continue;let o=n.moduleSpecifier.text,i=n.importClause;if(i&&(i.name&&s.set(i.name.text,o),i.namedBindings&&g.isNamedImports(i.namedBindings)))for(let a of i.namedBindings.elements)s.set(a.name.text,o)}if(s.size!==0)for(let n of e.statements){let o=Ll(n);if(o){let i=jl(n);i&&Ze(i,o,s,r);continue}g.isClassDeclaration(n)&&n.name&&Gl(n,s,r)}}function Gl(t,e,r){let s=t.name.text;for(let n of t.members)g.isMethodDeclaration(n)&&n.body&&g.isIdentifier(n.name)?Ze(n.body,`${s}.${n.name.text}`,e,r):g.isConstructorDeclaration(n)&&n.body&&Ze(n.body,`${s}.constructor`,e,r)}function Ll(t){if(mr(t)){if(g.isFunctionDeclaration(t)&&t.name)return t.name.text;if(g.isVariableStatement(t)){for(let e of t.declarationList.declarations)if(g.isIdentifier(e.name)&&e.initializer&&(g.isArrowFunction(e.initializer)||g.isFunctionExpression(e.initializer)))return e.name.text}}}function jl(t){if(g.isFunctionDeclaration(t))return t.body;if(g.isVariableStatement(t)){for(let e of t.declarationList.declarations)if(e.initializer&&(g.isArrowFunction(e.initializer)||g.isFunctionExpression(e.initializer)))return e.initializer}}function Ze(t,e,r,s){if(g.isCallExpression(t)&&g.isIdentifier(t.expression)){let n=t.expression.text,o=r.get(n);o&&!s.some(i=>i.from===e&&i.to===n&&i.toSpecifier===o)&&s.push({from:e,to:n,toSpecifier:o})}g.forEachChild(t,n=>Ze(n,e,r,s))}var Nn=m(()=>{"use strict";c();U();kn();O();wn()});function et(t,e){if(e.length===0)return"ui";let r=!1;return t.walk(s=>{if(s.type==="rule")return r=!0,!1}),r?"ui":"barrel"}var In=m(()=>{"use strict";c()});import An from"postcss";import*as _l from"postcss-less";function Mn(t){return t.startsWith("~")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//")||t.startsWith("data:")}function zl(t){let e=t.trim();return e.length>0&&!e.startsWith("http://")&&!e.startsWith("https://")&&!e.startsWith("//")&&!e.startsWith("data:")&&!e.startsWith("#")}function $l(t,e){let r=t.match(/^\(([^)]+)\)\s+['"]([^'"]+)['"]/);if(r){let o=r[1]?.trim()??"",i=r[2]??"";if(!i)return null;let a=Dn.has(o)?"side-effect":"static";return{fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:a,...Mn(i)?{isExternal:!0}:{}}}let s=t.match(/^url\(['"]?([^'")]+)['"]?\)/),n=s?s[1]?.trim()??"":t.match(/^['"]([^'"]+)['"]/)?.[1]??"";return n?{fromPath:e,toPath:"",rawSpecifier:n,isStyle:!0,type:"static",...Mn(n)?{isExternal:!0}:{}}:null}function Ul(t,e){let r=[],s=/url\(['"]?([^'")]+)['"]?\)/g,n=s.exec(t);for(;n!==null;){let o=n[1]?.trim()??"";zl(o)&&r.push({fromPath:e,toPath:"",rawSpecifier:o,isStyle:!0,type:"static"}),n=s.exec(t)}return r}function Rn(t,e){let r=[];return t.walk(s=>{if(s.type==="atrule"&&s.name==="import"){let n=$l(s.params,e);n&&r.push(n)}s.type==="decl"&&r.push(...Ul(s.value,e))}),r}function Bl(t){return t.replace(/(?<!:)\/\/.*/g,"")}function Jl(t,e){let r=[],s=/@import\s+(?:\(([^)]+)\)\s+)?['"]([^'"]+)['"]/g,n=s.exec(t);for(;n!==null;){let o=n[1]?.trim()??"",i=n[2]??"";if(i){let a=Dn.has(o)?"side-effect":"static";r.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:a})}n=s.exec(t)}return r}function On(t,e){let r=An.parse(Bl(t));return{imports:Rn(r,e),root:r}}function Gn(t,e){try{let r=Wl.parse(t);return{imports:Rn(r,e),root:r}}catch{return{imports:Jl(t,e),root:An.parse("")}}}var Wl,Dn,Ln=m(()=>{"use strict";c();Wl=_l,Dn=new Set(["reference","inline"])});import{parse as Kl}from"postcss-scss";function Hl(t){return!!(t.startsWith("sass:")||t.startsWith("~")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//")||!t.startsWith(".")&&!t.startsWith("/")&&!t.startsWith("_"))}function Ql(t){let e=t.match(/^['"]([^'"]+)['"]/);if(!e?.[1])return{specifier:""};let r=e[1],n=t.match(/\bas\s+(\S+)/)?.[1];return n!==void 0?{specifier:r,alias:n}:{specifier:r}}function jn(t,e){let r=Kl(t),s=[];return r.walk(n=>{if(n.type!=="atrule")return;let{name:o,params:i}=n;if(o!=="import"&&o!=="use"&&o!=="forward")return;let{specifier:a,alias:l}=Ql(i);if(!a)return;let p={fromPath:e,toPath:"",rawSpecifier:a,isStyle:!0,type:o==="forward"?"re-export":"static",...Hl(a)?{isExternal:!0}:{}};l&&(p.symbols=[l]),s.push(p)}),{imports:s,root:r}}var _n=m(()=>{"use strict";c()});function Wn(t,e){let r=[],s=/@require\s+['"]([^'"]+)['"]/g,n=s.exec(t);for(;n!==null;){let i=n[1];i&&r.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:"require"}),n=s.exec(t)}let o=/(?<!@)(?:import|require)\s*\(?\s*['"]([^'"]+)['"]/g;for(n=o.exec(t);n!==null;){let i=n[1];i&&r.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:"static"}),n=o.exec(t)}return r}function zn(t,e){if(e.length===0)return"ui";try{let r=it("stylus");return new r.Parser(t).parse().nodes.some(o=>o.constructor.name!=="Import")?"ui":"barrel"}catch{return t.replace(/^\s*@?(?:require|import)\b.*/gm,"").trim().length>0?"ui":"barrel"}}var $n=m(()=>{"use strict";c()});function ge(t,e){let r=R(t);if(r==="stylus"){let o=Wn(e,t);return{imports:o,exports:[],tags:[],category:zn(e,o)}}if(r==="scss"){let{imports:o,root:i}=jn(e,t);return{imports:o,exports:[],tags:[],category:et(i,o)}}if(r==="less"){let{imports:o,root:i}=Gn(e,t);return{imports:o,exports:[],tags:[],category:et(i,o)}}let{imports:s,root:n}=On(e,t);return{imports:s,exports:[],tags:[],category:et(n,s)}}var Un=m(()=>{"use strict";c();O();In();Ln();_n();$n()});async function Bn(t,e){let r=R(t),s=ks(r);return s?s(t,e):{imports:[],exports:[],tags:[],category:"other"}}var Jn=m(()=>{"use strict";c();O();cn();ln();mn();gn();hn();bn();vn();Nn();fe();Un();U();O();fe();for(let[t,e]of[["javascript",(r,s)=>fr(r,s,"javascript")],["typescript",(r,s)=>fr(r,s,"typescript")],["css",ge],["scss",ge],["less",ge],["stylus",ge],["coffeescript",an],["livescript",un],["lua",dn],["python",Cn],["go",fn],["gherkin",ir],["markdown",Sn]])H(t,e)});import Kn from"path";function Qn(t,e){for(let r of t.values()){let s=e.get(r.path);s!==void 0&&(r.coveragePct=s)}}function Vn(t,e){for(let r of t)if(r.isExternal){let s=r.rawSpecifier.startsWith("@")?r.rawSpecifier.split("/").slice(0,2).join("/"):r.rawSpecifier.split("/")[0];s&&!e.some(n=>n.name===s)&&e.push({name:s,kind:"library"})}}function Xn(t){for(let e of t.values())if(e.category==="test")for(let r of e.imports){if(r.isExternal||!r.toPath)continue;let s=t.get(r.toPath);s&&(s.category!=="logic"&&s.category!=="barrel"||(s.testedBy??=[],s.testedBy.includes(e.path)||s.testedBy.push(e.path)))}}function Yn(t){for(let e of t.values())if(e.type==="markdown")for(let r of e.imports){if(r.isExternal||!r.toPath)continue;let s=t.get(r.toPath);!s||s===e||(s.documentedBy??=[],s.documentedBy.includes(e.path)||s.documentedBy.push(e.path),s.category==="logic"&&(s.lastCommitAt??0)>(e.lastCommitAt??0)&&(e.staleFor??=[],e.staleFor.includes(s.path)||e.staleFor.push(s.path)))}}function Hn(t){return Math.round(t*1e4)/1e4}function qn(t){for(let e of t.values()){let r=[];for(let s of e.imports){if(s.isExternal||!s.toPath)continue;let n=t.get(s.toPath);if(!n||n.exports.length===0)continue;let o;if(s.symbols===void 0){if(s.type==="side-effect")continue;o=1}else s.symbols.includes("*")?o=1:o=s.symbols.length/n.exports.length;s.exportUsageRatio=Hn(Math.min(1,o)),r.push(s.exportUsageRatio)}r.length>0&&(e.avgExportUsage=Hn(r.reduce((s,n)=>s+n,0)/r.length),e.maxExportUsage=Math.max(...r))}}function ur(t,e,r){e&&(t.some(s=>s.name===e&&s.kind===r)||t.push({name:e,kind:r}))}function Vl(t,e){let r=e.toPath,s=Kn.basename(r,Kn.extname(r)).replace(/\.(test|spec)$/,"");ur(t.tags,s,"import")}function Xl(t,e){if(!(!e.symbols||e.symbols.includes("*")))for(let r of e.symbols)ur(t.tags,r,"import")}function Yl(t,e,r){let s=r.get(e.toPath);if(!(!s||s.category==="test"))for(let n of s.tags)n.kind==="comment-marker"&&ur(t.tags,n.name,"comment-marker")}function Zn(t){for(let e of t.values())if(e.category==="test")for(let r of e.imports)!r.toPath||r.isExternal||(Vl(e,r),Xl(e,r),Yl(e,r,t))}var eo=m(()=>{"use strict";c()});import so from"fs";import re from"path";function ql(t,e){let r=t.split(`
23
+ `),s=null,n=new Map,o=!1;for(let i of r){let a=i.trim();if(a.startsWith("module ")){s=a.slice(7).trim();continue}if(/^replace\s*\(/.test(a)){o=!0;continue}if(o&&a===")"){o=!1;continue}if(o&&a.includes("=>")){to(a,e,n);continue}!o&&/^replace\s+/.test(a)&&a.includes("=>")&&to(a.replace(/^replace\s+/,""),e,n)}return{mod:s,replaces:n}}function to(t,e,r){let[s,n]=t.split("=>").map(a=>a.trim());if(!s||!n)return;let o=s.split(/\s+/)[0];if(!n.startsWith(".")&&!n.startsWith("/"))return;let i=re.isAbsolute(n)?n:re.resolve(e,n);r.set(o,i)}function ro(t){let e;try{e=so.readdirSync(t,{withFileTypes:!0})}catch{return null}let r=e.filter(s=>s.isFile()&&s.name.endsWith(".go")&&!s.name.endsWith("_test.go")).map(s=>({path:re.join(t,s.name),isExternal:!1})).sort((s,n)=>s.path.localeCompare(n.path));return r.length>0?r:null}var de,no=m(()=>{"use strict";c();de=class{extensions=[".go"];goModCache=new Map;resolve(e,r,s,n){let{mod:o,replaces:i}=this.readGoMod(s);if(!o)return null;let a=this.applyReplace(r,i,s);if(a!==void 0)return ro(a);if(r!==o&&!r.startsWith(`${o}/`))return null;let l=r.slice(o.length).replace(/^\//,"");return l?ro(re.join(s,l)):null}readGoMod(e){let r=this.goModCache.get(e);if(r!==void 0)return r;let s={mod:null,replaces:new Map};try{let n=so.readFileSync(re.join(e,"go.mod"),"utf-8"),o=ql(n,e);return this.goModCache.set(e,o),o}catch{return this.goModCache.set(e,s),s}}applyReplace(e,r,s){for(let[n,o]of r){if(e===n)return o;if(e.startsWith(`${n}/`)){let i=e.slice(n.length+1);return re.join(o,i)}}}}});import Zl from"fs";import gr from"path";var he,oo=m(()=>{"use strict";c();he=class{extensions=[".lua"];resolve(e,r,s,n){let o=r.replace(/\./g,gr.sep),i=[s,gr.join(s,"lib")];for(let a of i){if(!Zl.existsSync(a))continue;let l=n(gr.join(a,"_dummy.lua"),o);if(l)return[l]}return null}}});import ep from"path";var ye,io=m(()=>{"use strict";c();ye=class{extensions=[".md",".mdx"];resolve(e,r,s,n){let o=n(ep.join(s,"_dummy"),`./${r}`);return o?[o]:null}}});import tp from"fs";import dr from"path";function ao(t){try{return tp.statSync(t,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}var xe,co=m(()=>{"use strict";c();xe=class{extensions=[".py"];resolve(e,r,s,n){let o=r.replace(/\./g,dr.sep),i=dr.join(s,`${o}.py`);if(ao(i))return[{path:i,isExternal:!1}];let a=dr.join(s,o,"__init__.py");return ao(a)?[{path:a,isExternal:!1}]:null}}});import lo from"path";var rp,Se,po=m(()=>{"use strict";c();rp=["~","http://","https://","//","data:","sass:"],Se=class{extensions=[".css",".scss",".sass",".less",".styl"];resolve(e,r,s,n){if(rp.some(h=>r.startsWith(h)))return null;let o=n(e,r);if(o)return[o];let i=lo.dirname(r),a=lo.basename(r),l=i==="."?`_${a}`:`${i}/_${a}`,p=n(e,l);return p?[p]:null}}});var fo=m(()=>{"use strict";c();no();oo();io();co();po()});import tt from"fs";import G from"path";var z,hr=m(()=>{"use strict";c();fo();z=class{constructor(e,r={}){this.rootDir=e;this.workspaceMap=r.workspaceMap??new Map,this.tsconfigSearchPaths=r.tsconfigSearchPaths??[e],this.pathAliases=r.pathAliases,this.langResolvers=r.langResolvers??[new xe,new he,new de,new Se,new ye]}rootDir;workspaceMap;tsconfigSearchPaths;pathAliases;langResolvers;resolveAll(e,r){let s=this.resolvePathAlias(r);if(s)return[s];if(r.startsWith(".")||r.startsWith("/")){let i=this.resolveLocalPath(e,r);return i?[i]:[]}let n=(i,a)=>this.resolveLocalPath(i,a);for(let i of this.langResolvers)if(i.extensions.some(a=>e.endsWith(a))){let a=i.resolve(e,r,this.rootDir,n);if(a)return a}let o=this.resolveWorkspaceImport(r);return o?[o]:[{path:r,isExternal:!0}]}resolve(e,r){let s=this.resolvePathAlias(r);if(s)return s;if(r.startsWith(".")||r.startsWith("/"))return this.resolveLocalPath(e,r);let n=(i,a)=>this.resolveLocalPath(i,a);for(let i of this.langResolvers)if(i.extensions.some(a=>e.endsWith(a))){let a=i.resolve(e,r,this.rootDir,n);if(a)return a[0]??null}let o=this.resolveWorkspaceImport(r);return o||{path:r,isExternal:!0}}resolveLocalPath(e,r){let s=G.dirname(e),n=r.startsWith("/")?r:G.resolve(s,r),o=!n.startsWith(this.rootDir),i=["",".ts",".tsx",".js",".jsx",".mjs",".cjs",".css",".scss",".sass",".less",".styl",".coffee",".ls",".lua",".py",".feature",".md",".mdx"],a=n.match(/\.(js|mjs|cjs)$/);if(a){let l=n.slice(0,-a[0].length);for(let p of[".ts",".tsx"]){let h=this.tryExtensions(l,p,o);if(h)return h}}for(let l of i){let p=this.tryExtensions(n,l,o);if(p)return p}return o?{path:n,isExternal:!0}:null}tryExtensions(e,r,s){let n=e+r;if(this.isFile(n))return{path:n,isExternal:s};let o=G.join(e,`index${r}`);if(this.isFile(o))return{path:o,isExternal:s};if(r===".py"){let i=G.join(e,"__init__.py");if(this.isFile(i))return{path:i,isExternal:s}}return null}isFile(e){try{return tt.statSync(e,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}resolvePathAlias(e){if(this.pathAliases)for(let r in this.pathAliases){let s=this.matchAliasPattern(r,e),n=this.pathAliases[r];if(s&&n){let o=this.tryAliasSubstitutions(n,s[1]||"");if(o)return o}}for(let r of this.tsconfigSearchPaths){let s=G.join(r,"tsconfig.json");if(tt.existsSync(s))try{let o=JSON.parse(tt.readFileSync(s,"utf-8")).compilerOptions?.paths;if(!o)continue;for(let i in o){let a=this.matchAliasPattern(i,e);if(a){let l=this.tryAliasSubstitutions(o[i],a[1]||"",r);if(l)return l}}}catch{}}return null}aliasRegexCache=new Map;matchAliasPattern(e,r){let s=this.aliasRegexCache.get(e);if(!s){let n=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace("\\*","(.*)");s=new RegExp(`^${n}$`),this.aliasRegexCache.set(e,s)}return r.match(s)}tryAliasSubstitutions(e,r,s=this.rootDir){let n=["",".ts",".tsx",".js",".jsx",".coffee",".ls",".lua",".feature"];for(let o of e){let i=o.replace("*",r),a=G.resolve(s,i);for(let l of n){let p=this.tryExtensions(a,l,!1);if(p)return p}}return null}resolveWorkspaceImport(e){if(this.workspaceMap.size===0)return null;for(let[r,s]of this.workspaceMap){if(e!==r&&!e.startsWith(`${r}/`))continue;let n=e.slice(r.length),o={path:"",isExternal:!1,isWorkspace:!0,workspacePackage:r};if(!n){for(let a of["src/index.ts","src/index.tsx","index.ts","index.tsx","index.js"]){let l=G.join(s,a);try{if(tt.statSync(l,{throwIfNoEntry:!1})?.isFile())return{...o,path:l}}catch{}}return{...o,path:s}}let i=this.resolveLocalPath(G.join(s,"_dummy"),n.slice(1));return i?{...o,path:i.path}:null}return null}}});import be from"fs";import F from"path";import sp from"piscina";function ip(t,e){if(t.length===0)return e;let r=t.map(i=>F.dirname(i).split(F.sep)),s=r[0];for(let i of r.slice(1)){let a=0;for(;a<s.length&&a<i.length&&s[a]===i[a];)a++;s=s.slice(0,a)}let n=s.join(F.sep)||F.sep,o=F.relative(e,n);return o.startsWith("..")||F.isAbsolute(o)?e:n}var np,mo,op,Ce,uo=m(()=>{"use strict";c();nr();U();nn();Jn();eo();ie();hr();np=["tests","test","__tests__","specs","spec"],mo=new Set(["node_modules",".git","dist","build",".next",".cache","mokosh-cache","coverage"]),op=20;Ce=class{constructor(e,r=null,s,n,o=!1,i=new Map,a=!0){this.rootDir=e;this.enableGitStats=o;this.coverageMap=i;this.parallelParsing=a;this.previousGraph=r,this.resolver=s||new z(e),this.lockFile=sn(e),n&&(this.progressCallback=n)}rootDir;enableGitStats;coverageMap;parallelParsing;graph={nodes:new Map};visited=new Set;queue=[];previousGraph=null;resolver;lockFile=null;progressCallback;pool=null;gitStatsMap=null;async build(e){let r=e.map(s=>F.isAbsolute(s)?s:F.resolve(this.rootDir,s));await this.initPool(),this.enableGitStats&&(this.gitStatsMap=en(this.rootDir));try{for(let s of r)this.enqueue(s);return await this.drain(),await this.processTestFiles(ip(r,this.rootDir)),await this.processDocFiles(),this.progressCallback&&this.visited.size>=100&&process.stderr.write(`
24
24
  Done. Total processed: ${this.visited.size} nodes.
25
- `),po(this.graph.nodes),io(this.graph.nodes),co(this.graph.nodes),ao(this.graph.nodes),this.coverageMap.size>0&&no(this.graph.nodes,this.coverageMap),new P(this.graph.nodes)}finally{this.pool&&(await this.pool.destroy(),this.pool=null)}}async initPool(){if(this.parallelParsing===!1)return;let e=typeof this.parallelParsing=="object"?this.parallelParsing:{},r=e.minFiles??Ml;if(!(r>0&&!this.hasAtLeastFiles(this.rootDir,r)))try{let s=F.join(f,"parse-worker.js");this.pool=new Nl({filename:s,...e.maxThreads!==void 0?{maxThreads:e.maxThreads}:{}})}catch(s){process.stderr.write(`
25
+ `),Zn(this.graph.nodes),Xn(this.graph.nodes),qn(this.graph.nodes),Yn(this.graph.nodes),this.coverageMap.size>0&&Qn(this.graph.nodes,this.coverageMap),new P(this.graph.nodes)}finally{this.pool&&(await this.pool.destroy(),this.pool=null)}}async initPool(){if(this.parallelParsing===!1)return;let e=typeof this.parallelParsing=="object"?this.parallelParsing:{},r=e.minFiles??op;if(!(r>0&&!this.hasAtLeastFiles(this.rootDir,r)))try{let s=F.join(f,"parse-worker.js");this.pool=new sp({filename:s,...e.maxThreads!==void 0?{maxThreads:e.maxThreads}:{}})}catch(s){process.stderr.write(`
26
26
  Warning: failed to start parse worker pool, falling back to synchronous parsing: ${s}
27
- `),this.pool=null}}hasAtLeastFiles(e,r){let s=0,n=[e];for(;n.length>0;){let o=n.pop(),i;try{i=be.readdirSync(o,{withFileTypes:!0})}catch{continue}for(let a of i)if(a.isDirectory())ko.has(a.name)||n.push(F.join(o,a.name));else if(a.isFile()&&(s++,s>=r))return!0}return s>=r}async processTestFiles(e){let r=ne(),s=o=>r.some(i=>o.name.includes(i));this.walkProject(e,s);let n=e;for(;n!==this.rootDir;){let o=F.dirname(n);if(o===n)break;for(let i of Il){let a=F.join(o,i);try{be.statSync(a).isDirectory()&&this.walkProject(a,s)}catch{}}n=o}await this.drain()}async processDocFiles(){this.walkProject(this.rootDir,e=>e.name.endsWith(".md")||e.name.endsWith(".mdx")),await this.drain()}walkProject(e,r){let s;try{s=be.readdirSync(e,{withFileTypes:!0})}catch{return}for(let n of s){let o=F.join(e,n.name);n.isDirectory()?ko.has(n.name)||this.walkProject(o,r):n.isFile()&&r(n)&&this.enqueue(o)}}enqueue(e){this.visited.has(e)||(this.visited.add(e),this.showProgress(),this.queue.push(e))}async drain(){for(;this.queue.length>0;){let e=this.queue;this.queue=[],await Promise.all(e.map(r=>this.finishFile(r)))}}async finishFile(e){let r=be.statSync(e,{throwIfNoEntry:!1});if(!r?.isFile())return;let s=F.relative(this.rootDir,e),n=await this.getNode(e,s,r);n.imports=await this.resolveImports(e,n.imports),oo(n.imports,n.tags),this.graph.nodes.set(n.path,n)}async getNode(e,r,s){let n=this.previousGraph?.nodes.get(r);if(n&&n.mtime===s.mtimeMs&&n.size===s.size)return{...n};let o=await this.tryParse(e,r);if(!o)return this.makeStubNode(e,r,s);let i=this.resolveCallEdges(e,o.rawCallEdges),a=this.buildNode(e,r,s,o,i);return this.attachGitStats(a,r),a}async tryParse(e,r){let s=be.readFileSync(e,"utf-8");try{return await this.parseContent(e,s)}catch(n){return process.stderr.write(`
27
+ `),this.pool=null}}hasAtLeastFiles(e,r){let s=0,n=[e];for(;n.length>0;){let o=n.pop(),i;try{i=be.readdirSync(o,{withFileTypes:!0})}catch{continue}for(let a of i)if(a.isDirectory())mo.has(a.name)||n.push(F.join(o,a.name));else if(a.isFile()&&(s++,s>=r))return!0}return s>=r}async processTestFiles(e){let r=se(),s=o=>r.some(i=>o.name.includes(i));this.walkProject(e,s);let n=e;for(;n!==this.rootDir;){let o=F.dirname(n);if(o===n)break;for(let i of np){let a=F.join(o,i);try{be.statSync(a).isDirectory()&&this.walkProject(a,s)}catch{}}n=o}await this.drain()}async processDocFiles(){this.walkProject(this.rootDir,e=>e.name.endsWith(".md")||e.name.endsWith(".mdx")),await this.drain()}walkProject(e,r){let s;try{s=be.readdirSync(e,{withFileTypes:!0})}catch{return}for(let n of s){let o=F.join(e,n.name);n.isDirectory()?mo.has(n.name)||this.walkProject(o,r):n.isFile()&&r(n)&&this.enqueue(o)}}enqueue(e){this.visited.has(e)||(this.visited.add(e),this.showProgress(),this.queue.push(e))}async drain(){for(;this.queue.length>0;){let e=this.queue;this.queue=[],await Promise.all(e.map(r=>this.finishFile(r)))}}async finishFile(e){let r=be.statSync(e,{throwIfNoEntry:!1});if(!r?.isFile())return;let s=F.relative(this.rootDir,e),n=await this.getNode(e,s,r);n.imports=await this.resolveImports(e,n.imports),Vn(n.imports,n.tags),this.graph.nodes.set(n.path,n)}async getNode(e,r,s){let n=this.previousGraph?.nodes.get(r);if(n&&n.mtime===s.mtimeMs&&n.size===s.size)return{...n};let o=await this.tryParse(e,r);if(!o)return this.makeStubNode(e,r,s);let i=this.resolveCallEdges(e,o.rawCallEdges),a=this.buildNode(e,r,s,o,i);return this.attachGitStats(a,r),a}async tryParse(e,r){let s=be.readFileSync(e,"utf-8");try{return await this.parseContent(e,s)}catch(n){return process.stderr.write(`
28
28
  Warning: failed to parse ${r}: ${n}
29
- `),null}}parseContent(e,r){return this.pool?this.pool.run({filePath:e,content:r}):eo(e,r)}makeStubNode(e,r,s){return{path:r,type:L(e),category:"other",imports:[],exports:[],tags:[],mtime:s.mtimeMs,size:s.size}}resolveCallEdges(e,r){let s=[];for(let n of r??[])try{let o=this.resolver.resolve(e,n.toSpecifier);o&&!o.isExternal&&s.push({from:n.from,to:n.to,toFile:F.relative(this.rootDir,o.path)})}catch{}return s}buildNode(e,r,s,n,o){let{imports:i,exports:a,tags:p,category:l,description:d,complexity:h,cognitiveComplexity:x,functions:C}=n;return{path:r,type:L(e),category:l,imports:i,exports:a,tags:p,mtime:s.mtimeMs,size:s.size,...d!==void 0?{description:d}:{},...o.length>0?{callEdges:o}:{},...h!==void 0?{complexity:h}:{},...x!==void 0?{cognitiveComplexity:x}:{},...C!==void 0?{functions:C}:{}}}attachGitStats(e,r){let s=this.gitStatsMap?.get(r);s&&(e.commitCount90d=s.commitCount90d,s.lastAuthor!==void 0&&(e.lastAuthor=s.lastAuthor),s.lastCommitAt!==void 0&&(e.lastCommitAt=s.lastCommitAt))}async resolveImports(e,r){let s=[];for(let n of r){let o=this.resolver.resolveAll(e,n.rawSpecifier);if(o.length!==0)for(let i of o){let a={...n,toPath:i.isExternal?i.path:F.relative(this.rootDir,i.path),isExternal:i.isExternal};i.isWorkspace&&(a.isWorkspace=!0,a.workspacePackage=i.workspacePackage),i.isExternal?this.attachLockfileVersion(a):this.enqueue(i.path),s.push(a)}}return s}attachLockfileVersion(e){if(!this.lockFile)return;let r=e.rawSpecifier.startsWith("@")?e.rawSpecifier.split("/").slice(0,2).join("/"):e.rawSpecifier.split("/")[0],s=r?this.lockFile.dependencies[r]:void 0;s&&(e.version=s.version)}showProgress(){this.progressCallback&&this.visited.size%100===0&&this.progressCallback(this.visited.size)}}});var Eo=m(()=>{"use strict";c();bt();wo();vt();Et();Me();De();ae();gr();Ot();Ae();jt();Ut();Bt()});var dr=m(()=>{"use strict";c();Eo()});function Fo(t,e){return{identifier:e?.identifier??new Qe,featureMap:e?.featureDetection===!1?new Map:W(t.nodes,e?.featureDetection??void 0)}}function Po(t,e,r,s,n){for(let o of e){let i=t.nodes.get(o);if(!i)continue;let a=new z(o,["*",...i.exports.map(p=>p.name)]);t.traverse(o,(p,l,d)=>{if(!d)return!0;if(!a.updateAffectedSymbols(p,d))return!1;if(l>0){let h=r.get(p.path);if(h)return s(h),!1}return n(p),!0},{direction:"incoming"})}}function hr(t,e,r){let{identifier:s,featureMap:n}=Fo(t,r),o=new Set;for(let i of e){let a=n.get(i);a&&o.add(a.tag)}return Po(t,e,n,i=>o.add(i.tag),i=>{if(s.isTestNode(i))for(let a of i.tags)o.add(a.name)}),Array.from(o)}function yr(t,e,r){let{identifier:s,featureMap:n}=Fo(t,r),o=new Set;return Po(t,e,n,()=>{},i=>{s.isTestNode(i)&&o.add(i.path)}),Array.from(o)}var To=m(()=>{"use strict";c();dr();er()});var No=m(()=>{"use strict";c();an();er();To()});import Al from"fs";import ve from"path";async function M(t,e,r=null,s={}){let n=s.silent?void 0:a=>{process.stderr.write(`Processed ${a} files...\r`)},o=ve.resolve(t);return await new Ce(o,r,s.pathAliases?new $(o,{pathAliases:s.pathAliases}):void 0,n,s.gitStats??!1,s.coverageMap??new Map,s.parallelParsing??!0).build(e)}async function Io(t,e={}){let r=ve.resolve(t),s=$t(r),n=e.packages?s.packages.filter(a=>e.packages?.includes(a.name)||e.packages?.includes(a.relativeRoot)):s.packages,o=new Map(s.packages.map(a=>[a.name,a.root])),i=new le(r,s.type);for(let a of n){let p=e.silent?void 0:h=>{process.stderr.write(`[${a.name}] Processed ${h} files...\r`)},d=await new Ce(r,null,new $(r,{workspaceMap:o,tsconfigSearchPaths:[a.root,r],pathAliases:e.pathAliases}),p,e.gitStats??!1,new Map,e.parallelParsing??!0).build(a.entryPoints);i.addPackage(a,d)}return i}function D(t,e={}){let r=[],s=new Set([...e.ignoreDirs??gt,...e.additionalIgnoreDirs??[]]),n=new Set([...e.extensions??dt,...e.additionalExtensions??[]]);function o(i){try{let a=Al.readdirSync(i,{withFileTypes:!0});for(let p of a){let l=ve.join(i,p.name);p.isDirectory()?s.has(p.name)||o(l):p.isFile()&&n.has(ve.extname(p.name).toLowerCase())&&r.push(ve.relative(t,l))}}catch{}}return o(t),r}var b=m(()=>{"use strict";c();ut();ht();ss();os();bt();vt();Et();Me();De();ae();ls();Ot();Ae();jt();Ut();Le();Bt();B();fe();js();No();ht();dr()});var Mo,Do,Ao=m(()=>{"use strict";c();Mo="mokosh-cache",Do="graph.json"});import ke from"path";import{parseArgs as Rl}from"util";function Ol(t){for(let e=0;e<t.length;e++)if(t[e]==="--root"&&t[e+1])return ke.resolve(t[e+1]);return process.cwd()}function Ll(t){let e=[];for(let r=0;r<t.length;r++){let s=t[r];if(!s.startsWith("--"))e.push(s);else if(Gl.has(s)){let n=t[r+1];n!==void 0&&!n.startsWith("--")&&(e.push(s,n),r++)}else s.slice(2)in xr&&e.push(s)}return e}function Ro(t){let e=Ol(t),r=ke.join(ke.resolve(e,Mo),Do),{values:s,positionals:n}=Rl({args:Ll(t),allowPositionals:!0,options:xr}),o=s["feature-threshold"],i=s["min-out-degree"],a=s.paths,p=s.cache,l=s.config,d=s["changed-symbols"],h=s.depth,x=s["complexity-threshold"],C=s.limit,I=s.metric;return{rootDir:e,cachePath:p?ke.resolve(e,p):r,configPath:l?ke.resolve(e,l):void 0,query:s.query,file:s.file,typeFilter:s.type,functionName:s.function,filterPaths:a?a.split(",").map(R=>R.trim()):void 0,featureThreshold:o?parseInt(o,10):void 0,minOutDegree:i?parseInt(i,10):void 0,mermaid:s.mermaid??!1,proposeTags:s["propose-tags"]??!1,plain:s.plain??!1,affectedTests:s["affected-tests"]??!1,detectFeatures:s["detect-features"]??!1,findUnused:s["find-unused"]??!1,excludeTests:s["exclude-tests"]??!1,checkCycles:s["check-cycles"]??!1,checkDocDrift:s["check-doc-drift"]??!1,findUncovered:s["find-uncovered"]??!1,callers:s.callers??!1,silent:s.silent??!1,queryHelp:s["query-help"]??!1,help:t.length===0||(s.help??!1),typeGraph:s["type-graph"]??!1,moduleResponsibility:s["module-responsibility"]??!1,featureGraph:s["feature-graph"]??!1,callGraph:s["call-graph"]??!1,apiSurface:s["api-surface"]??!1,applyTags:s["apply-tags"]??!1,dryRun:s["dry-run"]??!1,initSkill:s["init-skill"]??!1,initConfig:s["init-config"]??!1,force:s.force??!1,dependencies:s.dependencies??!1,dependents:s.dependents??!1,affected:s.affected??!1,testsOnly:s["tests-only"]??!1,changedSymbols:d?d.split(",").map(R=>R.trim()):void 0,cached:s.cached??!1,depth:h?parseInt(h,10):void 0,withEdgeDetail:s["with-edge-detail"]??!1,findComplexFunctions:s["find-complex-functions"]??!1,metric:I==="complexity"||I==="cognitiveComplexity"?I:void 0,complexityThreshold:x?parseInt(x,10):void 0,limit:C?parseInt(C,10):void 0,workspacePackages:s["workspace-packages"]??!1,workspaceAffected:s["workspace-affected"]??!1,clearCache:s["clear-cache"]??!1,slim:s.slim??!1,watch:s.watch??!1,entryPoints:n}}var xr,Gl,Oo=m(()=>{"use strict";c();Ao();xr={root:{type:"string"},cache:{type:"string"},config:{type:"string"},query:{type:"string"},file:{type:"string"},type:{type:"string"},paths:{type:"string"},function:{type:"string"},"feature-threshold":{type:"string"},"min-out-degree":{type:"string"},mermaid:{type:"boolean"},"propose-tags":{type:"boolean"},plain:{type:"boolean"},"affected-tests":{type:"boolean"},"detect-features":{type:"boolean"},"find-unused":{type:"boolean"},"exclude-tests":{type:"boolean"},"check-cycles":{type:"boolean"},"check-doc-drift":{type:"boolean"},"find-uncovered":{type:"boolean"},callers:{type:"boolean"},silent:{type:"boolean"},"query-help":{type:"boolean"},help:{type:"boolean"},"type-graph":{type:"boolean"},"module-responsibility":{type:"boolean"},"feature-graph":{type:"boolean"},"call-graph":{type:"boolean"},"api-surface":{type:"boolean"},"apply-tags":{type:"boolean"},"dry-run":{type:"boolean"},"init-skill":{type:"boolean"},"init-config":{type:"boolean"},force:{type:"boolean"},dependencies:{type:"boolean"},dependents:{type:"boolean"},affected:{type:"boolean"},"tests-only":{type:"boolean"},"changed-symbols":{type:"string"},cached:{type:"boolean"},depth:{type:"string"},"with-edge-detail":{type:"boolean"},"find-complex-functions":{type:"boolean"},metric:{type:"string"},"complexity-threshold":{type:"string"},limit:{type:"string"},"workspace-packages":{type:"boolean"},"workspace-affected":{type:"boolean"},"clear-cache":{type:"boolean"},slim:{type:"boolean"},watch:{type:"boolean"}},Gl=new Set(Object.entries(xr).filter(([,t])=>t.type==="string").map(([t])=>`--${t}`))});async function Sr(t){let{graph:e,file:r,testsOnly:s,changedSymbols:n,cached:o}=t;if(r||(console.error("Error: --affected requires --file <path>"),process.exit(1)),o){let a=kt(e),p=wt(a,r),l=s?p.filter(d=>e.nodes.get(d)?.category==="test"):p;console.log(JSON.stringify({file:r,affected:l,count:l.length},null,2));return}let i=Tt(e,r,{testsOnly:s,changedSymbols:n});console.log(JSON.stringify({file:r,affected:i,count:i.length},null,2))}var Go=m(()=>{"use strict";c();b()});import br from"path";function U(t){return t.filter(e=>{let r=br.basename(e).toLowerCase();return jl.some(s=>r.includes(s))})}function et(t){return new Ve().getChangedFiles().map(e=>br.relative(t,br.resolve(t,e)))}var jl,tt=m(()=>{"use strict";c();rr();jl=[".test.",".spec.","-test.","-spec."]});async function Lo(t){let{graph:e}=t,{rootDir:r,scanOptions:s,featureThreshold:n,rawConfig:o}=t,i=et(r);if(![...e.nodes.values()].some(l=>U([l.path]).length>0)){let l=D(r,s);e=await M(r,U(l),e,k(o))}let p=yr(e,i,{...n!==void 0&&{featureDetection:{minOutDegree:n}}});console.log(p.join(`
30
- `))}var jo=m(()=>{"use strict";c();b();tt()});async function _o(t){let{graph:e,rootDir:r,entryPoints:s}=t,n=s.length?s:xt(e,r);n.length===0&&(console.error("Error: No entry points found. Pass entry points as positional args or ensure package.json has a main/exports field."),process.exit(1));let o=St(e,n);console.log(JSON.stringify(o,null,2))}var Wo=m(()=>{"use strict";c();b()});async function zo(t){let{graph:e}=t,{rootDir:r,scanOptions:s,dryRun:n,plain:o,rawConfig:i}=t;if(o||console.log(n?"Dry run: computing tag changes...":"Applying tags to test files..."),e.nodes.size===0){let p=D(r,s);e=await M(r,U(p),e,k(i))}let a=await Zt(e,r,{dryRun:n});console.log(JSON.stringify(a,null,2))}var $o=m(()=>{"use strict";c();b();tt()});async function Uo(t){let{graph:e,functionName:r}=t;r||(console.error("Error: --call-graph requires --function <name>"),process.exit(1));let s=Ct(e,r);console.log(JSON.stringify(s,null,2))}var Bo=m(()=>{"use strict";c();b()});async function Cr(t){let{graph:e,file:r,plain:s,depth:n,withEdgeDetail:o}=t;r||(console.error("Error: --callers requires --file <path>"),process.exit(1));let i=Nt(e,r,{depth:n??1,withEdgeDetail:o});console.log(s?i.map(a=>a.file).join(`
31
- `):JSON.stringify({file:r,callers:i,count:i.length},null,2))}var Jo=m(()=>{"use strict";c();b()});async function vr(t){let{graph:e}=t,r=e.findCycles();if(r.length>0){process.stderr.write(`Found ${r.length} cycle(s):
29
+ `),null}}parseContent(e,r){return this.pool?this.pool.run({filePath:e,content:r}):Bn(e,r)}makeStubNode(e,r,s){return{path:r,type:R(e),category:"other",imports:[],exports:[],tags:[],mtime:s.mtimeMs,size:s.size}}resolveCallEdges(e,r){let s=[];for(let n of r??[])try{let o=this.resolver.resolve(e,n.toSpecifier);o&&!o.isExternal&&s.push({from:n.from,to:n.to,toFile:F.relative(this.rootDir,o.path)})}catch{}return s}buildNode(e,r,s,n,o){let{imports:i,exports:a,tags:l,category:p,description:h,complexity:d,cognitiveComplexity:S,functions:v}=n;return{path:r,type:R(e),category:p,imports:i,exports:a,tags:l,mtime:s.mtimeMs,size:s.size,...h!==void 0?{description:h}:{},...o.length>0?{callEdges:o}:{},...d!==void 0?{complexity:d}:{},...S!==void 0?{cognitiveComplexity:S}:{},...v!==void 0?{functions:v}:{}}}attachGitStats(e,r){let s=this.gitStatsMap?.get(r);s&&(e.commitCount90d=s.commitCount90d,s.lastAuthor!==void 0&&(e.lastAuthor=s.lastAuthor),s.lastCommitAt!==void 0&&(e.lastCommitAt=s.lastCommitAt))}async resolveImports(e,r){let s=[];for(let n of r){let o=this.resolver.resolveAll(e,n.rawSpecifier);if(o.length!==0)for(let i of o){let a={...n,toPath:i.isExternal?i.path:F.relative(this.rootDir,i.path),isExternal:i.isExternal};i.isWorkspace&&(a.isWorkspace=!0,a.workspacePackage=i.workspacePackage),i.isExternal?this.attachLockfileVersion(a):this.enqueue(i.path),s.push(a)}}return s}attachLockfileVersion(e){if(!this.lockFile)return;let r=e.rawSpecifier.startsWith("@")?e.rawSpecifier.split("/").slice(0,2).join("/"):e.rawSpecifier.split("/")[0],s=r?this.lockFile.dependencies[r]:void 0;s&&(e.version=s.version)}showProgress(){this.progressCallback&&this.visited.size%100===0&&this.progressCallback(this.visited.size)}}});var go=m(()=>{"use strict";c();St();uo();Ct();Et();Me();Ae();ie();hr();Gt();Oe();Wt();Jt();Kt()});var yr=m(()=>{"use strict";c();go()});function ho(t,e){return{identifier:e?.identifier??new Xe,featureMap:e?.featureDetection===!1?new Map:j(t.nodes,e?.featureDetection??void 0)}}function yo(t,e,r,s,n){for(let o of e){let i=t.nodes.get(o);if(!i)continue;let a=new _(o,["*",...i.exports.map(l=>l.name)]);t.traverse(o,(l,p,h)=>{if(!h)return!0;if(!a.updateAffectedSymbols(l,h))return!1;if(p>0){let d=r.get(l.path);if(d)return s(d),!1}return n(l),!0},{direction:"incoming"})}}function xr(t,e,r){let{identifier:s,featureMap:n}=ho(t,r),o=new Set;for(let i of e){let a=n.get(i);a&&o.add(a.tag)}return yo(t,e,n,i=>o.add(i.tag),i=>{if(s.isTestNode(i))for(let a of i.tags)o.add(a.name)}),Array.from(o)}function Sr(t,e,r){let{identifier:s,featureMap:n}=ho(t,r),o=new Set;return yo(t,e,n,()=>{},i=>{s.isTestNode(i)&&o.add(i.path)}),Array.from(o)}var xo=m(()=>{"use strict";c();yr();rr()});var So=m(()=>{"use strict";c();Xs();rr();xo()});import ap from"fs";import ve from"path";async function I(t,e,r=null,s={}){let n=s.silent?void 0:a=>{process.stderr.write(`Processed ${a} files...\r`)},o=ve.resolve(t);return await new Ce(o,r,s.pathAliases?new z(o,{pathAliases:s.pathAliases}):void 0,n,s.gitStats??!1,s.coverageMap??new Map,s.parallelParsing??!0).build(e)}async function bo(t,e={}){let r=ve.resolve(t),s=Bt(r),n=e.packages?s.packages.filter(a=>e.packages?.includes(a.name)||e.packages?.includes(a.relativeRoot)):s.packages,o=new Map(s.packages.map(a=>[a.name,a.root])),i=new pe(r,s.type);for(let a of n){let l=e.silent?void 0:d=>{process.stderr.write(`[${a.name}] Processed ${d} files...\r`)},h=await new Ce(r,null,new z(r,{workspaceMap:o,tsconfigSearchPaths:[a.root,r],pathAliases:e.pathAliases}),l,e.gitStats??!1,new Map,e.parallelParsing??!0).build(a.entryPoints);i.addPackage(a,h)}return i}function M(t,e={}){let r=[],s=new Set([...e.ignoreDirs??ut,...e.additionalIgnoreDirs??[]]),n=new Set([...e.extensions??gt,...e.additionalExtensions??[]]);function o(i){try{let a=ap.readdirSync(i,{withFileTypes:!0});for(let l of a){let p=ve.join(i,l.name);l.isDirectory()?s.has(l.name)||o(p):l.isFile()&&n.has(ve.extname(l.name).toLowerCase())&&r.push(ve.relative(t,p))}}catch{}}return o(t),r}var b=m(()=>{"use strict";c();mt();dt();Kr();Qr();St();Ct();Et();Me();Ae();Ft();ie();Rt();Gt();rs();Oe();Wt();Jt();_e();Kt();U();fe();Ts();So();dt();yr()});var Co,vo,ko=m(()=>{"use strict";c();Co="mokosh-cache",vo="graph.json"});import Ee from"path";import{parseArgs as cp}from"util";function lp(t){for(let e=0;e<t.length;e++)if(t[e]==="--root"&&t[e+1])return Ee.resolve(t[e+1]);return process.cwd()}function ke(t){return t?parseInt(t,10):void 0}function Eo(t){return t?t.split(",").map(e=>e.trim()):void 0}function fp(t){let e=[];for(let r=0;r<t.length;r++){let s=t[r];if(!s.startsWith("--"))e.push(s);else if(pp.has(s)){let n=t[r+1];n!==void 0&&!n.startsWith("--")&&(e.push(s,n),r++)}else s.slice(2)in br&&e.push(s)}return e}function wo(t){let e=lp(t),r=Ee.join(Ee.resolve(e,Co),vo),{values:s,positionals:n}=cp({args:fp(t),allowPositionals:!0,options:br}),o=s.cache,i=s.config,a=s.metric;return{rootDir:e,cachePath:o?Ee.resolve(e,o):r,configPath:i?Ee.resolve(e,i):void 0,query:s.query,file:s.file,typeFilter:s.type,functionName:s.function,filterPaths:Eo(s.paths),featureThreshold:ke(s["feature-threshold"]),minOutDegree:ke(s["min-out-degree"]),mermaid:s.mermaid??!1,proposeTags:s["propose-tags"]??!1,plain:s.plain??!1,affectedTests:s["affected-tests"]??!1,detectFeatures:s["detect-features"]??!1,findUnused:s["find-unused"]??!1,excludeTests:s["exclude-tests"]??!1,checkCycles:s["check-cycles"]??!1,checkDocDrift:s["check-doc-drift"]??!1,findUncovered:s["find-uncovered"]??!1,callers:s.callers??!1,silent:s.silent??!1,queryHelp:s["query-help"]??!1,help:t.length===0||(s.help??!1),typeGraph:s["type-graph"]??!1,moduleResponsibility:s["module-responsibility"]??!1,featureGraph:s["feature-graph"]??!1,callGraph:s["call-graph"]??!1,findSymbol:s["find-symbol"]??!1,apiSurface:s["api-surface"]??!1,applyTags:s["apply-tags"]??!1,dryRun:s["dry-run"]??!1,initSkill:s["init-skill"]??!1,initConfig:s["init-config"]??!1,force:s.force??!1,dependencies:s.dependencies??!1,dependents:s.dependents??!1,affected:s.affected??!1,testsOnly:s["tests-only"]??!1,changedSymbols:Eo(s["changed-symbols"]),cached:s.cached??!1,depth:ke(s.depth),withMeta:s["with-meta"]??!1,withEdgeDetail:s["with-edge-detail"]??!1,findComplexFunctions:s["find-complex-functions"]??!1,metric:a==="complexity"||a==="cognitiveComplexity"?a:void 0,complexityThreshold:ke(s["complexity-threshold"]),limit:ke(s.limit),workspacePackages:s["workspace-packages"]??!1,workspaceAffected:s["workspace-affected"]??!1,clearCache:s["clear-cache"]??!1,slim:s.slim??!1,watch:s.watch??!1,entryPoints:n}}var br,pp,Fo=m(()=>{"use strict";c();ko();br={root:{type:"string"},cache:{type:"string"},config:{type:"string"},query:{type:"string"},file:{type:"string"},type:{type:"string"},paths:{type:"string"},function:{type:"string"},"feature-threshold":{type:"string"},"min-out-degree":{type:"string"},mermaid:{type:"boolean"},"propose-tags":{type:"boolean"},plain:{type:"boolean"},"affected-tests":{type:"boolean"},"detect-features":{type:"boolean"},"find-unused":{type:"boolean"},"exclude-tests":{type:"boolean"},"check-cycles":{type:"boolean"},"check-doc-drift":{type:"boolean"},"find-uncovered":{type:"boolean"},callers:{type:"boolean"},silent:{type:"boolean"},"query-help":{type:"boolean"},help:{type:"boolean"},"type-graph":{type:"boolean"},"module-responsibility":{type:"boolean"},"feature-graph":{type:"boolean"},"call-graph":{type:"boolean"},"find-symbol":{type:"boolean"},"api-surface":{type:"boolean"},"apply-tags":{type:"boolean"},"dry-run":{type:"boolean"},"init-skill":{type:"boolean"},"init-config":{type:"boolean"},force:{type:"boolean"},dependencies:{type:"boolean"},dependents:{type:"boolean"},affected:{type:"boolean"},"tests-only":{type:"boolean"},"changed-symbols":{type:"string"},cached:{type:"boolean"},depth:{type:"string"},"with-meta":{type:"boolean"},"with-edge-detail":{type:"boolean"},"find-complex-functions":{type:"boolean"},metric:{type:"string"},"complexity-threshold":{type:"string"},limit:{type:"string"},"workspace-packages":{type:"boolean"},"workspace-affected":{type:"boolean"},"clear-cache":{type:"boolean"},slim:{type:"boolean"},watch:{type:"boolean"}},pp=new Set(Object.entries(br).filter(([,t])=>t.type==="string").map(([t])=>`--${t}`))});async function Cr(t){let{graph:e,file:r,testsOnly:s,changedSymbols:n,cached:o,withMeta:i}=t;r||(console.error("Error: --affected requires --file <path>"),process.exit(1));let a=h=>i?h.map(d=>({path:d,...W(e,d)})):h;if(o){let h=vt(e),d=kt(h,r),S=s?d.filter(L=>e.nodes.get(L)?.category==="test"):d,v=a(S);console.log(JSON.stringify({file:r,affected:v,count:v.length},null,2));return}let l=Tt(e,r,{testsOnly:s,changedSymbols:n}),p=a(l);console.log(JSON.stringify({file:r,affected:p,count:p.length},null,2))}var Po=m(()=>{"use strict";c();b()});import vr from"path";function $(t){return t.filter(e=>{let r=vr.basename(e).toLowerCase();return mp.some(s=>r.includes(s))})}function rt(t){return new Ye().getChangedFiles().map(e=>vr.relative(t,vr.resolve(t,e)))}var mp,st=m(()=>{"use strict";c();nr();mp=[".test.",".spec.","-test.","-spec."]});async function To(t){let{graph:e}=t,{rootDir:r,scanOptions:s,featureThreshold:n,rawConfig:o}=t,i=rt(r);if(![...e.nodes.values()].some(p=>$([p.path]).length>0)){let p=M(r,s);e=await I(r,$(p),e,k(o))}let l=Sr(e,i,{...n!==void 0&&{featureDetection:{minOutDegree:n}}});console.log(l.join(`
30
+ `))}var No=m(()=>{"use strict";c();b();st()});async function Io(t){let{graph:e,rootDir:r,entryPoints:s}=t,n=s.length?s:yt(e,r);n.length===0&&(console.error("Error: No entry points found. Pass entry points as positional args or ensure package.json has a main/exports field."),process.exit(1));let o=xt(e,n);console.log(JSON.stringify(o,null,2))}var Mo=m(()=>{"use strict";c();b()});async function Ao(t){let{graph:e}=t,{rootDir:r,scanOptions:s,dryRun:n,plain:o,rawConfig:i}=t;if(o||console.log(n?"Dry run: computing tag changes...":"Applying tags to test files..."),e.nodes.size===0){let l=M(r,s);e=await I(r,$(l),e,k(i))}let a=await tr(e,r,{dryRun:n});console.log(JSON.stringify(a,null,2))}var Do=m(()=>{"use strict";c();b();st()});async function Ro(t){let{graph:e,functionName:r}=t;r||(console.error("Error: --call-graph requires --function <name>"),process.exit(1));let s=bt(e,r);console.log(JSON.stringify(s,null,2))}var Oo=m(()=>{"use strict";c();b()});async function kr(t){let{graph:e,file:r,plain:s,depth:n,withEdgeDetail:o}=t;r||(console.error("Error: --callers requires --file <path>"),process.exit(1));let i=Nt(e,r,{depth:n??1,withEdgeDetail:o});console.log(s?i.map(a=>a.file).join(`
31
+ `):JSON.stringify({file:r,callers:i,count:i.length},null,2))}var Go=m(()=>{"use strict";c();b()});async function Er(t){let{graph:e}=t,r=e.findCycles();if(r.length>0){process.stderr.write(`Found ${r.length} cycle(s):
32
32
  `);for(let s of r)process.stderr.write(` ${s.join(" \u2192 ")}
33
- `);process.exit(1)}console.log("No cycles detected.")}var Ko=m(()=>{"use strict";c()});async function kr(t){let{graph:e}=t,r=[...e.nodes.values()].filter(s=>s.type==="markdown"&&s.staleFor&&s.staleFor.length>0).map(s=>({doc:s.path,staleFor:s.staleFor}));if(r.length>0){process.stderr.write(`Found ${r.length} doc(s) that may be out of date:
33
+ `);process.exit(1)}console.log("No cycles detected.")}var Lo=m(()=>{"use strict";c()});async function wr(t){let{graph:e}=t,r=[...e.nodes.values()].filter(s=>s.type==="markdown"&&s.staleFor&&s.staleFor.length>0).map(s=>({doc:s.path,staleFor:s.staleFor}));if(r.length>0){process.stderr.write(`Found ${r.length} doc(s) that may be out of date:
34
34
  `);for(let{doc:s,staleFor:n}of r)process.stderr.write(` ${s} \u2014 references changed more recently: ${n.join(", ")}
35
- `);process.exit(1)}console.log("No doc drift detected.")}var Ho=m(()=>{"use strict";c()});import Qo from"fs";function Vo(t){Qo.existsSync(t)?(Qo.unlinkSync(t),console.log(`Cache cleared: ${t}`)):console.log(`No cache file present at ${t}`)}var Xo=m(()=>{"use strict";c()});async function wr(t){let{graph:e,file:r,depth:s}=t;r||(console.error("Error: --dependencies requires --file <path>"),process.exit(1));let n=Ft(e,r,s??1);console.log(JSON.stringify({file:r,dependencies:n},null,2))}var qo=m(()=>{"use strict";c();b()});async function Er(t){let{graph:e,file:r}=t;r||(console.error("Error: --dependents requires --file <path>"),process.exit(1));let s=Pt(e,r);console.log(JSON.stringify({file:r,dependents:s},null,2))}var Yo=m(()=>{"use strict";c();b()});async function Zo(t){let{graph:e}=t,{rootDir:r,scanOptions:s,featureThreshold:n,rawConfig:o}=t;if(e.nodes.size===0){let p=D(r,s);e=await M(r,p,e,k(o))}let i=W(e.nodes,n!==void 0?{minOutDegree:n}:void 0),a=Array.from(i.values()).sort((p,l)=>l.outDegree-p.outDegree);console.log(JSON.stringify({features:a},null,2))}var ei=m(()=>{"use strict";c();b()});async function ti(t){let{graph:e}=t,{rootDir:r,scanOptions:s,minOutDegree:n,rawConfig:o}=t;if(e.nodes.size===0){let p=D(r,s);e=await M(r,p,e,k(o))}let i=oe(e,n!==void 0?{minOutDegree:n}:void 0),a=Object.fromEntries(i.features);console.log(JSON.stringify({features:a,unassigned:i.unassigned},null,2))}var ri=m(()=>{"use strict";c();b()});async function Fr(t){let{graph:e,metric:r,complexityThreshold:s,limit:n}=t,o=s??10,i=It(e,{metric:r,threshold:o,limit:n});console.log(JSON.stringify({metric:r??"cognitiveComplexity",threshold:o,functions:i,count:i.length},null,2))}var si=m(()=>{"use strict";c();b()});async function Pr(t){let{graph:e,featureThreshold:r,rawConfig:s,plain:n}=t,o=r??s.coverageThreshold??80;if(!At(e)){console.log(JSON.stringify({error:"No coverage data available. Set coverageReportPath in mokosh.config and rebuild the graph."},null,2));return}let i=[...e.nodes.values()].filter(a=>a.category!=="test"&&a.category!=="config").filter(a=>a.coveragePct!==void 0&&a.coveragePct<o).map(a=>({file:a.path,coveragePct:a.coveragePct}));console.log(n?i.map(a=>a.file).join(`
36
- `):JSON.stringify({threshold:o,uncovered:i,count:i.length},null,2))}var ni=m(()=>{"use strict";c();b()});import _l from"path";function zl(t){let e=_l.basename(t).toLowerCase();return Wl.some(r=>e.includes(r))}async function oi(t){let{graph:e,rootDir:r,scanOptions:s,excludeTests:n}=t,o=D(r,s),i=e.findUnusedFiles(o);n&&(i=i.filter(a=>!zl(a))),console.log(JSON.stringify({unusedFiles:i},null,2))}var Wl,ii=m(()=>{"use strict";c();b();Wl=[".test.",".spec.","-test.","-spec.",".stories."]});async function Tr(t){let{graph:e,queryStr:r,mermaidOutput:s,slim:n}=t,o=e.serialize();if(r){let a=_e(r);o=je(o,a)}if(s){let a=P.deserialize(o);console.log(Ne.serialize(a));return}let i=e.findCycles();i.length>0&&(o.cycles=i),console.log(JSON.stringify(n?Mt(o):o,null,2))}var ai=m(()=>{"use strict";c();b()});import $l from"fs";import Nr from"path";function rt(t,e,r){let s=t;for(let n=0;n<6;n++){let o=Nr.join(s,"templates",...e);if($l.existsSync(Nr.join(o,r)))return o;let i=Nr.dirname(s);if(i===s)break;s=i}throw new Error(`Could not locate mokosh templates/${e.join("/")}`)}var Ir=m(()=>{"use strict";c()});import ci from"fs";import pi from"path";function li(t,e=process.cwd()){let r=rt(f,["config"],"mokosh.config.js"),s=pi.join(r,"mokosh.config.js"),n=pi.join(e,"mokosh.config.js");if(ci.existsSync(n)&&!t){console.log("skipped mokosh.config.js (already exists, use --force to overwrite)");return}ci.copyFileSync(s,n),console.log("wrote mokosh.config.js")}var fi=m(()=>{"use strict";c();Ir()});import Mr from"fs";import st from"path";function mi(t,e=process.cwd()){let r=rt(f,["skill"],"SKILL.md");for(let s of Ul){let n=st.join(r,s.templateFile),o=st.join(e,...s.destPath),i=st.join(...s.destPath);if(Mr.existsSync(o)&&!t){console.log(`skipped ${i} (already exists, use --force to overwrite)`);continue}Mr.mkdirSync(st.dirname(o),{recursive:!0}),Mr.copyFileSync(n,o),console.log(`wrote ${i}`)}}var Ul,ui=m(()=>{"use strict";c();Ir();Ul=[{templateFile:"SKILL.md",destPath:[".claude","skills","mokosh","SKILL.md"]},{templateFile:"mokosh.md",destPath:[".claude","commands","mokosh.md"]}]});async function gi(t){let{graph:e,filterPaths:r,minOutDegree:s}=t,n=Rt(e,s!==void 0?{minOutDegree:s}:void 0);if(r?.length){let o=r.map(i=>n.get(i)).filter(Boolean);console.log(JSON.stringify({count:o.length,modules:o},null,2))}else{let o=Array.from(n.values());console.log(JSON.stringify({count:o.length,modules:o},null,2))}}var di=m(()=>{"use strict";c();b()});async function hi(t){let{graph:e}=t,{rootDir:r,scanOptions:s,featureThreshold:n,plain:o,rawConfig:i}=t;o||console.log("Proposing test tags based on git diff...");let a=et(r);if(e.nodes.size===0){let l=D(r,s);e=await M(r,U(l),e,k(i))}let p=hr(e,a,{...n!==void 0&&{featureDetection:{minOutDegree:n}}});console.log(o?p.join(" "):JSON.stringify({proposedTags:p},null,2))}var yi=m(()=>{"use strict";c();b();tt()});async function xi(t){let{graph:e,typeFilter:r}=t,s=Gt(e);if(r){let n=Lt(s,r);console.log(JSON.stringify(n,null,2))}else{let n=Array.from(s.types.values());console.log(JSON.stringify({count:n.length,types:n},null,2))}}var Si=m(()=>{"use strict";c();b()});function bi(t,e){let r=t.getAffectedAcrossPackages(e);console.log(JSON.stringify({file:e,affected:r,count:r.length},null,2))}var Ci=m(()=>{"use strict";c()});function vi(t){console.log(JSON.stringify(Dt(t),null,2))}var ki=m(()=>{"use strict";c();b()});import Dr from"path";function wi(t){let{rootDir:e,entryPoints:r,cachePath:s,configPath:n}=t,o=n?J(n,{isExplicitPath:!0}):J(e),i=Dr.join(Dr.resolve(e,"mokosh-cache"),"graph.json"),a=r.length>0?r:o.entryPoints??[],p=s!==i?s??i:o.cachePath?Dr.resolve(e,o.cachePath):s??i,l={...o.ignoreDirs!==void 0&&{additionalIgnoreDirs:o.ignoreDirs},...o.extensions!==void 0&&{additionalExtensions:o.extensions}};return{rootDir:e,resolvedEntryPoints:a,resolvedCachePath:p,scanOptions:l,rawConfig:o}}var Ei=m(()=>{"use strict";c();b()});import we from"fs";import Bl from"path";function Fi(t){if(!we.existsSync(t))return null;let e=we.readFileSync(t,"utf-8");return P.deserialize(JSON.parse(e))}function Ar(t,e){let r=Bl.dirname(e);we.existsSync(r)||we.mkdirSync(r,{recursive:!0}),we.writeFileSync(e,JSON.stringify(t.serialize(),null,2))}async function Rr(t,e,r,s={silent:!1,...k(void 0)}){return M(t,e,r,s)}var Pi=m(()=>{"use strict";c();b()});var Ti,Ni,Ii=m(()=>{"use strict";c();Ti=`
35
+ `);process.exit(1)}console.log("No doc drift detected.")}var jo=m(()=>{"use strict";c()});import _o from"fs";function Wo(t){_o.existsSync(t)?(_o.unlinkSync(t),console.log(`Cache cleared: ${t}`)):console.log(`No cache file present at ${t}`)}var zo=m(()=>{"use strict";c()});async function Fr(t){let{graph:e,file:r,depth:s,withMeta:n}=t;r||(console.error("Error: --dependencies requires --file <path>"),process.exit(1));let o=Pt(e,r,s??1),i=n?o.map(a=>({...a,...W(e,a.path)})):o;console.log(JSON.stringify({file:r,dependencies:i},null,2))}var $o=m(()=>{"use strict";c();b()});async function Pr(t){let{graph:e,file:r,withMeta:s}=t;r||(console.error("Error: --dependents requires --file <path>"),process.exit(1));let n=ae(e,r),o=s?n.map(i=>({...i,...W(e,i.path)})):n;console.log(JSON.stringify({file:r,dependents:o},null,2))}var Uo=m(()=>{"use strict";c();b()});async function Bo(t){let{graph:e}=t,{rootDir:r,scanOptions:s,featureThreshold:n,rawConfig:o}=t;if(e.nodes.size===0){let l=M(r,s);e=await I(r,l,e,k(o))}let i=j(e.nodes,n!==void 0?{minOutDegree:n}:void 0),a=Array.from(i.values()).sort((l,p)=>p.outDegree-l.outDegree);console.log(JSON.stringify({features:a},null,2))}var Jo=m(()=>{"use strict";c();b()});async function Ko(t){let{graph:e}=t,{rootDir:r,scanOptions:s,minOutDegree:n,rawConfig:o}=t;if(e.nodes.size===0){let l=M(r,s);e=await I(r,l,e,k(o))}let i=ne(e,n!==void 0?{minOutDegree:n}:void 0),a=Object.fromEntries(i.features);console.log(JSON.stringify({features:a,unassigned:i.unassigned},null,2))}var Ho=m(()=>{"use strict";c();b()});async function Tr(t){let{graph:e,metric:r,complexityThreshold:s,limit:n}=t,o=s??10,i=It(e,{metric:r,threshold:o,limit:n});console.log(JSON.stringify({metric:r??"cognitiveComplexity",threshold:o,functions:i,count:i.length},null,2))}var Qo=m(()=>{"use strict";c();b()});async function Vo(t){let{graph:e,functionName:r,plain:s}=t;r||(console.error("Error: --find-symbol requires --function <name>"),process.exit(1));let n=Lt(e,r);console.log(s?n.map(o=>o.path).join(`
36
+ `):JSON.stringify({name:r,matches:n,count:n.length},null,2))}var Xo=m(()=>{"use strict";c();b()});async function Nr(t){let{graph:e,featureThreshold:r,rawConfig:s,plain:n}=t,o=r??s.coverageThreshold??80;if(!Dt(e)){console.log(JSON.stringify({error:"No coverage data available. Set coverageReportPath in mokosh.config and rebuild the graph."},null,2));return}let i=[...e.nodes.values()].filter(a=>a.category!=="test"&&a.category!=="config").filter(a=>a.coveragePct!==void 0&&a.coveragePct<o).map(a=>({file:a.path,coveragePct:a.coveragePct}));console.log(n?i.map(a=>a.file).join(`
37
+ `):JSON.stringify({threshold:o,uncovered:i,count:i.length},null,2))}var Yo=m(()=>{"use strict";c();b()});import up from"path";function dp(t){let e=up.basename(t).toLowerCase();return gp.some(r=>e.includes(r))}async function qo(t){let{graph:e,rootDir:r,scanOptions:s,excludeTests:n}=t,o=M(r,s),i=e.findUnusedFiles(o);n&&(i=i.filter(a=>!dp(a))),console.log(JSON.stringify({unusedFiles:i},null,2))}var gp,Zo=m(()=>{"use strict";c();b();gp=[".test.",".spec.","-test.","-spec.",".stories."]});async function Ir(t){let{graph:e,queryStr:r,mermaidOutput:s,slim:n}=t,o=e.serialize();if(r){let l=ze(r);o=We(o,l)}if(s){let l=P.deserialize(o);console.log(Ne.serialize(l));return}let i=e.findCycles();i.length>0&&(o.cycles=i);let a=wt(e);console.log(JSON.stringify(n?{...Mt(o),languageCoverage:a}:{...o,languageCoverage:a},null,2))}var ei=m(()=>{"use strict";c();b()});import hp from"fs";import Mr from"path";function nt(t,e,r){let s=t;for(let n=0;n<6;n++){let o=Mr.join(s,"templates",...e);if(hp.existsSync(Mr.join(o,r)))return o;let i=Mr.dirname(s);if(i===s)break;s=i}throw new Error(`Could not locate mokosh templates/${e.join("/")}`)}var Ar=m(()=>{"use strict";c()});import ti from"fs";import ri from"path";function si(t,e=process.cwd()){let r=nt(f,["config"],"mokosh.config.js"),s=ri.join(r,"mokosh.config.js"),n=ri.join(e,"mokosh.config.js");if(ti.existsSync(n)&&!t){console.log("skipped mokosh.config.js (already exists, use --force to overwrite)");return}ti.copyFileSync(s,n),console.log("wrote mokosh.config.js")}var ni=m(()=>{"use strict";c();Ar()});import Dr from"fs";import ot from"path";function oi(t,e=process.cwd()){let r=nt(f,["skill"],"SKILL.md");for(let s of yp){let n=ot.join(r,s.templateFile),o=ot.join(e,...s.destPath),i=ot.join(...s.destPath);if(Dr.existsSync(o)&&!t){console.log(`skipped ${i} (already exists, use --force to overwrite)`);continue}Dr.mkdirSync(ot.dirname(o),{recursive:!0}),Dr.copyFileSync(n,o),console.log(`wrote ${i}`)}}var yp,ii=m(()=>{"use strict";c();Ar();yp=[{templateFile:"SKILL.md",destPath:[".claude","skills","mokosh","SKILL.md"]},{templateFile:"mokosh.md",destPath:[".claude","commands","mokosh.md"]}]});async function ai(t){let{graph:e,filterPaths:r,minOutDegree:s}=t,n=Ot(e,s!==void 0?{minOutDegree:s}:void 0);if(r?.length){let o=r.map(i=>n.get(i)).filter(Boolean);console.log(JSON.stringify({count:o.length,modules:o},null,2))}else{let o=Array.from(n.values());console.log(JSON.stringify({count:o.length,modules:o},null,2))}}var ci=m(()=>{"use strict";c();b()});async function li(t){let{graph:e}=t,{rootDir:r,scanOptions:s,featureThreshold:n,plain:o,rawConfig:i}=t;o||console.log("Proposing test tags based on git diff...");let a=rt(r);if(e.nodes.size===0){let p=M(r,s);e=await I(r,$(p),e,k(i))}let l=xr(e,a,{...n!==void 0&&{featureDetection:{minOutDegree:n}}});console.log(o?l.join(" "):JSON.stringify({proposedTags:l},null,2))}var pi=m(()=>{"use strict";c();b();st()});async function fi(t){let{graph:e,typeFilter:r}=t,s=jt(e);if(r){let n=_t(s,r);console.log(JSON.stringify(n,null,2))}else{let n=Array.from(s.types.values());console.log(JSON.stringify({count:n.length,types:n},null,2))}}var mi=m(()=>{"use strict";c();b()});function ui(t,e){let r=t.getAffectedAcrossPackages(e);console.log(JSON.stringify({file:e,affected:r,count:r.length},null,2))}var gi=m(()=>{"use strict";c()});function di(t){console.log(JSON.stringify(At(t),null,2))}var hi=m(()=>{"use strict";c();b()});import Rr from"path";function yi(t){let{rootDir:e,entryPoints:r,cachePath:s,configPath:n}=t,o=n?B(n,{isExplicitPath:!0}):B(e),i=Rr.join(Rr.resolve(e,"mokosh-cache"),"graph.json"),a=r.length>0?r:o.entryPoints??[],l=s!==i?s??i:o.cachePath?Rr.resolve(e,o.cachePath):s??i,p={...o.ignoreDirs!==void 0&&{additionalIgnoreDirs:o.ignoreDirs},...o.extensions!==void 0&&{additionalExtensions:o.extensions}};return{rootDir:e,resolvedEntryPoints:a,resolvedCachePath:l,scanOptions:p,rawConfig:o}}var xi=m(()=>{"use strict";c();b()});import we from"fs";import xp from"path";function Si(t){if(!we.existsSync(t))return null;let e=we.readFileSync(t,"utf-8");return P.deserialize(JSON.parse(e))}function Or(t,e){let r=xp.dirname(e);we.existsSync(r)||we.mkdirSync(r,{recursive:!0}),we.writeFileSync(e,JSON.stringify(t.serialize(),null,2))}async function Gr(t,e,r,s={silent:!1,...k(void 0)}){return I(t,e,r,s)}var bi=m(()=>{"use strict";c();b()});var Ci,vi,ki=m(()=>{"use strict";c();Ci=`
37
38
  Usage: mokosh [options] <entry-point1> <entry-point2> ...
38
39
 
39
40
  Options:
@@ -86,6 +87,7 @@ MCP parity (mirrors the MCP server's tools for use when MCP is unavailable):
86
87
  --tests-only Restrict --affected to test/spec files
87
88
  --changed-symbols <a,b,...> Restrict --affected to files that import these specific symbols
88
89
  --cached Use a precomputed impact cache for --affected instead of a fresh traversal
90
+ --with-meta Add category/exports per result for --dependencies/--dependents/--affected
89
91
  --with-edge-detail Include from/to function names per edge (use with --callers)
90
92
  --find-complex-functions List functions/methods at or above a complexity threshold, worst-first
91
93
  --metric <name> cognitiveComplexity (default) | complexity \u2014 used by --find-complex-functions
@@ -93,6 +95,9 @@ MCP parity (mirrors the MCP server's tools for use when MCP is unavailable):
93
95
  --limit <N> Max results for --find-complex-functions (default: 20)
94
96
  --workspace-packages List monorepo packages and their cross-package dependencies
95
97
  --workspace-affected Cross-package blast-radius for --file in a monorepo
98
+ --find-symbol Find every file that exports --function <name> by exact name, with
99
+ the best available caller/importer info per match (call-edge
100
+ precision for TS/JS, named-import for Python, file-level otherwise)
96
101
  --watch Re-run on file changes. Supported with the default output, --query,
97
102
  --callers, --dependencies, --dependents, --affected, --find-uncovered,
98
103
  --find-complex-functions, --check-cycles, and --check-doc-drift only.
@@ -106,7 +111,7 @@ Notes:
106
111
  server only loads JSON config (allowJs: false) for security. This is intentional.
107
112
  --workspace-packages/--workspace-affected require explicit opt-in (unlike MCP's analyze tool,
108
113
  which auto-detects a monorepo when entryPoints is empty); other commands remain single-package.
109
- `,Ni=`
114
+ `,vi=`
110
115
  Query filter reference (--query "key:value,key:value,...")
111
116
  All keys are case-insensitive. Multiple keys are AND'd together.
112
117
 
@@ -229,5 +234,5 @@ COMMON PATTERNS
229
234
 
230
235
  Large TypeScript logic files:
231
236
  --query "type:typescript,category:logic,sort:size,limit:5"
232
- `});var Mi,Di=m(()=>{"use strict";c();Mi=/(?:^|[/\\])(?:node_modules|\.git|dist|build|coverage)(?:[/\\]|$)/});import Jl from"fs";function Ai(t,e,r){let s=null,n=!1,o=!1,i=async()=>{if(n){o=!0;return}n=!0;try{await r()}finally{n=!1,o&&(o=!1,i())}};i();let a=null;try{a=Jl.watch(t,{recursive:!0},(p,l)=>{!l||Mi.test(l)||(s&&clearTimeout(s),s=setTimeout(()=>{i()},e))})}catch(p){console.error(`Warning: unable to watch ${t}: ${p.message}`)}process.on("SIGINT",()=>{s&&clearTimeout(s),a?.close(),process.exit(0)})}var Ri=m(()=>{"use strict";c();Di()});async function Oi(){let t=process.argv.slice(2),e=Ro(t);e.help&&(console.log(Ti),process.exit(0)),e.queryHelp&&(console.log(Ni),process.exit(0)),e.initSkill&&(mi(e.force),process.exit(0)),e.initConfig&&(li(e.force),process.exit(0)),e.clearCache&&(Vo(e.cachePath),process.exit(0));let r=wi(e);mt(r.rawConfig);let{rootDir:s,resolvedEntryPoints:n,resolvedCachePath:o,scanOptions:i}=r,{proposeTags:a,plain:p,affectedTests:l,detectFeatures:d,findUnused:h,findUncovered:x,excludeTests:C,checkCycles:I,checkDocDrift:R,callers:Or,dependencies:Gr,dependents:Lr,affected:jr,file:nt,silent:_r,featureThreshold:Li,query:ji,mermaid:_i,typeGraph:Wr,typeFilter:Wi,moduleResponsibility:zr,filterPaths:zi,minOutDegree:$i,featureGraph:Ui,callGraph:$r,functionName:Bi,apiSurface:Ur,applyTags:Br,dryRun:Ji,depth:Ki,cached:Hi,changedSymbols:Qi,withEdgeDetail:Vi,findComplexFunctions:Jr,metric:Xi,complexityThreshold:qi,limit:Yi,workspacePackages:Kr,workspaceAffected:Zi,slim:ea,testsOnly:ta,watch:Hr}=e;if(Kr||Zi){Hr&&(console.error("Error: --watch is not supported with --workspace-packages/--workspace-affected"),process.exit(1));let O=await Io(s,k(r.rawConfig));Kr?vi(O):(nt||(console.error("Error: --workspace-affected requires --file <path>"),process.exit(1)),bi(O,nt));return}let Qr=a||l||Br||Or||Gr||Lr||jr||x||Jr||Wr||zr||$r||Ur,Ee=Fi(o)??new P(new Map);(n.length>0||!Qr)&&(n.length===0&&!Qr&&!h&&!d&&!I&&!R&&(console.error("Error: No entry points provided"),process.exit(1)),Ee=await Rr(s,n,Ee,{silent:_r,...k(r.rawConfig)}),Ar(Ee,o));let ot={graph:Ee,rootDir:s,entryPoints:n.map(O=>O.replace(s+"/","")),scanOptions:i,rawConfig:r.rawConfig,featureThreshold:Li,queryStr:ji,mermaidOutput:_i,plain:p,excludeTests:C,file:nt,typeFilter:Wi,filterPaths:zi,minOutDegree:$i,functionName:Bi,dryRun:Ji,depth:Ki,cached:Hi,changedSymbols:Qi,withEdgeDetail:Vi,metric:Xi,complexityThreshold:qi,limit:Yi,slim:ea,testsOnly:ta},it=[[a,hi],[Br,zo],[l,Lo],[d,Zo],[h,oi],[I,vr],[R,kr],[x,Pr],[Or,Cr],[Gr,wr],[Lr,Er],[jr,Sr],[Jr,Fr],[Wr,xi],[zr,gi],[Ui,ti],[$r,Uo],[Ur,_o]].find(([O])=>O)?.[1]??Tr;if(Hr){Kl.has(it)||(console.error("Error: --watch is only supported with the default output, --query, --callers, --dependencies, --dependents, --affected, --find-uncovered, --find-complex-functions, --check-cycles, and --check-doc-drift"),process.exit(1)),Ai(s,300,async()=>{let O=await Rr(s,n,ot.graph,{silent:_r,...k(r.rawConfig)});Ar(O,o),console.log(`--- rebuilt at ${new Date().toISOString()} ---`),await it({...ot,graph:O})});return}await it(ot)}var Kl,Gi=m(()=>{"use strict";c();b();Oo();Go();jo();Wo();$o();Bo();Jo();Ko();Ho();Xo();qo();Yo();ei();ri();si();ni();ii();ai();fi();ui();di();yi();Si();Ci();ki();Ei();Pi();Ii();Ri();Kl=new Set([Tr,Cr,wr,Er,Sr,Pr,Fr,vr,kr])});var Hl=ra(()=>{c();Gi();Oi().catch(t=>{console.error(t),process.exit(1)})});export default Hl();
237
+ `});var Ei,wi=m(()=>{"use strict";c();Ei=/(?:^|[/\\])(?:node_modules|\.git|dist|build|coverage)(?:[/\\]|$)/});import Sp from"fs";function Fi(t,e,r){let s=null,n=!1,o=!1,i=async()=>{if(n){o=!0;return}n=!0;try{await r()}finally{n=!1,o&&(o=!1,i())}};i();let a=null;try{a=Sp.watch(t,{recursive:!0},(l,p)=>{!p||Ei.test(p)||(s&&clearTimeout(s),s=setTimeout(()=>{i()},e))})}catch(l){console.error(`Warning: unable to watch ${t}: ${l.message}`)}process.on("SIGINT",()=>{s&&clearTimeout(s),a?.close(),process.exit(0)})}var Pi=m(()=>{"use strict";c();wi()});function Cp(t){t.help&&(console.log(Ci),process.exit(0)),t.queryHelp&&(console.log(vi),process.exit(0)),t.initSkill&&(oi(t.force),process.exit(0)),t.initConfig&&(si(t.force),process.exit(0)),t.clearCache&&(Wo(t.cachePath),process.exit(0))}async function vp(t,e,r){if(!t.workspacePackages&&!t.workspaceAffected)return!1;t.watch&&(console.error("Error: --watch is not supported with --workspace-packages/--workspace-affected"),process.exit(1));let s=await bo(r,k(e.rawConfig));return t.workspacePackages?di(s):(t.file||(console.error("Error: --workspace-affected requires --file <path>"),process.exit(1)),ui(s,t.file)),!0}function kp(t){return t.proposeTags||t.affectedTests||t.applyTags||t.callers||t.dependencies||t.dependents||t.affected||t.findUncovered||t.findComplexFunctions||t.typeGraph||t.moduleResponsibility||t.callGraph||t.findSymbol||t.apiSurface}function Ep(t){let r=[{name:"--propose-tags",flag:t.proposeTags,handler:li},{name:"--apply-tags",flag:t.applyTags,handler:Ao},{name:"--affected-tests",flag:t.affectedTests,handler:To},{name:"--detect-features",flag:t.detectFeatures,handler:Bo},{name:"--find-unused",flag:t.findUnused,handler:qo},{name:"--check-cycles",flag:t.checkCycles,handler:Er},{name:"--check-doc-drift",flag:t.checkDocDrift,handler:wr},{name:"--find-uncovered",flag:t.findUncovered,handler:Nr},{name:"--callers",flag:t.callers,handler:kr},{name:"--dependencies",flag:t.dependencies,handler:Fr},{name:"--dependents",flag:t.dependents,handler:Pr},{name:"--affected",flag:t.affected,handler:Cr},{name:"--find-complex-functions",flag:t.findComplexFunctions,handler:Tr},{name:"--type-graph",flag:t.typeGraph,handler:fi},{name:"--module-responsibility",flag:t.moduleResponsibility,handler:ai},{name:"--feature-graph",flag:t.featureGraph,handler:Ko},{name:"--call-graph",flag:t.callGraph,handler:Ro},{name:"--find-symbol",flag:t.findSymbol,handler:Vo},{name:"--api-surface",flag:t.apiSurface,handler:Io}].filter(s=>s.flag);return r.length>1&&(console.error(`Error: conflicting flags: ${r.map(s=>s.name).join(", ")} (pass only one command flag)`),process.exit(1)),r[0]?.handler??Ir}async function wp(t,e,r,s,n,o,i){bp.has(t)||(console.error("Error: --watch is only supported with the default output, --query, --callers, --dependencies, --dependents, --affected, --find-uncovered, --find-complex-functions, --check-cycles, and --check-doc-drift"),process.exit(1)),Fi(r,300,async()=>{let a=await Gr(r,s,e.graph,{silent:o,...k(i)});Or(a,n),console.log(`--- rebuilt at ${new Date().toISOString()} ---`),await t({...e,graph:a})})}async function Ti(){let t=process.argv.slice(2),e=wo(t);Cp(e);let r=yi(e);ft(r.rawConfig);let{rootDir:s,resolvedEntryPoints:n,resolvedCachePath:o,scanOptions:i}=r;if(await vp(e,r,s))return;let a=kp(e),l=Si(o)??new P(new Map);(n.length>0||!a)&&(n.length===0&&!a&&!e.findUnused&&!e.detectFeatures&&!e.checkCycles&&!e.checkDocDrift&&(console.error("Error: No entry points provided"),process.exit(1)),l=await Gr(s,n,l,{silent:e.silent,...k(r.rawConfig)}),Or(l,o));let p={graph:l,rootDir:s,entryPoints:n.map(d=>d.replace(s+"/","")),scanOptions:i,rawConfig:r.rawConfig,featureThreshold:e.featureThreshold,queryStr:e.query,mermaidOutput:e.mermaid,plain:e.plain,excludeTests:e.excludeTests,file:e.file,typeFilter:e.typeFilter,filterPaths:e.filterPaths,minOutDegree:e.minOutDegree,functionName:e.functionName,dryRun:e.dryRun,depth:e.depth,cached:e.cached,changedSymbols:e.changedSymbols,withMeta:e.withMeta,withEdgeDetail:e.withEdgeDetail,metric:e.metric,complexityThreshold:e.complexityThreshold,limit:e.limit,slim:e.slim,testsOnly:e.testsOnly},h=Ep(e);if(e.watch){await wp(h,p,s,n,o,e.silent,r.rawConfig);return}await h(p)}var bp,Ni=m(()=>{"use strict";c();b();Fo();Po();No();Mo();Do();Oo();Go();Lo();jo();zo();$o();Uo();Jo();Ho();Qo();Xo();Yo();Zo();ei();ni();ii();ci();pi();mi();gi();hi();xi();bi();ki();Pi();bp=new Set([Ir,kr,Fr,Pr,Cr,Nr,Tr,Er,wr])});var Fp=Ii(()=>{c();Ni();Ti().catch(t=>{console.error(t),process.exit(1)})});export default Fp();
233
238
  //# sourceMappingURL=cli.mjs.map