@principal-ai/quality-lens-cli 0.1.54 → 0.1.55

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.
Files changed (2) hide show
  1. package/dist/cli.js +1 -1
  2. package/package.json +2 -2
package/dist/cli.js CHANGED
@@ -978,7 +978,7 @@ Make sure that all grammar rule definitions are done before 'performSelfAnalysis
978
978
  `)),this.errors=_}},Lar=class extends UR{errors;constructor(_){super(`Syntax error
979
979
  `+_.map(c=>c.message).join(`
980
980
  `)),this.errors=_}},Rar=class extends UR{constructor(_){super(_)}},Rlt=Io.default.build("{{digit}}{4}",{digit:_E}),Mlt=Io.default.build("{{digit}}{2}",{digit:_E}),Blt=Io.default.build("{{digit}}{2}",{digit:_E}),jlt=/[Tt ]/,BFe=Io.default.build("{{digit}}{2}",{digit:_E}),jFe=Io.default.build("{{digit}}{2}",{digit:_E}),Jlt=Io.default.build("{{digit}}{2}",{digit:_E}),Mar=Io.default.build("\\.{{digit}}+",{digit:_E}),Bar=Io.default.build("[+-]{{timeHour}}:{{timeMinute}}",{timeHour:BFe,timeMinute:jFe}),jar=Io.default.build("[Zz]|{{timeNumOffset}}",{timeNumOffset:Bar}),JFe=Io.default.build("{{timeHour}}:{{timeMinute}}:{{timeSecond}}{{timeSecFrac}}?",{timeHour:BFe,timeMinute:jFe,timeSecond:Jlt,timeSecFrac:Mar}),qFe=Io.default.build("{{dateFullYear}}-{{dateMonth}}-{{dateMDay}}",{dateFullYear:Rlt,dateMonth:Mlt,dateMDay:Blt}),Jar=Io.default.build("{{partialTime}}{{timeOffset}}",{partialTime:JFe,timeOffset:jar}),qar=Io.default.build("{{fullDate}}{{timeDelim}}{{fullTime}}",{fullDate:qFe,timeDelim:jlt,fullTime:Jar}),Uar=Io.default.build("{{fullDate}}{{timeDelim}}{{partialTime}}",{fullDate:qFe,timeDelim:jlt,partialTime:JFe}),zar=qFe,qlt=JFe,War=Io.default.build("{{offsetDateTime}}|{{localDateTime}}|{{localDate}}|{{localTime}}",{offsetDateTime:qar,localDateTime:Uar,localDate:zar,localTime:qlt}),aoe=Gu({name:"DateTime",pattern:War}),Var=_=>{let c=Io.default.build("({{dateFullYear}})-({{dateMonth}})-({{dateMDay}})",{dateFullYear:Rlt,dateMonth:Mlt,dateMDay:Blt}),f=Io.default.exec(_,c);if(f){let h=Number(f[1]),S=Number(f[2]),k=Number(f[3]),M=new Date(h,S-1,k);return M.getFullYear()===h&&M.getMonth()+1===S&&M.getDate()===k}return!0},$ar=_=>{let c=Io.default.build("({{timeHour}}):({{timeMinute}}):({{timeSecond}})",{timeHour:BFe,timeMinute:jFe,timeSecond:Jlt}),f=Io.default.exec(_,c);if(f){let h=Number(f[1]),S=Number(f[2]),k=Number(f[3]),M=new Date(0,0,0,h,S,k);return M.getHours()===h&&M.getMinutes()===S&&M.getSeconds()===k}return!0},Gar=_=>Var(_)&&$ar(_);R1(aoe,_=>{var c;if(!Gar(_))throw new UR(`Invalid date time: ${_}`);return((c=_.match(qlt))==null?void 0:c.index)===0?_:new Date(_)});var Ult=Gu({name:"DotSeparator",pattern:/\./,label:"."}),wFe=Gu({name:"ExpressionNewLine",pattern:Ik}),Har=Llt,zlt=Io.default.build("{{digit}}({{digit}}|{{underscore}}{{digit}})*",{digit:_E,underscore:o$}),Qar=Io.default.build("({{minus}}|{{plus}})?{{zeroPrefixableInt}}",{minus:RFe,plus:MFe,zeroPrefixableInt:zlt}),Kar=Io.default.build("[Ee]{{floatExpPart}}",{floatExpPart:Qar}),Xar=/\./,Yar=Io.default.build("{{decimalPoint}}{{zeroPrefixableInt}}",{decimalPoint:Xar,zeroPrefixableInt:zlt}),Zar=/inf/,eor=/nan/,tor=Io.default.build("({{minus}}|{{plus}})?({{inf}}|{{nan}})",{minus:RFe,plus:MFe,inf:Zar,nan:eor}),ror=Io.default.build("{{floatIntPart}}({{exp}}|{{frac}}{{exp}}?)|{{specialFloat}}",{floatIntPart:Har,exp:Kar,frac:Yar,specialFloat:tor}),ooe=Gu({name:"Float",pattern:ror}),nor=_=>_==="inf"||_==="+inf"?1/0:_==="-inf"?-1/0:_==="nan"||_==="+nan"||_==="-nan"?NaN:null;R1(ooe,_=>{let c=nor(_);if(c!==null)return c;let f=_.replace(/_/g,"");return parseFloat(f)});var ior=/}/,PFe=Gu({name:"InlineTableClose",pattern:ior,label:"}",pop_mode:!0}),sor=/{/,Wlt=Gu({name:"InlineTableOpen",pattern:sor,label:"{",push_mode:"InlineTable"}),aor=/,/,Vlt=Gu({name:"InlineTableSep",pattern:aor,label:",",pop_mode:!0,push_mode:"InlineTable"}),c$=Gu({name:"Integer",pattern:z_.NA});R1(c$,i$);var UFe=Gu({name:"KeyValueSeparator",pattern:/=/,label:"=",push_mode:"Value"}),$lt=Gu({name:"Newline",pattern:Ik,pop_mode:!0}),kk=Gu({name:"SimpleKey",pattern:z_.NA});R1(kk,i$);var Glt=Gu({name:"StdTableClose",pattern:/]/,label:"]",push_mode:"Value"}),Hlt=Gu({name:"StdTableOpen",pattern:/\[/,label:"["}),f7=Gu({name:"String",pattern:z_.NA});R1(f7,i$);var oor=Io.default.build("{{whiteSpaceChar}}+",{whiteSpaceChar:zR}),Qlt=Gu({name:"WhiteSpace",pattern:oor,group:z_.SKIPPED}),cor=Io.default.build("^{{whiteSpaceChar}}*{{newline}}(?:{{whiteSpaceChar}}|{{newline}})*",{whiteSpaceChar:zR,newline:Ik}),uor=_=>{let c=Io.default.exec(_,cor);return c?c[0].length:0},Klt=_=>{let c="";for(let f=0;f<_.length;f++){let h=_[f];if(h==="\\"){f++;let S=uor(_.slice(f));if(S>0){f+=S-1;continue}switch(_[f]){case"b":c+="\b";break;case"t":c+=" ";break;case"n":c+=`
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),M=parseInt(k,16);if(M>55295&&M<57344)throw new UR(`Invalid Unicode code point: \\u${k}`);c+=String.fromCodePoint(M),f+=4;break}case"U":{let k=_.slice(f+1,f+9),M=parseInt(k,16);if(M>1114111)throw new UR(`Invalid Unicode code point: \\U${k}`);c+=String.fromCodePoint(M),f+=8;break}case _.match(/^[0-7]{1,3}$/):}}else c+=h}return c},Xlt=_=>_.substring(3,_.length-3).replace(/^(\r\n|\n)/,""),lor=Io.default.build("{{quotationMark}}{3}",{quotationMark:OFe}),_or=Io.default.build("{{whiteSpaceChar}}|!|[#-\\x5B]|[\\x5D-~]|{{nonAscii}}",{whiteSpaceChar:zR,nonAscii:a$}),por=Io.default.build("{{multiLineBasicUnescaped}}|{{escaped}}",{multiLineBasicUnescaped:_or,escaped:Olt}),dor=Io.default.build("{{whiteSpaceChar}}*",{whiteSpaceChar:zR}),mor=Io.default.build("{{escape}}{{whiteSpace}}{{newline}}({{whiteSpaceChar}}|{{newline}})*",{escape:Plt,whiteSpace:dor,newline:Ik,whiteSpaceChar:zR}),hor=Io.default.build("{{multiLineBasicChar}}|{{newline}}|{{multiLineBasicEscapedNewline}}",{multiLineBasicChar:por,newline:Ik,multiLineBasicEscapedNewline:mor}),gor=Io.default.build("{{quotationMark}}{1,2}",{quotationMark:OFe}),yor=Io.default.build("{{multiLineBasicContent}}*({{multiLineBasicQuotes}}{{multiLineBasicContent}}+)*{{multiLineBasicQuotes}}?",{multiLineBasicContent:hor,multiLineBasicQuotes:gor}),Ylt=Gu({name:"MultiLineBasicString",pattern:Io.default.build("{{multiLineBasicStringDelimiter}}{{newline}}?{{multiLineBasicBody}}{{multiLineBasicStringDelimiter}}",{multiLineBasicStringDelimiter:lor,newline:Ik,multiLineBasicBody:yor}),label:'"""MultiLineBasicString"""',categories:[f7],line_breaks:!0});R1(Ylt,_=>{let c=Xlt(_);return Klt(c)});var vor=Io.default.build("{{apostrophe}}{3}",{apostrophe:LFe}),Dor=Io.default.build(" |[ -&]|[\\x28-~]|{{nonAscii}}",{nonAscii:a$}),bor=Io.default.build("{{multiLineLiteralChar}}|{{newline}}",{multiLineLiteralChar:Dor,newline:Ik}),Cor=Io.default.build("{{apostrophe}}{1,2}",{apostrophe:LFe}),Sor=Io.default.build("{{multiLineLiteralContent}}*({{multiLineLiteralQuotes}}{{multiLineLiteralContent}}+)*{{multiLineLiteralQuotes}}?",{multiLineLiteralContent:bor,multiLineLiteralQuotes:Cor}),Zlt=Gu({name:"MultiLineLiteralString",pattern:Io.default.build("{{multiLineLiteralStringDelimiter}}{{newline}}?{{multiLineLiteralBody}}{{multiLineLiteralStringDelimiter}}",{multiLineLiteralStringDelimiter:vor,newline:Ik,multiLineLiteralBody:Sor}),label:"'''MultiLineLiteralString'''",categories:[f7],line_breaks:!0});R1(Zlt,Xlt);var zFe=Gu({name:"QuotedKey",pattern:z_.NA,categories:[kk]});R1(zFe,i$);var Eor=Io.default.build("{{whiteSpaceChar}}|!|[#-\\x5B]|[\\x5D-~]|{{nonAscii}}",{whiteSpaceChar:zR,nonAscii:a$}),xor=Io.default.build("{{basicUnescaped}}|{{escaped}}",{basicUnescaped:Eor,escaped:Olt}),WFe=Gu({name:"BasicString",pattern:Io.default.build("{{quotationMark}}{{basicChar}}*{{quotationMark}}",{quotationMark:OFe,basicChar:xor}),label:'"BasicString"',categories:[zFe,f7]});R1(WFe,_=>{let c=_.slice(1,-1);return Klt(c)});var Tor=Io.default.build(" |[ -&]|[\\x28-~]|{{nonAscii}}",{nonAscii:a$}),VFe=Gu({name:"LiteralString",pattern:Io.default.build("{{apostrophe}}{{literalChar}}*{{apostrophe}}",{apostrophe:LFe,literalChar:Tor}),label:"'LiteralString'",categories:[zFe,f7]});R1(VFe,_=>_.slice(1,-1));var Aor=/0x/,For=/0o/,kor=/0b/,Ior=/[0-7]/,wor=/[01]/,Por=Io.default.build("{{hexPrefix}}{{hexDigit}}({{hexDigit}}|{{underscore}}{{hexDigit}})*",{hexPrefix:Aor,hexDigit:Nlt,underscore:o$}),Nor=Io.default.build("{{octPrefix}}{{digit0_7}}({{digit0_7}}|{{underscore}}{{digit0_7}})*",{octPrefix:For,digit0_7:Ior,underscore:o$}),Oor=Io.default.build("{{binPrefix}}{{digit0_1}}({{digit0_1}}|{{underscore}}{{digit0_1}})*",{binPrefix:kor,digit0_1:wor,underscore:o$}),Lor=Io.default.build("{{hexInteger}}|{{octalInteger}}|{{binaryInteger}}",{hexInteger:Por,octalInteger:Nor,binaryInteger:Oor}),eft=Gu({name:"NonDecimalInteger",pattern:Lor,categories:[c$]}),Ror=(_,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},Mor=_=>{if(_.startsWith("0x"))return 16;if(_.startsWith("0o"))return 8;if(_.startsWith("0b"))return 2};R1(eft,_=>{let c=_.replace(/_/g,"").slice(2),f=Mor(_),h=parseInt(c,f);return Number.isSafeInteger(h)?h:Ror(c,f)});var tft=Gu({name:"DecimalInteger",pattern:Llt,categories:[c$]});R1(tft,_=>{let c=_.replace(/_/g,""),f=parseInt(c);return Number.isSafeInteger(f)?f||0:BigInt(c)});var Bor=/[a-zA-Z]/,jor=Io.default.build("({{alpha}}|{{digit}}|-|_)+",{alpha:Bor,digit:_E}),rft=Gu({name:"UnquotedKey",pattern:jor,categories:[kk]});R1(rft,_=>_);var Jor=/#/,qor=Io.default.build(" |[ -~]|{{nonAscii}}",{nonAscii:a$}),Uor=Io.default.build("{{commentStartChar}}{{nonEol}}*",{commentStartChar:Jor,nonEol:qor}),nft=Gu({name:"Comment",pattern:Uor,group:"comment"}),zor=/true/,ift=Gu({name:"True",pattern:zor,label:"true",categories:[s$]});R1(ift,()=>!0);var Wor=/false/,sft=Gu({name:"False",pattern:Wor,label:"false",categories:[s$]});R1(sft,()=>!1);var Vor=Gu({name:"IgnoredNewline",pattern:Ik,group:z_.SKIPPED}),$or=Gu({name:"InlineTableKeyValSep",pattern:/=/,label:"=",push_mode:"Value",pop_mode:!0,categories:[UFe]}),Slt=[Qlt,WFe,VFe,rft,Ult,kk],Elt=[Qlt,Ylt,Zlt,WFe,VFe,ift,sft,aoe,ooe,eft,tft,Flt,Wlt,nft],aft={modes:{Key:[nft,wFe,UFe,wlt,Ilt,Hlt,Glt,...Slt],Value:[...Elt,$lt,Vlt,PFe],Array:[...Elt,Vor,klt,Alt],InlineTable:[...Slt,$or,PFe]},defaultMode:"Key"},Gor=new z_(aft,{ensureOptimizations:!0,skipValidations:!soe.isDebug(),traceInitPerf:soe.isDebug()}),Hor=class extends uV{toml=this.RULE("toml",()=>{this.MANY(()=>this.CONSUME(wFe)),this.MANY1(()=>{this.SUBRULE1(this.expression),this.OPTION2(()=>{this.CONSUME1($lt),this.MANY3(()=>this.CONSUME2(wFe))})})});valueCache;dottedKey=this.RULE("dottedKey",()=>{this.CONSUME(kk),this.AT_LEAST_ONE(()=>{this.CONSUME(Ult),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:Vlt,DEF:()=>this.SUBRULE(this.keyValue)})});inlineTable=this.RULE("inlineTable",()=>{this.CONSUME(Wlt),this.OPTION(()=>this.SUBRULE(this.inlineTableKeyValues)),this.CONSUME(PFe)});array=this.RULE("array",()=>{this.CONSUME(Flt),this.OPTION(()=>this.SUBRULE(this.arrayValues)),this.CONSUME(Alt)});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(UFe),this.SUBRULE(this.value)});arrayValues=this.RULE("arrayValues",()=>{this.SUBRULE(this.value);let _=!0;this.MANY({GATE:()=>_,DEF:()=>{this.CONSUME(klt),this.OPTION(()=>this.SUBRULE1(this.value))||(_=!1)}})});stdTable=this.RULE("stdTable",()=>{this.CONSUME(Hlt),this.SUBRULE(this.key),this.CONSUME(Glt)});arrayTable=this.RULE("arrayTable",()=>{this.CONSUME(wlt),this.SUBRULE(this.key),this.CONSUME(Ilt)});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(aft,{traceInitPerf:soe.isDebug(),maxLookahead:1,skipValidations:!soe.isDebug()}),this.performSelfAnalysis()}},n$=new Hor,xlt=_=>_&&(_.constructor===Object||_.constructor===void 0),ioe=()=>Object.create(null),kFe=(_,c)=>{try{return _()}catch(f){if(f instanceof qR)throw new Rar(c)}},qR=class extends Error{},Qor=n$.getBaseCstVisitorConstructor(),IFe=Symbol("explicitlyDeclared"),Tlt=Symbol("implicitlyDeclared"),r$=Symbol("notEditable"),Kor=class extends Qor{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);kFe(()=>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 kFe(()=>this.createTable(f,c),`Cannot create table '${f.join(".")}'`)}arrayTable(_,c){let f=this.visit(_.key);return kFe(()=>{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=>NFe[f.name](S.image,S,f.name));return h.length===1?h[0]:h}}assignPrimitiveValue(_,c,f){if(_ in f)throw new qR;return xlt(c)&&(c[IFe]=!0),f[_]=c,f}tryCreatingObject(_,c,f,h,S){if(c[_]){if(!xlt(c[_])||!S&&c[_][IFe]||!h&&c[_][Tlt]||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,Tlt,!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,IFe,!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]}},Xor=new Kor,$Fe=_=>{let c=Gor.tokenize(_);if(c.errors.length>0)throw new Oar(c.errors);n$.input=c.tokens;let f=n$.toml();if(n$.errors.length>0)throw new Lar(n$.errors);return Xor.visit(f)};var b_t=_h(zft(),1);var D_t=_h(woe(),1),rlr={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"},nlr=[{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"}],ilr=["eslint","typescript","test","prettier","knip","typedoc","alexandria"],slr={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],M=S[2];f.has(k)||f.set(k,{lensId:k,operations:new Set}),f.get(k).operations.add(M),h.isLensCommand=!0,h.lensId=k,h.lensOperation=M}}return f.size===0&&this.applyFallbackDetection(c,f),f}static detectLensFromScriptContent(c){if(!c)return null;for(let{pattern:f,lensId:h}of nlr)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=slr[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=rlr[S];if(k){let M=f?.get(S);M!==void 0&&(h[k]=M)}}return h}static getAvailableLenses(c){return Array.from(c.keys())}static getMissingLenses(c){let f=new Set(c.keys());return ilr.filter(h=>!f.has(h))}static calculateQualityProfile(c,f){let h=this.detectLensCommands(c),S=this.calculateMetrics(h,f),k=this.getAvailableLenses(h),M=this.getMissingLenses(h);return{hexagon:S,availableLenses:k,missingLenses:M}}static calculateLensReadiness(c,f,h,S){let k={};for(let[M,X]of Object.entries(D_t.ALL_LENS_REQUIREMENTS))k[M]=this.checkLensRequirements(X,c,f,h,S);return k}static checkLensRequirements(c,f,h,S,k){let M=[],X=[],se={...f,...h};for(let $ of c.devDependencies){let Qe=h[$.name]||f[$.name],Re=!!Qe;M.push({requirement:$,satisfied:Re,foundValue:Qe}),!Re&&$.critical!==!1&&X.push($)}for(let $ of c.scripts){let Qe=S.find(Je=>Je.name===$.name?!0:$.commandPattern&&Je.description?Je.description.includes($.commandPattern):!1),Re=!!Qe;M.push({requirement:$,satisfied:Re,foundValue:Qe?.description||Qe?.command}),!Re&&$.critical!==!1&&X.push($)}for(let $ of c.configs){let Qe=!1,Re;if(k){let Je=c.lensId,St=k[Je];if(St?.exists&&(Qe=!0,Re=St.path),!Qe&&$.alternatives)for(let Jt of $.alternatives){for(let[,Ir]of Object.entries(k))if(Ir?.exists&&Ir.path&&this.matchesConfigPattern(Ir.path,Jt)){Qe=!0,Re=Ir.path;break}if(Qe)break}}M.push({requirement:$,satisfied:Qe,foundValue:Re}),!Qe&&$.critical!==!1&&X.push($)}let de=X.filter($=>$.critical!==!1).length===0,xe=!de&&M.some($=>$.satisfied);return{lensId:c.lensId,displayName:c.displayName,ready:de,partial:xe,checks:M,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 M;return c.repository&&(typeof c.repository=="string"?M=c.repository:c.repository.url&&(M=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:M,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,M])=>{h.push({name:k,command:`npm run ${k}`,description:M.length>50?M.substring(0,47)+"...":M,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"]},M=c==="."||c===""?"":c.endsWith("/")?c:c+"/";if(f.allFiles)for(let[X,se]of Object.entries(k))for(let _e of se){let de=M+_e;if(f.allFiles.some($=>$.path===de||$.relativePath===de)){S[X]={path:de,exists:!0,type:this.getConfigFileType(_e)};break}}return h&&(h.eslintConfig&&(S.eslint={path:M+"package.json",exists:!0,type:"json",isInline:!0,inlineField:"eslintConfig"}),h.prettier&&(S.prettier={path:M+"package.json",exists:!0,type:"json",isInline:!0,inlineField:"prettier"}),h.jest&&(S.jest={path:M+"package.json",exists:!0,type:"json",isInline:!0,inlineField:"jest"}),h.babel&&(S.babel={path:M+"package.json",exists:!0,type:"json",isInline:!0,inlineField:"babel"}),h.vitest&&(S.vitest={path:M+"package.json",exists:!0,type:"json",isInline:!0,inlineField:"vitest"}),h.knip&&(S.knip={path:M+"package.json",exists:!0,type:"json",isInline:!0,inlineField:"knip"}),h.biome&&(S.biome={path:M+"package.json",exists:!0,type:"json",isInline:!0,inlineField:"biome"}),h.stylelint&&(S.stylelint={path:M+"package.json",exists:!0,type:"json",isInline:!0,inlineField:"stylelint"}),h.commitlint&&(S.commitlint={path:M+"package.json",exists:!0,type:"json",isInline:!0,inlineField:"commitlint"}),h["lint-staged"]&&(S["lint-staged"]={path:M+"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 _e of S){let de=k+_e;if(f.allFiles.some($=>$.path?.toLowerCase().startsWith(de.toLowerCase()+"/"))){let $=f.allFiles.find(Qe=>Qe.path?.toLowerCase().startsWith(de.toLowerCase()+"/"))?.path;return $?$.substring(0,$.indexOf("/",k.length)).substring(k.length):_e}}let M=new Map;for(let _e of f.allFiles){if(!_e.path||k!==""&&!_e.path.startsWith(k))continue;let xe=(k===""?_e.path:_e.path.substring(k.length)).split("/");if(xe.length===2){let $=xe[0],Qe=xe[1];M.has($)||M.set($,{docFiles:0,totalFiles:0});let Re=M.get($);Re.totalFiles++,this.isDocumentationFile(Qe)&&Re.docFiles++}}let X,se=.5;for(let[_e,de]of Array.from(M.entries()))if(de.docFiles>=2){let xe=de.docFiles/de.totalFiles;xe>se&&(se=xe,X=_e)}return X}isDocumentationFile(c){let f=c.toLowerCase();return[".md",".mdx",".rst",".txt",".adoc",".asciidoc"].some(M=>f.endsWith(M))?!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(M=>M.test(c))}},Ike=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 $Fe(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,M=c.project,X=k?.name||M?.name||"unnamed",se=k?.version||M?.version,_e={},de={};if(k?.dependencies&&Object.entries(k.dependencies).forEach(([gr,Wn])=>{gr!=="python"&&(_e[gr]=typeof Wn=="string"?Wn:JSON.stringify(Wn))}),k?.["dev-dependencies"]&&Object.entries(k["dev-dependencies"]).forEach(([gr,Wn])=>{de[gr]=typeof Wn=="string"?Wn:JSON.stringify(Wn)}),M?.dependencies&&Array.isArray(M.dependencies))try{let gr=M.dependencies.join(`
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),M=parseInt(k,16);if(M>55295&&M<57344)throw new UR(`Invalid Unicode code point: \\u${k}`);c+=String.fromCodePoint(M),f+=4;break}case"U":{let k=_.slice(f+1,f+9),M=parseInt(k,16);if(M>1114111)throw new UR(`Invalid Unicode code point: \\U${k}`);c+=String.fromCodePoint(M),f+=8;break}case _.match(/^[0-7]{1,3}$/):}}else c+=h}return c},Xlt=_=>_.substring(3,_.length-3).replace(/^(\r\n|\n)/,""),lor=Io.default.build("{{quotationMark}}{3}",{quotationMark:OFe}),_or=Io.default.build("{{whiteSpaceChar}}|!|[#-\\x5B]|[\\x5D-~]|{{nonAscii}}",{whiteSpaceChar:zR,nonAscii:a$}),por=Io.default.build("{{multiLineBasicUnescaped}}|{{escaped}}",{multiLineBasicUnescaped:_or,escaped:Olt}),dor=Io.default.build("{{whiteSpaceChar}}*",{whiteSpaceChar:zR}),mor=Io.default.build("{{escape}}{{whiteSpace}}{{newline}}({{whiteSpaceChar}}|{{newline}})*",{escape:Plt,whiteSpace:dor,newline:Ik,whiteSpaceChar:zR}),hor=Io.default.build("{{multiLineBasicChar}}|{{newline}}|{{multiLineBasicEscapedNewline}}",{multiLineBasicChar:por,newline:Ik,multiLineBasicEscapedNewline:mor}),gor=Io.default.build("{{quotationMark}}{1,2}",{quotationMark:OFe}),yor=Io.default.build("{{multiLineBasicContent}}*({{multiLineBasicQuotes}}{{multiLineBasicContent}}+)*{{multiLineBasicQuotes}}?",{multiLineBasicContent:hor,multiLineBasicQuotes:gor}),Ylt=Gu({name:"MultiLineBasicString",pattern:Io.default.build("{{multiLineBasicStringDelimiter}}{{newline}}?{{multiLineBasicBody}}{{multiLineBasicStringDelimiter}}",{multiLineBasicStringDelimiter:lor,newline:Ik,multiLineBasicBody:yor}),label:'"""MultiLineBasicString"""',categories:[f7],line_breaks:!0});R1(Ylt,_=>{let c=Xlt(_);return Klt(c)});var vor=Io.default.build("{{apostrophe}}{3}",{apostrophe:LFe}),Dor=Io.default.build(" |[ -&]|[\\x28-~]|{{nonAscii}}",{nonAscii:a$}),bor=Io.default.build("{{multiLineLiteralChar}}|{{newline}}",{multiLineLiteralChar:Dor,newline:Ik}),Cor=Io.default.build("{{apostrophe}}{1,2}",{apostrophe:LFe}),Sor=Io.default.build("{{multiLineLiteralContent}}*({{multiLineLiteralQuotes}}{{multiLineLiteralContent}}+)*{{multiLineLiteralQuotes}}?",{multiLineLiteralContent:bor,multiLineLiteralQuotes:Cor}),Zlt=Gu({name:"MultiLineLiteralString",pattern:Io.default.build("{{multiLineLiteralStringDelimiter}}{{newline}}?{{multiLineLiteralBody}}{{multiLineLiteralStringDelimiter}}",{multiLineLiteralStringDelimiter:vor,newline:Ik,multiLineLiteralBody:Sor}),label:"'''MultiLineLiteralString'''",categories:[f7],line_breaks:!0});R1(Zlt,Xlt);var zFe=Gu({name:"QuotedKey",pattern:z_.NA,categories:[kk]});R1(zFe,i$);var Eor=Io.default.build("{{whiteSpaceChar}}|!|[#-\\x5B]|[\\x5D-~]|{{nonAscii}}",{whiteSpaceChar:zR,nonAscii:a$}),xor=Io.default.build("{{basicUnescaped}}|{{escaped}}",{basicUnescaped:Eor,escaped:Olt}),WFe=Gu({name:"BasicString",pattern:Io.default.build("{{quotationMark}}{{basicChar}}*{{quotationMark}}",{quotationMark:OFe,basicChar:xor}),label:'"BasicString"',categories:[zFe,f7]});R1(WFe,_=>{let c=_.slice(1,-1);return Klt(c)});var Tor=Io.default.build(" |[ -&]|[\\x28-~]|{{nonAscii}}",{nonAscii:a$}),VFe=Gu({name:"LiteralString",pattern:Io.default.build("{{apostrophe}}{{literalChar}}*{{apostrophe}}",{apostrophe:LFe,literalChar:Tor}),label:"'LiteralString'",categories:[zFe,f7]});R1(VFe,_=>_.slice(1,-1));var Aor=/0x/,For=/0o/,kor=/0b/,Ior=/[0-7]/,wor=/[01]/,Por=Io.default.build("{{hexPrefix}}{{hexDigit}}({{hexDigit}}|{{underscore}}{{hexDigit}})*",{hexPrefix:Aor,hexDigit:Nlt,underscore:o$}),Nor=Io.default.build("{{octPrefix}}{{digit0_7}}({{digit0_7}}|{{underscore}}{{digit0_7}})*",{octPrefix:For,digit0_7:Ior,underscore:o$}),Oor=Io.default.build("{{binPrefix}}{{digit0_1}}({{digit0_1}}|{{underscore}}{{digit0_1}})*",{binPrefix:kor,digit0_1:wor,underscore:o$}),Lor=Io.default.build("{{hexInteger}}|{{octalInteger}}|{{binaryInteger}}",{hexInteger:Por,octalInteger:Nor,binaryInteger:Oor}),eft=Gu({name:"NonDecimalInteger",pattern:Lor,categories:[c$]}),Ror=(_,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},Mor=_=>{if(_.startsWith("0x"))return 16;if(_.startsWith("0o"))return 8;if(_.startsWith("0b"))return 2};R1(eft,_=>{let c=_.replace(/_/g,"").slice(2),f=Mor(_),h=parseInt(c,f);return Number.isSafeInteger(h)?h:Ror(c,f)});var tft=Gu({name:"DecimalInteger",pattern:Llt,categories:[c$]});R1(tft,_=>{let c=_.replace(/_/g,""),f=parseInt(c);return Number.isSafeInteger(f)?f||0:BigInt(c)});var Bor=/[a-zA-Z]/,jor=Io.default.build("({{alpha}}|{{digit}}|-|_)+",{alpha:Bor,digit:_E}),rft=Gu({name:"UnquotedKey",pattern:jor,categories:[kk]});R1(rft,_=>_);var Jor=/#/,qor=Io.default.build(" |[ -~]|{{nonAscii}}",{nonAscii:a$}),Uor=Io.default.build("{{commentStartChar}}{{nonEol}}*",{commentStartChar:Jor,nonEol:qor}),nft=Gu({name:"Comment",pattern:Uor,group:"comment"}),zor=/true/,ift=Gu({name:"True",pattern:zor,label:"true",categories:[s$]});R1(ift,()=>!0);var Wor=/false/,sft=Gu({name:"False",pattern:Wor,label:"false",categories:[s$]});R1(sft,()=>!1);var Vor=Gu({name:"IgnoredNewline",pattern:Ik,group:z_.SKIPPED}),$or=Gu({name:"InlineTableKeyValSep",pattern:/=/,label:"=",push_mode:"Value",pop_mode:!0,categories:[UFe]}),Slt=[Qlt,WFe,VFe,rft,Ult,kk],Elt=[Qlt,Ylt,Zlt,WFe,VFe,ift,sft,aoe,ooe,eft,tft,Flt,Wlt,nft],aft={modes:{Key:[nft,wFe,UFe,wlt,Ilt,Hlt,Glt,...Slt],Value:[...Elt,$lt,Vlt,PFe],Array:[...Elt,Vor,klt,Alt],InlineTable:[...Slt,$or,PFe]},defaultMode:"Key"},Gor=new z_(aft,{ensureOptimizations:!0,skipValidations:!soe.isDebug(),traceInitPerf:soe.isDebug()}),Hor=class extends uV{toml=this.RULE("toml",()=>{this.MANY(()=>this.CONSUME(wFe)),this.MANY1(()=>{this.SUBRULE1(this.expression),this.OPTION2(()=>{this.CONSUME1($lt),this.MANY3(()=>this.CONSUME2(wFe))})})});valueCache;dottedKey=this.RULE("dottedKey",()=>{this.CONSUME(kk),this.AT_LEAST_ONE(()=>{this.CONSUME(Ult),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:Vlt,DEF:()=>this.SUBRULE(this.keyValue)})});inlineTable=this.RULE("inlineTable",()=>{this.CONSUME(Wlt),this.OPTION(()=>this.SUBRULE(this.inlineTableKeyValues)),this.CONSUME(PFe)});array=this.RULE("array",()=>{this.CONSUME(Flt),this.OPTION(()=>this.SUBRULE(this.arrayValues)),this.CONSUME(Alt)});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(UFe),this.SUBRULE(this.value)});arrayValues=this.RULE("arrayValues",()=>{this.SUBRULE(this.value);let _=!0;this.MANY({GATE:()=>_,DEF:()=>{this.CONSUME(klt),this.OPTION(()=>this.SUBRULE1(this.value))||(_=!1)}})});stdTable=this.RULE("stdTable",()=>{this.CONSUME(Hlt),this.SUBRULE(this.key),this.CONSUME(Glt)});arrayTable=this.RULE("arrayTable",()=>{this.CONSUME(wlt),this.SUBRULE(this.key),this.CONSUME(Ilt)});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(aft,{traceInitPerf:soe.isDebug(),maxLookahead:1,skipValidations:!soe.isDebug()}),this.performSelfAnalysis()}},n$=new Hor,xlt=_=>_&&(_.constructor===Object||_.constructor===void 0),ioe=()=>Object.create(null),kFe=(_,c)=>{try{return _()}catch(f){if(f instanceof qR)throw new Rar(c)}},qR=class extends Error{},Qor=n$.getBaseCstVisitorConstructor(),IFe=Symbol("explicitlyDeclared"),Tlt=Symbol("implicitlyDeclared"),r$=Symbol("notEditable"),Kor=class extends Qor{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);kFe(()=>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 kFe(()=>this.createTable(f,c),`Cannot create table '${f.join(".")}'`)}arrayTable(_,c){let f=this.visit(_.key);return kFe(()=>{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=>NFe[f.name](S.image,S,f.name));return h.length===1?h[0]:h}}assignPrimitiveValue(_,c,f){if(_ in f)throw new qR;return xlt(c)&&(c[IFe]=!0),f[_]=c,f}tryCreatingObject(_,c,f,h,S){if(c[_]){if(!xlt(c[_])||!S&&c[_][IFe]||!h&&c[_][Tlt]||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,Tlt,!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,IFe,!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]}},Xor=new Kor,$Fe=_=>{let c=Gor.tokenize(_);if(c.errors.length>0)throw new Oar(c.errors);n$.input=c.tokens;let f=n$.toml();if(n$.errors.length>0)throw new Lar(n$.errors);return Xor.visit(f)};var b_t=_h(zft(),1);var D_t=_h(woe(),1),rlr={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"},nlr=[{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"}],ilr=["eslint","typescript","test","prettier","knip","typedoc","alexandria"],slr={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],M=S[2];f.has(k)||f.set(k,{lensId:k,operations:new Set}),f.get(k).operations.add(M),h.isLensCommand=!0,h.lensId=k,h.lensOperation=M}}return f.size===0&&this.applyFallbackDetection(c,f),f}static detectLensFromScriptContent(c){if(!c)return null;for(let{pattern:f,lensId:h}of nlr)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=slr[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=rlr[S];if(k){let M=f?.get(S);M!==void 0&&(h[k]=M)}}return h}static getAvailableLenses(c){return Array.from(c.keys())}static getMissingLenses(c){let f=new Set(c.keys());return ilr.filter(h=>!f.has(h))}static calculateQualityProfile(c,f){let h=this.detectLensCommands(c),S=this.calculateMetrics(h,f),k=this.getAvailableLenses(h),M=this.getMissingLenses(h);return{hexagon:S,availableLenses:k,missingLenses:M}}static calculateLensReadiness(c,f,h,S){let k={};for(let[M,X]of Object.entries(D_t.ALL_LENS_REQUIREMENTS))k[M]=this.checkLensRequirements(X,c,f,h,S);return k}static checkLensRequirements(c,f,h,S,k){let M=[],X=[],se={...f,...h};for(let $ of c.devDependencies){let Qe=h[$.name]||f[$.name],Re=!!Qe;M.push({requirement:$,satisfied:Re,foundValue:Qe}),!Re&&$.critical!==!1&&X.push($)}for(let $ of c.scripts){let Qe=S.find(Je=>Je.name===$.name),Re=!!Qe;M.push({requirement:$,satisfied:Re,foundValue:Qe?.description||Qe?.command}),!Re&&$.critical!==!1&&X.push($)}for(let $ of c.configs){let Qe=!1,Re;if(k){let Je=c.lensId,St=k[Je];if(St?.exists&&(Qe=!0,Re=St.path),!Qe&&$.alternatives)for(let Jt of $.alternatives){for(let[,Ir]of Object.entries(k))if(Ir?.exists&&Ir.path&&this.matchesConfigPattern(Ir.path,Jt)){Qe=!0,Re=Ir.path;break}if(Qe)break}}M.push({requirement:$,satisfied:Qe,foundValue:Re}),!Qe&&$.critical!==!1&&X.push($)}let de=X.filter($=>$.critical!==!1).length===0,xe=!de&&M.some($=>$.satisfied);return{lensId:c.lensId,displayName:c.displayName,ready:de,partial:xe,checks:M,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 M;return c.repository&&(typeof c.repository=="string"?M=c.repository:c.repository.url&&(M=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:M,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,M])=>{h.push({name:k,command:`npm run ${k}`,description:M.length>50?M.substring(0,47)+"...":M,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"]},M=c==="."||c===""?"":c.endsWith("/")?c:c+"/";if(f.allFiles)for(let[X,se]of Object.entries(k))for(let _e of se){let de=M+_e;if(f.allFiles.some($=>$.path===de||$.relativePath===de)){S[X]={path:de,exists:!0,type:this.getConfigFileType(_e)};break}}return h&&(h.eslintConfig&&(S.eslint={path:M+"package.json",exists:!0,type:"json",isInline:!0,inlineField:"eslintConfig"}),h.prettier&&(S.prettier={path:M+"package.json",exists:!0,type:"json",isInline:!0,inlineField:"prettier"}),h.jest&&(S.jest={path:M+"package.json",exists:!0,type:"json",isInline:!0,inlineField:"jest"}),h.babel&&(S.babel={path:M+"package.json",exists:!0,type:"json",isInline:!0,inlineField:"babel"}),h.vitest&&(S.vitest={path:M+"package.json",exists:!0,type:"json",isInline:!0,inlineField:"vitest"}),h.knip&&(S.knip={path:M+"package.json",exists:!0,type:"json",isInline:!0,inlineField:"knip"}),h.biome&&(S.biome={path:M+"package.json",exists:!0,type:"json",isInline:!0,inlineField:"biome"}),h.stylelint&&(S.stylelint={path:M+"package.json",exists:!0,type:"json",isInline:!0,inlineField:"stylelint"}),h.commitlint&&(S.commitlint={path:M+"package.json",exists:!0,type:"json",isInline:!0,inlineField:"commitlint"}),h["lint-staged"]&&(S["lint-staged"]={path:M+"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 _e of S){let de=k+_e;if(f.allFiles.some($=>$.path?.toLowerCase().startsWith(de.toLowerCase()+"/"))){let $=f.allFiles.find(Qe=>Qe.path?.toLowerCase().startsWith(de.toLowerCase()+"/"))?.path;return $?$.substring(0,$.indexOf("/",k.length)).substring(k.length):_e}}let M=new Map;for(let _e of f.allFiles){if(!_e.path||k!==""&&!_e.path.startsWith(k))continue;let xe=(k===""?_e.path:_e.path.substring(k.length)).split("/");if(xe.length===2){let $=xe[0],Qe=xe[1];M.has($)||M.set($,{docFiles:0,totalFiles:0});let Re=M.get($);Re.totalFiles++,this.isDocumentationFile(Qe)&&Re.docFiles++}}let X,se=.5;for(let[_e,de]of Array.from(M.entries()))if(de.docFiles>=2){let xe=de.docFiles/de.totalFiles;xe>se&&(se=xe,X=_e)}return X}isDocumentationFile(c){let f=c.toLowerCase();return[".md",".mdx",".rst",".txt",".adoc",".asciidoc"].some(M=>f.endsWith(M))?!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(M=>M.test(c))}},Ike=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 $Fe(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,M=c.project,X=k?.name||M?.name||"unnamed",se=k?.version||M?.version,_e={},de={};if(k?.dependencies&&Object.entries(k.dependencies).forEach(([gr,Wn])=>{gr!=="python"&&(_e[gr]=typeof Wn=="string"?Wn:JSON.stringify(Wn))}),k?.["dev-dependencies"]&&Object.entries(k["dev-dependencies"]).forEach(([gr,Wn])=>{de[gr]=typeof Wn=="string"?Wn:JSON.stringify(Wn)}),M?.dependencies&&Array.isArray(M.dependencies))try{let gr=M.dependencies.join(`
982
982
  `);(0,b_t.parsePipRequirementsFile)(gr).forEach(Xn=>{if(Xn.type==="ProjectName"&&Xn.name){let Xr="*";Xn.versionSpec&&Xn.versionSpec.length>0&&(Xr=Xn.versionSpec[0].version||"*"),_e[Xn.name]=Xr}})}catch(gr){console.warn("Failed to parse PEP 621 dependencies with pip-requirements-js, falling back to simple parsing:",gr),M.dependencies.forEach(Wn=>{let Xn=Wn.trim(),Xr=Xn.indexOf(" ");Xr>0?_e[Xn.substring(0,Xr)]="*":_e[Xn]="*"})}let xe=this.detectPythonPackageManager(c),$=k?.description||M?.description,Qe;k?.license?Qe=k.license:M?.license&&(Qe=typeof M.license=="string"?M.license:M.license.text);let Re,Je;k?.authors&&k.authors.length>0?(Re=k.authors,Je=k.authors[0]):M?.authors&&M.authors.length>0&&(Re=M.authors.map(gr=>gr.name&&gr.email?`${gr.name} <${gr.email}>`:gr.name||gr.email||"").filter(Boolean),Je=Re[0]);let St,Jt;k?(St=k.repository,Jt=k.homepage):M?.urls&&(St=M.urls.repository||M.urls.Repository||M.urls.source||M.urls.Source,Jt=M.urls.homepage||M.urls.Homepage||M.urls.home||M.urls.Home);let Ir=k?.keywords||M?.keywords;return{name:X,version:se,path:h,manifestPath:f,packageManager:xe,dependencies:_e,devDependencies:de,peerDependencies:{},description:$,license:Qe,author:Je,authors:Re,repository:St,homepage:Jt,keywords:Ir,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,{})}},wke=class{manifestFileName="Cargo.toml";packageType="cargo";canParse(c){return c.endsWith("Cargo.toml")}parseContent(c){try{return $Fe(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={},M={};c.dependencies&&Object.entries(c.dependencies).forEach(([_e,de])=>{k[_e]=typeof de=="string"?de:JSON.stringify(de)}),c["dev-dependencies"]&&Object.entries(c["dev-dependencies"]).forEach(([_e,de])=>{M[_e]=typeof de=="string"?de:JSON.stringify(de)});let X=h.authors?.[0],se=h.homepage||h.documentation;return{name:h.name||"unnamed",version:h.version,path:S,manifestPath:f,packageManager:"cargo",dependencies:k,devDependencies:M,peerDependencies:{},description:h.description,license:h.license,author:X,authors:h.authors,repository:h.repository,homepage:se,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 Ike,new wke];async discoverPackages(c,f){let h=[];if(!c.allFiles)return h;let S=c.allFiles.filter(_e=>_e.path?this.parsers.some(de=>de.canParse(_e.path)):!1),k=c.allFiles.map(_e=>_e.path).filter(Boolean);for(let _e of S){if(!_e.path)continue;let de=this.parsers.find(Xr=>Xr.canParse(_e.path));if(!de)continue;let xe=null;if(f)try{let Xr=await f(_e.path);Xr&&(xe=de.parseContent(Xr))}catch(Xr){console.warn(`Could not read or parse ${_e.path}:`,Xr);continue}else{let Xr=_e.path.split("/").slice(-2,-1)[0]||"unnamed";xe=this.createMinimalManifest(de.packageType,Xr)}if(!xe)continue;let $=de.extractPackageData(xe,_e.path);if(!$){console.warn(`[PackageLayerModule] extractPackageData returned null for ${_e.path}`,{content:xe,parser:de.packageType});continue}let Qe=_e.path.substring(0,_e.path.lastIndexOf("/")),Re=k.filter(Xr=>Xr.startsWith(Qe)&&this.isLockFile(Xr));$.packageManager=de.detectPackageManager(xe,Re),de.packageType==="node"&&$.availableCommands&&$.packageManager&&$.packageManager!=="unknown"&&$.packageManager!=="npm"&&($.availableCommands=$.availableCommands.map(Xr=>{if(Xr.command.includes("npm ")){let jr=Xr.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")),{...Xr,command:jr}}return Xr}));let Je={id:`package-manifest-${$.path}`,name:de.manifestFileName,patterns:[{type:"exact",pattern:_e.path,description:`${de.packageType} package manifest`}],matchedFiles:[_e.path],fileCount:1},St;de.detectConfigs&&(St=de.detectConfigs($.path,c,xe));let Jt;de.detectDocsFolder&&(Jt=de.detectDocsFolder($.path,c,xe));let Ir=$.availableCommands?v7.calculateQualityProfile($.availableCommands):void 0,gr=v7.calculateLensReadiness($.dependencies,$.devDependencies,$.availableCommands||[],St),Wn=Ir?{...Ir,lensReadiness:gr}:{hexagon:{},availableLenses:[],missingLenses:[],lensReadiness:gr},Xn={id:`package-${de.packageType}-${$.path.replace(/[^a-zA-Z0-9-]/g,"-")}`,name:$.name,type:de.packageType,enabled:!0,derivedFrom:{fileSets:[Je],derivationType:"content",description:`${de.packageType} package defined in ${de.manifestFileName}`,contentExtraction:{method:"parse",parser:{format:de.manifestFileName.endsWith(".json")?"json":"toml",paths:de.packageType==="node"?[""]:de.packageType==="python"?["tool.poetry","project"]:["package"]}}},packageData:$,configFiles:St,docsFolder:Jt,qualityMetrics:Wn,pillar:"foundationHealth"};h.push(Xn)}this.resolveWorkspaceRelationships(h);let M=h.find(_e=>_e.packageData.path===""||_e.packageData.path==="."),{orchestrator:X}=this.detectMonorepoOrchestrator(k),se=M?.packageData.isMonorepoRoot||X!=="none";if(M&&se){X!=="none"&&!M.packageData.isMonorepoRoot&&(M.packageData.isMonorepoRoot=!0);let _e=S.find($=>$.path==="package.json"||$.path==="./package.json"),de;if(_e&&f)try{let $=await f(_e.path),Qe=JSON.parse($);de=new XR().detectWorkspaces(Qe)||void 0}catch{}let xe=await this.buildMonorepoMetadata(k,de,f,M.configFiles);xe&&(M.packageData.monorepoMetadata=xe)}return this.propagateRootConfigs(h,M),this.recalculateLensReadinessWithInheritance(h,M),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(M=>M.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,M]of Object.entries(S)){let X=k.split("#"),se=X.length>1?k:void 0,_e=X.length>1?X[1]:k,de=this.inferToolFromTaskName(_e);h.push({name:_e,tool:de,filter:se})}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 M=this.inferToolFromTaskName(S);h.push({name:S,tool:M})}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:M}=this.detectMonorepoOrchestrator(c);if(k==="none"&&!f)return;let X={orchestrator:k,orchestratorConfigPath:M,workspacePatterns:f};if(M&&h)try{let xe=await h(M);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:se,hasSourceCode:_e,sourceDirs:de}=this.detectRootRole(c);return X.rootRole=se,X.rootHasSourceCode=_e,de.length>0&&(X.rootSourceDirs=de),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=[],M=[];for(let de of c)if(!(de.startsWith("packages/")||de.startsWith("apps/")||de.startsWith("libs/")||de.startsWith("node_modules/"))){for(let xe of f)de.startsWith(`${xe}/`)&&S.some(Qe=>de.endsWith(Qe))&&!k.includes(xe)&&k.push(xe);for(let xe of h)de.startsWith(`${xe}/`)&&S.some(Qe=>de.endsWith(Qe))&&!M.includes(xe)&&M.push(xe)}let X=k.length>0,se=M.length>0,_e=[...k,...M];return X?{role:"application",hasSourceCode:!0,sourceDirs:_e}:se?{role:"hybrid",hasSourceCode:!0,sourceDirs:_e}:{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,M]of Object.entries(h)){if(!M||!M.exists)continue;let X=S.configFiles[k];(!X||!X.exists)&&(S.configFiles[k]={...M,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(M=>M?.isInherited)))continue;let k=v7.calculateLensReadiness(h.packageData.dependencies,h.packageData.devDependencies,h.packageData.availableCommands||[],h.configFiles);for(let[M,X]of Object.entries(k)){let se=h.qualityMetrics?.lensReadiness?.[M];if(X.ready&&se&&!se.ready){X.readyViaInheritance=!0;let _e=X.checks.filter(de=>de.satisfied?h.configFiles?.[M]?.isInherited&&de.requirement.type==="config":!1).length;_e>0&&(X.inheritedChecks=_e)}}h.qualityMetrics&&(h.qualityMetrics.lensReadiness=k)}}};var B1=_h(upt(),1);var vpt=_h(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 gr={path:c,name:c.split("/").pop()||c,children:[],fileCount:0,totalSize:0,depth:0,relativePath:"."};return{sha:"",root:gr,allFiles:[],allDirectories:[gr],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 M=[],X;for(let gr of S)gr.enabled&&gr.filterData?.excludedPatterns&&(M.push(...gr.filterData.excludedPatterns.map(Wn=>Wn.pattern)),gr.filterData.sourceDirectory&&(X=gr.filterData.sourceDirectory));let se=await this.adapter.buildFilteredFileTree(c,M,X),_e=se.paths,de=se.stats,xe=this.createIgnoreInstances(S);for(let gr of _e)this.shouldIncludeFile(gr,xe,S)||this.filterStats.totalFiltered++;console.timeEnd("[FilesystemService] Build file tree"),console.log(`[FilesystemService] Found ${_e.length} paths after filtering`),console.time("[FilesystemService] Convert to tree structure");let{allFiles:$,allDirectories:Qe,rootDir:Re}=await this.convertPathsToTree(_e,c,de);console.timeEnd("[FilesystemService] Convert to tree structure");let Je=[];k&&(Je=await this.findInverseMatches(c,xe,S));let St=$.reduce((gr,Wn)=>gr+(Wn.size||0),0),Jt=Math.max(...Qe.map(gr=>gr.depth||0));S.forEach(gr=>{gr.enabled&&this.filterStats.filteredByLayer[gr.id]&&(gr.filterData.stats||(gr.filterData.stats={totalFiltered:0,bytesExcluded:0}),gr.filterData.stats.totalFiltered=this.filterStats.filteredByLayer[gr.id])});let Ir={sha:"",root:Re||{path:".",name:$4.basename(c)||"root",children:[],fileCount:0,totalSize:0,depth:0,relativePath:"."},allFiles:$,allDirectories:Qe,stats:{totalFiles:$.length,totalDirectories:Qe.length,totalSize:St,maxDepth:Jt},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"),Ir}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}`,M=(0,vpt.default)(),X=h.filterData.excludedPatterns.map(se=>se.pattern);M.add(X),f.set(k,{ignore:M,sourceDirectory:S,filterId:h.id,filterName:h.name})}return f}shouldIncludeFile(c,f,h){for(let[,{ignore:S,sourceDirectory:k,filterId:M,filterName:X}]of f){if(k!==""&&!c.startsWith(k+"/")&&c!==k)continue;let se=c;if(k!==""&&c.startsWith(k+"/")&&(se=c.slice(k.length+1)),!(!se||se===".")&&S.ignores(se)){this.filterStats.totalFiltered++,this.filterStats.filteredByLayer[M]=(this.filterStats.filteredByLayer[M]||0)+1;let _e=$4.dirname(c)||".";return this.filterStats.filteredByDirectory[_e]||(this.filterStats.filteredByDirectory[_e]={count:0,reasons:new Set}),this.filterStats.filteredByDirectory[_e].count++,this.filterStats.filteredByDirectory[_e].reasons.add(X),!1}}return!0}async convertPathsToTree(c,f,h){let S=[],k=[],M=new Map,X=h||new Map;if(!h&&this.adapter&&"getFileStats"in this.adapter){let _e=c.map(async de=>{try{let xe=$4.join(f,de),$=await this.adapter.getFileStats(xe);$&&X.set(de,{size:$.size||0,lastModified:$.lastModified||new Date,isDirectory:$.isDirectory||!1})}catch{}});await Promise.all(_e)}for(let _e of c){let de=X.get(_e);if(de?.isDirectory||_e.endsWith("/")){let $={path:_e||".",name:$4.basename(_e)||"root",children:[],fileCount:0,totalSize:0,depth:_e.split("/").length-1,relativePath:_e||"."};k.push($),M.set(_e,$)}else{let $={path:_e,name:$4.basename(_e),extension:$4.extname(_e).toLowerCase(),size:de?.size||0,lastModified:de?.lastModified||new Date,isDirectory:!1,relativePath:_e};S.push($)}}let se=M.get(".")||M.get("")||{path:".",name:$4.basename(f)||"root",children:[],fileCount:S.length,totalSize:S.reduce((_e,de)=>_e+(de.size||0),0),depth:0,relativePath:"."};return{allFiles:S,allDirectories:k,rootDir:se}}async findInverseMatches(c,f,h){console.log("[FilesystemService] Running inverse filter analysis...");let S=[];if(!this.adapter)return[];let M=(await this.adapter.buildFilteredFileTree(c)).paths;console.log(`[FilesystemService] Found ${M.length} total paths for inverse analysis`);for(let X of M){let se=[];for(let[,{ignore:_e,sourceDirectory:de,filterName:xe}]of f){if(de!==""&&!X.startsWith(de+"/")&&X!==de)continue;let $=X;de!==""&&X.startsWith(de+"/")&&($=X.slice(de.length+1)),!(!$||$===".")&&_e.ignores($)&&se.push(xe)}se.length>0&&S.push({path:X,matchedFilters:se})}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=_h(require("fs/promises"),1),l6e=_h(require("path"),1),Dpt=_h(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,M=f&&f.length>0?(0,Dpt.default)().add(f):null,X=async(se,_e="")=>{try{let de=await TC.readdir(se,{withFileTypes:!0});for(let xe of de){let $=l6e.join(se,xe.name),Qe=_e?l6e.join(_e,xe.name):xe.name;if(!(M&&M.ignores(Qe))&&!(xe.isDirectory()&&this.shouldSkipDirectory(xe.name)))if(xe.isDirectory()){S.push(Qe+"/");let Re=await TC.stat($);k.set(Qe+"/",{size:0,isDirectory:!0,lastModified:Re.mtime}),await X($,Qe)}else{S.push(Qe);let Re=await TC.stat($);k.set(Qe,{size:Re.size,isDirectory:!1,lastModified:Re.mtime})}}}catch(de){console.warn(`Error walking directory ${se}:`,de)}};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 lfr=_h(qoe(),1);var jT=_h(require("path")),G4=_h(require("fs/promises")),f6e=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 f6e(f),S=async M=>(await h.readFile(M))?.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=_h(woe());var _6e=require("child_process"),p6e=require("stream"),Uoe=class{constructor(){this.type="node"}async execute(c,f=[],h={}){let S=Date.now();return new Promise(k=>{let M="",X="",_e={...h.env||process.env};delete _e.NODE_OPTIONS,delete _e.TS_NODE_PROJECT,delete _e.TS_NODE_TRANSPILE_ONLY;let de=(0,_6e.spawn)(c,f,{cwd:h.cwd,env:_e,shell:!0});de.stdout&&de.stdout.on("data",$=>{M+=$.toString()}),de.stderr&&de.stderr.on("data",$=>{X+=$.toString()});let xe;h.timeout&&(xe=setTimeout(()=>{de.kill("SIGTERM")},h.timeout)),de.on("error",$=>{xe&&clearTimeout(xe),k({stdout:M,stderr:X||$.message,exitCode:1,duration:Date.now()-S,command:c,args:f,error:$})}),de.on("close",$=>{xe&&clearTimeout(xe),k({stdout:M,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 M=(0,_6e.spawn)(c,f,{cwd:h.cwd,env:k,shell:!0}),X=new Promise(se=>{let _e="",de="",xe=Date.now();M.stdout&&M.stdout.on("data",$=>{_e+=$.toString()}),M.stderr&&M.stderr.on("data",$=>{de+=$.toString()}),M.on("close",$=>{se({stdout:_e,stderr:de,exitCode:$??0,duration:Date.now()-xe,command:c,args:f})}),M.on("error",$=>{se({stdout:_e,stderr:de||$.message,exitCode:1,duration:Date.now()-xe,command:c,args:f,error:$})})});return{stdout:M.stdout||new p6e.Readable({read(){}}),stderr:M.stderr||new p6e.Readable({read(){}}),exitPromise:X,kill:()=>{M.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 M=new qp.BiomeLens(this.executor);M.setMode("lint"),this.lenses.set("biome-lint",M),this.lenses.set("biome",M);let X=new qp.BiomeLens(this.executor);X.setMode("format"),this.lenses.set("biome-format",X);let se=new qp.GitLens(this.executor);this.lenses.set("git",se);let _e=new qp.AlexandriaLens(this.executor);this.lenses.set("alexandria",_e),this.lenses.set("docs",_e)}async checkIfBunTestRunner(c,f){try{let h=await import("fs/promises"),k=(await import("path")).join(c,"package.json"),M=await h.readFile(k,"utf-8"),X=JSON.parse(M),se=f.replace(/^(npm|yarn|pnpm)\s+run\s+/,"").split(" ")[0]||"test",_e=X.scripts?.[se];return!!(_e&&(_e.startsWith("bun test")||_e.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(M=>f.has(M.extension)).map(M=>M.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 M=S.packageData.path||"",X=M?`${h}/${M}`: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 se=await this.getLensForExecution(k.lensId,X,k.command);if(!se)return console.warn(`[QualityLensService] No lens registered for: ${k.lensId}`),this.executeNonLensCommand(c,k,X,f);console.log(`[QualityLensService] Using ${se.name} for command: ${k.name} (lensId: ${k.lensId})`);try{let{command:_e,args:de}=this.parseCommandString(k.command);se.configure({cwd:X,tool:{name:k.lensId,command:_e,args:de,cwd:X,available:!0}});let xe=await se.run(),{success:$,exitCode:Qe}=this.determineLensSuccess(xe);return{success:$,toolName:k.lensId,command:k.command,packagePath:M,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(_e){console.error("[QualityLensService] Error:",_e);let de=_e instanceof Error?_e:new Error(String(_e));return this.createErrorResponse(k.lensId||k.name,k.command,M,de,f)}}async executeNonLensCommand(c,f,h,S){let{command:k,args:M}=this.parseCommandString(f.command);try{let X=await this.executor.execute(k,M,{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 se=X instanceof Error?X:new Error(String(X));return this.createErrorResponse(f.name,f.command,c.packageLayer?.packageData.path,se,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 M=S.split("/"),X="";for(let se=0;se<M.length-1;se++){let _e=M[se]??"";X=X?`${X}/${_e}`:_e;let de=this.fileCountsByPackage.get(X)||0;this.fileCountsByPackage.set(X,de+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(k=>!!(k.packagePath&&k.packagePath!=="")).map(k=>({name:k.package,path:k.packagePath})).filter((k,M,X)=>X.findIndex(se=>se.path===k.path)===M);if(f.length===0)return c;let h=new Map,S=[];for(let k of c){if(k.packagePath&&k.packagePath!==""){S.push(k);continue}let M=k.result?.lensResult?.issues;if(!M||M.length===0){S.push(k);continue}let X=[];for(let se of M){let _e=this.getIssuePath(se);if(!_e){X.push(se);continue}let de=this.findOwningPackage(_e,f);if(de){let xe=de.path,$=h.get(xe);$||($=new Map,h.set(xe,$));let Qe=$.get(k.lens);Qe||(Qe=[],$.set(k.lens,Qe));let Re=_e.slice(de.path.length+1),Je={...se,file:Re,originalPath:_e};Qe.push(Je)}else X.push(se)}if(k.result?.lensResult){let se={...k,result:{...k.result,lensResult:{...k.result.lensResult,issues:X,metrics:this.recalculateMetricsFromIssues(k.result.lensResult.metrics,X)}}};S.push(se)}else S.push(k)}for(let[k,M]of h){let X=f.find(se=>se.path===k);if(X)for(let[se,_e]of M){let de=S.findIndex(xe=>xe.packagePath===k&&xe.lens===se);if(de>=0){let xe=S[de];if(xe?.result?.lensResult){let Qe=[...xe.result.lensResult.issues||[],..._e];S[de]={...xe,result:{...xe.result,lensResult:{...xe.result.lensResult,issues:Qe,metrics:this.recalculateMetricsFromIssues(xe.result.lensResult.metrics,Qe)}}}}}else{let xe=c.find(Qe=>Qe.lens===se&&(!Qe.packagePath||Qe.packagePath==="")),$={lensName:se,tool:se,timestamp:Date.now(),success:!0,issues:_e,metrics:this.createMetricsFromIssues(_e)};S.push({package:X.name,packagePath:X.path,lens:se,command:xe?.command||se,timestamp:xe?.timestamp||Date.now(),result:{success:!0,toolName:se,command:xe?.command||se,packagePath:X.path,exitCode:_e.length>0?1:0,duration:0,stdout:"",stderr:"",lensResult:$}})}}}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 M=new Set(k.map(xe=>xe.file)).size,X=c.packagePath||"",se=this.getFileCountForPackage(X);if(se===0){let xe=c.result?.lensResult?.metrics?.filesAnalyzed||1,$=Math.max(0,xe-M);return Math.round($/xe*100)}let _e=Math.max(0,se-M);return Math.round(_e/se*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:M}]of f)h.push({name:S,path:k,hexagon:this.calculateHexagonMetrics(M)});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(M=>({package:{name:M.package,path:M.packagePath},lens:{id:M.lens,command:M.command},execution:{success:M.result?.success??!1,exitCode:M.result?.exitCode,duration:M.result?.duration,timestamp:M.timestamp},issues:M.result?.lensResult?.issues||[],metrics:M.result?.lensResult?.metrics||{},coverage:M.result?.lensResult?.coverage,fileMetrics:M.result?.lensResult?.fileMetrics,qualityContext:M.result?.qualityContext||{},error:M.error}))};return S.length>0&&(k.qualityMetrics={packages:S}),JSON.stringify(k,null,2)}};var bpt=(_=0)=>c=>`\x1B[${c+_}m`,Cpt=(_=0)=>c=>`\x1B[${38+_};5;${c}m`,Spt=(_=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]}},pPr=Object.keys(rd.modifier),pfr=Object.keys(rd.color),dfr=Object.keys(rd.bgColor),dPr=[...pfr,...dfr];function mfr(){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=bpt(),rd.color.ansi256=Cpt(),rd.color.ansi16m=Spt(),rd.bgColor.ansi=bpt(10),rd.bgColor.ansi256=Cpt(10),rd.bgColor.ansi16m=Spt(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 M=30+(Math.round(S)<<2|Math.round(h)<<1|Math.round(f));return k===2&&(M+=60),M},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 hfr=mfr(),hE=hfr;var $oe=_h(require("node:process"),1),xpt=_h(require("node:os"),1),d6e=_h(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 gfr(){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 yfr(_){return _===0?!1:{level:_,hasBasic:!0,has256:_>=2,has16m:_>=3}}function vfr(_,{streamIsTTY:c,sniffFlags:f=!0}={}){let h=gfr();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 M=xpt.default.release().split(".");return Number(M[0])>=10&&Number(M[2])>=10586?Number(M[2])>=14931?3:2:1}if("CI"in nd)return["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some(M=>M in nd)?3:["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(M=>M 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 M=Number.parseInt((nd.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(nd.TERM_PROGRAM){case"iTerm.app":return M>=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 Ept(_,c={}){let f=vfr(_,{streamIsTTY:_&&_.isTTY,...c});return yfr(f)}var Dfr={stdout:Ept({isTTY:d6e.default.isatty(1)}),stderr:Ept({isTTY:d6e.default.isatty(2)})},Tpt=Dfr;function Apt(_,c,f){let h=_.indexOf(c);if(h===-1)return _;let S=c.length,k=0,M="";do M+=_.slice(k,h)+c+f,k=h+S,h=_.indexOf(c,k);while(h!==-1);return M+=_.slice(k),M}function Fpt(_,c,f,h){let S=0,k="";do{let M=_[h-1]==="\r";k+=_.slice(S,M?h-1:h)+c+(M?`\r
983
983
  `:`
984
984
  `)+f,S=h+1,h=_.indexOf(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@principal-ai/quality-lens-cli",
3
- "version": "0.1.54",
3
+ "version": "0.1.55",
4
4
  "description": "CLI tool for running quality lenses on codebases in CI/CD pipelines",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -42,7 +42,7 @@
42
42
  "author": "Principal AI",
43
43
  "license": "MIT",
44
44
  "devDependencies": {
45
- "@principal-ai/codebase-composition": "^0.2.19",
45
+ "@principal-ai/codebase-composition": "^0.2.20",
46
46
  "@principal-ai/codebase-quality-lenses": "^0.1.38",
47
47
  "@principal-ai/repository-abstraction": "^0.2.0",
48
48
  "@types/jest": "^30.0.0",