@omfalos/mokosh 0.3.0 → 0.3.2
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.js +47 -33
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +47 -33
- package/dist/cli.mjs.map +1 -1
- package/dist/index.d.mts +97 -1
- package/dist/index.d.ts +97 -1
- package/dist/index.js +23 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -20
- package/dist/index.mjs.map +1 -1
- package/dist/mcp.js +26 -23
- package/dist/mcp.js.map +1 -1
- package/dist/mcp.mjs +26 -23
- package/dist/mcp.mjs.map +1 -1
- package/dist/parse-worker.js +2 -2
- package/dist/parse-worker.js.map +1 -1
- package/dist/parse-worker.mjs +2 -2
- package/dist/parse-worker.mjs.map +1 -1
- package/package.json +7 -7
- package/templates/skill/SKILL.md +4 -3
- package/templates/skill/mokosh.md +4 -3
package/dist/mcp.js
CHANGED
|
@@ -1,31 +1,34 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var
|
|
3
|
-
`)}};var yt=g(require("fs")),Ar=g(require("path"));function xt(r,e){let t=r.replace(/^\.\//,"");if(e.nodes.has(t))return t;let s=t.replace(/^dist\//,"src/").replace(/\.(js|mjs|cjs)$/,".ts");return e.nodes.has(s)?s:null}function Nr(r,e){if(typeof r=="string")return xt(r,e);if(r&&typeof r=="object"){let t=r;for(let s of["import","require","default"]){let n=Nr(t[s],e);if(n)return n}}return null}function co(r){if(!r)return"unknown";let e=r.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 po(r,e){let t=new Set,s=new Set,n=[...e];for(;n.length;){let o=n.shift();if(s.has(o))continue;s.add(o);let i=r.nodes.get(o);if(i){for(let a of i.exports)t.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=r.nodes.get(a.toPath);if(p)for(let l of p.exports)t.add(l.name);n.push(a.toPath)}else for(let p of a.symbols)t.add(p)}}}return t}function St(r,e){let t=[],s=Ar.default.join(e,"package.json");if(yt.default.existsSync(s))try{let n=JSON.parse(yt.default.readFileSync(s,"utf8"));if(n.exports&&typeof n.exports=="object"&&!Array.isArray(n.exports))for(let o of Object.values(n.exports)){let i=Nr(o,r);i&&!t.includes(i)&&t.push(i)}else if(typeof n.exports=="string"){let o=xt(n.exports,r);o&&t.push(o)}if(t.length===0)for(let o of[n.main,n.module].filter(Boolean)){let i=xt(o,r);i&&!t.includes(i)&&t.push(i)}}catch{}if(t.length===0){for(let n of["src/index.ts","src/index.js","index.ts","index.js"])if(r.nodes.has(n)){t.push(n);break}}return t}function lo(r,e){let t=new Set(e);for(let s of e)r.traverse(s,n=>(t.add(n.path),!0),{direction:"outgoing"});return t}function fo(r,e,t){let s=new Map;for(let n of e){if(t.includes(n))continue;let o=r.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 uo(r,e,t,s){let n=[];for(let o of r){let i=e.get(o),a=s.flatMap(m=>t.nodes.get(m)?.exports??[]).find(m=>m.name===o),c=i?.symbol??a,p=i?.file??s.find(m=>t.nodes.get(m)?.exports.some(d=>d.name===o))??s[0],l={name:o,definedIn:p,kind:co(c?.signature)};c?.doc&&(l.doc=c.doc),c?.signature&&(l.signature=c.signature),n.push(l)}return n.sort((o,i)=>o.name.localeCompare(i.name)),n}function mo(r,e,t){let s=c=>r.nodes.get(c)?.category==="test",n=[...e].filter(c=>!t.includes(c)&&!s(c)),o=[...r.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 bt(r,e){if(e.length===0)throw new Error("buildApiSurface requires at least one entry point");for(let p of e)if(!r.nodes.has(p))throw new Error(`Entry point not found in graph: ${p}`);let t=lo(r,e),s=fo(r,t,e),n=po(r,e),o=uo(n,s,r,e),{internalFiles:i,unreachableFromEntry:a,testFiles:c}=mo(r,t,e);return{entryPoints:e,publicExports:o,internalFiles:i,unreachableFromEntry:a,testFiles:c}}function vt(r,e){let t=null,s=[];for(let o of r.nodes.values()){o.exports.some(i=>i.name===e)&&(t=o.path);for(let i of o.callEdges??[])i.to===e&&s.push({file:o.path,callerFunction:i.from})}let n=[];if(t){let o=r.nodes.get(t);for(let i of o?.callEdges??[])i.from===e&&n.push({file:i.toFile,calleeFunction:i.to})}return{functionName:e,definedIn:t,callers:s,callees:n}}var go=g(require("fs")),ho=g(require("path"));function Mr(r){let e=[...r.nodes.entries()].sort(([s],[n])=>s.localeCompare(n)).map(([s,n])=>`${s}:${n.mtime}:${n.size}`).join("|"),t=2166136261;for(let s=0;s<e.length;s++)t^=e.charCodeAt(s),t=Math.imul(t,16777619)>>>0;return t.toString(16).padStart(8,"0")}function Ct(r){let e=new Map;for(let t of r.nodes.keys()){let s=[];r.traverse(t,n=>(n.path!==t&&s.push(n.path),!0),{direction:"incoming"}),e.set(t,s)}return{impact:e,graphHash:Mr(r)}}function kt(r,e){return r.impact.get(e)??[]}var ce=g(require("path"));function yo(r){let e=new Map;for(let[t,s]of r){let n=s.imports.filter(o=>o.toPath&&!o.isExternal).length;n>0&&e.set(t,n)}return e}function xo(r,e,t){let s=new Map;for(let[n,o]of e){if(o<t)continue;let i=r.get(n);if(!i||i.category==="test"||i.category==="barrel")continue;let a=ce.default.extname(n),c=ce.default.basename(n,a),p=c==="index"?ce.default.basename(ce.default.dirname(n)):c;s.set(n,{path:n,outDegree:o,tag:`feature:${p}`})}return s}function L(r,e){let t=e?.minOutDegree??5;return xo(r,yo(r),t)}var So=(r,e)=>r.outDegree-e.outDegree;function bo(r,e){let t=new Map;for(let s of e.values()){let n=new Set;r.traverse(s.path,o=>(o.path!==s.path&&n.add(o.path),!0),{direction:"outgoing"}),t.set(s.path,n)}return t}function vo(r,e,t,s){let n=new Map;for(let[o]of r){if(e.has(o))continue;let i=null;for(let a of e.values())t.get(a.path)?.has(o)&&(!i||s(a,i)<0)&&(i=a);i&&n.set(o,i.path)}return n}function Co(r,e){let t=new Map;for(let s of r.values()){let n=s.tag.replace("feature:",""),o=[];for(let[i,a]of e)a===s.path&&o.push(i);t.set(n,{hub:s.path,outDegree:s.outDegree,files:o})}return t}function ko(r,e,t){let s=[];for(let n of r.keys())!e.has(n)&&!t.has(n)&&s.push(n);return s}function pe(r,e){let t=e?.detectFn??L,s=e?.hubComparator??So,n=t(r.nodes,e),o=bo(r,n),i=vo(r.nodes,n,o,s);return{features:Co(n,i),unassigned:ko(r.nodes,n,i)}}var Ir=new Set(["typescript","javascript","python","go","scss","less","lua","coffeescript"]),Rr=new Set(["typescript","javascript","python"]),Le=new Set(["typescript","javascript","go","python"]);function wt(r){let e=new Map;for(let t of r.nodes.values())e.set(t.type,(e.get(t.type)??0)+1);return[...e.entries()].map(([t,s])=>({type:t,fileCount:s,exportsTracked:Ir.has(t),importSymbolsTracked:Rr.has(t),callEdgesTracked:Le.has(t)})).sort((t,s)=>s.fileCount-t.fileCount)}var le=class{constructor(e){this.nodes=e}nodes;findUnusedFiles(e){let t=new Set(this.nodes.keys());return e.filter(s=>!t.has(s))}findHighExportUsage(e){let t=[];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);t.push({path:s.path,maxExportUsage:s.maxExportUsage,tightestDep:n?.toPath??""})}return t.sort((s,n)=>n.maxExportUsage-s.maxExportUsage)}findCycles(){let e=[],t=new Set,s=new Set,n=[],o=i=>{t.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 t.has(c.toPath)||o(c.toPath)}s.delete(i),n.pop()};for(let i of this.nodes.keys())t.has(i)||o(i);return e}};var M=class r{constructor(e){this.nodes=e}nodes;_incomingEdgesCache=null;_callIncomingCache=null;serialize(){return{nodes:Array.from(this.nodes.values())}}static deserialize(e){let t=new Map;for(let s of e.nodes)t.set(s.path,s);return new r(t)}getIncomingEdgesMap(){if(this._incomingEdgesCache)return this._incomingEdgesCache;let e=new Map;for(let t of this.nodes.values())for(let s of t.imports)if(s.toPath){let n=e.get(s.toPath)||[];n.push(t.path),e.set(s.toPath,n)}return this._incomingEdgesCache=e,e}dfs(e,t,s,n){let o=new Set,i=s.maxDepth??1/0,a=(c,p,l)=>{if(p>i||o.has(c))return;let m=this.nodes.get(c);if(m&&(o.add(c),t(m,p,l)!==!1))for(let d of n(c))a(d,p+1,c)};a(e,0,null)}traverse(e,t,s={}){let n=s.direction??"outgoing",o=n==="incoming"?this.getIncomingEdgesMap():null;this.dfs(e,t,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 t of this.nodes.values())for(let s of t.callEdges??[]){let n=e.get(s.toFile)??[];n.push(t.path),e.set(s.toFile,n)}return this._callIncomingCache=e,e}traverseCalls(e,t,s={}){let n=s.direction??"outgoing",o=n==="incoming"?this.getCallIncomingCache():null;this.dfs(e,t,s,i=>n==="outgoing"?this.nodes.get(i)?.callEdges?.map(a=>a.toFile)??[]:o?.get(i)??[])}getCallers(e){let t=[];return this.traverseCalls(e,s=>(s.path!==e&&t.push(s.path),!0),{direction:"incoming",maxDepth:1}),t}getCallEdgesFor(e){return this.nodes.get(e)?.callEdges??[]}getNeighbors(e){let t=this.nodes.get(e);return t?t.imports.map(s=>this.nodes.get(s.toPath)).filter(s=>s!==void 0):[]}findUnusedFiles(e){return new le(this.nodes).findUnusedFiles(e)}findCycles(){return new le(this.nodes).findCycles()}};var _=class{affectedSymbols=new Map;constructor(e,t){this.affectedSymbols.set(e,new Set(["default",...t]))}updateAffectedSymbols(e,t){let s=this.affectedSymbols.get(t)||new Set,n=e.imports.find(c=>c.toPath===t);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 fe(r,e){let t=r.nodes.get(e);if(t)return{category:t.category,exports:t.exports.map(s=>s.name)}}function Et(r,e,t=1){let s=[];return r.traverse(e,(n,o,i)=>{if(n.path===e)return!0;let a=i?r.nodes.get(i)?.imports.find(c=>c.toPath===n.path):void 0;return s.push({path:n.path,...a?.symbols?{symbols:a.symbols}:{}}),!0},{direction:"outgoing",maxDepth:t}),s}function ue(r,e){let t=[];return r.traverse(e,s=>{if(s.path===e)return!0;let n=s.imports.find(o=>o.toPath===e);return t.push({path:s.path,...n?.symbols?{symbols:n.symbols}:{}}),!0},{direction:"incoming",maxDepth:1}),t}function Ft(r,e,t={}){let{testsOnly:s=!1,changedSymbols:n}=t,o=n?new _(e,n):null,i=[];return r.traverse(e,(a,c,p)=>{if(a.path===e)return!0;if(o&&p&&!o.updateAffectedSymbols(a,p))return!1;let l=a.category==="test"||a.tags.some(m=>m.name==="test");return(!s||l)&&i.push(a.path),!0},{direction:"incoming"}),i}function Tt(r,e,t={}){let{depth:s=1,withEdgeDetail:n=!1}=t,o=[];return r.traverseCalls(e,i=>{if(i.path===e)return!0;let a={file:i.path};return n&&(a.edges=(i.callEdges??[]).filter(c=>c.toFile===e).map(c=>({from:c.from,to:c.to}))),o.push(a),!0},{direction:"incoming",maxDepth:s}),o}function Pt(r,e={}){let{metric:t="cognitiveComplexity",threshold:s=10,limit:n=20}=e;return[...r.nodes.values()].flatMap(o=>(o.functions??[]).filter(i=>i[t]>=s).map(i=>({file:o.path,name:i.name,line:i.line,complexity:i.complexity,cognitiveComplexity:i.cognitiveComplexity}))).sort((o,i)=>i[t]-o[t]).slice(0,n)}function At(r){return{nodes:r.nodes.map(t=>({path:t.path,type:t.type,category:t.category,exports:t.exports.map(s=>s.name),tags:t.tags.filter(s=>s.kind==="comment-marker"||s.kind==="import").map(s=>s.name),importsFiles:t.imports.filter(s=>!s.isExternal&&s.toPath).map(s=>s.toPath),...t.description!==void 0&&{description:t.description},...t.testedBy!==void 0&&{testedBy:t.testedBy},...t.coveragePct!==void 0&&{coveragePct:t.coveragePct},...t.avgExportUsage!==void 0&&{avgExportUsage:t.avgExportUsage},...t.maxExportUsage!==void 0&&{maxExportUsage:t.maxExportUsage}})),cycles:r.cycles}}function Nt(r){let e=r.getPackageDependencies(),t=Array.from(r.packages.values()).map(({graph:s,pkg:n})=>({name:n.name,relativeRoot:n.relativeRoot,nodeCount:s.nodes.size,dependsOn:e.get(n.name)??[]}));return{monorepoType:r.type,packageCount:t.length,packages:t}}function Mt(r){return[...r.nodes.values()].some(e=>e.coveragePct!==void 0)}function Dr(r){if(r.category==="test")return"test";if(r.category==="config")return"config";if(r.category==="type-only")return"types";let e=r.path;return b(e,"component")||b(e,"components")?"component":b(e,"controller")||b(e,"controllers")?"controller":b(e,"middleware")?"middleware":b(e,"router")||b(e,"routes")||b(e,"route")?"router":b(e,"store")||b(e,"stores")?"store":b(e,"service")||b(e,"services")?"service":b(e,"handler")||b(e,"handlers")?"handler":b(e,"adapter")||b(e,"adapters")?"adapter":b(e,"plugin")||b(e,"plugins")?"plugin":b(e,"api")?"api":b(e,"cli")||b(e,"commands")||me(e)==="cli"?"cli":b(e,"util")||b(e,"utils")||b(e,"helper")||b(e,"helpers")?"util":b(e,"model")||b(e,"models")||me(e)==="model"?"model":b(e,"parser")||b(e,"parsers")||me(e)==="parser"?"parser":me(e)==="builder"?"builder":me(e)==="resolver"?"resolver":"other"}function b(r,e){return r.includes(`/${e}/`)||r.includes(`/${e}.`)}function me(r){let e=r.slice(r.lastIndexOf("/")+1);return e.slice(0,e.lastIndexOf("."))||e}function It(r,e){let t=pe(r,e),s=new Map;for(let[o,i]of t.features){for(let a of i.files)s.set(a,o);s.set(i.hub,o)}let n=new Map;for(let o of r.nodes.values()){let i=s.get(o.path);n.set(o.path,{path:o.path,role:Dr(o),...o.description?{description:o.description}:{},exports:o.exports.map(a=>a.name),...i?{featureHub:i}:{}})}return n}function Rt(r,e){let t=[];for(let s of r.nodes.values())if(s.exports.some(n=>n.name===e))if(Le.has(s.type)){let n=[];for(let o of r.nodes.values())for(let i of o.callEdges??[])i.to===e&&n.push({file:o.path,callerFunction:i.from});t.push({path:s.path,category:s.category,precision:"call",callers:n})}else{let n=ue(r,s.path).map(o=>({file:o.path,...o.symbols?{symbols:o.symbols}:{}}));t.push({path:s.path,category:s.category,precision:"file-level",importers:n})}return t}function wo(r){return r?r.startsWith("interface ")?"interface":r.startsWith("class ")?"class":r.startsWith("enum ")?"enum":"type":"type"}function Eo(r,e){if(e==="type-only")return!0;let t=r.signature??"";return t.startsWith("interface ")||t.startsWith("class ")||t.startsWith("enum ")}function Dt(r){let e=new Map;for(let s of r.nodes.values())if(!(s.type!=="typescript"&&s.type!=="javascript"))for(let n of s.exports){if(!Eo(n,s.category))continue;let o=`${s.path}::${n.name}`;e.set(o,{name:n.name,file:s.path,kind:wo(n.signature),...n.doc?{doc:n.doc}:{}})}let t=[];for(let s of r.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}`)&&t.push({fromFile:s.path,toType:o,toFile:n.toPath})}return{types:e,edges:t}}function Gt(r,e){let t=null;for(let o of r.types.values())if(o.name===e){t=o;break}if(!t)return{type:null,usedByFiles:[],uses:[]};let s=new Set,n=new Map;for(let o of r.edges)if(o.toType===e&&o.toFile===t.file&&s.add(o.fromFile),o.fromFile===t.file){let i=r.types.get(`${o.toFile}::${o.toType}`);i&&n.set(`${i.file}::${i.name}`,i)}return{type:t,usedByFiles:Array.from(s),uses:Array.from(n.values())}}var Qr=g(require("path"));var Oe=g(require("fs")),Ot=g(require("path"));var H=g(require("fs")),T=g(require("path"));var Lt=g(require("fs")),Fo=g(require("path"));function Gr(r){try{return Lt.default.statSync(r,{throwIfNoEntry:!1})?.isDirectory()===!0}catch{return!1}}function _e(r){try{return Lt.default.statSync(r,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}function _t(r,e){let t=T.default.join(e,"package.json");if(!H.default.existsSync(t))return null;let s={};try{s=JSON.parse(H.default.readFileSync(t,"utf-8"))}catch{return null}let n=s.name;return n?{name:n,root:e,relativeRoot:T.default.relative(r,e),entryPoints:To(e,s)}:null}function To(r,e){let t=[];if(e.exports){let n=e.exports;if(typeof n=="string")t.push(T.default.join(r,n));else if(typeof n=="object"&&n!==null){let o=n["."];if(typeof o=="string")t.push(T.default.join(r,o));else if(typeof o=="object"&&o!==null){let i=o.import??o.require??o.default;typeof i=="string"&&t.push(T.default.join(r,i))}}}e.main&&t.push(T.default.join(r,e.main));for(let n of["src/index.ts","src/index.tsx","index.ts","index.tsx","index.js"])t.push(T.default.join(r,n));let s=t.filter(_e);return s.length>0?s.slice(0,1):t.slice(0,1)}function Q(r,e){let t=[],s=new Set;for(let n of e){let o=n.replace(/\/$/,"").replace(/^\.\//,"");Po(r,o,s,t)}return t}function Po(r,e,t,s){if(!e.includes("*")){Ao(r,e,t,s);return}let n=e.split("/");n.includes("**")?No(r,n,t,s):Mo(r,n,t,s)}function Ao(r,e,t,s){let n=T.default.join(r,e);if(t.has(n)||!Gr(n))return;t.add(n);let o=_t(r,n);o&&s.push(o)}function No(r,e,t,s){let n=T.default.join(r,e[0]==="**"?"":e[0]??"");Lr(r,n,t,s)}function Mo(r,e,t,s){let n=e.findIndex(a=>a.includes("*")),o=T.default.join(r,...e.slice(0,n)),i;try{i=H.default.readdirSync(o,{withFileTypes:!0})}catch{return}for(let a of i){if(!a.isDirectory())continue;let c=T.default.join(o,a.name);if(t.has(c))continue;t.add(c);let p=_t(r,c);p&&s.push(p)}}function Lr(r,e,t,s){let n;try{n=H.default.readdirSync(e,{withFileTypes:!0})}catch{return}for(let o of n){if(!o.isDirectory()||o.name==="node_modules"||o.name.startsWith("."))continue;let i=T.default.join(e,o.name);if(H.default.existsSync(T.default.join(i,"package.json"))&&!t.has(i)){t.add(i);let a=_t(r,i);a&&s.push(a)}else Lr(r,i,t,s)}}var _r={type:"npm",detect(r){let e=Ot.default.join(r,"package.json");if(!Oe.default.existsSync(e))return null;let t;try{t=JSON.parse(Oe.default.readFileSync(e,"utf-8")).workspaces}catch{return null}if(!t||Oe.default.existsSync(Ot.default.join(r,"yarn.lock")))return null;let s=Array.isArray(t)?t:t.packages??[];return s.length===0?null:Q(r,s)}};var O=g(require("fs")),w=g(require("path"));var Or={type:"nx",detect(r){return O.default.existsSync(w.default.join(r,"nx.json"))?jr(r,r,new Set,0).map(t=>Io(r,t,w.default.join(t,"project.json"))).filter(t=>t!==null):null}};function jr(r,e,t,s){if(s>4)return[];let n;try{n=O.default.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=w.default.join(e,a);O.default.existsSync(w.default.join(c,"project.json"))&&!t.has(c)?(t.add(c),o.push(c)):o.push(...jr(r,c,t,s+1))}return o}function Io(r,e,t){let s={};try{s=JSON.parse(O.default.readFileSync(t,"utf-8"))}catch{return null}let n=s.name,o,i,a=w.default.join(e,"package.json");if(O.default.existsSync(a))try{let c=JSON.parse(O.default.readFileSync(a,"utf-8"));n=c.name??n,o=c.main,i=c.exports}catch{}return n?{name:n,root:e,relativeRoot:w.default.relative(r,e),entryPoints:Ro(e,s,o,i)}:null}function Ro(r,e,t,s){let n=[],o=e.targets?.build?.options?.main??e.targets?.build?.options?.entryFile;if(o){let a=w.default.resolve(r,"../..");n.push(w.default.resolve(a,o)),n.push(w.default.resolve(r,o))}if(s){let a=s;if(typeof a=="string")n.push(w.default.join(r,a));else if(typeof a=="object"&&a!==null){let c=a["."];typeof c=="string"&&n.push(w.default.join(r,c))}}if(t&&n.push(w.default.join(r,t)),e.sourceRoot){let a=w.default.resolve(r,"../.."),c=w.default.resolve(a,e.sourceRoot);n.push(w.default.join(c,"index.ts"),w.default.join(c,"index.tsx"))}for(let a of["src/index.ts","src/index.tsx","index.ts","index.tsx"])n.push(w.default.join(r,a));let i=n.filter(_e);return i.length>0?i.slice(0,1):n.slice(0,1)}var jt=g(require("fs")),Wr=g(require("path")),zr=require("js-yaml");var $r={type:"pnpm",detect(r){let e=Wr.default.join(r,"pnpm-workspace.yaml");if(!jt.default.existsSync(e))return null;let t=[];try{t=(0,zr.load)(jt.default.readFileSync(e,"utf-8"))?.packages??[]}catch{return null}return Q(r,t)}};var Br=g(require("fs")),Ur=g(require("path")),Kr={type:"turborepo",detect(r){return Br.default.existsSync(Ur.default.join(r,"turbo.json"))?[]:null}};var je=g(require("fs")),Wt=g(require("path"));var Jr={type:"yarn",detect(r){if(!je.default.existsSync(Wt.default.join(r,"yarn.lock")))return null;let e=Wt.default.join(r,"package.json");if(!je.default.existsSync(e))return null;let t;try{t=JSON.parse(je.default.readFileSync(e,"utf-8")).workspaces}catch{return null}if(!t)return null;let s=Array.isArray(t)?t:t.packages??[];return s.length===0?null:Q(r,s)}};var Vr=[];function R(r){Vr.push(r)}function Hr(){return Vr}R(Kr);R(Or);R($r);R(Jr);R(_r);function ge(r,e=Hr()){let t=Qr.default.resolve(r),s=new Map,n=[];for(let i of e){let a=i.detect(t);if(a!==null){n.push(i.type);for(let c of a)s.has(c.name)||s.set(c.name,c)}}if(n.length===0)return{root:t,type:"none",types:[],packages:[],packageMap:new Map};let o=Array.from(s.values());return{root:t,type:n[0],types:n,packages:o,packageMap:new Map(o.map(i=>[i.name,i]))}}var de=class r{constructor(e,t){this.monorepoRoot=e;this.type=t}monorepoRoot;type;packages=new Map;addPackage(e,t){this.packages.set(e.name,{graph:t,pkg:e})}getPackageForFile(e){for(let{pkg:t}of this.packages.values())if(e===t.relativeRoot||e.startsWith(`${t.relativeRoot}/`))return t}getPackageDependencies(){let e=new Map;for(let{graph:t,pkg:s}of this.packages.values()){let n=new Set;for(let o of t.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 t=this.getPackageForFile(e);if(!t)return[];let s=this.packages.get(t.name);if(!s)return[];let n=[];s.graph.traverse(e,o=>(o.path!==e&&n.push({file:o.path,package:t.name}),!0),{direction:"incoming"});for(let{graph:o,pkg:i}of this.packages.values())if(i.name!==t.name)for(let a of o.nodes.values())a.imports.some(p=>p.isWorkspace&&p.workspacePackage===t.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:t})=>({pkg:{name:t.name,relativeRoot:t.relativeRoot,entryPoints:t.entryPoints},nodes:Array.from(e.nodes.values())}))}}static deserialize(e){let t=new r(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 M(o);t.packages.set(s.name,{graph:i,pkg:{...s,root:""}})}return t}};var qr=new Map;function q(r,e){qr.set(r,e)}function Xr(r){return qr.get(r)}function Yr(r,e){return e.startsWith("!")?r!==e.slice(1):r===e}function Do(r,e){return e.startsWith("!")?!r.includes(e.slice(1)):r.includes(e)}var Go=(r,e)=>!e.category||Yr(r.category,e.category),Lo=(r,e)=>!e.type||Yr(r.type,e.type),_o=(r,e)=>e.lastAuthor?e.lastAuthor.startsWith("!")?r.lastAuthor!==e.lastAuthor.slice(1):r.lastAuthor!==void 0&&r.lastAuthor===e.lastAuthor:!0,Oo=(r,e)=>!e.path||Do(r.path,e.path),jo=(r,e)=>e.isExternal===void 0?!0:r.imports.some(s=>s.isExternal)===e.isExternal,Wo=(r,e)=>{if(!e.tags||e.tags.length===0)return!0;let t=e.tags.filter(n=>!n.startsWith("!")),s=e.tags.filter(n=>n.startsWith("!")).map(n=>n.slice(1));return!(t.length>0&&!t.some(n=>r.tags.some(o=>o.name===n))||s.some(n=>r.tags.some(o=>o.name===n)))},zo=(r,e)=>!e.allTags?.length||e.allTags.every(t=>r.tags.some(s=>s.name===t)),$o=(r,e)=>!e.importsFile||r.imports.some(t=>t.toPath?.includes(e.importsFile)),Bo=(r,e,t)=>e.importedBy===void 0?!0:(t?.get(r.path)??[]).some(n=>n.includes(e.importedBy)),Uo=(r,e)=>e.minImports===void 0||r.imports.length>=e.minImports,Ko=(r,e)=>e.maxImports===void 0||r.imports.length<=e.maxImports,Jo=(r,e)=>e.minSize===void 0||r.size>=e.minSize,Vo=(r,e)=>e.maxSize===void 0||r.size<=e.maxSize,Ho=(r,e)=>e.hasDocstring===void 0||!!r.description===e.hasDocstring,Qo=(r,e)=>e.isDocumented===void 0||!!r.documentedBy?.length===e.isDocumented,qo=(r,e)=>e.isStale===void 0||!!r.staleFor?.length===e.isStale,Xo=(r,e)=>e.minCoverage===void 0||(r.coveragePct??101)>=e.minCoverage,Yo=(r,e)=>e.maxCoverage===void 0||(r.coveragePct??0)<=e.maxCoverage,Zo=(r,e)=>e.minExportUsage===void 0||(r.avgExportUsage??-1)>=e.minExportUsage,ei=(r,e)=>e.maxExportUsage===void 0||(r.avgExportUsage??0)<=e.maxExportUsage,ti=(r,e)=>e.minComplexity===void 0||(r.complexity??-1/0)>=e.minComplexity,ri=(r,e)=>e.maxComplexity===void 0||(r.complexity??0)<=e.maxComplexity,si=(r,e)=>e.minCognitiveComplexity===void 0||(r.cognitiveComplexity??-1/0)>=e.minCognitiveComplexity,ni=(r,e)=>e.maxCognitiveComplexity===void 0||(r.cognitiveComplexity??0)<=e.maxCognitiveComplexity,oi=(r,e)=>e.minCommits===void 0||(r.commitCount90d??-1/0)>=e.minCommits,ii=(r,e)=>e.maxCommits===void 0||(r.commitCount90d??0)<=e.maxCommits,ai=(r,e,t)=>!e.any?.length||e.any.some(s=>he(r,s,t)),ci=[Go,Lo,_o,Oo,jo,Wo,zo,$o,Bo,Uo,Ko,Jo,Vo,Ho,Qo,qo,Xo,Yo,Zo,ei,ti,ri,si,ni,oi,ii,ai];function he(r,e,t){return ci.every(s=>s(r,e,t))}function We(r,e){let t=new Map;if(e.importedBy!==void 0){for(let i of r.nodes)for(let a of i.imports)if(a.toPath){let c=t.get(a.toPath)??[];c.push(i.path),t.set(a.toPath,c)}}let s=r.nodes.filter(i=>he(i,e,t)),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,c)=>{let p=0;return e.sort==="size"?p=c.size-a.size:e.sort==="imports"?p=c.imports.length-a.imports.length:e.sort==="commitCount90d"?p=(c.commitCount90d??0)-(a.commitCount90d??0):e.sort==="exportUsage"?p=(c.avgExportUsage??0)-(a.avgExportUsage??0):e.sort==="complexity"?p=(c.complexity??0)-(a.complexity??0):e.sort==="cognitiveComplexity"&&(p=(c.cognitiveComplexity??0)-(a.cognitiveComplexity??0)),p*i})}return e.limit!==void 0&&o.splice(e.limit),{nodes:o,cycles:r.cycles?.filter(i=>i.every(a=>n.has(a)))??void 0}}function Zr(r,e){let t=e.indexOf(":");if(t===-1)return;let s=e.slice(0,t).trim().toLowerCase(),n=e.slice(t+1).trim();if(!(!s||!n))switch(s){case"category":r.category=n;break;case"type":r.type=n;break;case"tag":case"tags":n.includes("+")?r.allTags=[...r.allTags??[],...n.split("+")]:r.tags=[...r.tags??[],n];break;case"path":r.path=n;break;case"external":r.isExternal=n.toLowerCase()==="true";break;case"importsfile":r.importsFile=n;break;case"importedby":r.importedBy=n;break;case"minimports":r.minImports=parseInt(n,10);break;case"maximports":r.maxImports=parseInt(n,10);break;case"minsize":r.minSize=parseInt(n,10);break;case"maxsize":r.maxSize=parseInt(n,10);break;case"sort":r.sort=n;break;case"sortdir":r.sortDir=n.toLowerCase()==="asc"?"asc":"desc";break;case"limit":r.limit=parseInt(n,10);break;case"hasdocstring":r.hasDocstring=n.toLowerCase()!=="false";break;case"mincoverage":r.minCoverage=parseInt(n,10);break;case"maxcoverage":r.maxCoverage=parseInt(n,10);break;case"minexportusage":r.minExportUsage=parseFloat(n);break;case"maxexportusage":r.maxExportUsage=parseFloat(n);break;case"mincomplexity":r.minComplexity=parseInt(n,10);break;case"maxcomplexity":r.maxComplexity=parseInt(n,10);break;case"mincognitivecomplexity":r.minCognitiveComplexity=parseInt(n,10);break;case"maxcognitivecomplexity":r.maxCognitiveComplexity=parseInt(n,10);break;case"mincommits":r.minCommits=parseInt(n,10);break;case"maxcommits":r.maxCommits=parseInt(n,10);break;case"isdocumented":r.isDocumented=n.toLowerCase()!=="false";break;case"isstale":r.isStale=n.toLowerCase()!=="false";break;case"lastauthor":r.lastAuthor=n;break}}function pi(r){let e=[];for(let t of r.split("|")){let s=t.trim();if(!s)continue;let n={};Zr(n,s),Object.keys(n).length>0&&e.push(n)}return e}function ze(r){let e={},t=r.split(",");for(let s of t){let n=s.trim();if(n.toLowerCase().startsWith("any(")&&n.endsWith(")")){let o=n.slice(4,-1),i=pi(o);i.length>0&&(e.any=[...e.any??[],...i]);continue}Zr(e,s)}return e}var Zt=g(require("fs/promises")),ps=g(require("path"));var Qe=g(require("path")),ye=g(require("typescript"));var zt=g(require("path")),$t=g(require("typescript"));var E=g(require("typescript")),es=new Set(["describe","test","it"]);function X(r){let e=[];for(let t of r.statements){if(!E.default.isExpressionStatement(t))continue;let s=t.expression;if(!E.default.isCallExpression(s))continue;let n=s.expression;E.default.isIdentifier(n)&&es.has(n.text)&&e.push(s),E.default.isPropertyAccessExpression(n)&&E.default.isIdentifier(n.expression)&&es.has(n.expression.text)&&e.push(s)}return e}function Y(r,e,t){for(let s of r.arguments){if(!E.default.isObjectLiteralExpression(s))continue;let n=s.properties.find(o=>E.default.isPropertyAssignment(o)&&E.default.isIdentifier(o.name)&&o.name.text===e);if(!(!n||!E.default.isArrayLiteralExpression(n.initializer)))return n.initializer.elements.filter(E.default.isStringLiteral).map(o=>o.text)}return null}function Z(r,e,t,s){if(r.arguments.length===0)return null;for(let o=1;o<r.arguments.length;o++){let i=r.arguments[o];if(!E.default.isObjectLiteralExpression(i))continue;let a=i.properties.find(p=>E.default.isPropertyAssignment(p)&&E.default.isIdentifier(p.name)&&p.name.text===e);if(a)return{start:a.initializer.getStart(s),end:a.initializer.getEnd(),text:t};let c=i.getEnd()-1;return{start:c,end:c,text:`${i.properties.length>0?", ":""}${e}: ${t}`}}let n=r.arguments[r.arguments.length-1];return{start:n.getStart(s),end:n.getStart(s),text:`{ ${e}: ${t} }, `}}function ee(r,e,t){let s=r.arguments;for(let n=1;n<s.length;n++){let o=s[n];if(!E.default.isObjectLiteralExpression(o))continue;let i=o.properties.findIndex(c=>E.default.isPropertyAssignment(c)&&E.default.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(t),end:o.properties[i+1].getStart(t),text:""}}return null}function te(r,e){let t=[...e].sort((n,o)=>o.start-n.start),s=r;for(let n of t)s=s.slice(0,n.start)+n.text+s.slice(n.end);return s}function re(r){return`[${r.map(e=>JSON.stringify(e)).join(", ")}]`}var N=new Set([".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"]);function li(r){return re(r.map(e=>`@${e}`))}function fi(r){return r.map(e=>e.startsWith("@")?e.slice(1):e)}var $e=class{name="cypress";canHandle(e){return N.has(zt.default.extname(e).toLowerCase())}apply(e,t,s){let n=$t.default.createSourceFile(zt.default.basename(e),t,$t.default.ScriptTarget.Latest,!0),o=X(n);if(o.length===0)return t;let i=Y(o[0],"tags",n),a=[...s].sort();if(i!==null&&JSON.stringify(fi(i).sort())===JSON.stringify(a))return t;let c=o.flatMap(p=>{let l=s.length===0?ee(p,"tags",n):Z(p,"tags",li(a),n);return l?[l]:[]});return c.length>0?te(t,c):t}};var ts=g(require("path")),Bt=/# <mokosh-tags>[\s\S]*?# <\/mokosh-tags>\n*/,Ut=/^@([a-zA-Z0-9_-]+)/gm;function ui(r){return["# <mokosh-tags>",...r.map(e=>`@${e}`),"# </mokosh-tags>"].join(`
|
|
4
|
-
`)
|
|
2
|
+
"use strict";var bo=Object.create;var Pe=Object.defineProperty;var vo=Object.getOwnPropertyDescriptor;var ko=Object.getOwnPropertyNames;var wo=Object.getPrototypeOf,Co=Object.prototype.hasOwnProperty;var Fo=(t,e)=>{for(var r in e)Pe(t,r,{get:e[r],enumerable:!0})},Ir=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of ko(e))!Co.call(t,s)&&s!==r&&Pe(t,s,{get:()=>e[s],enumerable:!(n=vo(e,s))||n.enumerable});return t};var h=(t,e,r)=>(r=t!=null?bo(wo(t)):{},Ir(e||!t||!t.__esModule?Pe(r,"default",{value:t,enumerable:!0}):r,t)),Eo=t=>Ir(Pe({},"__esModule",{value:!0}),t);var ep={};Fo(ep,{createMcpServer:()=>ut});module.exports=Eo(ep);var yo=require("@modelcontextprotocol/sdk/server/stdio.js");var ho=require("@modelcontextprotocol/sdk/server/index.js"),lt=require("@modelcontextprotocol/sdk/types.js");var Ws=h(require("fs"));var Ie=h(require("fs")),yt=h(require("path"));var To=[".config.","biome.json","tsconfig.json","package.json",".prettierrc",".eslintrc"],Dr=[];function Ae(t){Dr.push(t)}function Rr(t){return[...To,...Dr].some(e=>typeof e=="string"?t.includes(e):e instanceof RegExp?e.test(t):e(t))}var Po=[".test.",".spec.","-test.","-spec."],Gr=[];function Ne(t){Gr.push(t)}function oe(){return[...Po,...Gr]}var Ao=["jest","vitest","playwright","cypress","@testing-library/"],Lr=[];function Me(t){Lr.push(t)}function gt(){return[...Ao,...Lr]}var _r=.8;function dt(t){_r=t}function ht(){return _r}var No=["mokosh.config.js","mokosh.config.cjs","mokosh.config.json"];function ie(t,{allowJs:e=!0,isExplicitPath:r=!1}={}){if(r){let n=yt.default.resolve(t);return Ie.default.existsSync(n)?n.endsWith(".json")?Or(n):e?jr(n):{}:{}}for(let n of No){let s=yt.default.resolve(t,n);if(Ie.default.existsSync(s)){if(n.endsWith(".json"))return Or(s);if(e)return jr(s)}}return{}}function Or(t){return JSON.parse(Ie.default.readFileSync(t,"utf-8"))}function jr(t){let e=require(t);return e&&typeof e=="object"&&"default"in e&&(e=e.default),typeof e=="function"?e({}):e}function xt(t){for(let e of t.configMatchers??[])Ae(e);for(let e of t.testPatterns??[])Ne(e);for(let e of t.testLibraries??[])Me(e);t.barrelThreshold!==void 0&&dt(t.barrelThreshold)}function q(t){return{gitStats:t?.gitStats??!1,parallelParsing:t?.parallelParsing,pathAliases:t?.pathAliases}}var j=["node_modules",".git","dist","build",".next",".cache","mokosh-cache","coverage"],St=[".ts",".tsx",".js",".jsx",".mjs",".cjs",".css",".scss",".sass",".less",".styl",".coffee",".ls",".lua",".py",".go",".feature",".md",".mdx"];var Wr=h(require("fs")),bt=h(require("path"));function vt(t,e){let r=bt.default.resolve(t,e);try{let n=Wr.default.readFileSync(r,"utf-8"),s=JSON.parse(n),o=new Map;for(let[i,a]of Object.entries(s)){if(i==="total")continue;let c=a?.lines?.pct;if(typeof c!="number")continue;let p=bt.default.relative(t,i);o.set(p,c)}return o}catch{return new Map}}var De={serialize(t){let e=["graph TD"],r=new Set;for(let n of t.nodes.values()){let s=`"${n.path}"`;for(let o of n.imports){if(!o.toPath)continue;let i=`"${o.toPath}"`,a=`${n.path} -> ${o.toPath}`;if(!r.has(a)){let c=o.isStyle?"-- styles -->":"-->";e.push(` ${s} ${c} ${i}`),r.add(a)}}}return e.join(`
|
|
3
|
+
`)}};var kt=h(require("fs")),zr=h(require("path"));function wt(t,e){let r=t.replace(/^\.\//,"");if(e.nodes.has(r))return r;let n=r.replace(/^dist\//,"src/").replace(/\.(js|mjs|cjs)$/,".ts");return e.nodes.has(n)?n:null}function $r(t,e){if(typeof t=="string")return wt(t,e);if(t&&typeof t=="object"){let r=t;for(let n of["import","require","default"]){let s=$r(r[n],e);if(s)return s}}return null}function Io(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 Do(t,e){let r=new Set,n=new Set,s=[...e];for(;s.length;){let o=s.shift();if(n.has(o))continue;n.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 l of p.exports)r.add(l.name);s.push(a.toPath)}else for(let p of a.symbols)r.add(p)}}}return r}function Ct(t,e){let r=[],n=zr.default.join(e,"package.json");if(kt.default.existsSync(n))try{let s=JSON.parse(kt.default.readFileSync(n,"utf8"));if(s.exports&&typeof s.exports=="object"&&!Array.isArray(s.exports))for(let o of Object.values(s.exports)){let i=$r(o,t);i&&!r.includes(i)&&r.push(i)}else if(typeof s.exports=="string"){let o=wt(s.exports,t);o&&r.push(o)}if(r.length===0)for(let o of[s.main,s.module].filter(Boolean)){let i=wt(o,t);i&&!r.includes(i)&&r.push(i)}}catch{}if(r.length===0){for(let s of["src/index.ts","src/index.js","index.ts","index.js"])if(t.nodes.has(s)){r.push(s);break}}return r}function Ro(t,e){let r=new Set(e);for(let n of e)t.traverse(n,s=>(r.add(s.path),!0),{direction:"outgoing"});return r}function Go(t,e,r){let n=new Map;for(let s of e){if(r.includes(s))continue;let o=t.nodes.get(s);if(!o)continue;let i=o.category==="barrel";for(let a of o.exports){let c=n.get(a.name),p=!!(a.signature||a.doc);(!c||p&&!i)&&n.set(a.name,{file:s,symbol:a})}}return n}function Lo(t,e,r,n){let s=[];for(let o of t){let i=e.get(o),a=n.flatMap(g=>r.nodes.get(g)?.exports??[]).find(g=>g.name===o),c=i?.symbol??a,p=i?.file??n.find(g=>r.nodes.get(g)?.exports.some(u=>u.name===o))??n[0],l={name:o,definedIn:p,kind:Io(c?.signature)};c?.doc&&(l.doc=c.doc),c?.signature&&(l.signature=c.signature),s.push(l)}return s.sort((o,i)=>o.name.localeCompare(i.name)),s}function _o(t,e,r){let n=c=>t.nodes.get(c)?.category==="test",s=[...e].filter(c=>!r.includes(c)&&!n(c)),o=[...t.nodes.keys()].filter(c=>!e.has(c)),i=o.filter(c=>!n(c)),a=o.filter(c=>n(c));return{internalFiles:s,unreachableFromEntry:i,testFiles:a}}function Ft(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=Ro(t,e),n=Go(t,r,e),s=Do(t,e),o=Lo(s,n,t,e),{internalFiles:i,unreachableFromEntry:a,testFiles:c}=_o(t,r,e);return{entryPoints:e,publicExports:o,internalFiles:i,unreachableFromEntry:a,testFiles:c}}function Et(t,e){let r=null,n=[];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&&n.push({file:o.path,callerFunction:i.from})}let s=[];if(r){let o=t.nodes.get(r);for(let i of o?.callEdges??[])i.from===e&&s.push({file:i.toFile,calleeFunction:i.to})}return{functionName:e,definedIn:r,callers:n,callees:s}}var Oo=h(require("fs")),jo=h(require("path"));function Br(t){let e=[...t.nodes.entries()].sort(([n],[s])=>n.localeCompare(s)).map(([n,s])=>`${n}:${s.mtime}:${s.size}`).join("|"),r=2166136261;for(let n=0;n<e.length;n++)r^=e.charCodeAt(n),r=Math.imul(r,16777619)>>>0;return r.toString(16).padStart(8,"0")}function Tt(t){let e=new Map;for(let r of t.nodes.keys()){let n=[];t.traverse(r,s=>(s.path!==r&&n.push(s.path),!0),{direction:"incoming"}),e.set(r,n)}return{impact:e,graphHash:Br(t)}}function Pt(t,e){return t.impact.get(e)??[]}var sn=require("fs/promises"),Oe=h(require("path"));var ae=h(require("fs")),Ur=h(require("path")),At=require("js-yaml"),Nt=["package-lock.json","yarn.lock","pnpm-lock.yaml"];function Kr(t){let e=t.lastIndexOf("@");return e>0?t.substring(0,e):t}function Wo(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)),Kr(r)}).filter(Boolean)}function zo(t,e){let r=t.startsWith("/")?t.slice(1):t,n=r.lastIndexOf("@");return n>0?{name:r.substring(0,n),version:e||r.substring(n+1)}:{name:r,version:e}}function $o(t){try{let e=(0,At.load)(t),r={dependencies:{}};for(let[n,s]of Object.entries(e))if(!(n==="__metadata"||!s?.version))for(let o of n.split(", ")){let i=Kr(o);i&&(r.dependencies[i]={version:s.version,...s.dependencies!==void 0&&{dependencies:s.dependencies}})}return r}catch{return null}}function Bo(t){let e={dependencies:{}};for(let r of t.split(/\n\n+/)){let n=r.split(`
|
|
4
|
+
`).filter(c=>c.trim().length>0&&!c.trim().startsWith("#"));if(n.length<2)continue;let s=n[0];if(!s||s.startsWith(" "))continue;let o=Wo(s);if(o.length===0)continue;let a=n.find(c=>c.trim().startsWith('version "'))?.match(/version "(.*?)"/)?.[1]??"";for(let c of o)e.dependencies[c]={version:a}}return e}function Uo(t){let e=ae.default.readFileSync(t,"utf-8"),r=JSON.parse(e),n={dependencies:{}};if(r.packages)for(let[s,o]of Object.entries(r.packages)){if(!s.startsWith("node_modules/"))continue;let i=s.replace("node_modules/","");i.includes("node_modules/")||(n.dependencies[i]={version:o.version,...o.dependencies!==void 0&&{dependencies:o.dependencies}})}else if(r.dependencies)for(let[s,o]of Object.entries(r.dependencies))n.dependencies[s]={version:o.version,...o.dependencies!==void 0&&{dependencies:o.dependencies}};return n}function Ko(t){let e=ae.default.readFileSync(t,"utf-8");if(e.includes("__metadata:")){let r=$o(e);if(r!==null)return r}return Bo(e)}function Jo(t){let e=ae.default.readFileSync(t,"utf-8"),r={dependencies:{}};try{let n=(0,At.load)(e);if(n.packages)for(let[s,o]of Object.entries(n.packages)){let{name:i,version:a}=zo(s,o.version);i&&(r.dependencies[i]={version:a,...o.dependencies!==void 0&&{dependencies:o.dependencies}})}if(n.dependencies)for(let[s,o]of Object.entries(n.dependencies)){if(r.dependencies[s])continue;let i=typeof o=="string"?o:o.version;r.dependencies[s]={version:i||""}}}catch{}return r}function Jr(t){let e={"package-lock.json":Uo,"yarn.lock":Ko,"pnpm-lock.yaml":Jo},r=Nt.map(n=>[n,e[n]]);for(let[n,s]of r){let o=Ur.default.join(t,n);if(ae.default.existsSync(o))return s(o)}return null}var Vo=new Set(["css","scss","less","stylus"]);function Vr(t){return Vo.has(t)?"style":"code"}function Ho(t){let e=5381;for(let r=0;r<t.length;r++)e=e*33+t.charCodeAt(r)>>>0;return e.toString(36)}function Qo(t,e){let r=[];for(let n=0;n<=t.length-e;n++)r.push(Ho(t.slice(n,n+e).map(s=>s.text).join(" ")));return r}function qo(t,e,r){let n=t.get(e.file),s=t.get(r.file);if(!n||!s)return 0;let o=0;for(;e.windowIndex+o+1<n.length&&r.windowIndex+o+1<s.length&&n[e.windowIndex+o+1]===s[r.windowIndex+o+1];)o++;return o}function Yo(t,e,r){if(e.windowIndex===0||r.windowIndex===0)return!0;let n=t.get(e.file),s=t.get(r.file);return!n||!s?!0:n[e.windowIndex-1]!==s[r.windowIndex-1]}var Mt=class{parent=new Map;find(e){this.parent.has(e)||this.parent.set(e,e);let r=e;for(;this.parent.get(r)!==r;)r=this.parent.get(r);let n=e;for(;n!==r;){let s=this.parent.get(n);this.parent.set(n,r),n=s}return r}union(e,r){let n=this.find(e),s=this.find(r);n!==s&&this.parent.set(n,s)}root(e){return this.find(e)}};function Re(t){return`${t.file}#${t.startLine}#${t.endLine}`}var Xo=new Set(["{","}",":",",","[","]"]);function Zo(t,e,r){let n=0;for(let s=e;s<e+r;s++)Xo.has(t[s].text)&&n++;return n/r}function Hr(t,e,r,n=.5){let s=new Map,o=new Map,i=new Map;for(let{file:u,tokens:d}of t){if(d.length<e)continue;o.set(u,d);let x=Qo(d,e);s.set(u,x);for(let y=0;y<x.length;y++){let S={file:u,windowIndex:y},C=i.get(x[y]);C?C.push(S):i.set(x[y],[S])}}let a=[];for(let u of i.values())if(!(u.length<2))for(let d=0;d<u.length;d++)for(let x=d+1;x<u.length;x++){let y=u[d],S=u[x];if(y.file===S.file&&y.windowIndex===S.windowIndex||!Yo(s,y,S))continue;let C=qo(s,y,S),N=e+C,M=o.get(y.file);if(Zo(M,y.windowIndex,N)>n)continue;if(y.file===S.file){let[xo,So]=y.windowIndex<S.windowIndex?[y,S]:[S,y];if(xo.windowIndex+N>So.windowIndex)continue}let O=o.get(S.file),ft={file:y.file,startLine:M[y.windowIndex].line,endLine:M[y.windowIndex+N-1].line},mt={file:S.file,startLine:O[S.windowIndex].line,endLine:O[S.windowIndex+N-1].line},Mr=Math.min(ft.endLine-ft.startLine+1,mt.endLine-mt.startLine+1);Mr<r||a.push({occA:ft,occB:mt,lines:Mr,tokens:N})}let c=new Mt,p=new Map;for(let{occA:u,occB:d}of a){let x=Re(u),y=Re(d);p.set(x,u),p.set(y,d),c.union(x,y)}let l=new Map;for(let u of p.keys()){let d=c.root(u),x=l.get(d);x?x.add(u):l.set(d,new Set([u]))}let g=[];for(let u of l.values()){if(u.size<2)continue;let d=[...u].map(S=>p.get(S)),x=0,y=e;for(let S of a)!u.has(Re(S.occA))||!u.has(Re(S.occB))||S.lines>x&&(x=S.lines,y=S.tokens);g.push({occurrences:d,lines:x,tokens:y})}return g.sort((u,d)=>d.lines-u.lines)}var It=h(require("postcss")),ei=h(require("postcss-less")),ti=ei,qr=new Set(["reference","inline"]);function Qr(t){return t.startsWith("~")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//")||t.startsWith("data:")}function ri(t){let e=t.trim();return e.length>0&&!e.startsWith("http://")&&!e.startsWith("https://")&&!e.startsWith("//")&&!e.startsWith("data:")&&!e.startsWith("#")}function ni(t,e){let r=t.match(/^\(([^)]+)\)\s+['"]([^'"]+)['"]/);if(r){let o=r[1]?.trim()??"",i=r[2]??"";if(!i)return null;let a=qr.has(o)?"side-effect":"static";return{fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:a,...Qr(i)?{isExternal:!0}:{}}}let n=t.match(/^url\(['"]?([^'")]+)['"]?\)/),s=n?n[1]?.trim()??"":t.match(/^['"]([^'"]+)['"]/)?.[1]??"";return s?{fromPath:e,toPath:"",rawSpecifier:s,isStyle:!0,type:"static",...Qr(s)?{isExternal:!0}:{}}:null}function si(t,e){let r=[],n=/url\(['"]?([^'")]+)['"]?\)/g,s=n.exec(t);for(;s!==null;){let o=s[1]?.trim()??"";ri(o)&&r.push({fromPath:e,toPath:"",rawSpecifier:o,isStyle:!0,type:"static"}),s=n.exec(t)}return r}function Yr(t,e){let r=[];return t.walk(n=>{if(n.type==="atrule"&&n.name==="import"){let s=ni(n.params,e);s&&r.push(s)}n.type==="decl"&&r.push(...si(n.value,e))}),r}function oi(t){return t.replace(/(?<!:)\/\/.*/g,"")}function ii(t,e){let r=[],n=/@import\s+(?:\(([^)]+)\)\s+)?['"]([^'"]+)['"]/g,s=n.exec(t);for(;s!==null;){let o=s[1]?.trim()??"",i=s[2]??"";if(i){let a=qr.has(o)?"side-effect":"static";r.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:a})}s=n.exec(t)}return r}function Ge(t,e){let r=It.default.parse(oi(t));return{imports:Yr(r,e),root:r}}function ai(t){let e=[],r=[];for(let n of t.nodes??[]){if(n.type!=="atrule")continue;let{value:s}=n;if(s===void 0)continue;let o=n.name;o&&(e.push({name:o}),r.push({name:o,kind:"variable"}))}return{exports:e,tags:r}}function Le(t,e){try{let r=ti.parse(t),{exports:n,tags:s}=ai(r);return{imports:Yr(r,e),root:r,exports:n,tags:s}}catch{return{imports:ii(t,e),root:It.default.parse(""),exports:[],tags:[]}}}var Zr=require("postcss-scss");function Xr(t){return t.startsWith("_")||t.startsWith("-")}function ci(t){return!!(t.startsWith("sass:")||t.startsWith("~")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//")||!t.startsWith(".")&&!t.startsWith("/")&&!t.startsWith("_"))}function pi(t){let e=t.match(/^['"]([^'"]+)['"]/);if(!e?.[1])return{specifier:""};let r=e[1],s=t.match(/\bas\s+(\S+)/)?.[1];return s!==void 0?{specifier:r,alias:s}:{specifier:r}}function li(t){let e=[],r=[];for(let n of t.nodes??[]){if(n.type==="decl"&&n.prop.startsWith("$")){let s=n.prop.slice(1);if(!s||Xr(s))continue;e.push({name:s}),r.push({name:s,kind:"variable"});continue}if(n.type==="atrule"&&(n.name==="mixin"||n.name==="function")){let o=n.params.match(/^([\w-]+)/)?.[1];if(!o||Xr(o))continue;let i=n.params.trim();e.push(i.includes("(")?{name:o,signature:i}:{name:o}),r.push({name:o,kind:"function"})}}return{exports:e,tags:r}}function _e(t,e){let r=(0,Zr.parse)(t),n=[];r.walk(i=>{if(i.type!=="atrule")return;let{name:a,params:c}=i;if(a!=="import"&&a!=="use"&&a!=="forward")return;let{specifier:p,alias:l}=pi(c);if(!p)return;let g={fromPath:e,toPath:"",rawSpecifier:p,isStyle:!0,type:a==="forward"?"re-export":"static",...ci(p)?{isExternal:!0}:{}};l&&(g.symbols=[l]),n.push(g)});let{exports:s,tags:o}=li(r);return{imports:n,root:r,exports:s,tags:o}}function ui(t){return t.trim().replace(/\s+/g," ")}function fi(t){try{return t.fileType==="scss"?_e(t.source,t.file).root:t.fileType==="less"?Le(t.source,t.file).root:t.fileType==="css"?Ge(t.source,t.file).root:void 0}catch{return}}function mi(t){let e=fi(t);if(!e)return[];let r=[];return e.walkRules(n=>{let s=n.nodes?.filter(l=>l.type==="decl")??[];if(s.length===0)return;let o=s[0],i=s[s.length-1],a=n.source?.start?.line??o?.source?.start?.line,c=i?.source?.end?.line??i?.source?.start?.line??a;if(a===void 0||c===void 0)return;let p=s.map(l=>`${l.prop.trim().toLowerCase()}:${ui(l.value)}`).join(";");r.push({file:t.file,startLine:a,endLine:c,lines:c-a+1,signature:p,declCount:s.length})}),r}function en(t,e,r=2){let n=new Map;for(let o of t)for(let i of mi(o)){if(i.declCount<r||i.lines<e)continue;let a=n.get(i.signature);a?a.push(i):n.set(i.signature,[i])}let s=[];for(let o of n.values())for(let i=0;i<o.length;i++)for(let a=i+1;a<o.length;a++){let c=o[i],p=o[a];if(c.file===p.file&&c.startLine===p.startLine&&c.endLine===p.endLine)continue;let l={file:c.file,startLine:c.startLine,endLine:c.endLine},g={file:p.file,startLine:p.startLine,endLine:p.endLine};s.push({occurrences:[l,g],lines:Math.min(c.lines,p.lines),tokens:c.declCount,family:"style"})}return s.sort((o,i)=>i.lines-o.lines)}var gi={typescript:{line:["//"],block:[["/*","*/"]]},javascript:{line:["//"],block:[["/*","*/"]]},go:{line:["//"],block:[["/*","*/"]]},css:{block:[["/*","*/"]]},scss:{line:["//"],block:[["/*","*/"]]},less:{line:["//"],block:[["/*","*/"]]},stylus:{line:["//"],block:[["/*","*/"]]},python:{line:["#"]},gherkin:{line:["#"]},coffeescript:{line:["#"],block:[["###","###"]]},livescript:{line:["#"],block:[["###","###"]]},lua:{line:["--"],block:[["--[[","]]"]]},markdown:{block:[["<!--","-->"]]}};function tn(t,e,r){let n=t.slice(e,r).replace(/[^\n]/g," ");return t.slice(0,e)+n+t.slice(r)}function di(t,e){if(!e)return t;let r=t;for(let[n,s]of e.block??[]){let o=0;for(;;){let i=r.indexOf(n,o);if(i===-1)break;let a=r.indexOf(s,i+n.length),c=a===-1?r.length:a+s.length;r=tn(r,i,c),o=c}}for(let n of e.line??[]){let s=0;for(;;){let o=r.indexOf(n,s);if(o===-1)break;let i=r.indexOf(`
|
|
5
|
+
`,o),a=i===-1?r.length:i;r=tn(r,o,a),s=a}}return r}var hi=["===","!==","...","=>","==","!=","<=",">=","&&","||","::","->","..","+=","-=","*=","/="],Dt=new RegExp(`${hi.map(t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|")}|[A-Za-z_$][A-Za-z0-9_$]*|\\d+(?:\\.\\d+)?|"(?:\\\\.|[^"\\\\])*"|'(?:\\\\.|[^'\\\\])*'|\`(?:\\\\.|[^\`\\\\])*\`|\\S`,"g"),yi=/^[A-Za-z_$][A-Za-z0-9_$]*$/,rn=/^\d+(?:\.\d+)?$/,xi=/^(".*"|'.*'|`.*`)$/s,Si=new Set(["if","else","elif","for","while","do","switch","case","default","break","continue","return","function","def","class","struct","interface","const","let","var","local","import","export","from","package","try","catch","except","finally","throw","raise","new","this","self","end","then","yield","async","await","nil","null","None","true","false","True","False","and","or","not","in","of","is"]);function nn(t,e,r=!0){let n=di(t,gi[e]),s=[],o=1,i=0;Dt.lastIndex=0;let a=Dt.exec(n);for(;a!==null;){for(let l=i;l<a.index;l++)n[l]===`
|
|
6
|
+
`&&o++;i=a.index;let c=a[0],p=c;yi.test(c)&&!Si.has(c)?p="ID":r&&(rn.test(c)||xi.test(c))&&(p=rn.test(c)?"NUM":"STR"),s.push({text:p,line:o});for(let l=i;l<a.index+c.length;l++)n[l]===`
|
|
7
|
+
`&&o++;i=a.index+c.length,a=Dt.exec(n)}return s}var bi=new Set(["css","scss","less"]);function vi(t){return Nt.includes(Oe.default.basename(t))}function ki(t,e){if(e.length===0)return!1;let r=new Set(e);return t.split(Oe.default.sep).some(n=>r.has(n))}async function Rt(t,e,r={}){let{minLines:n=6,windowSize:s=15,ignoreLiterals:o=!0,maxPunctuationRatio:i=.5,limit:a=50,ignoreDirs:c=j}=r,p=[...t.nodes.values()].filter(d=>!vi(d.path)&&!ki(d.path,c)),l=[],g=new Map;await Promise.all(p.map(async d=>{let x;try{x=await(0,sn.readFile)(Oe.default.join(e,d.path),"utf8")}catch{return}if(bi.has(d.type)){l.push({file:d.path,source:x,fileType:d.type});return}let y=Vr(d.type),S={file:d.path,tokens:nn(x,d.type,o)},C=g.get(y);C?C.push(S):g.set(y,[S])}));let u=en(l,n);for(let[d,x]of g)for(let y of Hr(x,s,n,i))u.push({...y,family:d});return u.sort((d,x)=>x.lines-d.lines).slice(0,a)}var ce=h(require("path"));function wi(t){let e=new Map;for(let[r,n]of t){let s=n.imports.filter(o=>o.toPath&&!o.isExternal).length;s>0&&e.set(r,s)}return e}function Ci(t,e,r){let n=new Map;for(let[s,o]of e){if(o<r)continue;let i=t.get(s);if(!i||i.category==="test"||i.category==="barrel")continue;let a=ce.default.extname(s),c=ce.default.basename(s,a),p=c==="index"?ce.default.basename(ce.default.dirname(s)):c;n.set(s,{path:s,outDegree:o,tag:`feature:${p}`})}return n}function W(t,e){let r=e?.minOutDegree??5;return Ci(t,wi(t),r)}var Fi=(t,e)=>t.outDegree-e.outDegree;function Ei(t,e){let r=new Map;for(let n of e.values()){let s=new Set;t.traverse(n.path,o=>(o.path!==n.path&&s.add(o.path),!0),{direction:"outgoing"}),r.set(n.path,s)}return r}function Ti(t,e,r,n){let s=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||n(a,i)<0)&&(i=a);i&&s.set(o,i.path)}return s}function Pi(t,e){let r=new Map;for(let n of t.values()){let s=n.tag.replace("feature:",""),o=[];for(let[i,a]of e)a===n.path&&o.push(i);r.set(s,{hub:n.path,outDegree:n.outDegree,files:o})}return r}function Ai(t,e,r){let n=[];for(let s of t.keys())!e.has(s)&&!r.has(s)&&n.push(s);return n}function pe(t,e){let r=e?.detectFn??W,n=e?.hubComparator??Fi,s=r(t.nodes,e),o=Ei(t,s),i=Ti(t.nodes,s,o,n);return{features:Pi(s,i),unassigned:Ai(t.nodes,s,i)}}var on=new Set(["typescript","javascript","python","go","scss","less","lua","coffeescript"]),an=new Set(["typescript","javascript","python"]),je=new Set(["typescript","javascript","go","python"]);function Gt(t){let e=new Map;for(let r of t.nodes.values())e.set(r.type,(e.get(r.type)??0)+1);return[...e.entries()].map(([r,n])=>({type:r,fileCount:n,exportsTracked:on.has(r),importSymbolsTracked:an.has(r),callEdgesTracked:je.has(r)})).sort((r,n)=>n.fileCount-r.fileCount)}var le=class{constructor(e){this.nodes=e}nodes;findUnusedFiles(e){let r=new Set(this.nodes.keys());return e.filter(n=>!r.has(n))}findHighExportUsage(e){let r=[];for(let n of this.nodes.values()){if(n.maxExportUsage===void 0||n.maxExportUsage<e)continue;let s=n.imports.reduce((o,i)=>(i.exportUsageRatio??0)>(o?.exportUsageRatio??0)?i:o,null);r.push({path:n.path,maxExportUsage:n.maxExportUsage,tightestDep:s?.toPath??""})}return r.sort((n,s)=>s.maxExportUsage-n.maxExportUsage)}findCycles(){let e=[],r=new Set,n=new Set,s=[],o=i=>{r.add(i),n.add(i),s.push(i);let a=this.nodes.get(i);if(a){for(let c of a.imports)if(!(!c.toPath||c.isExternal))if(n.has(c.toPath)){let p=s.indexOf(c.toPath);e.push([...s.slice(p),c.toPath])}else r.has(c.toPath)||o(c.toPath)}n.delete(i),s.pop()};for(let i of this.nodes.keys())r.has(i)||o(i);return e}};var D=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 n of e.nodes)r.set(n.path,n);return new t(r)}getIncomingEdgesMap(){if(this._incomingEdgesCache)return this._incomingEdgesCache;let e=new Map;for(let r of this.nodes.values())for(let n of r.imports)if(n.toPath){let s=e.get(n.toPath)||[];s.push(r.path),e.set(n.toPath,s)}return this._incomingEdgesCache=e,e}dfs(e,r,n,s){let o=new Set,i=n.maxDepth??1/0,a=(c,p,l)=>{if(p>i||o.has(c))return;let g=this.nodes.get(c);if(g&&(o.add(c),r(g,p,l)!==!1))for(let u of s(c))a(u,p+1,c)};a(e,0,null)}traverse(e,r,n={}){let s=n.direction??"outgoing",o=s==="incoming"?this.getIncomingEdgesMap():null;this.dfs(e,r,n,i=>s==="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 n of r.callEdges??[]){let s=e.get(n.toFile)??[];s.push(r.path),e.set(n.toFile,s)}return this._callIncomingCache=e,e}traverseCalls(e,r,n={}){let s=n.direction??"outgoing",o=s==="incoming"?this.getCallIncomingCache():null;this.dfs(e,r,n,i=>s==="outgoing"?this.nodes.get(i)?.callEdges?.map(a=>a.toFile)??[]:o?.get(i)??[])}getCallers(e){let r=[];return this.traverseCalls(e,n=>(n.path!==e&&r.push(n.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(n=>this.nodes.get(n.toPath)).filter(n=>n!==void 0):[]}findUnusedFiles(e){return new le(this.nodes).findUnusedFiles(e)}findCycles(){return new le(this.nodes).findCycles()}};var z=class{affectedSymbols=new Map;constructor(e,r){this.affectedSymbols.set(e,new Set(["default",...r]))}updateAffectedSymbols(e,r){let n=this.affectedSymbols.get(r)||new Set,s=e.imports.find(c=>c.toPath===r);if(!s)return!1;let o=s.symbols||["*"],i=new Set;for(let c of o)(c==="*"||n.has("*")||n.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 ue(t,e){let r=t.nodes.get(e);if(r)return{category:r.category,exports:r.exports.map(n=>n.name)}}function Lt(t,e,r=1){let n=[];return t.traverse(e,(s,o,i)=>{if(s.path===e)return!0;let a=i?t.nodes.get(i)?.imports.find(c=>c.toPath===s.path):void 0;return n.push({path:s.path,...a?.symbols?{symbols:a.symbols}:{}}),!0},{direction:"outgoing",maxDepth:r}),n}function fe(t,e){let r=[];return t.traverse(e,n=>{if(n.path===e)return!0;let s=n.imports.find(o=>o.toPath===e);return r.push({path:n.path,...s?.symbols?{symbols:s.symbols}:{}}),!0},{direction:"incoming",maxDepth:1}),r}function _t(t,e,r={}){let{testsOnly:n=!1,changedSymbols:s}=r,o=s?new z(e,s):null,i=[];return t.traverse(e,(a,c,p)=>{if(a.path===e)return!0;if(o&&p&&!o.updateAffectedSymbols(a,p))return!1;let l=a.category==="test"||a.tags.some(g=>g.name==="test");return(!n||l)&&i.push(a.path),!0},{direction:"incoming"}),i}function Ot(t,e,r={}){let{depth:n=1,withEdgeDetail:s=!1}=r,o=[];return t.traverseCalls(e,i=>{if(i.path===e)return!0;let a={file:i.path};return s&&(a.edges=(i.callEdges??[]).filter(c=>c.toFile===e).map(c=>({from:c.from,to:c.to}))),o.push(a),!0},{direction:"incoming",maxDepth:n}),o}function jt(t,e={}){let{metric:r="cognitiveComplexity",threshold:n=10,limit:s=20}=e;return[...t.nodes.values()].flatMap(o=>(o.functions??[]).filter(i=>i[r]>=n).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,s)}function Wt(t){return{nodes:t.nodes.map(r=>({path:r.path,type:r.type,category:r.category,exports:r.exports.map(n=>n.name),tags:r.tags.filter(n=>n.kind==="comment-marker"||n.kind==="import").map(n=>n.name),importsFiles:r.imports.filter(n=>!n.isExternal&&n.toPath).map(n=>n.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 zt(t){let e=t.getPackageDependencies(),r=Array.from(t.packages.values()).map(({graph:n,pkg:s})=>({name:s.name,relativeRoot:s.relativeRoot,nodeCount:n.nodes.size,dependsOn:e.get(s.name)??[]}));return{monorepoType:t.type,packageCount:r.length,packages:r}}function $t(t){return[...t.nodes.values()].some(e=>e.coveragePct!==void 0)}function cn(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 k(e,"component")||k(e,"components")?"component":k(e,"controller")||k(e,"controllers")?"controller":k(e,"middleware")?"middleware":k(e,"router")||k(e,"routes")||k(e,"route")?"router":k(e,"store")||k(e,"stores")?"store":k(e,"service")||k(e,"services")?"service":k(e,"handler")||k(e,"handlers")?"handler":k(e,"adapter")||k(e,"adapters")?"adapter":k(e,"plugin")||k(e,"plugins")?"plugin":k(e,"api")?"api":k(e,"cli")||k(e,"commands")||me(e)==="cli"?"cli":k(e,"util")||k(e,"utils")||k(e,"helper")||k(e,"helpers")?"util":k(e,"model")||k(e,"models")||me(e)==="model"?"model":k(e,"parser")||k(e,"parsers")||me(e)==="parser"?"parser":me(e)==="builder"?"builder":me(e)==="resolver"?"resolver":"other"}function k(t,e){return t.includes(`/${e}/`)||t.includes(`/${e}.`)}function me(t){let e=t.slice(t.lastIndexOf("/")+1);return e.slice(0,e.lastIndexOf("."))||e}function Bt(t,e){let r=pe(t,e),n=new Map;for(let[o,i]of r.features){for(let a of i.files)n.set(a,o);n.set(i.hub,o)}let s=new Map;for(let o of t.nodes.values()){let i=n.get(o.path);s.set(o.path,{path:o.path,role:cn(o),...o.description?{description:o.description}:{},exports:o.exports.map(a=>a.name),...i?{featureHub:i}:{}})}return s}function Ut(t,e){let r=[];for(let n of t.nodes.values())if(n.exports.some(s=>s.name===e))if(je.has(n.type)){let s=[];for(let o of t.nodes.values())for(let i of o.callEdges??[])i.to===e&&s.push({file:o.path,callerFunction:i.from});r.push({path:n.path,category:n.category,precision:"call",callers:s})}else{let s=fe(t,n.path).map(o=>({file:o.path,...o.symbols?{symbols:o.symbols}:{}}));r.push({path:n.path,category:n.category,precision:"file-level",importers:s})}return r}function Ni(t){return t?t.startsWith("interface ")?"interface":t.startsWith("class ")?"class":t.startsWith("enum ")?"enum":"type":"type"}function Mi(t,e){if(e==="type-only")return!0;let r=t.signature??"";return r.startsWith("interface ")||r.startsWith("class ")||r.startsWith("enum ")}function Kt(t){let e=new Map;for(let n of t.nodes.values())if(!(n.type!=="typescript"&&n.type!=="javascript"))for(let s of n.exports){if(!Mi(s,n.category))continue;let o=`${n.path}::${s.name}`;e.set(o,{name:s.name,file:n.path,kind:Ni(s.signature),...s.doc?{doc:s.doc}:{}})}let r=[];for(let n of t.nodes.values())if(!(n.type!=="typescript"&&n.type!=="javascript")){for(let s of n.imports)if(!(!s.toPath||s.isExternal||!s.symbols?.length))for(let o of s.symbols)e.has(`${s.toPath}::${o}`)&&r.push({fromFile:n.path,toType:o,toFile:s.toPath})}return{types:e,edges:r}}function Jt(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 n=new Set,s=new Map;for(let o of t.edges)if(o.toType===e&&o.toFile===r.file&&n.add(o.fromFile),o.fromFile===r.file){let i=t.types.get(`${o.toFile}::${o.toType}`);i&&s.set(`${i.file}::${i.name}`,i)}return{type:r,usedByFiles:Array.from(n),uses:Array.from(s.values())}}var wn=h(require("path"));var ze=h(require("fs")),Qt=h(require("path"));var Y=h(require("fs")),P=h(require("path"));var Vt=h(require("fs")),Ii=h(require("path"));function pn(t){try{return Vt.default.statSync(t,{throwIfNoEntry:!1})?.isDirectory()===!0}catch{return!1}}function We(t){try{return Vt.default.statSync(t,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}function Ht(t,e){let r=P.default.join(e,"package.json");if(!Y.default.existsSync(r))return null;let n={};try{n=JSON.parse(Y.default.readFileSync(r,"utf-8"))}catch{return null}let s=n.name;return s?{name:s,root:e,relativeRoot:P.default.relative(t,e),entryPoints:Di(e,n)}:null}function Di(t,e){let r=[];if(e.exports){let s=e.exports;if(typeof s=="string")r.push(P.default.join(t,s));else if(typeof s=="object"&&s!==null){let o=s["."];if(typeof o=="string")r.push(P.default.join(t,o));else if(typeof o=="object"&&o!==null){let i=o.import??o.require??o.default;typeof i=="string"&&r.push(P.default.join(t,i))}}}e.main&&r.push(P.default.join(t,e.main));for(let s of["src/index.ts","src/index.tsx","index.ts","index.tsx","index.js"])r.push(P.default.join(t,s));let n=r.filter(We);return n.length>0?n.slice(0,1):r.slice(0,1)}function X(t,e){let r=[],n=new Set;for(let s of e){let o=s.replace(/\/$/,"").replace(/^\.\//,"");Ri(t,o,n,r)}return r}function Ri(t,e,r,n){if(!e.includes("*")){Gi(t,e,r,n);return}let s=e.split("/");s.includes("**")?Li(t,s,r,n):_i(t,s,r,n)}function Gi(t,e,r,n){let s=P.default.join(t,e);if(r.has(s)||!pn(s))return;r.add(s);let o=Ht(t,s);o&&n.push(o)}function Li(t,e,r,n){let s=P.default.join(t,e[0]==="**"?"":e[0]??"");ln(t,s,r,n)}function _i(t,e,r,n){let s=e.findIndex(a=>a.includes("*")),o=P.default.join(t,...e.slice(0,s)),i;try{i=Y.default.readdirSync(o,{withFileTypes:!0})}catch{return}for(let a of i){if(!a.isDirectory())continue;let c=P.default.join(o,a.name);if(r.has(c))continue;r.add(c);let p=Ht(t,c);p&&n.push(p)}}function ln(t,e,r,n){let s;try{s=Y.default.readdirSync(e,{withFileTypes:!0})}catch{return}for(let o of s){if(!o.isDirectory()||o.name==="node_modules"||o.name.startsWith("."))continue;let i=P.default.join(e,o.name);if(Y.default.existsSync(P.default.join(i,"package.json"))&&!r.has(i)){r.add(i);let a=Ht(t,i);a&&n.push(a)}else ln(t,i,r,n)}}var un={type:"npm",detect(t){let e=Qt.default.join(t,"package.json");if(!ze.default.existsSync(e))return null;let r;try{r=JSON.parse(ze.default.readFileSync(e,"utf-8")).workspaces}catch{return null}if(!r||ze.default.existsSync(Qt.default.join(t,"yarn.lock")))return null;let n=Array.isArray(r)?r:r.packages??[];return n.length===0?null:X(t,n)}};var $=h(require("fs")),E=h(require("path"));var fn={type:"nx",detect(t){return $.default.existsSync(E.default.join(t,"nx.json"))?mn(t,t,new Set,0).map(r=>Oi(t,r,E.default.join(r,"project.json"))).filter(r=>r!==null):null}};function mn(t,e,r,n){if(n>4)return[];let s;try{s=$.default.readdirSync(e,{withFileTypes:!0})}catch{return[]}let o=[];for(let i of s){if(!i.isDirectory())continue;let a=i.name;if(a.startsWith(".")||a==="node_modules"||a==="dist"||a===".nx")continue;let c=E.default.join(e,a);$.default.existsSync(E.default.join(c,"project.json"))&&!r.has(c)?(r.add(c),o.push(c)):o.push(...mn(t,c,r,n+1))}return o}function Oi(t,e,r){let n={};try{n=JSON.parse($.default.readFileSync(r,"utf-8"))}catch{return null}let s=n.name,o,i,a=E.default.join(e,"package.json");if($.default.existsSync(a))try{let c=JSON.parse($.default.readFileSync(a,"utf-8"));s=c.name??s,o=c.main,i=c.exports}catch{}return s?{name:s,root:e,relativeRoot:E.default.relative(t,e),entryPoints:ji(e,n,o,i)}:null}function ji(t,e,r,n){let s=[],o=e.targets?.build?.options?.main??e.targets?.build?.options?.entryFile;if(o){let a=E.default.resolve(t,"../..");s.push(E.default.resolve(a,o)),s.push(E.default.resolve(t,o))}if(n){let a=n;if(typeof a=="string")s.push(E.default.join(t,a));else if(typeof a=="object"&&a!==null){let c=a["."];typeof c=="string"&&s.push(E.default.join(t,c))}}if(r&&s.push(E.default.join(t,r)),e.sourceRoot){let a=E.default.resolve(t,"../.."),c=E.default.resolve(a,e.sourceRoot);s.push(E.default.join(c,"index.ts"),E.default.join(c,"index.tsx"))}for(let a of["src/index.ts","src/index.tsx","index.ts","index.tsx"])s.push(E.default.join(t,a));let i=s.filter(We);return i.length>0?i.slice(0,1):s.slice(0,1)}var qt=h(require("fs")),gn=h(require("path")),dn=require("js-yaml");var hn={type:"pnpm",detect(t){let e=gn.default.join(t,"pnpm-workspace.yaml");if(!qt.default.existsSync(e))return null;let r=[];try{r=(0,dn.load)(qt.default.readFileSync(e,"utf-8"))?.packages??[]}catch{return null}return X(t,r)}};var yn=h(require("fs")),xn=h(require("path")),Sn={type:"turborepo",detect(t){return yn.default.existsSync(xn.default.join(t,"turbo.json"))?[]:null}};var $e=h(require("fs")),Yt=h(require("path"));var bn={type:"yarn",detect(t){if(!$e.default.existsSync(Yt.default.join(t,"yarn.lock")))return null;let e=Yt.default.join(t,"package.json");if(!$e.default.existsSync(e))return null;let r;try{r=JSON.parse($e.default.readFileSync(e,"utf-8")).workspaces}catch{return null}if(!r)return null;let n=Array.isArray(r)?r:r.packages??[];return n.length===0?null:X(t,n)}};var vn=[];function G(t){vn.push(t)}function kn(){return vn}G(Sn);G(fn);G(hn);G(bn);G(un);function ge(t,e=kn()){let r=wn.default.resolve(t),n=new Map,s=[];for(let i of e){let a=i.detect(r);if(a!==null){s.push(i.type);for(let c of a)n.has(c.name)||n.set(c.name,c)}}if(s.length===0)return{root:r,type:"none",types:[],packages:[],packageMap:new Map};let o=Array.from(n.values());return{root:r,type:s[0],types:s,packages:o,packageMap:new Map(o.map(i=>[i.name,i]))}}var de=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:n}of this.packages.values()){let s=new Set;for(let o of r.nodes.values())for(let i of o.imports)i.isWorkspace&&i.workspacePackage&&s.add(i.workspacePackage);e.set(n.name,[...s])}return e}getAffectedAcrossPackages(e){let r=this.getPackageForFile(e);if(!r)return[];let n=this.packages.get(r.name);if(!n)return[];let s=[];n.graph.traverse(e,o=>(o.path!==e&&s.push({file:o.path,package:r.name}),!0),{direction:"incoming"});for(let{graph:o,pkg:i}of this.packages.values())if(i.name!==r.name)for(let a of o.nodes.values())a.imports.some(p=>p.isWorkspace&&p.workspacePackage===r.name)&&s.push({file:a.path,package:i.name});return s}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:n,nodes:s}of e.packages){let o=new Map(s.map(a=>[a.path,a])),i=new D(o);r.packages.set(n.name,{graph:i,pkg:{...n,root:""}})}return r}};var Cn=new Map;function Z(t,e){Cn.set(t,e)}function Fn(t){return Cn.get(t)}function En(t,e){return e.startsWith("!")?t!==e.slice(1):t===e}function Wi(t,e){return e.startsWith("!")?!t.includes(e.slice(1)):t.includes(e)}var zi=(t,e)=>!e.category||En(t.category,e.category),$i=(t,e)=>!e.type||En(t.type,e.type),Bi=(t,e)=>e.lastAuthor?e.lastAuthor.startsWith("!")?t.lastAuthor!==e.lastAuthor.slice(1):t.lastAuthor!==void 0&&t.lastAuthor===e.lastAuthor:!0,Ui=(t,e)=>!e.path||Wi(t.path,e.path),Ki=(t,e)=>e.isExternal===void 0?!0:t.imports.some(n=>n.isExternal)===e.isExternal,Ji=(t,e)=>{if(!e.tags||e.tags.length===0)return!0;let r=e.tags.filter(s=>!s.startsWith("!")),n=e.tags.filter(s=>s.startsWith("!")).map(s=>s.slice(1));return!(r.length>0&&!r.some(s=>t.tags.some(o=>o.name===s))||n.some(s=>t.tags.some(o=>o.name===s)))},Vi=(t,e)=>!e.allTags?.length||e.allTags.every(r=>t.tags.some(n=>n.name===r)),Hi=(t,e)=>!e.importsFile||t.imports.some(r=>r.toPath?.includes(e.importsFile)),Qi=(t,e,r)=>e.importedBy===void 0?!0:(r?.get(t.path)??[]).some(s=>s.includes(e.importedBy)),qi=(t,e)=>e.minImports===void 0||t.imports.length>=e.minImports,Yi=(t,e)=>e.maxImports===void 0||t.imports.length<=e.maxImports,Xi=(t,e)=>e.minSize===void 0||t.size>=e.minSize,Zi=(t,e)=>e.maxSize===void 0||t.size<=e.maxSize,ea=(t,e)=>e.hasDocstring===void 0||!!t.description===e.hasDocstring,ta=(t,e)=>e.isDocumented===void 0||!!t.documentedBy?.length===e.isDocumented,ra=(t,e)=>e.isStale===void 0||!!t.staleFor?.length===e.isStale,na=(t,e)=>e.minCoverage===void 0||(t.coveragePct??101)>=e.minCoverage,sa=(t,e)=>e.maxCoverage===void 0||(t.coveragePct??0)<=e.maxCoverage,oa=(t,e)=>e.minExportUsage===void 0||(t.avgExportUsage??-1)>=e.minExportUsage,ia=(t,e)=>e.maxExportUsage===void 0||(t.avgExportUsage??0)<=e.maxExportUsage,aa=(t,e)=>e.minComplexity===void 0||(t.complexity??-1/0)>=e.minComplexity,ca=(t,e)=>e.maxComplexity===void 0||(t.complexity??0)<=e.maxComplexity,pa=(t,e)=>e.minCognitiveComplexity===void 0||(t.cognitiveComplexity??-1/0)>=e.minCognitiveComplexity,la=(t,e)=>e.maxCognitiveComplexity===void 0||(t.cognitiveComplexity??0)<=e.maxCognitiveComplexity,ua=(t,e)=>e.minCommits===void 0||(t.commitCount90d??-1/0)>=e.minCommits,fa=(t,e)=>e.maxCommits===void 0||(t.commitCount90d??0)<=e.maxCommits,ma=(t,e,r)=>!e.any?.length||e.any.some(n=>he(t,n,r)),ga=[zi,$i,Bi,Ui,Ki,Ji,Vi,Hi,Qi,qi,Yi,Xi,Zi,ea,ta,ra,na,sa,oa,ia,aa,ca,pa,la,ua,fa,ma];function he(t,e,r){return ga.every(n=>n(t,e,r))}function Be(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 n=t.nodes.filter(i=>he(i,e,r)),s=new Set(n.map(i=>i.path)),o=n.map(i=>({...i,imports:i.imports.filter(a=>!a.toPath||s.has(a.toPath))}));if(e.sort){let i=e.sortDir==="asc"?-1:1;o.sort((a,c)=>{let p=0;return e.sort==="size"?p=c.size-a.size:e.sort==="imports"?p=c.imports.length-a.imports.length:e.sort==="commitCount90d"?p=(c.commitCount90d??0)-(a.commitCount90d??0):e.sort==="exportUsage"?p=(c.avgExportUsage??0)-(a.avgExportUsage??0):e.sort==="complexity"?p=(c.complexity??0)-(a.complexity??0):e.sort==="cognitiveComplexity"&&(p=(c.cognitiveComplexity??0)-(a.cognitiveComplexity??0)),p*i})}return e.limit!==void 0&&o.splice(e.limit),{nodes:o,cycles:t.cycles?.filter(i=>i.every(a=>s.has(a)))??void 0}}function Tn(t,e){let r=e.indexOf(":");if(r===-1)return;let n=e.slice(0,r).trim().toLowerCase(),s=e.slice(r+1).trim();if(!(!n||!s))switch(n){case"category":t.category=s;break;case"type":t.type=s;break;case"tag":case"tags":s.includes("+")?t.allTags=[...t.allTags??[],...s.split("+")]:t.tags=[...t.tags??[],s];break;case"path":t.path=s;break;case"external":t.isExternal=s.toLowerCase()==="true";break;case"importsfile":t.importsFile=s;break;case"importedby":t.importedBy=s;break;case"minimports":t.minImports=parseInt(s,10);break;case"maximports":t.maxImports=parseInt(s,10);break;case"minsize":t.minSize=parseInt(s,10);break;case"maxsize":t.maxSize=parseInt(s,10);break;case"sort":t.sort=s;break;case"sortdir":t.sortDir=s.toLowerCase()==="asc"?"asc":"desc";break;case"limit":t.limit=parseInt(s,10);break;case"hasdocstring":t.hasDocstring=s.toLowerCase()!=="false";break;case"mincoverage":t.minCoverage=parseInt(s,10);break;case"maxcoverage":t.maxCoverage=parseInt(s,10);break;case"minexportusage":t.minExportUsage=parseFloat(s);break;case"maxexportusage":t.maxExportUsage=parseFloat(s);break;case"mincomplexity":t.minComplexity=parseInt(s,10);break;case"maxcomplexity":t.maxComplexity=parseInt(s,10);break;case"mincognitivecomplexity":t.minCognitiveComplexity=parseInt(s,10);break;case"maxcognitivecomplexity":t.maxCognitiveComplexity=parseInt(s,10);break;case"mincommits":t.minCommits=parseInt(s,10);break;case"maxcommits":t.maxCommits=parseInt(s,10);break;case"isdocumented":t.isDocumented=s.toLowerCase()!=="false";break;case"isstale":t.isStale=s.toLowerCase()!=="false";break;case"lastauthor":t.lastAuthor=s;break}}function da(t){let e=[];for(let r of t.split("|")){let n=r.trim();if(!n)continue;let s={};Tn(s,n),Object.keys(s).length>0&&e.push(s)}return e}function Ue(t){let e={},r=t.split(",");for(let n of r){let s=n.trim();if(s.toLowerCase().startsWith("any(")&&s.endsWith(")")){let o=s.slice(4,-1),i=da(o);i.length>0&&(e.any=[...e.any??[],...i]);continue}Tn(e,n)}return e}var fr=h(require("fs/promises")),Wn=h(require("path"));var Ze=h(require("path")),ye=h(require("typescript"));var Nn=h(require("path"));var An=h(require("path")),F=h(require("typescript")),Pn=new Set(["describe","test","it"]);function B(t,e){let r=t[e];if(r===void 0)throw new Error(`Index ${e} out of bounds (length ${t.length})`);return r}function Xt(t){let e=[];for(let r of t.statements){if(!F.default.isExpressionStatement(r))continue;let n=r.expression;if(!F.default.isCallExpression(n))continue;let s=n.expression;F.default.isIdentifier(s)&&Pn.has(s.text)&&e.push(n),F.default.isPropertyAccessExpression(s)&&F.default.isIdentifier(s.expression)&&Pn.has(s.expression.text)&&e.push(n)}return e}function Zt(t,e,r){for(let n of t.arguments){if(!F.default.isObjectLiteralExpression(n))continue;let s=n.properties.find(o=>F.default.isPropertyAssignment(o)&&F.default.isIdentifier(o.name)&&o.name.text===e);if(!(!s||!F.default.isArrayLiteralExpression(s.initializer)))return s.initializer.elements.filter(F.default.isStringLiteral).map(o=>o.text)}return null}function er(t,e,r,n){if(t.arguments.length===0)return null;for(let o=1;o<t.arguments.length;o++){let i=B(t.arguments,o);if(!F.default.isObjectLiteralExpression(i))continue;let a=i.properties.find(p=>F.default.isPropertyAssignment(p)&&F.default.isIdentifier(p.name)&&p.name.text===e);if(a)return{start:a.initializer.getStart(n),end:a.initializer.getEnd(),text:r};let c=i.getEnd()-1;return{start:c,end:c,text:`${i.properties.length>0?", ":""}${e}: ${r}`}}let s=B(t.arguments,t.arguments.length-1);return{start:s.getStart(n),end:s.getStart(n),text:`{ ${e}: ${r} }, `}}function tr(t,e,r){let n=t.arguments;for(let s=1;s<n.length;s++){let o=B(n,s);if(!F.default.isObjectLiteralExpression(o))continue;let i=o.properties.findIndex(c=>F.default.isPropertyAssignment(c)&&F.default.isIdentifier(c.name)&&c.name.text===e);if(i<0)continue;if(o.properties.length===1)return{start:B(n,s-1).getEnd(),end:o.getEnd(),text:""};let a=B(o.properties,i);return i===o.properties.length-1?{start:B(o.properties,i-1).getEnd(),end:a.getEnd(),text:""}:{start:a.getStart(r),end:B(o.properties,i+1).getStart(r),text:""}}return null}function rr(t,e){let r=[...e].sort((s,o)=>o.start-s.start),n=t;for(let s of r)n=n.slice(0,s.start)+s.text+n.slice(s.end);return n}function nr(t){return`[${t.map(e=>JSON.stringify(e)).join(", ")}]`}var I=new Set([".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"]);function ha(t){return t.map(e=>e.startsWith("@")?e.slice(1):e)}function Ke(t,e,r,n){let s=F.default.createSourceFile(An.default.basename(t),e,F.default.ScriptTarget.Latest,!0),o=Xt(s),[i]=o;if(!i)return e;let a=Zt(i,n,s),c=[...r].sort();if(a!==null&&JSON.stringify(ha(a).sort())===JSON.stringify(c))return e;let p=nr(c.map(g=>`@${g}`)),l=o.flatMap(g=>{let u=r.length===0?tr(g,n,s):er(g,n,p,s);return u?[u]:[]});return l.length>0?rr(e,l):e}var Je=class{name="cypress";canHandle(e){return I.has(Nn.default.extname(e).toLowerCase())}apply(e,r,n){return Ke(e,r,n,"tags")}};var Mn=h(require("path")),sr=/# <mokosh-tags>[\s\S]*?# <\/mokosh-tags>\n*/,or=/^@([a-zA-Z0-9_-]+)/gm;function ya(t){return`${["# <mokosh-tags>",...t.map(e=>`@${e}`),"# </mokosh-tags>"].join(`
|
|
8
|
+
`)}
|
|
5
9
|
|
|
6
|
-
`}function
|
|
7
|
-
`}function
|
|
8
|
-
|
|
9
|
-
`)
|
|
10
|
+
`}function xa(t){let e=new Set;or.lastIndex=0;let r=or.exec(t);for(;r!==null;)r[1]&&e.add(r[1]),r=or.exec(t);return e}var Ve=class{name="gherkin";canHandle(e){return Mn.default.extname(e).toLowerCase()===".feature"}apply(e,r,n){let s=r.replace(sr,""),o=xa(s),i=n.filter(c=>!o.has(c)),a=i.length>0?ya(i):"";return sr.test(r)?r.replace(sr,a):a?r.replace(/^(Feature:)/m,`${a}$1`):r}};function In(t,e){let r=t.replace(/\\/g,"/"),n=e.replace(/\\/g,"/"),s="";for(let o=0;o<r.length;o++){let i=r[o];i==="*"?r[o+1]==="*"?(s+=".*",o++):s+="[^/]*":i==="?"?s+="[^/]":i!==void 0&&(s+=i.replace(/[.+^${}()|[\]\\]/g,"\\$&"))}return new RegExp(`^${s}$`).test(n)}var Dn=h(require("path")),ir=/^\/\/go:build mokosh_[^\n]+\n/m,Sa=/^package\s+\S+/m;function ba(t){return`//go:build ${t.map(r=>`mokosh_${r}`).join(" || ")}
|
|
11
|
+
`}function va(t){let e=ir.exec(t);if(!e)return null;let r=e[0]??"",n=/mokosh_([a-zA-Z0-9_-]+)/g,s=[],o=n.exec(r);for(;o!==null;)o[1]&&s.push(o[1]),o=n.exec(r);return s}var He=class{name="go";canHandle(e){return Dn.default.basename(e).endsWith("_test.go")}apply(e,r,n){let s=va(r),o=[...n].sort();if(s!==null&&JSON.stringify([...s].sort())===JSON.stringify(o))return r;if(n.length===0)return r.replace(ir,"");let i=ba(o);if(s!==null)return r.replace(ir,i);let a=Sa.exec(r);if(!a)return r;let c=a.index;return`${r.slice(0,c)+i}
|
|
12
|
+
${r.slice(c)}`}};var Rn=h(require("path"));var ka=/^\/\*\*\n(?: \* @group .+\n)+ \*\/\n+/,ar=/^ \* @group (.+)$/gm;function wa(t){return`${["/**",...t.map(e=>` * @group ${e}`)," */"].join(`
|
|
13
|
+
`)}
|
|
10
14
|
|
|
11
|
-
`}function
|
|
15
|
+
`}function Ca(t){let e=[];ar.lastIndex=0;let r=ar.exec(t);for(;r!==null;)r[1]&&e.push(r[1]),r=ar.exec(t);return e}var Qe=class{name="jest";canHandle(e){return I.has(Rn.default.extname(e).toLowerCase())}apply(e,r,n){let s=ka.exec(r),o=s?Ca(s[0]):null,i=[...n].sort();if(o!==null&&JSON.stringify([...o].sort())===JSON.stringify(i))return r;let a=s?r.slice(s[0].length):r;return n.length===0?a:wa(i)+a}};var Gn=h(require("path"));var qe=class{name="playwright";canHandle(e){return I.has(Gn.default.extname(e).toLowerCase())}apply(e,r,n){return Ke(e,r,n,"tag")}};var Ln=h(require("path")),cr=/^pytestmark\s*=\s*.+$/m,Fa=/^import pytest\s*$/m;function Ea(t){let e=t.map(r=>`pytest.mark.${r}`).join(", ");return t.length===1?`pytestmark = pytest.mark.${t[0]}`:`pytestmark = [${e}]`}function Ta(t){let e=cr.exec(t);if(!e)return null;let r=e[0],n=[],s=/pytest\.mark\.([a-zA-Z0-9_-]+)/g,o=s.exec(r);for(;o!==null;)o[1]&&n.push(o[1]),o=s.exec(r);return n}var Ye=class{name="pytest";canHandle(e){return Ln.default.extname(e).toLowerCase()===".py"}apply(e,r,n){let s=Ta(r),o=[...n].sort();if(s!==null&&JSON.stringify([...s].sort())===JSON.stringify(o))return r;if(n.length===0)return r.replace(cr,"").replace(/\n{3,}/g,`
|
|
12
16
|
|
|
13
|
-
`);let i=
|
|
14
|
-
`,
|
|
17
|
+
`);let i=Ea(o);if(s!==null)return r.replace(cr,i);let a=Fa.test(r),c=Pa(r),p=r.slice(0,c),l=r.slice(c),g=a?"":`import pytest
|
|
18
|
+
`,u=p.endsWith(`
|
|
15
19
|
|
|
16
20
|
`)?"":`
|
|
17
|
-
`;return
|
|
18
|
-
|
|
19
|
-
`),
|
|
20
|
-
`).map(o=>o.trim()).filter(o=>o!=="")}catch{return[]}});return Array.from(new Set(
|
|
21
|
-
`)){if(
|
|
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=Ri(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 _i(r){let e=xe.default.readFileSync(r,"utf-8"),t=JSON.parse(e),s={dependencies:{}};if(t.packages)for(let[n,o]of Object.entries(t.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(t.dependencies)for(let[n,o]of Object.entries(t.dependencies))s.dependencies[n]={version:o.version,...o.dependencies!==void 0&&{dependencies:o.dependencies}};return s}function Oi(r){let e=xe.default.readFileSync(r,"utf-8");if(e.includes("__metadata:")){let t=Gi(e);if(t!==null)return t}return Li(e)}function ji(r){let e=xe.default.readFileSync(r,"utf-8"),t={dependencies:{}};try{let s=(0,tr.load)(e);if(s.packages)for(let[n,o]of Object.entries(s.packages)){let{name:i,version:a}=Di(n,o.version);i&&(t.dependencies[i]={version:a,...o.dependencies!==void 0&&{dependencies:o.dependencies}})}if(s.dependencies)for(let[n,o]of Object.entries(s.dependencies)){if(t.dependencies[n])continue;let i=typeof o=="string"?o:o.version;t.dependencies[n]={version:i||""}}}catch{}return t}function hs(r){let e=[["package-lock.json",_i],["yarn.lock",Oi],["pnpm-lock.yaml",ji]];for(let[t,s]of e){let n=gs.default.join(r,t);if(xe.default.existsSync(n))return s(n)}return null}var rr=g(require("path"));function D(r){switch(rr.default.extname(r).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 P(r){let e=rr.default.extname(r).toLowerCase();return[".css",".scss",".sass",".less",".styl"].includes(e)}var xs=g(require("coffeescript"));function G(r){return r.startsWith("'")||r.startsWith('"')?r.slice(1,-1):r}function Ss(r){if(r){if(typeof r.originalValue=="string")return r.originalValue;if(typeof r.value=="string")return G(r.value)}}function j(r){if(r){if(typeof r.value=="string")return r.value;if(typeof r.base?.value=="string")return r.base.value}}function Wi(r){let e=new Set,t=/@tag\s+([a-zA-Z0-9_-]+)/g,s=t.exec(r);for(;s!==null;)s[1]&&e.add(s[1]),s=t.exec(r);return e}function zi(r,e){let t=r.toLowerCase();return t.includes(".test.")||t.includes(".spec.")||e.has("test")?"test":"logic"}function $i(r,e){let t=Ss(e.source);return t?{fromPath:r,toPath:"",rawSpecifier:t,isStyle:P(t),type:"static"}:null}function Bi(r,e){let t=e.variable?.base?.value==="require",s=Ss(e.args?.[0]?.base);return!t||!s?null:{fromPath:r,toPath:"",rawSpecifier:s,isStyle:P(s),type:"require"}}function ys(r,e){if(e)return[{name:e}];let t=r.value;if(t?.constructor?.name==="Class"){let n=j(t.variable);return n?[{name:n}]:[]}if(t?.base?.constructor?.name==="Obj"&&Array.isArray(t.base.properties))return t.base.properties.map(n=>j(n.variable)??j(n)).filter(n=>!!n).map(n=>({name:n}));let s=j(t);return s?[{name:s}]:[]}function Ui(r){if(Array.isArray(r.specifiers))return r.specifiers.map(t=>t.identifier??t.original?.value).filter(t=>!!t).map(t=>({name:t}));let e=j(r.variable)??j(r.variable?.base);return e?[{name:e}]:[]}function Ki(r,e,t,s){let n=e.constructor?.name;if(n==="ImportDeclaration"){let o=$i(r,e);o&&t.push(o)}else if(n==="Call"){let o=Bi(r,e);o&&t.push(o)}else if(n==="Assign"){let o=j(e.variable?.base),i=e.variable?.properties?.[0]?.name?.value;o==="module"&&i==="exports"?s.push(...ys(e,void 0)):o==="exports"&&typeof i=="string"&&s.push(...ys(e,i))}else n==="ExportNamedDeclaration"&&e.clause?s.push(...Ui(e.clause)):n==="ExportDefaultDeclaration"&&s.push({name:"default"})}function sr(r,e,t,s){if(!(!e||typeof e!="object")){Ki(r,e,t,s);for(let n in e){if(n==="locationData")continue;let o=e[n];if(!(!o||typeof o!="object"))if(Array.isArray(o))for(let i of o)sr(r,i,t,s);else sr(r,o,t,s)}}}function bs(r,e){let t=Wi(e),s=zi(r,t),n=[],o=[];try{sr(r,xs.default.nodes(e),n,o)}catch{}let i=new Set,a=o.filter(c=>i.has(c.name)?!1:(i.add(c.name),!0));return{imports:n,exports:a,tags:Array.from(t).map(c=>({name:c,kind:"comment-marker"})),category:s}}var se=require("@cucumber/gherkin"),vs=require("@cucumber/messages");var Ji=vs.IdGenerator.uuid();function nr(r,e){let t=new Set;try{let s=new se.AstBuilder(Ji),n=new se.GherkinClassicTokenMatcher,i=new se.Parser(s,n).parse(e);i.feature&&(i.feature.tags.forEach(a=>{t.add(a.name.startsWith("@")?a.name.slice(1):a.name)}),i.feature.children.forEach(a=>{a.scenario&&(a.scenario.tags.forEach(c=>{t.add(c.name.startsWith("@")?c.name.slice(1):c.name)}),a.scenario.examples.forEach(c=>{c.tags.forEach(p=>{t.add(p.name.startsWith("@")?p.name.slice(1):p.name)})})),a.rule&&a.rule.children.forEach(c=>{c.scenario&&c.scenario.tags.forEach(p=>{t.add(p.name.startsWith("@")?p.name.slice(1):p.name)})})}))}catch(s){console.warn(`[GherkinParser] Failed to parse ${r}:`,s)}return{imports:[],exports:[],tags:Array.from(t).map(s=>({name:s,kind:"comment-marker"})),category:"test"}}q("gherkin",nr);var ws=g(require("path")),Es=require("@lezer/go");function W(r){let e=[],t=r.firstChild;for(;t;)e.push(t),t=t.nextSibling;return e}function Se(r,e){let t=1;for(let s=0;s<e&&s<r.length;s++)r[s]===`
|
|
23
|
-
`&&t++;return t}function Vi(r,e){let t=1;function s(n){switch(n.type.name){case"IfStatement":case"ForStatement":t++;break;case"Case":{n.firstChild?.type.name==="case"&&t++;break}case"LogicOp":{let i=e.slice(n.from,n.to);(i==="&&"||i==="||")&&t++;break}}let o=n.firstChild;for(;o;)s(o),o=o.nextSibling}return s(r),t}function Hi(r,e){let t=0;function s(n,o,i){let a=n.type.name;if(a==="IfStatement"){t+=i?1:1+o;let l=W(n),m=i?o:o+1,d=l[1];d&&d.type.name!=="Block"&&s(d,m,!1);let h=l.find(S=>S.type.name==="Block");h&&s(h,m,!1);let C=l.findIndex(S=>S.type.name==="else");if(C>=0){let S=l[C+1];S?.type.name==="IfStatement"?s(S,o,!0):S&&(t+=1,s(S,o+1,!1))}return}if(a==="ForStatement"||a==="SwitchStatement"||a==="SelectStatement"){t+=1+o;let l=n.firstChild;for(;l;)s(l,o+1,!1),l=l.nextSibling;return}if(a==="LogicOp"){let l=e.slice(n.from,n.to);(l==="&&"||l==="||")&&(t+=1)}if(o>0&&a==="FunctionLiteral"){t+=1+o;let l=n.firstChild;for(;l;)s(l,o+1,!1),l=l.nextSibling;return}let p=n.firstChild;for(;p;)s(p,o,!1),p=p.nextSibling}return s(r,0,!1),t}function Ze(r,e){return{complexity:Vi(r,e),cognitiveComplexity:Hi(r,e)}}function or(r,e){let s=r.getChild("Parameters")?.getChild("Parameter"),n=s?.getChild("TypeName")??s?.getChild("PointerType")?.getChild("TypeName");return n?e.slice(n.from,n.to):void 0}function Cs(r,e){let t=[],s=r.cursor();do if(s.name==="FunctionDecl"){let n=s.node.getChild("DefName");if(n){let o=e.slice(n.from,n.to),{complexity:i,cognitiveComplexity:a}=Ze(s.node,e);t.push({name:o,line:Se(e,s.from),complexity:i,cognitiveComplexity:a})}}else if(s.name==="MethodDecl"){let n=s.node.getChild("FieldName");if(n){let o=e.slice(n.from,n.to),i=or(s.node,e),a=i?`${i}.${o}`:o,{complexity:c,cognitiveComplexity:p}=Ze(s.node,e);t.push({name:a,line:Se(e,s.from),complexity:c,cognitiveComplexity:p})}}while(s.next());return t}var Qi=/\/\/\s*@tag\s+([a-zA-Z0-9_-]+)/,qi=/^\/\/go:build\s+(.+)$/,Xi=/^\/\/\s*\+build\s+(.+)$/;function Fs(r,e){let t=[],s=new Map,n=new Set,o=new Set,i=new Map,a=Es.parser.parse(e),c=a.cursor();do switch(c.name){case"LineComment":{let k=e.slice(c.from,c.to),A=k.match(Qi);A?.[1]&&n.add(A[1]);let K=k.match(qi);K&&ks(K[1],o);let J=k.match(Xi);J&&ks(J[1],o);break}case"ImportSpec":{let k=c.node.getChild("String");if(k){let K=e.slice(k.from,k.to).slice(1,-1);t.push({fromPath:r,toPath:"",rawSpecifier:K,isExternal:!0,isStyle:!1,type:"static"});let J=c.node.getChild("DefName"),Ae=J?e.slice(J.from,J.to):K.split("/").pop();Ae&&Ae!=="_"&&Ae!=="."&&i.set(Ae,K)}break}case"FunctionDecl":case"MethodDecl":case"TypeDecl":case"VarDecl":case"ConstDecl":{let k=c.node.getChild("DefName")??c.node.getChild("FieldName")??c.node.getChild("TypeSpec")?.getChild("DefName")??c.node.getChild("VarSpec")?.getChild("DefName")??c.node.getChild("ConstSpec")?.getChild("DefName");if(k){let A=e.slice(k.from,k.to);A!=="_"&&/^[A-Z]/.test(A)&&!s.has(A)&&s.set(A,{name:A})}break}}while(c.next());let p=t.some(k=>k.rawSpecifier==="testing"),l=ws.default.basename(r).endsWith("_test.go")||n.has("test")||p?"test":"logic",m=new Set([...n,...o]),{complexity:d,cognitiveComplexity:h}=Ze(a.topNode,e),C=Cs(a,e),S=l==="test"?[]:Yi(a,e,i);return{imports:t,exports:Array.from(s.values()),tags:Array.from(m).map(k=>({name:k,kind:"comment-marker"})),category:l,rawCallEdges:S,complexity:d,cognitiveComplexity:h,...C.length>0?{functions:C}:{}}}function Yi(r,e,t){let s=[];function n(i,a){if(i.type.name==="CallExpr"){let p=i.firstChild;if(p?.type.name==="SelectorExpr"){let l=p.firstChild,m=p.getChild("FieldName");if(l?.type.name==="VariableName"&&m){let d=e.slice(l.from,l.to),h=t.get(d);if(h){let C=e.slice(m.from,m.to);s.push({from:a,to:C,toSpecifier:h})}}}}let c=i.firstChild;for(;c;)n(c,a),c=c.nextSibling}let o=r.cursor();do if(o.name==="FunctionDecl"){let i=o.node.getChild("DefName"),a=o.node.getChild("Block");if(i&&a){let c=e.slice(i.from,i.to);/^[A-Z]/.test(c)&&n(a,c)}}else if(o.name==="MethodDecl"){let i=o.node.getChild("FieldName"),a=o.node.getChild("Block");if(i&&a){let c=e.slice(i.from,i.to),p=or(o.node,e);n(a,p?`${p}.${c}`:c)}}while(o.next());return s}function ks(r,e){for(let t of r.split(/[\s,&|!()]+/)){let s=t.trim();s&&s!=="ignore"&&e.add(s)}}var Ts=g(require("livescript"));function Zi(r){let e=new Set,t=/@tag\s+([a-zA-Z0-9_-]+)/g,s=t.exec(r);for(;s!==null;)s[1]&&e.add(s[1]),s=t.exec(r);return e}function ea(r,e){let t=r.toLowerCase();return t.includes(".test.")||t.includes(".spec.")||e.has("test")?"test":"logic"}function z(r){if(r){if(typeof r.value=="string")return r.value;if(typeof r.base?.value=="string")return r.base.value}}function ta(r){if(!r)return[];if(r.constructor?.name==="Class"){let t=z(r.title);return t?[{name:t}]:[]}if(r.constructor?.name==="Obj"&&Array.isArray(r.items))return r.items.map(t=>z(t.key)??z(t.val)).filter(t=>!!t).map(t=>({name:t}));let e=z(r);return e?[{name:e}]:[]}function ra(r){let e=r.constructor?.name||r.type;if(e==="Assign"&&r.left?.constructor?.name==="Chain"){let t=r.left,s=z(t.head),o=t.tails?.[0]?.key?.name;if(s==="module"&&o==="exports")return ta(r.right);if(s==="exports"&&typeof o=="string")return[{name:o}];if(t.head?.verb==="out"&&typeof o=="string")return[{name:o}]}if(e==="Import"&&r.left?.verb==="out"){let t=r.right;if(t?.constructor?.name==="Obj"&&Array.isArray(t.items))return t.items.map(s=>z(s.val)??z(s.key)).filter(s=>!!s).map(s=>({name:s}))}return[]}var sa=new Set(["first_line","first_column","last_line","last_column","line","column"]);function na(r,e){let t=r.constructor?.name||r.type;if(t==="Import"){let s=r.right?.value;if(typeof s=="string"){let n=G(s);return{fromPath:e,toPath:"",rawSpecifier:n,isStyle:P(n),type:"static"}}}if(t==="Chain"&&r.head?.value==="require"){let s=r.tails?.[0];if(s?.constructor?.name==="Call"||s?.type==="Call"){let n=s.args?.[0]?.value;if(typeof n=="string"){let o=G(n);return{fromPath:e,toPath:"",rawSpecifier:o,isStyle:P(o),type:"require"}}}}return null}function ir(r,e,t){if(!r||typeof r!="object")return[];let s=[],n=na(r,e);n&&s.push(n),t.push(...ra(r));for(let o in r){if(sa.has(o))continue;let i=r[o];if(!(!i||typeof i!="object"))if(Array.isArray(i))for(let a of i)s.push(...ir(a,e,t));else s.push(...ir(i,e,t))}return s}function Ps(r,e){let t=Zi(e),s=ea(r,t),n=[],o=[];try{n=ir(Ts.default.ast(e),r,o)}catch{}let i=new Set,a=o.filter(c=>i.has(c.name)?!1:(i.add(c.name),!0));return{imports:n,exports:a,tags:Array.from(t).map(c=>({name:c,kind:"comment-marker"})),category:s}}var As=g(require("luaparse"));function oa(r){let e=new Set,t=/@tag\s+([a-zA-Z0-9_-]+)/g,s=t.exec(r);for(;s!==null;)s[1]&&e.add(s[1]),s=t.exec(r);return e}function ia(r,e){let t=r.toLowerCase();return t.includes(".test.")||t.includes(".spec.")||e.has("test")?"test":"logic"}function aa(r,e){let t=[];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=G(i.raw))}else if(n.type==="StringCallExpression"){let i=n.argument;i?.type==="StringLiteral"&&(o=G(i.raw))}o&&t.push({fromPath:e,toPath:"",rawSpecifier:o,isStyle:P(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(r),t}function ca(r){let e=new Set;for(let t of r)t.type==="LocalStatement"&&t.variables.forEach((s,n)=>{t.init[n]?.type==="TableConstructorExpression"&&e.add(s.name)});return e}function pa(r){let e=r[r.length-1];if(e?.type!=="ReturnStatement")return[];let t=e.arguments[0];if(t?.type!=="TableConstructorExpression")return[];let s=[];for(let n of t.fields)n.type==="TableKeyString"&&s.push({name:n.key.name});return s}function la(r){let e=r.body,t=ca(e),s=pa(e);for(let o of e)if(o.type==="FunctionDeclaration")o.identifier?.type==="MemberExpression"?o.identifier.base.type==="Identifier"&&t.has(o.identifier.base.name)&&s.push({name:o.identifier.identifier.name}):o.identifier?.type==="Identifier"&&!o.isLocal&&s.push({name:o.identifier.name});else if(o.type==="AssignmentStatement")for(let i of o.variables)i.type==="MemberExpression"&&i.base.type==="Identifier"&&t.has(i.base.name)&&s.push({name:i.identifier.name});let n=new Set;return s.filter(o=>n.has(o.name)?!1:(n.add(o.name),!0))}function Ns(r,e){let t=oa(e),s=ia(r,t),n=[],o=[];try{let i=As.default.parse(e);n=aa(i,r),o=la(i)}catch{}return{imports:n,exports:o,tags:Array.from(t).map(i=>({name:i,kind:"comment-marker"})),category:s}}var fa=["http://","https://","mailto:","//"],ua="ts|tsx|js|jsx|mjs|cjs|py|go|lua|css|scss|less|styl|coffee|ls|feature|md|mdx|json",ma=new RegExp(`(?:\\.{1,2}/)?[\\w.-]+(?:/[\\w.-]+)*\\.(?:${ua})\\b`,"g"),Ms;async function ga(){return Ms??=(async()=>{let{unified:r}=await import("unified"),e=(await import("remark-parse")).default;return r().use(e)})(),Ms}function da(r){let e=r.trim();return e.length===0||e.startsWith("#")||fa.some(t=>e.startsWith(t))}function ha(r,e){let t=r.match(ma);return t?t.map(s=>({fromPath:e,toPath:"",rawSpecifier:s,isStyle:!1,type:"static"})):[]}function Is(r,e,t){if(r.type==="link"&&typeof r.url=="string"&&!da(r.url)&&t.push({fromPath:e,toPath:"",rawSpecifier:r.url,isStyle:!1,type:"static"}),(r.type==="code"||r.type==="inlineCode")&&typeof r.value=="string"&&t.push(...ha(r.value,e)),Array.isArray(r.children))for(let s of r.children)Is(s,e,t)}async function Rs(r,e){let s=(await ga()).parse(e),n=[];Is(s,r,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 Gs=g(require("path")),Ls=require("@lezer/python");function ya(r){let e=1;function t(s){switch(s.type.name){case"IfStatement":{e+=W(s).filter(o=>o.type.name==="if"||o.type.name==="elif").length;break}case"TryStatement":{e+=W(s).filter(o=>o.type.name==="except").length;break}case"ForStatement":case"WhileStatement":case"ConditionalExpression":e++;break;case"and":case"or":e++;break}let n=s.firstChild;for(;n;)t(n),n=n.nextSibling}return t(r),e}function xa(r){let e=0;function t(s,n){let o=s.type.name;if(o==="IfStatement"){let c=W(s),p=0,l=0;for(;l<c.length;){let m=c[l];if(m?.type.name==="if"||m?.type.name==="elif"){let d=p>0;e+=d?1:1+n;let h=d?n:n+1,C=c[l+1],S=c[l+2];C&&t(C,h),S&&t(S,h),p++,l+=3}else if(m?.type.name==="else"){e+=1;let d=c[l+1];d&&t(d,n+1),l+=2}else l++}return}if(o==="TryStatement"){let c=W(s),p=0;for(;p<c.length;){let l=c[p];if(l?.type.name==="except"){for(e+=1+n,p++;p<c.length&&c[p]?.type.name!=="Body";)t(c[p],n),p++;p<c.length&&(t(c[p],n),p++)}else l?.type.name==="Body"&&t(l,n),p++}return}if(o==="ForStatement"||o==="WhileStatement"){e+=1+n;let c=s.firstChild;for(;c;)t(c,n+1),c=c.nextSibling;return}if((o==="ConditionalExpression"||o==="and"||o==="or")&&(e+=1),n>0&&(o==="FunctionDefinition"||o==="LambdaExpression")){e+=1+n;let c=s.firstChild;for(;c;)t(c,n+1),c=c.nextSibling;return}let a=s.firstChild;for(;a;)t(a,n),a=a.nextSibling}return t(r,0),e}function ar(r){return{complexity:ya(r),cognitiveComplexity:xa(r)}}function Ds(r,e){let t=[];function s(i,a){let{complexity:c,cognitiveComplexity:p}=ar(i);t.push({name:a,line:Se(e,i.from),complexity:c,cognitiveComplexity:p})}function n(i){let a=i.firstChild;for(;a;)o(a),a=a.nextSibling}function o(i){if(i.type.name==="ClassDefinition"){let a=i.getChild("VariableName"),c=a?e.slice(a.from,a.to):void 0,p=i.getChild("Body");if(p){let l=p.firstChild;for(;l;){if(l.type.name==="FunctionDefinition"){let m=l.getChild("VariableName"),d=m?e.slice(m.from,m.to):void 0;d&&s(l,c?`${c}.${d}`:d),n(l)}else o(l);l=l.nextSibling}}return}if(i.type.name==="FunctionDefinition"){let a=i.getChild("VariableName");a&&s(i,e.slice(a.from,a.to)),n(i);return}n(i)}return o(r.topNode),t}var Sa=new Set(["pytest","unittest","nose","hypothesis"]);function _s(r,e){let t=[],s=[],n=new Set,o=Gs.default.basename(r).toLowerCase(),i=Ls.parser.parse(e),a=i.cursor();do switch(a.name){case"Comment":{let h=e.slice(a.from,a.to).match(/#\s*@tag\s+([a-zA-Z0-9_-]+)/);h?.[1]&&n.add(h[1]);break}case"ImportStatement":{for(let h of ba(a.node,e,r))t.push(h);break}case"FunctionDefinition":case"ClassDefinition":{let h=a.node.parent;if(h?.name==="Script"||h?.name==="DecoratedStatement"&&h.parent?.name==="Script"){let S=a.node.getChild("VariableName");S&&s.push({name:e.slice(S.from,S.to)})}break}case"AssignStatement":{if(a.node.parent?.name==="Script"){let h=a.node.firstChild;h?.name==="VariableName"&&s.push({name:e.slice(h.from,h.to)})}break}}while(a.next());let c=Fa(o,t,n);c==="test"&&n.add("test");let{complexity:p,cognitiveComplexity:l}=ar(i.topNode),m=Ds(i,e),d=c==="test"?[]:Ea(i,e);return{imports:t,exports:s,tags:Array.from(n).map(h=>({name:h,kind:"comment-marker"})),category:c,rawCallEdges:d,complexity:p,cognitiveComplexity:l,...m.length>0?{functions:m}:{}}}function ba(r,e,t){let s=r.firstChild;return s?s.name==="from"?va(r,e,t):Ca(r,e,t):[]}function va(r,e,t){let s=r.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=ka(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[be(t,o,i,!0)];let p=a===1?"./":"../".repeat(a-1);return c?[be(t,p+c.replace(/\./g,"/"),i,!1)]:i[0]==="*"?[be(t,p.slice(0,-1),["*"],!1)]:i.map(l=>be(t,p+l,[l],!1))}function Ca(r,e,t){let s=[],n=r.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(be(t,o,["*"],!0))}n=n.nextSibling}return s}function ka(r,e){let t=[],s=r;for(;s;)s.name==="*"?t.push("*"):s.name==="VariableName"&&(t.push(e.slice(s.from,s.to)),s.nextSibling?.name==="as"&&(s=s.nextSibling.nextSibling??s.nextSibling)),s=s.nextSibling;return t}function wa(r,e){let t=new Map,s=r.cursor();do{if(s.name!=="ImportStatement")continue;let o=s.node.firstChild;if(o?.type.name!=="from")continue;let i=o.nextSibling;for(;i&&i.type.name!=="import";)i=i.nextSibling;if(!i)continue;let a=e.slice(o.to,i.from).trim(),c=0;for(;c<a.length&&a[c]===".";)c++;let p=a.slice(c),l=c<=1?"./":"../".repeat(c-1),m=i.nextSibling;for(;m;){if(m.type.name==="VariableName"){let d=e.slice(m.from,m.to),h=d;if(m.nextSibling?.type.name==="as"){let S=m.nextSibling.nextSibling;S?.type.name==="VariableName"&&(h=e.slice(S.from,S.to),m=S)}let C=c===0?a:p?l+p.replace(/\./g,"/"):l+d;t.set(h,C)}m=m.nextSibling}}while(s.next());return t}function Ea(r,e){let t=wa(r,e),s=[];function n(a,c){if(a.type.name==="CallExpression"&&a.firstChild?.type.name==="VariableName"){let l=a.firstChild,m=e.slice(l.from,l.to),d=t.get(m);d&&s.push({from:c,to:m,toSpecifier:d})}let p=a.firstChild;for(;p;)n(p,c),p=p.nextSibling}function o(a){let c=a.firstChild;for(;c;)i(c),c=c.nextSibling}function i(a){if(a.type.name==="ClassDefinition"){let c=a.getChild("VariableName"),p=c?e.slice(c.from,c.to):void 0,l=a.getChild("Body");if(l){let m=l.firstChild;for(;m;){if(m.type.name==="FunctionDefinition"){let d=m.getChild("VariableName"),h=d?e.slice(d.from,d.to):void 0;h&&n(m,p?`${p}.${h}`:h)}else i(m);m=m.nextSibling}}return}if(a.type.name==="FunctionDefinition"){let c=a.getChild("VariableName");c&&n(a,e.slice(c.from,c.to));return}o(a)}return i(r.topNode),s}function be(r,e,t,s){return{fromPath:r,toPath:"",rawSpecifier:e,isStyle:!1,isExternal:s,type:"static",symbols:t.length>0?t:void 0}}function Fa(r,e,t){return r.startsWith("test_")||r.endsWith("_test.py")?"test":r==="conftest.py"||r==="setup.py"?"config":t.has("test")||e.some(s=>Sa.has(s.rawSpecifier))?"test":"logic"}var lr=g(require("path")),f=g(require("typescript"));var y=g(require("typescript"));function Ta(r){let e=1;function t(s){switch(s.kind){case y.default.SyntaxKind.IfStatement:case y.default.SyntaxKind.ConditionalExpression:case y.default.SyntaxKind.ForStatement:case y.default.SyntaxKind.ForInStatement:case y.default.SyntaxKind.ForOfStatement:case y.default.SyntaxKind.WhileStatement:case y.default.SyntaxKind.DoStatement:case y.default.SyntaxKind.CatchClause:case y.default.SyntaxKind.CaseClause:e++;break;case y.default.SyntaxKind.BinaryExpression:{let n=s.operatorToken.kind;(n===y.default.SyntaxKind.AmpersandAmpersandToken||n===y.default.SyntaxKind.BarBarToken||n===y.default.SyntaxKind.QuestionQuestionToken)&&e++;break}}y.default.forEachChild(s,t)}return t(r),e}function Pa(r){let e=0;function t(s,n,o){if(y.default.isIfStatement(s)){e+=o?1:1+n;let a=o?n:n+1;t(s.expression,a,!1),t(s.thenStatement,a,!1),s.elseStatement&&(y.default.isIfStatement(s.elseStatement)?t(s.elseStatement,n,!0):(e+=1,t(s.elseStatement,n+1,!1)));return}if(y.default.isForStatement(s)||y.default.isForInStatement(s)||y.default.isForOfStatement(s)||y.default.isWhileStatement(s)||y.default.isDoStatement(s)||y.default.isSwitchStatement(s)){e+=1+n,y.default.forEachChild(s,a=>t(a,n+1,!1));return}if(y.default.isCatchClause(s)){e+=1+n,y.default.forEachChild(s,a=>t(a,n,!1));return}if(y.default.isConditionalExpression(s)&&(e+=1),y.default.isBinaryExpression(s)){let a=s.operatorToken.kind;(a===y.default.SyntaxKind.AmpersandAmpersandToken||a===y.default.SyntaxKind.BarBarToken||a===y.default.SyntaxKind.QuestionQuestionToken)&&(e+=1)}if(n>0&&(y.default.isFunctionDeclaration(s)||y.default.isFunctionExpression(s)||y.default.isArrowFunction(s))){e+=1+n,y.default.forEachChild(s,a=>t(a,n+1,!1));return}y.default.forEachChild(s,a=>t(a,n,!1))}return t(r,0,!1),e}function cr(r){return{complexity:Ta(r),cognitiveComplexity:Pa(r)}}var v=g(require("typescript")),pr=new Set(["test","describe","it"]);function Os(r,e){Aa(r,e),Ma(r,e),Ia(r,e),Ra(r,e)}function Aa(r,e){if((v.default.isFunctionDeclaration(r)||v.default.isVariableDeclaration(r))&&r.name&&v.default.isIdentifier(r.name)&&Na(r)){let t;if(v.default.isFunctionDeclaration(r))t="function";else{let s=r.initializer;t=s&&(v.default.isArrowFunction(s)||v.default.isFunctionExpression(s))?"function":"variable"}e.tags.add({name:r.name.text,kind:t})}}function Na(r){if(v.default.isFunctionDeclaration(r))return v.default.isSourceFile(r.parent);let e=r.parent?.parent;return!!e&&v.default.isSourceFile(e.parent)}function Ma(r,e){if(!v.default.isStringLiteral(r))return;let t=r.text.match(/@[\w-]+/g);if(t)for(let s of t)e.tags.add({name:s.substring(1),kind:"comment-marker"})}function Ia(r,e){if(!v.default.isSourceFile(r))return;let t=/@tag\s+([a-zA-Z0-9_-]+)/g,s=r.getFullText(),n=t.exec(s);for(;n!==null;)n[1]&&e.tags.add({name:n[1],kind:"comment-marker"}),n=t.exec(s)}function Ra(r,e){if(v.default.isCallExpression(r)&&Da(r.expression))for(let t of r.arguments)v.default.isObjectLiteralExpression(t)&&Ga(t,e)}function Da(r){return v.default.isIdentifier(r)?pr.has(r.text):!!(v.default.isPropertyAccessExpression(r)&&(pr.has(r.name.text)||v.default.isIdentifier(r.expression)&&pr.has(r.expression.text)))}function Ga(r,e){for(let t of r.properties){if(!v.default.isPropertyAssignment(t)||!v.default.isIdentifier(t.name)||t.name.text!=="tags"&&t.name.text!=="tag")continue;let{initializer:s}=t,n=v.default.isArrayLiteralExpression(s)?s.elements.filter(v.default.isStringLiteral):t.name.text==="tag"&&v.default.isStringLiteral(s)?[s]:[];for(let o of n)e.tags.add({name:o.text.replace(/^@/,""),kind:"comment-marker"})}}function fr(r,e,t){let s=[],n=new Map,o=new Set,i=f.default.createSourceFile(r,e,f.default.ScriptTarget.Latest,!0,t==="typescript"?f.default.ScriptKind.TSX:f.default.ScriptKind.JSX),a={filePath:r,imports:s,exports:n,tags:o,rawCallEdges:[],sourceFile:i,hasUI:!1,hasTypesOnly:!0,totalStatements:0,exportStatements:0},c=S=>{ja(S,a),f.default.forEachChild(S,c)};c(i);let p=qa(r,a);(p==="test"||p==="barrel")&&o.add({name:p,kind:"comment-marker"}),p!=="test"&&Xa(a,i);let l=i.statements[0],m=l?Ws(l):void 0,{complexity:d,cognitiveComplexity:h}=cr(i),C=La(i);return{imports:s,exports:Array.from(n.values()),tags:Array.from(o),category:p,rawCallEdges:a.rawCallEdges??[],complexity:d,cognitiveComplexity:h,...C.length>0?{functions:C}:{},...m!==void 0?{description:m}:{}}}function La(r){let e=[],t=(n,o)=>{let{complexity:i,cognitiveComplexity:a}=cr(o),c=r.getLineAndCharacterOfPosition(o.getStart(r)).line+1;e.push({name:n,line:c,complexity:i,cognitiveComplexity:a})},s=(n,o)=>{if(f.default.isFunctionDeclaration(n)&&n.name&&n.body?t(n.name.text,n):f.default.isVariableDeclaration(n)&&f.default.isIdentifier(n.name)&&n.initializer&&(f.default.isArrowFunction(n.initializer)||f.default.isFunctionExpression(n.initializer))?t(n.name.text,n.initializer):o&&f.default.isMethodDeclaration(n)&&f.default.isIdentifier(n.name)&&n.body?t(`${o}.${n.name.text}`,n):o&&f.default.isConstructorDeclaration(n)&&n.body?t(`${o}.constructor`,n):o&&f.default.isGetAccessorDeclaration(n)&&f.default.isIdentifier(n.name)&&n.body?t(`${o}.get ${n.name.text}`,n):o&&f.default.isSetAccessorDeclaration(n)&&f.default.isIdentifier(n.name)&&n.body&&t(`${o}.set ${n.name.text}`,n),f.default.isClassDeclaration(n)&&n.name){let i=n.name.text;f.default.forEachChild(n,a=>s(a,i));return}f.default.forEachChild(n,i=>s(i,o))};return s(r,void 0),e}function js(r,e,t,s){let n={name:r},o=Ws(t);o!==void 0&&(n.doc=o);let i=_a(e);i!==void 0&&(n.flags=i);let a=Oa(e,s);return a!==void 0&&(n.signature=a),n}function Ws(r){let e=f.default.getJSDocCommentsAndTags(r);for(let t of e)if(f.default.isJSDoc(t)&&t.comment)return f.default.getTextOfJSDocComment(t.comment)||void 0}function _a(r){let e=new Set(["deprecated","internal","public","alpha","beta"]),t=f.default.getJSDocTags(r).map(s=>s.tagName.text).filter(s=>e.has(s));return t.length>0?t:void 0}function Oa(r,e){let t=f.default.createPrinter({removeComments:!0}),s=n=>t.printNode(f.default.EmitHint.Unspecified,n,e);if(f.default.isFunctionDeclaration(r)||f.default.isMethodDeclaration(r)){let n=r.parameters.map(s).join(", "),o=r.type?s(r.type):"void";return`${r.typeParameters?`<${r.typeParameters.map(a=>a.name.text).join(", ")}>`:""}(${n}) => ${o}`}if(f.default.isVariableDeclaration(r)){if(r.type)return s(r.type);if(r.initializer&&(f.default.isArrowFunction(r.initializer)||f.default.isFunctionExpression(r.initializer))){let n=r.initializer,o=n.parameters.map(s).join(", "),i=n.type?s(n.type):"unknown";return`(${o}) => ${i}`}return}if(f.default.isClassDeclaration(r)&&r.name)return`class ${r.name.text}`;if(f.default.isInterfaceDeclaration(r))return`interface ${r.name.text}`;if(f.default.isTypeAliasDeclaration(r))return s(r.type);if(f.default.isEnumDeclaration(r))return`enum ${r.name.text}`}function ja(r,e){Wa(r,e),za(r,e),Ba(r,e),Ua(r,e),Qa(r,e),Os(r,e)}function Wa(r,e){if(!f.default.isSourceFile(r))return;let t=r.statements.filter(s=>!f.default.isEmptyStatement(s));e.totalStatements=t.length,e.exportStatements=t.filter(s=>f.default.isExportDeclaration(s)||f.default.isExportAssignment(s)||ur(s)).length}function za(r,e){if(f.default.isJsxElement(r)||f.default.isJsxSelfClosingElement(r)||f.default.isJsxFragment(r)){e.hasUI=!0,e.hasTypesOnly=!1;return}if(f.default.isFunctionDeclaration(r)||f.default.isMethodDeclaration(r)||f.default.isArrowFunction(r)||f.default.isClassDeclaration(r)||f.default.isVariableStatement(r)||f.default.isEnumDeclaration(r)){e.hasTypesOnly=!1;return}f.default.isExportDeclaration(r)&&!$a(r)&&(e.hasTypesOnly=!1)}function $a(r){return r.isTypeOnly?!0:!r.exportClause||!f.default.isNamedExports(r.exportClause)?!1:r.exportClause.elements.every(e=>e.isTypeOnly)}function Ba(r,e){if(!f.default.isImportDeclaration(r)||!r.moduleSpecifier||!f.default.isStringLiteral(r.moduleSpecifier))return;let t=[];if(r.importClause&&(r.importClause.name&&t.push("default"),r.importClause.namedBindings))if(f.default.isNamedImports(r.importClause.namedBindings))for(let n of r.importClause.namedBindings.elements)t.push(n.name.text);else f.default.isNamespaceImport(r.importClause.namedBindings)&&t.push("*");let s=t.length>0?"static":"side-effect";e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:r.moduleSpecifier.text,isStyle:P(r.moduleSpecifier.text),type:s,symbols:t.length>0?t:void 0})}function Ua(r,e){f.default.isExportDeclaration(r)?Ka(r,e):f.default.isExportAssignment(r)?e.exports.set("default",{name:"default"}):ur(r)&&Ha(r,e)}function Ka(r,e){if(r.moduleSpecifier&&f.default.isStringLiteral(r.moduleSpecifier))Ja(r,r.moduleSpecifier.text,e);else if(r.exportClause&&f.default.isNamedExports(r.exportClause))for(let t of r.exportClause.elements){let s=t.name.text;e.exports.set(s,{name:s})}}function Ja(r,e,t){let s=Va(r),n={fromPath:t.filePath,toPath:"",rawSpecifier:e,isStyle:P(e),type:"re-export"};s.length>0&&(n.symbols=s),t.imports.push(n)}function Va(r){return r.exportClause?f.default.isNamedExports(r.exportClause)?r.exportClause.elements.map(e=>e.name.text):[]:["*"]}function Ha(r,e){if((f.default.isFunctionDeclaration(r)||f.default.isClassDeclaration(r)||f.default.isInterfaceDeclaration(r)||f.default.isTypeAliasDeclaration(r)||f.default.isEnumDeclaration(r))&&r.name){let s=r.name.text;e.exports.set(s,js(s,r,r,e.sourceFile));return}if(f.default.isVariableStatement(r)){for(let s of r.declarationList.declarations)if(f.default.isIdentifier(s.name)){let n=s.name.text;e.exports.set(n,js(n,s,r,e.sourceFile))}}}function Qa(r,e){if(!f.default.isCallExpression(r))return;let t=r.arguments[0];!t||!f.default.isStringLiteral(t)||(r.expression.kind===f.default.SyntaxKind.ImportKeyword?e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:t.text,isStyle:P(t.text),type:"dynamic"}):f.default.isIdentifier(r.expression)&&r.expression.text==="require"&&e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:t.text,isStyle:P(t.text),type:"require"}))}function qa(r,e){let t=lr.default.basename(r).toLowerCase(),s=lr.default.extname(r).toLowerCase();return ie().some(o=>t.includes(o))?"test":Cr(t)?"config":e.imports.some(o=>ct().some(i=>o.rawSpecifier.includes(i)))?"test":s===".tsx"||s===".jsx"||e.hasUI?"ui":e.hasTypesOnly&&e.totalStatements>0?"type-only":e.totalStatements>0&&e.exportStatements/e.totalStatements>lt()?"barrel":"logic"}function ur(r){return f.default.canHaveModifiers(r)&&f.default.getModifiers(r)?.some(e=>e.kind===f.default.SyntaxKind.ExportKeyword)===!0}function Xa(r,e){let t=r.rawCallEdges??[];r.rawCallEdges=t;let s=new Map;for(let n of e.statements){if(!f.default.isImportDeclaration(n)||!f.default.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.default.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=Za(n);if(o){let i=ec(n);i&&et(i,o,s,t);continue}f.default.isClassDeclaration(n)&&n.name&&Ya(n,s,t)}}function Ya(r,e,t){let s=r.name.text;for(let n of r.members)f.default.isMethodDeclaration(n)&&n.body&&f.default.isIdentifier(n.name)?et(n.body,`${s}.${n.name.text}`,e,t):f.default.isConstructorDeclaration(n)&&n.body&&et(n.body,`${s}.constructor`,e,t)}function Za(r){if(ur(r)){if(f.default.isFunctionDeclaration(r)&&r.name)return r.name.text;if(f.default.isVariableStatement(r)){for(let e of r.declarationList.declarations)if(f.default.isIdentifier(e.name)&&e.initializer&&(f.default.isArrowFunction(e.initializer)||f.default.isFunctionExpression(e.initializer)))return e.name.text}}}function ec(r){if(f.default.isFunctionDeclaration(r))return r.body;if(f.default.isVariableStatement(r)){for(let e of r.declarationList.declarations)if(e.initializer&&(f.default.isArrowFunction(e.initializer)||f.default.isFunctionExpression(e.initializer)))return e.initializer}}function et(r,e,t,s){if(f.default.isCallExpression(r)&&f.default.isIdentifier(r.expression)){let n=r.expression.text,o=t.get(n);o&&!s.some(i=>i.from===e&&i.to===n&&i.toSpecifier===o)&&s.push({from:e,to:n,toSpecifier:o})}f.default.forEachChild(r,n=>et(n,e,t,s))}function tt(r,e){if(e.length===0)return"ui";let t=!1;return r.walk(s=>{if(s.type==="rule")return t=!0,!1}),t?"ui":"barrel"}var mr=g(require("postcss")),tc=g(require("postcss-less")),rc=tc,$s=new Set(["reference","inline"]);function zs(r){return r.startsWith("~")||r.startsWith("http://")||r.startsWith("https://")||r.startsWith("//")||r.startsWith("data:")}function sc(r){let e=r.trim();return e.length>0&&!e.startsWith("http://")&&!e.startsWith("https://")&&!e.startsWith("//")&&!e.startsWith("data:")&&!e.startsWith("#")}function nc(r,e){let t=r.match(/^\(([^)]+)\)\s+['"]([^'"]+)['"]/);if(t){let o=t[1]?.trim()??"",i=t[2]??"";if(!i)return null;let a=$s.has(o)?"side-effect":"static";return{fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:a,...zs(i)?{isExternal:!0}:{}}}let s=r.match(/^url\(['"]?([^'")]+)['"]?\)/),n=s?s[1]?.trim()??"":r.match(/^['"]([^'"]+)['"]/)?.[1]??"";return n?{fromPath:e,toPath:"",rawSpecifier:n,isStyle:!0,type:"static",...zs(n)?{isExternal:!0}:{}}:null}function oc(r,e){let t=[],s=/url\(['"]?([^'")]+)['"]?\)/g,n=s.exec(r);for(;n!==null;){let o=n[1]?.trim()??"";sc(o)&&t.push({fromPath:e,toPath:"",rawSpecifier:o,isStyle:!0,type:"static"}),n=s.exec(r)}return t}function Bs(r,e){let t=[];return r.walk(s=>{if(s.type==="atrule"&&s.name==="import"){let n=nc(s.params,e);n&&t.push(n)}s.type==="decl"&&t.push(...oc(s.value,e))}),t}function ic(r){return r.replace(/(?<!:)\/\/.*/g,"")}function ac(r,e){let t=[],s=/@import\s+(?:\(([^)]+)\)\s+)?['"]([^'"]+)['"]/g,n=s.exec(r);for(;n!==null;){let o=n[1]?.trim()??"",i=n[2]??"";if(i){let a=$s.has(o)?"side-effect":"static";t.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:a})}n=s.exec(r)}return t}function Us(r,e){let t=mr.default.parse(ic(r));return{imports:Bs(t,e),root:t}}function cc(r){let e=[],t=[];for(let s of r.nodes??[]){if(s.type!=="atrule")continue;let{value:n}=s;if(n===void 0)continue;let o=s.name;o&&(e.push({name:o}),t.push({name:o,kind:"variable"}))}return{exports:e,tags:t}}function Ks(r,e){try{let t=rc.parse(r),{exports:s,tags:n}=cc(t);return{imports:Bs(t,e),root:t,exports:s,tags:n}}catch{return{imports:ac(r,e),root:mr.default.parse(""),exports:[],tags:[]}}}var Vs=require("postcss-scss");function Js(r){return r.startsWith("_")||r.startsWith("-")}function pc(r){return!!(r.startsWith("sass:")||r.startsWith("~")||r.startsWith("http://")||r.startsWith("https://")||r.startsWith("//")||!r.startsWith(".")&&!r.startsWith("/")&&!r.startsWith("_"))}function lc(r){let e=r.match(/^['"]([^'"]+)['"]/);if(!e?.[1])return{specifier:""};let t=e[1],n=r.match(/\bas\s+(\S+)/)?.[1];return n!==void 0?{specifier:t,alias:n}:{specifier:t}}function fc(r){let e=[],t=[];for(let s of r.nodes??[]){if(s.type==="decl"&&s.prop.startsWith("$")){let n=s.prop.slice(1);if(!n||Js(n))continue;e.push({name:n}),t.push({name:n,kind:"variable"});continue}if(s.type==="atrule"&&(s.name==="mixin"||s.name==="function")){let o=s.params.match(/^([\w-]+)/)?.[1];if(!o||Js(o))continue;let i=s.params.trim();e.push(i.includes("(")?{name:o,signature:i}:{name:o}),t.push({name:o,kind:"function"})}}return{exports:e,tags:t}}function Hs(r,e){let t=(0,Vs.parse)(r),s=[];t.walk(i=>{if(i.type!=="atrule")return;let{name:a,params:c}=i;if(a!=="import"&&a!=="use"&&a!=="forward")return;let{specifier:p,alias:l}=lc(c);if(!p)return;let m={fromPath:e,toPath:"",rawSpecifier:p,isStyle:!0,type:a==="forward"?"re-export":"static",...pc(p)?{isExternal:!0}:{}};l&&(m.symbols=[l]),s.push(m)});let{exports:n,tags:o}=fc(t);return{imports:s,root:t,exports:n,tags:o}}function Qs(r,e){let t=[],s=/@require\s+['"]([^'"]+)['"]/g,n=s.exec(r);for(;n!==null;){let i=n[1];i&&t.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:"require"}),n=s.exec(r)}let o=/(?<!@)(?:import|require)\s*\(?\s*['"]([^'"]+)['"]/g;for(n=o.exec(r);n!==null;){let i=n[1];i&&t.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:"static"}),n=o.exec(r)}return t}function qs(r,e){if(e.length===0)return"ui";try{let t=require("stylus");return new t.Parser(r).parse().nodes.some(o=>o.constructor.name!=="Import")?"ui":"barrel"}catch{return r.replace(/^\s*@?(?:require|import)\b.*/gm,"").trim().length>0?"ui":"barrel"}}function ve(r,e){let t=D(r);if(t==="stylus"){let o=Qs(e,r);return{imports:o,exports:[],tags:[],category:qs(e,o)}}if(t==="scss"){let{imports:o,root:i,exports:a,tags:c}=Hs(e,r);return{imports:o,exports:a,tags:c,category:tt(i,o)}}if(t==="less"){let{imports:o,root:i,exports:a,tags:c}=Ks(e,r);return{imports:o,exports:a,tags:c,category:tt(i,o)}}let{imports:s,root:n}=Us(e,r);return{imports:s,exports:[],tags:[],category:tt(n,s)}}for(let[r,e]of[["javascript",(t,s)=>fr(t,s,"javascript")],["typescript",(t,s)=>fr(t,s,"typescript")],["css",ve],["scss",ve],["less",ve],["stylus",ve],["coffeescript",bs],["livescript",Ps],["lua",Ns],["python",_s],["go",Fs],["gherkin",nr],["markdown",Rs]])q(r,e);async function Xs(r,e){let t=D(r),s=Xr(t);return s?s(r,e):{imports:[],exports:[],tags:[],category:"other"}}var gr=g(require("path"));function Zs(r,e){for(let t of r.values()){let s=e.get(t.path);s!==void 0&&(t.coveragePct=s)}}function en(r,e){for(let t of r)if(t.isExternal){let s=t.rawSpecifier.startsWith("@")?t.rawSpecifier.split("/").slice(0,2).join("/"):t.rawSpecifier.split("/")[0];s&&!e.some(n=>n.name===s)&&e.push({name:s,kind:"library"})}}function tn(r){for(let e of r.values())if(e.category==="test")for(let t of e.imports){if(t.isExternal||!t.toPath)continue;let s=r.get(t.toPath);s&&(s.category!=="logic"&&s.category!=="barrel"||(s.testedBy??=[],s.testedBy.includes(e.path)||s.testedBy.push(e.path)))}}function rn(r){for(let e of r.values())if(e.type==="markdown")for(let t of e.imports){if(t.isExternal||!t.toPath)continue;let s=r.get(t.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 Ys(r){return Math.round(r*1e4)/1e4}function sn(r){for(let e of r.values()){let t=[];for(let s of e.imports){if(s.isExternal||!s.toPath)continue;let n=r.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=Ys(Math.min(1,o)),t.push(s.exportUsageRatio)}t.length>0&&(e.avgExportUsage=Ys(t.reduce((s,n)=>s+n,0)/t.length),e.maxExportUsage=Math.max(...t))}}function dr(r,e,t){e&&(r.some(s=>s.name===e&&s.kind===t)||r.push({name:e,kind:t}))}function uc(r,e){let t=e.toPath,s=gr.default.basename(t,gr.default.extname(t)).replace(/\.(test|spec)$/,"");dr(r.tags,s,"import")}function mc(r,e){if(!(!e.symbols||e.symbols.includes("*")))for(let t of e.symbols)dr(r.tags,t,"import")}function gc(r,e,t){let s=t.get(e.toPath);if(!(!s||s.category==="test"))for(let n of s.tags)n.kind==="comment-marker"&&dr(r.tags,n.name,"comment-marker")}function nn(r){for(let e of r.values())if(e.category==="test")for(let t of e.imports)!t.toPath||t.isExternal||(uc(e,t),mc(e,t),gc(e,t,r))}var Te=g(require("fs")),I=g(require("path"));var hr=g(require("fs")),$=g(require("path")),Ce=class{extensions=[".go"];goModCache=new Map;resolve(e,t,s,n){let{mod:o,replaces:i}=this.readGoMod(s);if(!o)return null;let a=this.applyReplace(t,i,s);if(a!==void 0)return an(a);if(t!==o&&!t.startsWith(`${o}/`))return null;let c=t.slice(o.length).replace(/^\//,"");return c?an($.default.join(s,c)):null}readGoMod(e){let t=this.goModCache.get(e);if(t!==void 0)return t;let s={mod:null,replaces:new Map};try{let n=hr.default.readFileSync($.default.join(e,"go.mod"),"utf-8"),o=dc(n,e);return this.goModCache.set(e,o),o}catch{return this.goModCache.set(e,s),s}}applyReplace(e,t,s){for(let[n,o]of t){if(e===n)return o;if(e.startsWith(`${n}/`)){let i=e.slice(n.length+1);return $.default.join(o,i)}}}};function dc(r,e){let t=r.split(`
|
|
24
|
-
`),s=null,n=new Map,o=!1;for(let i of t){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("=>")){on(a,e,n);continue}!o&&/^replace\s+/.test(a)&&a.includes("=>")&&on(a.replace(/^replace\s+/,""),e,n)}return{mod:s,replaces:n}}function on(r,e,t){let[s,n]=r.split("=>").map(a=>a.trim());if(!s||!n)return;let o=s.split(/\s+/)[0];if(!n.startsWith(".")&&!n.startsWith("/"))return;let i=$.default.isAbsolute(n)?n:$.default.resolve(e,n);t.set(o,i)}function an(r){let e;try{e=hr.default.readdirSync(r,{withFileTypes:!0})}catch{return null}let t=e.filter(s=>s.isFile()&&s.name.endsWith(".go")&&!s.name.endsWith("_test.go")).map(s=>({path:$.default.join(r,s.name),isExternal:!1})).sort((s,n)=>s.path.localeCompare(n.path));return t.length>0?t:null}var cn=g(require("fs")),rt=g(require("path")),ke=class{extensions=[".lua"];resolve(e,t,s,n){let o=t.replace(/\./g,rt.default.sep),i=[s,rt.default.join(s,"lib")];for(let a of i){if(!cn.default.existsSync(a))continue;let c=n(rt.default.join(a,"_dummy.lua"),o);if(c)return[c]}return null}};var pn=g(require("path")),we=class{extensions=[".md",".mdx"];resolve(e,t,s,n){let o=n(pn.default.join(s,"_dummy"),`./${t}`);return o?[o]:null}};var fn=g(require("fs")),st=g(require("path")),Ee=class{extensions=[".py"];resolve(e,t,s,n){let o=t.replace(/\./g,st.default.sep),i=st.default.join(s,`${o}.py`);if(ln(i))return[{path:i,isExternal:!1}];let a=st.default.join(s,o,"__init__.py");return ln(a)?[{path:a,isExternal:!1}]:null}};function ln(r){try{return fn.default.statSync(r,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}var yr=g(require("path")),hc=["~","http://","https://","//","data:","sass:"],Fe=class{extensions=[".css",".scss",".sass",".less",".styl"];resolve(e,t,s,n){if(hc.some(l=>t.startsWith(l)))return null;let o=n(e,t);if(o)return[o];let i=yr.default.dirname(t),a=yr.default.basename(t),c=i==="."?`_${a}`:`${i}/_${a}`,p=n(e,c);return p?[p]:null}};var B=class{constructor(e,t={}){this.rootDir=e;this.workspaceMap=t.workspaceMap??new Map,this.tsconfigSearchPaths=t.tsconfigSearchPaths??[e],this.pathAliases=t.pathAliases,this.langResolvers=t.langResolvers??[new Ee,new ke,new Ce,new Fe,new we]}rootDir;workspaceMap;tsconfigSearchPaths;pathAliases;langResolvers;resolveAll(e,t){let s=this.resolvePathAlias(t);if(s)return[s];if(t.startsWith(".")||t.startsWith("/")){let i=this.resolveLocalPath(e,t);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,t,this.rootDir,n);if(a)return a}let o=this.resolveWorkspaceImport(t);return o?[o]:[{path:t,isExternal:!0}]}resolve(e,t){let s=this.resolvePathAlias(t);if(s)return s;if(t.startsWith(".")||t.startsWith("/"))return this.resolveLocalPath(e,t);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,t,this.rootDir,n);if(a)return a[0]??null}let o=this.resolveWorkspaceImport(t);return o||{path:t,isExternal:!0}}resolveLocalPath(e,t){let s=I.default.dirname(e),n=t.startsWith("/")?t:I.default.resolve(s,t),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 c=n.slice(0,-a[0].length);for(let p of[".ts",".tsx"]){let l=this.tryExtensions(c,p,o);if(l)return l}}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,t,s){let n=e+t;if(this.isFile(n))return{path:n,isExternal:s};let o=I.default.join(e,`index${t}`);if(this.isFile(o))return{path:o,isExternal:s};if(t===".py"){let i=I.default.join(e,"__init__.py");if(this.isFile(i))return{path:i,isExternal:s}}return null}isFile(e){try{return Te.default.statSync(e,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}resolvePathAlias(e){if(this.pathAliases)for(let t in this.pathAliases){let s=this.matchAliasPattern(t,e),n=this.pathAliases[t];if(s&&n){let o=this.tryAliasSubstitutions(n,s[1]||"");if(o)return o}}for(let t of this.tsconfigSearchPaths){let s=I.default.join(t,"tsconfig.json");if(Te.default.existsSync(s))try{let o=JSON.parse(Te.default.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]||"",t);if(c)return c}}}catch{}}return null}aliasRegexCache=new Map;matchAliasPattern(e,t){let s=this.aliasRegexCache.get(e);if(!s){let n=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace("\\*","(.*)");s=new RegExp(`^${n}$`),this.aliasRegexCache.set(e,s)}return t.match(s)}tryAliasSubstitutions(e,t,s=this.rootDir){let n=["",".ts",".tsx",".js",".jsx",".coffee",".ls",".lua",".feature"];for(let o of e){let i=o.replace("*",t),a=I.default.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[t,s]of this.workspaceMap){if(e!==t&&!e.startsWith(`${t}/`))continue;let n=e.slice(t.length),o={path:"",isExternal:!1,isWorkspace:!0,workspacePackage:t};if(!n){for(let a of["src/index.ts","src/index.tsx","index.ts","index.tsx","index.js"]){let c=I.default.join(s,a);try{if(Te.default.statSync(c,{throwIfNoEntry:!1})?.isFile())return{...o,path:c}}catch{}}return{...o,path:s}}let i=this.resolveLocalPath(I.default.join(s,"_dummy"),n.slice(1));return i?{...o,path:i.path}:null}return null}};var yc=["tests","test","__tests__","specs","spec"],un=new Set(["node_modules",".git","dist","build",".next",".cache","mokosh-cache","coverage"]),xc=20;function Sc(r,e){if(r.length===0)return e;let t=r.map(i=>F.default.dirname(i).split(F.default.sep)),s=t[0];for(let i of t.slice(1)){let a=0;for(;a<s.length&&a<i.length&&s[a]===i[a];)a++;s=s.slice(0,a)}let n=s.join(F.default.sep)||F.default.sep,o=F.default.relative(e,n);return o.startsWith("..")||F.default.isAbsolute(o)?e:n}var Pe=class{constructor(e,t=null,s,n,o=!1,i=new Map,a=!0){this.rootDir=e;this.enableGitStats=o;this.coverageMap=i;this.parallelParsing=a;this.previousGraph=t,this.resolver=s||new B(e),this.lockFile=hs(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 t=e.map(s=>F.default.isAbsolute(s)?s:F.default.resolve(this.rootDir,s));await this.initPool(),this.enableGitStats&&(this.gitStatsMap=ms(this.rootDir));try{for(let s of t)this.enqueue(s);return await this.drain(),await this.processTestFiles(Sc(t,this.rootDir)),await this.processDocFiles(),this.progressCallback&&this.visited.size>=100&&process.stderr.write(`
|
|
21
|
+
`;return`${p+u+g+i}
|
|
22
|
+
${l}`}};function Pa(t){let e=t.split(`
|
|
23
|
+
`),r=-1;return e.forEach((s,o)=>{(s.trimStart().startsWith("import ")||s.trimStart().startsWith("from "))&&(r=o)}),r<0?0:e.slice(0,r+1).reduce((s,o)=>s+o.length+1,0)}var pr=h(require("path")),lr=h(require("typescript"));var Aa=/\/\/ <mokosh-tags>[\s\S]*?\/\/ <\/mokosh-tags>\n*/,Xe=class{name="vitest";canHandle(e){return I.has(pr.default.extname(e).toLowerCase())}apply(e,r,n){let s=r.replace(Aa,""),o=lr.default.createSourceFile(pr.default.basename(e),s,lr.default.ScriptTarget.Latest,!0),i=Xt(o),[a]=i;if(!a)return s;let c=Zt(a,"tags",o),p=[...n].sort();if(c!==null&&JSON.stringify([...c].sort())===JSON.stringify(p))return s;let l=i.flatMap(g=>{let u=n.length===0?tr(g,"tags",o):er(g,"tags",nr(p),o);return u?[u]:[]});return l.length>0?rr(s,l):s}};var _n={vitest:()=>new Xe,playwright:()=>new qe,cypress:()=>new Je,jest:()=>new Qe},Na={"@playwright/test":"playwright",cypress:"cypress","@jest/globals":"jest",vitest:"vitest"};function Ma(t){let e=ye.default.createSourceFile("detect.ts",t,ye.default.ScriptTarget.Latest,!0);for(let r of e.statements){if(!ye.default.isImportDeclaration(r)||!ye.default.isStringLiteral(r.moduleSpecifier))continue;let n=Na[r.moduleSpecifier.text];if(n)return n}return null}var ur=class{constructor(e,r,n){this.rootDir=e;this.defaultFramework=r;this.frameworkOverrides=n}rootDir;defaultFramework;frameworkOverrides;name="auto";canHandle(e){return I.has(Ze.default.extname(e).toLowerCase())}apply(e,r,n){let s=Ma(r)??this.matchOverride(e)??this.defaultFramework;return(_n[s]??_n.vitest)().apply(e,r,n)}matchOverride(e){let r=Ze.default.relative(this.rootDir,e).split(Ze.default.sep).join("/");for(let[n,s]of this.frameworkOverrides)if(In(n,r))return s;return null}};function On(t="vitest",e={},r=process.cwd()){return[new Ve,new Ye,new He,new ur(r,t,Object.entries(e))]}function jn(t,e){return e.find(r=>r.canHandle(t))??null}var Ia=/^[a-zA-Z][a-zA-Z0-9_-]{1,}$/,Da=new Set(["import"]),Ra=new Set(["common","fixture","fixtures","helper","helpers","index","main","mock","mocks","setup","shared","spec","test","tests","types","util","utils"]);async function Ga(t,e,r,n){let s;try{s=await fr.default.readFile(t,"utf8")}catch(a){return{path:t,status:"error",error:String(a)}}let o=jn(t,n);if(!o)return{path:t,status:"unchanged"};let i=o.apply(t,s,e);return i===s?{path:t,status:"unchanged"}:(r||await fr.default.writeFile(t,i,"utf8"),{path:t,status:"updated"})}async function mr(t,e,r){let n=ie(e),s=n.tagApplier?.framework??"vitest",o=n.tagApplier?.frameworkOverrides??{},i=On(s,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,l=[];for(let d of c.tags)Da.has(d.kind)&&Ia.test(d.name)&&(Ra.has(d.name.toLowerCase())||p.has(d.name)||(p.add(d.name),l.push(d.name)));l.sort();let g=Wn.default.resolve(e,c.path),u=await Ga(g,l,r.dryRun,i);u.path=c.path,a.files.push(u),u.status==="updated"?a.updated++:u.status==="unchanged"?a.unchanged++:a.errors++}return a}var et=class{isTestNode(e){return e.category==="test"||e.tags.some(r=>r.name==="test")}};var ne=h(require("fs")),T=h(require("path")),Is=h(require("piscina"));var tt=require("child_process"),rt=class{getChangedFiles(){try{let r=[["diff","--name-only"],["diff","--cached","--name-only"],["ls-files","--others","--exclude-standard"]].flatMap(n=>{try{return(0,tt.execFileSync)("git",n,{encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).split(`
|
|
24
|
+
`).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),[]}}},zn="%x00%H%x09%ae%x09%at",$n=256*1024*1024;function Bn(t,e){let r="",n=0;for(let s of t.split(`
|
|
25
|
+
`)){if(s.startsWith("\0")){let[,c,p]=s.slice(1).split(" ");r=c??"",n=p?Number(p)*1e3:0;continue}if(s==="")continue;let o=s.split(" "),i=o[0];if(!i)continue;let a=i.startsWith("R")||i.startsWith("C")?o[2]:o[1];a&&e(a,r,n)}}function Un(t){let e=new Map;try{let r=(0,tt.execFileSync)("git",["-C",t,"log","--since=90 days ago","--name-status","-M",`--format=${zn}`],{encoding:"utf-8",stdio:["ignore","pipe","ignore"],maxBuffer:$n});Bn(r,(n,s,o)=>{let i=e.get(n);if(i){i.commitCount90d+=1;return}e.set(n,{commitCount90d:1,lastAuthor:s||void 0,lastCommitAt:o||void 0})})}catch{return e}try{let r=(0,tt.execFileSync)("git",["-C",t,"log","--name-status","-M",`--format=${zn}`],{encoding:"utf-8",stdio:["ignore","pipe","ignore"],maxBuffer:$n});Bn(r,(n,s,o)=>{e.has(n)||e.set(n,{commitCount90d:0,lastAuthor:void 0,lastCommitAt:o||void 0})})}catch{}return e}var gr=h(require("path"));function L(t){switch(gr.default.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 A(t){let e=gr.default.extname(t).toLowerCase();return[".css",".scss",".sass",".less",".styl"].includes(e)}var Jn=h(require("coffeescript"));function _(t){return t.startsWith("'")||t.startsWith('"')?t.slice(1,-1):t}function ee(t){let e=new Set,r=/@tag\s+([a-zA-Z0-9_-]+)/g,n=r.exec(t);for(;n!==null;)n[1]&&e.add(n[1]),n=r.exec(t);return e}function te(t,e){let r=t.toLowerCase();return r.includes(".test.")||r.includes(".spec.")||e.has("test")?"test":"logic"}function Vn(t){if(t){if(typeof t.originalValue=="string")return t.originalValue;if(typeof t.value=="string")return _(t.value)}}function U(t){if(t){if(typeof t.value=="string")return t.value;if(typeof t.base?.value=="string")return t.base.value}}function La(t,e){let r=Vn(e.source);return r?{fromPath:t,toPath:"",rawSpecifier:r,isStyle:A(r),type:"static"}:null}function _a(t,e){let r=e.variable?.base?.value==="require",n=Vn(e.args?.[0]?.base);return!r||!n?null:{fromPath:t,toPath:"",rawSpecifier:n,isStyle:A(n),type:"require"}}function Kn(t,e){if(e)return[{name:e}];let r=t.value;if(r?.constructor?.name==="Class"){let s=U(r.variable);return s?[{name:s}]:[]}if(r?.base?.constructor?.name==="Obj"&&Array.isArray(r.base.properties))return r.base.properties.map(s=>U(s.variable)??U(s)).filter(s=>!!s).map(s=>({name:s}));let n=U(r);return n?[{name:n}]:[]}function Oa(t){if(Array.isArray(t.specifiers))return t.specifiers.map(r=>r.identifier??r.original?.value).filter(r=>!!r).map(r=>({name:r}));let e=U(t.variable)??U(t.variable?.base);return e?[{name:e}]:[]}function ja(t,e,r,n){let s=e.constructor?.name;if(s==="ImportDeclaration"){let o=La(t,e);o&&r.push(o)}else if(s==="Call"){let o=_a(t,e);o&&r.push(o)}else if(s==="Assign"){let o=U(e.variable?.base),i=e.variable?.properties?.[0]?.name?.value;o==="module"&&i==="exports"?n.push(...Kn(e,void 0)):o==="exports"&&typeof i=="string"&&n.push(...Kn(e,i))}else s==="ExportNamedDeclaration"&&e.clause?n.push(...Oa(e.clause)):s==="ExportDefaultDeclaration"&&n.push({name:"default"})}function dr(t,e,r,n){if(!(!e||typeof e!="object")){ja(t,e,r,n);for(let s in e){if(s==="locationData")continue;let o=e[s];if(!(!o||typeof o!="object"))if(Array.isArray(o))for(let i of o)dr(t,i,r,n);else dr(t,o,r,n)}}}function Hn(t,e){let r=ee(e),n=te(t,r),s=[],o=[];try{dr(t,Jn.default.nodes(e),s,o)}catch{}let i=new Set,a=o.filter(c=>i.has(c.name)?!1:(i.add(c.name),!0));return{imports:s,exports:a,tags:Array.from(r).map(c=>({name:c,kind:"comment-marker"})),category:n}}var re=require("@cucumber/gherkin"),Qn=require("@cucumber/messages");var Wa=Qn.IdGenerator.uuid();function hr(t,e){let r=new Set;try{let n=new re.AstBuilder(Wa),s=new re.GherkinClassicTokenMatcher,i=new re.Parser(n,s).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(n){console.warn(`[GherkinParser] Failed to parse ${t}:`,n)}return{imports:[],exports:[],tags:Array.from(r).map(n=>({name:n,kind:"comment-marker"})),category:"test"}}Z("gherkin",hr);var Xn=h(require("path")),Zn=require("@lezer/go");function K(t){let e=[],r=t.firstChild;for(;r;)e.push(r),r=r.nextSibling;return e}function xe(t,e){let r=1;for(let n=0;n<e&&n<t.length;n++)t[n]===`
|
|
26
|
+
`&&r++;return r}function za(t,e){let r=1;function n(s){switch(s.type.name){case"IfStatement":case"ForStatement":r++;break;case"Case":{s.firstChild?.type.name==="case"&&r++;break}case"LogicOp":{let i=e.slice(s.from,s.to);(i==="&&"||i==="||")&&r++;break}}let o=s.firstChild;for(;o;)n(o),o=o.nextSibling}return n(t),r}function $a(t,e){let r=0;function n(s,o,i){let a=s.type.name;if(a==="IfStatement"){r+=i?1:1+o;let l=K(s),g=i?o:o+1,u=l[1];u&&u.type.name!=="Block"&&n(u,g,!1);let d=l.find(y=>y.type.name==="Block");d&&n(d,g,!1);let x=l.findIndex(y=>y.type.name==="else");if(x>=0){let y=l[x+1];y?.type.name==="IfStatement"?n(y,o,!0):y&&(r+=1,n(y,o+1,!1))}return}if(a==="ForStatement"||a==="SwitchStatement"||a==="SelectStatement"){r+=1+o;let l=s.firstChild;for(;l;)n(l,o+1,!1),l=l.nextSibling;return}if(a==="LogicOp"){let l=e.slice(s.from,s.to);(l==="&&"||l==="||")&&(r+=1)}if(o>0&&a==="FunctionLiteral"){r+=1+o;let l=s.firstChild;for(;l;)n(l,o+1,!1),l=l.nextSibling;return}let p=s.firstChild;for(;p;)n(p,o,!1),p=p.nextSibling}return n(t,0,!1),r}function nt(t,e){return{complexity:za(t,e),cognitiveComplexity:$a(t,e)}}function yr(t,e){let n=t.getChild("Parameters")?.getChild("Parameter"),s=n?.getChild("TypeName")??n?.getChild("PointerType")?.getChild("TypeName");return s?e.slice(s.from,s.to):void 0}function qn(t,e){let r=[],n=t.cursor();do if(n.name==="FunctionDecl"){let s=n.node.getChild("DefName");if(s){let o=e.slice(s.from,s.to),{complexity:i,cognitiveComplexity:a}=nt(n.node,e);r.push({name:o,line:xe(e,n.from),complexity:i,cognitiveComplexity:a})}}else if(n.name==="MethodDecl"){let s=n.node.getChild("FieldName");if(s){let o=e.slice(s.from,s.to),i=yr(n.node,e),a=i?`${i}.${o}`:o,{complexity:c,cognitiveComplexity:p}=nt(n.node,e);r.push({name:a,line:xe(e,n.from),complexity:c,cognitiveComplexity:p})}}while(n.next());return r}var Ba=/\/\/\s*@tag\s+([a-zA-Z0-9_-]+)/,Ua=/^\/\/go:build\s+(.+)$/,Ka=/^\/\/\s*\+build\s+(.+)$/;function es(t,e){let r=[],n=new Map,s=new Set,o=new Set,i=new Map,a=Zn.parser.parse(e),c=a.cursor();do switch(c.name){case"LineComment":{let S=e.slice(c.from,c.to),C=S.match(Ba);C?.[1]&&s.add(C[1]);let N=S.match(Ua);N&&Yn(N[1],o);let M=S.match(Ka);M&&Yn(M[1],o);break}case"ImportSpec":{let S=c.node.getChild("String");if(S){let N=e.slice(S.from,S.to).slice(1,-1);r.push({fromPath:t,toPath:"",rawSpecifier:N,isExternal:!0,isStyle:!1,type:"static"});let M=c.node.getChild("DefName"),O=M?e.slice(M.from,M.to):N.split("/").pop();O&&O!=="_"&&O!=="."&&i.set(O,N)}break}case"FunctionDecl":case"MethodDecl":case"TypeDecl":case"VarDecl":case"ConstDecl":{let S=c.node.getChild("DefName")??c.node.getChild("FieldName")??c.node.getChild("TypeSpec")?.getChild("DefName")??c.node.getChild("VarSpec")?.getChild("DefName")??c.node.getChild("ConstSpec")?.getChild("DefName");if(S){let C=e.slice(S.from,S.to);C!=="_"&&/^[A-Z]/.test(C)&&!n.has(C)&&n.set(C,{name:C})}break}}while(c.next());let p=r.some(S=>S.rawSpecifier==="testing"),l=Xn.default.basename(t).endsWith("_test.go")||s.has("test")||p?"test":"logic",g=new Set([...s,...o]),{complexity:u,cognitiveComplexity:d}=nt(a.topNode,e),x=qn(a,e),y=l==="test"?[]:Ja(a,e,i);return{imports:r,exports:Array.from(n.values()),tags:Array.from(g).map(S=>({name:S,kind:"comment-marker"})),category:l,rawCallEdges:y,complexity:u,cognitiveComplexity:d,...x.length>0?{functions:x}:{}}}function Ja(t,e,r){let n=[];function s(i,a){if(i.type.name==="CallExpr"){let p=i.firstChild;if(p?.type.name==="SelectorExpr"){let l=p.firstChild,g=p.getChild("FieldName");if(l?.type.name==="VariableName"&&g){let u=e.slice(l.from,l.to),d=r.get(u);if(d){let x=e.slice(g.from,g.to);n.push({from:a,to:x,toSpecifier:d})}}}}let c=i.firstChild;for(;c;)s(c,a),c=c.nextSibling}let o=t.cursor();do if(o.name==="FunctionDecl"){let i=o.node.getChild("DefName"),a=o.node.getChild("Block");if(i&&a){let c=e.slice(i.from,i.to);/^[A-Z]/.test(c)&&s(a,c)}}else if(o.name==="MethodDecl"){let i=o.node.getChild("FieldName"),a=o.node.getChild("Block");if(i&&a){let c=e.slice(i.from,i.to),p=yr(o.node,e);s(a,p?`${p}.${c}`:c)}}while(o.next());return n}function Yn(t,e){for(let r of t.split(/[\s,&|!()]+/)){let n=r.trim();n&&n!=="ignore"&&e.add(n)}}var ts=h(require("livescript"));function J(t){if(t){if(typeof t.value=="string")return t.value;if(typeof t.base?.value=="string")return t.base.value}}function Va(t){if(!t)return[];if(t.constructor?.name==="Class"){let r=J(t.title);return r?[{name:r}]:[]}if(t.constructor?.name==="Obj"&&Array.isArray(t.items))return t.items.map(r=>J(r.key)??J(r.val)).filter(r=>!!r).map(r=>({name:r}));let e=J(t);return e?[{name:e}]:[]}function Ha(t){let e=t.constructor?.name||t.type;if(e==="Assign"&&t.left?.constructor?.name==="Chain"){let r=t.left,n=J(r.head),o=r.tails?.[0]?.key?.name;if(n==="module"&&o==="exports")return Va(t.right);if(n==="exports"&&typeof o=="string")return[{name:o}];if(r.head?.verb==="out"&&typeof o=="string")return[{name:o}]}if(e==="Import"&&t.left?.verb==="out"){let r=t.right;if(r?.constructor?.name==="Obj"&&Array.isArray(r.items))return r.items.map(n=>J(n.val)??J(n.key)).filter(n=>!!n).map(n=>({name:n}))}return[]}var Qa=new Set(["first_line","first_column","last_line","last_column","line","column"]);function qa(t,e){let r=t.constructor?.name||t.type;if(r==="Import"){let n=t.right?.value;if(typeof n=="string"){let s=_(n);return{fromPath:e,toPath:"",rawSpecifier:s,isStyle:A(s),type:"static"}}}if(r==="Chain"&&t.head?.value==="require"){let n=t.tails?.[0];if(n?.constructor?.name==="Call"||n?.type==="Call"){let s=n.args?.[0]?.value;if(typeof s=="string"){let o=_(s);return{fromPath:e,toPath:"",rawSpecifier:o,isStyle:A(o),type:"require"}}}}return null}function xr(t,e,r){if(!t||typeof t!="object")return[];let n=[],s=qa(t,e);s&&n.push(s),r.push(...Ha(t));for(let o in t){if(Qa.has(o))continue;let i=t[o];if(!(!i||typeof i!="object"))if(Array.isArray(i))for(let a of i)n.push(...xr(a,e,r));else n.push(...xr(i,e,r))}return n}function rs(t,e){let r=ee(e),n=te(t,r),s=[],o=[];try{s=xr(ts.default.ast(e),t,o)}catch{}let i=new Set,a=o.filter(c=>i.has(c.name)?!1:(i.add(c.name),!0));return{imports:s,exports:a,tags:Array.from(r).map(c=>({name:c,kind:"comment-marker"})),category:n}}var ns=h(require("luaparse"));function Ya(t,e){let r=[];function n(s){if(!(!s||typeof s!="object")){if((s.type==="CallExpression"||s.type==="StringCallExpression")&&s.base?.type==="Identifier"&&s.base?.name==="require"){let o;if(s.type==="CallExpression"){let i=s.arguments?.[0];i?.type==="StringLiteral"&&(o=_(i.raw))}else if(s.type==="StringCallExpression"){let i=s.argument;i?.type==="StringLiteral"&&(o=_(i.raw))}o&&r.push({fromPath:e,toPath:"",rawSpecifier:o,isStyle:A(o),type:"require"})}for(let o in s){if(o==="loc")continue;let i=s[o];if(i&&typeof i=="object")if(Array.isArray(i))for(let a of i)n(a);else n(i)}}}return n(t),r}function Xa(t){let e=new Set;for(let r of t)r.type==="LocalStatement"&&r.variables.forEach((n,s)=>{r.init[s]?.type==="TableConstructorExpression"&&e.add(n.name)});return e}function Za(t){let e=t[t.length-1];if(e?.type!=="ReturnStatement")return[];let r=e.arguments[0];if(r?.type!=="TableConstructorExpression")return[];let n=[];for(let s of r.fields)s.type==="TableKeyString"&&n.push({name:s.key.name});return n}function ec(t){let e=t.body,r=Xa(e),n=Za(e);for(let o of e)if(o.type==="FunctionDeclaration")o.identifier?.type==="MemberExpression"?o.identifier.base.type==="Identifier"&&r.has(o.identifier.base.name)&&n.push({name:o.identifier.identifier.name}):o.identifier?.type==="Identifier"&&!o.isLocal&&n.push({name:o.identifier.name});else if(o.type==="AssignmentStatement")for(let i of o.variables)i.type==="MemberExpression"&&i.base.type==="Identifier"&&r.has(i.base.name)&&n.push({name:i.identifier.name});let s=new Set;return n.filter(o=>s.has(o.name)?!1:(s.add(o.name),!0))}function ss(t,e){let r=ee(e),n=te(t,r),s=[],o=[];try{let i=ns.default.parse(e);s=Ya(i,t),o=ec(i)}catch{}return{imports:s,exports:o,tags:Array.from(r).map(i=>({name:i,kind:"comment-marker"})),category:n}}var tc=["http://","https://","mailto:","//"],rc="ts|tsx|js|jsx|mjs|cjs|py|go|lua|css|scss|less|styl|coffee|ls|feature|md|mdx|json",nc=new RegExp(`(?:\\.{1,2}/)?[\\w.-]+(?:/[\\w.-]+)*\\.(?:${rc})\\b`,"g"),os;async function sc(){return os??=(async()=>{let{unified:t}=await import("unified"),e=(await import("remark-parse")).default;return t().use(e)})(),os}function oc(t){let e=t.trim();return e.length===0||e.startsWith("#")||tc.some(r=>e.startsWith(r))}function ic(t,e){let r=t.match(nc);return r?r.map(n=>({fromPath:e,toPath:"",rawSpecifier:n,isStyle:!1,type:"static"})):[]}function is(t,e,r){if(t.type==="link"&&typeof t.url=="string"&&!oc(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(...ic(t.value,e)),Array.isArray(t.children))for(let n of t.children)is(n,e,r)}async function as(t,e){let n=(await sc()).parse(e),s=[];is(n,t,s);let o=new Set;return{imports:s.filter(a=>o.has(a.rawSpecifier)?!1:(o.add(a.rawSpecifier),!0)),exports:[],tags:[],category:"other"}}var ps=h(require("path")),ls=require("@lezer/python");function ac(t){let e=1;function r(n){switch(n.type.name){case"IfStatement":{e+=K(n).filter(o=>o.type.name==="if"||o.type.name==="elif").length;break}case"TryStatement":{e+=K(n).filter(o=>o.type.name==="except").length;break}case"ForStatement":case"WhileStatement":case"ConditionalExpression":e++;break;case"and":case"or":e++;break}let s=n.firstChild;for(;s;)r(s),s=s.nextSibling}return r(t),e}function cc(t){let e=0;function r(n,s){let o=n.type.name;if(o==="IfStatement"){let c=K(n),p=0,l=0;for(;l<c.length;){let g=c[l];if(g?.type.name==="if"||g?.type.name==="elif"){let u=p>0;e+=u?1:1+s;let d=u?s:s+1,x=c[l+1],y=c[l+2];x&&r(x,d),y&&r(y,d),p++,l+=3}else if(g?.type.name==="else"){e+=1;let u=c[l+1];u&&r(u,s+1),l+=2}else l++}return}if(o==="TryStatement"){let c=K(n),p=0;for(;p<c.length;){let l=c[p];if(l?.type.name==="except"){for(e+=1+s,p++;p<c.length&&c[p]?.type.name!=="Body";)r(c[p],s),p++;p<c.length&&(r(c[p],s),p++)}else l?.type.name==="Body"&&r(l,s),p++}return}if(o==="ForStatement"||o==="WhileStatement"){e+=1+s;let c=n.firstChild;for(;c;)r(c,s+1),c=c.nextSibling;return}if((o==="ConditionalExpression"||o==="and"||o==="or")&&(e+=1),s>0&&(o==="FunctionDefinition"||o==="LambdaExpression")){e+=1+s;let c=n.firstChild;for(;c;)r(c,s+1),c=c.nextSibling;return}let a=n.firstChild;for(;a;)r(a,s),a=a.nextSibling}return r(t,0),e}function Sr(t){return{complexity:ac(t),cognitiveComplexity:cc(t)}}function cs(t,e){let r=[];function n(i,a){let{complexity:c,cognitiveComplexity:p}=Sr(i);r.push({name:a,line:xe(e,i.from),complexity:c,cognitiveComplexity:p})}function s(i){let a=i.firstChild;for(;a;)o(a),a=a.nextSibling}function o(i){if(i.type.name==="ClassDefinition"){let a=i.getChild("VariableName"),c=a?e.slice(a.from,a.to):void 0,p=i.getChild("Body");if(p){let l=p.firstChild;for(;l;){if(l.type.name==="FunctionDefinition"){let g=l.getChild("VariableName"),u=g?e.slice(g.from,g.to):void 0;u&&n(l,c?`${c}.${u}`:u),s(l)}else o(l);l=l.nextSibling}}return}if(i.type.name==="FunctionDefinition"){let a=i.getChild("VariableName");a&&n(i,e.slice(a.from,a.to)),s(i);return}s(i)}return o(t.topNode),r}var pc=new Set(["pytest","unittest","nose","hypothesis"]);function us(t,e){let r=[],n=[],s=new Set,o=ps.default.basename(t).toLowerCase(),i=ls.parser.parse(e),a=i.cursor();do switch(a.name){case"Comment":{let d=e.slice(a.from,a.to).match(/#\s*@tag\s+([a-zA-Z0-9_-]+)/);d?.[1]&&s.add(d[1]);break}case"ImportStatement":{for(let d of lc(a.node,e,t))r.push(d);break}case"FunctionDefinition":case"ClassDefinition":{let d=a.node.parent;if(d?.name==="Script"||d?.name==="DecoratedStatement"&&d.parent?.name==="Script"){let y=a.node.getChild("VariableName");y&&n.push({name:e.slice(y.from,y.to)})}break}case"AssignStatement":{if(a.node.parent?.name==="Script"){let d=a.node.firstChild;d?.name==="VariableName"&&n.push({name:e.slice(d.from,d.to)})}break}}while(a.next());let c=hc(o,r,s);c==="test"&&s.add("test");let{complexity:p,cognitiveComplexity:l}=Sr(i.topNode),g=cs(i,e),u=c==="test"?[]:dc(i,e);return{imports:r,exports:n,tags:Array.from(s).map(d=>({name:d,kind:"comment-marker"})),category:c,rawCallEdges:u,complexity:p,cognitiveComplexity:l,...g.length>0?{functions:g}:{}}}function lc(t,e,r){let n=t.firstChild;return n?n.name==="from"?uc(t,e,r):fc(t,e,r):[]}function uc(t,e,r){let n=t.firstChild;if(!n)return[];let s=n.nextSibling;for(;s&&s.name!=="import";)s=s.nextSibling;if(!s)return[];let o=e.slice(n.to,s.from).trim(),i=mc(s.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[Se(r,o,i,!0)];let p=a===1?"./":"../".repeat(a-1);return c?[Se(r,p+c.replace(/\./g,"/"),i,!1)]:i[0]==="*"?[Se(r,p.slice(0,-1),["*"],!1)]:i.map(l=>Se(r,p+l,[l],!1))}function fc(t,e,r){let n=[],s=t.firstChild?.nextSibling??null;for(;s;){if(s.name==="VariableName"){let o=e.slice(s.from,s.to);for(;s.nextSibling?.name==="."&&s.nextSibling.nextSibling?.name==="VariableName";)s=s.nextSibling.nextSibling,o+=`.${e.slice(s.from,s.to)}`;s.nextSibling?.name==="as"&&(s=s.nextSibling.nextSibling??s.nextSibling),n.push(Se(r,o,["*"],!0))}s=s.nextSibling}return n}function mc(t,e){let r=[],n=t;for(;n;)n.name==="*"?r.push("*"):n.name==="VariableName"&&(r.push(e.slice(n.from,n.to)),n.nextSibling?.name==="as"&&(n=n.nextSibling.nextSibling??n.nextSibling)),n=n.nextSibling;return r}function gc(t,e){let r=new Map,n=t.cursor();do{if(n.name!=="ImportStatement")continue;let o=n.node.firstChild;if(o?.type.name!=="from")continue;let i=o.nextSibling;for(;i&&i.type.name!=="import";)i=i.nextSibling;if(!i)continue;let a=e.slice(o.to,i.from).trim(),c=0;for(;c<a.length&&a[c]===".";)c++;let p=a.slice(c),l=c<=1?"./":"../".repeat(c-1),g=i.nextSibling;for(;g;){if(g.type.name==="VariableName"){let u=e.slice(g.from,g.to),d=u;if(g.nextSibling?.type.name==="as"){let y=g.nextSibling.nextSibling;y?.type.name==="VariableName"&&(d=e.slice(y.from,y.to),g=y)}let x=c===0?a:p?l+p.replace(/\./g,"/"):l+u;r.set(d,x)}g=g.nextSibling}}while(n.next());return r}function dc(t,e){let r=gc(t,e),n=[];function s(a,c){if(a.type.name==="CallExpression"&&a.firstChild?.type.name==="VariableName"){let l=a.firstChild,g=e.slice(l.from,l.to),u=r.get(g);u&&n.push({from:c,to:g,toSpecifier:u})}let p=a.firstChild;for(;p;)s(p,c),p=p.nextSibling}function o(a){let c=a.firstChild;for(;c;)i(c),c=c.nextSibling}function i(a){if(a.type.name==="ClassDefinition"){let c=a.getChild("VariableName"),p=c?e.slice(c.from,c.to):void 0,l=a.getChild("Body");if(l){let g=l.firstChild;for(;g;){if(g.type.name==="FunctionDefinition"){let u=g.getChild("VariableName"),d=u?e.slice(u.from,u.to):void 0;d&&s(g,p?`${p}.${d}`:d)}else i(g);g=g.nextSibling}}return}if(a.type.name==="FunctionDefinition"){let c=a.getChild("VariableName");c&&s(a,e.slice(c.from,c.to));return}o(a)}return i(t.topNode),n}function Se(t,e,r,n){return{fromPath:t,toPath:"",rawSpecifier:e,isStyle:!1,isExternal:n,type:"static",symbols:r.length>0?r:void 0}}function hc(t,e,r){return t.startsWith("test_")||t.endsWith("_test.py")?"test":t==="conftest.py"||t==="setup.py"?"config":r.has("test")||e.some(n=>pc.has(n.rawSpecifier))?"test":"logic"}var kr=h(require("path")),m=h(require("typescript"));var b=h(require("typescript"));function yc(t){let e=1;function r(n){switch(n.kind){case b.default.SyntaxKind.IfStatement:case b.default.SyntaxKind.ConditionalExpression:case b.default.SyntaxKind.ForStatement:case b.default.SyntaxKind.ForInStatement:case b.default.SyntaxKind.ForOfStatement:case b.default.SyntaxKind.WhileStatement:case b.default.SyntaxKind.DoStatement:case b.default.SyntaxKind.CatchClause:case b.default.SyntaxKind.CaseClause:e++;break;case b.default.SyntaxKind.BinaryExpression:{let s=n.operatorToken.kind;(s===b.default.SyntaxKind.AmpersandAmpersandToken||s===b.default.SyntaxKind.BarBarToken||s===b.default.SyntaxKind.QuestionQuestionToken)&&e++;break}}b.default.forEachChild(n,r)}return r(t),e}function xc(t){let e=0;function r(n,s,o){if(b.default.isIfStatement(n)){e+=o?1:1+s;let a=o?s:s+1;r(n.expression,a,!1),r(n.thenStatement,a,!1),n.elseStatement&&(b.default.isIfStatement(n.elseStatement)?r(n.elseStatement,s,!0):(e+=1,r(n.elseStatement,s+1,!1)));return}if(b.default.isForStatement(n)||b.default.isForInStatement(n)||b.default.isForOfStatement(n)||b.default.isWhileStatement(n)||b.default.isDoStatement(n)||b.default.isSwitchStatement(n)){e+=1+s,b.default.forEachChild(n,a=>r(a,s+1,!1));return}if(b.default.isCatchClause(n)){e+=1+s,b.default.forEachChild(n,a=>r(a,s,!1));return}if(b.default.isConditionalExpression(n)&&(e+=1),b.default.isBinaryExpression(n)){let a=n.operatorToken.kind;(a===b.default.SyntaxKind.AmpersandAmpersandToken||a===b.default.SyntaxKind.BarBarToken||a===b.default.SyntaxKind.QuestionQuestionToken)&&(e+=1)}if(s>0&&(b.default.isFunctionDeclaration(n)||b.default.isFunctionExpression(n)||b.default.isArrowFunction(n))){e+=1+s,b.default.forEachChild(n,a=>r(a,s+1,!1));return}b.default.forEachChild(n,a=>r(a,s,!1))}return r(t,0,!1),e}function br(t){return{complexity:yc(t),cognitiveComplexity:xc(t)}}var w=h(require("typescript")),vr=new Set(["test","describe","it"]);function fs(t,e){Sc(t,e),vc(t,e),kc(t,e),wc(t,e)}function Sc(t,e){if((w.default.isFunctionDeclaration(t)||w.default.isVariableDeclaration(t))&&t.name&&w.default.isIdentifier(t.name)&&bc(t)){let r;if(w.default.isFunctionDeclaration(t))r="function";else{let n=t.initializer;r=n&&(w.default.isArrowFunction(n)||w.default.isFunctionExpression(n))?"function":"variable"}e.tags.add({name:t.name.text,kind:r})}}function bc(t){if(w.default.isFunctionDeclaration(t))return w.default.isSourceFile(t.parent);let e=t.parent?.parent;return!!e&&w.default.isSourceFile(e.parent)}function vc(t,e){if(!w.default.isStringLiteral(t))return;let r=t.text.match(/@[\w-]+/g);if(r)for(let n of r)e.tags.add({name:n.substring(1),kind:"comment-marker"})}function kc(t,e){if(!w.default.isSourceFile(t))return;let r=/@tag\s+([a-zA-Z0-9_-]+)/g,n=t.getFullText(),s=r.exec(n);for(;s!==null;)s[1]&&e.tags.add({name:s[1],kind:"comment-marker"}),s=r.exec(n)}function wc(t,e){if(w.default.isCallExpression(t)&&Cc(t.expression))for(let r of t.arguments)w.default.isObjectLiteralExpression(r)&&Fc(r,e)}function Cc(t){return w.default.isIdentifier(t)?vr.has(t.text):!!(w.default.isPropertyAccessExpression(t)&&(vr.has(t.name.text)||w.default.isIdentifier(t.expression)&&vr.has(t.expression.text)))}function Fc(t,e){for(let r of t.properties){if(!w.default.isPropertyAssignment(r)||!w.default.isIdentifier(r.name)||r.name.text!=="tags"&&r.name.text!=="tag")continue;let{initializer:n}=r,s=w.default.isArrayLiteralExpression(n)?n.elements.filter(w.default.isStringLiteral):r.name.text==="tag"&&w.default.isStringLiteral(n)?[n]:[];for(let o of s)e.tags.add({name:o.text.replace(/^@/,""),kind:"comment-marker"})}}function wr(t,e,r){let n=[],s=new Map,o=new Set,i=m.default.createSourceFile(t,e,m.default.ScriptTarget.Latest,!0,r==="typescript"?m.default.ScriptKind.TSX:m.default.ScriptKind.JSX),a={filePath:t,imports:n,exports:s,tags:o,rawCallEdges:[],sourceFile:i,hasUI:!1,hasTypesOnly:!0,totalStatements:0,exportStatements:0},c=y=>{Ac(y,a),m.default.forEachChild(y,c)};c(i);let p=Wc(t,a);(p==="test"||p==="barrel")&&o.add({name:p,kind:"comment-marker"}),p!=="test"&&zc(a,i);let l=i.statements[0],g=l?gs(l):void 0,{complexity:u,cognitiveComplexity:d}=br(i),x=Ec(i);return{imports:n,exports:Array.from(s.values()),tags:Array.from(o),category:p,rawCallEdges:a.rawCallEdges??[],complexity:u,cognitiveComplexity:d,...x.length>0?{functions:x}:{},...g!==void 0?{description:g}:{}}}function Ec(t){let e=[],r=(s,o)=>{let{complexity:i,cognitiveComplexity:a}=br(o),c=t.getLineAndCharacterOfPosition(o.getStart(t)).line+1;e.push({name:s,line:c,complexity:i,cognitiveComplexity:a})},n=(s,o)=>{if(m.default.isFunctionDeclaration(s)&&s.name&&s.body?r(s.name.text,s):m.default.isVariableDeclaration(s)&&m.default.isIdentifier(s.name)&&s.initializer&&(m.default.isArrowFunction(s.initializer)||m.default.isFunctionExpression(s.initializer))?r(s.name.text,s.initializer):o&&m.default.isMethodDeclaration(s)&&m.default.isIdentifier(s.name)&&s.body?r(`${o}.${s.name.text}`,s):o&&m.default.isConstructorDeclaration(s)&&s.body?r(`${o}.constructor`,s):o&&m.default.isGetAccessorDeclaration(s)&&m.default.isIdentifier(s.name)&&s.body?r(`${o}.get ${s.name.text}`,s):o&&m.default.isSetAccessorDeclaration(s)&&m.default.isIdentifier(s.name)&&s.body&&r(`${o}.set ${s.name.text}`,s),m.default.isClassDeclaration(s)&&s.name){let i=s.name.text;m.default.forEachChild(s,a=>n(a,i));return}m.default.forEachChild(s,i=>n(i,o))};return n(t,void 0),e}function ms(t,e,r,n){let s={name:t},o=gs(r);o!==void 0&&(s.doc=o);let i=Tc(e);i!==void 0&&(s.flags=i);let a=Pc(e,n);return a!==void 0&&(s.signature=a),s}function gs(t){let e=m.default.getJSDocCommentsAndTags(t);for(let r of e)if(m.default.isJSDoc(r)&&r.comment)return m.default.getTextOfJSDocComment(r.comment)||void 0}function Tc(t){let e=new Set(["deprecated","internal","public","alpha","beta"]),r=m.default.getJSDocTags(t).map(n=>n.tagName.text).filter(n=>e.has(n));return r.length>0?r:void 0}function Pc(t,e){let r=m.default.createPrinter({removeComments:!0}),n=s=>r.printNode(m.default.EmitHint.Unspecified,s,e);if(m.default.isFunctionDeclaration(t)||m.default.isMethodDeclaration(t)){let s=t.parameters.map(n).join(", "),o=t.type?n(t.type):"void";return`${t.typeParameters?`<${t.typeParameters.map(a=>a.name.text).join(", ")}>`:""}(${s}) => ${o}`}if(m.default.isVariableDeclaration(t)){if(t.type)return n(t.type);if(t.initializer&&(m.default.isArrowFunction(t.initializer)||m.default.isFunctionExpression(t.initializer))){let s=t.initializer,o=s.parameters.map(n).join(", "),i=s.type?n(s.type):"unknown";return`(${o}) => ${i}`}return}if(m.default.isClassDeclaration(t)&&t.name)return`class ${t.name.text}`;if(m.default.isInterfaceDeclaration(t))return`interface ${t.name.text}`;if(m.default.isTypeAliasDeclaration(t))return n(t.type);if(m.default.isEnumDeclaration(t))return`enum ${t.name.text}`}function Ac(t,e){Nc(t,e),Mc(t,e),Dc(t,e),Rc(t,e),jc(t,e),fs(t,e)}function Nc(t,e){if(!m.default.isSourceFile(t))return;let r=t.statements.filter(n=>!m.default.isEmptyStatement(n));e.totalStatements=r.length,e.exportStatements=r.filter(n=>m.default.isExportDeclaration(n)||m.default.isExportAssignment(n)||Cr(n)).length}function Mc(t,e){if(m.default.isJsxElement(t)||m.default.isJsxSelfClosingElement(t)||m.default.isJsxFragment(t)){e.hasUI=!0,e.hasTypesOnly=!1;return}if(m.default.isFunctionDeclaration(t)||m.default.isMethodDeclaration(t)||m.default.isArrowFunction(t)||m.default.isClassDeclaration(t)||m.default.isVariableStatement(t)||m.default.isEnumDeclaration(t)){e.hasTypesOnly=!1;return}m.default.isExportDeclaration(t)&&!Ic(t)&&(e.hasTypesOnly=!1)}function Ic(t){return t.isTypeOnly?!0:!t.exportClause||!m.default.isNamedExports(t.exportClause)?!1:t.exportClause.elements.every(e=>e.isTypeOnly)}function Dc(t,e){if(!m.default.isImportDeclaration(t)||!t.moduleSpecifier||!m.default.isStringLiteral(t.moduleSpecifier))return;let r=[];if(t.importClause&&(t.importClause.name&&r.push("default"),t.importClause.namedBindings))if(m.default.isNamedImports(t.importClause.namedBindings))for(let s of t.importClause.namedBindings.elements)r.push(s.name.text);else m.default.isNamespaceImport(t.importClause.namedBindings)&&r.push("*");let n=r.length>0?"static":"side-effect";e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:t.moduleSpecifier.text,isStyle:A(t.moduleSpecifier.text),type:n,symbols:r.length>0?r:void 0})}function Rc(t,e){m.default.isExportDeclaration(t)?Gc(t,e):m.default.isExportAssignment(t)?e.exports.set("default",{name:"default"}):Cr(t)&&Oc(t,e)}function Gc(t,e){if(t.moduleSpecifier&&m.default.isStringLiteral(t.moduleSpecifier))Lc(t,t.moduleSpecifier.text,e);else if(t.exportClause&&m.default.isNamedExports(t.exportClause))for(let r of t.exportClause.elements){let n=r.name.text;e.exports.set(n,{name:n})}}function Lc(t,e,r){let n=_c(t),s={fromPath:r.filePath,toPath:"",rawSpecifier:e,isStyle:A(e),type:"re-export"};n.length>0&&(s.symbols=n),r.imports.push(s)}function _c(t){return t.exportClause?m.default.isNamedExports(t.exportClause)?t.exportClause.elements.map(e=>e.name.text):[]:["*"]}function Oc(t,e){if((m.default.isFunctionDeclaration(t)||m.default.isClassDeclaration(t)||m.default.isInterfaceDeclaration(t)||m.default.isTypeAliasDeclaration(t)||m.default.isEnumDeclaration(t))&&t.name){let n=t.name.text;e.exports.set(n,ms(n,t,t,e.sourceFile));return}if(m.default.isVariableStatement(t)){for(let n of t.declarationList.declarations)if(m.default.isIdentifier(n.name)){let s=n.name.text;e.exports.set(s,ms(s,n,t,e.sourceFile))}}}function jc(t,e){if(!m.default.isCallExpression(t))return;let r=t.arguments[0];!r||!m.default.isStringLiteral(r)||(t.expression.kind===m.default.SyntaxKind.ImportKeyword?e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:r.text,isStyle:A(r.text),type:"dynamic"}):m.default.isIdentifier(t.expression)&&t.expression.text==="require"&&e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:r.text,isStyle:A(r.text),type:"require"}))}function Wc(t,e){let r=kr.default.basename(t).toLowerCase(),n=kr.default.extname(t).toLowerCase();return oe().some(o=>r.includes(o))?"test":Rr(r)?"config":e.imports.some(o=>gt().some(i=>o.rawSpecifier.includes(i)))?"test":n===".tsx"||n===".jsx"||e.hasUI?"ui":e.hasTypesOnly&&e.totalStatements>0?"type-only":e.totalStatements>0&&e.exportStatements/e.totalStatements>ht()?"barrel":"logic"}function Cr(t){return m.default.canHaveModifiers(t)&&m.default.getModifiers(t)?.some(e=>e.kind===m.default.SyntaxKind.ExportKeyword)===!0}function zc(t,e){let r=t.rawCallEdges??[];t.rawCallEdges=r;let n=new Map;for(let s of e.statements){if(!m.default.isImportDeclaration(s)||!m.default.isStringLiteral(s.moduleSpecifier))continue;let o=s.moduleSpecifier.text,i=s.importClause;if(i&&(i.name&&n.set(i.name.text,o),i.namedBindings&&m.default.isNamedImports(i.namedBindings)))for(let a of i.namedBindings.elements)n.set(a.name.text,o)}if(n.size!==0)for(let s of e.statements){let o=Bc(s);if(o){let i=Uc(s);i&&st(i,o,n,r);continue}m.default.isClassDeclaration(s)&&s.name&&$c(s,s.name.text,n,r)}}function $c(t,e,r,n){for(let s of t.members)m.default.isMethodDeclaration(s)&&s.body&&m.default.isIdentifier(s.name)?st(s.body,`${e}.${s.name.text}`,r,n):m.default.isConstructorDeclaration(s)&&s.body&&st(s.body,`${e}.constructor`,r,n)}function Bc(t){if(Cr(t)){if(m.default.isFunctionDeclaration(t)&&t.name)return t.name.text;if(m.default.isVariableStatement(t)){for(let e of t.declarationList.declarations)if(m.default.isIdentifier(e.name)&&e.initializer&&(m.default.isArrowFunction(e.initializer)||m.default.isFunctionExpression(e.initializer)))return e.name.text}}}function Uc(t){if(m.default.isFunctionDeclaration(t))return t.body;if(m.default.isVariableStatement(t)){for(let e of t.declarationList.declarations)if(e.initializer&&(m.default.isArrowFunction(e.initializer)||m.default.isFunctionExpression(e.initializer)))return e.initializer}}function st(t,e,r,n){if(m.default.isCallExpression(t)&&m.default.isIdentifier(t.expression)){let s=t.expression.text,o=r.get(s);o&&!n.some(i=>i.from===e&&i.to===s&&i.toSpecifier===o)&&n.push({from:e,to:s,toSpecifier:o})}m.default.forEachChild(t,s=>st(s,e,r,n))}function ot(t,e){if(e.length===0)return"ui";let r=!1;return t.walk(n=>{if(n.type==="rule")return r=!0,!1}),r?"ui":"barrel"}function ds(t,e){let r=[],n=/@require\s+['"]([^'"]+)['"]/g,s=n.exec(t);for(;s!==null;){let i=s[1];i&&r.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:"require"}),s=n.exec(t)}let o=/(?<!@)(?:import|require)\s*\(?\s*['"]([^'"]+)['"]/g;for(s=o.exec(t);s!==null;){let i=s[1];i&&r.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:"static"}),s=o.exec(t)}return r}function hs(t,e){if(e.length===0)return"ui";try{let r=require("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"}}function be(t,e){let r=L(t);if(r==="stylus"){let o=ds(e,t);return{imports:o,exports:[],tags:[],category:hs(e,o)}}if(r==="scss"){let{imports:o,root:i,exports:a,tags:c}=_e(e,t);return{imports:o,exports:a,tags:c,category:ot(i,o)}}if(r==="less"){let{imports:o,root:i,exports:a,tags:c}=Le(e,t);return{imports:o,exports:a,tags:c,category:ot(i,o)}}let{imports:n,root:s}=Ge(e,t);return{imports:n,exports:[],tags:[],category:ot(s,n)}}for(let[t,e]of[["javascript",(r,n)=>wr(r,n,"javascript")],["typescript",(r,n)=>wr(r,n,"typescript")],["css",be],["scss",be],["less",be],["stylus",be],["coffeescript",Hn],["livescript",rs],["lua",ss],["python",us],["go",es],["gherkin",hr],["markdown",as]])Z(t,e);async function ys(t,e){let r=L(t),n=Fn(r);return n?n(t,e):{imports:[],exports:[],tags:[],category:"other"}}var Fr=h(require("path"));function Ss(t,e){for(let r of t.values()){let n=e.get(r.path);n!==void 0&&(r.coveragePct=n)}}function bs(t,e){for(let r of t)if(r.isExternal){let n=r.rawSpecifier.startsWith("@")?r.rawSpecifier.split("/").slice(0,2).join("/"):r.rawSpecifier.split("/")[0];n&&!e.some(s=>s.name===n)&&e.push({name:n,kind:"library"})}}function vs(t){for(let e of t.values())if(e.category==="test")for(let r of e.imports){if(r.isExternal||!r.toPath)continue;let n=t.get(r.toPath);n&&(n.category!=="logic"&&n.category!=="barrel"||(n.testedBy??=[],n.testedBy.includes(e.path)||n.testedBy.push(e.path)))}}function ks(t){for(let e of t.values())if(e.type==="markdown")for(let r of e.imports){if(r.isExternal||!r.toPath)continue;let n=t.get(r.toPath);!n||n===e||(n.documentedBy??=[],n.documentedBy.includes(e.path)||n.documentedBy.push(e.path),n.category==="logic"&&(n.lastCommitAt??0)>(e.lastCommitAt??0)&&(e.staleFor??=[],e.staleFor.includes(n.path)||e.staleFor.push(n.path)))}}function xs(t){return Math.round(t*1e4)/1e4}function ws(t){for(let e of t.values()){let r=[];for(let n of e.imports){if(n.isExternal||!n.toPath)continue;let s=t.get(n.toPath);if(!s||s.exports.length===0)continue;let o;if(n.symbols===void 0){if(n.type==="side-effect")continue;o=1}else n.symbols.includes("*")?o=1:o=n.symbols.length/s.exports.length;n.exportUsageRatio=xs(Math.min(1,o)),r.push(n.exportUsageRatio)}r.length>0&&(e.avgExportUsage=xs(r.reduce((n,s)=>n+s,0)/r.length),e.maxExportUsage=Math.max(...r))}}function Er(t,e,r){e&&(t.some(n=>n.name===e&&n.kind===r)||t.push({name:e,kind:r}))}function Kc(t,e){let r=e.toPath,n=Fr.default.basename(r,Fr.default.extname(r)).replace(/\.(test|spec)$/,"");Er(t.tags,n,"import")}function Jc(t,e){if(!(!e.symbols||e.symbols.includes("*")))for(let r of e.symbols)Er(t.tags,r,"import")}function Vc(t,e,r){let n=r.get(e.toPath);if(!(!n||n.category==="test"))for(let s of n.tags)s.kind==="comment-marker"&&Er(t.tags,s.name,"comment-marker")}function Cs(t){for(let e of t.values())if(e.category==="test")for(let r of e.imports)!r.toPath||r.isExternal||(Kc(e,r),Jc(e,r),Vc(e,r,t))}var Ee=h(require("fs")),R=h(require("path"));var Tr=h(require("fs")),V=h(require("path")),ve=class{extensions=[".go"];goModCache=new Map;resolve(e,r,n,s){let{mod:o,replaces:i}=this.readGoMod(n);if(!o)return null;let a=this.applyReplace(r,i,n);if(a!==void 0)return Es(a);if(r!==o&&!r.startsWith(`${o}/`))return null;let c=r.slice(o.length).replace(/^\//,"");return c?Es(V.default.join(n,c)):null}readGoMod(e){let r=this.goModCache.get(e);if(r!==void 0)return r;let n={mod:null,replaces:new Map};try{let s=Tr.default.readFileSync(V.default.join(e,"go.mod"),"utf-8"),o=Hc(s,e);return this.goModCache.set(e,o),o}catch{return this.goModCache.set(e,n),n}}applyReplace(e,r,n){for(let[s,o]of r){if(e===s)return o;if(e.startsWith(`${s}/`)){let i=e.slice(s.length+1);return V.default.join(o,i)}}}};function Hc(t,e){let r=t.split(`
|
|
27
|
+
`),n=null,s=new Map,o=!1;for(let i of r){let a=i.trim();if(a.startsWith("module ")){n=a.slice(7).trim();continue}if(/^replace\s*\(/.test(a)){o=!0;continue}if(o&&a===")"){o=!1;continue}if(o&&a.includes("=>")){Fs(a,e,s);continue}!o&&/^replace\s+/.test(a)&&a.includes("=>")&&Fs(a.replace(/^replace\s+/,""),e,s)}return{mod:n,replaces:s}}function Fs(t,e,r){let[n,s]=t.split("=>").map(a=>a.trim());if(!n||!s)return;let o=n.split(/\s+/)[0];if(!s.startsWith(".")&&!s.startsWith("/"))return;let i=V.default.isAbsolute(s)?s:V.default.resolve(e,s);r.set(o,i)}function Es(t){let e;try{e=Tr.default.readdirSync(t,{withFileTypes:!0})}catch{return null}let r=e.filter(n=>n.isFile()&&n.name.endsWith(".go")&&!n.name.endsWith("_test.go")).map(n=>({path:V.default.join(t,n.name),isExternal:!1})).sort((n,s)=>n.path.localeCompare(s.path));return r.length>0?r:null}var Ts=h(require("fs")),it=h(require("path")),ke=class{extensions=[".lua"];resolve(e,r,n,s){let o=r.replace(/\./g,it.default.sep),i=[n,it.default.join(n,"lib")];for(let a of i){if(!Ts.default.existsSync(a))continue;let c=s(it.default.join(a,"_dummy.lua"),o);if(c)return[c]}return null}};var Ps=h(require("path")),we=class{extensions=[".md",".mdx"];resolve(e,r,n,s){let o=s(Ps.default.join(n,"_dummy"),`./${r}`);return o?[o]:null}};var Ns=h(require("fs")),at=h(require("path")),Ce=class{extensions=[".py"];resolve(e,r,n,s){let o=r.replace(/\./g,at.default.sep),i=at.default.join(n,`${o}.py`);if(As(i))return[{path:i,isExternal:!1}];let a=at.default.join(n,o,"__init__.py");return As(a)?[{path:a,isExternal:!1}]:null}};function As(t){try{return Ns.default.statSync(t,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}var Pr=h(require("path")),Qc=["~","http://","https://","//","data:","sass:"],Fe=class{extensions=[".css",".scss",".sass",".less",".styl"];resolve(e,r,n,s){if(Qc.some(l=>r.startsWith(l)))return null;let o=s(e,r);if(o)return[o];let i=Pr.default.dirname(r),a=Pr.default.basename(r),c=i==="."?`_${a}`:`${i}/_${a}`,p=s(e,c);return p?[p]:null}};var H=class{constructor(e,r={}){this.rootDir=e;this.workspaceMap=r.workspaceMap??new Map,this.tsconfigSearchPaths=r.tsconfigSearchPaths??[e],this.pathAliases=r.pathAliases,this.langResolvers=r.langResolvers??[new Ce,new ke,new ve,new Fe,new we]}rootDir;workspaceMap;tsconfigSearchPaths;pathAliases;langResolvers;resolveAll(e,r){let n=this.resolvePathAlias(r);if(n)return[n];if(r.startsWith(".")||r.startsWith("/")){let i=this.resolveLocalPath(e,r);return i?[i]:[]}let s=(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,s);if(a)return a}let o=this.resolveWorkspaceImport(r);return o?[o]:[{path:r,isExternal:!0}]}resolve(e,r){let n=this.resolvePathAlias(r);if(n)return n;if(r.startsWith(".")||r.startsWith("/"))return this.resolveLocalPath(e,r);let s=(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,s);if(a)return a[0]??null}let o=this.resolveWorkspaceImport(r);return o||{path:r,isExternal:!0}}resolveLocalPath(e,r){let n=R.default.dirname(e),s=r.startsWith("/")?r:R.default.resolve(n,r),o=!s.startsWith(this.rootDir),i=["",".ts",".tsx",".js",".jsx",".mjs",".cjs",".css",".scss",".sass",".less",".styl",".coffee",".ls",".lua",".py",".feature",".md",".mdx"],a=s.match(/\.(js|mjs|cjs)$/);if(a){let c=s.slice(0,-a[0].length);for(let p of[".ts",".tsx"]){let l=this.tryExtensions(c,p,o);if(l)return l}}for(let c of i){let p=this.tryExtensions(s,c,o);if(p)return p}return o?{path:s,isExternal:!0}:null}tryExtensions(e,r,n){let s=e+r;if(this.isFile(s))return{path:s,isExternal:n};let o=R.default.join(e,`index${r}`);if(this.isFile(o))return{path:o,isExternal:n};if(r===".py"){let i=R.default.join(e,"__init__.py");if(this.isFile(i))return{path:i,isExternal:n}}return null}isFile(e){try{return Ee.default.statSync(e,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}resolvePathAlias(e){if(this.pathAliases)for(let r in this.pathAliases){let n=this.matchAliasPattern(r,e),s=this.pathAliases[r];if(n&&s){let o=this.tryAliasSubstitutions(s,n[1]||"");if(o)return o}}for(let r of this.tsconfigSearchPaths){let n=R.default.join(r,"tsconfig.json");if(Ee.default.existsSync(n))try{let o=JSON.parse(Ee.default.readFileSync(n,"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 n=this.aliasRegexCache.get(e);if(!n){let s=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace("\\*","(.*)");n=new RegExp(`^${s}$`),this.aliasRegexCache.set(e,n)}return r.match(n)}tryAliasSubstitutions(e,r,n=this.rootDir){let s=["",".ts",".tsx",".js",".jsx",".coffee",".ls",".lua",".feature"];for(let o of e){let i=o.replace("*",r),a=R.default.resolve(n,i);for(let c of s){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,n]of this.workspaceMap){if(e!==r&&!e.startsWith(`${r}/`))continue;let s=e.slice(r.length),o={path:"",isExternal:!1,isWorkspace:!0,workspacePackage:r};if(!s){for(let a of["src/index.ts","src/index.tsx","index.ts","index.tsx","index.js"]){let c=R.default.join(n,a);try{if(Ee.default.statSync(c,{throwIfNoEntry:!1})?.isFile())return{...o,path:c}}catch{}}return{...o,path:n}}let i=this.resolveLocalPath(R.default.join(n,"_dummy"),s.slice(1));return i?{...o,path:i.path}:null}return null}};var qc=["tests","test","__tests__","specs","spec"],Ms=new Set(["node_modules",".git","dist","build",".next",".cache","mokosh-cache","coverage"]),Yc=20;function Xc(t,e){if(t.length===0)return e;let r=t.map(i=>T.default.dirname(i).split(T.default.sep)),n=r[0]??[];for(let i of r.slice(1)){let a=0;for(;a<n.length&&a<i.length&&n[a]===i[a];)a++;n=n.slice(0,a)}let s=n.join(T.default.sep)||T.default.sep,o=T.default.relative(e,s);return o.startsWith("..")||T.default.isAbsolute(o)?e:s}var Te=class{constructor(e,r=null,n,s,o=!1,i=new Map,a=!0){this.rootDir=e;this.enableGitStats=o;this.coverageMap=i;this.parallelParsing=a;this.previousGraph=r,this.resolver=n||new H(e),this.lockFile=Jr(e),s&&(this.progressCallback=s)}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(n=>T.default.isAbsolute(n)?n:T.default.resolve(this.rootDir,n));await this.initPool(),this.enableGitStats&&(this.gitStatsMap=Un(this.rootDir));try{for(let n of r)this.enqueue(n);return await this.drain(),await this.processTestFiles(Xc(r,this.rootDir)),await this.processDocFiles(),this.progressCallback&&this.visited.size>=100&&process.stderr.write(`
|
|
25
28
|
Done. Total processed: ${this.visited.size} nodes.
|
|
26
|
-
`),
|
|
27
|
-
Warning: failed to start parse worker pool, falling back to synchronous parsing: ${
|
|
28
|
-
`),this.pool=null}}hasAtLeastFiles(e,
|
|
29
|
-
Warning: failed to parse ${
|
|
30
|
-
`),null}}parseContent(e,t){return this.pool?this.pool.run({filePath:e,content:t}):Xs(e,t)}makeStubNode(e,t,s){return{path:t,type:D(e),category:"other",imports:[],exports:[],tags:[],mtime:s.mtimeMs,size:s.size}}resolveCallEdges(e,t){let s=[];for(let n of t??[])try{let o=this.resolver.resolve(e,n.toSpecifier);o&&!o.isExternal&&s.push({from:n.from,to:n.to,toFile:F.default.relative(this.rootDir,o.path)})}catch{}return s}buildNode(e,t,s,n,o){let{imports:i,exports:a,tags:c,category:p,description:l,complexity:m,cognitiveComplexity:d,functions:h}=n;return{path:t,type:D(e),category:p,imports:i,exports:a,tags:c,mtime:s.mtimeMs,size:s.size,...l!==void 0?{description:l}:{},...o.length>0?{callEdges:o}:{},...m!==void 0?{complexity:m}:{},...d!==void 0?{cognitiveComplexity:d}:{},...h!==void 0?{functions:h}:{}}}attachGitStats(e,t){let s=this.gitStatsMap?.get(t);s&&(e.commitCount90d=s.commitCount90d,s.lastAuthor!==void 0&&(e.lastAuthor=s.lastAuthor),s.lastCommitAt!==void 0&&(e.lastCommitAt=s.lastCommitAt))}async resolveImports(e,t){let s=[];for(let n of t){let o=this.resolver.resolveAll(e,n.rawSpecifier);if(o.length!==0)for(let i of o){let a={...n,toPath:i.isExternal?i.path:F.default.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 t=e.rawSpecifier.startsWith("@")?e.rawSpecifier.split("/").slice(0,2).join("/"):e.rawSpecifier.split("/")[0],s=t?this.lockFile.dependencies[t]:void 0;s&&(e.version=s.version)}showProgress(){this.progressCallback&&this.visited.size%100===0&&this.progressCallback(this.visited.size)}};function gn(r,e){return{identifier:e?.identifier??new qe,featureMap:e?.featureDetection===!1?new Map:L(r.nodes,e?.featureDetection??void 0)}}function dn(r,e,t,s,n){for(let o of e){let i=r.nodes.get(o);if(!i)continue;let a=new _(o,["*",...i.exports.map(c=>c.name)]);r.traverse(o,(c,p,l)=>{if(!l)return!0;if(!a.updateAffectedSymbols(c,l))return!1;if(p>0){let m=t.get(c.path);if(m)return s(m),!1}return n(c),!0},{direction:"incoming"})}}function xr(r,e,t){let{identifier:s,featureMap:n}=gn(r,t),o=new Set;for(let i of e){let a=n.get(i);a&&o.add(a.tag)}return dn(r,e,n,i=>o.add(i.tag),i=>{if(s.isTestNode(i))for(let a of i.tags)o.add(a.name)}),Array.from(o)}function Sr(r,e,t){let{identifier:s,featureMap:n}=gn(r,t),o=new Set;return dn(r,e,n,()=>{},i=>{s.isTestNode(i)&&o.add(i.path)}),Array.from(o)}var hn=g(require("fs")),oe=g(require("path"));async function yn(r,e,t=null,s={}){let n=s.silent?void 0:a=>{process.stderr.write(`Processed ${a} files...\r`)},o=oe.default.resolve(r);return await new Pe(o,t,s.pathAliases?new B(o,{pathAliases:s.pathAliases}):void 0,n,s.gitStats??!1,s.coverageMap??new Map,s.parallelParsing??!0).build(e)}async function xn(r,e={}){let t=oe.default.resolve(r),s=ge(t),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 de(t,s.type);for(let a of n){let c=e.silent?void 0:m=>{process.stderr.write(`[${a.name}] Processed ${m} files...\r`)},l=await new Pe(t,null,new B(t,{workspaceMap:o,tsconfigSearchPaths:[a.root,t],pathAliases:e.pathAliases}),c,e.gitStats??!1,new Map,e.parallelParsing??!0).build(a.entryPoints);i.addPackage(a,l)}return i}function Sn(r,e={}){let t=[],s=new Set([...e.ignoreDirs??mt,...e.additionalIgnoreDirs??[]]),n=new Set([...e.extensions??gt,...e.additionalExtensions??[]]);function o(i){try{let a=hn.default.readdirSync(i,{withFileTypes:!0});for(let c of a){let p=oe.default.join(i,c.name);c.isDirectory()?s.has(c.name)||o(p):c.isFile()&&n.has(oe.default.extname(c.name).toLowerCase())&&t.push(oe.default.relative(r,p))}}catch{}}return o(r),t}var bn=/(?:^|[/\\])(?:node_modules|\.git|dist|build|coverage)(?:[/\\]|$)/;var nt=class{graphs=new Map;configs=new Map;workspaceGraphs=new Map;changeImpactCaches=new Map;dirtyRoots=new Set;watchers=new Map;lastAnalyze=new Map;isConfigured(e){return this.configs.has(e)}storeConfig(e,t){this.configs.set(e,t)}getConfig(e){return this.configs.get(e)}async getOrBuild(e,t,s=new Map){let n=this.configs.get(e),o=await yn(e,t,this.graphs.get(e)??null,{...V(n),coverageMap:s});return this.graphs.set(e,o),o}require(e){let t=this.graphs.get(e);if(!t)throw new Error('No graph cached for this root. Call "analyze" first.');return t}async getOrBuildWorkspace(e,t={}){let s=this.workspaceGraphs.get(e);if(s)return s;let n=await xn(e,t);return this.workspaceGraphs.set(e,n),n}requireWorkspace(e){let t=this.workspaceGraphs.get(e);if(!t)throw new Error('No workspace graph cached for this root. Call "analyze" first.');return t}hasWorkspace(e){return this.workspaceGraphs.has(e)}getOrBuildChangeImpact(e){let t=this.changeImpactCaches.get(e);if(t)return t;let s=this.require(e),n=Ct(s);return this.changeImpactCaches.set(e,n),n}storeLastAnalyze(e,t){this.lastAnalyze.set(e,t)}startWatching(e){if(!this.watchers.has(e))try{let t=vn.default.watch(e,{recursive:!0},(s,n)=>{!n||bn.test(n)||this.dirtyRoots.add(e)});t.on("error",()=>{this.watchers.delete(e)}),this.watchers.set(e,t)}catch{}}async ensureFresh(e){if(!this.dirtyRoots.has(e))return this.require(e);this.dirtyRoots.delete(e),this.changeImpactCaches.delete(e);let t=this.lastAnalyze.get(e);return t?.kind==="single"?this.getOrBuild(e,t.entryPoints,t.coverageMap):this.require(e)}async ensureFreshWorkspace(e){if(!this.dirtyRoots.has(e))return this.requireWorkspace(e);this.dirtyRoots.delete(e),this.changeImpactCaches.delete(e),this.workspaceGraphs.delete(e);let t=this.configs.get(e);return this.getOrBuildWorkspace(e,V(t))}invalidate(e){let t=this.graphs.has(e)||this.workspaceGraphs.has(e);return this.graphs.delete(e),this.workspaceGraphs.delete(e),this.changeImpactCaches.delete(e),this.dirtyRoots.delete(e),t}};var U=g(require("path"));var Cn=g(require("fs")),kn=g(require("os")),ot=g(require("path"));function x(r){return{content:[{type:"text",text:JSON.stringify(r,null,2)}]}}function wn(r){if(!ot.default.isAbsolute(r))throw new Error("root must be an absolute path");let e=ot.default.resolve(r),t=kn.default.homedir();if(e!==t&&!e.startsWith(t+ot.default.sep))throw new Error("root must be within the user home directory");let s;try{s=Cn.default.statSync(e)}catch{throw new Error("root does not exist")}if(!s.isDirectory())throw new Error("root is not a directory")}async function En(r,e){let{root:t,entryPoints:s}=e;if(!r.isConfigured(t)){let d=ae(t,{allowJs:!1});ut(d),r.storeConfig(t,d)}if(s.length===0){let d=ge(t);if(d.type!=="none"){let h=r.getConfig(t),C=await r.getOrBuildWorkspace(t,V(h));r.storeLastAnalyze(t,{kind:"workspace"}),r.startWatching(t);let S=Array.from(C.packages.values()).map(({graph:k,pkg:A})=>({package:A.name,relativeRoot:A.relativeRoot,nodeCount:k.nodes.size}));return x({monorepoType:d.type,packageCount:C.packages.size,packages:S})}}let n=s.map(d=>U.default.resolve(t,d)),o=r.getConfig(t),i=o?.coverageReportPath?ht(t,o.coverageReportPath):new Map,a=await r.getOrBuild(t,n,i);r.storeLastAnalyze(t,{kind:"single",entryPoints:n,coverageMap:i}),r.startWatching(t);let c=a.serialize(),p=c.nodes.reduce((d,h)=>(d[h.category]=(d[h.category]??0)+1,d),{}),l=a.findCycles(),m=wt(a);return x({nodeCount:c.nodes.length,categories:p,cycles:l,languageCoverage:m})}async function Fn(r,e){let{root:t,file:s,depth:n=1,withMeta:o=!1}=e,i=await r.ensureFresh(t),a=Et(i,s,n),c=o?a.map(p=>({...p,...fe(i,p.path)})):a;return x({file:s,dependencies:c})}async function Tn(r,e){let{root:t,file:s,withMeta:n=!1}=e,o=await r.ensureFresh(t),i=ue(o,s),a=n?i.map(c=>({...c,...fe(o,c.path)})):i;return x({file:s,dependents:a})}async function Pn(r,e){let{root:t,file:s,testsOnly:n=!1,cached:o=!1,changedSymbols:i,withMeta:a=!1}=e,c=await r.ensureFresh(t),p=d=>a?d.map(h=>({path:h,...fe(c,h)})):d;if(o){let d=r.getOrBuildChangeImpact(t),h=kt(d,s),C=n?h.filter(k=>c.nodes.get(k)?.category==="test"):h,S=p(C);return x({file:s,affected:S,count:S.length})}let l=Ft(c,s,{testsOnly:n,changedSymbols:i}),m=p(l);return x({file:s,affected:m,count:m.length})}async function An(r,e){let{root:t,file:s,depth:n=1,withEdgeDetail:o=!1}=e,i=await r.ensureFresh(t),a=Tt(i,s,{depth:n,withEdgeDetail:o});return x({file:s,callers:a,count:a.length})}async function Nn(r,e){let{root:t,entryPoints:s}=e,n=s.map(c=>U.default.resolve(t,c)),o=await r.getOrBuild(t,n),i=Sn(t),a=o.findUnusedFiles(i);return x({unusedFiles:a,count:a.length})}async function Mn(r,e){let{root:t,coverageThreshold:s}=e,n=await r.ensureFresh(t),o=r.getConfig(t),i=s??o?.coverageThreshold??80;if(!Mt(n))return x({error:"No coverage data available. Set coverageReportPath in mokosh.config and call analyze again."});let a=[...n.nodes.values()].filter(c=>c.category!=="test"&&c.category!=="config").filter(c=>c.coveragePct!==void 0&&c.coveragePct<i).map(c=>({file:c.path,coveragePct:c.coveragePct}));return x({threshold:i,uncovered:a,count:a.length})}async function In(r,e){let{root:t}=e,n=[...(await r.ensureFresh(t)).nodes.values()].filter(o=>o.type==="markdown"&&o.staleFor&&o.staleFor.length>0).map(o=>({doc:o.path,staleFor:o.staleFor}));return x({staleDocs:n,count:n.length})}async function Rn(r,e){let{root:t,metric:s="cognitiveComplexity",threshold:n=10,limit:o=20}=e,i=await r.ensureFresh(t),a=Pt(i,{metric:s,threshold:n,limit:o});return x({metric:s,threshold:n,functions:a,count:a.length})}async function Dn(r,e){let{root:t,changedFiles:s,featureThreshold:n,format:o="tags"}=e,i=await r.ensureFresh(t),a=s??new Ye().getChangedFiles().map(l=>U.default.relative(t,U.default.resolve(t,l))),c=n!==void 0?{featureDetection:{minOutDegree:n}}:void 0;if(o==="paths"){let l=Sr(i,a,c);return x({changedFiles:a,affectedTests:l,count:l.length})}let p=xr(i,a,c);return x({changedFiles:a,proposedTags:p})}async function Gn(r,e){let{root:t,entryPoints:s,featureThreshold:n}=e,o=s?await r.getOrBuild(t,s.map(c=>U.default.resolve(t,c))):await r.ensureFresh(t),i=L(o.nodes,n!==void 0?{minOutDegree:n}:void 0),a=Array.from(i.values()).sort((c,p)=>p.outDegree-c.outDegree);return x({features:a,count:a.length})}async function Ln(r,e){let{root:t,entryPoints:s,filter:n,mermaid:o=!1,slim:i=!0}=e,a=s?await r.getOrBuild(t,s.map(p=>U.default.resolve(t,p))):await r.ensureFresh(t),c=We(a.serialize(),ze(n));return o?x(Ge.serialize(M.deserialize(c))):i?x(At(c)):x(c)}async function _n(r,e){let{root:t}=e,s=await r.ensureFreshWorkspace(t);return x(Nt(s))}async function On(r,e){let{root:t,file:s}=e,o=(await r.ensureFreshWorkspace(t)).getAffectedAcrossPackages(s);return x({file:s,affected:o,count:o.length})}function jn(r,e){let{root:t}=e,s=r.invalidate(t);return x({root:t,cleared:s,message:s?"Cache cleared. Call analyze to rebuild.":"No cache was present for this root."})}async function Wn(r,e){let{root:t,type:s}=e,n=await r.ensureFresh(t),o=Dt(n);if(s)return x(Gt(o,s));let i=Array.from(o.types.values());return x({count:i.length,types:i})}async function zn(r,e){let{root:t,paths:s,minOutDegree:n}=e,o=await r.ensureFresh(t),i=It(o,n!==void 0?{minOutDegree:n}:void 0);if(s?.length){let c=s.map(p=>i.get(p)).filter(Boolean);return x({count:c.length,modules:c})}let a=Array.from(i.values());return x({count:a.length,modules:a})}async function $n(r,e){let{root:t,minOutDegree:s}=e,n=await r.ensureFresh(t),o=pe(n,s!==void 0?{minOutDegree:s}:void 0),i=Object.fromEntries(o.features);return x({features:i,unassigned:o.unassigned})}async function Bn(r,e){let{root:t,function:s}=e,n=await r.ensureFresh(t);return x(vt(n,s))}async function Un(r,e){let{root:t,name:s}=e,n=await r.ensureFresh(t),o=Rt(n,s);return x({name:s,matches:o,count:o.length})}async function Kn(r,e){let{root:t,entryPoints:s}=e,n=await r.ensureFresh(t),o=s?.length?s:St(n,t);if(o.length===0)throw new Error("No entry points found. Pass entryPoints explicitly or ensure package.json has a main/exports field.");return x(bt(n,o))}async function Jn(r,e){let t=await r.ensureFresh(e.root),s=await er(t,e.root,{dryRun:e.dryRun??!1});return x(s)}var Vn=[{name:"analyze",description:"Build the dependency graph for a project from entry points. Returns a summary of node count, categories, and cycles. Must be called before get_dependencies, get_dependents, get_affected, or propose_tags. Pass an empty entryPoints array to auto-detect a monorepo (pnpm/npm/yarn/Nx/Turborepo) and build per-package graphs \u2014 use get_workspace_packages and get_workspace_affected for monorepo queries.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root (or monorepo root)"},entryPoints:{type:"array",items:{type:"string"},description:"Entry point files relative to root (e.g. ['src/index.ts']). Pass [] to trigger monorepo auto-detection."}},required:["root","entryPoints"]}},{name:"get_dependencies",description:"Get files that a given file imports (outgoing traversal). depth=1 returns immediate imports; omit for the full transitive tree. Each result includes the specific symbols imported from that file (when known).",inputSchema:{type:"object",properties:{root:{type:"string"},file:{type:"string",description:"File path relative to root"},depth:{type:"number",description:"Max traversal depth (default: 1)"},withMeta:{type:"boolean",description:"Include each result's category and export names alongside the path (default: false). Set true when you need to decide what to do with a result without a follow-up lookup."}},required:["root","file"]}},{name:"get_dependents",description:"Get files that directly import a given file (one-hop incoming edges). Each result includes the specific symbols that dependent file imports from this file (when known).",inputSchema:{type:"object",properties:{root:{type:"string"},file:{type:"string",description:"File path relative to root"},withMeta:{type:"boolean",description:"Include each result's category and export names alongside the path (default: false). Set true when you need to decide what to do with a result without a follow-up lookup."}},required:["root","file"]}},{name:"get_affected",description:"Get all files transitively affected if a given file changes \u2014 full incoming traversal upward. Use before a refactor to understand blast radius. Set testsOnly=true to get only test files. Set cached=true to use a pre-computed O(1) lookup cache instead of graph traversal \u2014 faster on repeated calls for the same root. Pass changedSymbols to restrict blast-radius to files that actually import those symbols \u2014 omit to treat the whole file as changed. Set withMeta=true to get { path, category, exports } objects instead of bare path strings.",inputSchema:{type:"object",properties:{root:{type:"string"},file:{type:"string",description:"File path relative to root"},testsOnly:{type:"boolean",description:"Return only test/spec files (default: false)"},cached:{type:"boolean",description:"Use a pre-computed impact cache for O(1) lookup instead of graph traversal. Cache is built lazily on first use and reused for the session (default: false)."},changedSymbols:{type:"array",items:{type:"string"},description:"Restrict blast-radius to files that import at least one of these symbols. Omit to treat the whole file as changed (conservative, same as before)."},withMeta:{type:"boolean",description:"Return each affected file as { path, category, exports } instead of a bare path string (default: false). Set true when you need to decide what to do with a result without a follow-up lookup."}},required:["root","file"]}},{name:"get_callers",description:"Get files whose exported functions call into a given file (call-graph dependents). More precise than get_affected: only files with actual runtime call edges, not mere imports. Requires prior analyze() call.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to project root"},file:{type:"string",description:"File path relative to root"},depth:{type:"number",description:"Max traversal depth (default: 1)"},withEdgeDetail:{type:"boolean",description:"Include from/to function names per edge (default: false)"}},required:["root","file"]}},{name:"find_unused",description:"Find files in the project that are not reachable from any entry point. Useful before cleanup passes.",inputSchema:{type:"object",properties:{root:{type:"string"},entryPoints:{type:"array",items:{type:"string"}}},required:["root","entryPoints"]}},{name:"find_uncovered",description:"Find non-test files whose line coverage is below the configured threshold. Requires a prior analyze() call and coverageReportPath set in mokosh.config. coverageThreshold overrides the config default (default: 80).",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},coverageThreshold:{type:"number",description:"Line-coverage % below which a file is considered uncovered. Overrides config value."}},required:["root"]}},{name:"check_doc_drift",description:"Find markdown docs whose referenced files changed more recently than the doc itself \u2014 a commit-recency heuristic for stale documentation, not a content diff. Requires a prior analyze() call with gitStats: true in mokosh.config (otherwise no file has commit-timestamp data and nothing is flagged). See docs/adr-009-markdown-parsing.md for known limitations.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"}},required:["root"]}},{name:"find_complex_functions",description:"Find individual functions/methods above a cognitive (or cyclomatic) complexity threshold, sorted worst-first. Requires a prior analyze() call. Populated for TypeScript/JavaScript, Go, and Python.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},metric:{type:"string",enum:["cognitiveComplexity","complexity"],description:"Which score to threshold/sort on (default: cognitiveComplexity)"},threshold:{type:"number",description:"Minimum score to include (default: 10)"},limit:{type:"number",description:"Max results to return, worst-first (default: 20)"}},required:["root"]}},{name:"propose_tags",description:"Propose what to run based on changed files. Pass changedFiles explicitly or omit to use git diff. format='tags' (default) returns test tags for CI tag-filtering; format='paths' returns test file paths ready to pipe directly to a test runner (e.g. vitest). Feature hubs act as traversal boundaries in both modes.",inputSchema:{type:"object",properties:{root:{type:"string"},changedFiles:{type:"array",items:{type:"string"},description:"Changed files relative to root. Omit to read from git diff."},featureThreshold:{type:"number",description:"Min importers for a file to be treated as a feature hub (default: 5). A hub short-circuits traversal and emits a feature:<name> tag instead of all downstream tags."},format:{type:"string",enum:["tags","paths"],description:"Output format: 'tags' returns test tag names for CI filtering (default); 'paths' returns test file paths to pipe to a test runner."}},required:["root"]}},{name:"detect_features",description:"Identify feature hub files \u2014 non-test files that import many other internal modules (orchestrators / aggregators like src/parser.ts or src/cli/runner.ts). Returns a list sorted by import count descending.",inputSchema:{type:"object",properties:{root:{type:"string"},entryPoints:{type:"array",items:{type:"string"},description:"Entry point files relative to root. Omit to use the cached graph."},featureThreshold:{type:"number",description:"Min internal imports a file must have to qualify as a feature hub (default: 5)."}},required:["root"]}},{name:"query",description:"Filter the graph by category, tag, or path. Returns matching nodes as JSON or a Mermaid diagram. If entryPoints is omitted the cached graph from a prior 'analyze' call is used.",inputSchema:{type:"object",properties:{root:{type:"string"},entryPoints:{type:"array",items:{type:"string"},description:"Entry points to build the graph. Omit to reuse the cached graph from a prior 'analyze' call."},filter:{type:"string",description:"Query string e.g. 'category:logic' or 'category:logic,tag:auth'. Supports: category, type, tag, path, external, importsFile, importedBy, minImports, maxImports, minSize, maxSize, hasDocstring, minCoverage, maxCoverage, minExportUsage, maxExportUsage, minComplexity, maxComplexity, minCognitiveComplexity, maxCognitiveComplexity, minCommits, maxCommits, isDocumented, isStale, lastAuthor. OR logic: any(key:val|key:val) matches if any single-key clause holds, ANDed with the rest of the query. sort: size|imports|commitCount90d|exportUsage|complexity|cognitiveComplexity, with sortDir: asc|desc (default desc). limit: N."},mermaid:{type:"boolean",description:"Return a Mermaid diagram (default: false)"},slim:{type:"boolean",description:"Compact response mode (default: true). Returns export names, meaningful tags, and a flat importsFiles path list \u2014 no edge objects, no mtime/size. Pass false only when full edge metadata is needed."}},required:["root","filter"]}},{name:"get_workspace_packages",description:"List all workspace packages detected in a monorepo, with their node counts and inter-package dependencies. Requires a prior analyze() call with empty entryPoints on a monorepo root.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the monorepo root"}},required:["root"]}},{name:"get_workspace_affected",description:"Cross-package blast-radius analysis. Returns every file that could be affected if a given file changes, annotated with the package it belongs to. Requires a prior analyze() call with empty entryPoints on a monorepo root.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the monorepo root"},file:{type:"string",description:"Monorepo-root-relative path of the changed file (e.g. 'packages/shared/src/utils.ts')"}},required:["root","file"]}},{name:"get_type_graph",description:"Return type-level relationships for the project. Without a type name, returns an inventory of all interfaces, classes, enums, and type aliases with their file and kind. With a type name, returns which files import that type (usedByFiles) and which types the defining file imports (uses). Requires a prior analyze() call. Only covers TypeScript/JavaScript files.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},type:{type:"string",description:"Exact exported name of the type to look up (e.g. 'FileNode'). Omit to get the full type inventory."}},required:["root"]}},{name:"get_module_responsibility",description:"Return what each file is responsible for: its semantic role, JSDoc description (when present), exported symbol names, and which feature hub it belongs to. Pass specific paths to filter, or omit paths to get all files. Requires a prior analyze() call.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},paths:{type:"array",items:{type:"string"},description:"Project-relative file paths to include. Omit to return all files."},minOutDegree:{type:"number",description:"Min imports for a file to qualify as a feature hub (default: 5)."}},required:["root"]}},{name:"get_feature_graph",description:"Group files by domain: returns which files each feature hub (high-import orchestrator) transitively owns. Each file is assigned to the most specific hub that can reach it (lowest out-degree wins). Use this instead of a full query when answering 'what files are in the X feature/module?' \u2014 typically 85\u201395% fewer tokens than a full graph query.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},minOutDegree:{type:"number",description:"Minimum internal imports a file must have to qualify as a feature hub (default: 5)."}},required:["root"]}},{name:"get_call_graph",description:"Look up callers and callees for a named function. Returns the file that defines the function, all files/functions that call it, and all files/functions it calls. Always requires a function name \u2014 never returns the full call graph unfiltered. Call edges are only populated for TypeScript/JavaScript files.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},function:{type:"string",description:"Exact name of the function to look up (e.g. 'parseFile')."}},required:["root","function"]}},{name:"find_symbol",description:"Find every file that exports a symbol by exact name, with the best available usage info per match. Precision varies by the defining file's language: TypeScript/JavaScript, Go, and Python get function-level callers (via call edges) \u2014 though coverage differs per language (Go only tracks package-qualified calls, Python only tracks bare calls to `from module import name` symbols); everything else (CoffeeScript, LiveScript, Lua, Gherkin, Markdown, CSS/SCSS/Stylus) falls back to whole-file dependents, which is import-level only \u2014 a listed importer might not even use this specific export. Files whose parser never records exports (CoffeeScript, LiveScript, Lua, Gherkin, Markdown, CSS/SCSS/Stylus) never appear as matches, so a name that only exists in one of those returns an empty result, same as a typo. Each match's `precision` field is 'call' | 'file-level' \u2014 check it before trusting caller/importer results as symbol-exact.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},name:{type:"string",description:"Exact export name to look up (e.g. 'parseFile')."}},required:["root","name"]}},{name:"get_api_surface",description:"Build the API surface report for a project. Expands export* chains so every symbol accessible to consumers is listed (not just those directly declared in the entry file). Each export is resolved to its defining file and tagged with a kind (function/class/interface/type/enum/const). The graph is partitioned into: internalFiles (implementation reachable from entry points), unreachableFromEntry (non-test files not reachable from any entry point \u2014 may be separate consumers like CLI/MCP, config, or dead code), and testFiles (test suite). Supports multiple public entry points for libraries with sub-path exports. Requires a prior analyze() call. When entryPoints is omitted, auto-detects all entry points from package.json exports/main/module.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},entryPoints:{type:"array",items:{type:"string"},description:"Project-relative paths of public entry points (e.g. ['src/index.ts', 'src/utils.ts']). Omit to auto-detect from package.json exports / main / module fields."}},required:["root"]}},{name:"clear_cache",description:"Drop the cached dependency graph for a project root, forcing the next analyze() call to rebuild from disk. Call this after editing source files mid-session \u2014 otherwise get_affected, get_dependencies, and other query tools will reason from stale data.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root to invalidate."}},required:["root"]}},{name:"apply_tags",description:"Write @tag annotations into test file source code based on the dependency graph. Tags of kind 'import' (filename-derived) and 'comment-marker' (domain semantic, propagated from source files) are written as an idempotent block. Re-running is safe: the existing block is replaced in place. Tags already present in the file are excluded from the block to avoid duplication. Supports TypeScript/JavaScript (// <mokosh-tags> block with // @tag lines) and Gherkin .feature files (# <mokosh-tags> block with @tagname lines). Use dryRun=true to preview changes without writing to disk. Requires a prior analyze() call.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root."},dryRun:{type:"boolean",description:"When true, computes which files would change but does not write to disk (default: false)."}},required:["root"]}}];function at(){let r=new nt,e=new Hn.Server({name:"mokosh",version:"0.0.1"},{capabilities:{tools:{}}});return e.setRequestHandler(it.ListToolsRequestSchema,async()=>({tools:Vn})),e.setRequestHandler(it.CallToolRequestSchema,async t=>{let{name:s,arguments:n}=t.params,o=n,a={analyze:c=>En(r,c),get_dependencies:c=>Fn(r,c),get_dependents:c=>Tn(r,c),get_affected:c=>Pn(r,c),get_callers:c=>An(r,c),find_symbol:c=>Un(r,c),find_unused:c=>Nn(r,c),find_uncovered:c=>Mn(r,c),check_doc_drift:c=>In(r,c),find_complex_functions:c=>Rn(r,c),propose_tags:c=>Dn(r,c),detect_features:c=>Gn(r,c),get_type_graph:c=>Wn(r,c),get_module_responsibility:c=>zn(r,c),get_feature_graph:c=>$n(r,c),get_call_graph:c=>Bn(r,c),get_api_surface:c=>Kn(r,c),query:c=>Ln(r,c),get_workspace_packages:c=>_n(r,c),get_workspace_affected:c=>On(r,c),clear_cache:c=>jn(r,c),apply_tags:c=>Jn(r,c)}[s];if(!a)throw new Error(`Unknown tool: ${s}`);try{return wn(o.root),await a(o)}catch(c){return{content:[{type:"text",text:`Error: ${c instanceof Error?c.message:String(c)}`}],isError:!0}}}),e}async function bc(){let r=at(),e=new Qn.StdioServerTransport;await r.connect(e)}bc().catch(console.error);0&&(module.exports={createMcpServer});
|
|
29
|
+
`),Cs(this.graph.nodes),vs(this.graph.nodes),ws(this.graph.nodes),ks(this.graph.nodes),this.coverageMap.size>0&&Ss(this.graph.nodes,this.coverageMap),new D(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??Yc;if(!(r>0&&!this.hasAtLeastFiles(this.rootDir,r)))try{let n=T.default.join(__dirname,"parse-worker.js");this.pool=new Is.default({filename:n,...e.maxThreads!==void 0?{maxThreads:e.maxThreads}:{}})}catch(n){process.stderr.write(`
|
|
30
|
+
Warning: failed to start parse worker pool, falling back to synchronous parsing: ${n}
|
|
31
|
+
`),this.pool=null}}hasAtLeastFiles(e,r){let n=0,s=[e];for(;s.length>0;){let o=s.pop();if(o===void 0)continue;let i;try{i=ne.default.readdirSync(o,{withFileTypes:!0})}catch{continue}for(let a of i)if(a.isDirectory())Ms.has(a.name)||s.push(T.default.join(o,a.name));else if(a.isFile()&&(n++,n>=r))return!0}return n>=r}async processTestFiles(e){let r=oe(),n=o=>r.some(i=>o.name.includes(i));this.walkProject(e,n);let s=e;for(;s!==this.rootDir;){let o=T.default.dirname(s);if(o===s)break;for(let i of qc){let a=T.default.join(o,i);try{ne.default.statSync(a).isDirectory()&&this.walkProject(a,n)}catch{}}s=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 n;try{n=ne.default.readdirSync(e,{withFileTypes:!0})}catch{return}for(let s of n){let o=T.default.join(e,s.name);s.isDirectory()?Ms.has(s.name)||this.walkProject(o,r):s.isFile()&&r(s)&&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=ne.default.statSync(e,{throwIfNoEntry:!1});if(!r?.isFile())return;let n=T.default.relative(this.rootDir,e),s=await this.getNode(e,n,r);s.imports=await this.resolveImports(e,s.imports),bs(s.imports,s.tags),this.graph.nodes.set(s.path,s)}async getNode(e,r,n){let s=this.previousGraph?.nodes.get(r);if(s&&s.mtime===n.mtimeMs&&s.size===n.size)return{...s};let o=await this.tryParse(e,r);if(!o)return this.makeStubNode(e,r,n);let i=this.resolveCallEdges(e,o.rawCallEdges),a=this.buildNode(e,r,n,o,i);return this.attachGitStats(a,r),a}async tryParse(e,r){let n=ne.default.readFileSync(e,"utf-8");try{return await this.parseContent(e,n)}catch(s){return process.stderr.write(`
|
|
32
|
+
Warning: failed to parse ${r}: ${s}
|
|
33
|
+
`),null}}parseContent(e,r){return this.pool?this.pool.run({filePath:e,content:r}):ys(e,r)}makeStubNode(e,r,n){return{path:r,type:L(e),category:"other",imports:[],exports:[],tags:[],mtime:n.mtimeMs,size:n.size}}resolveCallEdges(e,r){let n=[];for(let s of r??[])try{let o=this.resolver.resolve(e,s.toSpecifier);o&&!o.isExternal&&n.push({from:s.from,to:s.to,toFile:T.default.relative(this.rootDir,o.path)})}catch{}return n}buildNode(e,r,n,s,o){let{imports:i,exports:a,tags:c,category:p,description:l,complexity:g,cognitiveComplexity:u,functions:d}=s;return{path:r,type:L(e),category:p,imports:i,exports:a,tags:c,mtime:n.mtimeMs,size:n.size,...l!==void 0?{description:l}:{},...o.length>0?{callEdges:o}:{},...g!==void 0?{complexity:g}:{},...u!==void 0?{cognitiveComplexity:u}:{},...d!==void 0?{functions:d}:{}}}attachGitStats(e,r){let n=this.gitStatsMap?.get(r);n&&(e.commitCount90d=n.commitCount90d,n.lastAuthor!==void 0&&(e.lastAuthor=n.lastAuthor),n.lastCommitAt!==void 0&&(e.lastCommitAt=n.lastCommitAt))}async resolveImports(e,r){let n=[];for(let s of r){let o=this.resolver.resolveAll(e,s.rawSpecifier);if(o.length!==0)for(let i of o){let a={...s,toPath:i.isExternal?i.path:T.default.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),n.push(a)}}return n}attachLockfileVersion(e){if(!this.lockFile)return;let r=e.rawSpecifier.startsWith("@")?e.rawSpecifier.split("/").slice(0,2).join("/"):e.rawSpecifier.split("/")[0],n=r?this.lockFile.dependencies[r]:void 0;n&&(e.version=n.version)}showProgress(){this.progressCallback&&this.visited.size%100===0&&this.progressCallback(this.visited.size)}};function Ds(t,e){return{identifier:e?.identifier??new et,featureMap:e?.featureDetection===!1?new Map:W(t.nodes,e?.featureDetection??void 0)}}function Rs(t,e,r,n,s){for(let o of e){let i=t.nodes.get(o);if(!i)continue;let a=new z(o,["*",...i.exports.map(c=>c.name)]);t.traverse(o,(c,p,l)=>{if(!l)return!0;if(!a.updateAffectedSymbols(c,l))return!1;if(p>0){let g=r.get(c.path);if(g)return n(g),!1}return s(c),!0},{direction:"incoming"})}}function Ar(t,e,r){let{identifier:n,featureMap:s}=Ds(t,r),o=new Set;for(let i of e){let a=s.get(i);a&&o.add(a.tag)}return Rs(t,e,s,i=>o.add(i.tag),i=>{if(n.isTestNode(i))for(let a of i.tags)o.add(a.name)}),Array.from(o)}function Nr(t,e,r){let{identifier:n,featureMap:s}=Ds(t,r),o=new Set;return Rs(t,e,s,()=>{},i=>{n.isTestNode(i)&&o.add(i.path)}),Array.from(o)}var Gs=h(require("fs")),se=h(require("path"));async function Ls(t,e,r=null,n={}){let s=n.silent?void 0:a=>{process.stderr.write(`Processed ${a} files...\r`)},o=se.default.resolve(t);return await new Te(o,r,n.pathAliases?new H(o,{pathAliases:n.pathAliases}):void 0,s,n.gitStats??!1,n.coverageMap??new Map,n.parallelParsing??!0).build(e)}async function _s(t,e={}){let r=se.default.resolve(t),n=ge(r),s=e.packages?n.packages.filter(a=>e.packages?.includes(a.name)||e.packages?.includes(a.relativeRoot)):n.packages,o=new Map(n.packages.map(a=>[a.name,a.root])),i=new de(r,n.type);for(let a of s){let c=e.silent?void 0:g=>{process.stderr.write(`[${a.name}] Processed ${g} files...\r`)},l=await new Te(r,null,new H(r,{workspaceMap:o,tsconfigSearchPaths:[a.root,r],pathAliases:e.pathAliases}),c,e.gitStats??!1,new Map,e.parallelParsing??!0).build(a.entryPoints);i.addPackage(a,l)}return i}function Os(t,e={}){let r=[],n=new Set([...e.ignoreDirs??j,...e.additionalIgnoreDirs??[]]),s=new Set([...e.extensions??St,...e.additionalExtensions??[]]);function o(i){try{let a=Gs.default.readdirSync(i,{withFileTypes:!0});for(let c of a){let p=se.default.join(i,c.name);c.isDirectory()?n.has(c.name)||o(p):c.isFile()&&s.has(se.default.extname(c.name).toLowerCase())&&r.push(se.default.relative(t,p))}}catch{}}return o(t),r}var js=/(?:^|[/\\])(?:node_modules|\.git|dist|build|coverage)(?:[/\\]|$)/;var ct=class{graphs=new Map;configs=new Map;workspaceGraphs=new Map;changeImpactCaches=new Map;dirtyRoots=new Set;watchers=new Map;lastAnalyze=new Map;isConfigured(e){return this.configs.has(e)}storeConfig(e,r){this.configs.set(e,r)}getConfig(e){return this.configs.get(e)}async getOrBuild(e,r,n=new Map){let s=this.configs.get(e),o=await Ls(e,r,this.graphs.get(e)??null,{...q(s),coverageMap:n});return this.graphs.set(e,o),o}require(e){let r=this.graphs.get(e);if(!r)throw new Error('No graph cached for this root. Call "analyze" first.');return r}async getOrBuildWorkspace(e,r={}){let n=this.workspaceGraphs.get(e);if(n)return n;let s=await _s(e,r);return this.workspaceGraphs.set(e,s),s}requireWorkspace(e){let r=this.workspaceGraphs.get(e);if(!r)throw new Error('No workspace graph cached for this root. Call "analyze" first.');return r}hasWorkspace(e){return this.workspaceGraphs.has(e)}getOrBuildChangeImpact(e){let r=this.changeImpactCaches.get(e);if(r)return r;let n=this.require(e),s=Tt(n);return this.changeImpactCaches.set(e,s),s}storeLastAnalyze(e,r){this.lastAnalyze.set(e,r)}startWatching(e){if(!this.watchers.has(e))try{let r=Ws.default.watch(e,{recursive:!0},(n,s)=>{!s||js.test(s)||this.dirtyRoots.add(e)});r.on("error",()=>{this.watchers.delete(e)}),this.watchers.set(e,r)}catch{}}async ensureFresh(e){if(!this.dirtyRoots.has(e))return this.require(e);this.dirtyRoots.delete(e),this.changeImpactCaches.delete(e);let r=this.lastAnalyze.get(e);return r?.kind==="single"?this.getOrBuild(e,r.entryPoints,r.coverageMap):this.require(e)}async ensureFreshWorkspace(e){if(!this.dirtyRoots.has(e))return this.requireWorkspace(e);this.dirtyRoots.delete(e),this.changeImpactCaches.delete(e),this.workspaceGraphs.delete(e);let r=this.configs.get(e);return this.getOrBuildWorkspace(e,q(r))}invalidate(e){let r=this.graphs.has(e)||this.workspaceGraphs.has(e);return this.graphs.delete(e),this.workspaceGraphs.delete(e),this.changeImpactCaches.delete(e),this.dirtyRoots.delete(e),r}};var Q=h(require("path"));var zs=h(require("fs")),$s=h(require("os")),pt=h(require("path"));function v(t){return{content:[{type:"text",text:JSON.stringify(t,null,2)}]}}function Bs(t){if(!pt.default.isAbsolute(t))throw new Error("root must be an absolute path");let e=pt.default.resolve(t),r=$s.default.homedir();if(e!==r&&!e.startsWith(r+pt.default.sep))throw new Error("root must be within the user home directory");let n;try{n=zs.default.statSync(e)}catch{throw new Error("root does not exist")}if(!n.isDirectory())throw new Error("root is not a directory")}async function Us(t,e){let{root:r,entryPoints:n}=e;if(!t.isConfigured(r)){let u=ie(r,{allowJs:!1});xt(u),t.storeConfig(r,u)}if(n.length===0){let u=ge(r);if(u.type!=="none"){let d=t.getConfig(r),x=await t.getOrBuildWorkspace(r,q(d));t.storeLastAnalyze(r,{kind:"workspace"}),t.startWatching(r);let y=Array.from(x.packages.values()).map(({graph:S,pkg:C})=>({package:C.name,relativeRoot:C.relativeRoot,nodeCount:S.nodes.size}));return v({monorepoType:u.type,packageCount:x.packages.size,packages:y})}}let s=n.map(u=>Q.default.resolve(r,u)),o=t.getConfig(r),i=o?.coverageReportPath?vt(r,o.coverageReportPath):new Map,a=await t.getOrBuild(r,s,i);t.storeLastAnalyze(r,{kind:"single",entryPoints:s,coverageMap:i}),t.startWatching(r);let c=a.serialize(),p=c.nodes.reduce((u,d)=>(u[d.category]=(u[d.category]??0)+1,u),{}),l=a.findCycles(),g=Gt(a);return v({nodeCount:c.nodes.length,categories:p,cycles:l,languageCoverage:g})}async function Ks(t,e){let{root:r,file:n,depth:s=1,withMeta:o=!1}=e,i=await t.ensureFresh(r),a=Lt(i,n,s),c=o?a.map(p=>({...p,...ue(i,p.path)})):a;return v({file:n,dependencies:c})}async function Js(t,e){let{root:r,file:n,withMeta:s=!1}=e,o=await t.ensureFresh(r),i=fe(o,n),a=s?i.map(c=>({...c,...ue(o,c.path)})):i;return v({file:n,dependents:a})}async function Vs(t,e){let{root:r,file:n,testsOnly:s=!1,cached:o=!1,changedSymbols:i,withMeta:a=!1}=e,c=await t.ensureFresh(r),p=u=>a?u.map(d=>({path:d,...ue(c,d)})):u;if(o){let u=t.getOrBuildChangeImpact(r),d=Pt(u,n),x=s?d.filter(S=>c.nodes.get(S)?.category==="test"):d,y=p(x);return v({file:n,affected:y,count:y.length})}let l=_t(c,n,{testsOnly:s,changedSymbols:i}),g=p(l);return v({file:n,affected:g,count:g.length})}async function Hs(t,e){let{root:r,file:n,depth:s=1,withEdgeDetail:o=!1}=e,i=await t.ensureFresh(r),a=Ot(i,n,{depth:s,withEdgeDetail:o});return v({file:n,callers:a,count:a.length})}async function Qs(t,e){let{root:r,entryPoints:n}=e,s=n?await t.getOrBuild(r,n.map(a=>Q.default.resolve(r,a))):await t.ensureFresh(r),o=Os(r),i=s.findUnusedFiles(o);return v({unusedFiles:i,count:i.length})}async function qs(t,e){let{root:r}=e,n=await t.ensureFresh(r),s=new Map;for(let i of n.nodes.values())for(let a of i.tags)s.set(a.name,(s.get(a.name)??0)+1);let o=[...s.entries()].map(([i,a])=>({name:i,count:a})).sort((i,a)=>a.count-i.count);return v({tags:o,count:o.length})}async function Ys(t,e){let{root:r,coverageThreshold:n}=e,s=await t.ensureFresh(r),o=t.getConfig(r),i=n??o?.coverageThreshold??80;if(!$t(s))return v({error:"No coverage data available. Set coverageReportPath in mokosh.config and call analyze again."});let a=[...s.nodes.values()].filter(c=>c.category!=="test"&&c.category!=="config").filter(c=>c.coveragePct!==void 0&&c.coveragePct<i).map(c=>({file:c.path,coveragePct:c.coveragePct}));return v({threshold:i,uncovered:a,count:a.length})}async function Xs(t,e){let{root:r}=e,s=[...(await t.ensureFresh(r)).nodes.values()].filter(o=>o.type==="markdown"&&o.staleFor&&o.staleFor.length>0).map(o=>({doc:o.path,staleFor:o.staleFor}));return v({staleDocs:s,count:s.length})}async function Zs(t,e){let{root:r,metric:n="cognitiveComplexity",threshold:s=10,limit:o=20}=e,i=await t.ensureFresh(r),a=jt(i,{metric:n,threshold:s,limit:o});return v({metric:n,threshold:s,functions:a,count:a.length})}async function eo(t,e){let{root:r,minLines:n=6,ignoreLiterals:s=!0,maxPunctuationRatio:o=.5,limit:i=50}=e,a=await t.ensureFresh(r),c=e.ignoreDirs??[...j,...t.getConfig(r)?.ignoreDirs??[]],p=await Rt(a,r,{minLines:n,ignoreLiterals:s,maxPunctuationRatio:o,limit:i,ignoreDirs:c});return v({minLines:n,groups:p,count:p.length})}async function to(t,e){let{root:r,changedFiles:n,featureThreshold:s,format:o="tags"}=e,i=await t.ensureFresh(r),a=n??new rt().getChangedFiles().map(l=>Q.default.relative(r,Q.default.resolve(r,l))),c=s!==void 0?{featureDetection:{minOutDegree:s}}:void 0;if(o==="paths"){let l=Nr(i,a,c);return v({changedFiles:a,affectedTests:l,count:l.length})}let p=Ar(i,a,c);return v({changedFiles:a,proposedTags:p})}async function ro(t,e){let{root:r,entryPoints:n,featureThreshold:s}=e,o=n?await t.getOrBuild(r,n.map(c=>Q.default.resolve(r,c))):await t.ensureFresh(r),i=W(o.nodes,s!==void 0?{minOutDegree:s}:void 0),a=Array.from(i.values()).sort((c,p)=>p.outDegree-c.outDegree);return v({features:a,count:a.length})}async function no(t,e){let{root:r,entryPoints:n,filter:s,mermaid:o=!1,slim:i=!0}=e,a=n?await t.getOrBuild(r,n.map(p=>Q.default.resolve(r,p))):await t.ensureFresh(r),c=Be(a.serialize(),Ue(s));return o?v(De.serialize(D.deserialize(c))):i?v(Wt(c)):v(c)}async function so(t,e){let{root:r}=e,n=await t.ensureFreshWorkspace(r);return v(zt(n))}async function oo(t,e){let{root:r,file:n}=e,o=(await t.ensureFreshWorkspace(r)).getAffectedAcrossPackages(n);return v({file:n,affected:o,count:o.length})}function io(t,e){let{root:r}=e,n=t.invalidate(r);return v({root:r,cleared:n,message:n?"Cache cleared. Call analyze to rebuild.":"No cache was present for this root."})}async function ao(t,e){let{root:r,type:n}=e,s=await t.ensureFresh(r),o=Kt(s);if(n)return v(Jt(o,n));let i=Array.from(o.types.values());return v({count:i.length,types:i})}async function co(t,e){let{root:r,paths:n,minOutDegree:s}=e,o=await t.ensureFresh(r),i=Bt(o,s!==void 0?{minOutDegree:s}:void 0);if(n?.length){let c=n.map(p=>i.get(p)).filter(Boolean);return v({count:c.length,modules:c})}let a=Array.from(i.values());return v({count:a.length,modules:a})}async function po(t,e){let{root:r,minOutDegree:n}=e,s=await t.ensureFresh(r),o=pe(s,n!==void 0?{minOutDegree:n}:void 0),i=Object.fromEntries(o.features);return v({features:i,unassigned:o.unassigned})}async function lo(t,e){let{root:r,function:n}=e,s=await t.ensureFresh(r);return v(Et(s,n))}async function uo(t,e){let{root:r,name:n}=e,s=await t.ensureFresh(r),o=Ut(s,n);return v({name:n,matches:o,count:o.length})}async function fo(t,e){let{root:r,entryPoints:n}=e,s=await t.ensureFresh(r),o=n?.length?n:Ct(s,r);if(o.length===0)throw new Error("No entry points found. Pass entryPoints explicitly or ensure package.json has a main/exports field.");return v(Ft(s,o))}async function mo(t,e){let r=await t.ensureFresh(e.root),n=await mr(r,e.root,{dryRun:e.dryRun??!1});return v(n)}var go=[{name:"analyze",description:"Build the dependency graph for a project from entry points. Returns a summary of node count, categories, and cycles. Must be called before get_dependencies, get_dependents, get_affected, or propose_tags. Pass an empty entryPoints array to auto-detect a monorepo (pnpm/npm/yarn/Nx/Turborepo) and build per-package graphs \u2014 use get_workspace_packages and get_workspace_affected for monorepo queries.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root (or monorepo root)"},entryPoints:{type:"array",items:{type:"string"},description:"Entry point files relative to root (e.g. ['src/index.ts']). Pass [] to trigger monorepo auto-detection."}},required:["root","entryPoints"]}},{name:"get_dependencies",description:"Get files that a given file imports (outgoing traversal). depth=1 returns immediate imports; omit for the full transitive tree. Each result includes the specific symbols imported from that file (when known).",inputSchema:{type:"object",properties:{root:{type:"string"},file:{type:"string",description:"File path relative to root"},depth:{type:"number",description:"Max traversal depth (default: 1)"},withMeta:{type:"boolean",description:"Include each result's category and export names alongside the path (default: false). Set true when you need to decide what to do with a result without a follow-up lookup."}},required:["root","file"]}},{name:"get_dependents",description:"Get files that directly import a given file (one-hop incoming edges). Each result includes the specific symbols that dependent file imports from this file (when known).",inputSchema:{type:"object",properties:{root:{type:"string"},file:{type:"string",description:"File path relative to root"},withMeta:{type:"boolean",description:"Include each result's category and export names alongside the path (default: false). Set true when you need to decide what to do with a result without a follow-up lookup."}},required:["root","file"]}},{name:"get_affected",description:"Get all files transitively affected if a given file changes \u2014 full incoming traversal upward. Use before a refactor to understand blast radius. Set testsOnly=true to get only test files. Set cached=true to use a pre-computed O(1) lookup cache instead of graph traversal \u2014 faster on repeated calls for the same root. Pass changedSymbols to restrict blast-radius to files that actually import those symbols \u2014 omit to treat the whole file as changed. Set withMeta=true to get { path, category, exports } objects instead of bare path strings.",inputSchema:{type:"object",properties:{root:{type:"string"},file:{type:"string",description:"File path relative to root"},testsOnly:{type:"boolean",description:"Return only test/spec files (default: false)"},cached:{type:"boolean",description:"Use a pre-computed impact cache for O(1) lookup instead of graph traversal. Cache is built lazily on first use and reused for the session (default: false)."},changedSymbols:{type:"array",items:{type:"string"},description:"Restrict blast-radius to files that import at least one of these symbols. Omit to treat the whole file as changed (conservative, same as before)."},withMeta:{type:"boolean",description:"Return each affected file as { path, category, exports } instead of a bare path string (default: false). Set true when you need to decide what to do with a result without a follow-up lookup."}},required:["root","file"]}},{name:"get_callers",description:"Get files whose exported functions call into a given file (call-graph dependents). More precise than get_affected: only files with actual runtime call edges, not mere imports. Requires prior analyze() call.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to project root"},file:{type:"string",description:"File path relative to root"},depth:{type:"number",description:"Max traversal depth (default: 1)"},withEdgeDetail:{type:"boolean",description:"Include from/to function names per edge (default: false)"}},required:["root","file"]}},{name:"find_unused",description:"Find files in the project that are not reachable from any entry point. Useful before cleanup passes. Omit entryPoints to reuse the cached graph from a prior analyze() call instead of rebuilding.",inputSchema:{type:"object",properties:{root:{type:"string"},entryPoints:{type:"array",items:{type:"string"},description:"Entry point files relative to root. Omit to reuse the cached graph from a prior analyze() call."}},required:["root"]}},{name:"list_tags",description:"List every distinct tag name present in the graph, with how many nodes carry each one. Call this before querying with tag:<name> to avoid a speculative filter silently returning zero results. Includes all tag kinds \u2014 a superset of what query's slim mode keeps (slim only retains comment-marker and import tags).",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"}},required:["root"]}},{name:"find_uncovered",description:"Find non-test files whose line coverage is below the configured threshold. Requires a prior analyze() call and coverageReportPath set in mokosh.config. coverageThreshold overrides the config default (default: 80).",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},coverageThreshold:{type:"number",description:"Line-coverage % below which a file is considered uncovered. Overrides config value."}},required:["root"]}},{name:"check_doc_drift",description:"Find markdown docs whose referenced files changed more recently than the doc itself \u2014 a commit-recency heuristic for stale documentation, not a content diff. Requires a prior analyze() call with gitStats: true in mokosh.config (otherwise no file has commit-timestamp data and nothing is flagged). See docs/adr-009-markdown-parsing.md for known limitations.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"}},required:["root"]}},{name:"find_complex_functions",description:"Find individual functions/methods above a cognitive (or cyclomatic) complexity threshold, sorted worst-first. Requires a prior analyze() call. Populated for TypeScript/JavaScript, Go, and Python.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},metric:{type:"string",enum:["cognitiveComplexity","complexity"],description:"Which score to threshold/sort on (default: cognitiveComplexity)"},threshold:{type:"number",description:"Minimum score to include (default: 10)"},limit:{type:"number",description:"Max results to return, worst-first (default: 20)"}},required:["root"]}},{name:"find_duplicates",description:"Find duplicated code blocks across the project, largest-first. Two matching strategies, picked per file: CSS/SCSS/Less are compared structurally by rule body \u2014 the literal, ordered property:value declarations a rule contains, independent of its selector \u2014 so a genuine copy-pasted declaration list is caught while rules that merely share shape (e.g. display:flex vs display:block) never match. Every other language mokosh parses (TypeScript/JavaScript, Python, Go, CoffeeScript, LiveScript, Lua, Gherkin, Markdown, and Stylus) runs a token-based shingle pipeline instead, partitioned by language family so matching never crosses between Stylus and code languages. Identifiers \u2014 and by default literals \u2014 are normalized before matching in the token-based path, so renamed-variable copies are still caught; blocks that are mostly object/array-literal structural punctuation (e.g. schema/object-literal boilerplate) rather than substantive shared logic are gated out. A block repeated N times across the project is reported once with N occurrences, not as separate pairs. Lock files (package-lock.json, yarn.lock, pnpm-lock.yaml) and files under an ignored directory are always excluded, even if the graph itself contains them. Requires a prior analyze() call.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},minLines:{type:"number",description:"Minimum duplicated block size in lines to report (default: 6)"},ignoreLiterals:{type:"boolean",description:"Normalize string/number literals too, not just identifiers, so only structural shape drives a match (default: true). Set false for stricter, exact-text-only matching."},maxPunctuationRatio:{type:"number",description:"Maximum fraction of a token-shingled block's window that may be object/array-literal structural punctuation ({ } : , [ ]) (default: 0.5). Filters out blocks that are mostly schema/object-literal shape instead of substantive shared logic. Does not apply to the CSS/Less/SCSS structural comparator. Set 1 to disable."},ignoreDirs:{type:"array",items:{type:"string"},description:"Directory names to exclude, matched against any path segment (default: DEFAULT_IGNORE_DIRS merged with this root's configured ignoreDirs, if any). Pass [] to disable."},limit:{type:"number",description:"Max duplicate blocks to return, largest-first (default: 50)"}},required:["root"]}},{name:"propose_tags",description:"Propose what to run based on changed files. Pass changedFiles explicitly or omit to use git diff. format='tags' (default) returns test tags for CI tag-filtering; format='paths' returns test file paths ready to pipe directly to a test runner (e.g. vitest). Feature hubs act as traversal boundaries in both modes.",inputSchema:{type:"object",properties:{root:{type:"string"},changedFiles:{type:"array",items:{type:"string"},description:"Changed files relative to root. Omit to read from git diff."},featureThreshold:{type:"number",description:"Min importers for a file to be treated as a feature hub (default: 5). A hub short-circuits traversal and emits a feature:<name> tag instead of all downstream tags."},format:{type:"string",enum:["tags","paths"],description:"Output format: 'tags' returns test tag names for CI filtering (default); 'paths' returns test file paths to pipe to a test runner."}},required:["root"]}},{name:"detect_features",description:"Identify feature hub files \u2014 non-test files that import many other internal modules (orchestrators / aggregators like src/parser.ts or src/cli/runner.ts). Returns a list sorted by import count descending.",inputSchema:{type:"object",properties:{root:{type:"string"},entryPoints:{type:"array",items:{type:"string"},description:"Entry point files relative to root. Omit to use the cached graph."},featureThreshold:{type:"number",description:"Min internal imports a file must have to qualify as a feature hub (default: 5)."}},required:["root"]}},{name:"query",description:"Filter the graph by category, tag, or path. Returns matching nodes as JSON or a Mermaid diagram. If entryPoints is omitted the cached graph from a prior 'analyze' call is used.",inputSchema:{type:"object",properties:{root:{type:"string"},entryPoints:{type:"array",items:{type:"string"},description:"Entry points to build the graph. Omit to reuse the cached graph from a prior 'analyze' call."},filter:{type:"string",description:"Query string e.g. 'category:logic' or 'category:logic,tag:auth'. Supports: category, type, tag, path, external, importsFile, importedBy, minImports, maxImports, minSize, maxSize, hasDocstring, minCoverage, maxCoverage, minExportUsage, maxExportUsage, minComplexity, maxComplexity, minCognitiveComplexity, maxCognitiveComplexity, minCommits, maxCommits, isDocumented, isStale, lastAuthor. OR logic: any(key:val|key:val) matches if any single-key clause holds, ANDed with the rest of the query. sort: size|imports|commitCount90d|exportUsage|complexity|cognitiveComplexity, with sortDir: asc|desc (default desc). limit: N."},mermaid:{type:"boolean",description:"Return a Mermaid diagram (default: false)"},slim:{type:"boolean",description:"Compact response mode (default: true). Returns export names, meaningful tags, and a flat importsFiles path list \u2014 no edge objects, no mtime/size. Tags are filtered to kinds comment-marker and import only; function/class/variable/type/library tags are dropped in slim output. Use list_tags to see the full tag inventory, or pass slim: false to get every tag kind on matching nodes."}},required:["root","filter"]}},{name:"get_workspace_packages",description:"List all workspace packages detected in a monorepo, with their node counts and inter-package dependencies. Requires a prior analyze() call with empty entryPoints on a monorepo root.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the monorepo root"}},required:["root"]}},{name:"get_workspace_affected",description:"Cross-package blast-radius analysis. Returns every file that could be affected if a given file changes, annotated with the package it belongs to. Requires a prior analyze() call with empty entryPoints on a monorepo root.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the monorepo root"},file:{type:"string",description:"Monorepo-root-relative path of the changed file (e.g. 'packages/shared/src/utils.ts')"}},required:["root","file"]}},{name:"get_type_graph",description:"Return type-level relationships for the project. Without a type name, returns an inventory of all interfaces, classes, enums, and type aliases with their file and kind. With a type name, returns which files import that type (usedByFiles) and which types the defining file imports (uses). Requires a prior analyze() call. Only covers TypeScript/JavaScript files.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},type:{type:"string",description:"Exact exported name of the type to look up (e.g. 'FileNode'). Omit to get the full type inventory."}},required:["root"]}},{name:"get_module_responsibility",description:"Return what each file is responsible for: its semantic role, JSDoc description (when present), exported symbol names, and which feature hub it belongs to. Pass specific paths to filter, or omit paths to get all files. Requires a prior analyze() call.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},paths:{type:"array",items:{type:"string"},description:"Project-relative file paths to include. Omit to return all files."},minOutDegree:{type:"number",description:"Min imports for a file to qualify as a feature hub (default: 5)."}},required:["root"]}},{name:"get_feature_graph",description:"Group files by domain: returns which files each feature hub (high-import orchestrator) transitively owns. Each file is assigned to the most specific hub that can reach it (lowest out-degree wins). Use this instead of a full query when answering 'what files are in the X feature/module?' \u2014 typically 85\u201395% fewer tokens than a full graph query.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},minOutDegree:{type:"number",description:"Minimum internal imports a file must have to qualify as a feature hub (default: 5)."}},required:["root"]}},{name:"get_call_graph",description:"Look up callers and callees for a named function. Returns the file that defines the function, all files/functions that call it, and all files/functions it calls. Always requires a function name \u2014 never returns the full call graph unfiltered. Call edges are only populated for TypeScript/JavaScript files.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},function:{type:"string",description:"Exact name of the function to look up (e.g. 'parseFile')."}},required:["root","function"]}},{name:"find_symbol",description:"Find every file that exports a symbol by exact name, with the best available usage info per match. Precision varies by the defining file's language: TypeScript/JavaScript, Go, and Python get function-level callers (via call edges) \u2014 though coverage differs per language (Go only tracks package-qualified calls, Python only tracks bare calls to `from module import name` symbols); everything else (CoffeeScript, LiveScript, Lua, Gherkin, Markdown, CSS/SCSS/Stylus) falls back to whole-file dependents, which is import-level only \u2014 a listed importer might not even use this specific export. Files whose parser never records exports (CoffeeScript, LiveScript, Lua, Gherkin, Markdown, CSS/SCSS/Stylus) never appear as matches, so a name that only exists in one of those returns an empty result, same as a typo. Each match's `precision` field is 'call' | 'file-level' \u2014 check it before trusting caller/importer results as symbol-exact.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},name:{type:"string",description:"Exact export name to look up (e.g. 'parseFile')."}},required:["root","name"]}},{name:"get_api_surface",description:"Build the API surface report for a project. Expands export* chains so every symbol accessible to consumers is listed (not just those directly declared in the entry file). Each export is resolved to its defining file and tagged with a kind (function/class/interface/type/enum/const). The graph is partitioned into: internalFiles (implementation reachable from entry points), unreachableFromEntry (non-test files not reachable from any entry point \u2014 may be separate consumers like CLI/MCP, config, or dead code), and testFiles (test suite). Supports multiple public entry points for libraries with sub-path exports. Requires a prior analyze() call. When entryPoints is omitted, auto-detects all entry points from package.json exports/main/module.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},entryPoints:{type:"array",items:{type:"string"},description:"Project-relative paths of public entry points (e.g. ['src/index.ts', 'src/utils.ts']). Omit to auto-detect from package.json exports / main / module fields."}},required:["root"]}},{name:"clear_cache",description:"Drop the cached dependency graph for a project root, forcing the next analyze() call to rebuild from disk. Call this after editing source files mid-session \u2014 otherwise get_affected, get_dependencies, and other query tools will reason from stale data.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root to invalidate."}},required:["root"]}},{name:"apply_tags",description:"Write @tag annotations into test file source code based on the dependency graph. Tags of kind 'import' (filename-derived) and 'comment-marker' (domain semantic, propagated from source files) are written as an idempotent block. Re-running is safe: the existing block is replaced in place. Tags already present in the file are excluded from the block to avoid duplication. Supports TypeScript/JavaScript (// <mokosh-tags> block with // @tag lines) and Gherkin .feature files (# <mokosh-tags> block with @tagname lines). Use dryRun=true to preview changes without writing to disk. Requires a prior analyze() call.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root."},dryRun:{type:"boolean",description:"When true, computes which files would change but does not write to disk (default: false)."}},required:["root"]}}];function ut(){let t=new ct,e=new ho.Server({name:"mokosh",version:"0.0.1"},{capabilities:{tools:{}}});return e.setRequestHandler(lt.ListToolsRequestSchema,async()=>({tools:go})),e.setRequestHandler(lt.CallToolRequestSchema,async r=>{let{name:n,arguments:s}=r.params,o=s,a={analyze:c=>Us(t,c),get_dependencies:c=>Ks(t,c),get_dependents:c=>Js(t,c),get_affected:c=>Vs(t,c),get_callers:c=>Hs(t,c),find_symbol:c=>uo(t,c),find_unused:c=>Qs(t,c),find_uncovered:c=>Ys(t,c),list_tags:c=>qs(t,c),check_doc_drift:c=>Xs(t,c),find_complex_functions:c=>Zs(t,c),find_duplicates:c=>eo(t,c),propose_tags:c=>to(t,c),detect_features:c=>ro(t,c),get_type_graph:c=>ao(t,c),get_module_responsibility:c=>co(t,c),get_feature_graph:c=>po(t,c),get_call_graph:c=>lo(t,c),get_api_surface:c=>fo(t,c),query:c=>no(t,c),get_workspace_packages:c=>so(t,c),get_workspace_affected:c=>oo(t,c),clear_cache:c=>io(t,c),apply_tags:c=>mo(t,c)}[n];if(!a)throw new Error(`Unknown tool: ${n}`);try{return Bs(o.root),await a(o)}catch(c){return{content:[{type:"text",text:`Error: ${c instanceof Error?c.message:String(c)}`}],isError:!0}}}),e}async function Zc(){let t=ut(),e=new yo.StdioServerTransport;await t.connect(e)}Zc().catch(console.error);0&&(module.exports={createMcpServer});
|
|
31
34
|
//# sourceMappingURL=mcp.js.map
|