@omfalos/mokosh 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +192 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +139 -0
- package/dist/cli.js.map +1 -0
- package/dist/cli.mjs +139 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/index.d.mts +1135 -0
- package/dist/index.d.ts +1135 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +26 -0
- package/dist/index.mjs.map +1 -0
- package/dist/mcp.d.mts +15 -0
- package/dist/mcp.d.ts +15 -0
- package/dist/mcp.js +28 -0
- package/dist/mcp.js.map +1 -0
- package/dist/mcp.mjs +28 -0
- package/dist/mcp.mjs.map +1 -0
- package/package.json +103 -0
package/dist/cli.mjs
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
var ge=(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 l=(t,e)=>()=>(t&&(e=t(t=0)),e);var Fo=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);function de(t){rr.push(t)}function sr(t){return[...wo,...rr].some(e=>typeof e=="string"?t.includes(e):e instanceof RegExp?e.test(t):e(t))}function he(t){nr.push(t)}function X(){return[...To,...nr]}function ye(t){or.push(t)}function qe(){return[...Po,...or]}function Ve(t){ir=t}function Qe(){return ir}var wo,rr,To,nr,Po,or,ir,G=l(()=>{"use strict";wo=[".config.","biome.json","tsconfig.json","package.json",".prettierrc",".eslintrc"],rr=[];To=[".test.",".spec.","-test.","-spec."],nr=[];Po=["jest","vitest","playwright","cypress","@testing-library/"],or=[];ir=.8});import Xe from"fs";import ar from"path";function O(t,{allowJs:e=!0,isExplicitPath:r=!1}={}){if(r){let s=ar.resolve(t);return Xe.existsSync(s)?s.endsWith(".json")?cr(s):e?pr(s):{}:{}}for(let s of No){let n=ar.resolve(t,s);if(Xe.existsSync(n)){if(s.endsWith(".json"))return cr(n);if(e)return pr(n)}}return{}}function cr(t){return JSON.parse(Xe.readFileSync(t,"utf-8"))}function pr(t){let e=ge(t);return e&&typeof e=="object"&&"default"in e&&(e=e.default),typeof e=="function"?e({}):e}function Ze(t){for(let e of t.configMatchers??[])de(e);for(let e of t.testPatterns??[])he(e);for(let e of t.testLibraries??[])ye(e);t.barrelThreshold!==void 0&&Ve(t.barrelThreshold)}var No,Ye=l(()=>{"use strict";G();No=["mokosh.config.js","mokosh.config.cjs","mokosh.config.json"]});var et,tt,rt=l(()=>{"use strict";et=["node_modules",".git","dist","build",".next",".cache","mokosh-cache","coverage"],tt=[".ts",".tsx",".js",".jsx",".mjs",".cjs",".css",".scss",".sass",".less",".styl",".coffee",".ls",".lua",".py",".go",".feature"]});import Yc from"fs";import tp from"path";var lr=l(()=>{"use strict"});var xe,fr=l(()=>{"use strict";xe={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 c=o.isStyle?"-- styles -->":"-->";e.push(` ${n} ${c} ${i}`),r.add(a)}}}return e.join(`
|
|
3
|
+
`)}}});var ur=l(()=>{"use strict";fr()});import mr from"fs";import Mo from"path";function st(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 gr(t,e){if(typeof t=="string")return st(t,e);if(t&&typeof t=="object"){let r=t;for(let s of["import","require","default"]){let n=gr(r[s],e);if(n)return n}}return null}function Do(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 Ro(t,e){let r=new Set,s=new Set,n=[...e];for(;n.length;){let o=n.shift();if(s.has(o))continue;s.add(o);let i=t.nodes.get(o);if(i){for(let a of i.exports)r.add(a.name);for(let a of i.imports){if(a.type!=="re-export"||a.isExternal||!a.toPath)continue;if(!a.symbols?.length||a.symbols.includes("*")){let p=t.nodes.get(a.toPath);if(p)for(let u of p.exports)r.add(u.name);n.push(a.toPath)}else for(let p of a.symbols)r.add(p)}}}return r}function nt(t,e){let r=[],s=Mo.join(e,"package.json");if(mr.existsSync(s))try{let n=JSON.parse(mr.readFileSync(s,"utf8"));if(n.exports&&typeof n.exports=="object"&&!Array.isArray(n.exports))for(let o of Object.values(n.exports)){let i=gr(o,t);i&&!r.includes(i)&&r.push(i)}else if(typeof n.exports=="string"){let o=st(n.exports,t);o&&r.push(o)}if(r.length===0)for(let o of[n.main,n.module].filter(Boolean)){let i=st(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 Ao(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 Lo(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 c=s.get(a.name),p=!!(a.signature||a.doc);(!c||p&&!i)&&s.set(a.name,{file:n,symbol:a})}}return s}function Go(t,e,r,s){let n=[];for(let o of t){let i=e.get(o),a=s.flatMap(m=>r.nodes.get(m)?.exports??[]).find(m=>m.name===o),c=i?.symbol??a,p=i?.file??s.find(m=>r.nodes.get(m)?.exports.some(h=>h.name===o))??s[0],u={name:o,definedIn:p,kind:Do(c?.signature)};c?.doc&&(u.doc=c.doc),c?.signature&&(u.signature=c.signature),n.push(u)}return n.sort((o,i)=>o.name.localeCompare(i.name)),n}function Oo(t,e,r){let s=c=>t.nodes.get(c)?.category==="test",n=[...e].filter(c=>!r.includes(c)&&!s(c)),o=[...t.nodes.keys()].filter(c=>!e.has(c)),i=o.filter(c=>!s(c)),a=o.filter(c=>s(c));return{internalFiles:n,unreachableFromEntry:i,testFiles:a}}function ot(t,e){if(e.length===0)throw new Error("buildApiSurface requires at least one entry point");for(let p of e)if(!t.nodes.has(p))throw new Error(`Entry point not found in graph: ${p}`);let r=Ao(t,e),s=Lo(t,r,e),n=Ro(t,e),o=Go(n,s,t,e),{internalFiles:i,unreachableFromEntry:a,testFiles:c}=Oo(t,r,e);return{entryPoints:e,publicExports:o,internalFiles:i,unreachableFromEntry:a,testFiles:c}}var it=l(()=>{"use strict"});function at(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=l(()=>{"use strict"});import fp from"fs";import mp from"path";var pt=l(()=>{"use strict"});import Se from"path";function jo(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 _o(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=Se.extname(n),c=Se.basename(n,a),p=c==="index"?Se.basename(Se.dirname(n)):c;s.set(n,{path:n,outDegree:o,tag:`feature:${p}`})}return s}function A(t,e){let r=e?.minOutDegree??5;return _o(t,jo(t),r)}var be=l(()=>{"use strict"});function zo(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 $o(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 Uo(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 Bo(t,e,r){let s=[];for(let n of t.keys())!e.has(n)&&!r.has(n)&&s.push(n);return s}function Z(t,e){let r=e?.detectFn??A,s=e?.hubComparator??Wo,n=r(t.nodes,e),o=zo(t,n),i=$o(t.nodes,n,o,s);return{features:Uo(n,i),unassigned:Bo(t.nodes,n,i)}}var Wo,ve=l(()=>{"use strict";be();Wo=(t,e)=>t.outDegree-e.outDegree});var Y,dr=l(()=>{"use strict";Y=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 c of a.imports)if(!(!c.toPath||c.isExternal))if(s.has(c.toPath)){let p=n.indexOf(c.toPath);e.push([...n.slice(p),c.toPath])}else r.has(c.toPath)||o(c.toPath)}s.delete(i),n.pop()};for(let i of this.nodes.keys())r.has(i)||o(i);return e}}});var F,ee=l(()=>{"use strict";dr();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=(c,p,u)=>{if(p>i||o.has(c))return;let m=this.nodes.get(c);if(m&&(o.add(c),r(m,p,u)!==!1))for(let h of n(c))a(h,p+1,c)};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 Y(this.nodes).findUnusedFiles(e)}findCycles(){return new Y(this.nodes).findCycles()}}});function hr(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 d(e,"component")||d(e,"components")?"component":d(e,"controller")||d(e,"controllers")?"controller":d(e,"middleware")?"middleware":d(e,"router")||d(e,"routes")||d(e,"route")?"router":d(e,"store")||d(e,"stores")?"store":d(e,"service")||d(e,"services")?"service":d(e,"handler")||d(e,"handlers")?"handler":d(e,"adapter")||d(e,"adapters")?"adapter":d(e,"plugin")||d(e,"plugins")?"plugin":d(e,"api")?"api":d(e,"cli")||d(e,"commands")||te(e)==="cli"?"cli":d(e,"util")||d(e,"utils")||d(e,"helper")||d(e,"helpers")?"util":d(e,"model")||d(e,"models")||te(e)==="model"?"model":d(e,"parser")||d(e,"parsers")||te(e)==="parser"?"parser":te(e)==="builder"?"builder":te(e)==="resolver"?"resolver":"other"}function d(t,e){return t.includes(`/${e}/`)||t.includes(`/${e}.`)}function te(t){let e=t.slice(t.lastIndexOf("/")+1);return e.slice(0,e.lastIndexOf("."))||e}var yr=l(()=>{"use strict"});function lt(t,e){let r=Z(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:hr(o),...o.description?{description:o.description}:{},exports:o.exports.map(a=>a.name),...i?{featureHub:i}:{}})}return n}var ft=l(()=>{"use strict";ve();yr()});var re,ut=l(()=>{"use strict";re=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(c=>c.toPath===r);if(!n)return!1;let o=n.symbols||["*"],i=new Set;for(let c of o)(c==="*"||s.has("*")||s.has(c))&&i.add("*");if(i.size===0)return!1;let a=this.affectedSymbols.get(e.path)||new Set;for(let c of i)a.add(c);return this.affectedSymbols.set(e.path,a),!0}}});function Jo(t){return t?t.startsWith("interface ")?"interface":t.startsWith("class ")?"class":t.startsWith("enum ")?"enum":"type":"type"}function Ko(t,e){if(e==="type-only")return!0;let r=t.signature??"";return r.startsWith("interface ")||r.startsWith("class ")||r.startsWith("enum ")}function mt(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(!Ko(n,s.category))continue;let o=`${s.path}::${n.name}`;e.set(o,{name:n.name,file:s.path,kind:Jo(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 gt(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 dt=l(()=>{"use strict"});import xr from"fs";import Ip from"path";function Sr(t){try{return xr.statSync(t,{throwIfNoEntry:!1})?.isDirectory()===!0}catch{return!1}}function Ce(t){try{return xr.statSync(t,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}var Ee=l(()=>{"use strict"});import se from"fs";import E from"path";function ht(t,e){let r=E.join(e,"package.json");if(!se.existsSync(r))return null;let s={};try{s=JSON.parse(se.readFileSync(r,"utf-8"))}catch{return null}let n=s.name;return n?{name:n,root:e,relativeRoot:E.relative(t,e),entryPoints:Ho(e,s)}:null}function Ho(t,e){let r=[];if(e.exports){let n=e.exports;if(typeof n=="string")r.push(E.join(t,n));else if(typeof n=="object"&&n!==null){let o=n["."];if(typeof o=="string")r.push(E.join(t,o));else if(typeof o=="object"&&o!==null){let i=o.import??o.require??o.default;typeof i=="string"&&r.push(E.join(t,i))}}}e.main&&r.push(E.join(t,e.main));for(let n of["src/index.ts","src/index.tsx","index.ts","index.tsx","index.js"])r.push(E.join(t,n));let s=r.filter(Ce);return s.length>0?s.slice(0,1):r.slice(0,1)}function j(t,e){let r=[],s=new Set;for(let n of e){let o=n.replace(/\/$/,"").replace(/^\.\//,"");qo(t,o,s,r)}return r}function qo(t,e,r,s){if(!e.includes("*")){Vo(t,e,r,s);return}let n=e.split("/");n.includes("**")?Qo(t,n,r,s):Xo(t,n,r,s)}function Vo(t,e,r,s){let n=E.join(t,e);if(r.has(n)||!Sr(n))return;r.add(n);let o=ht(t,n);o&&s.push(o)}function Qo(t,e,r,s){let n=E.join(t,e[0]==="**"?"":e[0]??"");br(t,n,r,s)}function Xo(t,e,r,s){let n=e.findIndex(a=>a.includes("*")),o=E.join(t,...e.slice(0,n)),i;try{i=se.readdirSync(o,{withFileTypes:!0})}catch{return}for(let a of i){if(!a.isDirectory())continue;let c=E.join(o,a.name);if(r.has(c))continue;r.add(c);let p=ht(t,c);p&&s.push(p)}}function br(t,e,r,s){let n;try{n=se.readdirSync(e,{withFileTypes:!0})}catch{return}for(let o of n){if(!o.isDirectory()||o.name==="node_modules"||o.name.startsWith("."))continue;let i=E.join(e,o.name);if(se.existsSync(E.join(i,"package.json"))&&!r.has(i)){r.add(i);let a=ht(t,i);a&&s.push(a)}else br(t,i,r,s)}}var ke=l(()=>{"use strict";Ee();Ee()});import yt from"fs";import vr from"path";var Cr,Er=l(()=>{"use strict";ke();Cr={type:"npm",detect(t){let e=vr.join(t,"package.json");if(!yt.existsSync(e))return null;let r;try{r=JSON.parse(yt.readFileSync(e,"utf-8")).workspaces}catch{return null}if(!r||yt.existsSync(vr.join(t,"yarn.lock")))return null;let s=Array.isArray(r)?r:r.packages??[];return s.length===0?null:j(t,s)}}});import _ from"fs";import S from"path";function Fr(t,e,r,s){if(s>4)return[];let n;try{n=_.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 c=S.join(e,a);_.existsSync(S.join(c,"project.json"))&&!r.has(c)?(r.add(c),o.push(c)):o.push(...Fr(t,c,r,s+1))}return o}function Zo(t,e,r){let s={};try{s=JSON.parse(_.readFileSync(r,"utf-8"))}catch{return null}let n=s.name,o,i,a=S.join(e,"package.json");if(_.existsSync(a))try{let c=JSON.parse(_.readFileSync(a,"utf-8"));n=c.name??n,o=c.main,i=c.exports}catch{}return n?{name:n,root:e,relativeRoot:S.relative(t,e),entryPoints:Yo(e,s,o,i)}:null}function Yo(t,e,r,s){let n=[],o=e.targets?.build?.options?.main??e.targets?.build?.options?.entryFile;if(o){let a=S.resolve(t,"../..");n.push(S.resolve(a,o)),n.push(S.resolve(t,o))}if(s){let a=s;if(typeof a=="string")n.push(S.join(t,a));else if(typeof a=="object"&&a!==null){let c=a["."];typeof c=="string"&&n.push(S.join(t,c))}}if(r&&n.push(S.join(t,r)),e.sourceRoot){let a=S.resolve(t,"../.."),c=S.resolve(a,e.sourceRoot);n.push(S.join(c,"index.ts"),S.join(c,"index.tsx"))}for(let a of["src/index.ts","src/index.tsx","index.ts","index.tsx"])n.push(S.join(t,a));let i=n.filter(Ce);return i.length>0?i.slice(0,1):n.slice(0,1)}var kr,wr=l(()=>{"use strict";Ee();kr={type:"nx",detect(t){return _.existsSync(S.join(t,"nx.json"))?Fr(t,t,new Set,0).map(r=>Zo(t,r,S.join(r,"project.json"))).filter(r=>r!==null):null}}});import Tr from"fs";import ei from"path";import ti from"js-yaml";var Pr,Nr=l(()=>{"use strict";ke();Pr={type:"pnpm",detect(t){let e=ei.join(t,"pnpm-workspace.yaml");if(!Tr.existsSync(e))return null;let r=[];try{r=ti.load(Tr.readFileSync(e,"utf-8"))?.packages??[]}catch{return null}return j(t,r)}}});import ri from"fs";import si from"path";var Ir,Mr=l(()=>{"use strict";Ir={type:"turborepo",detect(t){return ri.existsSync(si.join(t,"turbo.json"))?[]:null}}});import xt from"fs";import Dr from"path";var Rr,Ar=l(()=>{"use strict";ke();Rr={type:"yarn",detect(t){if(!xt.existsSync(Dr.join(t,"yarn.lock")))return null;let e=Dr.join(t,"package.json");if(!xt.existsSync(e))return null;let r;try{r=JSON.parse(xt.readFileSync(e,"utf-8")).workspaces}catch{return null}if(!r)return null;let s=Array.isArray(r)?r:r.packages??[];return s.length===0?null:j(t,s)}}});function I(t){ni.push(t)}var ni,Fe=l(()=>{"use strict";ni=[]});import al from"path";var St=l(()=>{"use strict";Er();wr();Nr();Mr();Ar();Fe();Fe();I(Ir);I(kr);I(Pr);I(Rr);I(Cr)});var bt=l(()=>{"use strict";ee()});function W(t,e){Lr.set(t,e)}function Gr(t){return Lr.get(t)}var Lr,ne=l(()=>{"use strict";Lr=new Map});function Or(t,e){return e.startsWith("!")?t!==e.slice(1):t===e}function oi(t,e){return e.startsWith("!")?!t.includes(e.slice(1)):t.includes(e)}var ii,ai,ci,pi,li,fi,ui,mi,gi,di,hi,yi,xi,Si,bi,vi,Ci,jr,_r=l(()=>{"use strict";ii=(t,e)=>!e.category||Or(t.category,e.category),ai=(t,e)=>!e.type||Or(t.type,e.type),ci=(t,e)=>!e.path||oi(t.path,e.path),pi=(t,e)=>e.isExternal===void 0?!0:t.imports.some(s=>s.isExternal)===e.isExternal,li=(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)))},fi=(t,e)=>!e.allTags?.length||e.allTags.every(r=>t.tags.some(s=>s.name===r)),ui=(t,e)=>!e.importsFile||t.imports.some(r=>r.toPath?.includes(e.importsFile)),mi=(t,e,r)=>e.importedBy===void 0?!0:(r?.get(t.path)??[]).some(n=>n.includes(e.importedBy)),gi=(t,e)=>e.minImports===void 0||t.imports.length>=e.minImports,di=(t,e)=>e.maxImports===void 0||t.imports.length<=e.maxImports,hi=(t,e)=>e.minSize===void 0||t.size>=e.minSize,yi=(t,e)=>e.maxSize===void 0||t.size<=e.maxSize,xi=(t,e)=>e.hasDocstring===void 0||!!t.description===e.hasDocstring,Si=(t,e)=>e.minCoverage===void 0||(t.coveragePct??101)>=e.minCoverage,bi=(t,e)=>e.maxCoverage===void 0||(t.coveragePct??0)<=e.maxCoverage,vi=(t,e)=>e.minExportUsage===void 0||(t.avgExportUsage??-1)>=e.minExportUsage,Ci=(t,e)=>e.maxExportUsage===void 0||(t.avgExportUsage??0)<=e.maxExportUsage,jr=[ii,ai,ci,pi,li,fi,ui,mi,gi,di,hi,yi,xi,Si,bi,vi,Ci]});function Wr(t,e,r){return jr.every(s=>s(t,e,r))}function we(t,e){let r=new Map;if(e.importedBy!==void 0){for(let i of t.nodes)for(let a of i.imports)if(a.toPath){let c=r.get(a.toPath)??[];c.push(i.path),r.set(a.toPath,c)}}let s=t.nodes.filter(i=>Wr(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))}));return e.sort&&o.sort((i,a)=>e.sort==="size"?a.size-i.size:e.sort==="imports"?a.imports.length-i.imports.length:e.sort==="commitCount90d"?(a.commitCount90d??0)-(i.commitCount90d??0):e.sort==="exportUsage"?(a.avgExportUsage??0)-(i.avgExportUsage??0):0),e.limit!==void 0&&o.splice(e.limit),{nodes:o,cycles:t.cycles?.filter(i=>i.every(a=>n.has(a)))??void 0}}var zr=l(()=>{"use strict";_r()});function Te(t){let e={},r=t.split(",");for(let s of r){let n=s.indexOf(":");if(n===-1)continue;let o=s.slice(0,n).trim().toLowerCase(),i=s.slice(n+1).trim();if(!(!o||!i))switch(o){case"category":e.category=i;break;case"type":e.type=i;break;case"tag":case"tags":i.includes("+")?e.allTags=[...e.allTags??[],...i.split("+")]:e.tags=[...e.tags??[],i];break;case"path":e.path=i;break;case"external":e.isExternal=i.toLowerCase()==="true";break;case"importsfile":e.importsFile=i;break;case"importedby":e.importedBy=i;break;case"minimports":e.minImports=parseInt(i,10);break;case"maximports":e.maxImports=parseInt(i,10);break;case"minsize":e.minSize=parseInt(i,10);break;case"maxsize":e.maxSize=parseInt(i,10);break;case"sort":e.sort=i;break;case"limit":e.limit=parseInt(i,10);break;case"hasdocstring":e.hasDocstring=i.toLowerCase()!=="false";break;case"mincoverage":e.minCoverage=parseInt(i,10);break;case"maxcoverage":e.maxCoverage=parseInt(i,10);break;case"minexportusage":e.minExportUsage=parseFloat(i);break;case"maxexportusage":e.maxExportUsage=parseFloat(i);break}}return e}var $r=l(()=>{"use strict"});var Ur=l(()=>{"use strict";zr();$r()});import b from"typescript";function z(t){let e=[];for(let r of t.statements){if(!b.isExpressionStatement(r))continue;let s=r.expression;if(!b.isCallExpression(s))continue;let n=s.expression;b.isIdentifier(n)&&Br.has(n.text)&&e.push(s),b.isPropertyAccessExpression(n)&&b.isIdentifier(n.expression)&&Br.has(n.expression.text)&&e.push(s)}return e}function $(t,e,r){for(let s of t.arguments){if(!b.isObjectLiteralExpression(s))continue;let n=s.properties.find(o=>b.isPropertyAssignment(o)&&b.isIdentifier(o.name)&&o.name.text===e);if(!(!n||!b.isArrayLiteralExpression(n.initializer)))return n.initializer.elements.filter(b.isStringLiteral).map(o=>o.text)}return null}function U(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(!b.isObjectLiteralExpression(i))continue;let a=i.properties.find(p=>b.isPropertyAssignment(p)&&b.isIdentifier(p.name)&&p.name.text===e);if(a)return{start:a.initializer.getStart(s),end:a.initializer.getEnd(),text:r};let c=i.getEnd()-1;return{start:c,end:c,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 B(t,e,r){let s=t.arguments;for(let n=1;n<s.length;n++){let o=s[n];if(!b.isObjectLiteralExpression(o))continue;let i=o.properties.findIndex(c=>b.isPropertyAssignment(c)&&b.isIdentifier(c.name)&&c.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 J(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 K(t){return`[${t.map(e=>JSON.stringify(e)).join(", ")}]`}var Br,P,H=l(()=>{"use strict";Br=new Set(["describe","test","it"]);P=new Set([".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"])});import Jr from"path";import Kr from"typescript";function Ei(t){return K(t.map(e=>`@${e}`))}function ki(t){return t.map(e=>e.startsWith("@")?e.slice(1):e)}var Pe,Hr=l(()=>{"use strict";H();Pe=class{name="cypress";canHandle(e){return P.has(Jr.extname(e).toLowerCase())}apply(e,r,s){let n=Kr.createSourceFile(Jr.basename(e),r,Kr.ScriptTarget.Latest,!0),o=z(n);if(o.length===0)return r;let i=$(o[0],"tags",n),a=[...s].sort();if(i!==null&&JSON.stringify(ki(i).sort())===JSON.stringify(a))return r;let c=o.flatMap(p=>{let u=s.length===0?B(p,"tags",n):U(p,"tags",Ei(a),n);return u?[u]:[]});return c.length>0?J(r,c):r}}});import Fi from"path";function wi(t){return["# <mokosh-tags>",...t.map(e=>`@${e}`),"# </mokosh-tags>"].join(`
|
|
4
|
+
`)+`
|
|
5
|
+
|
|
6
|
+
`}function Ti(t){let e=new Set;Ct.lastIndex=0;let r=Ct.exec(t);for(;r!==null;)r[1]&&e.add(r[1]),r=Ct.exec(t);return e}var vt,Ct,Ne,qr=l(()=>{"use strict";vt=/# <mokosh-tags>[\s\S]*?# <\/mokosh-tags>\n*/,Ct=/^@([a-zA-Z0-9_-]+)/gm;Ne=class{name="gherkin";canHandle(e){return Fi.extname(e).toLowerCase()===".feature"}apply(e,r,s){let n=r.replace(vt,""),o=Ti(n),i=s.filter(c=>!o.has(c)),a=i.length>0?wi(i):"";return vt.test(r)?r.replace(vt,a):a?r.replace(/^(Feature:)/m,`${a}$1`):r}}});function Vr(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 Qr=l(()=>{"use strict"});import Pi from"path";function Ii(t){return`//go:build ${t.map(r=>`mokosh_${r}`).join(" || ")}
|
|
7
|
+
`}function Mi(t){let e=Et.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 Et,Ni,Ie,Xr=l(()=>{"use strict";Et=/^\/\/go:build mokosh_[^\n]+\n/m,Ni=/^package\s+\S+/m;Ie=class{name="go";canHandle(e){return Pi.basename(e).endsWith("_test.go")}apply(e,r,s){let n=Mi(r),o=[...s].sort();if(n!==null&&JSON.stringify([...n].sort())===JSON.stringify(o))return r;if(s.length===0)return r.replace(Et,"");let i=Ii(o);if(n!==null)return r.replace(Et,i);let a=Ni.exec(r);if(!a)return r;let c=a.index;return r.slice(0,c)+i+`
|
|
8
|
+
`+r.slice(c)}}});import Di from"path";function Ai(t){return["/**",...t.map(e=>` * @group ${e}`)," */"].join(`
|
|
9
|
+
`)+`
|
|
10
|
+
|
|
11
|
+
`}function Li(t){let e=[];kt.lastIndex=0;let r=kt.exec(t);for(;r!==null;)r[1]&&e.push(r[1]),r=kt.exec(t);return e}var Ri,kt,Me,Zr=l(()=>{"use strict";H();Ri=/^\/\*\*\n(?: \* @group .+\n)+ \*\/\n+/,kt=/^ \* @group (.+)$/gm;Me=class{name="jest";canHandle(e){return P.has(Di.extname(e).toLowerCase())}apply(e,r,s){let n=Ri.exec(r),o=n?Li(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:Ai(i)+a}}});import Yr from"path";import es from"typescript";function Gi(t){return K(t.map(e=>`@${e}`))}function Oi(t){return t.map(e=>e.startsWith("@")?e.slice(1):e)}var De,ts=l(()=>{"use strict";H();De=class{name="playwright";canHandle(e){return P.has(Yr.extname(e).toLowerCase())}apply(e,r,s){let n=es.createSourceFile(Yr.basename(e),r,es.ScriptTarget.Latest,!0),o=z(n);if(o.length===0)return r;let i=$(o[0],"tag",n),a=[...s].sort();if(i!==null&&JSON.stringify(Oi(i).sort())===JSON.stringify(a))return r;let c=o.flatMap(p=>{let u=s.length===0?B(p,"tag",n):U(p,"tag",Gi(a),n);return u?[u]:[]});return c.length>0?J(r,c):r}}});import ji from"path";function Wi(t){let e=t.map(r=>`pytest.mark.${r}`).join(", ");return t.length===1?`pytestmark = pytest.mark.${t[0]}`:`pytestmark = [${e}]`}function zi(t){let e=Ft.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 $i(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 Ft,_i,Re,rs=l(()=>{"use strict";Ft=/^pytestmark\s*=\s*.+$/m,_i=/^import pytest\s*$/m;Re=class{name="pytest";canHandle(e){return ji.extname(e).toLowerCase()===".py"}apply(e,r,s){let n=zi(r),o=[...s].sort();if(n!==null&&JSON.stringify([...n].sort())===JSON.stringify(o))return r;if(s.length===0)return r.replace(Ft,"").replace(/\n{3,}/g,`
|
|
13
|
+
|
|
14
|
+
`);let i=Wi(o);if(n!==null)return r.replace(Ft,i);let a=_i.test(r),c=$i(r),p=r.slice(0,c),u=r.slice(c),m=a?"":`import pytest
|
|
15
|
+
`,h=p.endsWith(`
|
|
16
|
+
|
|
17
|
+
`)?"":`
|
|
18
|
+
`;return p+h+m+i+`
|
|
19
|
+
`+u}}});import ss from"path";import ns from"typescript";var Ui,Ae,os=l(()=>{"use strict";H();Ui=/\/\/ <mokosh-tags>[\s\S]*?\/\/ <\/mokosh-tags>\n*/,Ae=class{name="vitest";canHandle(e){return P.has(ss.extname(e).toLowerCase())}apply(e,r,s){let n=r.replace(Ui,""),o=ns.createSourceFile(ss.basename(e),n,ns.ScriptTarget.Latest,!0),i=z(o);if(i.length===0)return n;let a=$(i[0],"tags",o),c=[...s].sort();if(a!==null&&JSON.stringify([...a].sort())===JSON.stringify(c))return n;let p=i.flatMap(u=>{let m=s.length===0?B(u,"tags",o):U(u,"tags",K(c),o);return m?[m]:[]});return p.length>0?J(n,p):n}}});import wt from"path";import Le from"typescript";function Ji(t){let e=Le.createSourceFile("detect.ts",t,Le.ScriptTarget.Latest,!0);for(let r of e.statements){if(!Le.isImportDeclaration(r)||!Le.isStringLiteral(r.moduleSpecifier))continue;let s=Bi[r.moduleSpecifier.text];if(s)return s}return null}function as(t="vitest",e={},r=process.cwd()){return[new Ne,new Re,new Ie,new Tt(r,t,Object.entries(e))]}function cs(t,e){return e.find(r=>r.canHandle(t))??null}var is,Bi,Tt,ps=l(()=>{"use strict";Hr();qr();Qr();Xr();Zr();ts();rs();H();os();is={vitest:()=>new Ae,playwright:()=>new De,cypress:()=>new Pe,jest:()=>new Me},Bi={"@playwright/test":"playwright",cypress:"cypress","@jest/globals":"jest",vitest:"vitest"};Tt=class{constructor(e,r,s){this.rootDir=e;this.defaultFramework=r;this.frameworkOverrides=s}rootDir;defaultFramework;frameworkOverrides;name="auto";canHandle(e){return P.has(wt.extname(e).toLowerCase())}apply(e,r,s){let n=Ji(r)??this.matchOverride(e)??this.defaultFramework;return(is[n]??is.vitest)().apply(e,r,s)}matchOverride(e){let r=wt.relative(this.rootDir,e).split(wt.sep).join("/");for(let[s,n]of this.frameworkOverrides)if(Vr(s,r))return n;return null}}});import ls from"fs/promises";import Ki from"path";async function Qi(t,e,r,s){let n;try{n=await ls.readFile(t,"utf8")}catch(a){return{path:t,status:"error",error:String(a)}}let o=cs(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 ls.writeFile(t,i,"utf8"),{path:t,status:"updated"})}async function Pt(t,e,r){let s=O(e),n=s.tagApplier?.framework??"vitest",o=s.tagApplier?.frameworkOverrides??{},i=as(n,o,e),a={updated:0,unchanged:0,errors:0,files:[]};for(let c of t.nodes.values()){if(c.category!=="test")continue;let p=new Set,u=[];for(let x of c.tags)qi.has(x.kind)&&Hi.test(x.name)&&(Vi.has(x.name.toLowerCase())||p.has(x.name)||(p.add(x.name),u.push(x.name)));u.sort();let m=Ki.resolve(e,c.path),h=await Qi(m,u,r.dryRun,i);h.path=c.path,a.files.push(h),h.status==="updated"?a.updated++:h.status==="unchanged"?a.unchanged++:a.errors++}return a}var Hi,qi,Vi,fs=l(()=>{"use strict";Ye();ps();Hi=/^[a-zA-Z][a-zA-Z0-9_-]{1,}$/,qi=new Set(["import"]),Vi=new Set(["common","fixture","fixtures","helper","helpers","index","main","mock","mocks","setup","shared","spec","test","tests","types","util","utils"])});var Ge,Nt=l(()=>{"use strict";Ge=class{isTestNode(e){return e.category==="test"||e.tags.some(r=>r.name==="test")}}});import{execSync as us}from"child_process";function ms(t,e){let s=us(`git -C "${t}" log --follow --format="%ae" --since="90 days ago" -- "${e}"`,{encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).split(`
|
|
20
|
+
`).filter(Boolean);return{commitCount90d:s.length,lastAuthor:s[0]}}var Oe,It=l(()=>{"use strict";Oe=class{getChangedFiles(){try{let r=["git diff --name-only","git diff --cached --name-only","git ls-files --others --exclude-standard"].flatMap(s=>{try{return us(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 je from"fs";import Xi from"path";import gs from"js-yaml";function ds(t){let e=t.lastIndexOf("@");return e>0?t.substring(0,e):t}function Zi(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)),ds(r)}).filter(Boolean)}function Yi(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 ea(t){try{let e=gs.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=ds(o);i&&(r.dependencies[i]={version:n.version,...n.dependencies!==void 0&&{dependencies:n.dependencies}})}return r}catch{return null}}function ta(t){let e={dependencies:{}};for(let r of t.split(/\n\n+/)){let s=r.split(`
|
|
22
|
+
`).filter(c=>c.trim().length>0&&!c.trim().startsWith("#"));if(s.length<2)continue;let n=s[0];if(!n||n.startsWith(" "))continue;let o=Zi(n);if(o.length===0)continue;let a=s.find(c=>c.trim().startsWith('version "'))?.match(/version "(.*?)"/)?.[1]??"";for(let c of o)e.dependencies[c]={version:a}}return e}function ra(t){let e=je.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 sa(t){let e=je.readFileSync(t,"utf-8");if(e.includes("__metadata:")){let r=ea(e);if(r!==null)return r}return ta(e)}function na(t){let e=je.readFileSync(t,"utf-8"),r={dependencies:{}};try{let s=gs.load(e);if(s.packages)for(let[n,o]of Object.entries(s.packages)){let{name:i,version:a}=Yi(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 hs(t){let e=[["package-lock.json",ra],["yarn.lock",sa],["pnpm-lock.yaml",na]];for(let[r,s]of e){let n=Xi.join(t,r);if(je.existsSync(n))return s(n)}return null}var ys=l(()=>{"use strict"});import xs from"path";function M(t){switch(xs.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";default:return"unknown"}}function k(t){let e=xs.extname(t).toLowerCase();return[".css",".scss",".sass",".less",".styl"].includes(e)}var D=l(()=>{"use strict"});import oa from"coffeescript";function ia(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 aa(t,e){let r=t.toLowerCase();return r.includes(".test.")||r.includes(".spec.")||e.has("test")?"test":"logic"}function ca(t,e){let r=e.source?.value;return r?{fromPath:t,toPath:"",rawSpecifier:r,isStyle:k(r),type:"static"}:null}function pa(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:k(s),type:"require"}}function la(t,e,r){let s=e.constructor?.name;if(s==="ImportDeclaration"){let n=ca(t,e);n&&r.push(n)}else if(s==="Call"){let n=pa(t,e);n&&r.push(n)}}function Mt(t,e,r){if(!(!e||typeof e!="object")){la(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)Mt(t,o,r);else Mt(t,n,r)}}}function Ss(t,e){let r=ia(e),s=aa(t,r),n=[];try{Mt(t,oa.nodes(e),n)}catch{}return{imports:n,exports:[],tags:Array.from(r).map(o=>({name:o,kind:"comment-marker"})),category:s}}var bs=l(()=>{"use strict";D()});import{AstBuilder as fa,GherkinClassicTokenMatcher as ua,Parser as ma}from"@cucumber/gherkin";import{IdGenerator as ga}from"@cucumber/messages";function Dt(t,e){let r=new Set;try{let s=new fa(da),n=new ua,i=new ma(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(c=>{r.add(c.name.startsWith("@")?c.name.slice(1):c.name)}),a.scenario.examples.forEach(c=>{c.tags.forEach(p=>{r.add(p.name.startsWith("@")?p.name.slice(1):p.name)})})),a.rule&&a.rule.children.forEach(c=>{c.scenario&&c.scenario.tags.forEach(p=>{r.add(p.name.startsWith("@")?p.name.slice(1):p.name)})})}))}catch(s){console.warn(`[GherkinParser] Failed to parse ${t}:`,s)}return{imports:[],exports:[],tags:Array.from(r).map(s=>({name:s,kind:"comment-marker"})),category:"test"}}var da,vs=l(()=>{"use strict";ne();da=ga.uuid();W("gherkin",Dt)});import ha from"path";import{parser as ya}from"@lezer/go";function Es(t,e){let r=[],s=new Map,n=new Set,o=new Set,a=ya.parse(e).cursor();do switch(a.name){case"LineComment":{let m=e.slice(a.from,a.to),h=m.match(xa);h?.[1]&&n.add(h[1]);let x=m.match(Sa);x&&Cs(x[1],o);let N=m.match(ba);N&&Cs(N[1],o);break}case"ImportSpec":{let m=a.node.getChild("String");if(m){let x=e.slice(m.from,m.to).slice(1,-1);r.push({fromPath:t,toPath:"",rawSpecifier:x,isExternal:!0,isStyle:!1,type:"static"})}break}case"FunctionDecl":case"TypeDecl":case"VarDecl":case"ConstDecl":{let m=a.node.getChild("DefName")??a.node.getChild("TypeSpec")?.getChild("DefName")??a.node.getChild("VarSpec")?.getChild("DefName")??a.node.getChild("ConstSpec")?.getChild("DefName");if(m){let h=e.slice(m.from,m.to);h!=="_"&&/^[A-Z]/.test(h)&&!s.has(h)&&s.set(h,{name:h})}break}}while(a.next());let c=r.some(m=>m.rawSpecifier==="testing"),p=ha.basename(t).endsWith("_test.go")||n.has("test")||c?"test":"logic",u=new Set([...n,...o]);return{imports:r,exports:Array.from(s.values()),tags:Array.from(u).map(m=>({name:m,kind:"comment-marker"})),category:p}}function Cs(t,e){for(let r of t.split(/[\s,&|!()]+/)){let s=r.trim();s&&s!=="ignore"&&e.add(s)}}var xa,Sa,ba,ks=l(()=>{"use strict";xa=/\/\/\s*@tag\s+([a-zA-Z0-9_-]+)/,Sa=/^\/\/go:build\s+(.+)$/,ba=/^\/\/\s*\+build\s+(.+)$/});function q(t){return t.startsWith("'")||t.startsWith('"')?t.slice(1,-1):t}var Rt=l(()=>{"use strict"});import va from"livescript";function Ca(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 Ea(t,e){let r=t.toLowerCase();return r.includes(".test.")||r.includes(".spec.")||e.has("test")?"test":"logic"}function Fa(t,e){let r=t.constructor?.name||t.type;if(r==="Import"){let s=t.right?.value;if(typeof s=="string"){let n=q(s);return{fromPath:e,toPath:"",rawSpecifier:n,isStyle:k(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=q(n);return{fromPath:e,toPath:"",rawSpecifier:o,isStyle:k(o),type:"require"}}}}return null}function At(t,e){if(!t||typeof t!="object")return[];let r=[],s=Fa(t,e);s&&r.push(s);for(let n in t){if(ka.has(n))continue;let o=t[n];if(!(!o||typeof o!="object"))if(Array.isArray(o))for(let i of o)r.push(...At(i,e));else r.push(...At(o,e))}return r}function Fs(t,e){let r=Ca(e),s=Ea(t,r),n=[];try{n=At(va.ast(e),t)}catch{}return{imports:n,exports:[],tags:Array.from(r).map(o=>({name:o,kind:"comment-marker"})),category:s}}var ka,ws=l(()=>{"use strict";D();Rt();ka=new Set(["first_line","first_column","last_line","last_column","line","column"])});import wa from"luaparse";function Ta(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 Pa(t,e){let r=t.toLowerCase();return r.includes(".test.")||r.includes(".spec.")||e.has("test")?"test":"logic"}function Na(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=q(i.raw))}else if(n.type==="StringCallExpression"){let i=n.argument;i?.type==="StringLiteral"&&(o=q(i.raw))}o&&r.push({fromPath:e,toPath:"",rawSpecifier:o,isStyle:k(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 Ts(t,e){let r=Ta(e),s=Pa(t,r),n=[];try{let o=wa.parse(e);n=Na(o,t)}catch{}return{imports:n,exports:[],tags:Array.from(r).map(o=>({name:o,kind:"comment-marker"})),category:s}}var Ps=l(()=>{"use strict";D();Rt()});import Ia from"path";import{parser as Ma}from"@lezer/python";function Ns(t,e){let r=[],s=[],n=new Set,o=Ia.basename(t).toLowerCase(),a=Ma.parse(e).cursor();do switch(a.name){case"Comment":{let p=e.slice(a.from,a.to).match(/#\s*@tag\s+([a-zA-Z0-9_-]+)/);p?.[1]&&n.add(p[1]);break}case"ImportStatement":{for(let p of Ra(a.node,e,t))r.push(p);break}case"FunctionDefinition":case"ClassDefinition":{let p=a.node.parent;if(p?.name==="Script"||p?.name==="DecoratedStatement"&&p.parent?.name==="Script"){let m=a.node.getChild("VariableName");m&&s.push({name:e.slice(m.from,m.to)})}break}case"AssignStatement":{if(a.node.parent?.name==="Script"){let p=a.node.firstChild;p?.name==="VariableName"&&s.push({name:e.slice(p.from,p.to)})}break}}while(a.next());let c=Oa(o,r,n);return c==="test"&&n.add("test"),{imports:r,exports:s,tags:Array.from(n).map(p=>({name:p,kind:"comment-marker"})),category:c}}function Ra(t,e,r){let s=t.firstChild;return s?s.name==="from"?Aa(t,e,r):La(t,e,r):[]}function Aa(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=Ga(n.nextSibling,e);if(!i.length)return[];let a=0;for(;a<o.length&&o[a]===".";)a++;let c=o.slice(a);if(a===0)return[oe(r,o,i,!0)];let p=a===1?"./":"../".repeat(a-1);return c?[oe(r,p+c.replace(/\./g,"/"),i,!1)]:i[0]==="*"?[oe(r,p.slice(0,-1),["*"],!1)]:i.map(u=>oe(r,p+u,[u],!1))}function La(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(oe(r,o,["*"],!0))}n=n.nextSibling}return s}function Ga(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 oe(t,e,r,s){return{fromPath:t,toPath:"",rawSpecifier:e,isStyle:!1,isExternal:s,type:"static",symbols:r.length>0?r:void 0}}function Oa(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=>Da.has(s.rawSpecifier))?"test":"logic"}var Da,Is=l(()=>{"use strict";Da=new Set(["pytest","unittest","nose","hypothesis"])});import g from"typescript";function ja(t){let e=1;function r(s){switch(s.kind){case g.SyntaxKind.IfStatement:case g.SyntaxKind.ConditionalExpression:case g.SyntaxKind.ForStatement:case g.SyntaxKind.ForInStatement:case g.SyntaxKind.ForOfStatement:case g.SyntaxKind.WhileStatement:case g.SyntaxKind.DoStatement:case g.SyntaxKind.CatchClause:case g.SyntaxKind.CaseClause:e++;break;case g.SyntaxKind.BinaryExpression:{let n=s.operatorToken.kind;(n===g.SyntaxKind.AmpersandAmpersandToken||n===g.SyntaxKind.BarBarToken||n===g.SyntaxKind.QuestionQuestionToken)&&e++;break}}g.forEachChild(s,r)}return r(t),e}function _a(t){let e=0;function r(s,n,o){if(g.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&&(g.isIfStatement(s.elseStatement)?r(s.elseStatement,n,!0):(e+=1,r(s.elseStatement,n+1,!1)));return}if(g.isForStatement(s)||g.isForInStatement(s)||g.isForOfStatement(s)||g.isWhileStatement(s)||g.isDoStatement(s)||g.isSwitchStatement(s)){e+=1+n,g.forEachChild(s,a=>r(a,n+1,!1));return}if(g.isCatchClause(s)){e+=1+n,g.forEachChild(s,a=>r(a,n,!1));return}if(g.isConditionalExpression(s)&&(e+=1),g.isBinaryExpression(s)){let a=s.operatorToken.kind;(a===g.SyntaxKind.AmpersandAmpersandToken||a===g.SyntaxKind.BarBarToken||a===g.SyntaxKind.QuestionQuestionToken)&&(e+=1)}if(n>0&&(g.isFunctionDeclaration(s)||g.isFunctionExpression(s)||g.isArrowFunction(s))){e+=1+n,g.forEachChild(s,a=>r(a,n+1,!1));return}g.forEachChild(s,a=>r(a,n,!1))}return r(t,0,!1),e}function Lt(t){return{complexity:ja(t),cognitiveComplexity:_a(t)}}var Ms=l(()=>{"use strict"});import y from"typescript";function Ds(t,e){Wa(t,e),$a(t,e),Ua(t,e),Ba(t,e)}function Wa(t,e){if((y.isFunctionDeclaration(t)||y.isVariableDeclaration(t))&&t.name&&y.isIdentifier(t.name)&&za(t)){let r;if(y.isFunctionDeclaration(t))r="function";else{let s=t.initializer;r=s&&(y.isArrowFunction(s)||y.isFunctionExpression(s))?"function":"variable"}e.tags.add({name:t.name.text,kind:r})}}function za(t){if(y.isFunctionDeclaration(t))return y.isSourceFile(t.parent);let e=t.parent?.parent;return!!e&&y.isSourceFile(e.parent)}function $a(t,e){if(!y.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 Ua(t,e){if(!y.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 Ba(t,e){if(y.isCallExpression(t)&&Ja(t.expression))for(let r of t.arguments)y.isObjectLiteralExpression(r)&&Ka(r,e)}function Ja(t){return y.isIdentifier(t)?Gt.has(t.text):!!(y.isPropertyAccessExpression(t)&&(Gt.has(t.name.text)||y.isIdentifier(t.expression)&&Gt.has(t.expression.text)))}function Ka(t,e){for(let r of t.properties){if(!y.isPropertyAssignment(r)||!y.isIdentifier(r.name)||r.name.text!=="tags"&&r.name.text!=="tag")continue;let{initializer:s}=r,n=y.isArrayLiteralExpression(s)?s.elements.filter(y.isStringLiteral):r.name.text==="tag"&&y.isStringLiteral(s)?[s]:[];for(let o of n)e.tags.add({name:o.text.replace(/^@/,""),kind:"comment-marker"})}}var Gt,Rs=l(()=>{"use strict";Gt=new Set(["test","describe","it"])});import As from"path";import f from"typescript";function Ot(t,e,r){let s=[],n=new Map,o=new Set,i=f.createSourceFile(t,e,f.ScriptTarget.Latest,!0,r==="typescript"?f.ScriptKind.TSX:f.ScriptKind.JSX),a={filePath:t,imports:s,exports:n,tags:o,rawCallEdges:[],sourceFile:i,hasUI:!1,hasTypesOnly:!0,totalStatements:0,exportStatements:0},c=Q=>{Qa(Q,a),f.forEachChild(Q,c)};c(i);let p=ac(t,a);(p==="test"||p==="barrel")&&o.add({name:p,kind:"comment-marker"}),p!=="test"&&cc(a,i);let u=i.statements[0],m=u?Gs(u):void 0,{complexity:h,cognitiveComplexity:x}=Lt(i),N=Ha(i);return{imports:s,exports:Array.from(n.values()),tags:Array.from(o),category:p,rawCallEdges:a.rawCallEdges??[],complexity:h,cognitiveComplexity:x,...N.length>0?{functions:N}:{},...m!==void 0?{description:m}:{}}}function Ha(t){let e=[],r=(n,o)=>{let{complexity:i,cognitiveComplexity:a}=Lt(o),c=t.getLineAndCharacterOfPosition(o.getStart(t)).line+1;e.push({name:n,line:c,complexity:i,cognitiveComplexity:a})},s=(n,o)=>{if(f.isFunctionDeclaration(n)&&n.name&&n.body?r(n.name.text,n):f.isVariableDeclaration(n)&&f.isIdentifier(n.name)&&n.initializer&&(f.isArrowFunction(n.initializer)||f.isFunctionExpression(n.initializer))?r(n.name.text,n.initializer):o&&f.isMethodDeclaration(n)&&f.isIdentifier(n.name)&&n.body?r(`${o}.${n.name.text}`,n):o&&f.isConstructorDeclaration(n)&&n.body?r(`${o}.constructor`,n):o&&f.isGetAccessorDeclaration(n)&&f.isIdentifier(n.name)&&n.body?r(`${o}.get ${n.name.text}`,n):o&&f.isSetAccessorDeclaration(n)&&f.isIdentifier(n.name)&&n.body&&r(`${o}.set ${n.name.text}`,n),f.isClassDeclaration(n)&&n.name){let i=n.name.text;f.forEachChild(n,a=>s(a,i));return}f.forEachChild(n,i=>s(i,o))};return s(t,void 0),e}function Ls(t,e,r,s){let n={name:t},o=Gs(r);o!==void 0&&(n.doc=o);let i=qa(e);i!==void 0&&(n.flags=i);let a=Va(e,s);return a!==void 0&&(n.signature=a),n}function Gs(t){let e=f.getJSDocCommentsAndTags(t);for(let r of e)if(f.isJSDoc(r)&&r.comment)return f.getTextOfJSDocComment(r.comment)||void 0}function qa(t){let e=new Set(["deprecated","internal","public","alpha","beta"]),r=f.getJSDocTags(t).map(s=>s.tagName.text).filter(s=>e.has(s));return r.length>0?r:void 0}function Va(t,e){let r=f.createPrinter({removeComments:!0}),s=n=>r.printNode(f.EmitHint.Unspecified,n,e);if(f.isFunctionDeclaration(t)||f.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(f.isVariableDeclaration(t)){if(t.type)return s(t.type);if(t.initializer&&(f.isArrowFunction(t.initializer)||f.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(f.isClassDeclaration(t)&&t.name)return`class ${t.name.text}`;if(f.isInterfaceDeclaration(t))return`interface ${t.name.text}`;if(f.isTypeAliasDeclaration(t))return s(t.type);if(f.isEnumDeclaration(t))return`enum ${t.name.text}`}function Qa(t,e){Xa(t,e),Za(t,e),ec(t,e),tc(t,e),ic(t,e),Ds(t,e)}function Xa(t,e){if(!f.isSourceFile(t))return;let r=t.statements.filter(s=>!f.isEmptyStatement(s));e.totalStatements=r.length,e.exportStatements=r.filter(s=>f.isExportDeclaration(s)||f.isExportAssignment(s)||jt(s)).length}function Za(t,e){if(f.isJsxElement(t)||f.isJsxSelfClosingElement(t)||f.isJsxFragment(t)){e.hasUI=!0,e.hasTypesOnly=!1;return}if(f.isFunctionDeclaration(t)||f.isMethodDeclaration(t)||f.isArrowFunction(t)||f.isClassDeclaration(t)||f.isVariableStatement(t)||f.isEnumDeclaration(t)){e.hasTypesOnly=!1;return}f.isExportDeclaration(t)&&!Ya(t)&&(e.hasTypesOnly=!1)}function Ya(t){return t.isTypeOnly?!0:!t.exportClause||!f.isNamedExports(t.exportClause)?!1:t.exportClause.elements.every(e=>e.isTypeOnly)}function ec(t,e){if(!f.isImportDeclaration(t)||!t.moduleSpecifier||!f.isStringLiteral(t.moduleSpecifier))return;let r=[];if(t.importClause&&(t.importClause.name&&r.push("default"),t.importClause.namedBindings))if(f.isNamedImports(t.importClause.namedBindings))for(let n of t.importClause.namedBindings.elements)r.push(n.name.text);else f.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:k(t.moduleSpecifier.text),type:s,symbols:r.length>0?r:void 0})}function tc(t,e){f.isExportDeclaration(t)?rc(t,e):f.isExportAssignment(t)?e.exports.set("default",{name:"default"}):jt(t)&&oc(t,e)}function rc(t,e){if(t.moduleSpecifier&&f.isStringLiteral(t.moduleSpecifier))sc(t,t.moduleSpecifier.text,e);else if(t.exportClause&&f.isNamedExports(t.exportClause))for(let r of t.exportClause.elements){let s=r.name.text;e.exports.set(s,{name:s})}}function sc(t,e,r){let s=nc(t),n={fromPath:r.filePath,toPath:"",rawSpecifier:e,isStyle:k(e),type:"re-export"};s.length>0&&(n.symbols=s),r.imports.push(n)}function nc(t){return t.exportClause?f.isNamedExports(t.exportClause)?t.exportClause.elements.map(e=>e.name.text):[]:["*"]}function oc(t,e){if((f.isFunctionDeclaration(t)||f.isClassDeclaration(t)||f.isInterfaceDeclaration(t)||f.isTypeAliasDeclaration(t)||f.isEnumDeclaration(t))&&t.name){let s=t.name.text;e.exports.set(s,Ls(s,t,t,e.sourceFile));return}if(f.isVariableStatement(t)){for(let s of t.declarationList.declarations)if(f.isIdentifier(s.name)){let n=s.name.text;e.exports.set(n,Ls(n,s,t,e.sourceFile))}}}function ic(t,e){if(!f.isCallExpression(t))return;let r=t.arguments[0];!r||!f.isStringLiteral(r)||(t.expression.kind===f.SyntaxKind.ImportKeyword?e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:r.text,isStyle:k(r.text),type:"dynamic"}):f.isIdentifier(t.expression)&&t.expression.text==="require"&&e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:r.text,isStyle:k(r.text),type:"require"}))}function ac(t,e){let r=As.basename(t).toLowerCase(),s=As.extname(t).toLowerCase();return X().some(o=>r.includes(o))?"test":sr(r)?"config":e.imports.some(o=>qe().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>Qe()?"barrel":"logic"}function jt(t){return f.canHaveModifiers(t)&&f.getModifiers(t)?.some(e=>e.kind===f.SyntaxKind.ExportKeyword)===!0}function cc(t,e){let r=t.rawCallEdges??[];t.rawCallEdges=r;let s=new Map;for(let n of e.statements){if(!f.isImportDeclaration(n)||!f.isStringLiteral(n.moduleSpecifier))continue;let o=n.moduleSpecifier.text,i=n.importClause;if(i&&(i.name&&s.set(i.name.text,o),i.namedBindings&&f.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=lc(n);if(o){let i=fc(n);i&&_e(i,o,s,r);continue}f.isClassDeclaration(n)&&n.name&&pc(n,s,r)}}function pc(t,e,r){let s=t.name.text;for(let n of t.members)f.isMethodDeclaration(n)&&n.body&&f.isIdentifier(n.name)?_e(n.body,`${s}.${n.name.text}`,e,r):f.isConstructorDeclaration(n)&&n.body&&_e(n.body,`${s}.constructor`,e,r)}function lc(t){if(jt(t)){if(f.isFunctionDeclaration(t)&&t.name)return t.name.text;if(f.isVariableStatement(t)){for(let e of t.declarationList.declarations)if(f.isIdentifier(e.name)&&e.initializer&&(f.isArrowFunction(e.initializer)||f.isFunctionExpression(e.initializer)))return e.name.text}}}function fc(t){if(f.isFunctionDeclaration(t))return t.body;if(f.isVariableStatement(t)){for(let e of t.declarationList.declarations)if(e.initializer&&(f.isArrowFunction(e.initializer)||f.isFunctionExpression(e.initializer)))return e.initializer}}function _e(t,e,r,s){if(f.isCallExpression(t)&&f.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})}f.forEachChild(t,n=>_e(n,e,r,s))}var Os=l(()=>{"use strict";G();Ms();D();Rs()});function We(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 js=l(()=>{"use strict"});import Ws from"postcss";function _s(t){return t.startsWith("~")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//")||t.startsWith("data:")}function mc(t){let e=t.trim();return e.length>0&&!e.startsWith("http://")&&!e.startsWith("https://")&&!e.startsWith("//")&&!e.startsWith("data:")&&!e.startsWith("#")}function gc(t,e){let r=t.match(/^\(([^)]+)\)\s+['"]([^'"]+)['"]/);if(r){let o=r[1]?.trim()??"",i=r[2]??"";if(!i)return null;let a=zs.has(o)?"side-effect":"static";return{fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:a,..._s(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",..._s(n)?{isExternal:!0}:{}}:null}function dc(t,e){let r=[],s=/url\(['"]?([^'")]+)['"]?\)/g,n=s.exec(t);for(;n!==null;){let o=n[1]?.trim()??"";mc(o)&&r.push({fromPath:e,toPath:"",rawSpecifier:o,isStyle:!0,type:"static"}),n=s.exec(t)}return r}function $s(t,e){let r=[];return t.walk(s=>{if(s.type==="atrule"&&s.name==="import"){let n=gc(s.params,e);n&&r.push(n)}s.type==="decl"&&r.push(...dc(s.value,e))}),r}function hc(t){return t.replace(/(?<!:)\/\/.*/g,"")}function yc(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=zs.has(o)?"side-effect":"static";r.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:a})}n=s.exec(t)}return r}function Us(t,e){let r=Ws.parse(hc(t));return{imports:$s(r,e),root:r}}function Bs(t,e){try{let r=uc.parse(t);return{imports:$s(r,e),root:r}}catch{return{imports:yc(t,e),root:Ws.parse("")}}}var uc,zs,Js=l(()=>{"use strict";uc=ge("postcss-less"),zs=new Set(["reference","inline"])});import{parse as xc}from"postcss-scss";function Sc(t){return!!(t.startsWith("sass:")||t.startsWith("~")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//")||!t.startsWith(".")&&!t.startsWith("/")&&!t.startsWith("_"))}function bc(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 Ks(t,e){let r=xc(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:c}=bc(i);if(!a)return;let p={fromPath:e,toPath:"",rawSpecifier:a,isStyle:!0,type:o==="forward"?"re-export":"static",...Sc(a)?{isExternal:!0}:{}};c&&(p.symbols=[c]),s.push(p)}),{imports:s,root:r}}var Hs=l(()=>{"use strict"});function qs(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 Vs(t,e){if(e.length===0)return"ui";try{let r=ge("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 Qs=l(()=>{"use strict"});function ie(t,e){let r=M(t);if(r==="stylus"){let o=qs(e,t);return{imports:o,exports:[],tags:[],category:Vs(e,o)}}if(r==="scss"){let{imports:o,root:i}=Ks(e,t);return{imports:o,exports:[],tags:[],category:We(i,o)}}if(r==="less"){let{imports:o,root:i}=Bs(e,t);return{imports:o,exports:[],tags:[],category:We(i,o)}}let{imports:s,root:n}=Us(e,t);return{imports:s,exports:[],tags:[],category:We(n,s)}}var Xs=l(()=>{"use strict";D();js();Js();Hs();Qs()});async function Zs(t,e){let r=M(t),s=Gr(r);return s?s(t,e):{imports:[],exports:[],tags:[],category:"other"}}var Ys=l(()=>{"use strict";D();bs();vs();ks();ws();Ps();Is();Os();ne();Xs();G();D();ne();for(let[t,e]of[["javascript",(r,s)=>Ot(r,s,"javascript")],["typescript",(r,s)=>Ot(r,s,"typescript")],["css",ie],["scss",ie],["less",ie],["stylus",ie],["coffeescript",Ss],["livescript",Fs],["lua",Ts],["python",Ns],["go",Es],["gherkin",Dt]])W(t,e)});import _t from"path";function tn(t,e){for(let r of t.values()){let s=e.get(r.path);s!==void 0&&(r.coveragePct=s)}}function rn(t,e){for(let r of t)if(!r.rawSpecifier.startsWith(".")&&!_t.isAbsolute(r.rawSpecifier)){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 sn(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 en(t){return Math.round(t*1e4)/1e4}function nn(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=en(Math.min(1,o)),r.push(s.exportUsageRatio)}r.length>0&&(e.avgExportUsage=en(r.reduce((s,n)=>s+n,0)/r.length),e.maxExportUsage=Math.max(...r))}}function Wt(t,e,r){e&&(t.some(s=>s.name===e&&s.kind===r)||t.push({name:e,kind:r}))}function vc(t,e){let r=e.toPath,s=_t.basename(r,_t.extname(r)).replace(/\.(test|spec)$/,"");Wt(t.tags,s,"import")}function Cc(t,e){if(!(!e.symbols||e.symbols.includes("*")))for(let r of e.symbols)Wt(t.tags,r,"import")}function Ec(t,e,r){let s=r.get(e.toPath);if(!(!s||s.category==="test"))for(let n of s.tags)n.kind==="comment-marker"&&Wt(t.tags,n.name,"comment-marker")}function on(t){for(let e of t.values())if(e.category==="test")for(let r of e.imports)!r.toPath||r.isExternal||(vc(e,r),Cc(e,r),Ec(e,r,t))}var an=l(()=>{"use strict"});import ln from"fs";import V from"path";function kc(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("=>")){cn(a,e,n);continue}!o&&/^replace\s+/.test(a)&&a.includes("=>")&&cn(a.replace(/^replace\s+/,""),e,n)}return{mod:s,replaces:n}}function cn(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=V.isAbsolute(n)?n:V.resolve(e,n);r.set(o,i)}function pn(t){let e;try{e=ln.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:V.join(t,s.name),isExternal:!1})).sort((s,n)=>s.path.localeCompare(n.path));return r.length>0?r:null}var ae,fn=l(()=>{"use strict";ae=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 pn(a);if(r!==o&&!r.startsWith(`${o}/`))return null;let c=r.slice(o.length).replace(/^\//,"");return c?pn(V.join(s,c)):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=ln.readFileSync(V.join(e,"go.mod"),"utf-8"),o=kc(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 V.join(o,i)}}}}});import Fc from"fs";import zt from"path";var ce,un=l(()=>{"use strict";ce=class{extensions=[".lua"];resolve(e,r,s,n){let o=r.replace(/\./g,zt.sep),i=[s,zt.join(s,"lib")];for(let a of i){if(!Fc.existsSync(a))continue;let c=n(zt.join(a,"_dummy.lua"),o);if(c)return[c]}return null}}});import wc from"fs";import $t from"path";function mn(t){try{return wc.statSync(t,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}var pe,gn=l(()=>{"use strict";pe=class{extensions=[".py"];resolve(e,r,s,n){let o=r.replace(/\./g,$t.sep),i=$t.join(s,`${o}.py`);if(mn(i))return[{path:i,isExternal:!1}];let a=$t.join(s,o,"__init__.py");return mn(a)?[{path:a,isExternal:!1}]:null}}});var dn=l(()=>{"use strict";fn();un();gn()});import ze from"fs";import R from"path";var le,Ut=l(()=>{"use strict";dn();le=class{constructor(e,r={}){this.rootDir=e;this.workspaceMap=r.workspaceMap??new Map,this.tsconfigSearchPaths=r.tsconfigSearchPaths??[e],this.langResolvers=r.langResolvers??[new pe,new ce,new ae]}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=R.dirname(e),n=r.startsWith("/")?r:R.resolve(s,r),o=!n.startsWith(this.rootDir),i=["",".ts",".tsx",".js",".jsx",".mjs",".cjs",".css",".scss",".sass",".less",".styl",".coffee",".ls",".lua",".py",".feature"],a=n.match(/\.(js|mjs|cjs)$/);if(a){let c=n.slice(0,-a[0].length);for(let p of[".ts",".tsx"]){let u=this.tryExtensions(c,p,o);if(u)return u}}for(let c of i){let p=this.tryExtensions(n,c,o);if(p)return p}return o?{path:n,isExternal:!0}:null}tryExtensions(e,r,s){let n=e+r;if(this.isFile(n))return{path:n,isExternal:s};let o=R.join(e,`index${r}`);if(this.isFile(o))return{path:o,isExternal:s};if(r===".py"){let i=R.join(e,"__init__.py");if(this.isFile(i))return{path:i,isExternal:s}}return null}isFile(e){try{return ze.statSync(e,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}resolvePathAlias(e){for(let r of this.tsconfigSearchPaths){let s=R.join(r,"tsconfig.json");if(ze.existsSync(s))try{let o=JSON.parse(ze.readFileSync(s,"utf-8")).compilerOptions?.paths;if(!o)continue;for(let i in o){let a=this.matchAliasPattern(i,e);if(a){let c=this.tryAliasSubstitutions(o[i],a[1]||"",r);if(c)return c}}}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=R.resolve(s,i);for(let c of n){let p=this.tryExtensions(a,c,!1);if(p)return p}}return null}resolveWorkspaceImport(e){if(this.workspaceMap.size===0)return null;for(let[r,s]of this.workspaceMap){if(e!==r&&!e.startsWith(`${r}/`))continue;let n=e.slice(r.length),o={path:"",isExternal:!1,isWorkspace:!0,workspacePackage:r};if(!n){for(let a of["src/index.ts","src/index.tsx","index.ts","index.tsx","index.js"]){let c=R.join(s,a);try{if(ze.statSync(c,{throwIfNoEntry:!1})?.isFile())return{...o,path:c}}catch{}}return{...o,path:s}}let i=this.resolveLocalPath(R.join(s,"_dummy"),n.slice(1));return i?{...o,path:i.path}:null}return null}}});import $e from"fs";import C from"path";function Pc(t,e){if(t.length===0)return e;let r=t.map(i=>C.dirname(i).split(C.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(C.sep)||C.sep,o=C.relative(e,n);return o.startsWith("..")||C.isAbsolute(o)?e:n}var Tc,Ue,hn=l(()=>{"use strict";It();G();ys();Ys();an();ee();Ut();Tc=["tests","test","__tests__","specs","spec"];Ue=class{constructor(e,r=null,s,n,o=!1,i=new Map){this.rootDir=e;this.enableGitStats=o;this.coverageMap=i;this.previousGraph=r,this.resolver=s||new le(e),this.lockFile=hs(e),n&&(this.progressCallback=n)}rootDir;enableGitStats;coverageMap;graph={nodes:new Map};visited=new Set;previousGraph=null;resolver;lockFile=null;progressCallback;async build(e){let r=e.map(s=>C.isAbsolute(s)?s:C.resolve(this.rootDir,s));for(let s of r)await this.processFile(s);return await this.processTestFiles(Pc(r,this.rootDir)),this.progressCallback&&this.visited.size>=100&&process.stderr.write(`
|
|
24
|
+
Done. Total processed: ${this.visited.size} nodes.
|
|
25
|
+
`),on(this.graph.nodes),sn(this.graph.nodes),nn(this.graph.nodes),this.coverageMap.size>0&&tn(this.graph.nodes,this.coverageMap),new F(this.graph.nodes)}async processTestFiles(e){let r=X(),s=new Set(["node_modules",".git","dist","build",".next",".cache","mokosh-cache","coverage"]),n=async i=>{let a;try{a=$e.readdirSync(i,{withFileTypes:!0})}catch{return}for(let c of a){let p=C.join(i,c.name);c.isDirectory()?s.has(c.name)||await n(p):c.isFile()&&r.some(u=>c.name.includes(u))&&await this.processFile(p)}};await n(e);let o=e;for(;o!==this.rootDir;){let i=C.dirname(o);if(i===o)break;for(let a of Tc){let c=C.join(i,a);try{$e.statSync(c).isDirectory()&&await n(c)}catch{}}o=i}}async processFile(e){if(this.visited.has(e))return;this.visited.add(e),this.showProgress();let r=$e.statSync(e,{throwIfNoEntry:!1});if(!r?.isFile())return;let s=C.relative(this.rootDir,e),n=await this.getNode(e,s,r);n.imports=await this.resolveImports(e,n.imports),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);rn(o.imports,o.tags);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=$e.readFileSync(e,"utf-8");try{return await Zs(e,s)}catch(n){return process.stderr.write(`
|
|
26
|
+
Warning: failed to parse ${r}: ${n}
|
|
27
|
+
`),null}}makeStubNode(e,r,s){return{path:r,type:M(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:C.relative(this.rootDir,o.path)})}catch{}return s}buildNode(e,r,s,n,o){let{imports:i,exports:a,tags:c,category:p,description:u,complexity:m,cognitiveComplexity:h,functions:x}=n;return{path:r,type:M(e),category:p,imports:i,exports:a,tags:c,mtime:s.mtimeMs,size:s.size,...u!==void 0?{description:u}:{},...o.length>0?{callEdges:o}:{},...m!==void 0?{complexity:m}:{},...h!==void 0?{cognitiveComplexity:h}:{},...x!==void 0?{functions:x}:{}}}attachGitStats(e,r){if(this.enableGitStats)try{let s=ms(this.rootDir,r);e.commitCount90d=s.commitCount90d,s.lastAuthor!==void 0&&(e.lastAuthor=s.lastAuthor)}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:C.relative(this.rootDir,i.path),isExternal:i.isExternal};i.isWorkspace&&(a.isWorkspace=!0,a.workspacePackage=i.workspacePackage),i.isExternal?this.attachLockfileVersion(a):await this.processFile(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 yn=l(()=>{"use strict";it();hn();ct();pt();be();ve();ee();Ut();ft();ut();dt();St();bt()});var Bt=l(()=>{"use strict";yn()});function xn(t,e){return{identifier:e?.identifier??new Ge,featureMap:e?.featureDetection===!1?new Map:A(t.nodes,e?.featureDetection??void 0)}}function Sn(t,e,r,s,n){for(let o of e){let i=t.nodes.get(o);if(!i)continue;let a=new re(o,["*",...i.exports.map(c=>c.name)]);t.traverse(o,(c,p,u)=>{if(!u)return!0;if(!a.updateAffectedSymbols(c,u))return!1;if(p>0){let m=r.get(c.path);if(m)return s(m),!1}return n(c),!0},{direction:"incoming"})}}function Jt(t,e,r){let{identifier:s,featureMap:n}=xn(t,r),o=new Set;for(let i of e){let a=n.get(i);a&&o.add(a.tag)}return Sn(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 Kt(t,e,r){let{identifier:s,featureMap:n}=xn(t,r),o=new Set;return Sn(t,e,n,()=>{},i=>{s.isTestNode(i)&&o.add(i.path)}),Array.from(o)}var bn=l(()=>{"use strict";Bt();Nt()});var vn=l(()=>{"use strict";fs();Nt();bn()});import Mc from"fs";import Be from"path";async function w(t,e,r=null,s={}){let n=s.silent?void 0:i=>{process.stderr.write(`Processed ${i} files...\r`)};return await new Ue(Be.resolve(t),r,void 0,n,s.gitStats??!1,s.coverageMap??new Map).build(e)}function T(t,e={}){let r=[],s=new Set([...e.ignoreDirs??et,...e.additionalIgnoreDirs??[]]),n=new Set([...e.extensions??tt,...e.additionalExtensions??[]]);function o(i){try{let a=Mc.readdirSync(i,{withFileTypes:!0});for(let c of a){let p=Be.join(i,c.name);c.isDirectory()?s.has(c.name)||o(p):c.isFile()&&n.has(Be.extname(c.name).toLowerCase())&&r.push(Be.relative(t,p))}}catch{}}return o(t),r}var v=l(()=>{"use strict";Ye();rt();lr();ur();it();ct();pt();be();ve();ee();ft();ut();dt();St();Fe();bt();G();ne();Ur();vn();rt();Bt()});var Cn,En,kn=l(()=>{"use strict";Cn="mokosh-cache",En="graph.json"});import fe from"path";import{parseArgs as Dc}from"util";function Rc(t){for(let e=0;e<t.length;e++)if(t[e]==="--root"&&t[e+1])return fe.resolve(t[e+1]);return process.cwd()}function Lc(t){let e=[];for(let r=0;r<t.length;r++){let s=t[r];if(!s.startsWith("--"))e.push(s);else if(Ac.has(s)){let n=t[r+1];n!==void 0&&!n.startsWith("--")&&(e.push(s,n),r++)}else s.slice(2)in Ht&&e.push(s)}return e}function Fn(t){let e=Rc(t),r=fe.join(fe.resolve(e,Cn),En),{values:s,positionals:n}=Dc({args:Lc(t),allowPositionals:!0,options:Ht}),o=s["feature-threshold"],i=s["min-out-degree"],a=s.paths,c=s.cache,p=s.config;return{rootDir:e,cachePath:c?fe.resolve(e,c):r,configPath:p?fe.resolve(e,p):void 0,query:s.query,file:s.file,typeFilter:s.type,functionName:s.function,filterPaths:a?a.split(",").map(u=>u.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,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,entryPoints:n}}var Ht,Ac,wn=l(()=>{"use strict";kn();Ht={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"},"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"}},Ac=new Set(Object.entries(Ht).filter(([,t])=>t.type==="string").map(([t])=>`--${t}`))});import qt from"path";function L(t){return t.filter(e=>{let r=qt.basename(e).toLowerCase();return Gc.some(s=>r.includes(s))})}function Je(t){return new Oe().getChangedFiles().map(e=>qt.relative(t,qt.resolve(t,e)))}var Gc,Ke=l(()=>{"use strict";It();Gc=[".test.",".spec.","-test.","-spec."]});async function Tn(t){let{graph:e}=t,{rootDir:r,scanOptions:s,featureThreshold:n}=t,o=Je(r);if(![...e.nodes.values()].some(c=>L([c.path]).length>0)){let c=T(r,s);e=await w(r,L(c),e)}let a=Kt(e,o,{...n!==void 0&&{featureDetection:{minOutDegree:n}}});console.log(a.join(`
|
|
28
|
+
`))}var Pn=l(()=>{"use strict";v();Ke()});async function Nn(t){let{graph:e,rootDir:r,entryPoints:s}=t,n=s.length?s:nt(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=ot(e,n);console.log(JSON.stringify(o,null,2))}var In=l(()=>{"use strict";v()});async function Mn(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=T(r,s);e=await w(r,L(a),e)}let i=await Pt(e,r,{dryRun:n});console.log(JSON.stringify(i,null,2))}var Dn=l(()=>{"use strict";v();Ke()});async function Rn(t){let{graph:e,functionName:r}=t;r||(console.error("Error: --call-graph requires --function <name>"),process.exit(1));let s=at(e,r);console.log(JSON.stringify(s,null,2))}var An=l(()=>{"use strict";v()});async function Ln(t){let{graph:e,file:r,plain:s}=t;r||(console.error("Error: --callers requires --file <path>"),process.exit(1));let n=e.getCallers(r);console.log(s?n.join(`
|
|
29
|
+
`):JSON.stringify({file:r,callers:n,count:n.length},null,2))}var Gn=l(()=>{"use strict"});async function On(t){let{graph:e}=t,r=e.findCycles();if(r.length>0){process.stderr.write(`Found ${r.length} cycle(s):
|
|
30
|
+
`);for(let s of r)process.stderr.write(` ${s.join(" \u2192 ")}
|
|
31
|
+
`);process.exit(1)}console.log("No cycles detected.")}var jn=l(()=>{"use strict"});async function _n(t){let{graph:e}=t,{rootDir:r,scanOptions:s,featureThreshold:n}=t;if(e.nodes.size===0){let a=T(r,s);e=await w(r,a,e)}let o=A(e.nodes,n!==void 0?{minOutDegree:n}:void 0),i=Array.from(o.values()).sort((a,c)=>c.outDegree-a.outDegree);console.log(JSON.stringify({features:i},null,2))}var Wn=l(()=>{"use strict";v()});async function zn(t){let{graph:e}=t,{rootDir:r,scanOptions:s,minOutDegree:n}=t;if(e.nodes.size===0){let a=T(r,s);e=await w(r,a,e)}let o=Z(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 $n=l(()=>{"use strict";v()});async function Un(t){let{graph:e,featureThreshold:r,rawConfig:s,plain:n}=t,o=r??s.coverageThreshold??80,i=[...e.nodes.values()].filter(a=>a.category!=="test"&&a.category!=="config").filter(a=>(a.coveragePct??0)<o).map(a=>({file:a.path,coveragePct:a.coveragePct??null}));console.log(n?i.map(a=>a.file).join(`
|
|
32
|
+
`):JSON.stringify({threshold:o,uncovered:i,count:i.length},null,2))}var Bn=l(()=>{"use strict"});import Oc from"path";function _c(t){let e=Oc.basename(t).toLowerCase();return jc.some(r=>e.includes(r))}async function Jn(t){let{graph:e,rootDir:r,scanOptions:s,excludeTests:n}=t,o=T(r,s),i=e.findUnusedFiles(o);n&&(i=i.filter(a=>!_c(a))),console.log(JSON.stringify({unusedFiles:i},null,2))}var jc,Kn=l(()=>{"use strict";v();jc=[".test.",".spec.","-test.","-spec.",".stories."]});async function Hn(t){let{graph:e,queryStr:r,mermaidOutput:s}=t,n=e.serialize();if(r){let o=Te(r);n=we(n,o)}if(s){let o=F.deserialize(n);console.log(xe.serialize(o))}else{let o=e.findCycles();o.length>0&&(n.cycles=o),console.log(JSON.stringify(n,null,2))}}var qn=l(()=>{"use strict";v()});async function Vn(t){let{graph:e,filterPaths:r,minOutDegree:s}=t,n=lt(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 Qn=l(()=>{"use strict";v()});async function Xn(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=Je(r);if(e.nodes.size===0){let c=T(r,s);e=await w(r,L(c),e)}let a=Jt(e,i,{...n!==void 0&&{featureDetection:{minOutDegree:n}}});console.log(o?a.join(" "):JSON.stringify({proposedTags:a},null,2))}var Zn=l(()=>{"use strict";v();Ke()});async function Yn(t){let{graph:e,typeFilter:r}=t,s=mt(e);if(r){let n=gt(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 eo=l(()=>{"use strict";v()});import Vt from"path";function to(t){let{rootDir:e,entryPoints:r,cachePath:s,configPath:n}=t,o=n?O(n,{isExplicitPath:!0}):O(e),i=Vt.join(Vt.resolve(e,"mokosh-cache"),"graph.json"),a=r.length>0?r:o.entryPoints??[],c=s!==i?s??i:o.cachePath?Vt.resolve(e,o.cachePath):s??i,p={...o.ignoreDirs!==void 0&&{additionalIgnoreDirs:o.ignoreDirs},...o.extensions!==void 0&&{additionalExtensions:o.extensions}};return{rootDir:e,resolvedEntryPoints:a,resolvedCachePath:c,scanOptions:p,rawConfig:o}}var ro=l(()=>{"use strict";v()});import ue from"fs";import Wc from"path";function so(t){if(!ue.existsSync(t))return null;let e=ue.readFileSync(t,"utf-8");return F.deserialize(JSON.parse(e))}function no(t,e){let r=Wc.dirname(e);ue.existsSync(r)||ue.mkdirSync(r,{recursive:!0}),ue.writeFileSync(e,JSON.stringify(t.serialize(),null,2))}async function oo(t,e,r,s=!1,n=!1){return w(t,e,r,{silent:s,gitStats:n})}var io=l(()=>{"use strict";v()});var ao,co,po=l(()=>{"use strict";ao=`
|
|
33
|
+
Usage: mokosh [options] <entry-point1> <entry-point2> ...
|
|
34
|
+
|
|
35
|
+
Options:
|
|
36
|
+
--cache [file] Path to cache file (default: mokosh-cache/graph.json)
|
|
37
|
+
--config <file> Path to mokosh config file (overrides auto-discovery)
|
|
38
|
+
--mermaid Output Mermaid chart instead of JSON
|
|
39
|
+
--propose-tags Propose test tags based on git diff
|
|
40
|
+
--plain Output tags as plain text instead of JSON (use with --propose-tags)
|
|
41
|
+
--affected-tests List test files affected by git diff
|
|
42
|
+
--apply-tags Write @tag annotations into test files from graph tags
|
|
43
|
+
--dry-run Preview tag changes without writing to disk (use with --apply-tags)
|
|
44
|
+
--detect-features Output files with high out-degree (orchestrators/aggregators)
|
|
45
|
+
--feature-threshold <N> Min internal imports to be a feature hub (default: 5)
|
|
46
|
+
--find-unused Find files that are not reachable from entry points
|
|
47
|
+
--exclude-tests Exclude test files from --find-unused output
|
|
48
|
+
--check-cycles Check for circular dependencies; exits non-zero if found (CI gate)
|
|
49
|
+
--type-graph Output type-level graph (interfaces, classes, enums, type aliases)
|
|
50
|
+
--type <name> Filter --type-graph to a single type name
|
|
51
|
+
--module-responsibility Output each file's semantic role, description, and exports
|
|
52
|
+
--paths <a,b,...> Comma-separated file paths to filter --module-responsibility output
|
|
53
|
+
--min-out-degree <N> Min internal imports for hub detection (--module-responsibility, --feature-graph)
|
|
54
|
+
--feature-graph Group files into feature domains under their hub orchestrators
|
|
55
|
+
--call-graph Look up callers and callees for a named function
|
|
56
|
+
--function <name> Function name to look up with --call-graph
|
|
57
|
+
--api-surface Output the public API surface (expands export * chains)
|
|
58
|
+
--silent Suppress progress output on stderr
|
|
59
|
+
--query <query> Filter output using a query (e.g., category:logic,tag:auth)
|
|
60
|
+
--query-help Show all supported query filter keys and examples
|
|
61
|
+
--root <dir> Project root directory (default: current directory)
|
|
62
|
+
--help Show help
|
|
63
|
+
|
|
64
|
+
Notes:
|
|
65
|
+
Add mokosh-cache/ to your .gitignore to avoid committing the cache directory.
|
|
66
|
+
`,co=`
|
|
67
|
+
Query filter reference (--query "key:value,key:value,...")
|
|
68
|
+
All keys are case-insensitive. Multiple keys are AND'd together.
|
|
69
|
+
|
|
70
|
+
FILTERING
|
|
71
|
+
category:<value> Exact match on file category. Negate with !.
|
|
72
|
+
Values: logic | ui | test | config | barrel | type-only | other
|
|
73
|
+
Examples: category:logic category:!test
|
|
74
|
+
|
|
75
|
+
type:<value> Exact match on language. Negate with !.
|
|
76
|
+
Values: typescript | javascript | css | scss | less | stylus |
|
|
77
|
+
coffeescript | livescript | lua | gherkin
|
|
78
|
+
Example: type:typescript
|
|
79
|
+
|
|
80
|
+
tag:<value> File has this tag (OR across multiple tag: entries).
|
|
81
|
+
Negate with ! to exclude. Use + to require all (AND).
|
|
82
|
+
Examples: tag:auth (has "auth")
|
|
83
|
+
tag:!generated (does not have "generated")
|
|
84
|
+
tag:auth+core (has both "auth" AND "core")
|
|
85
|
+
|
|
86
|
+
path:<substr> File path contains substring. Negate with !.
|
|
87
|
+
Examples: path:src/api path:!__tests__
|
|
88
|
+
|
|
89
|
+
external:<bool> true = node has at least one external (node_modules) import.
|
|
90
|
+
Example: external:true
|
|
91
|
+
|
|
92
|
+
importsFile:<substr> Node directly imports a file whose path contains the substring.
|
|
93
|
+
Example: importsFile:src/utils/logger
|
|
94
|
+
|
|
95
|
+
importedBy:<substr> Node is directly imported by a file whose path contains the substring.
|
|
96
|
+
Example: importedBy:src/index
|
|
97
|
+
|
|
98
|
+
minImports:<N> Out-degree (direct import count) >= N.
|
|
99
|
+
maxImports:<N> Out-degree <= N.
|
|
100
|
+
Examples: minImports:5 maxImports:2
|
|
101
|
+
|
|
102
|
+
minSize:<bytes> File size >= N bytes.
|
|
103
|
+
maxSize:<bytes> File size <= N bytes.
|
|
104
|
+
Examples: minSize:1024 maxSize:4096
|
|
105
|
+
|
|
106
|
+
hasDocstring:<bool> true = node has a JSDoc description on its first statement.
|
|
107
|
+
false = undocumented files only.
|
|
108
|
+
Example: hasDocstring:false
|
|
109
|
+
|
|
110
|
+
SORTING & LIMITING (applied after all filters)
|
|
111
|
+
sort:<field> Sort results descending by one of:
|
|
112
|
+
size \u2014 file size in bytes
|
|
113
|
+
imports \u2014 number of direct imports
|
|
114
|
+
commitCount90d \u2014 commits in the last 90 days (requires gitStats: true)
|
|
115
|
+
Example: sort:imports
|
|
116
|
+
|
|
117
|
+
limit:<N> Return at most N results.
|
|
118
|
+
Example: limit:20
|
|
119
|
+
|
|
120
|
+
COMMON PATTERNS
|
|
121
|
+
Token-efficient context (logic only):
|
|
122
|
+
--query "category:logic"
|
|
123
|
+
|
|
124
|
+
Undocumented logic files:
|
|
125
|
+
--query "category:logic,hasDocstring:false"
|
|
126
|
+
|
|
127
|
+
10 most-imported files in a subsystem:
|
|
128
|
+
--query "path:src/api,sort:imports,limit:10"
|
|
129
|
+
|
|
130
|
+
Files using a specific library:
|
|
131
|
+
--query "tag:react,category:logic"
|
|
132
|
+
|
|
133
|
+
Files that import a specific module:
|
|
134
|
+
--query "importsFile:src/auth/session"
|
|
135
|
+
|
|
136
|
+
Large TypeScript logic files:
|
|
137
|
+
--query "type:typescript,category:logic,sort:size,limit:5"
|
|
138
|
+
`});async function lo(){let t=process.argv.slice(2),e=Fn(t);e.help&&(console.log(ao),process.exit(0)),e.queryHelp&&(console.log(co),process.exit(0));let r=to(e);Ze(r.rawConfig);let{rootDir:s,resolvedEntryPoints:n,resolvedCachePath:o,scanOptions:i}=r,{proposeTags:a,plain:c,affectedTests:p,detectFeatures:u,findUnused:m,findUncovered:h,excludeTests:x,checkCycles:N,callers:Q,file:uo,silent:mo,featureThreshold:go,query:ho,mermaid:yo,typeGraph:Qt,typeFilter:xo,moduleResponsibility:Xt,filterPaths:So,minOutDegree:bo,featureGraph:vo,callGraph:Zt,functionName:Co,apiSurface:Yt,applyTags:er,dryRun:Eo}=e,tr=a||p||er||Q||h||Qt||Xt||Zt||Yt,me=so(o)??new F(new Map);(n.length>0||!tr)&&(n.length===0&&!tr&&!m&&!u&&!N&&(console.error("Error: No entry points provided"),process.exit(1)),me=await oo(s,n,me,mo,r.rawConfig.gitStats??!1),no(me,o));let ko={graph:me,rootDir:s,entryPoints:n.map(He=>He.replace(s+"/","")),scanOptions:i,rawConfig:r.rawConfig,featureThreshold:go,queryStr:ho,mermaidOutput:yo,plain:c,excludeTests:x,file:uo,typeFilter:xo,filterPaths:So,minOutDegree:bo,functionName:Co,dryRun:Eo};await([[a,Xn],[er,Mn],[p,Tn],[u,_n],[m,Jn],[N,On],[h,Un],[Q,Ln],[Qt,Yn],[Xt,Vn],[vo,zn],[Zt,Rn],[Yt,Nn]].find(([He])=>He)?.[1]??Hn)(ko)}var fo=l(()=>{"use strict";v();wn();Pn();In();Dn();An();Gn();jn();Wn();$n();Bn();Kn();qn();Qn();Zn();eo();ro();io();po()});var zc=Fo(()=>{fo();lo().catch(t=>{console.error(t),process.exit(1)})});export default zc();
|
|
139
|
+
//# sourceMappingURL=cli.mjs.map
|