@principal-ai/quality-lens-cli 0.1.58 → 0.1.59
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
CHANGED
|
@@ -979,7 +979,7 @@ Make sure that all grammar rule definitions are done before 'performSelfAnalysis
|
|
|
979
979
|
`+_.map(c=>c.message).join(`
|
|
980
980
|
`)),this.errors=_}},Mar=class extends UR{constructor(_){super(_)}},Mlt=Io.default.build("{{digit}}{4}",{digit:_E}),Blt=Io.default.build("{{digit}}{2}",{digit:_E}),jlt=Io.default.build("{{digit}}{2}",{digit:_E}),Jlt=/[Tt ]/,jFe=Io.default.build("{{digit}}{2}",{digit:_E}),JFe=Io.default.build("{{digit}}{2}",{digit:_E}),qlt=Io.default.build("{{digit}}{2}",{digit:_E}),Bar=Io.default.build("\\.{{digit}}+",{digit:_E}),jar=Io.default.build("[+-]{{timeHour}}:{{timeMinute}}",{timeHour:jFe,timeMinute:JFe}),Jar=Io.default.build("[Zz]|{{timeNumOffset}}",{timeNumOffset:jar}),qFe=Io.default.build("{{timeHour}}:{{timeMinute}}:{{timeSecond}}{{timeSecFrac}}?",{timeHour:jFe,timeMinute:JFe,timeSecond:qlt,timeSecFrac:Bar}),UFe=Io.default.build("{{dateFullYear}}-{{dateMonth}}-{{dateMDay}}",{dateFullYear:Mlt,dateMonth:Blt,dateMDay:jlt}),qar=Io.default.build("{{partialTime}}{{timeOffset}}",{partialTime:qFe,timeOffset:Jar}),Uar=Io.default.build("{{fullDate}}{{timeDelim}}{{fullTime}}",{fullDate:UFe,timeDelim:Jlt,fullTime:qar}),zar=Io.default.build("{{fullDate}}{{timeDelim}}{{partialTime}}",{fullDate:UFe,timeDelim:Jlt,partialTime:qFe}),War=UFe,Ult=qFe,Var=Io.default.build("{{offsetDateTime}}|{{localDateTime}}|{{localDate}}|{{localTime}}",{offsetDateTime:Uar,localDateTime:zar,localDate:War,localTime:Ult}),aoe=Gu({name:"DateTime",pattern:Var}),$ar=_=>{let c=Io.default.build("({{dateFullYear}})-({{dateMonth}})-({{dateMDay}})",{dateFullYear:Mlt,dateMonth:Blt,dateMDay:jlt}),f=Io.default.exec(_,c);if(f){let h=Number(f[1]),S=Number(f[2]),k=Number(f[3]),R=new Date(h,S-1,k);return R.getFullYear()===h&&R.getMonth()+1===S&&R.getDate()===k}return!0},Gar=_=>{let c=Io.default.build("({{timeHour}}):({{timeMinute}}):({{timeSecond}})",{timeHour:jFe,timeMinute:JFe,timeSecond:qlt}),f=Io.default.exec(_,c);if(f){let h=Number(f[1]),S=Number(f[2]),k=Number(f[3]),R=new Date(0,0,0,h,S,k);return R.getHours()===h&&R.getMinutes()===S&&R.getSeconds()===k}return!0},Har=_=>$ar(_)&&Gar(_);R1(aoe,_=>{var c;if(!Har(_))throw new UR(`Invalid date time: ${_}`);return((c=_.match(Ult))==null?void 0:c.index)===0?_:new Date(_)});var zlt=Gu({name:"DotSeparator",pattern:/\./,label:"."}),PFe=Gu({name:"ExpressionNewLine",pattern:Ik}),Qar=Rlt,Wlt=Io.default.build("{{digit}}({{digit}}|{{underscore}}{{digit}})*",{digit:_E,underscore:o$}),Kar=Io.default.build("({{minus}}|{{plus}})?{{zeroPrefixableInt}}",{minus:MFe,plus:BFe,zeroPrefixableInt:Wlt}),Xar=Io.default.build("[Ee]{{floatExpPart}}",{floatExpPart:Kar}),Yar=/\./,Zar=Io.default.build("{{decimalPoint}}{{zeroPrefixableInt}}",{decimalPoint:Yar,zeroPrefixableInt:Wlt}),eor=/inf/,tor=/nan/,ror=Io.default.build("({{minus}}|{{plus}})?({{inf}}|{{nan}})",{minus:MFe,plus:BFe,inf:eor,nan:tor}),nor=Io.default.build("{{floatIntPart}}({{exp}}|{{frac}}{{exp}}?)|{{specialFloat}}",{floatIntPart:Qar,exp:Xar,frac:Zar,specialFloat:ror}),ooe=Gu({name:"Float",pattern:nor}),ior=_=>_==="inf"||_==="+inf"?1/0:_==="-inf"?-1/0:_==="nan"||_==="+nan"||_==="-nan"?NaN:null;R1(ooe,_=>{let c=ior(_);if(c!==null)return c;let f=_.replace(/_/g,"");return parseFloat(f)});var sor=/}/,NFe=Gu({name:"InlineTableClose",pattern:sor,label:"}",pop_mode:!0}),aor=/{/,Vlt=Gu({name:"InlineTableOpen",pattern:aor,label:"{",push_mode:"InlineTable"}),oor=/,/,$lt=Gu({name:"InlineTableSep",pattern:oor,label:",",pop_mode:!0,push_mode:"InlineTable"}),c$=Gu({name:"Integer",pattern:z_.NA});R1(c$,i$);var zFe=Gu({name:"KeyValueSeparator",pattern:/=/,label:"=",push_mode:"Value"}),Glt=Gu({name:"Newline",pattern:Ik,pop_mode:!0}),kk=Gu({name:"SimpleKey",pattern:z_.NA});R1(kk,i$);var Hlt=Gu({name:"StdTableClose",pattern:/]/,label:"]",push_mode:"Value"}),Qlt=Gu({name:"StdTableOpen",pattern:/\[/,label:"["}),f7=Gu({name:"String",pattern:z_.NA});R1(f7,i$);var cor=Io.default.build("{{whiteSpaceChar}}+",{whiteSpaceChar:zR}),Klt=Gu({name:"WhiteSpace",pattern:cor,group:z_.SKIPPED}),uor=Io.default.build("^{{whiteSpaceChar}}*{{newline}}(?:{{whiteSpaceChar}}|{{newline}})*",{whiteSpaceChar:zR,newline:Ik}),lor=_=>{let c=Io.default.exec(_,uor);return c?c[0].length:0},Xlt=_=>{let c="";for(let f=0;f<_.length;f++){let h=_[f];if(h==="\\"){f++;let S=lor(_.slice(f));if(S>0){f+=S-1;continue}switch(_[f]){case"b":c+="\b";break;case"t":c+=" ";break;case"n":c+=`
|
|
981
981
|
`;break;case"f":c+="\f";break;case"r":c+="\r";break;case'"':c+='"';break;case"\\":c+="\\";break;case"u":{let k=_.slice(f+1,f+5),R=parseInt(k,16);if(R>55295&&R<57344)throw new UR(`Invalid Unicode code point: \\u${k}`);c+=String.fromCodePoint(R),f+=4;break}case"U":{let k=_.slice(f+1,f+9),R=parseInt(k,16);if(R>1114111)throw new UR(`Invalid Unicode code point: \\U${k}`);c+=String.fromCodePoint(R),f+=8;break}case _.match(/^[0-7]{1,3}$/):}}else c+=h}return c},Ylt=_=>_.substring(3,_.length-3).replace(/^(\r\n|\n)/,""),_or=Io.default.build("{{quotationMark}}{3}",{quotationMark:LFe}),por=Io.default.build("{{whiteSpaceChar}}|!|[#-\\x5B]|[\\x5D-~]|{{nonAscii}}",{whiteSpaceChar:zR,nonAscii:a$}),dor=Io.default.build("{{multiLineBasicUnescaped}}|{{escaped}}",{multiLineBasicUnescaped:por,escaped:Llt}),mor=Io.default.build("{{whiteSpaceChar}}*",{whiteSpaceChar:zR}),hor=Io.default.build("{{escape}}{{whiteSpace}}{{newline}}({{whiteSpaceChar}}|{{newline}})*",{escape:Nlt,whiteSpace:mor,newline:Ik,whiteSpaceChar:zR}),gor=Io.default.build("{{multiLineBasicChar}}|{{newline}}|{{multiLineBasicEscapedNewline}}",{multiLineBasicChar:dor,newline:Ik,multiLineBasicEscapedNewline:hor}),yor=Io.default.build("{{quotationMark}}{1,2}",{quotationMark:LFe}),vor=Io.default.build("{{multiLineBasicContent}}*({{multiLineBasicQuotes}}{{multiLineBasicContent}}+)*{{multiLineBasicQuotes}}?",{multiLineBasicContent:gor,multiLineBasicQuotes:yor}),Zlt=Gu({name:"MultiLineBasicString",pattern:Io.default.build("{{multiLineBasicStringDelimiter}}{{newline}}?{{multiLineBasicBody}}{{multiLineBasicStringDelimiter}}",{multiLineBasicStringDelimiter:_or,newline:Ik,multiLineBasicBody:vor}),label:'"""MultiLineBasicString"""',categories:[f7],line_breaks:!0});R1(Zlt,_=>{let c=Ylt(_);return Xlt(c)});var Dor=Io.default.build("{{apostrophe}}{3}",{apostrophe:RFe}),bor=Io.default.build(" |[ -&]|[\\x28-~]|{{nonAscii}}",{nonAscii:a$}),Cor=Io.default.build("{{multiLineLiteralChar}}|{{newline}}",{multiLineLiteralChar:bor,newline:Ik}),Sor=Io.default.build("{{apostrophe}}{1,2}",{apostrophe:RFe}),Eor=Io.default.build("{{multiLineLiteralContent}}*({{multiLineLiteralQuotes}}{{multiLineLiteralContent}}+)*{{multiLineLiteralQuotes}}?",{multiLineLiteralContent:Cor,multiLineLiteralQuotes:Sor}),eft=Gu({name:"MultiLineLiteralString",pattern:Io.default.build("{{multiLineLiteralStringDelimiter}}{{newline}}?{{multiLineLiteralBody}}{{multiLineLiteralStringDelimiter}}",{multiLineLiteralStringDelimiter:Dor,newline:Ik,multiLineLiteralBody:Eor}),label:"'''MultiLineLiteralString'''",categories:[f7],line_breaks:!0});R1(eft,Ylt);var WFe=Gu({name:"QuotedKey",pattern:z_.NA,categories:[kk]});R1(WFe,i$);var xor=Io.default.build("{{whiteSpaceChar}}|!|[#-\\x5B]|[\\x5D-~]|{{nonAscii}}",{whiteSpaceChar:zR,nonAscii:a$}),Tor=Io.default.build("{{basicUnescaped}}|{{escaped}}",{basicUnescaped:xor,escaped:Llt}),VFe=Gu({name:"BasicString",pattern:Io.default.build("{{quotationMark}}{{basicChar}}*{{quotationMark}}",{quotationMark:LFe,basicChar:Tor}),label:'"BasicString"',categories:[WFe,f7]});R1(VFe,_=>{let c=_.slice(1,-1);return Xlt(c)});var Aor=Io.default.build(" |[ -&]|[\\x28-~]|{{nonAscii}}",{nonAscii:a$}),$Fe=Gu({name:"LiteralString",pattern:Io.default.build("{{apostrophe}}{{literalChar}}*{{apostrophe}}",{apostrophe:RFe,literalChar:Aor}),label:"'LiteralString'",categories:[WFe,f7]});R1($Fe,_=>_.slice(1,-1));var For=/0x/,kor=/0o/,Ior=/0b/,wor=/[0-7]/,Por=/[01]/,Nor=Io.default.build("{{hexPrefix}}{{hexDigit}}({{hexDigit}}|{{underscore}}{{hexDigit}})*",{hexPrefix:For,hexDigit:Olt,underscore:o$}),Oor=Io.default.build("{{octPrefix}}{{digit0_7}}({{digit0_7}}|{{underscore}}{{digit0_7}})*",{octPrefix:kor,digit0_7:wor,underscore:o$}),Lor=Io.default.build("{{binPrefix}}{{digit0_1}}({{digit0_1}}|{{underscore}}{{digit0_1}})*",{binPrefix:Ior,digit0_1:Por,underscore:o$}),Ror=Io.default.build("{{hexInteger}}|{{octalInteger}}|{{binaryInteger}}",{hexInteger:Nor,octalInteger:Oor,binaryInteger:Lor}),tft=Gu({name:"NonDecimalInteger",pattern:Ror,categories:[c$]}),Mor=(_,c)=>{let f=BigInt(0);for(let h=0;h<_.length;h++){let S=_[h],k=parseInt(S,c);f=f*BigInt(c)+BigInt(k)}return f},Bor=_=>{if(_.startsWith("0x"))return 16;if(_.startsWith("0o"))return 8;if(_.startsWith("0b"))return 2};R1(tft,_=>{let c=_.replace(/_/g,"").slice(2),f=Bor(_),h=parseInt(c,f);return Number.isSafeInteger(h)?h:Mor(c,f)});var rft=Gu({name:"DecimalInteger",pattern:Rlt,categories:[c$]});R1(rft,_=>{let c=_.replace(/_/g,""),f=parseInt(c);return Number.isSafeInteger(f)?f||0:BigInt(c)});var jor=/[a-zA-Z]/,Jor=Io.default.build("({{alpha}}|{{digit}}|-|_)+",{alpha:jor,digit:_E}),nft=Gu({name:"UnquotedKey",pattern:Jor,categories:[kk]});R1(nft,_=>_);var qor=/#/,Uor=Io.default.build(" |[ -~]|{{nonAscii}}",{nonAscii:a$}),zor=Io.default.build("{{commentStartChar}}{{nonEol}}*",{commentStartChar:qor,nonEol:Uor}),ift=Gu({name:"Comment",pattern:zor,group:"comment"}),Wor=/true/,sft=Gu({name:"True",pattern:Wor,label:"true",categories:[s$]});R1(sft,()=>!0);var Vor=/false/,aft=Gu({name:"False",pattern:Vor,label:"false",categories:[s$]});R1(aft,()=>!1);var $or=Gu({name:"IgnoredNewline",pattern:Ik,group:z_.SKIPPED}),Gor=Gu({name:"InlineTableKeyValSep",pattern:/=/,label:"=",push_mode:"Value",pop_mode:!0,categories:[zFe]}),Elt=[Klt,VFe,$Fe,nft,zlt,kk],xlt=[Klt,Zlt,eft,VFe,$Fe,sft,aft,aoe,ooe,tft,rft,klt,Vlt,ift],oft={modes:{Key:[ift,PFe,zFe,Plt,wlt,Qlt,Hlt,...Elt],Value:[...xlt,Glt,$lt,NFe],Array:[...xlt,$or,Ilt,Flt],InlineTable:[...Elt,Gor,NFe]},defaultMode:"Key"},Hor=new z_(oft,{ensureOptimizations:!0,skipValidations:!soe.isDebug(),traceInitPerf:soe.isDebug()}),Qor=class extends uV{toml=this.RULE("toml",()=>{this.MANY(()=>this.CONSUME(PFe)),this.MANY1(()=>{this.SUBRULE1(this.expression),this.OPTION2(()=>{this.CONSUME1(Glt),this.MANY3(()=>this.CONSUME2(PFe))})})});valueCache;dottedKey=this.RULE("dottedKey",()=>{this.CONSUME(kk),this.AT_LEAST_ONE(()=>{this.CONSUME(zlt),this.CONSUME1(kk)})});key=this.RULE("key",()=>{this.OR({MAX_LOOKAHEAD:2,DEF:[{ALT:()=>this.SUBRULE(this.dottedKey)},{ALT:()=>this.CONSUME(kk)}]})});inlineTableKeyValues=this.RULE("inlineTableKeyValues",()=>{this.MANY_SEP({SEP:$lt,DEF:()=>this.SUBRULE(this.keyValue)})});inlineTable=this.RULE("inlineTable",()=>{this.CONSUME(Vlt),this.OPTION(()=>this.SUBRULE(this.inlineTableKeyValues)),this.CONSUME(NFe)});array=this.RULE("array",()=>{this.CONSUME(klt),this.OPTION(()=>this.SUBRULE(this.arrayValues)),this.CONSUME(Flt)});value=this.RULE("value",()=>{this.OR(this.valueCache||(this.valueCache=[{ALT:()=>this.CONSUME(f7)},{ALT:()=>this.CONSUME(s$)},{ALT:()=>this.SUBRULE(this.array)},{ALT:()=>this.SUBRULE(this.inlineTable)},{ALT:()=>this.CONSUME(aoe)},{ALT:()=>this.CONSUME(ooe)},{ALT:()=>this.CONSUME(c$)}]))});keyValue=this.RULE("keyValue",()=>{this.SUBRULE(this.key),this.CONSUME(zFe),this.SUBRULE(this.value)});arrayValues=this.RULE("arrayValues",()=>{this.SUBRULE(this.value);let _=!0;this.MANY({GATE:()=>_,DEF:()=>{this.CONSUME(Ilt),this.OPTION(()=>this.SUBRULE1(this.value))||(_=!1)}})});stdTable=this.RULE("stdTable",()=>{this.CONSUME(Qlt),this.SUBRULE(this.key),this.CONSUME(Hlt)});arrayTable=this.RULE("arrayTable",()=>{this.CONSUME(Plt),this.SUBRULE(this.key),this.CONSUME(wlt)});table=this.RULE("table",()=>{this.OR([{ALT:()=>this.SUBRULE(this.stdTable)},{ALT:()=>this.SUBRULE(this.arrayTable)}])});expression=this.RULE("expression",()=>{this.OR([{ALT:()=>this.SUBRULE(this.keyValue)},{ALT:()=>this.SUBRULE(this.table)}])});constructor(){super(oft,{traceInitPerf:soe.isDebug(),maxLookahead:1,skipValidations:!soe.isDebug()}),this.performSelfAnalysis()}},n$=new Qor,Tlt=_=>_&&(_.constructor===Object||_.constructor===void 0),ioe=()=>Object.create(null),IFe=(_,c)=>{try{return _()}catch(f){if(f instanceof qR)throw new Mar(c)}},qR=class extends Error{},Kor=n$.getBaseCstVisitorConstructor(),wFe=Symbol("explicitlyDeclared"),Alt=Symbol("implicitlyDeclared"),r$=Symbol("notEditable"),Xor=class extends Kor{constructor(){super(),this.validateVisitor()}toml(_){var c;let f=ioe(),h=f;return(c=_.expression)==null||c.forEach(S=>h=this.visit(S,{current:h,root:f})),this.cleanInternalProperties(f),f}expression(_,{current:c,root:f}){if(_.keyValue)return this.visit(_.keyValue,c),c;if(_.table)return this.visit(_.table,f)}keyValue(_,c){let f=this.visit(_.key),h=this.visit(_.value);IFe(()=>this.assignValue(f,h,c),`Cannot assign value to '${f.join(".")}'`)}key(_){return _.dottedKey?this.visit(_.dottedKey):[this.interpret(_,kk)]}dottedKey(_){return this.interpret(_,kk)}inlineTableKeyValues(_,c){_.keyValue&&_.keyValue.forEach(f=>this.visit(f,c))}inlineTable(_){let c=ioe();return c[r$]=!0,_.inlineTableKeyValues&&this.visit(_.inlineTableKeyValues,c),c}value(_){return _.array?this.visit(_.array):_.inlineTable?this.visit(_.inlineTable):this.interpret(_,f7,ooe,s$,aoe,c$)}arrayValues(_,c){return _.value.forEach(f=>c.push(this.visit(f))),c}array(_){let c=[];return c[r$]=!0,_.arrayValues?this.visit(_.arrayValues,c):c}table(_,c){if(_.stdTable)return this.visit(_.stdTable,c);if(_.arrayTable)return this.visit(_.arrayTable,c)}stdTable(_,c){let f=this.visit(_.key);return IFe(()=>this.createTable(f,c),`Cannot create table '${f.join(".")}'`)}arrayTable(_,c){let f=this.visit(_.key);return IFe(()=>{let h=this.getOrCreateArray(f,c);if(h[r$])throw new qR;let S=ioe();return h.push(S),S},`Cannot create array table '${f.join(".")}'`)}cleanInternalProperties(_){for(let c of Object.getOwnPropertySymbols(_))delete _[c];for(let c in _)typeof _[c]=="object"&&this.cleanInternalProperties(_[c]),Array.isArray(_[c])&&_[c].forEach(f=>this.cleanInternalProperties(f))}interpret(_,...c){for(let f of c)if(_[f.name]){let h=_[f.name].map(S=>OFe[f.name](S.image,S,f.name));return h.length===1?h[0]:h}}assignPrimitiveValue(_,c,f){if(_ in f)throw new qR;return Tlt(c)&&(c[wFe]=!0),f[_]=c,f}tryCreatingObject(_,c,f,h,S){if(c[_]){if(!Tlt(c[_])||!S&&c[_][wFe]||!h&&c[_][Alt]||c[_][r$])throw new qR}else c[_]=ioe(),f&&(c[_][f]=!0);return c[_]}assignValue(_,c,f){let[h,...S]=_;return S.length>0?(this.tryCreatingObject(h,f,Alt,!0,!1),this.assignValue(S,c,f[h])):this.assignPrimitiveValue(h,c,f)}createTable(_,c){let[f,...h]=_;if(h.length>0){if(Array.isArray(c[f])){if(c[f][r$])throw new qR;let S=c[f][c[f].length-1];return this.createTable(h,S)}return this.tryCreatingObject(f,c,null,!0,!0),this.createTable(h,c[f])}return this.tryCreatingObject(f,c,wFe,!1,!1)}getOrCreateArray(_,c){let[f,...h]=_;if(h.length>0){if(Array.isArray(c[f])){let S=c[f][c[f].length-1];return this.getOrCreateArray(h,S)}return this.tryCreatingObject(f,c,null,!0,!0),this.getOrCreateArray(h,c[f])}if(c[f]&&!Array.isArray(c[f]))throw new qR;return c[f]=c[f]||[],c[f]}},Yor=new Xor,GFe=_=>{let c=Hor.tokenize(_);if(c.errors.length>0)throw new Lar(c.errors);n$.input=c.tokens;let f=n$.toml();if(n$.errors.length>0)throw new Rar(n$.errors);return Yor.visit(f)};var C_t=jm(Wft(),1);var b_t=jm(woe(),1),nlr={eslint:"linting",biome:"linting","biome-lint":"linting",oxlint:"linting",typescript:"types",flow:"types",test:"tests",jest:"tests",vitest:"tests","bun-test":"tests",mocha:"tests",playwright:"tests",cypress:"tests",prettier:"formatting","biome-format":"formatting",knip:"deadCode",depcheck:"deadCode",typedoc:"documentation",jsdoc:"documentation",alexandria:"documentation"},ilr=[{pattern:/^bun\s+test\b/,lensId:"bun-test"},{pattern:/^bun\s+run\s+test\b/,lensId:"bun-test"},{pattern:/\bbiome\s+(check|lint|ci)\b/,lensId:"biome-lint"},{pattern:/\bbiome\s+format\b/,lensId:"biome-format"},{pattern:/\bvitest\b/,lensId:"vitest"},{pattern:/\bjest\b/,lensId:"jest"}],slr=["eslint","typescript","test","prettier","knip","typedoc","alexandria"],alr={lint:"eslint",eslint:"eslint",typecheck:"typescript","type-check":"typescript",tsc:"typescript",test:"test",jest:"jest",vitest:"vitest",format:"prettier",prettier:"prettier",knip:"knip",unused:"knip",docs:"alexandria",alexandria:"alexandria",typedoc:"typedoc"},v7=class{static detectLensCommands(c){let f=new Map;for(let h of c)if(h.name.startsWith("lens:")){let S=h.name.split(":");if(S.length>=3){let k=S[1],R=S[2];f.has(k)||f.set(k,{lensId:k,operations:new Set}),f.get(k).operations.add(R),h.isLensCommand=!0,h.lensId=k,h.lensOperation=R}}return f.size===0&&this.applyFallbackDetection(c,f),f}static detectLensFromScriptContent(c){if(!c)return null;for(let{pattern:f,lensId:h}of ilr)if(f.test(c))return h;return null}static applyFallbackDetection(c,f){for(let h of c){let S=this.detectLensFromScriptContent(h.description);if(S||(S=alr[h.name]||null),S){f.has(S)||f.set(S,{lensId:S,operations:new Set});let k=h.name.includes("coverage")?"coverage":"check";f.get(S).operations.add(k),h.isLensCommand=!0,h.lensId=S,h.lensOperation=k}}}static calculateMetrics(c,f){let h={};for(let[S]of c){let k=nlr[S];if(k){let R=f?.get(S);R!==void 0&&(h[k]=R)}}return h}static getAvailableLenses(c){return Array.from(c.keys())}static getMissingLenses(c){let f=new Set(c.keys());return slr.filter(h=>!f.has(h))}static calculateQualityProfile(c,f){let h=this.detectLensCommands(c),S=this.calculateMetrics(h,f),k=this.getAvailableLenses(h),R=this.getMissingLenses(h);return{hexagon:S,availableLenses:k,missingLenses:R}}static calculateLensReadiness(c,f,h,S){let k={};for(let[R,X]of Object.entries(b_t.ALL_LENS_REQUIREMENTS))k[R]=this.checkLensRequirements(X,c,f,h,S);return k}static checkLensRequirements(c,f,h,S,k){let R=[],X=[],ae={...f,...h};for(let $ of c.devDependencies){let Qe=h[$.name]||f[$.name],Le=!!Qe;R.push({requirement:$,satisfied:Le,foundValue:Qe}),!Le&&$.critical!==!1&&X.push($)}for(let $ of c.scripts){let Qe=S.find(Je=>Je.name===$.name),Le=!!Qe;R.push({requirement:$,satisfied:Le,foundValue:Qe?.description||Qe?.command}),!Le&&$.critical!==!1&&X.push($)}for(let $ of c.configs){let Qe=!1,Le;if(k){let Je=c.lensId,Ct=k[Je];if(Ct?.exists&&(Qe=!0,Le=Ct.path),!Qe&&$.alternatives)for(let Bt of $.alternatives){for(let[,hr]of Object.entries(k))if(hr?.exists&&hr.path&&this.matchesConfigPattern(hr.path,Bt)){Qe=!0,Le=hr.path;break}if(Qe)break}}R.push({requirement:$,satisfied:Qe,foundValue:Le}),!Qe&&$.critical!==!1&&X.push($)}let pe=X.filter($=>$.critical!==!1).length===0,xe=!pe&&R.some($=>$.satisfied);return{lensId:c.lensId,displayName:c.displayName,ready:pe,partial:xe,checks:R,missing:X}}static matchesConfigPattern(c,f){let h=c.split("/").pop()||c;return f.includes("*")?new RegExp("^"+f.replace(/\./g,"\\.").replace(/\*/g,".*")+"$").test(h):h===f}};var XR=class{manifestFileName="package.json";packageType="node";canParse(c){return c.endsWith("package.json")}parseContent(c){try{return JSON.parse(c)}catch{return null}}extractPackageData(c,f){let h;f==="package.json"?h="":f.endsWith("/package.json")?h=f.slice(0,-13):h=f;let S=this.extractCommands(c,h),k;if(c.author){if(typeof c.author=="string")k=c.author;else if(c.author.name){let X=c.author.name;c.author.email&&(X+=` <${c.author.email}>`),c.author.url&&(X+=` (${c.author.url})`),k=X}}let R;return c.repository&&(typeof c.repository=="string"?R=c.repository:c.repository.url&&(R=c.repository.url)),{name:c.name||"unnamed",version:c.version,path:h,manifestPath:f,packageManager:"unknown",dependencies:c.dependencies||{},devDependencies:c.devDependencies||{},peerDependencies:c.peerDependencies||{},description:c.description,license:c.license,author:k,repository:R,homepage:c.homepage,keywords:c.keywords,isMonorepoRoot:!!c.workspaces,isWorkspace:!1,parentPackage:void 0,availableCommands:S}}extractCommands(c,f){let h=[];return c.scripts&&Object.entries(c.scripts).forEach(([k,R])=>{h.push({name:k,command:`npm run ${k}`,description:R.length>50?R.substring(0,47)+"...":R,type:"script",workingDirectory:f})}),[{name:"install",command:"npm install",description:"Install dependencies"},{name:"ci",command:"npm ci",description:"Clean install dependencies"},{name:"update",command:"npm update",description:"Update dependencies"}].forEach(k=>{h.push({...k,type:"standard",workingDirectory:f})}),h}detectWorkspaces(c){return Array.isArray(c.workspaces)?c.workspaces:c.workspaces&&typeof c.workspaces=="object"&&"packages"in c.workspaces&&c.workspaces.packages||null}detectPackageManager(c,f){if(c.packageManager){let h=c.packageManager.split("@")[0];if(["npm","yarn","pnpm","bun"].includes(h))return h}return f.some(h=>h.endsWith("bun.lockb")||h.endsWith("bun.lock"))?"bun":f.some(h=>h.endsWith("yarn.lock"))?"yarn":f.some(h=>h.endsWith("pnpm-lock.yaml"))?"pnpm":(f.some(h=>h.endsWith("package-lock.json")),"npm")}detectConfigs(c,f,h){let S={},k={knip:["knip.json","knip.jsonc",".knip.json","knip.config.js","knip.config.ts","knip.config.mjs"],eslint:[".eslintrc",".eslintrc.js",".eslintrc.json",".eslintrc.yml",".eslintrc.yaml","eslint.config.js","eslint.config.mjs",".eslintrc.cjs"],prettier:[".prettierrc",".prettierrc.js",".prettierrc.json",".prettierrc.yml",".prettierrc.yaml","prettier.config.js",".prettierrc.toml"],typescript:["tsconfig.json","tsconfig.base.json"],jest:["jest.config.js","jest.config.ts","jest.config.mjs","jest.config.cjs","jest.config.json"],vitest:["vitest.config.js","vitest.config.ts","vitest.config.mjs"],biome:["biome.json","biome.jsonc"],webpack:["webpack.config.js","webpack.config.ts","webpack.config.mjs"],vite:["vite.config.js","vite.config.ts","vite.config.mjs"],rollup:["rollup.config.js","rollup.config.ts","rollup.config.mjs"],babel:[".babelrc",".babelrc.js",".babelrc.json","babel.config.js","babel.config.json"],dockerfile:["Dockerfile","dockerfile","Dockerfile.dev","Dockerfile.prod"],gitignore:[".gitignore"],editorconfig:[".editorconfig"]},R=c==="."||c===""?"":c.endsWith("/")?c:c+"/";if(f.allFiles)for(let[X,ae]of Object.entries(k))for(let le of ae){let pe=R+le;if(f.allFiles.some($=>$.path===pe||$.relativePath===pe)){S[X]={path:pe,exists:!0,type:this.getConfigFileType(le)};break}}return h&&(h.eslintConfig&&(S.eslint={path:R+"package.json",exists:!0,type:"json",isInline:!0,inlineField:"eslintConfig"}),h.prettier&&(S.prettier={path:R+"package.json",exists:!0,type:"json",isInline:!0,inlineField:"prettier"}),h.jest&&(S.jest={path:R+"package.json",exists:!0,type:"json",isInline:!0,inlineField:"jest"}),h.babel&&(S.babel={path:R+"package.json",exists:!0,type:"json",isInline:!0,inlineField:"babel"}),h.vitest&&(S.vitest={path:R+"package.json",exists:!0,type:"json",isInline:!0,inlineField:"vitest"}),h.knip&&(S.knip={path:R+"package.json",exists:!0,type:"json",isInline:!0,inlineField:"knip"}),h.biome&&(S.biome={path:R+"package.json",exists:!0,type:"json",isInline:!0,inlineField:"biome"}),h.stylelint&&(S.stylelint={path:R+"package.json",exists:!0,type:"json",isInline:!0,inlineField:"stylelint"}),h.commitlint&&(S.commitlint={path:R+"package.json",exists:!0,type:"json",isInline:!0,inlineField:"commitlint"}),h["lint-staged"]&&(S["lint-staged"]={path:R+"package.json",exists:!0,type:"json",isInline:!0,inlineField:"lint-staged"})),S}getConfigFileType(c){return c.endsWith(".json")||c.endsWith(".jsonc")?"json":c.endsWith(".yml")||c.endsWith(".yaml")?"yaml":c.endsWith(".toml")?"toml":c.endsWith(".js")||c.endsWith(".mjs")||c.endsWith(".cjs")?"js":c.endsWith(".ts")||c.endsWith(".mts")||c.endsWith(".cts")?"ts":c.endsWith(".ini")?"ini":"custom"}detectDocsFolder(c,f,h){let S=["docs","documentation","doc"],k=c==="."||c===""?"":c;if(k&&!k.endsWith("/")&&(k+="/"),!f.allFiles)return;for(let le of S){let pe=k+le;if(f.allFiles.some($=>$.path?.toLowerCase().startsWith(pe.toLowerCase()+"/"))){let $=f.allFiles.find(Qe=>Qe.path?.toLowerCase().startsWith(pe.toLowerCase()+"/"))?.path;return $?$.substring(0,$.indexOf("/",k.length)).substring(k.length):le}}let R=new Map;for(let le of f.allFiles){if(!le.path||k!==""&&!le.path.startsWith(k))continue;let xe=(k===""?le.path:le.path.substring(k.length)).split("/");if(xe.length===2){let $=xe[0],Qe=xe[1];R.has($)||R.set($,{docFiles:0,totalFiles:0});let Le=R.get($);Le.totalFiles++,this.isDocumentationFile(Qe)&&Le.docFiles++}}let X,ae=.5;for(let[le,pe]of Array.from(R.entries()))if(pe.docFiles>=2){let xe=pe.docFiles/pe.totalFiles;xe>ae&&(ae=xe,X=le)}return X}isDocumentationFile(c){let f=c.toLowerCase();return[".md",".mdx",".rst",".txt",".adoc",".asciidoc"].some(R=>f.endsWith(R))?!0:[/^readme/i,/^changelog/i,/^changes/i,/^history/i,/^license/i,/^copying/i,/^install/i,/^usage/i,/^guide/i,/^tutorial/i,/^manual/i,/^faq/i,/^api/i,/^reference/i,/^spec/i,/^specification/i].some(R=>R.test(c))}},wke=class{manifestFileName="pyproject.toml";packageType="python";canParse(c){return c.endsWith("pyproject.toml")||c.endsWith("setup.py")||c.endsWith("requirements.txt")}parseContent(c){try{return GFe(c)}catch{return null}}extractPackageData(c,f){let h,S=f.split("/").pop()||"";f===S?h="":h=f.substring(0,f.lastIndexOf("/"));let k=c.tool?.poetry,R=c.project,X=k?.name||R?.name||"unnamed",ae=k?.version||R?.version,le={},pe={};if(k?.dependencies&&Object.entries(k.dependencies).forEach(([Cr,$n])=>{Cr!=="python"&&(le[Cr]=typeof $n=="string"?$n:JSON.stringify($n))}),k?.["dev-dependencies"]&&Object.entries(k["dev-dependencies"]).forEach(([Cr,$n])=>{pe[Cr]=typeof $n=="string"?$n:JSON.stringify($n)}),R?.dependencies&&Array.isArray(R.dependencies))try{let Cr=R.dependencies.join(`
|
|
982
|
-
`);(0,C_t.parsePipRequirementsFile)(Cr).forEach(Un=>{if(Un.type==="ProjectName"&&Un.name){let Yr="*";Un.versionSpec&&Un.versionSpec.length>0&&(Yr=Un.versionSpec[0].version||"*"),le[Un.name]=Yr}})}catch(Cr){console.warn("Failed to parse PEP 621 dependencies with pip-requirements-js, falling back to simple parsing:",Cr),R.dependencies.forEach($n=>{let Un=$n.trim(),Yr=Un.indexOf(" ");Yr>0?le[Un.substring(0,Yr)]="*":le[Un]="*"})}let xe=this.detectPythonPackageManager(c),$=k?.description||R?.description,Qe;k?.license?Qe=k.license:R?.license&&(Qe=typeof R.license=="string"?R.license:R.license.text);let Le,Je;k?.authors&&k.authors.length>0?(Le=k.authors,Je=k.authors[0]):R?.authors&&R.authors.length>0&&(Le=R.authors.map(Cr=>Cr.name&&Cr.email?`${Cr.name} <${Cr.email}>`:Cr.name||Cr.email||"").filter(Boolean),Je=Le[0]);let Ct,Bt;k?(Ct=k.repository,Bt=k.homepage):R?.urls&&(Ct=R.urls.repository||R.urls.Repository||R.urls.source||R.urls.Source,Bt=R.urls.homepage||R.urls.Homepage||R.urls.home||R.urls.Home);let hr=k?.keywords||R?.keywords;return{name:X,version:ae,path:h,manifestPath:f,packageManager:xe,dependencies:le,devDependencies:pe,peerDependencies:{},description:$,license:Qe,author:Je,authors:Le,repository:Ct,homepage:Bt,keywords:hr,isMonorepoRoot:!1,isWorkspace:!1,parentPackage:void 0,availableCommands:[]}}detectWorkspaces(c){return null}detectPackageManager(c,f){return this.detectPythonPackageManager(c)}detectPythonPackageManager(c){return c.tool?.poetry?"poetry":"pip"}detectDocsFolder(c,f,h){return new XR().detectDocsFolder(c,f,{})}},Pke=class{manifestFileName="Cargo.toml";packageType="cargo";canParse(c){return c.endsWith("Cargo.toml")}parseContent(c){try{return GFe(c)}catch{return null}}extractPackageData(c,f){let h=c.package;if(!h)return null;let S;f==="Cargo.toml"?S="":f.endsWith("/Cargo.toml")?S=f.slice(0,-11):S=f;let k={},R={};c.dependencies&&Object.entries(c.dependencies).forEach(([le,pe])=>{k[le]=typeof pe=="string"?pe:JSON.stringify(pe)}),c["dev-dependencies"]&&Object.entries(c["dev-dependencies"]).forEach(([le,pe])=>{R[le]=typeof pe=="string"?pe:JSON.stringify(pe)});let X=h.authors?.[0],ae=h.homepage||h.documentation;return{name:h.name||"unnamed",version:h.version,path:S,manifestPath:f,packageManager:"cargo",dependencies:k,devDependencies:R,peerDependencies:{},description:h.description,license:h.license,author:X,authors:h.authors,repository:h.repository,homepage:ae,keywords:h.keywords,isMonorepoRoot:!!c.workspace,isWorkspace:!1,parentPackage:void 0,availableCommands:[]}}detectWorkspaces(c){return c.workspace?.members||null}detectPackageManager(){return"cargo"}detectDocsFolder(c,f,h){return new XR().detectDocsFolder(c,f,{})}},YR=class{parsers=[new XR,new wke,new Pke];async discoverPackages(c,f){let h=[];if(!c.allFiles)return h;let S=c.allFiles.filter(le=>le.path?this.parsers.some(pe=>pe.canParse(le.path)):!1),k=c.allFiles.map(le=>le.path).filter(Boolean);for(let le of S){if(!le.path)continue;let pe=this.parsers.find(Yr=>Yr.canParse(le.path));if(!pe)continue;let xe=null;if(f)try{let Yr=await f(le.path);Yr&&(xe=pe.parseContent(Yr))}catch(Yr){console.warn(`Could not read or parse ${le.path}:`,Yr);continue}else{let Yr=le.path.split("/").slice(-2,-1)[0]||"unnamed";xe=this.createMinimalManifest(pe.packageType,Yr)}if(!xe)continue;let $=pe.extractPackageData(xe,le.path);if(!$){console.warn(`[PackageLayerModule] extractPackageData returned null for ${le.path}`,{content:xe,parser:pe.packageType});continue}let Qe=le.path.substring(0,le.path.lastIndexOf("/")),Le=k.filter(Yr=>Yr.startsWith(Qe)&&this.isLockFile(Yr));$.packageManager=pe.detectPackageManager(xe,Le),pe.packageType==="node"&&$.availableCommands&&$.packageManager&&$.packageManager!=="unknown"&&$.packageManager!=="npm"&&($.availableCommands=$.availableCommands.map(Yr=>{if(Yr.command.includes("npm ")){let jr=Yr.command;return $.packageManager==="yarn"?jr=jr.replace("npm run","yarn").replace("npm install","yarn install").replace("npm ci","yarn install --frozen-lockfile").replace("npm update","yarn upgrade"):$.packageManager==="pnpm"&&(jr=jr.replace("npm","pnpm")),{...Yr,command:jr}}return Yr}));let Je={id:`package-manifest-${$.path}`,name:pe.manifestFileName,patterns:[{type:"exact",pattern:le.path,description:`${pe.packageType} package manifest`}],matchedFiles:[le.path],fileCount:1},Ct;pe.detectConfigs&&(Ct=pe.detectConfigs($.path,c,xe));let Bt;pe.detectDocsFolder&&(Bt=pe.detectDocsFolder($.path,c,xe));let hr=$.availableCommands?v7.calculateQualityProfile($.availableCommands):void 0,Cr=v7.calculateLensReadiness($.dependencies,$.devDependencies,$.availableCommands||[],Ct),$n=hr?{...hr,lensReadiness:Cr}:{hexagon:{},availableLenses:[],missingLenses:[],lensReadiness:Cr},Un={id:`package-${pe.packageType}-${$.path.replace(/[^a-zA-Z0-9-]/g,"-")}`,name:$.name,type:pe.packageType,enabled:!0,derivedFrom:{fileSets:[Je],derivationType:"content",description:`${pe.packageType} package defined in ${pe.manifestFileName}`,contentExtraction:{method:"parse",parser:{format:pe.manifestFileName.endsWith(".json")?"json":"toml",paths:pe.packageType==="node"?[""]:pe.packageType==="python"?["tool.poetry","project"]:["package"]}}},packageData:$,configFiles:Ct,docsFolder:Bt,qualityMetrics:$n,pillar:"foundationHealth"};h.push(Un)}this.resolveWorkspaceRelationships(h);let R=h.find(le=>le.packageData.path===""||le.packageData.path==="."),{orchestrator:X}=this.detectMonorepoOrchestrator(k),ae=R?.packageData.isMonorepoRoot||X!=="none";if(R&&ae){X!=="none"&&!R.packageData.isMonorepoRoot&&(R.packageData.isMonorepoRoot=!0);let le=S.find($=>$.path==="package.json"||$.path==="./package.json"),pe;if(le&&f)try{let $=await f(le.path),Qe=JSON.parse($);pe=new XR().detectWorkspaces(Qe)||void 0}catch{}let xe=await this.buildMonorepoMetadata(k,pe,f,R.configFiles);xe&&(R.packageData.monorepoMetadata=xe)}return this.propagateRootConfigs(h,R),this.recalculateLensReadinessWithInheritance(h,R),h}createPackageLayersFromBoundaries(c){return c.map(f=>{let h={id:`package-manifest-${f.rootPath||"root"}`,name:"package.json",patterns:[{type:"exact",pattern:f.packageJsonPath,description:"Node.js package manifest"}],matchedFiles:[f.packageJsonPath],fileCount:1},S={name:f.packageData?.name||f.name,version:f.packageData?.version,path:f.rootPath||".",manifestPath:f.packageJsonPath,packageManager:"unknown",dependencies:{},devDependencies:{},peerDependencies:{},isMonorepoRoot:!!f.packageData?.workspaces,isWorkspace:!f.isRoot&&c.length>1,parentPackage:f.isRoot?void 0:"root"};return{id:`package-node-${f.id}`,name:S.name,type:"node",enabled:!0,derivedFrom:{fileSets:[h],derivationType:"content",description:"Node.js package defined in package.json"},packageData:S,pillar:"foundationHealth"}})}isLockFile(c){return["package-lock.json","yarn.lock","pnpm-lock.yaml","bun.lockb","bun.lock","poetry.lock","Pipfile.lock","Cargo.lock"].some(h=>c.endsWith(h))}resolveWorkspaceRelationships(c){let f=c.filter(h=>h.packageData.path==="."||h.packageData.path==="");c.forEach(h=>{if(h.packageData.path!=="."&&h.packageData.path!==""){h.packageData.isWorkspace=!0;let S=h.packageData.path.includes("/")?h.packageData.path.substring(0,h.packageData.path.lastIndexOf("/")):".",k=c.find(R=>R.packageData.path===S);k&&(h.packageData.parentPackage=k.packageData.name)}})}createMinimalManifest(c,f){switch(c){case"node":return{name:f,version:"0.0.0",dependencies:{},devDependencies:{}};case"python":return{project:{name:f,version:"0.0.0"}};case"cargo":return{package:{name:f,version:"0.0.0"}};default:return{}}}detectMonorepoOrchestrator(c){return c.includes("turbo.json")?{orchestrator:"turbo",configPath:"turbo.json"}:c.includes("nx.json")?{orchestrator:"nx",configPath:"nx.json"}:c.includes("lerna.json")?{orchestrator:"lerna",configPath:"lerna.json"}:c.includes("pnpm-workspace.yaml")?{orchestrator:"pnpm",configPath:"pnpm-workspace.yaml"}:c.includes("rush.json")?{orchestrator:"rush",configPath:"rush.json"}:{orchestrator:"none"}}parseTurboConfig(c){try{let f=JSON.parse(c),h=[],S=f.tasks||f.pipeline||{};for(let[k,R]of Object.entries(S)){let X=k.split("#"),ae=X.length>1?k:void 0,le=X.length>1?X[1]:k,pe=this.inferToolFromTaskName(le);h.push({name:le,tool:pe,filter:ae})}return h}catch{return[]}}parseNxConfig(c){try{let f=JSON.parse(c),h=[];if(f.targetDefaults)for(let[S,k]of Object.entries(f.targetDefaults)){let R=this.inferToolFromTaskName(S);h.push({name:S,tool:R})}return h}catch{return[]}}inferToolFromTaskName(c){return{lint:"eslint",typecheck:"typescript","type-check":"typescript",tsc:"typescript",test:"jest",format:"prettier",prettier:"prettier",build:"build",dev:"dev",start:"start",check:"biome"}[c.toLowerCase()]}async buildMonorepoMetadata(c,f,h,S){let{orchestrator:k,configPath:R}=this.detectMonorepoOrchestrator(c);if(k==="none"&&!f)return;let X={orchestrator:k,orchestratorConfigPath:R,workspacePatterns:f};if(R&&h)try{let xe=await h(R);k==="turbo"?X.definedTasks=this.parseTurboConfig(xe):k==="nx"&&(X.definedTasks=this.parseNxConfig(xe))}catch{}if(S){let xe=[];for(let[$,Qe]of Object.entries(S))Qe&&Qe.exists&&xe.push({tool:$,configPath:Qe.path,isInline:Qe.isInline});xe.length>0&&(X.rootConfigs=xe)}let{role:ae,hasSourceCode:le,sourceDirs:pe}=this.detectRootRole(c);return X.rootRole=ae,X.rootHasSourceCode=le,pe.length>0&&(X.rootSourceDirs=pe),X}detectRootRole(c){let f=["src","lib","app"],h=["scripts","e2e","test","tests","tools","__tests__"],S=[".ts",".tsx",".js",".jsx",".mjs",".cjs",".py",".rs",".go"],k=[],R=[];for(let pe of c)if(!(pe.startsWith("packages/")||pe.startsWith("apps/")||pe.startsWith("libs/")||pe.startsWith("node_modules/"))){for(let xe of f)pe.startsWith(`${xe}/`)&&S.some(Qe=>pe.endsWith(Qe))&&!k.includes(xe)&&k.push(xe);for(let xe of h)pe.startsWith(`${xe}/`)&&S.some(Qe=>pe.endsWith(Qe))&&!R.includes(xe)&&R.push(xe)}let X=k.length>0,ae=R.length>0,le=[...k,...R];return X?{role:"application",hasSourceCode:!0,sourceDirs:le}:ae?{role:"hybrid",hasSourceCode:!0,sourceDirs:le}:{role:"orchestrator",hasSourceCode:!1,sourceDirs:[]}}propagateRootConfigs(c,f){if(!f?.configFiles||!f.packageData.monorepoMetadata)return;let h=f.configFiles;for(let S of c)if(!(S.packageData.path===""||S.packageData.path===".")){S.configFiles||(S.configFiles={});for(let[k,R]of Object.entries(h)){if(!R||!R.exists)continue;let X=S.configFiles[k];(!X||!X.exists)&&(S.configFiles[k]={...R,isInherited:!0,inheritedFrom:"",inheritanceType:"root"})}}}recalculateLensReadinessWithInheritance(c,f){if(!(!f?.configFiles||!f.packageData.monorepoMetadata))for(let h of c){if(h.packageData.path===""||h.packageData.path==="."||!(h.configFiles&&Object.values(h.configFiles).some(R=>R?.isInherited)))continue;let k=v7.calculateLensReadiness(h.packageData.dependencies,h.packageData.devDependencies,h.packageData.availableCommands||[],h.configFiles);for(let[R,X]of Object.entries(k)){let ae=h.qualityMetrics?.lensReadiness?.[R];if(X.ready&&ae&&!ae.ready){X.readyViaInheritance=!0;let le=X.checks.filter(pe=>pe.satisfied?h.configFiles?.[R]?.isInherited&&pe.requirement.type==="config":!1).length;le>0&&(X.inheritedChecks=le)}}h.qualityMetrics&&(h.qualityMetrics.lensReadiness=k)}}};var B1=jm(lpt(),1);var Dpt=jm(qoe(),1),$4={basename:_=>_.split("/").pop()||"",join:(..._)=>_.filter(f=>f).join("/").replace(/\/+/g,"/"),relative:(_,c)=>!_||_==="."?c:c.startsWith(_+"/")?c.slice(_.length+1):c===_?".":c,dirname:_=>{let c=_.lastIndexOf("/");return c>0?_.slice(0,c):""},extname:_=>{let c=_.lastIndexOf(".");return c>0?_.slice(c):""}},sM=class{adapter;filterStats={totalFiltered:0,filteredByLayer:{},examples:[],filteredByDirectory:{}};constructor(c){this.adapter=c}async buildFileSystemTreeFromPath(c,f,h){console.time("[FilesystemService] Total build time"),this.filterStats={totalFiltered:0,filteredByLayer:{},examples:[],filteredByDirectory:{}};let S=f||[],k=h?.enableInverseFiltering||!1;if(!this.adapter){let Cr={path:c,name:c.split("/").pop()||c,children:[],fileCount:0,totalSize:0,depth:0,relativePath:"."};return{sha:"",root:Cr,allFiles:[],allDirectories:[Cr],stats:{totalFiles:0,totalDirectories:1,totalSize:0,maxDepth:0},metadata:{id:`fs-${Date.now()}`,timestamp:new Date,sourceType:"filesystem",sourceInfo:{path:c}},filterStats:this.filterStats,appliedFilters:S,inverseMatches:k?[]:void 0}}console.time("[FilesystemService] Build file tree");let R=[],X;for(let Cr of S)Cr.enabled&&Cr.filterData?.excludedPatterns&&(R.push(...Cr.filterData.excludedPatterns.map($n=>$n.pattern)),Cr.filterData.sourceDirectory&&(X=Cr.filterData.sourceDirectory));let ae=await this.adapter.buildFilteredFileTree(c,R,X),le=ae.paths,pe=ae.stats,xe=this.createIgnoreInstances(S);for(let Cr of le)this.shouldIncludeFile(Cr,xe,S)||this.filterStats.totalFiltered++;console.timeEnd("[FilesystemService] Build file tree"),console.log(`[FilesystemService] Found ${le.length} paths after filtering`),console.time("[FilesystemService] Convert to tree structure");let{allFiles:$,allDirectories:Qe,rootDir:Le}=await this.convertPathsToTree(le,c,pe);console.timeEnd("[FilesystemService] Convert to tree structure");let Je=[];k&&(Je=await this.findInverseMatches(c,xe,S));let Ct=$.reduce((Cr,$n)=>Cr+($n.size||0),0),Bt=Math.max(...Qe.map(Cr=>Cr.depth||0));S.forEach(Cr=>{Cr.enabled&&this.filterStats.filteredByLayer[Cr.id]&&(Cr.filterData.stats||(Cr.filterData.stats={totalFiltered:0,bytesExcluded:0}),Cr.filterData.stats.totalFiltered=this.filterStats.filteredByLayer[Cr.id])});let hr={sha:"",root:Le||{path:".",name:$4.basename(c)||"root",children:[],fileCount:0,totalSize:0,depth:0,relativePath:"."},allFiles:$,allDirectories:Qe,stats:{totalFiles:$.length,totalDirectories:Qe.length,totalSize:Ct,maxDepth:Bt},metadata:{id:`fs-${Date.now()}`,timestamp:new Date,sourceType:"filesystem",sourceInfo:{path:c}},filterStats:this.filterStats,appliedFilters:S,inverseMatches:Je};return console.timeEnd("[FilesystemService] Total build time"),hr}createIgnoreInstances(c){let f=new Map;for(let h of c){if(!h.enabled||!h.filterData?.excludedPatterns)continue;let S=h.filterData.sourceDirectory||"",k=`${h.id}:${S}`,R=(0,Dpt.default)(),X=h.filterData.excludedPatterns.map(ae=>ae.pattern);R.add(X),f.set(k,{ignore:R,sourceDirectory:S,filterId:h.id,filterName:h.name})}return f}shouldIncludeFile(c,f,h){for(let[,{ignore:S,sourceDirectory:k,filterId:R,filterName:X}]of f){if(k!==""&&!c.startsWith(k+"/")&&c!==k)continue;let ae=c;if(k!==""&&c.startsWith(k+"/")&&(ae=c.slice(k.length+1)),!(!ae||ae===".")&&S.ignores(ae)){this.filterStats.totalFiltered++,this.filterStats.filteredByLayer[R]=(this.filterStats.filteredByLayer[R]||0)+1;let le=$4.dirname(c)||".";return this.filterStats.filteredByDirectory[le]||(this.filterStats.filteredByDirectory[le]={count:0,reasons:new Set}),this.filterStats.filteredByDirectory[le].count++,this.filterStats.filteredByDirectory[le].reasons.add(X),!1}}return!0}async convertPathsToTree(c,f,h){let S=[],k=[],R=new Map,X=h||new Map;if(!h&&this.adapter&&"getFileStats"in this.adapter){let le=c.map(async pe=>{try{let xe=$4.join(f,pe),$=await this.adapter.getFileStats(xe);$&&X.set(pe,{size:$.size||0,lastModified:$.lastModified||new Date,isDirectory:$.isDirectory||!1})}catch{}});await Promise.all(le)}for(let le of c){let pe=X.get(le);if(pe?.isDirectory||le.endsWith("/")){let $={path:le||".",name:$4.basename(le)||"root",children:[],fileCount:0,totalSize:0,depth:le.split("/").length-1,relativePath:le||"."};k.push($),R.set(le,$)}else{let $={path:le,name:$4.basename(le),extension:$4.extname(le).toLowerCase(),size:pe?.size||0,lastModified:pe?.lastModified||new Date,isDirectory:!1,relativePath:le};S.push($)}}let ae=R.get(".")||R.get("")||{path:".",name:$4.basename(f)||"root",children:[],fileCount:S.length,totalSize:S.reduce((le,pe)=>le+(pe.size||0),0),depth:0,relativePath:"."};return{allFiles:S,allDirectories:k,rootDir:ae}}async findInverseMatches(c,f,h){console.log("[FilesystemService] Running inverse filter analysis...");let S=[];if(!this.adapter)return[];let R=(await this.adapter.buildFilteredFileTree(c)).paths;console.log(`[FilesystemService] Found ${R.length} total paths for inverse analysis`);for(let X of R){let ae=[];for(let[,{ignore:le,sourceDirectory:pe,filterName:xe}]of f){if(pe!==""&&!X.startsWith(pe+"/")&&X!==pe)continue;let $=X;pe!==""&&X.startsWith(pe+"/")&&($=X.slice(pe.length+1)),!(!$||$===".")&&le.ignores($)&&ae.push(xe)}ae.length>0&&S.push({path:X,matchedFilters:ae})}return console.log(`[FilesystemService] Inverse analysis complete: ${S.length} files matched filters`),S}getFilterStats(){return{...this.filterStats}}getEmptyTree(c){let f={path:".",name:$4.basename(c)||"root",children:[],fileCount:0,totalSize:0,depth:0,relativePath:"."};return{sha:"",root:f,allFiles:[],allDirectories:[f],stats:{totalFiles:0,totalDirectories:1,totalSize:0,maxDepth:0},metadata:{id:`fs-${Date.now()}`,timestamp:new Date,sourceType:"filesystem",sourceInfo:{path:c}},filterStats:this.filterStats,appliedFilters:[],inverseMatches:[]}}};var TC=jm(require("fs/promises"),1),f6e=jm(require("path"),1),bpt=jm(qoe(),1),v$=class{async readFile(c){try{return{content:await TC.readFile(c,"utf-8")}}catch{return null}}async fileExists(c){try{return await TC.access(c),!0}catch{return!1}}async isDirectory(c){try{return(await TC.stat(c)).isDirectory()}catch{return!1}}async readDirectory(c){try{return await TC.readdir(c)}catch{return[]}}async getFileStats(c){try{let f=await TC.stat(c);return{size:f.size,isDirectory:f.isDirectory(),lastModified:f.mtime}}catch{return null}}async buildFilteredFileTree(c,f,h){let S=[],k=new Map,R=f&&f.length>0?(0,bpt.default)().add(f):null,X=async(ae,le="")=>{try{let pe=await TC.readdir(ae,{withFileTypes:!0});for(let xe of pe){let $=f6e.join(ae,xe.name),Qe=le?f6e.join(le,xe.name):xe.name;if(!(R&&R.ignores(Qe))&&!(xe.isDirectory()&&this.shouldSkipDirectory(xe.name)))if(xe.isDirectory()){S.push(Qe+"/");let Le=await TC.stat($);k.set(Qe+"/",{size:0,isDirectory:!0,lastModified:Le.mtime}),await X($,Qe)}else{S.push(Qe);let Le=await TC.stat($);k.set(Qe,{size:Le.size,isDirectory:!1,lastModified:Le.mtime})}}}catch(pe){console.warn(`Error walking directory ${ae}:`,pe)}};return await X(c),{paths:S,stats:k}}shouldSkipDirectory(c){return["node_modules",".git","dist","build","coverage",".next",".turbo",".cache","tmp",".vscode",".idea"].includes(c)}};var ffr=jm(qoe(),1);var jT=jm(require("path")),G4=jm(require("fs/promises")),_6e=class{constructor(c){this.basePath=c}async readFile(c){try{let f=jT.isAbsolute(c)?c:jT.join(this.basePath,c);return{content:await G4.readFile(f,"utf-8")}}catch(f){return console.error(`[CLIFileSystemAdapter] Failed to read ${c}:`,f),null}}async fileExists(c){try{let f=jT.isAbsolute(c)?c:jT.join(this.basePath,c);return await G4.access(f),!0}catch{return!1}}async readDirectory(c){try{let f=jT.isAbsolute(c)?c:jT.join(this.basePath,c);return await G4.readdir(f)}catch(f){return console.error(`[CLIFileSystemAdapter] Failed to read directory ${c}:`,f),[]}}async isDirectory(c){try{let f=jT.isAbsolute(c)?c:jT.join(this.basePath,c);return(await G4.stat(f)).isDirectory()}catch{return!1}}buildFilteredFileTree(c,f,h){return Promise.resolve({paths:[]})}},E7=class{constructor(){this.packageModule=new YR}async extractPackages(c,f){try{let h=new _6e(f),S=async R=>(await h.readFile(R))?.content||"",k=await this.packageModule.discoverPackages(c,S);return console.info(`[RepositoryScanner] Found ${k.length} packages in ${f}`),k}catch(h){return console.error("[RepositoryScanner] Failed to extract packages:",h),[]}}};var qp=jm(woe());var p6e=require("child_process"),d6e=require("stream"),Uoe=class{constructor(){this.type="node"}async execute(c,f=[],h={}){let S=Date.now();return new Promise(k=>{let R="",X="",le={...h.env||process.env};delete le.NODE_OPTIONS,delete le.TS_NODE_PROJECT,delete le.TS_NODE_TRANSPILE_ONLY;let pe=(0,p6e.spawn)(c,f,{cwd:h.cwd,env:le,shell:!0});pe.stdout&&pe.stdout.on("data",$=>{R+=$.toString()}),pe.stderr&&pe.stderr.on("data",$=>{X+=$.toString()});let xe;h.timeout&&(xe=setTimeout(()=>{pe.kill("SIGTERM")},h.timeout)),pe.on("error",$=>{xe&&clearTimeout(xe),k({stdout:R,stderr:X||$.message,exitCode:1,duration:Date.now()-S,command:c,args:f,error:$})}),pe.on("close",$=>{xe&&clearTimeout(xe),k({stdout:R,stderr:X,exitCode:$??0,duration:Date.now()-S,command:c,args:f})})})}stream(c,f=[],h={}){let k={...h.env||process.env};delete k.NODE_OPTIONS,delete k.TS_NODE_PROJECT,delete k.TS_NODE_TRANSPILE_ONLY;let R=(0,p6e.spawn)(c,f,{cwd:h.cwd,env:k,shell:!0}),X=new Promise(ae=>{let le="",pe="",xe=Date.now();R.stdout&&R.stdout.on("data",$=>{le+=$.toString()}),R.stderr&&R.stderr.on("data",$=>{pe+=$.toString()}),R.on("close",$=>{ae({stdout:le,stderr:pe,exitCode:$??0,duration:Date.now()-xe,command:c,args:f})}),R.on("error",$=>{ae({stdout:le,stderr:pe||$.message,exitCode:1,duration:Date.now()-xe,command:c,args:f,error:$})})});return{stdout:R.stdout||new d6e.Readable({read(){}}),stderr:R.stderr||new d6e.Readable({read(){}}),exitPromise:X,kill:()=>{R.kill("SIGTERM")}}}async isAvailable(c){try{let f=["--version"];return(await this.execute(c,f,{timeout:5e3})).exitCode===0}catch{return!1}}};var zoe=class{constructor(){this.executor=new Uoe;let c=new v$;this.filesystemService=new sM(c),this.sourceFilesCache=new Map,this.lenses=new Map,this.initializeLenses()}initializeLenses(){console.log("[QualityLensService] Initializing lenses...");let c=new qp.ESLintLens(this.executor);this.lenses.set("eslint",c),this.lenses.set("lint",c);let f=new qp.JestLens(this.executor);this.lenses.set("jest",f),this.lenses.set("test",f);let h=new qp.BunTestLens(this.executor);this.lenses.set("bun-test",h),this.lenses.set("bun",h);let S=new qp.VitestLens(this.executor);this.lenses.set("vitest",S),this.lenses.set("typescript",null),this.lenses.set("typecheck",null),this.lenses.set("tsc",null),this.lenses.set("knip",null),this.lenses.set("deadcode",null);let k=new qp.PrettierLens(this.executor);this.lenses.set("prettier",k),this.lenses.set("format",k);let R=new qp.BiomeLens(this.executor);R.setMode("lint"),this.lenses.set("biome-lint",R),this.lenses.set("biome",R);let X=new qp.BiomeLens(this.executor);X.setMode("format"),this.lenses.set("biome-format",X);let ae=new qp.GitLens(this.executor);this.lenses.set("git",ae);let le=new qp.AlexandriaLens(this.executor);this.lenses.set("alexandria",le),this.lenses.set("docs",le)}async checkIfBunTestRunner(c,f){try{let h=await import("fs/promises"),k=(await import("path")).join(c,"package.json"),R=await h.readFile(k,"utf-8"),X=JSON.parse(R),ae=f.replace(/^(npm|yarn|pnpm)\s+run\s+/,"").split(" ")[0]||"test",le=X.scripts?.[ae];return!!(le&&(le.startsWith("bun test")||le.startsWith("bun run test")))}catch{return!1}}async discoverSourceFiles(c,f){let h=`${c}:${Array.from(f).join(",")}`;if(this.sourceFilesCache.has(h))return this.sourceFilesCache.get(h);try{let k=(await this.filesystemService.buildFileSystemTreeFromPath(c)).allFiles.filter(R=>f.has(R.extension)).map(R=>R.relativePath);return this.sourceFilesCache.set(h,k),console.log(`[QualityLensService] Discovered ${k.length} source files in ${c}`),k}catch(S){return console.warn(`[QualityLensService] Failed to discover source files in ${c}:`,S),[]}}async getLensForExecution(c,f,h){let S=c.toLowerCase();if(["typescript","typecheck","tsc"].includes(S)){let k=await this.discoverSourceFiles(f,qp.TS_SOURCE_EXTENSIONS);return new qp.TypeScriptLens(this.executor,{sourceFiles:k})}if(["knip","deadcode"].includes(S)){let k=await this.discoverSourceFiles(f,qp.SOURCE_EXTENSIONS);return new qp.KnipLens(this.executor,{sourceFiles:k})}return["test","jest"].includes(S)?h&&h.includes("bun test")?(console.log("[QualityLensService] Detected Bun test runner (from command)"),this.lenses.get("bun-test")||null):await this.checkIfBunTestRunner(f,h||"test")?(console.log("[QualityLensService] Detected Bun test runner (from package.json)"),this.lenses.get("bun-test")||null):this.lenses.get("jest")||null:["bun-test","bun"].includes(S)?this.lenses.get("bun-test")||null:S==="biome-lint"?(console.log("[QualityLensService] Using Biome lint lens"),this.lenses.get("biome-lint")||null):S==="biome-format"?(console.log("[QualityLensService] Using Biome format lens"),this.lenses.get("biome-format")||null):this.lenses.get(S)||null}async executeTool(c){let f=Date.now();if(!c.packageLayer||!c.packageCommand)throw new Error("packageLayer and packageCommand are required. Legacy execution has been removed.");return this.executeWithPackageLayer(c,f)}async executeWithPackageLayer(c,f){let{repoPath:h,packageLayer:S,packageCommand:k}=c;if(!S||!k)throw new Error("packageLayer and packageCommand are required for new execution path");let R=S.packageData.path||"",X=R?`${h}/${R}`:h;if(!k.isLensCommand||!k.lensId)return console.log(`[QualityLensService] Not a lens command, executing directly: ${k.name}`),this.executeNonLensCommand(c,k,X,f);let ae=await this.getLensForExecution(k.lensId,X,k.command);if(!ae)return console.warn(`[QualityLensService] No lens registered for: ${k.lensId}`),this.executeNonLensCommand(c,k,X,f);console.log(`[QualityLensService] Using ${ae.name} for command: ${k.name} (lensId: ${k.lensId})`);try{let{command:le,args:pe}=this.parseCommandString(k.command);ae.configure({cwd:X,tool:{name:k.lensId,command:le,args:pe,cwd:X,available:!0}});let xe=await ae.run(),{success:$,exitCode:Qe}=this.determineLensSuccess(xe);return{success:$,toolName:k.lensId,command:k.command,packagePath:R,exitCode:Qe,duration:Date.now()-f,stdout:xe.raw?.stdout||"",stderr:xe.raw?.stderr||xe.error?.message||"",lensResult:xe,qualityContext:{lensId:k.lensId,operation:k.lensOperation,availableLenses:S.qualityMetrics?.availableLenses,missingLenses:S.qualityMetrics?.missingLenses}}}catch(le){console.error("[QualityLensService] Error:",le);let pe=le instanceof Error?le:new Error(String(le));return this.createErrorResponse(k.lensId||k.name,k.command,R,pe,f)}}async executeNonLensCommand(c,f,h,S){let{command:k,args:R}=this.parseCommandString(f.command);try{let X=await this.executor.execute(k,R,{cwd:h});return{success:X.exitCode===0,toolName:f.name,command:f.command,packagePath:c.packageLayer?.packageData.path,exitCode:X.exitCode,duration:Date.now()-S,stdout:X.stdout,stderr:X.stderr}}catch(X){let ae=X instanceof Error?X:new Error(String(X));return this.createErrorResponse(f.name,f.command,c.packageLayer?.packageData.path,ae,S)}}parseCommandString(c){if(c.startsWith("npm run "))return{command:"npm",args:["run",...c.split(" ").slice(2)]};if(c.startsWith("yarn "))return{command:"yarn",args:c.split(" ").slice(1)};if(c.startsWith("pnpm "))return{command:"pnpm",args:c.split(" ").slice(1)};let f=c.split(" ");return{command:f[0]||"",args:f.slice(1)}}determineLensSuccess(c){let f=0;return c.raw?.exitCode!==void 0?f=c.raw.exitCode:(c.error||c.metrics?.issuesBySeverity?.error&&c.metrics.issuesBySeverity.error>0)&&(f=1),{success:f!==127,exitCode:f}}createErrorResponse(c,f,h,S,k){return{success:!1,toolName:c,command:f,packagePath:h,exitCode:1,duration:Date.now()-k,stdout:"",stderr:S.message||"Tool execution failed",error:S.message}}getAvailableLenses(){return Array.from(this.lenses.keys())}hasLensForTool(c){return this.lenses.has(c.toLowerCase())}};var Woe=class{constructor(){this.fileCountsByPackage=new Map}setFileTree(c){this.fileTree=c,this.calculateFileCountsPerPackage()}calculateFileCountsPerPackage(){if(!this.fileTree)return;this.fileCountsByPackage.clear();let c=new Set(["ts","tsx","js","jsx","mts","mjs","cts","cjs",".ts",".tsx",".js",".jsx",".mts",".mjs",".cts",".cjs"]);for(let f of this.fileTree.allFiles){let h=f.extension||"";if(!c.has(h)&&!c.has(h.replace(/^\./,"")))continue;let S=f.relativePath;if(S.includes(".test.")||S.includes(".spec.")||S.includes("__tests__")||S.includes("__mocks__")||S.endsWith(".config.ts")||S.endsWith(".config.js"))continue;let k=this.fileCountsByPackage.get("")||0;this.fileCountsByPackage.set("",k+1);let R=S.split("/"),X="";for(let ae=0;ae<R.length-1;ae++){let le=R[ae]??"";X=X?`${X}/${le}`:le;let pe=this.fileCountsByPackage.get(X)||0;this.fileCountsByPackage.set(X,pe+1)}}}getFileCountForPackage(c){return this.fileCountsByPackage.get(c||"")||0}mapLensToHexagonDimension(c){return{jest:"tests",vitest:"tests","bun-test":"tests",test:"tests",knip:"deadCode",deadcode:"deadCode",prettier:"formatting","biome-format":"formatting",format:"formatting",eslint:"linting","biome-lint":"linting",biome:"linting",lint:"linting",typescript:"types",typecheck:"types",tsc:"types",alexandria:"documentation"}[c.toLowerCase()]||null}getIssuePath(c){return c.file}findOwningPackage(c,f){let h,S=0;for(let k of f)k.path&&(c.startsWith(k.path+"/")||c===k.path)&&k.path.length>S&&(S=k.path.length,h=k);return h}distributeIssuesToPackages(c){let f=c.filter(R=>!!(R.packagePath&&R.packagePath!=="")).map(R=>({name:R.package,path:R.packagePath})).filter((R,X,ae)=>ae.findIndex(le=>le.path===R.path)===X);if(f.length===0)return c;let h=new Map,S=[];for(let R of c){if(R.packagePath&&R.packagePath!==""){S.push(R);continue}let X=R.result?.lensResult?.issues;if(!X||X.length===0){S.push(R);continue}let ae=[];for(let le of X){let pe=this.getIssuePath(le);if(!pe){ae.push(le);continue}let xe=this.findOwningPackage(pe,f);if(xe){let $=xe.path,Qe=h.get($);Qe||(Qe=new Map,h.set($,Qe));let Le=Qe.get(R.lens);Le||(Le=[],Qe.set(R.lens,Le));let Je=pe.slice(xe.path.length+1),Ct={...le,file:Je,originalPath:pe};Le.push(Ct)}else ae.push(le)}if(R.result?.lensResult){let le={...R,result:{...R.result,lensResult:{...R.result.lensResult,issues:ae,metrics:this.recalculateMetricsFromIssues(R.result.lensResult.metrics,ae)}}};S.push(le)}else S.push(R)}for(let[R,X]of h){let ae=f.find(le=>le.path===R);if(ae)for(let[le,pe]of X){let xe=S.findIndex($=>$.packagePath===R&&$.lens===le);if(xe>=0){let $=S[xe];if($?.result?.lensResult){let Le=[...$.result.lensResult.issues||[],...pe];S[xe]={...$,result:{...$.result,lensResult:{...$.result.lensResult,issues:Le,metrics:this.recalculateMetricsFromIssues($.result.lensResult.metrics,Le)}}}}}else{let $=c.find(Le=>Le.lens===le&&(!Le.packagePath||Le.packagePath==="")),Qe={lensName:le,tool:le,timestamp:Date.now(),success:!0,issues:pe,metrics:this.createMetricsFromIssues(pe)};S.push({package:ae.name,packagePath:ae.path,lens:le,command:$?.command||le,timestamp:$?.timestamp||Date.now(),result:{success:!0,toolName:le,command:$?.command||le,packagePath:ae.path,exitCode:pe.length>0?1:0,duration:0,stdout:"",stderr:"",lensResult:Qe}})}}}let k=c.filter(R=>(!R.packagePath||R.packagePath==="")&&R.result?.success);for(let R of k)for(let X of f){if(S.some(xe=>xe.packagePath===X.path&&xe.lens===R.lens))continue;let le=this.getFileCountForPackage(X.path);if(le===0)continue;let pe={lensName:R.lens,tool:R.lens,timestamp:Date.now(),success:!0,issues:[],metrics:{filesAnalyzed:le,totalIssues:0,issuesBySeverity:{error:0,warning:0,info:0,hint:0},executionTime:0},qualityScore:100};S.push({package:X.name,packagePath:X.path,lens:R.lens,command:R.command,timestamp:R.timestamp,result:{success:!0,toolName:R.lens,command:R.command,packagePath:X.path,exitCode:0,duration:0,stdout:"",stderr:"",lensResult:pe}})}return S}createMetricsFromIssues(c){let f={error:0,warning:0,info:0,hint:0};for(let S of c){let k=S.severity?.toLowerCase()||"warning";k in f&&f[k]++}return{filesAnalyzed:new Set(c.map(S=>this.getIssuePath(S)).filter(Boolean)).size||1,totalIssues:c.length,issuesBySeverity:f,executionTime:0}}recalculateMetricsFromIssues(c,f){let h=this.createMetricsFromIssues(f);return c?.custom&&(h.custom=c.custom),c?.executionTime&&(h.executionTime=c.executionTime),h}extractQualityScore(c){if(c.result?.lensResult?.qualityScore!==void 0&&c.result.lensResult.qualityScore!==null&&c.result.lensResult.qualityScore>0)return c.result.lensResult.qualityScore;if(!c.result?.success)return 0;let f=c.result?.lensResult?.metrics,h=c.result?.exitCode??0,S=this.mapLensToHexagonDimension(c.lens);if(S==="tests"){let xe=f?.custom;if(xe?.passRate!==void 0&&xe.passRate!==null)return Math.round(xe.passRate);if(h!==0&&(xe?.failedSuites&&xe.failedSuites>0||xe?.totalTests===0))return 0}if(S==="types"&&h===2&&(f?.filesAnalyzed??0)===0)return 0;let k=c.result?.lensResult?.issues||[];if(k.length===0&&h!==0&&(f?.filesAnalyzed??0)===0)return 0;if(k.length===0)return 100;let R=new Set(k.map(xe=>xe.file)).size,X=c.packagePath||"",ae=this.getFileCountForPackage(X);if(ae===0){let xe=c.result?.lensResult?.metrics?.filesAnalyzed||1,$=Math.max(0,xe-R);return Math.round($/xe*100)}let le=Math.max(0,ae-R);return Math.round(le/ae*100)}calculateHexagonMetrics(c){let f={tests:0,deadCode:0,formatting:0,linting:0,types:0,documentation:0};for(let h of c){let S=this.mapLensToHexagonDimension(h.lens);if(S){let k=this.extractQualityScore(h);S==="deadCode"&&(k=100-k),S==="deadCode"?f[S]=f[S]===0?k:Math.min(f[S],k):f[S]=Math.max(f[S],k)}}return f}getGitMetadata(){let c={};if(process.env.GITHUB_SHA&&(c.commit=process.env.GITHUB_SHA),process.env.GITHUB_REF){let f=process.env.GITHUB_REF;f.startsWith("refs/heads/")?c.branch=f.replace("refs/heads/",""):f.startsWith("refs/pull/")&&(c.branch=f)}if(process.env.GITHUB_REPOSITORY&&(c.repository=process.env.GITHUB_REPOSITORY),Object.keys(c).length!==0)return c}calculatePerPackageMetrics(c){let f=new Map;for(let S of c){let k=f.get(S.package);k?k.results.push(S):f.set(S.package,{path:S.packagePath,results:[S]})}let h=[];for(let[S,{path:k,results:R}]of f)h.push({name:S,path:k,hexagon:this.calculateHexagonMetrics(R)});return h}format(c){let f=this.getGitMetadata(),h=this.distributeIssuesToPackages(c),S=this.calculatePerPackageMetrics(h),k={metadata:{timestamp:new Date().toISOString(),version:"1.0.0",totalPackages:S.length,totalLenses:h.length,...f&&{git:f}},results:h.map(R=>({package:{name:R.package,path:R.packagePath},lens:{id:R.lens,command:R.command},execution:{success:R.result?.success??!1,exitCode:R.result?.exitCode,duration:R.result?.duration,timestamp:R.timestamp},issues:R.result?.lensResult?.issues||[],metrics:R.result?.lensResult?.metrics||{},coverage:R.result?.lensResult?.coverage,fileMetrics:R.result?.lensResult?.fileMetrics,qualityContext:R.result?.qualityContext||{},error:R.error}))};return S.length>0&&(k.qualityMetrics={packages:S}),JSON.stringify(k,null,2)}};var Cpt=(_=0)=>c=>`\x1B[${c+_}m`,Spt=(_=0)=>c=>`\x1B[${38+_};5;${c}m`,Ept=(_=0)=>(c,f,h)=>`\x1B[${38+_};2;${c};${f};${h}m`,rd={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},dPr=Object.keys(rd.modifier),dfr=Object.keys(rd.color),mfr=Object.keys(rd.bgColor),mPr=[...dfr,...mfr];function hfr(){let _=new Map;for(let[c,f]of Object.entries(rd)){for(let[h,S]of Object.entries(f))rd[h]={open:`\x1B[${S[0]}m`,close:`\x1B[${S[1]}m`},f[h]=rd[h],_.set(S[0],S[1]);Object.defineProperty(rd,c,{value:f,enumerable:!1})}return Object.defineProperty(rd,"codes",{value:_,enumerable:!1}),rd.color.close="\x1B[39m",rd.bgColor.close="\x1B[49m",rd.color.ansi=Cpt(),rd.color.ansi256=Spt(),rd.color.ansi16m=Ept(),rd.bgColor.ansi=Cpt(10),rd.bgColor.ansi256=Spt(10),rd.bgColor.ansi16m=Ept(10),Object.defineProperties(rd,{rgbToAnsi256:{value(c,f,h){return c===f&&f===h?c<8?16:c>248?231:Math.round((c-8)/247*24)+232:16+36*Math.round(c/255*5)+6*Math.round(f/255*5)+Math.round(h/255*5)},enumerable:!1},hexToRgb:{value(c){let f=/[a-f\d]{6}|[a-f\d]{3}/i.exec(c.toString(16));if(!f)return[0,0,0];let[h]=f;h.length===3&&(h=[...h].map(k=>k+k).join(""));let S=Number.parseInt(h,16);return[S>>16&255,S>>8&255,S&255]},enumerable:!1},hexToAnsi256:{value:c=>rd.rgbToAnsi256(...rd.hexToRgb(c)),enumerable:!1},ansi256ToAnsi:{value(c){if(c<8)return 30+c;if(c<16)return 90+(c-8);let f,h,S;if(c>=232)f=((c-232)*10+8)/255,h=f,S=f;else{c-=16;let X=c%36;f=Math.floor(c/36)/5,h=Math.floor(X/6)/5,S=X%6/5}let k=Math.max(f,h,S)*2;if(k===0)return 30;let R=30+(Math.round(S)<<2|Math.round(h)<<1|Math.round(f));return k===2&&(R+=60),R},enumerable:!1},rgbToAnsi:{value:(c,f,h)=>rd.ansi256ToAnsi(rd.rgbToAnsi256(c,f,h)),enumerable:!1},hexToAnsi:{value:c=>rd.ansi256ToAnsi(rd.hexToAnsi256(c)),enumerable:!1}}),rd}var gfr=hfr(),hE=gfr;var $oe=jm(require("node:process"),1),Tpt=jm(require("node:os"),1),m6e=jm(require("node:tty"),1);function AC(_,c=globalThis.Deno?globalThis.Deno.args:$oe.default.argv){let f=_.startsWith("-")?"":_.length===1?"-":"--",h=c.indexOf(f+_),S=c.indexOf("--");return h!==-1&&(S===-1||h<S)}var{env:nd}=$oe.default,Voe;AC("no-color")||AC("no-colors")||AC("color=false")||AC("color=never")?Voe=0:(AC("color")||AC("colors")||AC("color=true")||AC("color=always"))&&(Voe=1);function yfr(){if("FORCE_COLOR"in nd)return nd.FORCE_COLOR==="true"?1:nd.FORCE_COLOR==="false"?0:nd.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(nd.FORCE_COLOR,10),3)}function vfr(_){return _===0?!1:{level:_,hasBasic:!0,has256:_>=2,has16m:_>=3}}function Dfr(_,{streamIsTTY:c,sniffFlags:f=!0}={}){let h=yfr();h!==void 0&&(Voe=h);let S=f?Voe:h;if(S===0)return 0;if(f){if(AC("color=16m")||AC("color=full")||AC("color=truecolor"))return 3;if(AC("color=256"))return 2}if("TF_BUILD"in nd&&"AGENT_NAME"in nd)return 1;if(_&&!c&&S===void 0)return 0;let k=S||0;if(nd.TERM==="dumb")return k;if($oe.default.platform==="win32"){let R=Tpt.default.release().split(".");return Number(R[0])>=10&&Number(R[2])>=10586?Number(R[2])>=14931?3:2:1}if("CI"in nd)return["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some(R=>R in nd)?3:["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(R=>R in nd)||nd.CI_NAME==="codeship"?1:k;if("TEAMCITY_VERSION"in nd)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(nd.TEAMCITY_VERSION)?1:0;if(nd.COLORTERM==="truecolor"||nd.TERM==="xterm-kitty"||nd.TERM==="xterm-ghostty"||nd.TERM==="wezterm")return 3;if("TERM_PROGRAM"in nd){let R=Number.parseInt((nd.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(nd.TERM_PROGRAM){case"iTerm.app":return R>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(nd.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(nd.TERM)||"COLORTERM"in nd?1:k}function xpt(_,c={}){let f=Dfr(_,{streamIsTTY:_&&_.isTTY,...c});return vfr(f)}var bfr={stdout:xpt({isTTY:m6e.default.isatty(1)}),stderr:xpt({isTTY:m6e.default.isatty(2)})},Apt=bfr;function Fpt(_,c,f){let h=_.indexOf(c);if(h===-1)return _;let S=c.length,k=0,R="";do R+=_.slice(k,h)+c+f,k=h+S,h=_.indexOf(c,k);while(h!==-1);return R+=_.slice(k),R}function kpt(_,c,f,h){let S=0,k="";do{let R=_[h-1]==="\r";k+=_.slice(S,R?h-1:h)+c+(R?`\r
|
|
982
|
+
`);(0,C_t.parsePipRequirementsFile)(Cr).forEach(Un=>{if(Un.type==="ProjectName"&&Un.name){let Yr="*";Un.versionSpec&&Un.versionSpec.length>0&&(Yr=Un.versionSpec[0].version||"*"),le[Un.name]=Yr}})}catch(Cr){console.warn("Failed to parse PEP 621 dependencies with pip-requirements-js, falling back to simple parsing:",Cr),R.dependencies.forEach($n=>{let Un=$n.trim(),Yr=Un.indexOf(" ");Yr>0?le[Un.substring(0,Yr)]="*":le[Un]="*"})}let xe=this.detectPythonPackageManager(c),$=k?.description||R?.description,Qe;k?.license?Qe=k.license:R?.license&&(Qe=typeof R.license=="string"?R.license:R.license.text);let Le,Je;k?.authors&&k.authors.length>0?(Le=k.authors,Je=k.authors[0]):R?.authors&&R.authors.length>0&&(Le=R.authors.map(Cr=>Cr.name&&Cr.email?`${Cr.name} <${Cr.email}>`:Cr.name||Cr.email||"").filter(Boolean),Je=Le[0]);let Ct,Bt;k?(Ct=k.repository,Bt=k.homepage):R?.urls&&(Ct=R.urls.repository||R.urls.Repository||R.urls.source||R.urls.Source,Bt=R.urls.homepage||R.urls.Homepage||R.urls.home||R.urls.Home);let hr=k?.keywords||R?.keywords;return{name:X,version:ae,path:h,manifestPath:f,packageManager:xe,dependencies:le,devDependencies:pe,peerDependencies:{},description:$,license:Qe,author:Je,authors:Le,repository:Ct,homepage:Bt,keywords:hr,isMonorepoRoot:!1,isWorkspace:!1,parentPackage:void 0,availableCommands:[]}}detectWorkspaces(c){return null}detectPackageManager(c,f){return this.detectPythonPackageManager(c)}detectPythonPackageManager(c){return c.tool?.poetry?"poetry":"pip"}detectDocsFolder(c,f,h){return new XR().detectDocsFolder(c,f,{})}},Pke=class{manifestFileName="Cargo.toml";packageType="cargo";canParse(c){return c.endsWith("Cargo.toml")}parseContent(c){try{return GFe(c)}catch{return null}}extractPackageData(c,f){let h=c.package;if(!h)return null;let S;f==="Cargo.toml"?S="":f.endsWith("/Cargo.toml")?S=f.slice(0,-11):S=f;let k={},R={};c.dependencies&&Object.entries(c.dependencies).forEach(([le,pe])=>{k[le]=typeof pe=="string"?pe:JSON.stringify(pe)}),c["dev-dependencies"]&&Object.entries(c["dev-dependencies"]).forEach(([le,pe])=>{R[le]=typeof pe=="string"?pe:JSON.stringify(pe)});let X=h.authors?.[0],ae=h.homepage||h.documentation;return{name:h.name||"unnamed",version:h.version,path:S,manifestPath:f,packageManager:"cargo",dependencies:k,devDependencies:R,peerDependencies:{},description:h.description,license:h.license,author:X,authors:h.authors,repository:h.repository,homepage:ae,keywords:h.keywords,isMonorepoRoot:!!c.workspace,isWorkspace:!1,parentPackage:void 0,availableCommands:[]}}detectWorkspaces(c){return c.workspace?.members||null}detectPackageManager(){return"cargo"}detectDocsFolder(c,f,h){return new XR().detectDocsFolder(c,f,{})}},YR=class{parsers=[new XR,new wke,new Pke];async discoverPackages(c,f){let h=[];if(!c.allFiles)return h;let S=c.allFiles.filter(le=>le.path?this.parsers.some(pe=>pe.canParse(le.path)):!1),k=c.allFiles.map(le=>le.path).filter(Boolean);for(let le of S){if(!le.path)continue;let pe=this.parsers.find(Yr=>Yr.canParse(le.path));if(!pe)continue;let xe=null;if(f)try{let Yr=await f(le.path);Yr&&(xe=pe.parseContent(Yr))}catch(Yr){console.warn(`Could not read or parse ${le.path}:`,Yr);continue}else{let Yr=le.path.split("/").slice(-2,-1)[0]||"unnamed";xe=this.createMinimalManifest(pe.packageType,Yr)}if(!xe)continue;let $=pe.extractPackageData(xe,le.path);if(!$){console.warn(`[PackageLayerModule] extractPackageData returned null for ${le.path}`,{content:xe,parser:pe.packageType});continue}let Qe=le.path.substring(0,le.path.lastIndexOf("/")),Le=k.filter(Yr=>Yr.startsWith(Qe)&&this.isLockFile(Yr));$.packageManager=pe.detectPackageManager(xe,Le),pe.packageType==="node"&&$.availableCommands&&$.packageManager&&$.packageManager!=="unknown"&&$.packageManager!=="npm"&&($.availableCommands=$.availableCommands.map(Yr=>{if(Yr.command.includes("npm ")){let jr=Yr.command;return $.packageManager==="yarn"?jr=jr.replace("npm run","yarn").replace("npm install","yarn install").replace("npm ci","yarn install --frozen-lockfile").replace("npm update","yarn upgrade"):$.packageManager==="pnpm"&&(jr=jr.replace("npm","pnpm")),{...Yr,command:jr}}return Yr}));let Je={id:`package-manifest-${$.path}`,name:pe.manifestFileName,patterns:[{type:"exact",pattern:le.path,description:`${pe.packageType} package manifest`}],matchedFiles:[le.path],fileCount:1},Ct;pe.detectConfigs&&(Ct=pe.detectConfigs($.path,c,xe));let Bt;pe.detectDocsFolder&&(Bt=pe.detectDocsFolder($.path,c,xe));let hr=$.availableCommands?v7.calculateQualityProfile($.availableCommands):void 0,Cr=v7.calculateLensReadiness($.dependencies,$.devDependencies,$.availableCommands||[],Ct),$n=hr?{...hr,lensReadiness:Cr}:{hexagon:{},availableLenses:[],missingLenses:[],lensReadiness:Cr},Un={id:`package-${pe.packageType}-${$.path.replace(/[^a-zA-Z0-9-]/g,"-")}`,name:$.name,type:pe.packageType,enabled:!0,derivedFrom:{fileSets:[Je],derivationType:"content",description:`${pe.packageType} package defined in ${pe.manifestFileName}`,contentExtraction:{method:"parse",parser:{format:pe.manifestFileName.endsWith(".json")?"json":"toml",paths:pe.packageType==="node"?[""]:pe.packageType==="python"?["tool.poetry","project"]:["package"]}}},packageData:$,configFiles:Ct,docsFolder:Bt,qualityMetrics:$n,pillar:"foundationHealth"};h.push(Un)}this.resolveWorkspaceRelationships(h);let R=h.find(le=>le.packageData.path===""||le.packageData.path==="."),{orchestrator:X}=this.detectMonorepoOrchestrator(k),ae=R?.packageData.isMonorepoRoot||X!=="none";if(R&&ae){X!=="none"&&!R.packageData.isMonorepoRoot&&(R.packageData.isMonorepoRoot=!0);let le=S.find($=>$.path==="package.json"||$.path==="./package.json"),pe;if(le&&f)try{let $=await f(le.path),Qe=JSON.parse($);pe=new XR().detectWorkspaces(Qe)||void 0}catch{}let xe=await this.buildMonorepoMetadata(k,pe,f,R.configFiles);xe&&(R.packageData.monorepoMetadata=xe)}return this.propagateRootConfigs(h,R),this.recalculateLensReadinessWithInheritance(h,R),h}createPackageLayersFromBoundaries(c){return c.map(f=>{let h={id:`package-manifest-${f.rootPath||"root"}`,name:"package.json",patterns:[{type:"exact",pattern:f.packageJsonPath,description:"Node.js package manifest"}],matchedFiles:[f.packageJsonPath],fileCount:1},S={name:f.packageData?.name||f.name,version:f.packageData?.version,path:f.rootPath||".",manifestPath:f.packageJsonPath,packageManager:"unknown",dependencies:{},devDependencies:{},peerDependencies:{},isMonorepoRoot:!!f.packageData?.workspaces,isWorkspace:!f.isRoot&&c.length>1,parentPackage:f.isRoot?void 0:"root"};return{id:`package-node-${f.id}`,name:S.name,type:"node",enabled:!0,derivedFrom:{fileSets:[h],derivationType:"content",description:"Node.js package defined in package.json"},packageData:S,pillar:"foundationHealth"}})}isLockFile(c){return["package-lock.json","yarn.lock","pnpm-lock.yaml","bun.lockb","bun.lock","poetry.lock","Pipfile.lock","Cargo.lock"].some(h=>c.endsWith(h))}resolveWorkspaceRelationships(c){let f=c.filter(h=>h.packageData.path==="."||h.packageData.path==="");c.forEach(h=>{if(h.packageData.path!=="."&&h.packageData.path!==""){h.packageData.isWorkspace=!0;let S=h.packageData.path.includes("/")?h.packageData.path.substring(0,h.packageData.path.lastIndexOf("/")):".",k=c.find(R=>R.packageData.path===S);k&&(h.packageData.parentPackage=k.packageData.name)}})}createMinimalManifest(c,f){switch(c){case"node":return{name:f,version:"0.0.0",dependencies:{},devDependencies:{}};case"python":return{project:{name:f,version:"0.0.0"}};case"cargo":return{package:{name:f,version:"0.0.0"}};default:return{}}}detectMonorepoOrchestrator(c){return c.includes("turbo.json")?{orchestrator:"turbo",configPath:"turbo.json"}:c.includes("nx.json")?{orchestrator:"nx",configPath:"nx.json"}:c.includes("lerna.json")?{orchestrator:"lerna",configPath:"lerna.json"}:c.includes("pnpm-workspace.yaml")?{orchestrator:"pnpm",configPath:"pnpm-workspace.yaml"}:c.includes("rush.json")?{orchestrator:"rush",configPath:"rush.json"}:{orchestrator:"none"}}parseTurboConfig(c){try{let f=JSON.parse(c),h=[],S=f.tasks||f.pipeline||{};for(let[k,R]of Object.entries(S)){let X=k.split("#"),ae=X.length>1?k:void 0,le=X.length>1?X[1]:k,pe=this.inferToolFromTaskName(le);h.push({name:le,tool:pe,filter:ae})}return h}catch{return[]}}parseNxConfig(c){try{let f=JSON.parse(c),h=[];if(f.targetDefaults)for(let[S,k]of Object.entries(f.targetDefaults)){let R=this.inferToolFromTaskName(S);h.push({name:S,tool:R})}return h}catch{return[]}}inferToolFromTaskName(c){return{lint:"eslint",typecheck:"typescript","type-check":"typescript",tsc:"typescript",test:"jest",format:"prettier",prettier:"prettier",build:"build",dev:"dev",start:"start",check:"biome"}[c.toLowerCase()]}async buildMonorepoMetadata(c,f,h,S){let{orchestrator:k,configPath:R}=this.detectMonorepoOrchestrator(c);if(k==="none"&&!f)return;let X={orchestrator:k,orchestratorConfigPath:R,workspacePatterns:f};if(R&&h)try{let xe=await h(R);k==="turbo"?X.definedTasks=this.parseTurboConfig(xe):k==="nx"&&(X.definedTasks=this.parseNxConfig(xe))}catch{}if(S){let xe=[];for(let[$,Qe]of Object.entries(S))Qe&&Qe.exists&&xe.push({tool:$,configPath:Qe.path,isInline:Qe.isInline});xe.length>0&&(X.rootConfigs=xe)}let{role:ae,hasSourceCode:le,sourceDirs:pe}=this.detectRootRole(c);return X.rootRole=ae,X.rootHasSourceCode=le,pe.length>0&&(X.rootSourceDirs=pe),X}detectRootRole(c){let f=["src","lib","app"],h=["scripts","e2e","test","tests","tools","__tests__"],S=[".ts",".tsx",".js",".jsx",".mjs",".cjs",".py",".rs",".go"],k=[],R=[];for(let pe of c)if(!(pe.startsWith("packages/")||pe.startsWith("apps/")||pe.startsWith("libs/")||pe.startsWith("node_modules/"))){for(let xe of f)pe.startsWith(`${xe}/`)&&S.some(Qe=>pe.endsWith(Qe))&&!k.includes(xe)&&k.push(xe);for(let xe of h)pe.startsWith(`${xe}/`)&&S.some(Qe=>pe.endsWith(Qe))&&!R.includes(xe)&&R.push(xe)}let X=k.length>0,ae=R.length>0,le=[...k,...R];return X?{role:"application",hasSourceCode:!0,sourceDirs:le}:ae?{role:"hybrid",hasSourceCode:!0,sourceDirs:le}:{role:"orchestrator",hasSourceCode:!1,sourceDirs:[]}}propagateRootConfigs(c,f){if(!f?.configFiles||!f.packageData.monorepoMetadata)return;let h=f.configFiles;for(let S of c)if(!(S.packageData.path===""||S.packageData.path===".")){S.configFiles||(S.configFiles={});for(let[k,R]of Object.entries(h)){if(!R||!R.exists)continue;let X=S.configFiles[k];(!X||!X.exists)&&(S.configFiles[k]={...R,isInherited:!0,inheritedFrom:"",inheritanceType:"root"})}}}recalculateLensReadinessWithInheritance(c,f){if(!(!f?.configFiles||!f.packageData.monorepoMetadata))for(let h of c){if(h.packageData.path===""||h.packageData.path==="."||!(h.configFiles&&Object.values(h.configFiles).some(R=>R?.isInherited)))continue;let k=v7.calculateLensReadiness(h.packageData.dependencies,h.packageData.devDependencies,h.packageData.availableCommands||[],h.configFiles);for(let[R,X]of Object.entries(k)){let ae=h.qualityMetrics?.lensReadiness?.[R];if(X.ready&&ae&&!ae.ready){X.readyViaInheritance=!0;let le=X.checks.filter(pe=>pe.satisfied?h.configFiles?.[R]?.isInherited&&pe.requirement.type==="config":!1).length;le>0&&(X.inheritedChecks=le)}}h.qualityMetrics&&(h.qualityMetrics.lensReadiness=k)}}};var B1=jm(lpt(),1);var Dpt=jm(qoe(),1),$4={basename:_=>_.split("/").pop()||"",join:(..._)=>_.filter(f=>f).join("/").replace(/\/+/g,"/"),relative:(_,c)=>!_||_==="."?c:c.startsWith(_+"/")?c.slice(_.length+1):c===_?".":c,dirname:_=>{let c=_.lastIndexOf("/");return c>0?_.slice(0,c):""},extname:_=>{let c=_.lastIndexOf(".");return c>0?_.slice(c):""}},sM=class{adapter;filterStats={totalFiltered:0,filteredByLayer:{},examples:[],filteredByDirectory:{}};constructor(c){this.adapter=c}async buildFileSystemTreeFromPath(c,f,h){console.time("[FilesystemService] Total build time"),this.filterStats={totalFiltered:0,filteredByLayer:{},examples:[],filteredByDirectory:{}};let S=f||[],k=h?.enableInverseFiltering||!1;if(!this.adapter){let Cr={path:c,name:c.split("/").pop()||c,children:[],fileCount:0,totalSize:0,depth:0,relativePath:"."};return{sha:"",root:Cr,allFiles:[],allDirectories:[Cr],stats:{totalFiles:0,totalDirectories:1,totalSize:0,maxDepth:0},metadata:{id:`fs-${Date.now()}`,timestamp:new Date,sourceType:"filesystem",sourceInfo:{path:c}},filterStats:this.filterStats,appliedFilters:S,inverseMatches:k?[]:void 0}}console.time("[FilesystemService] Build file tree");let R=[],X;for(let Cr of S)Cr.enabled&&Cr.filterData?.excludedPatterns&&(R.push(...Cr.filterData.excludedPatterns.map($n=>$n.pattern)),Cr.filterData.sourceDirectory&&(X=Cr.filterData.sourceDirectory));let ae=await this.adapter.buildFilteredFileTree(c,R,X),le=ae.paths,pe=ae.stats,xe=this.createIgnoreInstances(S);for(let Cr of le)this.shouldIncludeFile(Cr,xe,S)||this.filterStats.totalFiltered++;console.timeEnd("[FilesystemService] Build file tree"),console.log(`[FilesystemService] Found ${le.length} paths after filtering`),console.time("[FilesystemService] Convert to tree structure");let{allFiles:$,allDirectories:Qe,rootDir:Le}=await this.convertPathsToTree(le,c,pe);console.timeEnd("[FilesystemService] Convert to tree structure");let Je=[];k&&(Je=await this.findInverseMatches(c,xe,S));let Ct=$.reduce((Cr,$n)=>Cr+($n.size||0),0),Bt=Math.max(...Qe.map(Cr=>Cr.depth||0));S.forEach(Cr=>{Cr.enabled&&this.filterStats.filteredByLayer[Cr.id]&&(Cr.filterData.stats||(Cr.filterData.stats={totalFiltered:0,bytesExcluded:0}),Cr.filterData.stats.totalFiltered=this.filterStats.filteredByLayer[Cr.id])});let hr={sha:"",root:Le||{path:".",name:$4.basename(c)||"root",children:[],fileCount:0,totalSize:0,depth:0,relativePath:"."},allFiles:$,allDirectories:Qe,stats:{totalFiles:$.length,totalDirectories:Qe.length,totalSize:Ct,maxDepth:Bt},metadata:{id:`fs-${Date.now()}`,timestamp:new Date,sourceType:"filesystem",sourceInfo:{path:c}},filterStats:this.filterStats,appliedFilters:S,inverseMatches:Je};return console.timeEnd("[FilesystemService] Total build time"),hr}createIgnoreInstances(c){let f=new Map;for(let h of c){if(!h.enabled||!h.filterData?.excludedPatterns)continue;let S=h.filterData.sourceDirectory||"",k=`${h.id}:${S}`,R=(0,Dpt.default)(),X=h.filterData.excludedPatterns.map(ae=>ae.pattern);R.add(X),f.set(k,{ignore:R,sourceDirectory:S,filterId:h.id,filterName:h.name})}return f}shouldIncludeFile(c,f,h){for(let[,{ignore:S,sourceDirectory:k,filterId:R,filterName:X}]of f){if(k!==""&&!c.startsWith(k+"/")&&c!==k)continue;let ae=c;if(k!==""&&c.startsWith(k+"/")&&(ae=c.slice(k.length+1)),!(!ae||ae===".")&&S.ignores(ae)){this.filterStats.totalFiltered++,this.filterStats.filteredByLayer[R]=(this.filterStats.filteredByLayer[R]||0)+1;let le=$4.dirname(c)||".";return this.filterStats.filteredByDirectory[le]||(this.filterStats.filteredByDirectory[le]={count:0,reasons:new Set}),this.filterStats.filteredByDirectory[le].count++,this.filterStats.filteredByDirectory[le].reasons.add(X),!1}}return!0}async convertPathsToTree(c,f,h){let S=[],k=[],R=new Map,X=h||new Map;if(!h&&this.adapter&&"getFileStats"in this.adapter){let le=c.map(async pe=>{try{let xe=$4.join(f,pe),$=await this.adapter.getFileStats(xe);$&&X.set(pe,{size:$.size||0,lastModified:$.lastModified||new Date,isDirectory:$.isDirectory||!1})}catch{}});await Promise.all(le)}for(let le of c){let pe=X.get(le);if(pe?.isDirectory||le.endsWith("/")){let $={path:le||".",name:$4.basename(le)||"root",children:[],fileCount:0,totalSize:0,depth:le.split("/").length-1,relativePath:le||"."};k.push($),R.set(le,$)}else{let $={path:le,name:$4.basename(le),extension:$4.extname(le).toLowerCase(),size:pe?.size||0,lastModified:pe?.lastModified||new Date,isDirectory:!1,relativePath:le};S.push($)}}let ae=R.get(".")||R.get("")||{path:".",name:$4.basename(f)||"root",children:[],fileCount:S.length,totalSize:S.reduce((le,pe)=>le+(pe.size||0),0),depth:0,relativePath:"."};return{allFiles:S,allDirectories:k,rootDir:ae}}async findInverseMatches(c,f,h){console.log("[FilesystemService] Running inverse filter analysis...");let S=[];if(!this.adapter)return[];let R=(await this.adapter.buildFilteredFileTree(c)).paths;console.log(`[FilesystemService] Found ${R.length} total paths for inverse analysis`);for(let X of R){let ae=[];for(let[,{ignore:le,sourceDirectory:pe,filterName:xe}]of f){if(pe!==""&&!X.startsWith(pe+"/")&&X!==pe)continue;let $=X;pe!==""&&X.startsWith(pe+"/")&&($=X.slice(pe.length+1)),!(!$||$===".")&&le.ignores($)&&ae.push(xe)}ae.length>0&&S.push({path:X,matchedFilters:ae})}return console.log(`[FilesystemService] Inverse analysis complete: ${S.length} files matched filters`),S}getFilterStats(){return{...this.filterStats}}getEmptyTree(c){let f={path:".",name:$4.basename(c)||"root",children:[],fileCount:0,totalSize:0,depth:0,relativePath:"."};return{sha:"",root:f,allFiles:[],allDirectories:[f],stats:{totalFiles:0,totalDirectories:1,totalSize:0,maxDepth:0},metadata:{id:`fs-${Date.now()}`,timestamp:new Date,sourceType:"filesystem",sourceInfo:{path:c}},filterStats:this.filterStats,appliedFilters:[],inverseMatches:[]}}};var TC=jm(require("fs/promises"),1),f6e=jm(require("path"),1),bpt=jm(qoe(),1),v$=class{async readFile(c){try{return{content:await TC.readFile(c,"utf-8")}}catch{return null}}async fileExists(c){try{return await TC.access(c),!0}catch{return!1}}async isDirectory(c){try{return(await TC.stat(c)).isDirectory()}catch{return!1}}async readDirectory(c){try{return await TC.readdir(c)}catch{return[]}}async getFileStats(c){try{let f=await TC.stat(c);return{size:f.size,isDirectory:f.isDirectory(),lastModified:f.mtime}}catch{return null}}async buildFilteredFileTree(c,f,h){let S=[],k=new Map,R=f&&f.length>0?(0,bpt.default)().add(f):null,X=async(ae,le="")=>{try{let pe=await TC.readdir(ae,{withFileTypes:!0});for(let xe of pe){let $=f6e.join(ae,xe.name),Qe=le?f6e.join(le,xe.name):xe.name;if(!(R&&R.ignores(Qe))&&!(xe.isDirectory()&&this.shouldSkipDirectory(xe.name)))if(xe.isDirectory()){S.push(Qe+"/");let Le=await TC.stat($);k.set(Qe+"/",{size:0,isDirectory:!0,lastModified:Le.mtime}),await X($,Qe)}else{S.push(Qe);let Le=await TC.stat($);k.set(Qe,{size:Le.size,isDirectory:!1,lastModified:Le.mtime})}}}catch(pe){console.warn(`Error walking directory ${ae}:`,pe)}};return await X(c),{paths:S,stats:k}}shouldSkipDirectory(c){return["node_modules",".git","dist","build","coverage",".next",".turbo",".cache","tmp",".vscode",".idea"].includes(c)}};var ffr=jm(qoe(),1);var jT=jm(require("path")),G4=jm(require("fs/promises")),_6e=class{constructor(c){this.basePath=c}async readFile(c){try{let f=jT.isAbsolute(c)?c:jT.join(this.basePath,c);return{content:await G4.readFile(f,"utf-8")}}catch(f){return console.error(`[CLIFileSystemAdapter] Failed to read ${c}:`,f),null}}async fileExists(c){try{let f=jT.isAbsolute(c)?c:jT.join(this.basePath,c);return await G4.access(f),!0}catch{return!1}}async readDirectory(c){try{let f=jT.isAbsolute(c)?c:jT.join(this.basePath,c);return await G4.readdir(f)}catch(f){return console.error(`[CLIFileSystemAdapter] Failed to read directory ${c}:`,f),[]}}async isDirectory(c){try{let f=jT.isAbsolute(c)?c:jT.join(this.basePath,c);return(await G4.stat(f)).isDirectory()}catch{return!1}}buildFilteredFileTree(c,f,h){return Promise.resolve({paths:[]})}},E7=class{constructor(){this.packageModule=new YR}async extractPackages(c,f){try{let h=new _6e(f),S=async R=>(await h.readFile(R))?.content||"",k=await this.packageModule.discoverPackages(c,S);return console.info(`[RepositoryScanner] Found ${k.length} packages in ${f}`),k}catch(h){return console.error("[RepositoryScanner] Failed to extract packages:",h),[]}}};var qp=jm(woe());var p6e=require("child_process"),d6e=require("stream"),Uoe=class{constructor(){this.type="node"}async execute(c,f=[],h={}){let S=Date.now();return new Promise(k=>{let R="",X="",le={...h.env||process.env};delete le.NODE_OPTIONS,delete le.TS_NODE_PROJECT,delete le.TS_NODE_TRANSPILE_ONLY;let pe=(0,p6e.spawn)(c,f,{cwd:h.cwd,env:le,shell:!0});pe.stdout&&pe.stdout.on("data",$=>{R+=$.toString()}),pe.stderr&&pe.stderr.on("data",$=>{X+=$.toString()});let xe;h.timeout&&(xe=setTimeout(()=>{pe.kill("SIGTERM")},h.timeout)),pe.on("error",$=>{xe&&clearTimeout(xe),k({stdout:R,stderr:X||$.message,exitCode:1,duration:Date.now()-S,command:c,args:f,error:$})}),pe.on("close",$=>{xe&&clearTimeout(xe),k({stdout:R,stderr:X,exitCode:$??0,duration:Date.now()-S,command:c,args:f})})})}stream(c,f=[],h={}){let k={...h.env||process.env};delete k.NODE_OPTIONS,delete k.TS_NODE_PROJECT,delete k.TS_NODE_TRANSPILE_ONLY;let R=(0,p6e.spawn)(c,f,{cwd:h.cwd,env:k,shell:!0}),X=new Promise(ae=>{let le="",pe="",xe=Date.now();R.stdout&&R.stdout.on("data",$=>{le+=$.toString()}),R.stderr&&R.stderr.on("data",$=>{pe+=$.toString()}),R.on("close",$=>{ae({stdout:le,stderr:pe,exitCode:$??0,duration:Date.now()-xe,command:c,args:f})}),R.on("error",$=>{ae({stdout:le,stderr:pe||$.message,exitCode:1,duration:Date.now()-xe,command:c,args:f,error:$})})});return{stdout:R.stdout||new d6e.Readable({read(){}}),stderr:R.stderr||new d6e.Readable({read(){}}),exitPromise:X,kill:()=>{R.kill("SIGTERM")}}}async isAvailable(c){try{let f=["--version"];return(await this.execute(c,f,{timeout:5e3})).exitCode===0}catch{return!1}}};var zoe=class{constructor(){this.executor=new Uoe;let c=new v$;this.filesystemService=new sM(c),this.sourceFilesCache=new Map,this.lenses=new Map,this.initializeLenses()}initializeLenses(){console.log("[QualityLensService] Initializing lenses...");let c=new qp.ESLintLens(this.executor);this.lenses.set("eslint",c),this.lenses.set("lint",c);let f=new qp.JestLens(this.executor);this.lenses.set("jest",f),this.lenses.set("test",f);let h=new qp.BunTestLens(this.executor);this.lenses.set("bun-test",h),this.lenses.set("bun",h);let S=new qp.VitestLens(this.executor);this.lenses.set("vitest",S),this.lenses.set("typescript",null),this.lenses.set("typecheck",null),this.lenses.set("tsc",null),this.lenses.set("knip",null),this.lenses.set("deadcode",null);let k=new qp.PrettierLens(this.executor);this.lenses.set("prettier",k),this.lenses.set("format",k);let R=new qp.BiomeLens(this.executor);R.setMode("lint"),this.lenses.set("biome-lint",R),this.lenses.set("biome",R);let X=new qp.BiomeLens(this.executor);X.setMode("format"),this.lenses.set("biome-format",X);let ae=new qp.GitLens(this.executor);this.lenses.set("git",ae);let le=new qp.AlexandriaLens(this.executor);this.lenses.set("alexandria",le),this.lenses.set("docs",le)}async checkIfBunTestRunner(c,f){try{let h=await import("fs/promises"),k=(await import("path")).join(c,"package.json"),R=await h.readFile(k,"utf-8"),X=JSON.parse(R),ae=f.replace(/^(npm|yarn|pnpm)\s+run\s+/,"").split(" ")[0]||"test",le=X.scripts?.[ae];return!!(le&&(le.startsWith("bun test")||le.startsWith("bun run test")))}catch{return!1}}async discoverSourceFiles(c,f){let h=`${c}:${Array.from(f).join(",")}`;if(this.sourceFilesCache.has(h))return this.sourceFilesCache.get(h);try{let k=(await this.filesystemService.buildFileSystemTreeFromPath(c)).allFiles.filter(R=>f.has(R.extension)).map(R=>R.relativePath);return this.sourceFilesCache.set(h,k),console.log(`[QualityLensService] Discovered ${k.length} source files in ${c}`),k}catch(S){return console.warn(`[QualityLensService] Failed to discover source files in ${c}:`,S),[]}}async getLensForExecution(c,f,h){let S=c.toLowerCase();if(["typescript","typecheck","tsc"].includes(S)){let k=await this.discoverSourceFiles(f,qp.TS_SOURCE_EXTENSIONS);return new qp.TypeScriptLens(this.executor,{sourceFiles:k})}if(["knip","deadcode"].includes(S)){let k=await this.discoverSourceFiles(f,qp.SOURCE_EXTENSIONS);return new qp.KnipLens(this.executor,{sourceFiles:k})}return["test","jest"].includes(S)?h&&h.includes("bun test")?(console.log("[QualityLensService] Detected Bun test runner (from command)"),this.lenses.get("bun-test")||null):await this.checkIfBunTestRunner(f,h||"test")?(console.log("[QualityLensService] Detected Bun test runner (from package.json)"),this.lenses.get("bun-test")||null):this.lenses.get("jest")||null:["bun-test","bun"].includes(S)?this.lenses.get("bun-test")||null:S==="biome-lint"?(console.log("[QualityLensService] Using Biome lint lens"),this.lenses.get("biome-lint")||null):S==="biome-format"?(console.log("[QualityLensService] Using Biome format lens"),this.lenses.get("biome-format")||null):this.lenses.get(S)||null}async executeTool(c){let f=Date.now();if(!c.packageLayer||!c.packageCommand)throw new Error("packageLayer and packageCommand are required. Legacy execution has been removed.");return this.executeWithPackageLayer(c,f)}async executeWithPackageLayer(c,f){let{repoPath:h,packageLayer:S,packageCommand:k}=c;if(!S||!k)throw new Error("packageLayer and packageCommand are required for new execution path");let R=S.packageData.path||"",X=R?`${h}/${R}`:h;if(!k.isLensCommand||!k.lensId)return console.log(`[QualityLensService] Not a lens command, executing directly: ${k.name}`),this.executeNonLensCommand(c,k,X,f);let ae=await this.getLensForExecution(k.lensId,X,k.command);if(!ae)return console.warn(`[QualityLensService] No lens registered for: ${k.lensId}`),this.executeNonLensCommand(c,k,X,f);console.log(`[QualityLensService] Using ${ae.name} for command: ${k.name} (lensId: ${k.lensId})`);try{let{command:le,args:pe}=this.parseCommandString(k.command);ae.configure({cwd:X,tool:{name:k.lensId,command:le,args:pe,cwd:X,available:!0}});let xe=await ae.run(),{success:$,exitCode:Qe}=this.determineLensSuccess(xe);return{success:$,toolName:k.lensId,command:k.command,packagePath:R,exitCode:Qe,duration:Date.now()-f,stdout:xe.raw?.stdout||"",stderr:xe.raw?.stderr||xe.error?.message||"",lensResult:xe,qualityContext:{lensId:k.lensId,operation:k.lensOperation,availableLenses:S.qualityMetrics?.availableLenses,missingLenses:S.qualityMetrics?.missingLenses}}}catch(le){console.error("[QualityLensService] Error:",le);let pe=le instanceof Error?le:new Error(String(le));return this.createErrorResponse(k.lensId||k.name,k.command,R,pe,f)}}async executeNonLensCommand(c,f,h,S){let{command:k,args:R}=this.parseCommandString(f.command);try{let X=await this.executor.execute(k,R,{cwd:h});return{success:X.exitCode===0,toolName:f.name,command:f.command,packagePath:c.packageLayer?.packageData.path,exitCode:X.exitCode,duration:Date.now()-S,stdout:X.stdout,stderr:X.stderr}}catch(X){let ae=X instanceof Error?X:new Error(String(X));return this.createErrorResponse(f.name,f.command,c.packageLayer?.packageData.path,ae,S)}}parseCommandString(c){if(c.startsWith("npm run "))return{command:"npm",args:["run",...c.split(" ").slice(2)]};if(c.startsWith("yarn "))return{command:"yarn",args:c.split(" ").slice(1)};if(c.startsWith("pnpm "))return{command:"pnpm",args:c.split(" ").slice(1)};let f=c.split(" ");return{command:f[0]||"",args:f.slice(1)}}determineLensSuccess(c){let f=0;return c.raw?.exitCode!==void 0?f=c.raw.exitCode:(c.error||c.metrics?.issuesBySeverity?.error&&c.metrics.issuesBySeverity.error>0)&&(f=1),{success:f!==127,exitCode:f}}createErrorResponse(c,f,h,S,k){return{success:!1,toolName:c,command:f,packagePath:h,exitCode:1,duration:Date.now()-k,stdout:"",stderr:S.message||"Tool execution failed",error:S.message}}getAvailableLenses(){return Array.from(this.lenses.keys())}hasLensForTool(c){return this.lenses.has(c.toLowerCase())}};var Woe=class{constructor(){this.fileCountsByPackage=new Map}setFileTree(c){this.fileTree=c,this.calculateFileCountsPerPackage()}calculateFileCountsPerPackage(){if(!this.fileTree)return;this.fileCountsByPackage.clear();let c=new Set(["ts","tsx","js","jsx","mts","mjs","cts","cjs",".ts",".tsx",".js",".jsx",".mts",".mjs",".cts",".cjs"]);for(let f of this.fileTree.allFiles){let h=f.extension||"";if(!c.has(h)&&!c.has(h.replace(/^\./,"")))continue;let S=f.relativePath;if(S.includes(".test.")||S.includes(".spec.")||S.includes("__tests__")||S.includes("__mocks__")||S.endsWith(".config.ts")||S.endsWith(".config.js"))continue;let k=this.fileCountsByPackage.get("")||0;this.fileCountsByPackage.set("",k+1);let R=S.split("/"),X="";for(let ae=0;ae<R.length-1;ae++){let le=R[ae]??"";X=X?`${X}/${le}`:le;let pe=this.fileCountsByPackage.get(X)||0;this.fileCountsByPackage.set(X,pe+1)}}}getFileCountForPackage(c){return this.fileCountsByPackage.get(c||"")||0}mapLensToHexagonDimension(c){return{jest:"tests",vitest:"tests","bun-test":"tests",test:"tests",knip:"deadCode",deadcode:"deadCode",prettier:"formatting","biome-format":"formatting",format:"formatting",eslint:"linting","biome-lint":"linting",biome:"linting",lint:"linting",typescript:"types",typecheck:"types",tsc:"types",alexandria:"documentation"}[c.toLowerCase()]||null}getIssuePath(c){return c.file}findOwningPackage(c,f){let h,S=0;for(let k of f)k.path&&(c.startsWith(k.path+"/")||c===k.path)&&k.path.length>S&&(S=k.path.length,h=k);return h}distributeIssuesToPackages(c){let f=c.filter(R=>!!(R.packagePath&&R.packagePath!=="")).map(R=>({name:R.package,path:R.packagePath})).filter((R,X,ae)=>ae.findIndex(le=>le.path===R.path)===X);if(f.length===0)return c;let h=new Map,S=[];for(let R of c){if(R.packagePath&&R.packagePath!==""){S.push(R);continue}let X=R.result?.lensResult?.issues;if(!X||X.length===0){S.push(R);continue}let ae=[];for(let le of X){let pe=this.getIssuePath(le);if(!pe){ae.push(le);continue}let xe=this.findOwningPackage(pe,f);if(xe){let $=xe.path,Qe=h.get($);Qe||(Qe=new Map,h.set($,Qe));let Le=Qe.get(R.lens);Le||(Le=[],Qe.set(R.lens,Le));let Je=pe.slice(xe.path.length+1),Ct={...le,file:Je,originalPath:pe};Le.push(Ct)}else ae.push(le)}if(R.result?.lensResult){let le={...R,result:{...R.result,lensResult:{...R.result.lensResult,issues:ae,metrics:this.recalculateMetricsFromIssues(R.result.lensResult.metrics,ae)}}};S.push(le)}else S.push(R)}for(let[R,X]of h){let ae=f.find(le=>le.path===R);if(ae)for(let[le,pe]of X){let xe=S.findIndex($=>$.packagePath===R&&$.lens===le);if(xe>=0){let $=S[xe];if($?.result?.lensResult){let Le=[...$.result.lensResult.issues||[],...pe];S[xe]={...$,result:{...$.result,lensResult:{...$.result.lensResult,issues:Le,metrics:this.recalculateMetricsFromIssues($.result.lensResult.metrics,Le)}}}}}else{let $=c.find(Le=>Le.lens===le&&(!Le.packagePath||Le.packagePath==="")),Qe={lensName:le,tool:le,timestamp:Date.now(),success:!0,issues:pe,metrics:this.createMetricsFromIssues(pe)};S.push({package:ae.name,packagePath:ae.path,lens:le,command:$?.command||le,timestamp:$?.timestamp||Date.now(),result:{success:!0,toolName:le,command:$?.command||le,packagePath:ae.path,exitCode:pe.length>0?1:0,duration:0,stdout:"",stderr:"",lensResult:Qe}})}}}let k=c.filter(R=>(!R.packagePath||R.packagePath==="")&&R.result?.success);for(let R of k)for(let X of f){if(S.some(xe=>xe.packagePath===X.path&&xe.lens===R.lens))continue;let le=this.getFileCountForPackage(X.path);if(le===0)continue;let pe={lensName:R.lens,tool:R.lens,timestamp:Date.now(),success:!0,issues:[],metrics:{filesAnalyzed:le,totalIssues:0,issuesBySeverity:{error:0,warning:0,info:0,hint:0},executionTime:0},qualityScore:100};S.push({package:X.name,packagePath:X.path,lens:R.lens,command:R.command,timestamp:R.timestamp,result:{success:!0,toolName:R.lens,command:R.command,packagePath:X.path,exitCode:0,duration:0,stdout:"",stderr:"",lensResult:pe}})}return S}createMetricsFromIssues(c){let f={error:0,warning:0,info:0,hint:0};for(let S of c){let k=S.severity?.toLowerCase()||"warning";k in f&&f[k]++}return{filesAnalyzed:new Set(c.map(S=>this.getIssuePath(S)).filter(Boolean)).size||1,totalIssues:c.length,issuesBySeverity:f,executionTime:0}}recalculateMetricsFromIssues(c,f){let h=this.createMetricsFromIssues(f);return c?.custom&&(h.custom=c.custom),c?.executionTime&&(h.executionTime=c.executionTime),h}extractQualityScore(c){if(c.result?.lensResult?.qualityScore!==void 0&&c.result.lensResult.qualityScore!==null&&c.result.lensResult.qualityScore>0)return c.result.lensResult.qualityScore;if(!c.result?.success)return 0;let f=c.result?.lensResult?.metrics,h=c.result?.exitCode??0,S=this.mapLensToHexagonDimension(c.lens);if(S==="tests"){let xe=f?.custom;if(xe?.passRate!==void 0&&xe.passRate!==null)return Math.round(xe.passRate);if(h!==0&&(xe?.failedSuites&&xe.failedSuites>0||xe?.totalTests===0))return 0}if(S==="types"&&h===2&&(f?.filesAnalyzed??0)===0)return 0;let k=c.result?.lensResult?.issues||[];if(k.length===0&&h!==0&&(f?.filesAnalyzed??0)===0)return 0;if(k.length===0)return 100;let R=new Set(k.map(xe=>xe.file)).size,X=c.packagePath||"",ae=this.getFileCountForPackage(X);if(ae===0){let xe=c.result?.lensResult?.metrics?.filesAnalyzed||1,$=Math.max(0,xe-R);return Math.round($/xe*100)}let le=Math.max(0,ae-R);return Math.round(le/ae*100)}calculateHexagonMetrics(c){let f={tests:0,deadCode:0,formatting:0,linting:0,types:0,documentation:0};for(let h of c){let S=this.mapLensToHexagonDimension(h.lens);if(S){let k=this.extractQualityScore(h);S==="deadCode"&&(k=100-k),S==="deadCode"?f[S]=f[S]===0?k:Math.min(f[S],k):f[S]=Math.max(f[S],k)}}return f}getGitMetadata(){let c={};if(process.env.GITHUB_SHA&&(c.commit=process.env.GITHUB_SHA),process.env.GITHUB_REF){let f=process.env.GITHUB_REF;f.startsWith("refs/heads/")?c.branch=f.replace("refs/heads/",""):f.startsWith("refs/pull/")&&(c.branch=f)}if(process.env.GITHUB_REPOSITORY&&(c.repository=process.env.GITHUB_REPOSITORY),Object.keys(c).length!==0)return c}calculatePerPackageMetrics(c){let f=new Map;for(let S of c){let k=f.get(S.package);k?(k.results.push(S),k.lenses.add(S.lens)):f.set(S.package,{path:S.packagePath,results:[S],lenses:new Set([S.lens])})}let h=[];for(let[S,{path:k,results:R,lenses:X}]of f)h.push({name:S,path:k,hexagon:this.calculateHexagonMetrics(R),lensesRan:Array.from(X)});return h}format(c){let f=this.getGitMetadata(),h=this.distributeIssuesToPackages(c),S=this.calculatePerPackageMetrics(h),k={metadata:{timestamp:new Date().toISOString(),version:"1.0.0",totalPackages:S.length,totalLenses:h.length,...f&&{git:f}},results:h.map(R=>({package:{name:R.package,path:R.packagePath},lens:{id:R.lens,command:R.command},execution:{success:R.result?.success??!1,exitCode:R.result?.exitCode,duration:R.result?.duration,timestamp:R.timestamp},issues:R.result?.lensResult?.issues||[],metrics:R.result?.lensResult?.metrics||{},coverage:R.result?.lensResult?.coverage,fileMetrics:R.result?.lensResult?.fileMetrics,qualityContext:R.result?.qualityContext||{},error:R.error}))};return S.length>0&&(k.qualityMetrics={packages:S}),JSON.stringify(k,null,2)}};var Cpt=(_=0)=>c=>`\x1B[${c+_}m`,Spt=(_=0)=>c=>`\x1B[${38+_};5;${c}m`,Ept=(_=0)=>(c,f,h)=>`\x1B[${38+_};2;${c};${f};${h}m`,rd={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},dPr=Object.keys(rd.modifier),dfr=Object.keys(rd.color),mfr=Object.keys(rd.bgColor),mPr=[...dfr,...mfr];function hfr(){let _=new Map;for(let[c,f]of Object.entries(rd)){for(let[h,S]of Object.entries(f))rd[h]={open:`\x1B[${S[0]}m`,close:`\x1B[${S[1]}m`},f[h]=rd[h],_.set(S[0],S[1]);Object.defineProperty(rd,c,{value:f,enumerable:!1})}return Object.defineProperty(rd,"codes",{value:_,enumerable:!1}),rd.color.close="\x1B[39m",rd.bgColor.close="\x1B[49m",rd.color.ansi=Cpt(),rd.color.ansi256=Spt(),rd.color.ansi16m=Ept(),rd.bgColor.ansi=Cpt(10),rd.bgColor.ansi256=Spt(10),rd.bgColor.ansi16m=Ept(10),Object.defineProperties(rd,{rgbToAnsi256:{value(c,f,h){return c===f&&f===h?c<8?16:c>248?231:Math.round((c-8)/247*24)+232:16+36*Math.round(c/255*5)+6*Math.round(f/255*5)+Math.round(h/255*5)},enumerable:!1},hexToRgb:{value(c){let f=/[a-f\d]{6}|[a-f\d]{3}/i.exec(c.toString(16));if(!f)return[0,0,0];let[h]=f;h.length===3&&(h=[...h].map(k=>k+k).join(""));let S=Number.parseInt(h,16);return[S>>16&255,S>>8&255,S&255]},enumerable:!1},hexToAnsi256:{value:c=>rd.rgbToAnsi256(...rd.hexToRgb(c)),enumerable:!1},ansi256ToAnsi:{value(c){if(c<8)return 30+c;if(c<16)return 90+(c-8);let f,h,S;if(c>=232)f=((c-232)*10+8)/255,h=f,S=f;else{c-=16;let X=c%36;f=Math.floor(c/36)/5,h=Math.floor(X/6)/5,S=X%6/5}let k=Math.max(f,h,S)*2;if(k===0)return 30;let R=30+(Math.round(S)<<2|Math.round(h)<<1|Math.round(f));return k===2&&(R+=60),R},enumerable:!1},rgbToAnsi:{value:(c,f,h)=>rd.ansi256ToAnsi(rd.rgbToAnsi256(c,f,h)),enumerable:!1},hexToAnsi:{value:c=>rd.ansi256ToAnsi(rd.hexToAnsi256(c)),enumerable:!1}}),rd}var gfr=hfr(),hE=gfr;var $oe=jm(require("node:process"),1),Tpt=jm(require("node:os"),1),m6e=jm(require("node:tty"),1);function AC(_,c=globalThis.Deno?globalThis.Deno.args:$oe.default.argv){let f=_.startsWith("-")?"":_.length===1?"-":"--",h=c.indexOf(f+_),S=c.indexOf("--");return h!==-1&&(S===-1||h<S)}var{env:nd}=$oe.default,Voe;AC("no-color")||AC("no-colors")||AC("color=false")||AC("color=never")?Voe=0:(AC("color")||AC("colors")||AC("color=true")||AC("color=always"))&&(Voe=1);function yfr(){if("FORCE_COLOR"in nd)return nd.FORCE_COLOR==="true"?1:nd.FORCE_COLOR==="false"?0:nd.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(nd.FORCE_COLOR,10),3)}function vfr(_){return _===0?!1:{level:_,hasBasic:!0,has256:_>=2,has16m:_>=3}}function Dfr(_,{streamIsTTY:c,sniffFlags:f=!0}={}){let h=yfr();h!==void 0&&(Voe=h);let S=f?Voe:h;if(S===0)return 0;if(f){if(AC("color=16m")||AC("color=full")||AC("color=truecolor"))return 3;if(AC("color=256"))return 2}if("TF_BUILD"in nd&&"AGENT_NAME"in nd)return 1;if(_&&!c&&S===void 0)return 0;let k=S||0;if(nd.TERM==="dumb")return k;if($oe.default.platform==="win32"){let R=Tpt.default.release().split(".");return Number(R[0])>=10&&Number(R[2])>=10586?Number(R[2])>=14931?3:2:1}if("CI"in nd)return["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some(R=>R in nd)?3:["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(R=>R in nd)||nd.CI_NAME==="codeship"?1:k;if("TEAMCITY_VERSION"in nd)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(nd.TEAMCITY_VERSION)?1:0;if(nd.COLORTERM==="truecolor"||nd.TERM==="xterm-kitty"||nd.TERM==="xterm-ghostty"||nd.TERM==="wezterm")return 3;if("TERM_PROGRAM"in nd){let R=Number.parseInt((nd.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(nd.TERM_PROGRAM){case"iTerm.app":return R>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(nd.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(nd.TERM)||"COLORTERM"in nd?1:k}function xpt(_,c={}){let f=Dfr(_,{streamIsTTY:_&&_.isTTY,...c});return vfr(f)}var bfr={stdout:xpt({isTTY:m6e.default.isatty(1)}),stderr:xpt({isTTY:m6e.default.isatty(2)})},Apt=bfr;function Fpt(_,c,f){let h=_.indexOf(c);if(h===-1)return _;let S=c.length,k=0,R="";do R+=_.slice(k,h)+c+f,k=h+S,h=_.indexOf(c,k);while(h!==-1);return R+=_.slice(k),R}function kpt(_,c,f,h){let S=0,k="";do{let R=_[h-1]==="\r";k+=_.slice(S,R?h-1:h)+c+(R?`\r
|
|
983
983
|
`:`
|
|
984
984
|
`)+f,S=h+1,h=_.indexOf(`
|
|
985
985
|
`,S)}while(h!==-1);return k+=_.slice(S),k}var{stdout:Ipt,stderr:wpt}=Apt,h6e=Symbol("GENERATOR"),aM=Symbol("STYLER"),D$=Symbol("IS_EMPTY"),Ppt=["ansi","ansi","ansi256","ansi16m"],oM=Object.create(null),Cfr=(_,c={})=>{if(c.level&&!(Number.isInteger(c.level)&&c.level>=0&&c.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");let f=Ipt?Ipt.level:0;_.level=c.level===void 0?f:c.level};var Sfr=_=>{let c=(...f)=>f.join(" ");return Cfr(c,_),Object.setPrototypeOf(c,b$.prototype),c};function b$(_){return Sfr(_)}Object.setPrototypeOf(b$.prototype,Function.prototype);for(let[_,c]of Object.entries(hE))oM[_]={get(){let f=Goe(this,y6e(c.open,c.close,this[aM]),this[D$]);return Object.defineProperty(this,_,{value:f}),f}};oM.visible={get(){let _=Goe(this,this[aM],!0);return Object.defineProperty(this,"visible",{value:_}),_}};var g6e=(_,c,f,...h)=>_==="rgb"?c==="ansi16m"?hE[f].ansi16m(...h):c==="ansi256"?hE[f].ansi256(hE.rgbToAnsi256(...h)):hE[f].ansi(hE.rgbToAnsi(...h)):_==="hex"?g6e("rgb",c,f,...hE.hexToRgb(...h)):hE[f][_](...h),Efr=["rgb","hex","ansi256"];for(let _ of Efr){oM[_]={get(){let{level:f}=this;return function(...h){let S=y6e(g6e(_,Ppt[f],"color",...h),hE.color.close,this[aM]);return Goe(this,S,this[D$])}}};let c="bg"+_[0].toUpperCase()+_.slice(1);oM[c]={get(){let{level:f}=this;return function(...h){let S=y6e(g6e(_,Ppt[f],"bgColor",...h),hE.bgColor.close,this[aM]);return Goe(this,S,this[D$])}}}}var xfr=Object.defineProperties(()=>{},{...oM,level:{enumerable:!0,get(){return this[h6e].level},set(_){this[h6e].level=_}}}),y6e=(_,c,f)=>{let h,S;return f===void 0?(h=_,S=c):(h=f.openAll+_,S=c+f.closeAll),{open:_,close:c,openAll:h,closeAll:S,parent:f}},Goe=(_,c,f)=>{let h=(...S)=>Tfr(h,S.length===1?""+S[0]:S.join(" "));return Object.setPrototypeOf(h,xfr),h[h6e]=_,h[aM]=c,h[D$]=f,h},Tfr=(_,c)=>{if(_.level<=0||!c)return _[D$]?"":c;let f=_[aM];if(f===void 0)return c;let{openAll:h,closeAll:S}=f;if(c.includes("\x1B"))for(;f!==void 0;)c=Fpt(c,f.close,f.open),f=f.parent;let k=c.indexOf(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JsonFormatter.d.ts","sourceRoot":"","sources":["../../src/output/JsonFormatter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,WAAW,EAIZ,MAAM,uCAAuC,CAAC;AAC/C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AACrE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAG3E,YAAY,EAAE,qBAAqB,EAAE,WAAW,EAAE,CAAC;AAKnD,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"JsonFormatter.d.ts","sourceRoot":"","sources":["../../src/output/JsonFormatter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,WAAW,EAIZ,MAAM,uCAAuC,CAAC;AAC/C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AACrE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAG3E,YAAY,EAAE,qBAAqB,EAAE,WAAW,EAAE,CAAC;AAKnD,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,qBAAqB,CAAC;IAE/B,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAKD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE;QACR,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,EAAE,MAAM,CAAC;QAChB,aAAa,EAAE,MAAM,CAAC;QACtB,WAAW,EAAE,MAAM,CAAC;QACpB,GAAG,CAAC,EAAE,WAAW,CAAC;KACnB,CAAC;IACF,OAAO,EAAE,KAAK,CAAC;QACb,OAAO,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,IAAI,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;QACzC,IAAI,EAAE;YAAE,EAAE,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE,MAAM,CAAA;SAAE,CAAC;QACtC,SAAS,EAAE;YACT,OAAO,EAAE,OAAO,CAAC;YACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;YAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;YAClB,SAAS,EAAE,MAAM,CAAC;SACnB,CAAC;QACF,MAAM,EAAE,OAAO,EAAE,CAAC;QAClB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACjC,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,WAAW,CAAC,EAAE,OAAO,EAAE,CAAC;QACxB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACxC,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC,CAAC;IACH,cAAc,CAAC,EAAE;QACf,QAAQ,EAAE,qBAAqB,EAAE,CAAC;KACnC,CAAC;CACH;AAKD,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,qBAAqB,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB;AAoBD,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,CAAW;IAC5B,OAAO,CAAC,mBAAmB,CAAkC;IAK7D,WAAW,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IASrC,OAAO,CAAC,6BAA6B;IAmErC,sBAAsB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM;IAOnD,OAAO,CAAC,yBAAyB;IAmCjC,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,iBAAiB;IAgCzB,OAAO,CAAC,0BAA0B;IAwOlC,OAAO,CAAC,uBAAuB;IA+B/B,OAAO,CAAC,4BAA4B;IAqBpC,OAAO,CAAC,mBAAmB;IAoG3B,OAAO,CAAC,uBAAuB;IA2C/B,OAAO,CAAC,cAAc;IAiCtB,OAAO,CAAC,0BAA0B;IAsClC,MAAM,CAAC,OAAO,EAAE,mBAAmB,EAAE,GAAG,MAAM;CAkD/C"}
|