@omfalos/mokosh 0.1.7 → 0.1.8

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,39 @@
1
1
  #!/usr/bin/env node
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 Yi=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);import Zi from"path";import{fileURLToPath as ea}from"url";var ta,ra,f,c=m(()=>{"use strict";ta=()=>ea(import.meta.url),ra=()=>Zi.dirname(ta()),f=ra()});function Ee(t){Qr.push(t)}function Vr(t){return[...sa,...Qr].some(e=>typeof e=="string"?t.includes(e):e instanceof RegExp?e.test(t):e(t))}function Fe(t){Xr.push(t)}function se(){return[...na,...Xr]}function Pe(t){qr.push(t)}function at(){return[...oa,...qr]}function ct(t){Yr=t}function pt(){return Yr}var sa,Qr,na,Xr,oa,qr,Yr,$=m(()=>{"use strict";c();sa=[".config.","biome.json","tsconfig.json","package.json",".prettierrc",".eslintrc"],Qr=[];na=[".test.",".spec.","-test.","-spec."],Xr=[];oa=["jest","vitest","playwright","cypress","@testing-library/"],qr=[];Yr=.8});import lt from"fs";import Zr from"path";function U(t,{allowJs:e=!0,isExplicitPath:r=!1}={}){if(r){let s=Zr.resolve(t);return lt.existsSync(s)?s.endsWith(".json")?es(s):e?ts(s):{}:{}}for(let s of ia){let n=Zr.resolve(t,s);if(lt.existsSync(n)){if(s.endsWith(".json"))return es(n);if(e)return ts(n)}}return{}}function es(t){return JSON.parse(lt.readFileSync(t,"utf-8"))}function ts(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??[])Ee(e);for(let e of t.testPatterns??[])Fe(e);for(let e of t.testLibraries??[])Pe(e);t.barrelThreshold!==void 0&&ct(t.barrelThreshold)}var ia,mt=m(()=>{"use strict";c();$();ia=["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 af from"fs";import pf from"path";var rs=m(()=>{"use strict";c()});var Te,ss=m(()=>{"use strict";c();Te={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 ns=m(()=>{"use strict";c();ss()});import os from"fs";import ca 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 is(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=is(r[s],e);if(n)return n}}return null}function pa(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 la(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 yt(t,e){let r=[],s=ca.join(e,"package.json");if(os.existsSync(s))try{let n=JSON.parse(os.readFileSync(s,"utf8"));if(n.exports&&typeof n.exports=="object"&&!Array.isArray(n.exports))for(let o of Object.values(n.exports)){let i=is(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 fa(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 ma(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 ua(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:pa(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 ga(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 xt(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=fa(t,e),s=ma(t,r,e),n=la(t,e),o=ua(n,s,t,e),{internalFiles:i,unreachableFromEntry:a,testFiles:p}=ga(t,r,e);return{entryPoints:e,publicExports:o,internalFiles:i,unreachableFromEntry:a,testFiles:p}}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 wf from"fs";import Ff from"path";function as(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:as(t)}}function kt(t,e){return t.impact.get(e)??[]}var wt=m(()=>{"use strict";c()});import Ne from"path";function da(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 ha(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=Ne.extname(n),p=Ne.basename(n,a),l=p==="index"?Ne.basename(Ne.dirname(n)):p;s.set(n,{path:n,outDegree:o,tag:`feature:${l}`})}return s}function _(t,e){let r=e?.minOutDegree??5;return ha(t,da(t),r)}var Ie=m(()=>{"use strict";c()});function xa(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 Sa(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 ba(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 Ca(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??_,s=e?.hubComparator??ya,n=r(t.nodes,e),o=xa(t,n),i=Sa(t.nodes,n,o,s);return{features:ba(n,i),unassigned:Ca(t.nodes,n,i)}}var ya,Me=m(()=>{"use strict";c();Ie();ya=(t,e)=>t.outDegree-e.outDegree});var oe,cs=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 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 F,ie=m(()=>{"use strict";c();cs();F=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 oe(this.nodes).findUnusedFiles(e)}findCycles(){return new oe(this.nodes).findCycles()}}});var W,De=m(()=>{"use strict";c();W=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 Et(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 Ft(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 Pt(t,e,r={}){let{testsOnly:s=!1,changedSymbols:n}=r,o=n?new W(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 Tt(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 Nt(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 It(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 Mt(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 ps=m(()=>{"use strict";c();De()});function ls(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")||ae(e)==="cli"?"cli":S(e,"util")||S(e,"utils")||S(e,"helper")||S(e,"helpers")?"util":S(e,"model")||S(e,"models")||ae(e)==="model"?"model":S(e,"parser")||S(e,"parsers")||ae(e)==="parser"?"parser":ae(e)==="builder"?"builder":ae(e)==="resolver"?"resolver":"other"}function S(t,e){return t.includes(`/${e}/`)||t.includes(`/${e}.`)}function ae(t){let e=t.slice(t.lastIndexOf("/")+1);return e.slice(0,e.lastIndexOf("."))||e}var fs=m(()=>{"use strict";c()});function At(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:ls(o),...o.description?{description:o.description}:{},exports:o.exports.map(a=>a.name),...i?{featureHub:i}:{}})}return n}var Rt=m(()=>{"use strict";c();Me();fs()});function va(t){return t?t.startsWith("interface ")?"interface":t.startsWith("class ")?"class":t.startsWith("enum ")?"enum":"type":"type"}function ka(t,e){if(e==="type-only")return!0;let r=t.signature??"";return r.startsWith("interface ")||r.startsWith("class ")||r.startsWith("enum ")}function Ot(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(!ka(n,s.category))continue;let o=`${s.path}::${n.name}`;e.set(o,{name:n.name,file:s.path,kind:va(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 Gt=m(()=>{"use strict";c()});import ms from"fs";import tm from"path";function us(t){try{return ms.statSync(t,{throwIfNoEntry:!1})?.isDirectory()===!0}catch{return!1}}function Ae(t){try{return ms.statSync(t,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}var Re=m(()=>{"use strict";c()});import ce from"fs";import P from"path";function jt(t,e){let r=P.join(e,"package.json");if(!ce.existsSync(r))return null;let s={};try{s=JSON.parse(ce.readFileSync(r,"utf-8"))}catch{return null}let n=s.name;return n?{name:n,root:e,relativeRoot:P.relative(t,e),entryPoints:wa(e,s)}:null}function wa(t,e){let r=[];if(e.exports){let n=e.exports;if(typeof n=="string")r.push(P.join(t,n));else if(typeof n=="object"&&n!==null){let o=n["."];if(typeof o=="string")r.push(P.join(t,o));else if(typeof o=="object"&&o!==null){let i=o.import??o.require??o.default;typeof i=="string"&&r.push(P.join(t,i))}}}e.main&&r.push(P.join(t,e.main));for(let n of["src/index.ts","src/index.tsx","index.ts","index.tsx","index.js"])r.push(P.join(t,n));let s=r.filter(Ae);return s.length>0?s.slice(0,1):r.slice(0,1)}function B(t,e){let r=[],s=new Set;for(let n of e){let o=n.replace(/\/$/,"").replace(/^\.\//,"");Ea(t,o,s,r)}return r}function Ea(t,e,r,s){if(!e.includes("*")){Fa(t,e,r,s);return}let n=e.split("/");n.includes("**")?Pa(t,n,r,s):Ta(t,n,r,s)}function Fa(t,e,r,s){let n=P.join(t,e);if(r.has(n)||!us(n))return;r.add(n);let o=jt(t,n);o&&s.push(o)}function Pa(t,e,r,s){let n=P.join(t,e[0]==="**"?"":e[0]??"");gs(t,n,r,s)}function Ta(t,e,r,s){let n=e.findIndex(a=>a.includes("*")),o=P.join(t,...e.slice(0,n)),i;try{i=ce.readdirSync(o,{withFileTypes:!0})}catch{return}for(let a of i){if(!a.isDirectory())continue;let p=P.join(o,a.name);if(r.has(p))continue;r.add(p);let l=jt(t,p);l&&s.push(l)}}function gs(t,e,r,s){let n;try{n=ce.readdirSync(e,{withFileTypes:!0})}catch{return}for(let o of n){if(!o.isDirectory()||o.name==="node_modules"||o.name.startsWith("."))continue;let i=P.join(e,o.name);if(ce.existsSync(P.join(i,"package.json"))&&!r.has(i)){r.add(i);let a=jt(t,i);a&&s.push(a)}else gs(t,i,r,s)}}var Oe=m(()=>{"use strict";c();Re();Re()});import _t from"fs";import ds from"path";var hs,ys=m(()=>{"use strict";c();Oe();hs={type:"npm",detect(t){let e=ds.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(ds.join(t,"yarn.lock")))return null;let s=Array.isArray(r)?r:r.packages??[];return s.length===0?null:B(t,s)}}});import J from"fs";import k from"path";function Ss(t,e,r,s){if(s>4)return[];let n;try{n=J.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=k.join(e,a);J.existsSync(k.join(p,"project.json"))&&!r.has(p)?(r.add(p),o.push(p)):o.push(...Ss(t,p,r,s+1))}return o}function Na(t,e,r){let s={};try{s=JSON.parse(J.readFileSync(r,"utf-8"))}catch{return null}let n=s.name,o,i,a=k.join(e,"package.json");if(J.existsSync(a))try{let p=JSON.parse(J.readFileSync(a,"utf-8"));n=p.name??n,o=p.main,i=p.exports}catch{}return n?{name:n,root:e,relativeRoot:k.relative(t,e),entryPoints:Ia(e,s,o,i)}:null}function Ia(t,e,r,s){let n=[],o=e.targets?.build?.options?.main??e.targets?.build?.options?.entryFile;if(o){let a=k.resolve(t,"../..");n.push(k.resolve(a,o)),n.push(k.resolve(t,o))}if(s){let a=s;if(typeof a=="string")n.push(k.join(t,a));else if(typeof a=="object"&&a!==null){let p=a["."];typeof p=="string"&&n.push(k.join(t,p))}}if(r&&n.push(k.join(t,r)),e.sourceRoot){let a=k.resolve(t,"../.."),p=k.resolve(a,e.sourceRoot);n.push(k.join(p,"index.ts"),k.join(p,"index.tsx"))}for(let a of["src/index.ts","src/index.tsx","index.ts","index.tsx"])n.push(k.join(t,a));let i=n.filter(Ae);return i.length>0?i.slice(0,1):n.slice(0,1)}var xs,bs=m(()=>{"use strict";c();Re();xs={type:"nx",detect(t){return J.existsSync(k.join(t,"nx.json"))?Ss(t,t,new Set,0).map(r=>Na(t,r,k.join(r,"project.json"))).filter(r=>r!==null):null}}});import Cs from"fs";import Ma from"path";import Da from"js-yaml";var vs,ks=m(()=>{"use strict";c();Oe();vs={type:"pnpm",detect(t){let e=Ma.join(t,"pnpm-workspace.yaml");if(!Cs.existsSync(e))return null;let r=[];try{r=Da.load(Cs.readFileSync(e,"utf-8"))?.packages??[]}catch{return null}return B(t,r)}}});import Aa from"fs";import Ra from"path";var ws,Es=m(()=>{"use strict";c();ws={type:"turborepo",detect(t){return Aa.existsSync(Ra.join(t,"turbo.json"))?[]:null}}});import Wt from"fs";import Fs from"path";var Ps,Ts=m(()=>{"use strict";c();Oe();Ps={type:"yarn",detect(t){if(!Wt.existsSync(Fs.join(t,"yarn.lock")))return null;let e=Fs.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)return null;let s=Array.isArray(r)?r:r.packages??[];return s.length===0?null:B(t,s)}}});function O(t){Ns.push(t)}function Is(){return Ns}var Ns,Le=m(()=>{"use strict";c();Ns=[]});import Oa from"path";function zt(t,e=Is()){let r=Oa.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 $t=m(()=>{"use strict";c();ys();bs();ks();Es();Ts();Le();Le();O(ws);O(xs);O(vs);O(Ps);O(hs)});var pe,Ut=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(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 F(o);r.packages.set(s.name,{graph:i,pkg:{...s,root:""}})}return r}}});function K(t,e){Ms.set(t,e)}function Ds(t){return Ms.get(t)}var Ms,le=m(()=>{"use strict";c();Ms=new Map});function As(t,e){return e.startsWith("!")?t!==e.slice(1):t===e}function La(t,e){return e.startsWith("!")?!t.includes(e.slice(1)):t.includes(e)}function fe(t,e,r){return lc.every(s=>s(t,e,r))}var Ga,ja,_a,Wa,za,$a,Ua,Ba,Ja,Ka,Ha,Qa,Va,Xa,qa,Ya,Za,ec,tc,rc,sc,nc,oc,ic,ac,cc,pc,lc,Bt=m(()=>{"use strict";c();Ga=(t,e)=>!e.category||As(t.category,e.category),ja=(t,e)=>!e.type||As(t.type,e.type),_a=(t,e)=>e.lastAuthor?e.lastAuthor.startsWith("!")?t.lastAuthor!==e.lastAuthor.slice(1):t.lastAuthor!==void 0&&t.lastAuthor===e.lastAuthor:!0,Wa=(t,e)=>!e.path||La(t.path,e.path),za=(t,e)=>e.isExternal===void 0?!0:t.imports.some(s=>s.isExternal)===e.isExternal,$a=(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)))},Ua=(t,e)=>!e.allTags?.length||e.allTags.every(r=>t.tags.some(s=>s.name===r)),Ba=(t,e)=>!e.importsFile||t.imports.some(r=>r.toPath?.includes(e.importsFile)),Ja=(t,e,r)=>e.importedBy===void 0?!0:(r?.get(t.path)??[]).some(n=>n.includes(e.importedBy)),Ka=(t,e)=>e.minImports===void 0||t.imports.length>=e.minImports,Ha=(t,e)=>e.maxImports===void 0||t.imports.length<=e.maxImports,Qa=(t,e)=>e.minSize===void 0||t.size>=e.minSize,Va=(t,e)=>e.maxSize===void 0||t.size<=e.maxSize,Xa=(t,e)=>e.hasDocstring===void 0||!!t.description===e.hasDocstring,qa=(t,e)=>e.isDocumented===void 0||!!t.documentedBy?.length===e.isDocumented,Ya=(t,e)=>e.isStale===void 0||!!t.staleFor?.length===e.isStale,Za=(t,e)=>e.minCoverage===void 0||(t.coveragePct??101)>=e.minCoverage,ec=(t,e)=>e.maxCoverage===void 0||(t.coveragePct??0)<=e.maxCoverage,tc=(t,e)=>e.minExportUsage===void 0||(t.avgExportUsage??-1)>=e.minExportUsage,rc=(t,e)=>e.maxExportUsage===void 0||(t.avgExportUsage??0)<=e.maxExportUsage,sc=(t,e)=>e.minComplexity===void 0||(t.complexity??-1/0)>=e.minComplexity,nc=(t,e)=>e.maxComplexity===void 0||(t.complexity??0)<=e.maxComplexity,oc=(t,e)=>e.minCognitiveComplexity===void 0||(t.cognitiveComplexity??-1/0)>=e.minCognitiveComplexity,ic=(t,e)=>e.maxCognitiveComplexity===void 0||(t.cognitiveComplexity??0)<=e.maxCognitiveComplexity,ac=(t,e)=>e.minCommits===void 0||(t.commitCount90d??-1/0)>=e.minCommits,cc=(t,e)=>e.maxCommits===void 0||(t.commitCount90d??0)<=e.maxCommits,pc=(t,e,r)=>!e.any?.length||e.any.some(s=>fe(t,s,r)),lc=[Ga,ja,_a,Wa,za,$a,Ua,Ba,Ja,Ka,Ha,Qa,Va,Xa,qa,Ya,Za,ec,tc,rc,sc,nc,oc,ic,ac,cc,pc]});function Ge(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=>fe(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 Rs=m(()=>{"use strict";c();Bt();Bt()});function Os(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 fc(t){let e=[];for(let r of t.split("|")){let s=r.trim();if(!s)continue;let n={};Os(n,s),Object.keys(n).length>0&&e.push(n)}return e}function je(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=fc(o);i.length>0&&(e.any=[...e.any??[],...i]);continue}Os(e,s)}return e}var Ls=m(()=>{"use strict";c()});var Gs=m(()=>{"use strict";c();Rs();Ls()});import w from"typescript";function H(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)&&js.has(n.text)&&e.push(s),w.isPropertyAccessExpression(n)&&w.isIdentifier(n.expression)&&js.has(n.expression.text)&&e.push(s)}return e}function Q(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 V(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(l=>w.isPropertyAssignment(l)&&w.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 X(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(p=>w.isPropertyAssignment(p)&&w.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 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 Y(t){return`[${t.map(e=>JSON.stringify(e)).join(", ")}]`}var js,D,Z=m(()=>{"use strict";c();js=new Set(["describe","test","it"]);D=new Set([".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"])});import _s from"path";import Ws from"typescript";function mc(t){return Y(t.map(e=>`@${e}`))}function uc(t){return t.map(e=>e.startsWith("@")?e.slice(1):e)}var _e,zs=m(()=>{"use strict";c();Z();_e=class{name="cypress";canHandle(e){return D.has(_s.extname(e).toLowerCase())}apply(e,r,s){let n=Ws.createSourceFile(_s.basename(e),r,Ws.ScriptTarget.Latest,!0),o=H(n);if(o.length===0)return r;let i=Q(o[0],"tags",n),a=[...s].sort();if(i!==null&&JSON.stringify(uc(i).sort())===JSON.stringify(a))return r;let p=o.flatMap(l=>{let d=s.length===0?X(l,"tags",n):V(l,"tags",mc(a),n);return d?[d]:[]});return p.length>0?q(r,p):r}}});import gc from"path";function dc(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 ta=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);import ra from"path";import{fileURLToPath as sa}from"url";var na,oa,f,c=m(()=>{"use strict";na=()=>sa(import.meta.url),oa=()=>ra.dirname(na()),f=oa()});function Ee(t){Qr.push(t)}function Vr(t){return[...ia,...Qr].some(e=>typeof e=="string"?t.includes(e):e instanceof RegExp?e.test(t):e(t))}function Fe(t){Xr.push(t)}function se(){return[...aa,...Xr]}function Pe(t){qr.push(t)}function at(){return[...ca,...qr]}function ct(t){Yr=t}function pt(){return Yr}var ia,Qr,aa,Xr,ca,qr,Yr,$=m(()=>{"use strict";c();ia=[".config.","biome.json","tsconfig.json","package.json",".prettierrc",".eslintrc"],Qr=[];aa=[".test.",".spec.","-test.","-spec."],Xr=[];ca=["jest","vitest","playwright","cypress","@testing-library/"],qr=[];Yr=.8});import lt from"fs";import Zr from"path";function U(t,{allowJs:e=!0,isExplicitPath:r=!1}={}){if(r){let s=Zr.resolve(t);return lt.existsSync(s)?s.endsWith(".json")?es(s):e?ts(s):{}:{}}for(let s of pa){let n=Zr.resolve(t,s);if(lt.existsSync(n)){if(s.endsWith(".json"))return es(n);if(e)return ts(n)}}return{}}function es(t){return JSON.parse(lt.readFileSync(t,"utf-8"))}function ts(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??[])Ee(e);for(let e of t.testPatterns??[])Fe(e);for(let e of t.testLibraries??[])Pe(e);t.barrelThreshold!==void 0&&ct(t.barrelThreshold)}var pa,mt=m(()=>{"use strict";c();$();pa=["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 lf from"fs";import mf from"path";var rs=m(()=>{"use strict";c()});var Te,ss=m(()=>{"use strict";c();Te={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 ns=m(()=>{"use strict";c();ss()});import os from"fs";import fa 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 is(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=is(r[s],e);if(n)return n}}return null}function ma(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 ua(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 yt(t,e){let r=[],s=fa.join(e,"package.json");if(os.existsSync(s))try{let n=JSON.parse(os.readFileSync(s,"utf8"));if(n.exports&&typeof n.exports=="object"&&!Array.isArray(n.exports))for(let o of Object.values(n.exports)){let i=is(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 ga(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 da(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 ha(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:ma(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 ya(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 xt(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=ga(t,e),s=da(t,r,e),n=ua(t,e),o=ha(n,s,t,e),{internalFiles:i,unreachableFromEntry:a,testFiles:p}=ya(t,r,e);return{entryPoints:e,publicExports:o,internalFiles:i,unreachableFromEntry:a,testFiles:p}}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 Pf from"fs";import Nf from"path";function as(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:as(t)}}function kt(t,e){return t.impact.get(e)??[]}var wt=m(()=>{"use strict";c()});import Ne from"path";function xa(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 Sa(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=Ne.extname(n),p=Ne.basename(n,a),l=p==="index"?Ne.basename(Ne.dirname(n)):p;s.set(n,{path:n,outDegree:o,tag:`feature:${l}`})}return s}function _(t,e){let r=e?.minOutDegree??5;return Sa(t,xa(t),r)}var Ie=m(()=>{"use strict";c()});function Ca(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 va(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 ka(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 wa(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??_,s=e?.hubComparator??ba,n=r(t.nodes,e),o=Ca(t,n),i=va(t.nodes,n,o,s);return{features:ka(n,i),unassigned:wa(t.nodes,n,i)}}var ba,Me=m(()=>{"use strict";c();Ie();ba=(t,e)=>t.outDegree-e.outDegree});var oe,cs=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 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 F,ie=m(()=>{"use strict";c();cs();F=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 oe(this.nodes).findUnusedFiles(e)}findCycles(){return new oe(this.nodes).findCycles()}}});var W,De=m(()=>{"use strict";c();W=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 Et(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 Ft(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 Pt(t,e,r={}){let{testsOnly:s=!1,changedSymbols:n}=r,o=n?new W(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 Tt(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 Nt(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 It(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 Mt(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 ps=m(()=>{"use strict";c();De()});function ls(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")||ae(e)==="cli"?"cli":S(e,"util")||S(e,"utils")||S(e,"helper")||S(e,"helpers")?"util":S(e,"model")||S(e,"models")||ae(e)==="model"?"model":S(e,"parser")||S(e,"parsers")||ae(e)==="parser"?"parser":ae(e)==="builder"?"builder":ae(e)==="resolver"?"resolver":"other"}function S(t,e){return t.includes(`/${e}/`)||t.includes(`/${e}.`)}function ae(t){let e=t.slice(t.lastIndexOf("/")+1);return e.slice(0,e.lastIndexOf("."))||e}var fs=m(()=>{"use strict";c()});function At(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:ls(o),...o.description?{description:o.description}:{},exports:o.exports.map(a=>a.name),...i?{featureHub:i}:{}})}return n}var Rt=m(()=>{"use strict";c();Me();fs()});function Ea(t){return t?t.startsWith("interface ")?"interface":t.startsWith("class ")?"class":t.startsWith("enum ")?"enum":"type":"type"}function Fa(t,e){if(e==="type-only")return!0;let r=t.signature??"";return r.startsWith("interface ")||r.startsWith("class ")||r.startsWith("enum ")}function Ot(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(!Fa(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 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 Gt=m(()=>{"use strict";c()});import ms from"fs";import nm from"path";function us(t){try{return ms.statSync(t,{throwIfNoEntry:!1})?.isDirectory()===!0}catch{return!1}}function Ae(t){try{return ms.statSync(t,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}var Re=m(()=>{"use strict";c()});import ce from"fs";import P from"path";function jt(t,e){let r=P.join(e,"package.json");if(!ce.existsSync(r))return null;let s={};try{s=JSON.parse(ce.readFileSync(r,"utf-8"))}catch{return null}let n=s.name;return n?{name:n,root:e,relativeRoot:P.relative(t,e),entryPoints:Pa(e,s)}:null}function Pa(t,e){let r=[];if(e.exports){let n=e.exports;if(typeof n=="string")r.push(P.join(t,n));else if(typeof n=="object"&&n!==null){let o=n["."];if(typeof o=="string")r.push(P.join(t,o));else if(typeof o=="object"&&o!==null){let i=o.import??o.require??o.default;typeof i=="string"&&r.push(P.join(t,i))}}}e.main&&r.push(P.join(t,e.main));for(let n of["src/index.ts","src/index.tsx","index.ts","index.tsx","index.js"])r.push(P.join(t,n));let s=r.filter(Ae);return s.length>0?s.slice(0,1):r.slice(0,1)}function B(t,e){let r=[],s=new Set;for(let n of e){let o=n.replace(/\/$/,"").replace(/^\.\//,"");Ta(t,o,s,r)}return r}function Ta(t,e,r,s){if(!e.includes("*")){Na(t,e,r,s);return}let n=e.split("/");n.includes("**")?Ia(t,n,r,s):Ma(t,n,r,s)}function Na(t,e,r,s){let n=P.join(t,e);if(r.has(n)||!us(n))return;r.add(n);let o=jt(t,n);o&&s.push(o)}function Ia(t,e,r,s){let n=P.join(t,e[0]==="**"?"":e[0]??"");gs(t,n,r,s)}function Ma(t,e,r,s){let n=e.findIndex(a=>a.includes("*")),o=P.join(t,...e.slice(0,n)),i;try{i=ce.readdirSync(o,{withFileTypes:!0})}catch{return}for(let a of i){if(!a.isDirectory())continue;let p=P.join(o,a.name);if(r.has(p))continue;r.add(p);let l=jt(t,p);l&&s.push(l)}}function gs(t,e,r,s){let n;try{n=ce.readdirSync(e,{withFileTypes:!0})}catch{return}for(let o of n){if(!o.isDirectory()||o.name==="node_modules"||o.name.startsWith("."))continue;let i=P.join(e,o.name);if(ce.existsSync(P.join(i,"package.json"))&&!r.has(i)){r.add(i);let a=jt(t,i);a&&s.push(a)}else gs(t,i,r,s)}}var Oe=m(()=>{"use strict";c();Re();Re()});import _t from"fs";import ds from"path";var hs,ys=m(()=>{"use strict";c();Oe();hs={type:"npm",detect(t){let e=ds.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(ds.join(t,"yarn.lock")))return null;let s=Array.isArray(r)?r:r.packages??[];return s.length===0?null:B(t,s)}}});import J from"fs";import k from"path";function Ss(t,e,r,s){if(s>4)return[];let n;try{n=J.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=k.join(e,a);J.existsSync(k.join(p,"project.json"))&&!r.has(p)?(r.add(p),o.push(p)):o.push(...Ss(t,p,r,s+1))}return o}function Da(t,e,r){let s={};try{s=JSON.parse(J.readFileSync(r,"utf-8"))}catch{return null}let n=s.name,o,i,a=k.join(e,"package.json");if(J.existsSync(a))try{let p=JSON.parse(J.readFileSync(a,"utf-8"));n=p.name??n,o=p.main,i=p.exports}catch{}return n?{name:n,root:e,relativeRoot:k.relative(t,e),entryPoints:Aa(e,s,o,i)}:null}function Aa(t,e,r,s){let n=[],o=e.targets?.build?.options?.main??e.targets?.build?.options?.entryFile;if(o){let a=k.resolve(t,"../..");n.push(k.resolve(a,o)),n.push(k.resolve(t,o))}if(s){let a=s;if(typeof a=="string")n.push(k.join(t,a));else if(typeof a=="object"&&a!==null){let p=a["."];typeof p=="string"&&n.push(k.join(t,p))}}if(r&&n.push(k.join(t,r)),e.sourceRoot){let a=k.resolve(t,"../.."),p=k.resolve(a,e.sourceRoot);n.push(k.join(p,"index.ts"),k.join(p,"index.tsx"))}for(let a of["src/index.ts","src/index.tsx","index.ts","index.tsx"])n.push(k.join(t,a));let i=n.filter(Ae);return i.length>0?i.slice(0,1):n.slice(0,1)}var xs,bs=m(()=>{"use strict";c();Re();xs={type:"nx",detect(t){return J.existsSync(k.join(t,"nx.json"))?Ss(t,t,new Set,0).map(r=>Da(t,r,k.join(r,"project.json"))).filter(r=>r!==null):null}}});import Cs from"fs";import Ra from"path";import{load as Oa}from"js-yaml";var vs,ks=m(()=>{"use strict";c();Oe();vs={type:"pnpm",detect(t){let e=Ra.join(t,"pnpm-workspace.yaml");if(!Cs.existsSync(e))return null;let r=[];try{r=Oa(Cs.readFileSync(e,"utf-8"))?.packages??[]}catch{return null}return B(t,r)}}});import La from"fs";import Ga from"path";var ws,Es=m(()=>{"use strict";c();ws={type:"turborepo",detect(t){return La.existsSync(Ga.join(t,"turbo.json"))?[]:null}}});import Wt from"fs";import Fs from"path";var Ps,Ts=m(()=>{"use strict";c();Oe();Ps={type:"yarn",detect(t){if(!Wt.existsSync(Fs.join(t,"yarn.lock")))return null;let e=Fs.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)return null;let s=Array.isArray(r)?r:r.packages??[];return s.length===0?null:B(t,s)}}});function O(t){Ns.push(t)}function Is(){return Ns}var Ns,Le=m(()=>{"use strict";c();Ns=[]});import ja from"path";function zt(t,e=Is()){let r=ja.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 $t=m(()=>{"use strict";c();ys();bs();ks();Es();Ts();Le();Le();O(ws);O(xs);O(vs);O(Ps);O(hs)});var pe,Ut=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(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 F(o);r.packages.set(s.name,{graph:i,pkg:{...s,root:""}})}return r}}});function K(t,e){Ms.set(t,e)}function Ds(t){return Ms.get(t)}var Ms,le=m(()=>{"use strict";c();Ms=new Map});function As(t,e){return e.startsWith("!")?t!==e.slice(1):t===e}function _a(t,e){return e.startsWith("!")?!t.includes(e.slice(1)):t.includes(e)}function fe(t,e,r){return uc.every(s=>s(t,e,r))}var Wa,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,Bt=m(()=>{"use strict";c();Wa=(t,e)=>!e.category||As(t.category,e.category),za=(t,e)=>!e.type||As(t.type,e.type),$a=(t,e)=>e.lastAuthor?e.lastAuthor.startsWith("!")?t.lastAuthor!==e.lastAuthor.slice(1):t.lastAuthor!==void 0&&t.lastAuthor===e.lastAuthor:!0,Ua=(t,e)=>!e.path||_a(t.path,e.path),Ba=(t,e)=>e.isExternal===void 0?!0:t.imports.some(s=>s.isExternal)===e.isExternal,Ja=(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)))},Ka=(t,e)=>!e.allTags?.length||e.allTags.every(r=>t.tags.some(s=>s.name===r)),Ha=(t,e)=>!e.importsFile||t.imports.some(r=>r.toPath?.includes(e.importsFile)),Qa=(t,e,r)=>e.importedBy===void 0?!0:(r?.get(t.path)??[]).some(n=>n.includes(e.importedBy)),Va=(t,e)=>e.minImports===void 0||t.imports.length>=e.minImports,Xa=(t,e)=>e.maxImports===void 0||t.imports.length<=e.maxImports,qa=(t,e)=>e.minSize===void 0||t.size>=e.minSize,Ya=(t,e)=>e.maxSize===void 0||t.size<=e.maxSize,Za=(t,e)=>e.hasDocstring===void 0||!!t.description===e.hasDocstring,ec=(t,e)=>e.isDocumented===void 0||!!t.documentedBy?.length===e.isDocumented,tc=(t,e)=>e.isStale===void 0||!!t.staleFor?.length===e.isStale,rc=(t,e)=>e.minCoverage===void 0||(t.coveragePct??101)>=e.minCoverage,sc=(t,e)=>e.maxCoverage===void 0||(t.coveragePct??0)<=e.maxCoverage,nc=(t,e)=>e.minExportUsage===void 0||(t.avgExportUsage??-1)>=e.minExportUsage,oc=(t,e)=>e.maxExportUsage===void 0||(t.avgExportUsage??0)<=e.maxExportUsage,ic=(t,e)=>e.minComplexity===void 0||(t.complexity??-1/0)>=e.minComplexity,ac=(t,e)=>e.maxComplexity===void 0||(t.complexity??0)<=e.maxComplexity,cc=(t,e)=>e.minCognitiveComplexity===void 0||(t.cognitiveComplexity??-1/0)>=e.minCognitiveComplexity,pc=(t,e)=>e.maxCognitiveComplexity===void 0||(t.cognitiveComplexity??0)<=e.maxCognitiveComplexity,lc=(t,e)=>e.minCommits===void 0||(t.commitCount90d??-1/0)>=e.minCommits,fc=(t,e)=>e.maxCommits===void 0||(t.commitCount90d??0)<=e.maxCommits,mc=(t,e,r)=>!e.any?.length||e.any.some(s=>fe(t,s,r)),uc=[Wa,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]});function Ge(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=>fe(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 Rs=m(()=>{"use strict";c();Bt();Bt()});function Os(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 gc(t){let e=[];for(let r of t.split("|")){let s=r.trim();if(!s)continue;let n={};Os(n,s),Object.keys(n).length>0&&e.push(n)}return e}function je(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=gc(o);i.length>0&&(e.any=[...e.any??[],...i]);continue}Os(e,s)}return e}var Ls=m(()=>{"use strict";c()});var Gs=m(()=>{"use strict";c();Rs();Ls()});import w from"typescript";function H(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)&&js.has(n.text)&&e.push(s),w.isPropertyAccessExpression(n)&&w.isIdentifier(n.expression)&&js.has(n.expression.text)&&e.push(s)}return e}function Q(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 V(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(l=>w.isPropertyAssignment(l)&&w.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 X(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(p=>w.isPropertyAssignment(p)&&w.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 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 Y(t){return`[${t.map(e=>JSON.stringify(e)).join(", ")}]`}var js,D,Z=m(()=>{"use strict";c();js=new Set(["describe","test","it"]);D=new Set([".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"])});import _s from"path";import Ws from"typescript";function dc(t){return Y(t.map(e=>`@${e}`))}function hc(t){return t.map(e=>e.startsWith("@")?e.slice(1):e)}var _e,zs=m(()=>{"use strict";c();Z();_e=class{name="cypress";canHandle(e){return D.has(_s.extname(e).toLowerCase())}apply(e,r,s){let n=Ws.createSourceFile(_s.basename(e),r,Ws.ScriptTarget.Latest,!0),o=H(n);if(o.length===0)return r;let i=Q(o[0],"tags",n),a=[...s].sort();if(i!==null&&JSON.stringify(hc(i).sort())===JSON.stringify(a))return r;let p=o.flatMap(l=>{let d=s.length===0?X(l,"tags",n):V(l,"tags",dc(a),n);return d?[d]:[]});return p.length>0?q(r,p):r}}});import yc from"path";function xc(t){return["# <mokosh-tags>",...t.map(e=>`@${e}`),"# </mokosh-tags>"].join(`
4
4
  `)+`
5
5
 
6
- `}function hc(t){let e=new Set;Kt.lastIndex=0;let r=Kt.exec(t);for(;r!==null;)r[1]&&e.add(r[1]),r=Kt.exec(t);return e}var Jt,Kt,We,$s=m(()=>{"use strict";c();Jt=/# <mokosh-tags>[\s\S]*?# <\/mokosh-tags>\n*/,Kt=/^@([a-zA-Z0-9_-]+)/gm;We=class{name="gherkin";canHandle(e){return gc.extname(e).toLowerCase()===".feature"}apply(e,r,s){let n=r.replace(Jt,""),o=hc(n),i=s.filter(p=>!o.has(p)),a=i.length>0?dc(i):"";return Jt.test(r)?r.replace(Jt,a):a?r.replace(/^(Feature:)/m,`${a}$1`):r}}});function Us(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 Bs=m(()=>{"use strict";c()});import yc from"path";function Sc(t){return`//go:build ${t.map(r=>`mokosh_${r}`).join(" || ")}
7
- `}function bc(t){let e=Ht.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 Ht,xc,ze,Js=m(()=>{"use strict";c();Ht=/^\/\/go:build mokosh_[^\n]+\n/m,xc=/^package\s+\S+/m;ze=class{name="go";canHandle(e){return yc.basename(e).endsWith("_test.go")}apply(e,r,s){let n=bc(r),o=[...s].sort();if(n!==null&&JSON.stringify([...n].sort())===JSON.stringify(o))return r;if(s.length===0)return r.replace(Ht,"");let i=Sc(o);if(n!==null)return r.replace(Ht,i);let a=xc.exec(r);if(!a)return r;let p=a.index;return r.slice(0,p)+i+`
8
- `+r.slice(p)}}});import Cc from"path";function kc(t){return["/**",...t.map(e=>` * @group ${e}`)," */"].join(`
6
+ `}function Sc(t){let e=new Set;Kt.lastIndex=0;let r=Kt.exec(t);for(;r!==null;)r[1]&&e.add(r[1]),r=Kt.exec(t);return e}var Jt,Kt,We,$s=m(()=>{"use strict";c();Jt=/# <mokosh-tags>[\s\S]*?# <\/mokosh-tags>\n*/,Kt=/^@([a-zA-Z0-9_-]+)/gm;We=class{name="gherkin";canHandle(e){return yc.extname(e).toLowerCase()===".feature"}apply(e,r,s){let n=r.replace(Jt,""),o=Sc(n),i=s.filter(p=>!o.has(p)),a=i.length>0?xc(i):"";return Jt.test(r)?r.replace(Jt,a):a?r.replace(/^(Feature:)/m,`${a}$1`):r}}});function Us(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 Bs=m(()=>{"use strict";c()});import bc from"path";function vc(t){return`//go:build ${t.map(r=>`mokosh_${r}`).join(" || ")}
7
+ `}function kc(t){let e=Ht.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 Ht,Cc,ze,Js=m(()=>{"use strict";c();Ht=/^\/\/go:build mokosh_[^\n]+\n/m,Cc=/^package\s+\S+/m;ze=class{name="go";canHandle(e){return bc.basename(e).endsWith("_test.go")}apply(e,r,s){let n=kc(r),o=[...s].sort();if(n!==null&&JSON.stringify([...n].sort())===JSON.stringify(o))return r;if(s.length===0)return r.replace(Ht,"");let i=vc(o);if(n!==null)return r.replace(Ht,i);let a=Cc.exec(r);if(!a)return r;let p=a.index;return r.slice(0,p)+i+`
8
+ `+r.slice(p)}}});import wc from"path";function Fc(t){return["/**",...t.map(e=>` * @group ${e}`)," */"].join(`
9
9
  `)+`
10
10
 
11
- `}function wc(t){let e=[];Qt.lastIndex=0;let r=Qt.exec(t);for(;r!==null;)r[1]&&e.push(r[1]),r=Qt.exec(t);return e}var vc,Qt,$e,Ks=m(()=>{"use strict";c();Z();vc=/^\/\*\*\n(?: \* @group .+\n)+ \*\/\n+/,Qt=/^ \* @group (.+)$/gm;$e=class{name="jest";canHandle(e){return D.has(Cc.extname(e).toLowerCase())}apply(e,r,s){let n=vc.exec(r),o=n?wc(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:kc(i)+a}}});import Hs from"path";import Qs from"typescript";function Ec(t){return Y(t.map(e=>`@${e}`))}function Fc(t){return t.map(e=>e.startsWith("@")?e.slice(1):e)}var Ue,Vs=m(()=>{"use strict";c();Z();Ue=class{name="playwright";canHandle(e){return D.has(Hs.extname(e).toLowerCase())}apply(e,r,s){let n=Qs.createSourceFile(Hs.basename(e),r,Qs.ScriptTarget.Latest,!0),o=H(n);if(o.length===0)return r;let i=Q(o[0],"tag",n),a=[...s].sort();if(i!==null&&JSON.stringify(Fc(i).sort())===JSON.stringify(a))return r;let p=o.flatMap(l=>{let d=s.length===0?X(l,"tag",n):V(l,"tag",Ec(a),n);return d?[d]:[]});return p.length>0?q(r,p):r}}});import Pc from"path";function Nc(t){let e=t.map(r=>`pytest.mark.${r}`).join(", ");return t.length===1?`pytestmark = pytest.mark.${t[0]}`:`pytestmark = [${e}]`}function Ic(t){let e=Vt.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 Mc(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 Vt,Tc,Be,Xs=m(()=>{"use strict";c();Vt=/^pytestmark\s*=\s*.+$/m,Tc=/^import pytest\s*$/m;Be=class{name="pytest";canHandle(e){return Pc.extname(e).toLowerCase()===".py"}apply(e,r,s){let n=Ic(r),o=[...s].sort();if(n!==null&&JSON.stringify([...n].sort())===JSON.stringify(o))return r;if(s.length===0)return r.replace(Vt,"").replace(/\n{3,}/g,`
11
+ `}function Pc(t){let e=[];Qt.lastIndex=0;let r=Qt.exec(t);for(;r!==null;)r[1]&&e.push(r[1]),r=Qt.exec(t);return e}var Ec,Qt,$e,Ks=m(()=>{"use strict";c();Z();Ec=/^\/\*\*\n(?: \* @group .+\n)+ \*\/\n+/,Qt=/^ \* @group (.+)$/gm;$e=class{name="jest";canHandle(e){return D.has(wc.extname(e).toLowerCase())}apply(e,r,s){let n=Ec.exec(r),o=n?Pc(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:Fc(i)+a}}});import Hs from"path";import Qs from"typescript";function Tc(t){return Y(t.map(e=>`@${e}`))}function Nc(t){return t.map(e=>e.startsWith("@")?e.slice(1):e)}var Ue,Vs=m(()=>{"use strict";c();Z();Ue=class{name="playwright";canHandle(e){return D.has(Hs.extname(e).toLowerCase())}apply(e,r,s){let n=Qs.createSourceFile(Hs.basename(e),r,Qs.ScriptTarget.Latest,!0),o=H(n);if(o.length===0)return r;let i=Q(o[0],"tag",n),a=[...s].sort();if(i!==null&&JSON.stringify(Nc(i).sort())===JSON.stringify(a))return r;let p=o.flatMap(l=>{let d=s.length===0?X(l,"tag",n):V(l,"tag",Tc(a),n);return d?[d]:[]});return p.length>0?q(r,p):r}}});import Ic from"path";function Dc(t){let e=t.map(r=>`pytest.mark.${r}`).join(", ");return t.length===1?`pytestmark = pytest.mark.${t[0]}`:`pytestmark = [${e}]`}function Ac(t){let e=Vt.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 Rc(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 Vt,Mc,Be,Xs=m(()=>{"use strict";c();Vt=/^pytestmark\s*=\s*.+$/m,Mc=/^import pytest\s*$/m;Be=class{name="pytest";canHandle(e){return Ic.extname(e).toLowerCase()===".py"}apply(e,r,s){let n=Ac(r),o=[...s].sort();if(n!==null&&JSON.stringify([...n].sort())===JSON.stringify(o))return r;if(s.length===0)return r.replace(Vt,"").replace(/\n{3,}/g,`
13
13
 
14
- `);let i=Nc(o);if(n!==null)return r.replace(Vt,i);let a=Tc.test(r),p=Mc(r),l=r.slice(0,p),d=r.slice(p),h=a?"":`import pytest
14
+ `);let i=Dc(o);if(n!==null)return r.replace(Vt,i);let a=Mc.test(r),p=Rc(r),l=r.slice(0,p),d=r.slice(p),h=a?"":`import pytest
15
15
  `,x=l.endsWith(`
16
16
 
17
17
  `)?"":`
18
18
  `;return l+x+h+i+`
19
- `+d}}});import qs from"path";import Ys from"typescript";var Dc,Je,Zs=m(()=>{"use strict";c();Z();Dc=/\/\/ <mokosh-tags>[\s\S]*?\/\/ <\/mokosh-tags>\n*/,Je=class{name="vitest";canHandle(e){return D.has(qs.extname(e).toLowerCase())}apply(e,r,s){let n=r.replace(Dc,""),o=Ys.createSourceFile(qs.basename(e),n,Ys.ScriptTarget.Latest,!0),i=H(o);if(i.length===0)return n;let a=Q(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?X(d,"tags",o):V(d,"tags",Y(p),o);return h?[h]:[]});return l.length>0?q(n,l):n}}});import Xt from"path";import Ke from"typescript";function Rc(t){let e=Ke.createSourceFile("detect.ts",t,Ke.ScriptTarget.Latest,!0);for(let r of e.statements){if(!Ke.isImportDeclaration(r)||!Ke.isStringLiteral(r.moduleSpecifier))continue;let s=Ac[r.moduleSpecifier.text];if(s)return s}return null}function tn(t="vitest",e={},r=process.cwd()){return[new We,new Be,new ze,new qt(r,t,Object.entries(e))]}function rn(t,e){return e.find(r=>r.canHandle(t))??null}var en,Ac,qt,sn=m(()=>{"use strict";c();zs();$s();Bs();Js();Ks();Vs();Xs();Z();Zs();en={vitest:()=>new Je,playwright:()=>new Ue,cypress:()=>new _e,jest:()=>new $e},Ac={"@playwright/test":"playwright",cypress:"cypress","@jest/globals":"jest",vitest:"vitest"};qt=class{constructor(e,r,s){this.rootDir=e;this.defaultFramework=r;this.frameworkOverrides=s}rootDir;defaultFramework;frameworkOverrides;name="auto";canHandle(e){return D.has(Xt.extname(e).toLowerCase())}apply(e,r,s){let n=Rc(r)??this.matchOverride(e)??this.defaultFramework;return(en[n]??en.vitest)().apply(e,r,s)}matchOverride(e){let r=Xt.relative(this.rootDir,e).split(Xt.sep).join("/");for(let[s,n]of this.frameworkOverrides)if(Us(s,r))return n;return null}}});import nn from"fs/promises";import Oc from"path";async function _c(t,e,r,s){let n;try{n=await nn.readFile(t,"utf8")}catch(a){return{path:t,status:"error",error:String(a)}}let o=rn(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 nn.writeFile(t,i,"utf8"),{path:t,status:"updated"})}async function Yt(t,e,r){let s=U(e),n=s.tagApplier?.framework??"vitest",o=s.tagApplier?.frameworkOverrides??{},i=tn(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)Gc.has(C.kind)&&Lc.test(C.name)&&(jc.has(C.name.toLowerCase())||l.has(C.name)||(l.add(C.name),d.push(C.name)));d.sort();let h=Oc.resolve(e,p.path),x=await _c(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 Lc,Gc,jc,on=m(()=>{"use strict";c();mt();sn();Lc=/^[a-zA-Z][a-zA-Z0-9_-]{1,}$/,Gc=new Set(["import"]),jc=new Set(["common","fixture","fixtures","helper","helpers","index","main","mock","mocks","setup","shared","spec","test","tests","types","util","utils"])});var He,Zt=m(()=>{"use strict";c();He=class{isTestNode(e){return e.category==="test"||e.tags.some(r=>r.name==="test")}}});import{execFileSync as er}from"child_process";function an(t,e){let s=er("git",["-C",t,"log","--follow","--format=%ae","--since=90 days ago","--",e],{encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).split(`
20
- `).filter(Boolean),n=er("git",["-C",t,"log","-1","--format=%at","--",e],{encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).trim();return{commitCount90d:s.length,lastAuthor:s[0],lastCommitAt:n?Number(n)*1e3:void 0}}var Qe,tr=m(()=>{"use strict";c();Qe=class{getChangedFiles(){try{let r=[["diff","--name-only"],["diff","--cached","--name-only"],["ls-files","--others","--exclude-standard"]].flatMap(s=>{try{return er("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),[]}}}});import Ve from"fs";import Wc from"path";import cn from"js-yaml";function pn(t){let e=t.lastIndexOf("@");return e>0?t.substring(0,e):t}function zc(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)),pn(r)}).filter(Boolean)}function $c(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 Uc(t){try{let e=cn.load(t),r={dependencies:{}};for(let[s,n]of Object.entries(e))if(!(s==="__metadata"||!n?.version))for(let o of s.split(", ")){let i=pn(o);i&&(r.dependencies[i]={version:n.version,...n.dependencies!==void 0&&{dependencies:n.dependencies}})}return r}catch{return null}}function Bc(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=zc(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 Jc(t){let e=Ve.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 Kc(t){let e=Ve.readFileSync(t,"utf-8");if(e.includes("__metadata:")){let r=Uc(e);if(r!==null)return r}return Bc(e)}function Hc(t){let e=Ve.readFileSync(t,"utf-8"),r={dependencies:{}};try{let s=cn.load(e);if(s.packages)for(let[n,o]of Object.entries(s.packages)){let{name:i,version:a}=$c(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 ln(t){let e=[["package-lock.json",Jc],["yarn.lock",Kc],["pnpm-lock.yaml",Hc]];for(let[r,s]of e){let n=Wc.join(t,r);if(Ve.existsSync(n))return s(n)}return null}var fn=m(()=>{"use strict";c()});import mn from"path";function L(t){switch(mn.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 T(t){let e=mn.extname(t).toLowerCase();return[".css",".scss",".sass",".less",".styl"].includes(e)}var G=m(()=>{"use strict";c()});import Qc from"coffeescript";function Vc(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 Xc(t,e){let r=t.toLowerCase();return r.includes(".test.")||r.includes(".spec.")||e.has("test")?"test":"logic"}function qc(t,e){let r=e.source?.value;return r?{fromPath:t,toPath:"",rawSpecifier:r,isStyle:T(r),type:"static"}:null}function Yc(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:T(s),type:"require"}}function Zc(t,e,r){let s=e.constructor?.name;if(s==="ImportDeclaration"){let n=qc(t,e);n&&r.push(n)}else if(s==="Call"){let n=Yc(t,e);n&&r.push(n)}}function rr(t,e,r){if(!(!e||typeof e!="object")){Zc(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)rr(t,o,r);else rr(t,n,r)}}}function un(t,e){let r=Vc(e),s=Xc(t,r),n=[];try{rr(t,Qc.nodes(e),n)}catch{}return{imports:n,exports:[],tags:Array.from(r).map(o=>({name:o,kind:"comment-marker"})),category:s}}var gn=m(()=>{"use strict";c();G()});import{AstBuilder as ep,GherkinClassicTokenMatcher as tp,Parser as rp}from"@cucumber/gherkin";import{IdGenerator as sp}from"@cucumber/messages";function sr(t,e){let r=new Set;try{let s=new ep(np),n=new tp,i=new rp(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 np,dn=m(()=>{"use strict";c();le();np=sp.uuid();K("gherkin",sr)});import op from"path";import{parser as ip}from"@lezer/go";function yn(t,e){let r=[],s=new Map,n=new Set,o=new Set,a=ip.parse(e).cursor();do switch(a.name){case"LineComment":{let h=e.slice(a.from,a.to),x=h.match(ap);x?.[1]&&n.add(x[1]);let C=h.match(cp);C&&hn(C[1],o);let N=h.match(pp);N&&hn(N[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=op.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 hn(t,e){for(let r of t.split(/[\s,&|!()]+/)){let s=r.trim();s&&s!=="ignore"&&e.add(s)}}var ap,cp,pp,xn=m(()=>{"use strict";c();ap=/\/\/\s*@tag\s+([a-zA-Z0-9_-]+)/,cp=/^\/\/go:build\s+(.+)$/,pp=/^\/\/\s*\+build\s+(.+)$/});function ee(t){return t.startsWith("'")||t.startsWith('"')?t.slice(1,-1):t}var nr=m(()=>{"use strict";c()});import lp from"livescript";function fp(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 mp(t,e){let r=t.toLowerCase();return r.includes(".test.")||r.includes(".spec.")||e.has("test")?"test":"logic"}function gp(t,e){let r=t.constructor?.name||t.type;if(r==="Import"){let s=t.right?.value;if(typeof s=="string"){let n=ee(s);return{fromPath:e,toPath:"",rawSpecifier:n,isStyle:T(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=ee(n);return{fromPath:e,toPath:"",rawSpecifier:o,isStyle:T(o),type:"require"}}}}return null}function or(t,e){if(!t||typeof t!="object")return[];let r=[],s=gp(t,e);s&&r.push(s);for(let n in t){if(up.has(n))continue;let o=t[n];if(!(!o||typeof o!="object"))if(Array.isArray(o))for(let i of o)r.push(...or(i,e));else r.push(...or(o,e))}return r}function Sn(t,e){let r=fp(e),s=mp(t,r),n=[];try{n=or(lp.ast(e),t)}catch{}return{imports:n,exports:[],tags:Array.from(r).map(o=>({name:o,kind:"comment-marker"})),category:s}}var up,bn=m(()=>{"use strict";c();G();nr();up=new Set(["first_line","first_column","last_line","last_column","line","column"])});import dp from"luaparse";function hp(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 yp(t,e){let r=t.toLowerCase();return r.includes(".test.")||r.includes(".spec.")||e.has("test")?"test":"logic"}function xp(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=ee(i.raw))}else if(n.type==="StringCallExpression"){let i=n.argument;i?.type==="StringLiteral"&&(o=ee(i.raw))}o&&r.push({fromPath:e,toPath:"",rawSpecifier:o,isStyle:T(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 Cn(t,e){let r=hp(e),s=yp(t,r),n=[];try{let o=dp.parse(e);n=xp(o,t)}catch{}return{imports:n,exports:[],tags:Array.from(r).map(o=>({name:o,kind:"comment-marker"})),category:s}}var vn=m(()=>{"use strict";c();G();nr()});async function vp(){return kn??=(async()=>{let{unified:t}=await import("unified"),e=(await import("remark-parse")).default;return t().use(e)})(),kn}function kp(t){let e=t.trim();return e.length===0||e.startsWith("#")||Sp.some(r=>e.startsWith(r))}function wp(t,e){let r=t.match(Cp);return r?r.map(s=>({fromPath:e,toPath:"",rawSpecifier:s,isStyle:!1,type:"static"})):[]}function wn(t,e,r){if(t.type==="link"&&typeof t.url=="string"&&!kp(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(...wp(t.value,e)),Array.isArray(t.children))for(let s of t.children)wn(s,e,r)}async function En(t,e){let s=(await vp()).parse(e),n=[];wn(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 Sp,bp,Cp,kn,Fn=m(()=>{"use strict";c();Sp=["http://","https://","mailto:","//"],bp="ts|tsx|js|jsx|mjs|cjs|py|go|lua|css|scss|less|styl|coffee|ls|feature|md|mdx|json",Cp=new RegExp(`(?:\\.{1,2}/)?[\\w.-]+(?:/[\\w.-]+)*\\.(?:${bp})\\b`,"g")});import Ep from"path";import{parser as Fp}from"@lezer/python";function Pn(t,e){let r=[],s=[],n=new Set,o=Ep.basename(t).toLowerCase(),a=Fp.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 Tp(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=Dp(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 Tp(t,e,r){let s=t.firstChild;return s?s.name==="from"?Np(t,e,r):Ip(t,e,r):[]}function Np(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=Mp(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[me(r,o,i,!0)];let l=a===1?"./":"../".repeat(a-1);return p?[me(r,l+p.replace(/\./g,"/"),i,!1)]:i[0]==="*"?[me(r,l.slice(0,-1),["*"],!1)]:i.map(d=>me(r,l+d,[d],!1))}function Ip(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(me(r,o,["*"],!0))}n=n.nextSibling}return s}function Mp(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 me(t,e,r,s){return{fromPath:t,toPath:"",rawSpecifier:e,isStyle:!1,isExternal:s,type:"static",symbols:r.length>0?r:void 0}}function Dp(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=>Pp.has(s.rawSpecifier))?"test":"logic"}var Pp,Tn=m(()=>{"use strict";c();Pp=new Set(["pytest","unittest","nose","hypothesis"])});import y from"typescript";function Ap(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 Rp(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 ir(t){return{complexity:Ap(t),cognitiveComplexity:Rp(t)}}var Nn=m(()=>{"use strict";c()});import v from"typescript";function In(t,e){Op(t,e),Gp(t,e),jp(t,e),_p(t,e)}function Op(t,e){if((v.isFunctionDeclaration(t)||v.isVariableDeclaration(t))&&t.name&&v.isIdentifier(t.name)&&Lp(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 Lp(t){if(v.isFunctionDeclaration(t))return v.isSourceFile(t.parent);let e=t.parent?.parent;return!!e&&v.isSourceFile(e.parent)}function Gp(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 jp(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 _p(t,e){if(v.isCallExpression(t)&&Wp(t.expression))for(let r of t.arguments)v.isObjectLiteralExpression(r)&&zp(r,e)}function Wp(t){return v.isIdentifier(t)?ar.has(t.text):!!(v.isPropertyAccessExpression(t)&&(ar.has(t.name.text)||v.isIdentifier(t.expression)&&ar.has(t.expression.text)))}function zp(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 ar,Mn=m(()=>{"use strict";c();ar=new Set(["test","describe","it"])});import Dn from"path";import g from"typescript";function cr(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=A=>{Jp(A,a),g.forEachChild(A,p)};p(i);let l=rl(t,a);(l==="test"||l==="barrel")&&o.add({name:l,kind:"comment-marker"}),l!=="test"&&sl(a,i);let d=i.statements[0],h=d?Rn(d):void 0,{complexity:x,cognitiveComplexity:C}=ir(i),N=$p(i);return{imports:s,exports:Array.from(n.values()),tags:Array.from(o),category:l,rawCallEdges:a.rawCallEdges??[],complexity:x,cognitiveComplexity:C,...N.length>0?{functions:N}:{},...h!==void 0?{description:h}:{}}}function $p(t){let e=[],r=(n,o)=>{let{complexity:i,cognitiveComplexity:a}=ir(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 An(t,e,r,s){let n={name:t},o=Rn(r);o!==void 0&&(n.doc=o);let i=Up(e);i!==void 0&&(n.flags=i);let a=Bp(e,s);return a!==void 0&&(n.signature=a),n}function Rn(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 Up(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 Bp(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 Jp(t,e){Kp(t,e),Hp(t,e),Vp(t,e),Xp(t,e),tl(t,e),In(t,e)}function Kp(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)||pr(s)).length}function Hp(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)&&!Qp(t)&&(e.hasTypesOnly=!1)}function Qp(t){return t.isTypeOnly?!0:!t.exportClause||!g.isNamedExports(t.exportClause)?!1:t.exportClause.elements.every(e=>e.isTypeOnly)}function Vp(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:T(t.moduleSpecifier.text),type:s,symbols:r.length>0?r:void 0})}function Xp(t,e){g.isExportDeclaration(t)?qp(t,e):g.isExportAssignment(t)?e.exports.set("default",{name:"default"}):pr(t)&&el(t,e)}function qp(t,e){if(t.moduleSpecifier&&g.isStringLiteral(t.moduleSpecifier))Yp(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 Yp(t,e,r){let s=Zp(t),n={fromPath:r.filePath,toPath:"",rawSpecifier:e,isStyle:T(e),type:"re-export"};s.length>0&&(n.symbols=s),r.imports.push(n)}function Zp(t){return t.exportClause?g.isNamedExports(t.exportClause)?t.exportClause.elements.map(e=>e.name.text):[]:["*"]}function el(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,An(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,An(n,s,t,e.sourceFile))}}}function tl(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:T(r.text),type:"dynamic"}):g.isIdentifier(t.expression)&&t.expression.text==="require"&&e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:r.text,isStyle:T(r.text),type:"require"}))}function rl(t,e){let r=Dn.basename(t).toLowerCase(),s=Dn.extname(t).toLowerCase();return se().some(o=>r.includes(o))?"test":Vr(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>pt()?"barrel":"logic"}function pr(t){return g.canHaveModifiers(t)&&g.getModifiers(t)?.some(e=>e.kind===g.SyntaxKind.ExportKeyword)===!0}function sl(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=ol(n);if(o){let i=il(n);i&&Xe(i,o,s,r);continue}g.isClassDeclaration(n)&&n.name&&nl(n,s,r)}}function nl(t,e,r){let s=t.name.text;for(let n of t.members)g.isMethodDeclaration(n)&&n.body&&g.isIdentifier(n.name)?Xe(n.body,`${s}.${n.name.text}`,e,r):g.isConstructorDeclaration(n)&&n.body&&Xe(n.body,`${s}.constructor`,e,r)}function ol(t){if(pr(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 il(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 Xe(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=>Xe(n,e,r,s))}var On=m(()=>{"use strict";c();$();Nn();G();Mn()});function qe(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 Ln=m(()=>{"use strict";c()});import jn from"postcss";import*as al from"postcss-less";function Gn(t){return t.startsWith("~")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//")||t.startsWith("data:")}function pl(t){let e=t.trim();return e.length>0&&!e.startsWith("http://")&&!e.startsWith("https://")&&!e.startsWith("//")&&!e.startsWith("data:")&&!e.startsWith("#")}function ll(t,e){let r=t.match(/^\(([^)]+)\)\s+['"]([^'"]+)['"]/);if(r){let o=r[1]?.trim()??"",i=r[2]??"";if(!i)return null;let a=_n.has(o)?"side-effect":"static";return{fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:a,...Gn(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",...Gn(n)?{isExternal:!0}:{}}:null}function fl(t,e){let r=[],s=/url\(['"]?([^'")]+)['"]?\)/g,n=s.exec(t);for(;n!==null;){let o=n[1]?.trim()??"";pl(o)&&r.push({fromPath:e,toPath:"",rawSpecifier:o,isStyle:!0,type:"static"}),n=s.exec(t)}return r}function Wn(t,e){let r=[];return t.walk(s=>{if(s.type==="atrule"&&s.name==="import"){let n=ll(s.params,e);n&&r.push(n)}s.type==="decl"&&r.push(...fl(s.value,e))}),r}function ml(t){return t.replace(/(?<!:)\/\/.*/g,"")}function ul(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=_n.has(o)?"side-effect":"static";r.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:a})}n=s.exec(t)}return r}function zn(t,e){let r=jn.parse(ml(t));return{imports:Wn(r,e),root:r}}function $n(t,e){try{let r=cl.parse(t);return{imports:Wn(r,e),root:r}}catch{return{imports:ul(t,e),root:jn.parse("")}}}var cl,_n,Un=m(()=>{"use strict";c();cl=al,_n=new Set(["reference","inline"])});import{parse as gl}from"postcss-scss";function dl(t){return!!(t.startsWith("sass:")||t.startsWith("~")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//")||!t.startsWith(".")&&!t.startsWith("/")&&!t.startsWith("_"))}function hl(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 Bn(t,e){let r=gl(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}=hl(i);if(!a)return;let l={fromPath:e,toPath:"",rawSpecifier:a,isStyle:!0,type:o==="forward"?"re-export":"static",...dl(a)?{isExternal:!0}:{}};p&&(l.symbols=[p]),s.push(l)}),{imports:s,root:r}}var Jn=m(()=>{"use strict";c()});function Kn(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 Hn(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 Qn=m(()=>{"use strict";c()});function ue(t,e){let r=L(t);if(r==="stylus"){let o=Kn(e,t);return{imports:o,exports:[],tags:[],category:Hn(e,o)}}if(r==="scss"){let{imports:o,root:i}=Bn(e,t);return{imports:o,exports:[],tags:[],category:qe(i,o)}}if(r==="less"){let{imports:o,root:i}=$n(e,t);return{imports:o,exports:[],tags:[],category:qe(i,o)}}let{imports:s,root:n}=zn(e,t);return{imports:s,exports:[],tags:[],category:qe(n,s)}}var Vn=m(()=>{"use strict";c();G();Ln();Un();Jn();Qn()});async function Xn(t,e){let r=L(t),s=Ds(r);return s?s(t,e):{imports:[],exports:[],tags:[],category:"other"}}var qn=m(()=>{"use strict";c();G();gn();dn();xn();bn();vn();Fn();Tn();On();le();Vn();$();G();le();for(let[t,e]of[["javascript",(r,s)=>cr(r,s,"javascript")],["typescript",(r,s)=>cr(r,s,"typescript")],["css",ue],["scss",ue],["less",ue],["stylus",ue],["coffeescript",un],["livescript",Sn],["lua",Cn],["python",Pn],["go",yn],["gherkin",sr],["markdown",En]])K(t,e)});import Yn from"path";function eo(t,e){for(let r of t.values()){let s=e.get(r.path);s!==void 0&&(r.coveragePct=s)}}function to(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 ro(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 so(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 Zn(t){return Math.round(t*1e4)/1e4}function no(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=Zn(Math.min(1,o)),r.push(s.exportUsageRatio)}r.length>0&&(e.avgExportUsage=Zn(r.reduce((s,n)=>s+n,0)/r.length),e.maxExportUsage=Math.max(...r))}}function lr(t,e,r){e&&(t.some(s=>s.name===e&&s.kind===r)||t.push({name:e,kind:r}))}function yl(t,e){let r=e.toPath,s=Yn.basename(r,Yn.extname(r)).replace(/\.(test|spec)$/,"");lr(t.tags,s,"import")}function xl(t,e){if(!(!e.symbols||e.symbols.includes("*")))for(let r of e.symbols)lr(t.tags,r,"import")}function Sl(t,e,r){let s=r.get(e.toPath);if(!(!s||s.category==="test"))for(let n of s.tags)n.kind==="comment-marker"&&lr(t.tags,n.name,"comment-marker")}function oo(t){for(let e of t.values())if(e.category==="test")for(let r of e.imports)!r.toPath||r.isExternal||(yl(e,r),xl(e,r),Sl(e,r,t))}var io=m(()=>{"use strict";c()});import po from"fs";import te from"path";function bl(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("=>")){ao(a,e,n);continue}!o&&/^replace\s+/.test(a)&&a.includes("=>")&&ao(a.replace(/^replace\s+/,""),e,n)}return{mod:s,replaces:n}}function ao(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=te.isAbsolute(n)?n:te.resolve(e,n);r.set(o,i)}function co(t){let e;try{e=po.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:te.join(t,s.name),isExternal:!1})).sort((s,n)=>s.path.localeCompare(n.path));return r.length>0?r:null}var ge,lo=m(()=>{"use strict";c();ge=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 co(a);if(r!==o&&!r.startsWith(`${o}/`))return null;let p=r.slice(o.length).replace(/^\//,"");return p?co(te.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=po.readFileSync(te.join(e,"go.mod"),"utf-8"),o=bl(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 te.join(o,i)}}}}});import Cl from"fs";import fr from"path";var de,fo=m(()=>{"use strict";c();de=class{extensions=[".lua"];resolve(e,r,s,n){let o=r.replace(/\./g,fr.sep),i=[s,fr.join(s,"lib")];for(let a of i){if(!Cl.existsSync(a))continue;let p=n(fr.join(a,"_dummy.lua"),o);if(p)return[p]}return null}}});import vl from"path";var he,mo=m(()=>{"use strict";c();he=class{extensions=[".md",".mdx"];resolve(e,r,s,n){let o=n(vl.join(s,"_dummy"),`./${r}`);return o?[o]:null}}});import kl from"fs";import mr from"path";function uo(t){try{return kl.statSync(t,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}var ye,go=m(()=>{"use strict";c();ye=class{extensions=[".py"];resolve(e,r,s,n){let o=r.replace(/\./g,mr.sep),i=mr.join(s,`${o}.py`);if(uo(i))return[{path:i,isExternal:!1}];let a=mr.join(s,o,"__init__.py");return uo(a)?[{path:a,isExternal:!1}]:null}}});import ho from"path";var wl,xe,yo=m(()=>{"use strict";c();wl=["~","http://","https://","//","data:","sass:"],xe=class{extensions=[".css",".scss",".sass",".less",".styl"];resolve(e,r,s,n){if(wl.some(d=>r.startsWith(d)))return null;let o=n(e,r);if(o)return[o];let i=ho.dirname(r),a=ho.basename(r),p=i==="."?`_${a}`:`${i}/_${a}`,l=n(e,p);return l?[l]:null}}});var xo=m(()=>{"use strict";c();lo();fo();mo();go();yo()});import Ye from"fs";import j from"path";var re,ur=m(()=>{"use strict";c();xo();re=class{constructor(e,r={}){this.rootDir=e;this.workspaceMap=r.workspaceMap??new Map,this.tsconfigSearchPaths=r.tsconfigSearchPaths??[e],this.langResolvers=r.langResolvers??[new ye,new de,new ge,new xe,new he]}rootDir;workspaceMap;tsconfigSearchPaths;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=j.dirname(e),n=r.startsWith("/")?r:j.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=j.join(e,`index${r}`);if(this.isFile(o))return{path:o,isExternal:s};if(r===".py"){let i=j.join(e,"__init__.py");if(this.isFile(i))return{path:i,isExternal:s}}return null}isFile(e){try{return Ye.statSync(e,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}resolvePathAlias(e){for(let r of this.tsconfigSearchPaths){let s=j.join(r,"tsconfig.json");if(Ye.existsSync(s))try{let o=JSON.parse(Ye.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=j.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=j.join(s,a);try{if(Ye.statSync(p,{throwIfNoEntry:!1})?.isFile())return{...o,path:p}}catch{}}return{...o,path:s}}let i=this.resolveLocalPath(j.join(s,"_dummy"),n.slice(1));return i?{...o,path:i.path}:null}return null}}});import Se from"fs";import E from"path";import El from"piscina";function Tl(t,e){if(t.length===0)return e;let r=t.map(i=>E.dirname(i).split(E.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(E.sep)||E.sep,o=E.relative(e,n);return o.startsWith("..")||E.isAbsolute(o)?e:n}var Fl,So,Pl,be,bo=m(()=>{"use strict";c();tr();$();fn();qn();io();ie();ur();Fl=["tests","test","__tests__","specs","spec"],So=new Set(["node_modules",".git","dist","build",".next",".cache","mokosh-cache","coverage"]),Pl=20;be=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 re(e),this.lockFile=ln(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;async build(e){let r=e.map(s=>E.isAbsolute(s)?s:E.resolve(this.rootDir,s));await this.initPool();try{for(let s of r)this.enqueue(s);return await this.drain(),await this.processTestFiles(Tl(r,this.rootDir)),await this.processDocFiles(),this.progressCallback&&this.visited.size>=100&&process.stderr.write(`
19
+ `+d}}});import qs from"path";import Ys from"typescript";var Oc,Je,Zs=m(()=>{"use strict";c();Z();Oc=/\/\/ <mokosh-tags>[\s\S]*?\/\/ <\/mokosh-tags>\n*/,Je=class{name="vitest";canHandle(e){return D.has(qs.extname(e).toLowerCase())}apply(e,r,s){let n=r.replace(Oc,""),o=Ys.createSourceFile(qs.basename(e),n,Ys.ScriptTarget.Latest,!0),i=H(o);if(i.length===0)return n;let a=Q(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?X(d,"tags",o):V(d,"tags",Y(p),o);return h?[h]:[]});return l.length>0?q(n,l):n}}});import Xt from"path";import Ke from"typescript";function Gc(t){let e=Ke.createSourceFile("detect.ts",t,Ke.ScriptTarget.Latest,!0);for(let r of e.statements){if(!Ke.isImportDeclaration(r)||!Ke.isStringLiteral(r.moduleSpecifier))continue;let s=Lc[r.moduleSpecifier.text];if(s)return s}return null}function tn(t="vitest",e={},r=process.cwd()){return[new We,new Be,new ze,new qt(r,t,Object.entries(e))]}function rn(t,e){return e.find(r=>r.canHandle(t))??null}var en,Lc,qt,sn=m(()=>{"use strict";c();zs();$s();Bs();Js();Ks();Vs();Xs();Z();Zs();en={vitest:()=>new Je,playwright:()=>new Ue,cypress:()=>new _e,jest:()=>new $e},Lc={"@playwright/test":"playwright",cypress:"cypress","@jest/globals":"jest",vitest:"vitest"};qt=class{constructor(e,r,s){this.rootDir=e;this.defaultFramework=r;this.frameworkOverrides=s}rootDir;defaultFramework;frameworkOverrides;name="auto";canHandle(e){return D.has(Xt.extname(e).toLowerCase())}apply(e,r,s){let n=Gc(r)??this.matchOverride(e)??this.defaultFramework;return(en[n]??en.vitest)().apply(e,r,s)}matchOverride(e){let r=Xt.relative(this.rootDir,e).split(Xt.sep).join("/");for(let[s,n]of this.frameworkOverrides)if(Us(s,r))return n;return null}}});import nn from"fs/promises";import jc from"path";async function $c(t,e,r,s){let n;try{n=await nn.readFile(t,"utf8")}catch(a){return{path:t,status:"error",error:String(a)}}let o=rn(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 nn.writeFile(t,i,"utf8"),{path:t,status:"updated"})}async function Yt(t,e,r){let s=U(e),n=s.tagApplier?.framework??"vitest",o=s.tagApplier?.frameworkOverrides??{},i=tn(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)Wc.has(C.kind)&&_c.test(C.name)&&(zc.has(C.name.toLowerCase())||l.has(C.name)||(l.add(C.name),d.push(C.name)));d.sort();let h=jc.resolve(e,p.path),x=await $c(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 _c,Wc,zc,on=m(()=>{"use strict";c();mt();sn();_c=/^[a-zA-Z][a-zA-Z0-9_-]{1,}$/,Wc=new Set(["import"]),zc=new Set(["common","fixture","fixtures","helper","helpers","index","main","mock","mocks","setup","shared","spec","test","tests","types","util","utils"])});var He,Zt=m(()=>{"use strict";c();He=class{isTestNode(e){return e.category==="test"||e.tags.some(r=>r.name==="test")}}});import{execFileSync as er}from"child_process";function pn(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 ln(t){let e=new Map;try{let r=er("git",["-C",t,"log","--since=90 days ago","--name-status","-M",`--format=${an}`],{encoding:"utf-8",stdio:["ignore","pipe","ignore"],maxBuffer:cn});pn(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=er("git",["-C",t,"log","--name-status","-M",`--format=${an}`],{encoding:"utf-8",stdio:["ignore","pipe","ignore"],maxBuffer:cn});pn(r,(s,n,o)=>{e.has(s)||e.set(s,{commitCount90d:0,lastAuthor:void 0,lastCommitAt:o||void 0})})}catch{}return e}var Qe,an,cn,tr=m(()=>{"use strict";c();Qe=class{getChangedFiles(){try{let r=[["diff","--name-only"],["diff","--cached","--name-only"],["ls-files","--others","--exclude-standard"]].flatMap(s=>{try{return er("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),[]}}},an="%x00%H%x09%ae%x09%at",cn=256*1024*1024});import Ve from"fs";import Uc from"path";import{load as fn}from"js-yaml";function mn(t){let e=t.lastIndexOf("@");return e>0?t.substring(0,e):t}function Bc(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)),mn(r)}).filter(Boolean)}function Jc(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 Kc(t){try{let e=fn(t),r={dependencies:{}};for(let[s,n]of Object.entries(e))if(!(s==="__metadata"||!n?.version))for(let o of s.split(", ")){let i=mn(o);i&&(r.dependencies[i]={version:n.version,...n.dependencies!==void 0&&{dependencies:n.dependencies}})}return r}catch{return null}}function Hc(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=Bc(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 Qc(t){let e=Ve.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 Vc(t){let e=Ve.readFileSync(t,"utf-8");if(e.includes("__metadata:")){let r=Kc(e);if(r!==null)return r}return Hc(e)}function Xc(t){let e=Ve.readFileSync(t,"utf-8"),r={dependencies:{}};try{let s=fn(e);if(s.packages)for(let[n,o]of Object.entries(s.packages)){let{name:i,version:a}=Jc(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 un(t){let e=[["package-lock.json",Qc],["yarn.lock",Vc],["pnpm-lock.yaml",Xc]];for(let[r,s]of e){let n=Uc.join(t,r);if(Ve.existsSync(n))return s(n)}return null}var gn=m(()=>{"use strict";c()});import dn from"path";function L(t){switch(dn.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 T(t){let e=dn.extname(t).toLowerCase();return[".css",".scss",".sass",".less",".styl"].includes(e)}var G=m(()=>{"use strict";c()});import qc from"coffeescript";function Yc(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 Zc(t,e){let r=t.toLowerCase();return r.includes(".test.")||r.includes(".spec.")||e.has("test")?"test":"logic"}function ep(t,e){let r=e.source?.value;return r?{fromPath:t,toPath:"",rawSpecifier:r,isStyle:T(r),type:"static"}:null}function tp(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:T(s),type:"require"}}function rp(t,e,r){let s=e.constructor?.name;if(s==="ImportDeclaration"){let n=ep(t,e);n&&r.push(n)}else if(s==="Call"){let n=tp(t,e);n&&r.push(n)}}function rr(t,e,r){if(!(!e||typeof e!="object")){rp(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)rr(t,o,r);else rr(t,n,r)}}}function hn(t,e){let r=Yc(e),s=Zc(t,r),n=[];try{rr(t,qc.nodes(e),n)}catch{}return{imports:n,exports:[],tags:Array.from(r).map(o=>({name:o,kind:"comment-marker"})),category:s}}var yn=m(()=>{"use strict";c();G()});import{AstBuilder as sp,GherkinClassicTokenMatcher as np,Parser as op}from"@cucumber/gherkin";import{IdGenerator as ip}from"@cucumber/messages";function sr(t,e){let r=new Set;try{let s=new sp(ap),n=new np,i=new op(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 ap,xn=m(()=>{"use strict";c();le();ap=ip.uuid();K("gherkin",sr)});import cp from"path";import{parser as pp}from"@lezer/go";function bn(t,e){let r=[],s=new Map,n=new Set,o=new Set,a=pp.parse(e).cursor();do switch(a.name){case"LineComment":{let h=e.slice(a.from,a.to),x=h.match(lp);x?.[1]&&n.add(x[1]);let C=h.match(fp);C&&Sn(C[1],o);let N=h.match(mp);N&&Sn(N[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=cp.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 Sn(t,e){for(let r of t.split(/[\s,&|!()]+/)){let s=r.trim();s&&s!=="ignore"&&e.add(s)}}var lp,fp,mp,Cn=m(()=>{"use strict";c();lp=/\/\/\s*@tag\s+([a-zA-Z0-9_-]+)/,fp=/^\/\/go:build\s+(.+)$/,mp=/^\/\/\s*\+build\s+(.+)$/});function ee(t){return t.startsWith("'")||t.startsWith('"')?t.slice(1,-1):t}var nr=m(()=>{"use strict";c()});import up from"livescript";function gp(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 dp(t,e){let r=t.toLowerCase();return r.includes(".test.")||r.includes(".spec.")||e.has("test")?"test":"logic"}function yp(t,e){let r=t.constructor?.name||t.type;if(r==="Import"){let s=t.right?.value;if(typeof s=="string"){let n=ee(s);return{fromPath:e,toPath:"",rawSpecifier:n,isStyle:T(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=ee(n);return{fromPath:e,toPath:"",rawSpecifier:o,isStyle:T(o),type:"require"}}}}return null}function or(t,e){if(!t||typeof t!="object")return[];let r=[],s=yp(t,e);s&&r.push(s);for(let n in t){if(hp.has(n))continue;let o=t[n];if(!(!o||typeof o!="object"))if(Array.isArray(o))for(let i of o)r.push(...or(i,e));else r.push(...or(o,e))}return r}function vn(t,e){let r=gp(e),s=dp(t,r),n=[];try{n=or(up.ast(e),t)}catch{}return{imports:n,exports:[],tags:Array.from(r).map(o=>({name:o,kind:"comment-marker"})),category:s}}var hp,kn=m(()=>{"use strict";c();G();nr();hp=new Set(["first_line","first_column","last_line","last_column","line","column"])});import xp from"luaparse";function Sp(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 bp(t,e){let r=t.toLowerCase();return r.includes(".test.")||r.includes(".spec.")||e.has("test")?"test":"logic"}function Cp(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=ee(i.raw))}else if(n.type==="StringCallExpression"){let i=n.argument;i?.type==="StringLiteral"&&(o=ee(i.raw))}o&&r.push({fromPath:e,toPath:"",rawSpecifier:o,isStyle:T(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 wn(t,e){let r=Sp(e),s=bp(t,r),n=[];try{let o=xp.parse(e);n=Cp(o,t)}catch{}return{imports:n,exports:[],tags:Array.from(r).map(o=>({name:o,kind:"comment-marker"})),category:s}}var En=m(()=>{"use strict";c();G();nr()});async function Ep(){return Fn??=(async()=>{let{unified:t}=await import("unified"),e=(await import("remark-parse")).default;return t().use(e)})(),Fn}function Fp(t){let e=t.trim();return e.length===0||e.startsWith("#")||vp.some(r=>e.startsWith(r))}function Pp(t,e){let r=t.match(wp);return r?r.map(s=>({fromPath:e,toPath:"",rawSpecifier:s,isStyle:!1,type:"static"})):[]}function Pn(t,e,r){if(t.type==="link"&&typeof t.url=="string"&&!Fp(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(...Pp(t.value,e)),Array.isArray(t.children))for(let s of t.children)Pn(s,e,r)}async function Tn(t,e){let s=(await Ep()).parse(e),n=[];Pn(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 vp,kp,wp,Fn,Nn=m(()=>{"use strict";c();vp=["http://","https://","mailto:","//"],kp="ts|tsx|js|jsx|mjs|cjs|py|go|lua|css|scss|less|styl|coffee|ls|feature|md|mdx|json",wp=new RegExp(`(?:\\.{1,2}/)?[\\w.-]+(?:/[\\w.-]+)*\\.(?:${kp})\\b`,"g")});import Tp from"path";import{parser as Np}from"@lezer/python";function In(t,e){let r=[],s=[],n=new Set,o=Tp.basename(t).toLowerCase(),a=Np.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 Mp(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=Op(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 Mp(t,e,r){let s=t.firstChild;return s?s.name==="from"?Dp(t,e,r):Ap(t,e,r):[]}function Dp(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=Rp(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[me(r,o,i,!0)];let l=a===1?"./":"../".repeat(a-1);return p?[me(r,l+p.replace(/\./g,"/"),i,!1)]:i[0]==="*"?[me(r,l.slice(0,-1),["*"],!1)]:i.map(d=>me(r,l+d,[d],!1))}function Ap(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(me(r,o,["*"],!0))}n=n.nextSibling}return s}function Rp(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 me(t,e,r,s){return{fromPath:t,toPath:"",rawSpecifier:e,isStyle:!1,isExternal:s,type:"static",symbols:r.length>0?r:void 0}}function Op(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=>Ip.has(s.rawSpecifier))?"test":"logic"}var Ip,Mn=m(()=>{"use strict";c();Ip=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 Gp(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 ir(t){return{complexity:Lp(t),cognitiveComplexity:Gp(t)}}var Dn=m(()=>{"use strict";c()});import v from"typescript";function An(t,e){jp(t,e),Wp(t,e),zp(t,e),$p(t,e)}function jp(t,e){if((v.isFunctionDeclaration(t)||v.isVariableDeclaration(t))&&t.name&&v.isIdentifier(t.name)&&_p(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 _p(t){if(v.isFunctionDeclaration(t))return v.isSourceFile(t.parent);let e=t.parent?.parent;return!!e&&v.isSourceFile(e.parent)}function Wp(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 zp(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 $p(t,e){if(v.isCallExpression(t)&&Up(t.expression))for(let r of t.arguments)v.isObjectLiteralExpression(r)&&Bp(r,e)}function Up(t){return v.isIdentifier(t)?ar.has(t.text):!!(v.isPropertyAccessExpression(t)&&(ar.has(t.name.text)||v.isIdentifier(t.expression)&&ar.has(t.expression.text)))}function Bp(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 ar,Rn=m(()=>{"use strict";c();ar=new Set(["test","describe","it"])});import On from"path";import g from"typescript";function cr(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=A=>{Qp(A,a),g.forEachChild(A,p)};p(i);let l=ol(t,a);(l==="test"||l==="barrel")&&o.add({name:l,kind:"comment-marker"}),l!=="test"&&il(a,i);let d=i.statements[0],h=d?Gn(d):void 0,{complexity:x,cognitiveComplexity:C}=ir(i),N=Jp(i);return{imports:s,exports:Array.from(n.values()),tags:Array.from(o),category:l,rawCallEdges:a.rawCallEdges??[],complexity:x,cognitiveComplexity:C,...N.length>0?{functions:N}:{},...h!==void 0?{description:h}:{}}}function Jp(t){let e=[],r=(n,o)=>{let{complexity:i,cognitiveComplexity:a}=ir(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=Gn(r);o!==void 0&&(n.doc=o);let i=Kp(e);i!==void 0&&(n.flags=i);let a=Hp(e,s);return a!==void 0&&(n.signature=a),n}function Gn(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 Kp(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 Hp(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 Qp(t,e){Vp(t,e),Xp(t,e),Yp(t,e),Zp(t,e),nl(t,e),An(t,e)}function Vp(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)||pr(s)).length}function Xp(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)&&!qp(t)&&(e.hasTypesOnly=!1)}function qp(t){return t.isTypeOnly?!0:!t.exportClause||!g.isNamedExports(t.exportClause)?!1:t.exportClause.elements.every(e=>e.isTypeOnly)}function Yp(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:T(t.moduleSpecifier.text),type:s,symbols:r.length>0?r:void 0})}function Zp(t,e){g.isExportDeclaration(t)?el(t,e):g.isExportAssignment(t)?e.exports.set("default",{name:"default"}):pr(t)&&sl(t,e)}function el(t,e){if(t.moduleSpecifier&&g.isStringLiteral(t.moduleSpecifier))tl(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 tl(t,e,r){let s=rl(t),n={fromPath:r.filePath,toPath:"",rawSpecifier:e,isStyle:T(e),type:"re-export"};s.length>0&&(n.symbols=s),r.imports.push(n)}function rl(t){return t.exportClause?g.isNamedExports(t.exportClause)?t.exportClause.elements.map(e=>e.name.text):[]:["*"]}function sl(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 nl(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:T(r.text),type:"dynamic"}):g.isIdentifier(t.expression)&&t.expression.text==="require"&&e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:r.text,isStyle:T(r.text),type:"require"}))}function ol(t,e){let r=On.basename(t).toLowerCase(),s=On.extname(t).toLowerCase();return se().some(o=>r.includes(o))?"test":Vr(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>pt()?"barrel":"logic"}function pr(t){return g.canHaveModifiers(t)&&g.getModifiers(t)?.some(e=>e.kind===g.SyntaxKind.ExportKeyword)===!0}function il(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=cl(n);if(o){let i=pl(n);i&&Xe(i,o,s,r);continue}g.isClassDeclaration(n)&&n.name&&al(n,s,r)}}function al(t,e,r){let s=t.name.text;for(let n of t.members)g.isMethodDeclaration(n)&&n.body&&g.isIdentifier(n.name)?Xe(n.body,`${s}.${n.name.text}`,e,r):g.isConstructorDeclaration(n)&&n.body&&Xe(n.body,`${s}.constructor`,e,r)}function cl(t){if(pr(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 pl(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 Xe(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=>Xe(n,e,r,s))}var jn=m(()=>{"use strict";c();$();Dn();G();Rn()});function qe(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 _n=m(()=>{"use strict";c()});import zn from"postcss";import*as ll from"postcss-less";function Wn(t){return t.startsWith("~")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//")||t.startsWith("data:")}function ml(t){let e=t.trim();return e.length>0&&!e.startsWith("http://")&&!e.startsWith("https://")&&!e.startsWith("//")&&!e.startsWith("data:")&&!e.startsWith("#")}function ul(t,e){let r=t.match(/^\(([^)]+)\)\s+['"]([^'"]+)['"]/);if(r){let o=r[1]?.trim()??"",i=r[2]??"";if(!i)return null;let a=$n.has(o)?"side-effect":"static";return{fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:a,...Wn(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",...Wn(n)?{isExternal:!0}:{}}:null}function gl(t,e){let r=[],s=/url\(['"]?([^'")]+)['"]?\)/g,n=s.exec(t);for(;n!==null;){let o=n[1]?.trim()??"";ml(o)&&r.push({fromPath:e,toPath:"",rawSpecifier:o,isStyle:!0,type:"static"}),n=s.exec(t)}return r}function Un(t,e){let r=[];return t.walk(s=>{if(s.type==="atrule"&&s.name==="import"){let n=ul(s.params,e);n&&r.push(n)}s.type==="decl"&&r.push(...gl(s.value,e))}),r}function dl(t){return t.replace(/(?<!:)\/\/.*/g,"")}function hl(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=$n.has(o)?"side-effect":"static";r.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:a})}n=s.exec(t)}return r}function Bn(t,e){let r=zn.parse(dl(t));return{imports:Un(r,e),root:r}}function Jn(t,e){try{let r=fl.parse(t);return{imports:Un(r,e),root:r}}catch{return{imports:hl(t,e),root:zn.parse("")}}}var fl,$n,Kn=m(()=>{"use strict";c();fl=ll,$n=new Set(["reference","inline"])});import{parse as yl}from"postcss-scss";function xl(t){return!!(t.startsWith("sass:")||t.startsWith("~")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//")||!t.startsWith(".")&&!t.startsWith("/")&&!t.startsWith("_"))}function Sl(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 Hn(t,e){let r=yl(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}=Sl(i);if(!a)return;let l={fromPath:e,toPath:"",rawSpecifier:a,isStyle:!0,type:o==="forward"?"re-export":"static",...xl(a)?{isExternal:!0}:{}};p&&(l.symbols=[p]),s.push(l)}),{imports:s,root:r}}var Qn=m(()=>{"use strict";c()});function Vn(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 Xn(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 qn=m(()=>{"use strict";c()});function ue(t,e){let r=L(t);if(r==="stylus"){let o=Vn(e,t);return{imports:o,exports:[],tags:[],category:Xn(e,o)}}if(r==="scss"){let{imports:o,root:i}=Hn(e,t);return{imports:o,exports:[],tags:[],category:qe(i,o)}}if(r==="less"){let{imports:o,root:i}=Jn(e,t);return{imports:o,exports:[],tags:[],category:qe(i,o)}}let{imports:s,root:n}=Bn(e,t);return{imports:s,exports:[],tags:[],category:qe(n,s)}}var Yn=m(()=>{"use strict";c();G();_n();Kn();Qn();qn()});async function Zn(t,e){let r=L(t),s=Ds(r);return s?s(t,e):{imports:[],exports:[],tags:[],category:"other"}}var eo=m(()=>{"use strict";c();G();yn();xn();Cn();kn();En();Nn();Mn();jn();le();Yn();$();G();le();for(let[t,e]of[["javascript",(r,s)=>cr(r,s,"javascript")],["typescript",(r,s)=>cr(r,s,"typescript")],["css",ue],["scss",ue],["less",ue],["stylus",ue],["coffeescript",hn],["livescript",vn],["lua",wn],["python",In],["go",bn],["gherkin",sr],["markdown",Tn]])K(t,e)});import to from"path";function so(t,e){for(let r of t.values()){let s=e.get(r.path);s!==void 0&&(r.coveragePct=s)}}function no(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 oo(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 io(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 ro(t){return Math.round(t*1e4)/1e4}function ao(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=ro(Math.min(1,o)),r.push(s.exportUsageRatio)}r.length>0&&(e.avgExportUsage=ro(r.reduce((s,n)=>s+n,0)/r.length),e.maxExportUsage=Math.max(...r))}}function lr(t,e,r){e&&(t.some(s=>s.name===e&&s.kind===r)||t.push({name:e,kind:r}))}function bl(t,e){let r=e.toPath,s=to.basename(r,to.extname(r)).replace(/\.(test|spec)$/,"");lr(t.tags,s,"import")}function Cl(t,e){if(!(!e.symbols||e.symbols.includes("*")))for(let r of e.symbols)lr(t.tags,r,"import")}function vl(t,e,r){let s=r.get(e.toPath);if(!(!s||s.category==="test"))for(let n of s.tags)n.kind==="comment-marker"&&lr(t.tags,n.name,"comment-marker")}function co(t){for(let e of t.values())if(e.category==="test")for(let r of e.imports)!r.toPath||r.isExternal||(bl(e,r),Cl(e,r),vl(e,r,t))}var po=m(()=>{"use strict";c()});import mo from"fs";import te from"path";function kl(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("=>")){lo(a,e,n);continue}!o&&/^replace\s+/.test(a)&&a.includes("=>")&&lo(a.replace(/^replace\s+/,""),e,n)}return{mod:s,replaces:n}}function lo(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=te.isAbsolute(n)?n:te.resolve(e,n);r.set(o,i)}function fo(t){let e;try{e=mo.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:te.join(t,s.name),isExternal:!1})).sort((s,n)=>s.path.localeCompare(n.path));return r.length>0?r:null}var ge,uo=m(()=>{"use strict";c();ge=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 fo(a);if(r!==o&&!r.startsWith(`${o}/`))return null;let p=r.slice(o.length).replace(/^\//,"");return p?fo(te.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=mo.readFileSync(te.join(e,"go.mod"),"utf-8"),o=kl(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 te.join(o,i)}}}}});import wl from"fs";import fr from"path";var de,go=m(()=>{"use strict";c();de=class{extensions=[".lua"];resolve(e,r,s,n){let o=r.replace(/\./g,fr.sep),i=[s,fr.join(s,"lib")];for(let a of i){if(!wl.existsSync(a))continue;let p=n(fr.join(a,"_dummy.lua"),o);if(p)return[p]}return null}}});import El from"path";var he,ho=m(()=>{"use strict";c();he=class{extensions=[".md",".mdx"];resolve(e,r,s,n){let o=n(El.join(s,"_dummy"),`./${r}`);return o?[o]:null}}});import Fl from"fs";import mr from"path";function yo(t){try{return Fl.statSync(t,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}var ye,xo=m(()=>{"use strict";c();ye=class{extensions=[".py"];resolve(e,r,s,n){let o=r.replace(/\./g,mr.sep),i=mr.join(s,`${o}.py`);if(yo(i))return[{path:i,isExternal:!1}];let a=mr.join(s,o,"__init__.py");return yo(a)?[{path:a,isExternal:!1}]:null}}});import So from"path";var Pl,xe,bo=m(()=>{"use strict";c();Pl=["~","http://","https://","//","data:","sass:"],xe=class{extensions=[".css",".scss",".sass",".less",".styl"];resolve(e,r,s,n){if(Pl.some(d=>r.startsWith(d)))return null;let o=n(e,r);if(o)return[o];let i=So.dirname(r),a=So.basename(r),p=i==="."?`_${a}`:`${i}/_${a}`,l=n(e,p);return l?[l]:null}}});var Co=m(()=>{"use strict";c();uo();go();ho();xo();bo()});import Ye from"fs";import j from"path";var re,ur=m(()=>{"use strict";c();Co();re=class{constructor(e,r={}){this.rootDir=e;this.workspaceMap=r.workspaceMap??new Map,this.tsconfigSearchPaths=r.tsconfigSearchPaths??[e],this.langResolvers=r.langResolvers??[new ye,new de,new ge,new xe,new he]}rootDir;workspaceMap;tsconfigSearchPaths;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=j.dirname(e),n=r.startsWith("/")?r:j.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=j.join(e,`index${r}`);if(this.isFile(o))return{path:o,isExternal:s};if(r===".py"){let i=j.join(e,"__init__.py");if(this.isFile(i))return{path:i,isExternal:s}}return null}isFile(e){try{return Ye.statSync(e,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}resolvePathAlias(e){for(let r of this.tsconfigSearchPaths){let s=j.join(r,"tsconfig.json");if(Ye.existsSync(s))try{let o=JSON.parse(Ye.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=j.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=j.join(s,a);try{if(Ye.statSync(p,{throwIfNoEntry:!1})?.isFile())return{...o,path:p}}catch{}}return{...o,path:s}}let i=this.resolveLocalPath(j.join(s,"_dummy"),n.slice(1));return i?{...o,path:i.path}:null}return null}}});import Se from"fs";import E from"path";import Tl from"piscina";function Ml(t,e){if(t.length===0)return e;let r=t.map(i=>E.dirname(i).split(E.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(E.sep)||E.sep,o=E.relative(e,n);return o.startsWith("..")||E.isAbsolute(o)?e:n}var Nl,vo,Il,be,ko=m(()=>{"use strict";c();tr();$();gn();eo();po();ie();ur();Nl=["tests","test","__tests__","specs","spec"],vo=new Set(["node_modules",".git","dist","build",".next",".cache","mokosh-cache","coverage"]),Il=20;be=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 re(e),this.lockFile=un(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=>E.isAbsolute(s)?s:E.resolve(this.rootDir,s));await this.initPool(),this.enableGitStats&&(this.gitStatsMap=ln(this.rootDir));try{for(let s of r)this.enqueue(s);return await this.drain(),await this.processTestFiles(Ml(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
- `),oo(this.graph.nodes),ro(this.graph.nodes),no(this.graph.nodes),so(this.graph.nodes),this.coverageMap.size>0&&eo(this.graph.nodes,this.coverageMap),new F(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??Pl;if(!(r>0&&!this.hasAtLeastFiles(this.rootDir,r)))try{let s=E.join(f,"parse-worker.js");this.pool=new El({filename:s,...e.maxThreads!==void 0?{maxThreads:e.maxThreads}:{}})}catch(s){process.stderr.write(`
25
+ `),co(this.graph.nodes),oo(this.graph.nodes),ao(this.graph.nodes),io(this.graph.nodes),this.coverageMap.size>0&&so(this.graph.nodes,this.coverageMap),new F(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??Il;if(!(r>0&&!this.hasAtLeastFiles(this.rootDir,r)))try{let s=E.join(f,"parse-worker.js");this.pool=new Tl({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=Se.readdirSync(o,{withFileTypes:!0})}catch{continue}for(let a of i)if(a.isDirectory())So.has(a.name)||n.push(E.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=E.dirname(n);if(o===n)break;for(let i of Fl){let a=E.join(o,i);try{Se.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=Se.readdirSync(e,{withFileTypes:!0})}catch{return}for(let n of s){let o=E.join(e,n.name);n.isDirectory()?So.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=Se.statSync(e,{throwIfNoEntry:!1});if(!r?.isFile())return;let s=E.relative(this.rootDir,e),n=await this.getNode(e,s,r);n.imports=await this.resolveImports(e,n.imports),to(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=Se.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=Se.readdirSync(o,{withFileTypes:!0})}catch{continue}for(let a of i)if(a.isDirectory())vo.has(a.name)||n.push(E.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=E.dirname(n);if(o===n)break;for(let i of Nl){let a=E.join(o,i);try{Se.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=Se.readdirSync(e,{withFileTypes:!0})}catch{return}for(let n of s){let o=E.join(e,n.name);n.isDirectory()?vo.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=Se.statSync(e,{throwIfNoEntry:!1});if(!r?.isFile())return;let s=E.relative(this.rootDir,e),n=await this.getNode(e,s,r);n.imports=await this.resolveImports(e,n.imports),no(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=Se.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}):Xn(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:E.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){if(this.enableGitStats)try{let s=an(this.rootDir,r);e.commitCount90d=s.commitCount90d,s.lastAuthor!==void 0&&(e.lastAuthor=s.lastAuthor),s.lastCommitAt!==void 0&&(e.lastCommitAt=s.lastCommitAt)}catch{}}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:E.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 Co=m(()=>{"use strict";c();St();bo();Ct();wt();Ie();Me();ie();ur();Rt();De();Gt();$t();Ut()});var gr=m(()=>{"use strict";c();Co()});function vo(t,e){return{identifier:e?.identifier??new He,featureMap:e?.featureDetection===!1?new Map:_(t.nodes,e?.featureDetection??void 0)}}function ko(t,e,r,s,n){for(let o of e){let i=t.nodes.get(o);if(!i)continue;let a=new W(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 dr(t,e,r){let{identifier:s,featureMap:n}=vo(t,r),o=new Set;for(let i of e){let a=n.get(i);a&&o.add(a.tag)}return ko(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 hr(t,e,r){let{identifier:s,featureMap:n}=vo(t,r),o=new Set;return ko(t,e,n,()=>{},i=>{s.isTestNode(i)&&o.add(i.path)}),Array.from(o)}var wo=m(()=>{"use strict";c();gr();Zt()});var Eo=m(()=>{"use strict";c();on();Zt();wo()});import Nl from"fs";import Ce from"path";async function I(t,e,r=null,s={}){let n=s.silent?void 0:i=>{process.stderr.write(`Processed ${i} files...\r`)};return await new be(Ce.resolve(t),r,void 0,n,s.gitStats??!1,s.coverageMap??new Map,s.parallelParsing??!0).build(e)}async function Fo(t,e={}){let r=Ce.resolve(t),s=zt(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 p=e.silent?void 0:h=>{process.stderr.write(`[${a.name}] Processed ${h} files...\r`)},d=await new be(r,null,new re(r,{workspaceMap:o,tsconfigSearchPaths:[a.root,r]}),p,e.gitStats??!1,new Map,e.parallelParsing??!0).build(a.entryPoints);i.addPackage(a,d)}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=Nl.readdirSync(i,{withFileTypes:!0});for(let p of a){let l=Ce.join(i,p.name);p.isDirectory()?s.has(p.name)||o(l):p.isFile()&&n.has(Ce.extname(p.name).toLowerCase())&&r.push(Ce.relative(t,l))}}catch{}}return o(t),r}var b=m(()=>{"use strict";c();mt();dt();rs();ns();St();Ct();wt();Ie();Me();ie();ps();Rt();De();Gt();$t();Le();Ut();$();le();Gs();Eo();dt();gr()});var Po,To,No=m(()=>{"use strict";c();Po="mokosh-cache",To="graph.json"});import ve from"path";import{parseArgs as Il}from"util";function Ml(t){for(let e=0;e<t.length;e++)if(t[e]==="--root"&&t[e+1])return ve.resolve(t[e+1]);return process.cwd()}function Al(t){let e=[];for(let r=0;r<t.length;r++){let s=t[r];if(!s.startsWith("--"))e.push(s);else if(Dl.has(s)){let n=t[r+1];n!==void 0&&!n.startsWith("--")&&(e.push(s,n),r++)}else s.slice(2)in yr&&e.push(s)}return e}function Io(t){let e=Ml(t),r=ve.join(ve.resolve(e,Po),To),{values:s,positionals:n}=Il({args:Al(t),allowPositionals:!0,options:yr}),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,N=s.metric;return{rootDir:e,cachePath:p?ve.resolve(e,p):r,configPath:l?ve.resolve(e,l):void 0,query:s.query,file:s.file,typeFilter:s.type,functionName:s.function,filterPaths:a?a.split(",").map(A=>A.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(A=>A.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:N==="complexity"||N==="cognitiveComplexity"?N: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 yr,Dl,Mo=m(()=>{"use strict";c();No();yr={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"}},Dl=new Set(Object.entries(yr).filter(([,t])=>t.type==="string").map(([t])=>`--${t}`))});async function xr(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=vt(e),p=kt(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=Pt(e,r,{testsOnly:s,changedSymbols:n});console.log(JSON.stringify({file:r,affected:i,count:i.length},null,2))}var Do=m(()=>{"use strict";c();b()});import Sr from"path";function z(t){return t.filter(e=>{let r=Sr.basename(e).toLowerCase();return Rl.some(s=>r.includes(s))})}function Ze(t){return new Qe().getChangedFiles().map(e=>Sr.relative(t,Sr.resolve(t,e)))}var Rl,et=m(()=>{"use strict";c();tr();Rl=[".test.",".spec.","-test.","-spec."]});async function Ao(t){let{graph:e}=t,{rootDir:r,scanOptions:s,featureThreshold:n}=t,o=Ze(r);if(![...e.nodes.values()].some(p=>z([p.path]).length>0)){let p=M(r,s);e=await I(r,z(p),e)}let a=hr(e,o,{...n!==void 0&&{featureDetection:{minOutDegree:n}}});console.log(a.join(`
30
- `))}var Ro=m(()=>{"use strict";c();b();et()});async function Oo(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 Lo=m(()=>{"use strict";c();b()});async function Go(t){let{graph:e}=t,{rootDir:r,scanOptions:s,dryRun:n,plain:o}=t;if(o||console.log(n?"Dry run: computing tag changes...":"Applying tags to test files..."),e.nodes.size===0){let a=M(r,s);e=await I(r,z(a),e)}let i=await Yt(e,r,{dryRun:n});console.log(JSON.stringify(i,null,2))}var jo=m(()=>{"use strict";c();b();et()});async function _o(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 Wo=m(()=>{"use strict";c();b()});async function br(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=Tt(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 zo=m(()=>{"use strict";c();b()});async function Cr(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}):Zn(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:E.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:E.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 wo=m(()=>{"use strict";c();St();ko();Ct();wt();Ie();Me();ie();ur();Rt();De();Gt();$t();Ut()});var gr=m(()=>{"use strict";c();wo()});function Eo(t,e){return{identifier:e?.identifier??new He,featureMap:e?.featureDetection===!1?new Map:_(t.nodes,e?.featureDetection??void 0)}}function Fo(t,e,r,s,n){for(let o of e){let i=t.nodes.get(o);if(!i)continue;let a=new W(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 dr(t,e,r){let{identifier:s,featureMap:n}=Eo(t,r),o=new Set;for(let i of e){let a=n.get(i);a&&o.add(a.tag)}return Fo(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 hr(t,e,r){let{identifier:s,featureMap:n}=Eo(t,r),o=new Set;return Fo(t,e,n,()=>{},i=>{s.isTestNode(i)&&o.add(i.path)}),Array.from(o)}var Po=m(()=>{"use strict";c();gr();Zt()});var To=m(()=>{"use strict";c();on();Zt();Po()});import Dl from"fs";import Ce from"path";async function I(t,e,r=null,s={}){let n=s.silent?void 0:i=>{process.stderr.write(`Processed ${i} files...\r`)};return await new be(Ce.resolve(t),r,void 0,n,s.gitStats??!1,s.coverageMap??new Map,s.parallelParsing??!0).build(e)}async function No(t,e={}){let r=Ce.resolve(t),s=zt(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 p=e.silent?void 0:h=>{process.stderr.write(`[${a.name}] Processed ${h} files...\r`)},d=await new be(r,null,new re(r,{workspaceMap:o,tsconfigSearchPaths:[a.root,r]}),p,e.gitStats??!1,new Map,e.parallelParsing??!0).build(a.entryPoints);i.addPackage(a,d)}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=Dl.readdirSync(i,{withFileTypes:!0});for(let p of a){let l=Ce.join(i,p.name);p.isDirectory()?s.has(p.name)||o(l):p.isFile()&&n.has(Ce.extname(p.name).toLowerCase())&&r.push(Ce.relative(t,l))}}catch{}}return o(t),r}var b=m(()=>{"use strict";c();mt();dt();rs();ns();St();Ct();wt();Ie();Me();ie();ps();Rt();De();Gt();$t();Le();Ut();$();le();Gs();To();dt();gr()});var Io,Mo,Do=m(()=>{"use strict";c();Io="mokosh-cache",Mo="graph.json"});import ve from"path";import{parseArgs as Al}from"util";function Rl(t){for(let e=0;e<t.length;e++)if(t[e]==="--root"&&t[e+1])return ve.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(Ol.has(s)){let n=t[r+1];n!==void 0&&!n.startsWith("--")&&(e.push(s,n),r++)}else s.slice(2)in yr&&e.push(s)}return e}function Ao(t){let e=Rl(t),r=ve.join(ve.resolve(e,Io),Mo),{values:s,positionals:n}=Al({args:Ll(t),allowPositionals:!0,options:yr}),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,N=s.metric;return{rootDir:e,cachePath:p?ve.resolve(e,p):r,configPath:l?ve.resolve(e,l):void 0,query:s.query,file:s.file,typeFilter:s.type,functionName:s.function,filterPaths:a?a.split(",").map(A=>A.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(A=>A.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:N==="complexity"||N==="cognitiveComplexity"?N: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 yr,Ol,Ro=m(()=>{"use strict";c();Do();yr={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"}},Ol=new Set(Object.entries(yr).filter(([,t])=>t.type==="string").map(([t])=>`--${t}`))});async function xr(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=vt(e),p=kt(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=Pt(e,r,{testsOnly:s,changedSymbols:n});console.log(JSON.stringify({file:r,affected:i,count:i.length},null,2))}var Oo=m(()=>{"use strict";c();b()});import Sr from"path";function z(t){return t.filter(e=>{let r=Sr.basename(e).toLowerCase();return Gl.some(s=>r.includes(s))})}function Ze(t){return new Qe().getChangedFiles().map(e=>Sr.relative(t,Sr.resolve(t,e)))}var Gl,et=m(()=>{"use strict";c();tr();Gl=[".test.",".spec.","-test.","-spec."]});async function Lo(t){let{graph:e}=t,{rootDir:r,scanOptions:s,featureThreshold:n}=t,o=Ze(r);if(![...e.nodes.values()].some(p=>z([p.path]).length>0)){let p=M(r,s);e=await I(r,z(p),e)}let a=hr(e,o,{...n!==void 0&&{featureDetection:{minOutDegree:n}}});console.log(a.join(`
30
+ `))}var Go=m(()=>{"use strict";c();b();et()});async function jo(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 _o=m(()=>{"use strict";c();b()});async function Wo(t){let{graph:e}=t,{rootDir:r,scanOptions:s,dryRun:n,plain:o}=t;if(o||console.log(n?"Dry run: computing tag changes...":"Applying tags to test files..."),e.nodes.size===0){let a=M(r,s);e=await I(r,z(a),e)}let i=await Yt(e,r,{dryRun:n});console.log(JSON.stringify(i,null,2))}var zo=m(()=>{"use strict";c();b();et()});async function $o(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 Uo=m(()=>{"use strict";c();b()});async function br(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=Tt(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 Bo=m(()=>{"use strict";c();b()});async function Cr(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 $o=m(()=>{"use strict";c()});async function vr(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 Jo=m(()=>{"use strict";c()});async function vr(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 Uo=m(()=>{"use strict";c()});import Bo from"fs";function Jo(t){Bo.existsSync(t)?(Bo.unlinkSync(t),console.log(`Cache cleared: ${t}`)):console.log(`No cache file present at ${t}`)}var Ko=m(()=>{"use strict";c()});async function kr(t){let{graph:e,file:r,depth:s}=t;r||(console.error("Error: --dependencies requires --file <path>"),process.exit(1));let n=Et(e,r,s??1);console.log(JSON.stringify({file:r,dependencies:n},null,2))}var Ho=m(()=>{"use strict";c();b()});async function wr(t){let{graph:e,file:r}=t;r||(console.error("Error: --dependents requires --file <path>"),process.exit(1));let s=Ft(e,r);console.log(JSON.stringify({file:r,dependents:s},null,2))}var Qo=m(()=>{"use strict";c();b()});async function Vo(t){let{graph:e}=t,{rootDir:r,scanOptions:s,featureThreshold:n}=t;if(e.nodes.size===0){let a=M(r,s);e=await I(r,a,e)}let o=_(e.nodes,n!==void 0?{minOutDegree:n}:void 0),i=Array.from(o.values()).sort((a,p)=>p.outDegree-a.outDegree);console.log(JSON.stringify({features:i},null,2))}var Xo=m(()=>{"use strict";c();b()});async function qo(t){let{graph:e}=t,{rootDir:r,scanOptions:s,minOutDegree:n}=t;if(e.nodes.size===0){let a=M(r,s);e=await I(r,a,e)}let o=ne(e,n!==void 0?{minOutDegree:n}:void 0),i=Object.fromEntries(o.features);console.log(JSON.stringify({features:i,unassigned:o.unassigned},null,2))}var Yo=m(()=>{"use strict";c();b()});async function Er(t){let{graph:e,metric:r,complexityThreshold:s,limit:n}=t,o=s??10,i=Nt(e,{metric:r,threshold:o,limit:n});console.log(JSON.stringify({metric:r??"cognitiveComplexity",threshold:o,functions:i,count:i.length},null,2))}var Zo=m(()=>{"use strict";c();b()});async function Fr(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(`
36
- `):JSON.stringify({threshold:o,uncovered:i,count:i.length},null,2))}var ei=m(()=>{"use strict";c();b()});import Ol from"path";function Gl(t){let e=Ol.basename(t).toLowerCase();return Ll.some(r=>e.includes(r))}async function ti(t){let{graph:e,rootDir:r,scanOptions:s,excludeTests:n}=t,o=M(r,s),i=e.findUnusedFiles(o);n&&(i=i.filter(a=>!Gl(a))),console.log(JSON.stringify({unusedFiles:i},null,2))}var Ll,ri=m(()=>{"use strict";c();b();Ll=[".test.",".spec.","-test.","-spec.",".stories."]});async function Pr(t){let{graph:e,queryStr:r,mermaidOutput:s,slim:n}=t,o=e.serialize();if(r){let a=je(r);o=Ge(o,a)}if(s){let a=F.deserialize(o);console.log(Te.serialize(a));return}let i=e.findCycles();i.length>0&&(o.cycles=i),console.log(JSON.stringify(n?It(o):o,null,2))}var si=m(()=>{"use strict";c();b()});import jl from"fs";import Tr from"path";function tt(t,e,r){let s=t;for(let n=0;n<6;n++){let o=Tr.join(s,"templates",...e);if(jl.existsSync(Tr.join(o,r)))return o;let i=Tr.dirname(s);if(i===s)break;s=i}throw new Error(`Could not locate mokosh templates/${e.join("/")}`)}var Nr=m(()=>{"use strict";c()});import ni from"fs";import oi from"path";function ii(t,e=process.cwd()){let r=tt(f,["config"],"mokosh.config.js"),s=oi.join(r,"mokosh.config.js"),n=oi.join(e,"mokosh.config.js");if(ni.existsSync(n)&&!t){console.log("skipped mokosh.config.js (already exists, use --force to overwrite)");return}ni.copyFileSync(s,n),console.log("wrote mokosh.config.js")}var ai=m(()=>{"use strict";c();Nr()});import Ir from"fs";import rt from"path";function ci(t,e=process.cwd()){let r=tt(f,["skill"],"SKILL.md");for(let s of _l){let n=rt.join(r,s.templateFile),o=rt.join(e,...s.destPath),i=rt.join(...s.destPath);if(Ir.existsSync(o)&&!t){console.log(`skipped ${i} (already exists, use --force to overwrite)`);continue}Ir.mkdirSync(rt.dirname(o),{recursive:!0}),Ir.copyFileSync(n,o),console.log(`wrote ${i}`)}}var _l,pi=m(()=>{"use strict";c();Nr();_l=[{templateFile:"SKILL.md",destPath:[".claude","skills","mokosh","SKILL.md"]},{templateFile:"mokosh.md",destPath:[".claude","commands","mokosh.md"]}]});async function li(t){let{graph:e,filterPaths:r,minOutDegree:s}=t,n=At(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 fi=m(()=>{"use strict";c();b()});async function mi(t){let{graph:e}=t,{rootDir:r,scanOptions:s,featureThreshold:n,plain:o}=t;o||console.log("Proposing test tags based on git diff...");let i=Ze(r);if(e.nodes.size===0){let p=M(r,s);e=await I(r,z(p),e)}let a=dr(e,i,{...n!==void 0&&{featureDetection:{minOutDegree:n}}});console.log(o?a.join(" "):JSON.stringify({proposedTags:a},null,2))}var ui=m(()=>{"use strict";c();b();et()});async function gi(t){let{graph:e,typeFilter:r}=t,s=Ot(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 di=m(()=>{"use strict";c();b()});function hi(t,e){let r=t.getAffectedAcrossPackages(e);console.log(JSON.stringify({file:e,affected:r,count:r.length},null,2))}var yi=m(()=>{"use strict";c()});function xi(t){console.log(JSON.stringify(Mt(t),null,2))}var Si=m(()=>{"use strict";c();b()});import Mr from"path";function bi(t){let{rootDir:e,entryPoints:r,cachePath:s,configPath:n}=t,o=n?U(n,{isExplicitPath:!0}):U(e),i=Mr.join(Mr.resolve(e,"mokosh-cache"),"graph.json"),a=r.length>0?r:o.entryPoints??[],p=s!==i?s??i:o.cachePath?Mr.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 Ci=m(()=>{"use strict";c();b()});import ke from"fs";import Wl from"path";function vi(t){if(!ke.existsSync(t))return null;let e=ke.readFileSync(t,"utf-8");return F.deserialize(JSON.parse(e))}function Dr(t,e){let r=Wl.dirname(e);ke.existsSync(r)||ke.mkdirSync(r,{recursive:!0}),ke.writeFileSync(e,JSON.stringify(t.serialize(),null,2))}async function Ar(t,e,r,s=!1,n=!1,o){return I(t,e,r,{silent:s,gitStats:n,parallelParsing:o})}var ki=m(()=>{"use strict";c();b()});var wi,Ei,Fi=m(()=>{"use strict";c();wi=`
35
+ `);process.exit(1)}console.log("No doc drift detected.")}var Ko=m(()=>{"use strict";c()});import Ho from"fs";function Qo(t){Ho.existsSync(t)?(Ho.unlinkSync(t),console.log(`Cache cleared: ${t}`)):console.log(`No cache file present at ${t}`)}var Vo=m(()=>{"use strict";c()});async function kr(t){let{graph:e,file:r,depth:s}=t;r||(console.error("Error: --dependencies requires --file <path>"),process.exit(1));let n=Et(e,r,s??1);console.log(JSON.stringify({file:r,dependencies:n},null,2))}var Xo=m(()=>{"use strict";c();b()});async function wr(t){let{graph:e,file:r}=t;r||(console.error("Error: --dependents requires --file <path>"),process.exit(1));let s=Ft(e,r);console.log(JSON.stringify({file:r,dependents:s},null,2))}var qo=m(()=>{"use strict";c();b()});async function Yo(t){let{graph:e}=t,{rootDir:r,scanOptions:s,featureThreshold:n}=t;if(e.nodes.size===0){let a=M(r,s);e=await I(r,a,e)}let o=_(e.nodes,n!==void 0?{minOutDegree:n}:void 0),i=Array.from(o.values()).sort((a,p)=>p.outDegree-a.outDegree);console.log(JSON.stringify({features:i},null,2))}var Zo=m(()=>{"use strict";c();b()});async function ei(t){let{graph:e}=t,{rootDir:r,scanOptions:s,minOutDegree:n}=t;if(e.nodes.size===0){let a=M(r,s);e=await I(r,a,e)}let o=ne(e,n!==void 0?{minOutDegree:n}:void 0),i=Object.fromEntries(o.features);console.log(JSON.stringify({features:i,unassigned:o.unassigned},null,2))}var ti=m(()=>{"use strict";c();b()});async function Er(t){let{graph:e,metric:r,complexityThreshold:s,limit:n}=t,o=s??10,i=Nt(e,{metric:r,threshold:o,limit:n});console.log(JSON.stringify({metric:r??"cognitiveComplexity",threshold:o,functions:i,count:i.length},null,2))}var ri=m(()=>{"use strict";c();b()});async function Fr(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(`
36
+ `):JSON.stringify({threshold:o,uncovered:i,count:i.length},null,2))}var si=m(()=>{"use strict";c();b()});import jl from"path";function Wl(t){let e=jl.basename(t).toLowerCase();return _l.some(r=>e.includes(r))}async function ni(t){let{graph:e,rootDir:r,scanOptions:s,excludeTests:n}=t,o=M(r,s),i=e.findUnusedFiles(o);n&&(i=i.filter(a=>!Wl(a))),console.log(JSON.stringify({unusedFiles:i},null,2))}var _l,oi=m(()=>{"use strict";c();b();_l=[".test.",".spec.","-test.","-spec.",".stories."]});async function Pr(t){let{graph:e,queryStr:r,mermaidOutput:s,slim:n}=t,o=e.serialize();if(r){let a=je(r);o=Ge(o,a)}if(s){let a=F.deserialize(o);console.log(Te.serialize(a));return}let i=e.findCycles();i.length>0&&(o.cycles=i),console.log(JSON.stringify(n?It(o):o,null,2))}var ii=m(()=>{"use strict";c();b()});import zl from"fs";import Tr from"path";function tt(t,e,r){let s=t;for(let n=0;n<6;n++){let o=Tr.join(s,"templates",...e);if(zl.existsSync(Tr.join(o,r)))return o;let i=Tr.dirname(s);if(i===s)break;s=i}throw new Error(`Could not locate mokosh templates/${e.join("/")}`)}var Nr=m(()=>{"use strict";c()});import ai from"fs";import ci from"path";function pi(t,e=process.cwd()){let r=tt(f,["config"],"mokosh.config.js"),s=ci.join(r,"mokosh.config.js"),n=ci.join(e,"mokosh.config.js");if(ai.existsSync(n)&&!t){console.log("skipped mokosh.config.js (already exists, use --force to overwrite)");return}ai.copyFileSync(s,n),console.log("wrote mokosh.config.js")}var li=m(()=>{"use strict";c();Nr()});import Ir from"fs";import rt from"path";function fi(t,e=process.cwd()){let r=tt(f,["skill"],"SKILL.md");for(let s of $l){let n=rt.join(r,s.templateFile),o=rt.join(e,...s.destPath),i=rt.join(...s.destPath);if(Ir.existsSync(o)&&!t){console.log(`skipped ${i} (already exists, use --force to overwrite)`);continue}Ir.mkdirSync(rt.dirname(o),{recursive:!0}),Ir.copyFileSync(n,o),console.log(`wrote ${i}`)}}var $l,mi=m(()=>{"use strict";c();Nr();$l=[{templateFile:"SKILL.md",destPath:[".claude","skills","mokosh","SKILL.md"]},{templateFile:"mokosh.md",destPath:[".claude","commands","mokosh.md"]}]});async function ui(t){let{graph:e,filterPaths:r,minOutDegree:s}=t,n=At(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 gi=m(()=>{"use strict";c();b()});async function di(t){let{graph:e}=t,{rootDir:r,scanOptions:s,featureThreshold:n,plain:o}=t;o||console.log("Proposing test tags based on git diff...");let i=Ze(r);if(e.nodes.size===0){let p=M(r,s);e=await I(r,z(p),e)}let a=dr(e,i,{...n!==void 0&&{featureDetection:{minOutDegree:n}}});console.log(o?a.join(" "):JSON.stringify({proposedTags:a},null,2))}var hi=m(()=>{"use strict";c();b();et()});async function yi(t){let{graph:e,typeFilter:r}=t,s=Ot(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 xi=m(()=>{"use strict";c();b()});function Si(t,e){let r=t.getAffectedAcrossPackages(e);console.log(JSON.stringify({file:e,affected:r,count:r.length},null,2))}var bi=m(()=>{"use strict";c()});function Ci(t){console.log(JSON.stringify(Mt(t),null,2))}var vi=m(()=>{"use strict";c();b()});import Mr from"path";function ki(t){let{rootDir:e,entryPoints:r,cachePath:s,configPath:n}=t,o=n?U(n,{isExplicitPath:!0}):U(e),i=Mr.join(Mr.resolve(e,"mokosh-cache"),"graph.json"),a=r.length>0?r:o.entryPoints??[],p=s!==i?s??i:o.cachePath?Mr.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 wi=m(()=>{"use strict";c();b()});import ke from"fs";import Ul from"path";function Ei(t){if(!ke.existsSync(t))return null;let e=ke.readFileSync(t,"utf-8");return F.deserialize(JSON.parse(e))}function Dr(t,e){let r=Ul.dirname(e);ke.existsSync(r)||ke.mkdirSync(r,{recursive:!0}),ke.writeFileSync(e,JSON.stringify(t.serialize(),null,2))}async function Ar(t,e,r,s=!1,n=!1,o){return I(t,e,r,{silent:s,gitStats:n,parallelParsing:o})}var Fi=m(()=>{"use strict";c();b()});var Pi,Ti,Ni=m(()=>{"use strict";c();Pi=`
37
37
  Usage: mokosh [options] <entry-point1> <entry-point2> ...
38
38
 
39
39
  Options:
@@ -106,7 +106,7 @@ Notes:
106
106
  server only loads JSON config (allowJs: false) for security. This is intentional.
107
107
  --workspace-packages/--workspace-affected require explicit opt-in (unlike MCP's analyze tool,
108
108
  which auto-detects a monorepo when entryPoints is empty); other commands remain single-package.
109
- `,Ei=`
109
+ `,Ti=`
110
110
  Query filter reference (--query "key:value,key:value,...")
111
111
  All keys are case-insensitive. Multiple keys are AND'd together.
112
112
 
@@ -229,5 +229,5 @@ COMMON PATTERNS
229
229
 
230
230
  Large TypeScript logic files:
231
231
  --query "type:typescript,category:logic,sort:size,limit:5"
232
- `});var Pi,Ti=m(()=>{"use strict";c();Pi=/(?:^|[/\\])(?:node_modules|\.git|dist|build|coverage)(?:[/\\]|$)/});import zl from"fs";function Ni(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=zl.watch(t,{recursive:!0},(p,l)=>{!l||Pi.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 Ii=m(()=>{"use strict";c();Ti()});async function Mi(){let t=process.argv.slice(2),e=Io(t);e.help&&(console.log(wi),process.exit(0)),e.queryHelp&&(console.log(Ei),process.exit(0)),e.initSkill&&(ci(e.force),process.exit(0)),e.initConfig&&(ii(e.force),process.exit(0)),e.clearCache&&(Jo(e.cachePath),process.exit(0));let r=bi(e);ft(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:N,checkDocDrift:A,callers:Rr,dependencies:Or,dependents:Lr,affected:Gr,file:st,silent:jr,featureThreshold:Ai,query:Ri,mermaid:Oi,typeGraph:_r,typeFilter:Li,moduleResponsibility:Wr,filterPaths:Gi,minOutDegree:ji,featureGraph:_i,callGraph:zr,functionName:Wi,apiSurface:$r,applyTags:Ur,dryRun:zi,depth:$i,cached:Ui,changedSymbols:Bi,withEdgeDetail:Ji,findComplexFunctions:Br,metric:Ki,complexityThreshold:Hi,limit:Qi,workspacePackages:Jr,workspaceAffected:Vi,slim:Xi,testsOnly:qi,watch:Kr}=e;if(Jr||Vi){Kr&&(console.error("Error: --watch is not supported with --workspace-packages/--workspace-affected"),process.exit(1));let R=await Fo(s,{gitStats:r.rawConfig.gitStats??!1,parallelParsing:r.rawConfig.parallelParsing});Jr?xi(R):(st||(console.error("Error: --workspace-affected requires --file <path>"),process.exit(1)),hi(R,st));return}let Hr=a||l||Ur||Rr||Or||Lr||Gr||x||Br||_r||Wr||zr||$r,we=vi(o)??new F(new Map);(n.length>0||!Hr)&&(n.length===0&&!Hr&&!h&&!d&&!N&&!A&&(console.error("Error: No entry points provided"),process.exit(1)),we=await Ar(s,n,we,jr,r.rawConfig.gitStats??!1,r.rawConfig.parallelParsing),Dr(we,o));let nt={graph:we,rootDir:s,entryPoints:n.map(R=>R.replace(s+"/","")),scanOptions:i,rawConfig:r.rawConfig,featureThreshold:Ai,queryStr:Ri,mermaidOutput:Oi,plain:p,excludeTests:C,file:st,typeFilter:Li,filterPaths:Gi,minOutDegree:ji,functionName:Wi,dryRun:zi,depth:$i,cached:Ui,changedSymbols:Bi,withEdgeDetail:Ji,metric:Ki,complexityThreshold:Hi,limit:Qi,slim:Xi,testsOnly:qi},ot=[[a,mi],[Ur,Go],[l,Ao],[d,Vo],[h,ti],[N,Cr],[A,vr],[x,Fr],[Rr,br],[Or,kr],[Lr,wr],[Gr,xr],[Br,Er],[_r,gi],[Wr,li],[_i,qo],[zr,_o],[$r,Oo]].find(([R])=>R)?.[1]??Pr;if(Kr){$l.has(ot)||(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)),Ni(s,300,async()=>{let R=await Ar(s,n,nt.graph,jr,r.rawConfig.gitStats??!1,r.rawConfig.parallelParsing);Dr(R,o),console.log(`--- rebuilt at ${new Date().toISOString()} ---`),await ot({...nt,graph:R})});return}await ot(nt)}var $l,Di=m(()=>{"use strict";c();b();Mo();Do();Ro();Lo();jo();Wo();zo();$o();Uo();Ko();Ho();Qo();Xo();Yo();Zo();ei();ri();si();ai();pi();fi();ui();di();yi();Si();Ci();ki();Fi();Ii();$l=new Set([Pr,br,kr,wr,xr,Fr,Er,Cr,vr])});var Ul=Yi(()=>{c();Di();Mi().catch(t=>{console.error(t),process.exit(1)})});export default Ul();
232
+ `});var Ii,Mi=m(()=>{"use strict";c();Ii=/(?:^|[/\\])(?:node_modules|\.git|dist|build|coverage)(?:[/\\]|$)/});import Bl from"fs";function Di(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=Bl.watch(t,{recursive:!0},(p,l)=>{!l||Ii.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 Ai=m(()=>{"use strict";c();Mi()});async function Ri(){let t=process.argv.slice(2),e=Ao(t);e.help&&(console.log(Pi),process.exit(0)),e.queryHelp&&(console.log(Ti),process.exit(0)),e.initSkill&&(fi(e.force),process.exit(0)),e.initConfig&&(pi(e.force),process.exit(0)),e.clearCache&&(Qo(e.cachePath),process.exit(0));let r=ki(e);ft(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:N,checkDocDrift:A,callers:Rr,dependencies:Or,dependents:Lr,affected:Gr,file:st,silent:jr,featureThreshold:Li,query:Gi,mermaid:ji,typeGraph:_r,typeFilter:_i,moduleResponsibility:Wr,filterPaths:Wi,minOutDegree:zi,featureGraph:$i,callGraph:zr,functionName:Ui,apiSurface:$r,applyTags:Ur,dryRun:Bi,depth:Ji,cached:Ki,changedSymbols:Hi,withEdgeDetail:Qi,findComplexFunctions:Br,metric:Vi,complexityThreshold:Xi,limit:qi,workspacePackages:Jr,workspaceAffected:Yi,slim:Zi,testsOnly:ea,watch:Kr}=e;if(Jr||Yi){Kr&&(console.error("Error: --watch is not supported with --workspace-packages/--workspace-affected"),process.exit(1));let R=await No(s,{gitStats:r.rawConfig.gitStats??!1,parallelParsing:r.rawConfig.parallelParsing});Jr?Ci(R):(st||(console.error("Error: --workspace-affected requires --file <path>"),process.exit(1)),Si(R,st));return}let Hr=a||l||Ur||Rr||Or||Lr||Gr||x||Br||_r||Wr||zr||$r,we=Ei(o)??new F(new Map);(n.length>0||!Hr)&&(n.length===0&&!Hr&&!h&&!d&&!N&&!A&&(console.error("Error: No entry points provided"),process.exit(1)),we=await Ar(s,n,we,jr,r.rawConfig.gitStats??!1,r.rawConfig.parallelParsing),Dr(we,o));let nt={graph:we,rootDir:s,entryPoints:n.map(R=>R.replace(s+"/","")),scanOptions:i,rawConfig:r.rawConfig,featureThreshold:Li,queryStr:Gi,mermaidOutput:ji,plain:p,excludeTests:C,file:st,typeFilter:_i,filterPaths:Wi,minOutDegree:zi,functionName:Ui,dryRun:Bi,depth:Ji,cached:Ki,changedSymbols:Hi,withEdgeDetail:Qi,metric:Vi,complexityThreshold:Xi,limit:qi,slim:Zi,testsOnly:ea},ot=[[a,di],[Ur,Wo],[l,Lo],[d,Yo],[h,ni],[N,Cr],[A,vr],[x,Fr],[Rr,br],[Or,kr],[Lr,wr],[Gr,xr],[Br,Er],[_r,yi],[Wr,ui],[$i,ei],[zr,$o],[$r,jo]].find(([R])=>R)?.[1]??Pr;if(Kr){Jl.has(ot)||(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)),Di(s,300,async()=>{let R=await Ar(s,n,nt.graph,jr,r.rawConfig.gitStats??!1,r.rawConfig.parallelParsing);Dr(R,o),console.log(`--- rebuilt at ${new Date().toISOString()} ---`),await ot({...nt,graph:R})});return}await ot(nt)}var Jl,Oi=m(()=>{"use strict";c();b();Ro();Oo();Go();_o();zo();Uo();Bo();Jo();Ko();Vo();Xo();qo();Zo();ti();ri();si();oi();ii();li();mi();gi();hi();xi();bi();vi();wi();Fi();Ni();Ai();Jl=new Set([Pr,br,kr,wr,xr,Fr,Er,Cr,vr])});var Kl=ta(()=>{c();Oi();Ri().catch(t=>{console.error(t),process.exit(1)})});export default Kl();
233
233
  //# sourceMappingURL=cli.mjs.map