@lisa.ai/agent 2.9.7 → 2.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +189 -72
  2. package/dist/index.js +283 -155
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var jt=Object.create;var _e=Object.defineProperty;var Et=Object.getOwnPropertyDescriptor;var Ft=Object.getOwnPropertyNames;var At=Object.getPrototypeOf,Pt=Object.prototype.hasOwnProperty;var It=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Tt=(e,t,s,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ft(t))!Pt.call(e,o)&&o!==s&&_e(e,o,{get:()=>t[o],enumerable:!(n=Et(t,o))||n.enumerable});return e};var b=(e,t,s)=>(s=e!=null?jt(At(e)):{},Tt(t||!e||!e.__esModule?_e(s,"default",{value:e,enumerable:!0}):s,e));var Lt=It((tn,Kt)=>{Kt.exports={name:"@lisa.ai/agent",version:"2.9.7",description:"Lisa.ai Autonomous CI/CD Worker Agent",main:"dist/index.js",bin:{"lisa-agent":"dist/index.js"},files:["dist/"],scripts:{build:"tsup",typecheck:"tsc --noEmit",start:"node dist/index.js",dev:"ts-node src/index.ts",prepublishOnly:"npm run typecheck && npm run build"},keywords:["lisa","ci","cd","agent"],author:"Lisa.ai",license:"ISC",dependencies:{"@ai-sdk/anthropic":"^3.0.46","@ai-sdk/google":"^3.0.30","@ai-sdk/openai":"^3.0.30","@octokit/rest":"^22.0.1",ai:"^6.0.94",commander:"^11.1.0",dotenv:"^17.3.1","simple-git":"^3.31.1"},devDependencies:{"@types/jest":"^30.0.0","@types/node":"^20.0.0","ts-node":"^10.9.1",tsup:"^8.5.1",typescript:"^5.0.0"}}});var kt=require("commander"),X=b(require("fs")),he=b(require("path")),Ct=b(require("readline"));var Oe=b(require("dotenv"));Oe.config({quiet:!0});async function ye(e){let t=process.env.LISA_CONTROL_PLANE_URL||"http://localhost:3088";try{let s=`${t}/api/v1/lisa/config/${e}`;console.log(`[Lisa.ai Agent] Fetching dynamic configuration from ${s}...`);let n=await fetch(s);if(!n.ok){let i=n.status===404?"not_found":"unreachable";return console.warn(i==="not_found"?`[Lisa.ai Agent Warning] Control Plane returned 404. Project '${e}' not found.`:`[Lisa.ai Agent Warning] Control Plane returned ${n.status}. Falling back to local defaults.`),{ok:!1,reason:i}}return{ok:!0,config:await n.json()}}catch{return console.warn(`[Lisa.ai Agent Warning] Failed to reach Control Plane (${t}). Using local fallback configuration.`),{ok:!1,reason:"unreachable"}}}var rt=require("child_process"),H=b(require("fs")),Z=b(require("path"));var S=b(require("path")),R=b(require("fs"));function we(e){return e.replace(/\x1B\[[0-9;]*[a-zA-Z]/g,"")}function Y(e){let t=we(e),s=[...t.matchAll(/Executed\s+(\d+)\s+of\s+(\d+)(?:\s+\((\d+)\s+FAILED\))?/g)];if(s.length>0){let g=[...s].reverse().find(f=>f[3]!==void 0)??s[s.length-1],d=parseInt(g[2]),x=g[3]?parseInt(g[3]):0,h=parseInt(g[1])-x;return{total:d,passed:h,failed:x}}let n=t.match(/Tests:\s+(?:(\d+)\s+failed,?\s*)?(?:(\d+)\s+passed,?\s*)?(\d+)\s+total/);if(n){let g=parseInt(n[3]),d=n[1]?parseInt(n[1]):0,x=n[2]?parseInt(n[2]):0;return{total:g,passed:x,failed:d}}let o=t.match(/(\d+)\s+failed/),i=t.match(/(\d+)\s+passed/);if(i||o){let g=o?parseInt(o[1]):0,d=i?parseInt(i[1]):0,x=t.match(/(\d+)\s+skipped/),h=x?parseInt(x[1]):0;return{total:d+g+h,passed:d,failed:g}}let r=t.match(/Tests\s+(?:(\d+)\s+failed\s*\|?\s*)?(\d+)\s+passed\s*\((\d+)\)/);if(r){let g=parseInt(r[3]),d=r[1]?parseInt(r[1]):0,x=parseInt(r[2]);return{total:g,passed:x,failed:d}}let a=t.match(/(\d+)\s+passing/),p=t.match(/(\d+)\s+failing/);if(a){let g=parseInt(a[1]),d=p?parseInt(p[1]):0;return{total:g+d,passed:g,failed:d}}return null}function Fe(e,t=process.cwd(),s=[]){let n=e.replace(/\x1B\[[0-9;]*[a-zA-Z]/g,""),o=s.map(l=>S.resolve(t,l)),i=new Map,r=new Set,a=/(?:Chrome|Firefox|Safari)(?:\s+Headless)?\s+[\d.]+(?:\s+[\d.]+)*\s+\([^)]+\)\s+(.+?)\s+FAILED/g,p;for(;(p=a.exec(n))!==null;){let u=p[1].trim().split(" ");for(let c=1;c<Math.min(u.length,6);c++){let L=u.slice(0,c).join(" ");if(r.has(L))continue;r.add(L);let $=Ae(L,t,o);if($){let m=S.resolve($);i.has(m)||i.set(m,S.relative(t,$));break}}}let g=/^FAIL\s+([a-zA-Z0-9_./-\\]+\.(?:spec|test)\.(ts|tsx|js|jsx))/gm,d;for(;(d=g.exec(n))!==null;){let l=d[1],u=S.isAbsolute(l)?l:S.resolve(t,l);!o.includes(u)&&R.existsSync(u)&&!i.has(u)&&i.set(u,S.relative(t,u))}let x=/\[(?:chromium|firefox|webkit)\]\s+[>›]\s+([^\s:]+\.(?:spec|test)\.[tj]sx?):\d+:\d+\s+[>›]/g,h;for(;(h=x.exec(n))!==null;){let l=h[1],u=S.isAbsolute(l)?l:S.resolve(t,l);!o.includes(u)&&R.existsSync(u)&&!i.has(u)&&i.set(u,S.relative(t,u))}let f=/Running:\s+([^\s]+\.(?:cy|spec|test)\.[tj]sx?)/g,w;for(;(w=f.exec(n))!==null;){let l=w[1],u=S.isAbsolute(l)?l:S.resolve(t,l);if(!o.includes(u)&&R.existsSync(u)&&!i.has(u)){let c=l.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");new RegExp(c+"\\s+\\d+\\s+\\d+\\s+([1-9]\\d*)").test(n)&&i.set(u,S.relative(t,u))}}return[...i.values()]}function ve(e,t=[],s=process.cwd()){let n=e.replace(/\x1B\[[0-9;]*[a-zA-Z]/g,""),o=t.map(l=>S.resolve(l));{let l=/(?:Chrome|Firefox|Safari)(?:\s+Headless)?\s+[\d.]+(?:\s+[\d.]+)*\s+\([^)]+\)\s+(.+?)\s+FAILED/g,u=new Set,c;for(;(c=l.exec(n))!==null;){let $=c[1].trim().split(" ");for(let m=1;m<Math.min($.length,5);m++){let y=$.slice(0,m).join(" ");if(u.has(y))continue;u.add(y);let v=Ae(y,s,o);if(v)return S.relative(s,v)}}}let i=/([a-zA-Z]:[a-zA-Z0-9_.\-\/\\]+\.(?:ts|tsx|js|jsx|vue)|[a-zA-Z0-9_.\-\/\\]+\.(?:ts|tsx|js|jsx|vue))(?:\s*[:(])/g,r;for(;(r=i.exec(n))!==null;){let l=r[1];if(l){if(/(?:^|[/\\])(node_modules|dist|build)[/\\]/.test(l))continue;let u=S.isAbsolute(l)?l:S.resolve(s,l);if(!o.includes(u)&&R.existsSync(u))return l}}let a=/FAIL\s+([a-zA-Z0-9_.\-\/\\]+\.(?:ts|tsx|js|jsx|vue))/gi,p;for(;(p=a.exec(n))!==null;){let l=p[1],u=S.isAbsolute(l)?l:S.resolve(s,l);if(!o.includes(u)&&R.existsSync(u))return l}{let l=/\[(?:chromium|firefox|webkit)\]\s+[>›]\s+([^\s:]+\.(?:spec|test)\.[tj]sx?):\d+:\d+\s+[>›]/g,u;for(;(u=l.exec(n))!==null;){let c=u[1],L=S.isAbsolute(c)?c:S.resolve(s,c);if(!o.includes(L)&&R.existsSync(L))return c}}let g=/([a-zA-Z]:[a-zA-Z0-9_.\-\/\\]+\.(?:ts|tsx|js|jsx|vue)|[a-zA-Z0-9_.\-\/\\]+\.(?:ts|tsx|js|jsx|vue))/g,d;for(;(d=g.exec(n))!==null;){let l=d[1];if(l){if(/(?:^|[/\\])(node_modules|dist|build)[/\\]/.test(l))continue;let u=S.isAbsolute(l)?l:S.resolve(s,l);if(!o.includes(u)&&R.existsSync(u))return l}}let x=/\b([A-Z][a-zA-Z0-9]{3,})\b/g,h,f=new Set,w=["Error","TypeError","SyntaxError","ReferenceError","RangeError","Object","Boolean","String","Number","Array","NullInjectorError","NullInjector","R3Injector","ChainedInjector","Module","Component","Standalone","Application","App2","TestBed","UserContext","Chrome","ChromeHeadless","Karma","Launching","Starting","Headless","Connected","Executed","INFO","SUCCESS","FAILED","Building","Initial","Names","Lazy","Source","Find","NotFound","NG0201","Windows","Linux","Macintosh","Users","AppData","Local","Temp","Process","Unexpected","Expected","Validation","Directory","Configuration","Documentation"];for(;(h=x.exec(n))!==null;){let l=h[1];if(!l||w.includes(l)||f.has(l)||/^[A-Z][A-Z0-9]{5,11}$/.test(l)||/^[A-Za-z0-9]{16,}$/.test(l))continue;f.add(l);let u=Ge(l,s,o);if(u)return S.relative(s,u)}return null}function Ae(e,t,s){if(!R.existsSync(t))return null;let n=R.readdirSync(t);for(let o of n){let i=S.join(t,o);if(["node_modules","dist","build",".git",".angular"].includes(o))continue;let r;try{r=R.statSync(i)}catch{continue}if(r.isDirectory()){let a=Ae(e,i,s);if(a)return a}else if(/\.(spec|test)\.(ts|tsx|js|jsx)$/.test(o)){if(s.includes(S.resolve(i)))continue;try{let a=R.readFileSync(i,"utf8");if(a.includes(`describe('${e}'`)||a.includes(`describe("${e}"`))return i}catch{continue}}}return null}function Ge(e,t,s){if(!R.existsSync(t))return null;let n=R.readdirSync(t);for(let o of n){let i=S.join(t,o);if(o==="node_modules"||o==="dist"||o==="build"||o===".git"||o===".angular")continue;let r;try{r=R.statSync(i)}catch{continue}if(r.isDirectory()){let a=Ge(e,i,s);if(a)return a}else if(o.match(/\.(ts|tsx|js|jsx|vue)$/)){let a=R.readFileSync(i,"utf8");if(a.includes(`class ${e}`)||a.includes(`function ${e}`)||a.includes(`const ${e}`)||a.includes(`let ${e}`)||a.includes(`exports.${e}`)||a.includes(`module.exports.${e}`)){let p=i,g=S.extname(i),d=i.slice(0,-g.length);if(!o.includes(".spec.")&&!o.includes(".test.")){let x=[`${d}.spec${g}`,`${d}.test${g}`,`${d}.spec.js`,`${d}.test.js`];for(let h of x)if(R.existsSync(h)){p=h;break}}if(!s.includes(S.resolve(p)))return p}}}return null}var pe=require("ai"),He=require("@ai-sdk/openai"),qe=require("@ai-sdk/anthropic"),Be=require("@ai-sdk/google"),Ye=b(require("dotenv"));Ye.config({quiet:!0});var Pe=15e3;function Ke(e,t){return e.length<=Pe?e:(console.warn(`[Lisa.ai LLM] ${t} is ${e.length} chars \u2014 truncating to ${Pe} to stay within context window.`),e.slice(0,Pe)+`
2
+ "use strict";var Vt=Object.create;var tt=Object.defineProperty;var Wt=Object.getOwnPropertyDescriptor;var zt=Object.getOwnPropertyNames;var Zt=Object.getPrototypeOf,Jt=Object.prototype.hasOwnProperty;var Qt=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Xt=(e,t,s,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of zt(t))!Jt.call(e,o)&&o!==s&&tt(e,o,{get:()=>t[o],enumerable:!(n=Wt(t,o))||n.enumerable});return e};var S=(e,t,s)=>(s=e!=null?Vt(Zt(e)):{},Xt(t||!e||!e.__esModule?tt(s,"default",{value:e,enumerable:!0}):s,e));var Gt=Qt((qn,vs)=>{vs.exports={name:"@lisa.ai/agent",version:"2.11.0",description:"Lisa.ai Autonomous CI/CD Worker Agent",main:"dist/index.js",bin:{"lisa-agent":"dist/index.js"},files:["dist/"],scripts:{build:"tsup",typecheck:"tsc --noEmit",start:"node dist/index.js",dev:"ts-node src/index.ts",prepublishOnly:"npm run typecheck && npm run build"},keywords:["lisa","ci","cd","agent"],author:"Lisa.ai",license:"ISC",dependencies:{"@ai-sdk/anthropic":"^3.0.46","@ai-sdk/google":"^3.0.30","@ai-sdk/openai":"^3.0.30","@octokit/rest":"^22.0.1",ai:"^6.0.94",commander:"^11.1.0",dotenv:"^17.3.1","simple-git":"^3.31.1"},devDependencies:{"@types/jest":"^30.0.0","@types/node":"^20.0.0","ts-node":"^10.9.1",tsup:"^8.5.1",typescript:"^5.0.0"}}});var Bt=require("commander"),re=S(require("fs")),Se=S(require("path")),qt=S(require("readline"));var st=S(require("dotenv"));st.config({quiet:!0});async function je(e){let t=process.env.LISA_CONTROL_PLANE_URL||"http://localhost:3088";try{let s=`${t}/api/v1/lisa/config/${e}`;console.log(`[Lisa.ai Agent] Fetching dynamic configuration from ${s}...`);let n=await fetch(s);if(!n.ok){let i=n.status===404?"not_found":"unreachable";return console.warn(i==="not_found"?`[Lisa.ai Agent Warning] Control Plane returned 404. Project '${e}' not found.`:`[Lisa.ai Agent Warning] Control Plane returned ${n.status}. Falling back to local defaults.`),{ok:!1,reason:i}}return{ok:!0,config:await n.json()}}catch{return console.warn(`[Lisa.ai Agent Warning] Failed to reach Control Plane (${t}). Using local fallback configuration.`),{ok:!1,reason:"unreachable"}}}var $t=require("child_process"),B=S(require("fs")),te=S(require("path"));var j=S(require("path")),D=S(require("fs"));function Ee(e){return e.replace(/\x1B\[[0-9;]*[a-zA-Z]/g,"")}function G(e){let t=Ee(e),s=[...t.matchAll(/Executed\s+(\d+)\s+of\s+(\d+)(?:\s+\((\d+)\s+FAILED\))?/g)];if(s.length>0){let u=[...s].reverse().find(L=>L[3]!==void 0)??s[s.length-1],p=parseInt(u[2]),$=u[3]?parseInt(u[3]):0,g=parseInt(u[1])-$;return{total:p,passed:g,failed:$}}let n=t.match(/Tests:\s+(?:(\d+)\s+failed,?\s*)?(?:(\d+)\s+passed,?\s*)?(\d+)\s+total/);if(n){let u=parseInt(n[3]),p=n[1]?parseInt(n[1]):0,$=n[2]?parseInt(n[2]):0;return{total:u,passed:$,failed:p}}let o=t.match(/(\d+)\s+failed/),i=t.match(/(\d+)\s+passed/);if(i||o){let u=o?parseInt(o[1]):0,p=i?parseInt(i[1]):0,$=t.match(/(\d+)\s+skipped/),g=$?parseInt($[1]):0;return{total:p+u+g,passed:p,failed:u}}let r=t.match(/Tests\s+(?:(\d+)\s+failed\s*\|?\s*)?(\d+)\s+passed\s*\((\d+)\)/);if(r){let u=parseInt(r[3]),p=r[1]?parseInt(r[1]):0,$=parseInt(r[2]);return{total:u,passed:$,failed:p}}let a=t.match(/(\d+)\s+passing/),c=t.match(/(\d+)\s+failing/);if(a){let u=parseInt(a[1]),p=c?parseInt(c[1]):0;return{total:u+p,passed:u,failed:p}}return null}function Ge(e,t=process.cwd(),s=[]){let n=e.replace(/\x1B\[[0-9;]*[a-zA-Z]/g,""),o=s.map(d=>j.resolve(t,d)),i=new Map,r=new Set,a=/(?:Chrome|Firefox|Safari)(?:\s+Headless)?\s+[\d.]+(?:\s+[\d.]+)*\s+\([^)]+\)\s+(.+?)\s+FAILED/g,c;for(;(c=a.exec(n))!==null;){let l=c[1].trim().split(" ");for(let y=1;y<Math.min(l.length,6);y++){let h=l.slice(0,y).join(" ");if(r.has(h))continue;r.add(h);let C=Be(h,t,o);if(C){let v=j.resolve(C);i.has(v)||i.set(v,j.relative(t,C));break}}}let u=/^FAIL\s+([a-zA-Z0-9_./-\\]+\.(?:spec|test)\.(ts|tsx|js|jsx))/gm,p;for(;(p=u.exec(n))!==null;){let d=p[1],l=j.isAbsolute(d)?d:j.resolve(t,d);!o.includes(l)&&D.existsSync(l)&&!i.has(l)&&i.set(l,j.relative(t,l))}let $=/\[(?:chromium|firefox|webkit)\]\s+[>›]\s+([^\s:]+\.(?:spec|test)\.[tj]sx?):\d+:\d+\s+[>›]/g,g;for(;(g=$.exec(n))!==null;){let d=g[1],l=j.isAbsolute(d)?d:j.resolve(t,d);!o.includes(l)&&D.existsSync(l)&&!i.has(l)&&i.set(l,j.relative(t,l))}let L=/Running:\s+([^\s]+\.(?:cy|spec|test)\.[tj]sx?)/g,m;for(;(m=L.exec(n))!==null;){let d=m[1],l=j.isAbsolute(d)?d:j.resolve(t,d);if(!o.includes(l)&&D.existsSync(l)&&!i.has(l)){let y=d.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");new RegExp(y+"\\s+\\d+\\s+\\d+\\s+([1-9]\\d*)").test(n)&&i.set(l,j.relative(t,l))}}return[...i.values()]}function Ae(e,t=[],s=process.cwd()){let n=e.replace(/\x1B\[[0-9;]*[a-zA-Z]/g,""),o=t.map(d=>j.resolve(d));{let d=/(?:Chrome|Firefox|Safari)(?:\s+Headless)?\s+[\d.]+(?:\s+[\d.]+)*\s+\([^)]+\)\s+(.+?)\s+FAILED/g,l=new Set,y;for(;(y=d.exec(n))!==null;){let C=y[1].trim().split(" ");for(let v=1;v<Math.min(C.length,5);v++){let x=C.slice(0,v).join(" ");if(l.has(x))continue;l.add(x);let f=Be(x,s,o);if(f)return j.relative(s,f)}}}let i=/([a-zA-Z]:[a-zA-Z0-9_.\-\/\\]+\.(?:ts|tsx|js|jsx|vue)|[a-zA-Z0-9_.\-\/\\]+\.(?:ts|tsx|js|jsx|vue))(?:\s*[:(])/g,r;for(;(r=i.exec(n))!==null;){let d=r[1];if(d){if(/(?:^|[/\\])(node_modules|dist|build)[/\\]/.test(d))continue;let l=j.isAbsolute(d)?d:j.resolve(s,d);if(!o.includes(l)&&D.existsSync(l))return d}}let a=/FAIL\s+([a-zA-Z0-9_.\-\/\\]+\.(?:ts|tsx|js|jsx|vue))/gi,c;for(;(c=a.exec(n))!==null;){let d=c[1],l=j.isAbsolute(d)?d:j.resolve(s,d);if(!o.includes(l)&&D.existsSync(l))return d}{let d=/\[(?:chromium|firefox|webkit)\]\s+[>›]\s+([^\s:]+\.(?:spec|test)\.[tj]sx?):\d+:\d+\s+[>›]/g,l;for(;(l=d.exec(n))!==null;){let y=l[1],h=j.isAbsolute(y)?y:j.resolve(s,y);if(!o.includes(h)&&D.existsSync(h))return y}}let u=/([a-zA-Z]:[a-zA-Z0-9_.\-\/\\]+\.(?:ts|tsx|js|jsx|vue)|[a-zA-Z0-9_.\-\/\\]+\.(?:ts|tsx|js|jsx|vue))/g,p;for(;(p=u.exec(n))!==null;){let d=p[1];if(d){if(/(?:^|[/\\])(node_modules|dist|build)[/\\]/.test(d))continue;let l=j.isAbsolute(d)?d:j.resolve(s,d);if(!o.includes(l)&&D.existsSync(l))return d}}let $=/\b([A-Z][a-zA-Z0-9]{3,})\b/g,g,L=new Set,m=["Error","TypeError","SyntaxError","ReferenceError","RangeError","Object","Boolean","String","Number","Array","NullInjectorError","NullInjector","R3Injector","ChainedInjector","Module","Component","Standalone","Application","App2","TestBed","UserContext","Chrome","ChromeHeadless","Karma","Launching","Starting","Headless","Connected","Executed","INFO","SUCCESS","FAILED","Building","Initial","Names","Lazy","Source","Find","NotFound","NG0201","Windows","Linux","Macintosh","Users","AppData","Local","Temp","Process","Unexpected","Expected","Validation","Directory","Configuration","Documentation"];for(;(g=$.exec(n))!==null;){let d=g[1];if(!d||m.includes(d)||L.has(d)||/^[A-Z][A-Z0-9]{5,11}$/.test(d)||/^[A-Za-z0-9]{16,}$/.test(d))continue;L.add(d);let l=nt(d,s,o);if(l)return j.relative(s,l)}return null}function Be(e,t,s){if(!D.existsSync(t))return null;let n=D.readdirSync(t);for(let o of n){let i=j.join(t,o);if(["node_modules","dist","build",".git",".angular"].includes(o))continue;let r;try{r=D.statSync(i)}catch{continue}if(r.isDirectory()){let a=Be(e,i,s);if(a)return a}else if(/\.(spec|test)\.(ts|tsx|js|jsx)$/.test(o)){if(s.includes(j.resolve(i)))continue;try{let a=D.readFileSync(i,"utf8");if(a.includes(`describe('${e}'`)||a.includes(`describe("${e}"`))return i}catch{continue}}}return null}function nt(e,t,s){if(!D.existsSync(t))return null;let n=D.readdirSync(t);for(let o of n){let i=j.join(t,o);if(o==="node_modules"||o==="dist"||o==="build"||o===".git"||o===".angular")continue;let r;try{r=D.statSync(i)}catch{continue}if(r.isDirectory()){let a=nt(e,i,s);if(a)return a}else if(o.match(/\.(ts|tsx|js|jsx|vue)$/)){let a=D.readFileSync(i,"utf8");if(a.includes(`class ${e}`)||a.includes(`function ${e}`)||a.includes(`const ${e}`)||a.includes(`let ${e}`)||a.includes(`exports.${e}`)||a.includes(`module.exports.${e}`)){let c=i,u=j.extname(i),p=i.slice(0,-u.length);if(!o.includes(".spec.")&&!o.includes(".test.")){let $=[`${p}.spec${u}`,`${p}.test${u}`,`${p}.spec.js`,`${p}.test.js`];for(let g of $)if(D.existsSync(g)){c=g;break}}if(!s.includes(j.resolve(c)))return c}}}return null}var ce=require("ai"),Te=require("@ai-sdk/openai"),ot=require("@ai-sdk/anthropic"),it=require("@ai-sdk/google"),at=S(require("dotenv"));at.config({quiet:!0});var qe=15e3;function Pe(e,t){return e.length<=qe?e:(console.warn(`[Lisa.ai LLM] ${t} is ${e.length} chars \u2014 truncating to ${qe} to stay within context window.`),e.slice(0,qe)+`
3
3
 
4
- // ... (truncated)`)}function Ve(e,t){if(!/\b(describe|it\(|test\(|expect\(|beforeEach|afterEach|suite|assert\.|cy\.)\b/.test(e))throw new Error(`LLM returned a non-code response for ${t} (possible context overflow). Skipping to prevent file corruption.`)}function We(e){if(!e||e.length===0)return"";let t={unit:"unit tests \u2014 test every function/method in complete isolation, mocking ALL external dependencies, services, and I/O",integration:"integration tests \u2014 test how modules work together using real service/repository layers; for HTTP routes use supertest or equivalent",e2e:"end-to-end tests \u2014 simulate complete user flows using the configured e2e framework (Playwright/Cypress); cover the full path from HTTP request to response or UI action to assertion"};return`5. Test scope \u2014 generate ALL of the following test types for this file:
4
+ // ... (truncated)`)}function Ie(e,t){if(!/\b(describe|it\(|test\(|expect\(|beforeEach|afterEach|suite|assert\.|cy\.)\b/.test(e))throw new Error(`LLM returned a non-code response for ${t} (possible context overflow). Skipping to prevent file corruption.`)}function rt(e){if(!e||e.length===0)return"";let t={unit:"unit tests \u2014 test every function/method in complete isolation, mocking ALL external dependencies, services, and I/O",integration:"integration tests \u2014 test how modules work together using real service/repository layers; for HTTP routes use supertest or equivalent",e2e:"end-to-end tests \u2014 simulate complete user flows using the configured e2e framework (Playwright/Cypress); cover the full path from HTTP request to response or UI action to assertion"};return`5. Test scope \u2014 generate ALL of the following test types for this file:
5
5
  ${e.map(n=>` \u2022 ${t[n]??n}`).join(`
6
6
  `)}
7
- `}function xe(e,t){if(e==="claude"){let o=t||process.env.ANTHROPIC_API_KEY;if(!o)throw new Error("No Anthropic API key provided by local ENV or Control Plane");let i=process.env.LISA_CLAUDE_MODEL||"claude-haiku-4-5";return(0,qe.createAnthropic)({apiKey:o})(i)}if(e==="openai"){let o=t||process.env.OPENAI_API_KEY;if(!o)throw new Error("No OpenAI API key provided by local ENV or Control Plane");let i=process.env.LISA_OPENAI_MODEL||"gpt-4o-mini";return(0,He.createOpenAI)({apiKey:o})(i)}let s=t||process.env.GOOGLE_GENERATIVE_AI_API_KEY;if(!s)throw new Error("No Google API key provided by local ENV or Control Plane");let n=process.env.LISA_GOOGLE_MODEL||"gemini-2.0-flash";return(0,Be.createGoogleGenerativeAI)({apiKey:s})(n)}async function ze(e,t,s,n,o,i,r,a){console.log(`[Lisa.ai Auto-Heal] Requesting fix from ${n} for ${e}...`);let p=xe(n,o),g=`You are Lisa.ai, an autonomous CI/CD expert platform.
7
+ `}function pe(e,t){if(e==="claude"){let o=t||process.env.ANTHROPIC_API_KEY;if(!o)throw new Error("No Anthropic API key provided by local ENV or Control Plane");let i=process.env.LISA_CLAUDE_MODEL||"claude-haiku-4-5";return(0,ot.createAnthropic)({apiKey:o})(i)}if(e==="openai"){let o=t||process.env.OPENAI_API_KEY;if(!o)throw new Error("No OpenAI API key provided by local ENV or Control Plane");let i=process.env.LISA_OPENAI_MODEL||"gpt-4o-mini";return(0,Te.createOpenAI)({apiKey:o})(i)}let s=t||process.env.GOOGLE_GENERATIVE_AI_API_KEY;if(!s)throw new Error("No Google API key provided by local ENV or Control Plane");let n=process.env.LISA_GOOGLE_MODEL||"gemini-2.0-flash";return(0,it.createGoogleGenerativeAI)({apiKey:s})(n)}async function lt(e,t,s,n,o,i,r,a){console.log(`[Lisa.ai Auto-Heal] Requesting fix from ${n} for ${e}...`);let c=pe(n,o),u=`You are Lisa.ai, an autonomous CI/CD expert platform.
8
8
  A build/compilation error occurred. Your task is to fix the provided file so that the error resolves.
9
9
 
10
10
  --- Error Log ---
@@ -21,48 +21,70 @@ A build/compilation error occurred. Your task is to fix the provided file so tha
21
21
  5. FRAMEWORK TEST RULE: If fixing a testing file ('.spec' or '.test') and an Angular error happens like 'NullInjectorError: No provider for X', you MUST add X to the 'providers' array in 'TestBed.configureTestingModule' or import the required testing module. If a React testing library error arises, fix the render context.
22
22
  6. CRITICAL ANGULAR RULE: If an Angular component imports 'RouterLink' or uses '[routerLink]' in its template, you MUST provide 'ActivatedRoute' in the providers array or import 'RouterTestingModule'. If it uses HTTP, import 'HttpClientTestingModule'.
23
23
  7. CRITICAL STANDALONE RULE: If a component has 'standalone: true' in its decorator (check the Sibling Context!), you MUST NOT add it to the 'declarations' array. Instead, you MUST add it to the 'imports' array within 'TestBed.configureTestingModule'.
24
- 8. Return the code wrapped in a markdown code block (\`\`\`typescript ... \`\`\`). Do not include any explanation or intro text.`;if(r){if(/standalone\s*:\s*true/.test(r)){let f=r.match(/export class (\w+)/),w=f?f[1]:"the component";g+=`
24
+ 8. Return the code wrapped in a markdown code block (\`\`\`typescript ... \`\`\`). Do not include any explanation or intro text.`;if(r){if(/standalone\s*:\s*true/.test(r)){let L=r.match(/export class (\w+)/),m=L?L[1]:"the component";u+=`
25
25
 
26
26
  --- CRITICAL ARCHITECTURAL REQUIREMENT ---
27
- The component `+w+` is marked as STANDALONE (standalone: true).
28
- You MUST add `+w+` to the 'imports' array within 'TestBed.configureTestingModule'.
29
- DO NOT add it to the 'declarations' array. If you omit `+w+" from 'imports', the test will fail."}g+=`
27
+ The component `+m+` is marked as STANDALONE (standalone: true).
28
+ You MUST add `+m+` to the 'imports' array within 'TestBed.configureTestingModule'.
29
+ DO NOT add it to the 'declarations' array. If you omit `+m+" from 'imports', the test will fail."}u+=`
30
30
 
31
31
  --- Sibling Component / Service Context ---
32
32
  You are fixing a '.spec' test file. Here is the actual implementation code for the component you are testing.
33
33
  Use this to identify EXACTLY which imports, Services, and Variables need to be mocked inside your 'TestBed'.
34
- `+r}a&&a.length>0&&(g+=`
34
+ `+r}a&&a.length>0&&(u+=`
35
35
 
36
36
  --- MEMORY ENGINE: PROVEN FIX PATTERNS ---
37
37
  The following fix patterns were SUCCESSFULLY used to resolve identical errors in past runs. Prioritise these approaches before trying anything novel:
38
- `+a.map((h,f)=>`
39
- [Pattern ${f+1}]
40
- ${h}`).join(`
41
- `)),i&&(console.log(`[Lisa.ai Auto-Heal] Warning! Agent is looping on ${e}. Injecting previous failed context...`),g+=`
38
+ `+a.map((g,L)=>`
39
+ [Pattern ${L+1}]
40
+ ${g}`).join(`
41
+ `)),i&&(console.log(`[Lisa.ai Auto-Heal] Warning! Agent is looping on ${e}. Injecting previous failed context...`),u+=`
42
42
 
43
43
  --- CRITICAL WARNING ---
44
44
  You previously attempted to fix this file but the compiler REJECTED your fix!
45
45
  Here is the previous analysis and failed fix you attempted:
46
46
  `+i+`
47
47
 
48
- DO NOT repeat the identical code changes. Try a completely different programming approach, fix syntax typos, or check for missing imports.`);let{text:d}=await(0,pe.generateText)({model:p,prompt:g}),x=d.match(/```(?:typescript|ts|javascript|js)?\n([\s\S]*?)```/);return x?x[1].trim():d.trim()}async function ee(e,t,s,n,o,i){console.log(`[Lisa.ai Coverage] Requesting test generation from ${s} for ${e}...`);let r=xe(s,n),a=o?`3. You MUST use the '${o}' testing framework exclusively. All imports, describe/it/test blocks, and mock utilities must follow '${o}' conventions.
48
+ DO NOT repeat the identical code changes. Try a completely different programming approach, fix syntax typos, or check for missing imports.`);let{text:p}=await(0,ce.generateText)({model:c,prompt:u}),$=p.match(/```(?:typescript|ts|javascript|js)?\n([\s\S]*?)```/);return $?$[1].trim():p.trim()}async function X(e,t,s,n,o,i){console.log(`[Lisa.ai Coverage] Requesting test generation from ${s} for ${e}...`);let r=pe(s,n),a=o?`3. You MUST use the '${o}' testing framework exclusively. All imports, describe/it/test blocks, and mock utilities must follow '${o}' conventions.
49
49
  `:`3. Include all necessary imports assuming a standard testing framework (Jest/Karma/Vitest) is available.
50
- `,p=We(i),g=`You are Lisa.ai, an autonomous CI/CD expert platform.
50
+ `,c=rt(i),u=`You are Lisa.ai, an autonomous CI/CD expert platform.
51
51
  A source file lacks 100% test coverage. Your task is to generate a comprehensive testing suite covering all branches, lines, and functions.
52
52
 
53
53
  --- Target File Content (`+e+`) ---
54
- `+Ke(t,e)+"\n\n--- Constraints ---\n1. Return the generated test code wrapped in a markdown code block (```typescript ... ```).\n2. Do not include any explanation or intro text.\n"+a+`4. Aim for 100% logic coverage.
55
- `+p,{text:d}=await(0,pe.generateText)({model:r,prompt:g}),x=d.match(/```(?:typescript|ts|javascript|js)?\n([\s\S]*?)```/),h=x?x[1].trim():d.trim();return Ve(h,e),h}async function Ze(e,t,s,n,o,i,r,a){console.log(`[Lisa.ai Coverage] Requesting test update from ${o} for ${e}...`);let p=xe(o,i),g=r?`3. You MUST use the '${r}' testing framework exclusively. All new tests must follow '${r}' conventions and integrate cleanly with the existing suite.
54
+ `+Pe(t,e)+"\n\n--- Constraints ---\n1. Return the generated test code wrapped in a markdown code block (```typescript ... ```).\n2. Do not include any explanation or intro text.\n"+a+`4. Aim for 100% logic coverage.
55
+ `+c,{text:p}=await(0,ce.generateText)({model:r,prompt:u}),$=p.match(/```(?:typescript|ts|javascript|js)?\n([\s\S]*?)```/),g=$?$[1].trim():p.trim();return Ie(g,e),g}async function ct(e,t,s,n,o,i,r,a){console.log(`[Lisa.ai Coverage] Requesting test update from ${o} for ${e}...`);let c=pe(o,i),u=r?`3. You MUST use the '${r}' testing framework exclusively. All new tests must follow '${r}' conventions and integrate cleanly with the existing suite.
56
56
  `:`3. Append missing tests to the existing suite. Do not delete existing passing tests unless they are fundamentally broken.
57
- `,d=We(a),x=`You are Lisa.ai, an autonomous CI/CD expert platform.
57
+ `,p=rt(a),$=`You are Lisa.ai, an autonomous CI/CD expert platform.
58
58
  A source file lacks 100% test coverage. You must update its existing test suite to achieve full coverage.
59
59
 
60
60
  --- Target File Content (`+e+`) ---
61
- `+Ke(t,e)+`
61
+ `+Pe(t,e)+`
62
62
 
63
63
  --- Existing Test Suite (`+s+`) ---
64
- `+n+"\n\n--- Constraints ---\n1. Return the updated complete test code wrapped in a markdown code block (```typescript ... ```).\n2. Do not include any explanation or intro text.\n"+g+`4. Aim for 100% logic coverage across branches, lines, and functions.
65
- `+d,{text:h}=await(0,pe.generateText)({model:p,prompt:x}),f=h.match(/```(?:typescript|ts|javascript|js)?\n([\s\S]*?)```/),w=f?f[1].trim():h.trim();return Ve(w,e),w}async function ie(e,t,s){let n=xe(t,s),{text:o}=await(0,pe.generateText)({model:n,prompt:e}),i=o.match(/```(?:typescript|ts|javascript|js)?\n([\s\S]*?)```/);return i?i[1].trim():o.trim()}var Je=b(require("fs")),Qe=b(require("simple-git")),Xe=require("@octokit/rest"),Xt=require("dotenv/config");function Rt(e){let t=e.healedFiles.map(o=>`- \`${o}\``).join(`
64
+ `+n+"\n\n--- Constraints ---\n1. Return the updated complete test code wrapped in a markdown code block (```typescript ... ```).\n2. Do not include any explanation or intro text.\n"+u+`4. Aim for 100% logic coverage across branches, lines, and functions.
65
+ `+p,{text:g}=await(0,ce.generateText)({model:c,prompt:$}),L=g.match(/```(?:typescript|ts|javascript|js)?\n([\s\S]*?)```/),m=L?L[1].trim():g.trim();return Ie(m,e),m}async function dt(e,t,s,n,o){try{let i=new AbortController,r=setTimeout(()=>i.abort(),6e4),a=(0,Te.createOpenAI)({baseURL:o.baseUrl+"/v1",apiKey:"ollama"}),c=`You are Lisa.ai, an autonomous CI/CD expert.
66
+ Apply the PROVEN FIX PATTERN below to resolve the error. Do not deviate from the pattern unless absolutely necessary.
67
+
68
+ --- Error Log ---
69
+ `+s.slice(0,4e3)+`
70
+
71
+ --- Target File (`+e+`) ---
72
+ `+Pe(t,e)+`
73
+
74
+ --- PROVEN FIX PATTERNS ---
75
+ `+n.map((g,L)=>`[Pattern ${L+1}]
76
+ ${g}`).join(`
77
+ `)+"\n\nReturn ONLY the complete fixed file wrapped in ```typescript ... ```. No explanation.",{text:u}=await(0,ce.generateText)({model:a(o.model),prompt:c,abortSignal:i.signal});clearTimeout(r);let p=u.match(/```(?:typescript|ts|javascript|js)?\n([\s\S]*?)```/),$=p?p[1].trim():u.trim();return Ie($,e),$}catch(i){return console.log(` [Lisa LLM] Failed: ${i.message?.slice(0,120)??String(i)}`),null}}async function ut(e,t,s,n,o){try{let i=new AbortController,r=setTimeout(()=>i.abort(),6e4),a=(0,Te.createOpenAI)({baseURL:n.baseUrl+"/v1",apiKey:"ollama"}),c=o?`Use the '${o}' testing framework exclusively.
78
+ `:"",u=`You are Lisa.ai, an autonomous CI/CD expert.
79
+ Generate a comprehensive test suite for the file below. Use the PROVEN PATTERNS as a guide for test structure and style.
80
+
81
+ --- Source File (`+e+`) ---
82
+ `+Pe(t,e)+`
83
+
84
+ --- PROVEN PATTERNS ---
85
+ `+s.map((L,m)=>`[Pattern ${m+1}]
86
+ ${L}`).join(`
87
+ `)+"\n\n--- Constraints ---\n1. Return ONLY the test code in ```typescript ... ```.\n2. Aim for 100% logic coverage.\n"+c,{text:p}=await(0,ce.generateText)({model:a(n.model),prompt:u,abortSignal:i.signal});clearTimeout(r);let $=p.match(/```(?:typescript|ts|javascript|js)?\n([\s\S]*?)```/),g=$?$[1].trim():p.trim();return Ie(g,e),g}catch(i){return console.log(` [Lisa LLM] Generation failed: ${i.message?.slice(0,120)??String(i)}`),null}}async function ge(e,t,s){let n=pe(t,s),{text:o}=await(0,ce.generateText)({model:n,prompt:e}),i=o.match(/```(?:typescript|ts|javascript|js)?\n([\s\S]*?)```/);return i?i[1].trim():o.trim()}var pt=S(require("fs")),gt=S(require("simple-git")),ft=require("@octokit/rest"),Fs=require("dotenv/config");function es(e){let t=e.healedFiles.map(o=>`- \`${o}\``).join(`
66
88
  `),s=e.quarantinedFiles.length>0?e.quarantinedFiles.map(o=>`- \`${o}\``).join(`
67
89
  `):"_None \u2014 all failures healed successfully._",n=e.testCounts?["| Metric | Before | After (est.) |","|---|---|---|",`| Passing | ${e.testCounts.passed} | ~${e.testCounts.passed+e.healedFiles.length} |`,`| Failing | ${e.testCounts.failed} | ~${Math.max(0,e.testCounts.failed-e.healedFiles.length)} |`,`| Total | ${e.testCounts.total} | ${e.testCounts.total} |`].join(`
68
90
  `):"_Test counts not available._";return`## Lisa.ai Auto-Heal Report
@@ -82,12 +104,12 @@ ${n}
82
104
  ---
83
105
 
84
106
  > This PR was generated automatically by [Lisa.ai](https://www.npmjs.com/package/@lisa.ai/agent).
85
- > Please review the changes before merging.`}async function et(e){if(e.healedFiles.length===0)return console.log("[Lisa.ai CI] No files were healed. Skipping PR creation."),null;let t=process.env.GITHUB_TOKEN,s=process.env.GITHUB_REPOSITORY;if(!t||!s)return console.log("[Lisa.ai CI] GITHUB_TOKEN or GITHUB_REPOSITORY not set. Skipping PR creation."),null;let n=(0,Qe.default)(),i=`lisa-fix/auto-heal-${Date.now()}`,r=process.env.GITHUB_REF_NAME||"main";try{await n.addConfig("user.name","Lisa.ai"),await n.addConfig("user.email","lisa@lisa.ai"),await n.checkoutLocalBranch(i),await n.add(e.healedFiles);let a=e.healedFiles.length===1?`fix: Lisa.ai auto-healed ${e.healedFiles[0]}`:`fix: Lisa.ai auto-healed ${e.healedFiles.length} failing test specs`;await n.commit(a),console.log(`[Lisa.ai CI] Committed ${e.healedFiles.length} file(s) to branch ${i}`),await n.push("origin",i,{"--set-upstream":null}),console.log("[Lisa.ai CI] Pushed branch to origin.");let[p,g]=s.split("/"),x=await new Xe.Octokit({auth:t}).rest.pulls.create({owner:p,repo:g,title:a,body:Rt(e),head:i,base:r});return console.log(`[Lisa.ai CI] Pull Request created: ${x.data.html_url}`),x.data.html_url}catch(a){return console.error(`[Lisa.ai CI] Failed to create PR: ${a.message}`),null}}function Ie(e,t){let s=process.env.GITHUB_STEP_SUMMARY;if(!s)return;let n=["## Lisa.ai Heal Results","","| Metric | Value |","|---|---|",`| Files Healed | ${e.healedFiles.length} |`,`| Files Quarantined | ${e.quarantinedFiles.length} |`,`| Model | ${e.modelProvider} |`,`| Framework | ${e.framework} |`,`| Scope | ${e.scope} |`];e.testCounts&&n.push(`| Tests Passing (before) | ${e.testCounts.passed} |`,`| Tests Failing (before) | ${e.testCounts.failed} |`),t&&n.push("",`**Pull Request:** ${t}`),e.healedFiles.length>0&&(n.push("","### Healed Files"),e.healedFiles.forEach(o=>n.push(`- \`${o}\``))),e.quarantinedFiles.length>0&&(n.push("","### Quarantined Files"),e.quarantinedFiles.forEach(o=>n.push(`- \`${o}\``)));try{Je.appendFileSync(s,n.join(`
107
+ > Please review the changes before merging.`}async function mt(e){if(e.healedFiles.length===0)return console.log("[Lisa.ai CI] No files were healed. Skipping PR creation."),null;let t=process.env.GITHUB_TOKEN,s=process.env.GITHUB_REPOSITORY;if(!t||!s)return console.log("[Lisa.ai CI] GITHUB_TOKEN or GITHUB_REPOSITORY not set. Skipping PR creation."),null;let n=(0,gt.default)(),i=`lisa-fix/auto-heal-${Date.now()}`,r=process.env.GITHUB_REF_NAME||"main";try{await n.addConfig("user.name","Lisa.ai"),await n.addConfig("user.email","lisa@lisa.ai"),await n.checkoutLocalBranch(i),await n.add(e.healedFiles);let a=e.healedFiles.length===1?`fix: Lisa.ai auto-healed ${e.healedFiles[0]}`:`fix: Lisa.ai auto-healed ${e.healedFiles.length} failing test specs`;await n.commit(a),console.log(`[Lisa.ai CI] Committed ${e.healedFiles.length} file(s) to branch ${i}`),await n.push("origin",i,{"--set-upstream":null}),console.log("[Lisa.ai CI] Pushed branch to origin.");let[c,u]=s.split("/"),$=await new ft.Octokit({auth:t}).rest.pulls.create({owner:c,repo:u,title:a,body:es(e),head:i,base:r});return console.log(`[Lisa.ai CI] Pull Request created: ${$.data.html_url}`),$.data.html_url}catch(a){return console.error(`[Lisa.ai CI] Failed to create PR: ${a.message}`),null}}function Ye(e,t){let s=process.env.GITHUB_STEP_SUMMARY;if(!s)return;let n=["## Lisa.ai Heal Results","","| Metric | Value |","|---|---|",`| Files Healed | ${e.healedFiles.length} |`,`| Files Quarantined | ${e.quarantinedFiles.length} |`,`| Model | ${e.modelProvider} |`,`| Framework | ${e.framework} |`,`| Scope | ${e.scope} |`];e.testCounts&&n.push(`| Tests Passing (before) | ${e.testCounts.passed} |`,`| Tests Failing (before) | ${e.testCounts.failed} |`),t&&n.push("",`**Pull Request:** ${t}`),e.healedFiles.length>0&&(n.push("","### Healed Files"),e.healedFiles.forEach(o=>n.push(`- \`${o}\``))),e.quarantinedFiles.length>0&&(n.push("","### Quarantined Files"),e.quarantinedFiles.forEach(o=>n.push(`- \`${o}\``)));try{pt.appendFileSync(s,n.join(`
86
108
  `)+`
87
- `)}catch{}}var tt=b(require("dotenv"));tt.config({quiet:!0});async function I(e){let s=`${process.env.LISA_CONTROL_PLANE_URL||"http://localhost:3088"}/api/v1/lisa/telemetry`;fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).catch(n=>{console.debug(`[Lisa.ai Agent Debug] Failed to report telemetry: ${n.message}`)})}var K=b(require("fs")),_=b(require("path"));var $e=b(require("fs")),st=b(require("path")),te=".lisai.json",P=class{static _config=null;static _loaded=!1;static load(t=process.cwd()){if(this._loaded)return this._config;this._loaded=!0;let s=st.resolve(t,te);if(!$e.existsSync(s))return null;try{let n=$e.readFileSync(s,"utf-8");return this._config=JSON.parse(n),console.log(`[Lisa.ai Config] Loaded project config from ${te}`),this._config}catch(n){return console.warn(`[Lisa.ai Config] Warning: ${te} found but failed to parse \u2014 ${n.message}. Using defaults.`),null}}static get(){return this._config}static applyEnvDefaults(t){if(!t.model)return;let s={claude:"LISA_CLAUDE_MODEL",openai:"LISA_OPENAI_MODEL",gemini:"LISA_GOOGLE_MODEL"},n=t.provider;n&&s[n]&&!process.env[s[n]]&&(process.env[s[n]]=t.model,console.log(`[Lisa.ai Config] Model override applied: ${n} \u2192 ${t.model}`))}static printSummary(t){let s=[];t.projectId&&s.push(`projectId=${t.projectId}`),t.provider&&s.push(`provider=${t.provider}`),t.model&&s.push(`model=${t.model}`),t.testingFramework&&s.push(`testingFramework=${t.testingFramework}`),t.testTypes?.length&&s.push(`testTypes=[${t.testTypes.join(",")}]`),t.maxRetries!==void 0&&s.push(`maxRetries=${t.maxRetries}`),t.testCommand&&s.push(`testCommand="${t.testCommand}"`),t.e2eFramework&&s.push(`e2eFramework=${t.e2eFramework}`),t.e2eCommand&&s.push(`e2eCommand="${t.e2eCommand}"`),s.length&&console.log(`[Lisa.ai Config] Settings: ${s.join(", ")}`),t.skipFiles?.length&&console.log(`[Lisa.ai Config] Extra skip files : ${t.skipFiles.join(", ")}`),t.skipDirs?.length&&console.log(`[Lisa.ai Config] Extra skip dirs : ${t.skipDirs.join(", ")}`),t.skipPaths?.length&&console.log(`[Lisa.ai Config] Extra skip paths : ${t.skipPaths.join(", ")}`)}};var V=class{static scanRepository(t=process.cwd()){let s=_.resolve(t,"package.json"),n={type:"unknown",testingFramework:"none"};if(!K.existsSync(s))return console.warn(`[Lisa.ai AutoDiscovery] No package.json found at ${s}. Defaulting to Generic Node.`),n.type="node",n;let o=JSON.parse(K.readFileSync(s,"utf8")),i={...o.dependencies||{},...o.devDependencies||{}},r=o.scripts||{};return i["@angular/core"]?n.type="angular":i.react?n.type="react":i.vue?n.type="vue":n.type="node",i.jest||r.test?.includes("jest")?n.testingFramework="jest":i.karma||r.test?.includes("karma")||r.test?.includes("ng test")?n.testingFramework="karma":(i.vitest||r.test?.includes("vitest"))&&(n.testingFramework="vitest"),n.testingFramework!=="none"&&(n.testingFramework==="karma"?n.type==="angular"?n.suggestedTestCommand="npx ng test --no-watch --browsers=ChromeHeadless":n.suggestedTestCommand="npx karma start --single-run --browsers=ChromeHeadless":r.test?n.suggestedTestCommand="npm run test":n.testingFramework==="jest"?n.suggestedTestCommand="npx jest --coverage":n.testingFramework==="vitest"&&(n.suggestedTestCommand="npx vitest run --coverage")),n}static findUntestedFiles(t,s=[]){let n=[];if(!K.existsSync(t))return n;let o=K.readdirSync(t),i=P.get(),r=i?.skipDirs??[],a=i?.skipFiles??[],p=i?.skipPaths??[],g=["node_modules","dist","build",".git",".angular","coverage","public","assets",...r],d=["main.ts","index.ts","index.js","index.jsx","app.config.ts","app.routes.ts","styles.css","styles.scss","tailwind.config.js","tailwind.config.ts","eslint.config.js","eslint.config.ts","jest.config.js","jest.config.ts","jest.config.mjs","jest.setup.js","jest.setup.ts","webpack.config.js","webpack.config.ts","babel.config.js","babel.config.ts","rollup.config.js","rollup.config.ts","vite.config.js","vite.config.ts","vitest.config.js","vitest.config.ts","karma.conf.js","karma.config.js","prettier.config.js","prettier.config.ts","postcss.config.js","postcss.config.ts","gulpfile.js","Gulpfile.js",".eslintrc.js",".eslintrc.ts",".babelrc.js"],x=[/^\./,/\.config\.(js|ts|mjs|cjs)$/,/\.conf\.(js|ts|mjs|cjs)$/];for(let h of o){let f=_.join(t,h);if(g.includes(h))continue;let w;try{w=K.statSync(f)}catch{continue}if(w.isDirectory())n.push(...this.findUntestedFiles(f,s));else if(h.match(/\.(ts|tsx|js|jsx|vue)$/)&&!h.includes(".spec.")&&!h.includes(".test.")){if(d.includes(h)||a.includes(h)||x.some($=>$.test(h)))continue;let l=_.extname(h),u=h.slice(0,-l.length);if(![_.join(t,`${u}.spec${l}`),_.join(t,`${u}.test${l}`),_.join(t,`${u}.spec.js`),_.join(t,`${u}.test.js`),_.join(t,`${u}.spec.ts`),_.join(t,`${u}.test.ts`)].some($=>K.existsSync($))){let $=_.relative(process.cwd(),f);if(p.some(m=>$.startsWith(m)))continue;s.includes($)||n.push($)}}}return n}};var nt=require("child_process"),ae=class{static async installMissingFramework(t,s=process.cwd()){if(t.testingFramework!=="none")return t;console.log(`
88
- [Lisa.ai Auto-Installer] \u{1F6A8} No testing framework detected for ${t.type} architecture.`),console.log("[Lisa.ai Auto-Installer] \u{1FA84} Initiating Zero-Config Installation Protocol...");let n="",o="none";switch(t.type){case"angular":console.log("[Lisa.ai Auto-Installer] Provisioning Angular TestBed environment..."),n="npm install --save-dev karma karma-chrome-launcher karma-coverage karma-jasmine jasmine-core @types/jasmine",o="karma",t.suggestedTestCommand="npm run test";break;case"react":case"node":default:console.log("[Lisa.ai Auto-Installer] Provisioning Universal Jest environment..."),n="npm install --save-dev jest @types/jest ts-jest",o="jest",t.suggestedTestCommand="npx jest --coverage";break;case"vue":console.log("[Lisa.ai Auto-Installer] Provisioning Vue Vitest environment..."),n="npm install --save-dev vitest @vue/test-utils jsdom",o="vitest",t.suggestedTestCommand="npx vitest run --coverage";break}if(n){console.log(`[Lisa.ai Executing] ${n}`);let i=n.split(" "),r=process.platform==="win32"?`${i[0]}.cmd`:i[0];return(0,nt.spawnSync)(r,i.slice(1),{cwd:s,stdio:"inherit"}).status!==0&&(console.error(`
89
- \u274C [Lisa.ai Auto-Installer] Failed to construct dynamic testing environment.`),process.exit(1)),console.log("\u2705 [Lisa.ai Auto-Installer] Framework successfully injected."),t.testingFramework=o,t}return t}};var Le=b(require("fs")),Te=b(require("path"));var re=class{static async provisionConfigurationFiles(t,s,n,o=process.cwd()){if(t.testingFramework==="none")return;if(console.log(`
90
- [Lisa.ai Auto-Generator] \u{1FA84} Analyzing ${t.type} architecture to generate ${t.testingFramework} configuration specs...`),["jest.config.js","jest.config.ts","karma.conf.js","vitest.config.ts","vitest.config.js"].some(p=>Le.existsSync(Te.join(o,p)))){console.log("[Lisa.ai Auto-Generator] Setup file detected. Bypassing initialization.");return}let a=`You are an expert ${t.type} architect.
109
+ `)}catch{}}var ht=S(require("dotenv"));ht.config({quiet:!0});async function N(e){let s=`${process.env.LISA_CONTROL_PLANE_URL||"http://localhost:3088"}/api/v1/lisa/telemetry`;fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).catch(n=>{console.debug(`[Lisa.ai Agent Debug] Failed to report telemetry: ${n.message}`)})}var Z=S(require("fs")),q=S(require("path"));var Re=S(require("fs")),yt=S(require("path")),de=".lisai.json",$e={enabled:!1,provider:"ollama",model:"qwen2.5-coder:7b",baseUrl:"http://localhost:11434",confidenceThreshold:.8};function Ke(e){let t=process.env;return{enabled:t.LISA_LLM_ENABLED==="true"||e?.enabled||$e.enabled,provider:e?.provider??$e.provider,model:t.LISA_LLM_MODEL||(e?.model??$e.model),baseUrl:t.LISA_LLM_URL||(e?.baseUrl??$e.baseUrl),confidenceThreshold:e?.confidenceThreshold??$e.confidenceThreshold}}var R=class{static _config=null;static _loaded=!1;static load(t=process.cwd()){if(this._loaded)return this._config;this._loaded=!0;let s=yt.resolve(t,de);if(!Re.existsSync(s))return null;try{let n=Re.readFileSync(s,"utf-8");return this._config=JSON.parse(n),console.log(`[Lisa.ai Config] Loaded project config from ${de}`),this._config}catch(n){return console.warn(`[Lisa.ai Config] Warning: ${de} found but failed to parse \u2014 ${n.message}. Using defaults.`),null}}static get(){return this._config}static applyEnvDefaults(t){if(!t.model)return;let s={claude:"LISA_CLAUDE_MODEL",openai:"LISA_OPENAI_MODEL",gemini:"LISA_GOOGLE_MODEL"},n=t.provider;n&&s[n]&&!process.env[s[n]]&&(process.env[s[n]]=t.model,console.log(`[Lisa.ai Config] Model override applied: ${n} \u2192 ${t.model}`))}static printSummary(t){let s=[];t.projectId&&s.push(`projectId=${t.projectId}`),t.provider&&s.push(`provider=${t.provider}`),t.model&&s.push(`model=${t.model}`),t.testingFramework&&s.push(`testingFramework=${t.testingFramework}`),t.testTypes?.length&&s.push(`testTypes=[${t.testTypes.join(",")}]`),t.maxRetries!==void 0&&s.push(`maxRetries=${t.maxRetries}`),t.testCommand&&s.push(`testCommand="${t.testCommand}"`),t.e2eFramework&&s.push(`e2eFramework=${t.e2eFramework}`),t.e2eCommand&&s.push(`e2eCommand="${t.e2eCommand}"`),s.length&&console.log(`[Lisa.ai Config] Settings: ${s.join(", ")}`),t.skipFiles?.length&&console.log(`[Lisa.ai Config] Extra skip files : ${t.skipFiles.join(", ")}`),t.skipDirs?.length&&console.log(`[Lisa.ai Config] Extra skip dirs : ${t.skipDirs.join(", ")}`),t.skipPaths?.length&&console.log(`[Lisa.ai Config] Extra skip paths : ${t.skipPaths.join(", ")}`);let n=Ke(t.lisaLlm);n.enabled&&console.log(`[Lisa.ai Config] Lisa LLM enabled: ${n.model} @ ${n.baseUrl} (threshold=${n.confidenceThreshold})`)}};var K=class{static scanRepository(t=process.cwd()){let s=q.resolve(t,"package.json"),n={type:"unknown",testingFramework:"none"};if(!Z.existsSync(s))return console.warn(`[Lisa.ai AutoDiscovery] No package.json found at ${s}. Defaulting to Generic Node.`),n.type="node",n;let o=JSON.parse(Z.readFileSync(s,"utf8")),i={...o.dependencies||{},...o.devDependencies||{}},r=o.scripts||{};return i["@angular/core"]?n.type="angular":i.react?n.type="react":i.vue?n.type="vue":n.type="node",i.jest||r.test?.includes("jest")?n.testingFramework="jest":i.karma||r.test?.includes("karma")||r.test?.includes("ng test")?n.testingFramework="karma":(i.vitest||r.test?.includes("vitest"))&&(n.testingFramework="vitest"),n.testingFramework!=="none"&&(n.testingFramework==="karma"?n.type==="angular"?n.suggestedTestCommand="npx ng test --no-watch --browsers=ChromeHeadless":n.suggestedTestCommand="npx karma start --single-run --browsers=ChromeHeadless":r.test?n.suggestedTestCommand="npm run test":n.testingFramework==="jest"?n.suggestedTestCommand="npx jest --coverage":n.testingFramework==="vitest"&&(n.suggestedTestCommand="npx vitest run --coverage")),n}static findUntestedFiles(t,s=[]){let n=[];if(!Z.existsSync(t))return n;let o=Z.readdirSync(t),i=R.get(),r=i?.skipDirs??[],a=i?.skipFiles??[],c=i?.skipPaths??[],u=["node_modules","dist","build",".git",".angular","coverage","public","assets",...r],p=["main.ts","index.ts","index.js","index.jsx","app.config.ts","app.routes.ts","styles.css","styles.scss","tailwind.config.js","tailwind.config.ts","eslint.config.js","eslint.config.ts","jest.config.js","jest.config.ts","jest.config.mjs","jest.setup.js","jest.setup.ts","webpack.config.js","webpack.config.ts","babel.config.js","babel.config.ts","rollup.config.js","rollup.config.ts","vite.config.js","vite.config.ts","vitest.config.js","vitest.config.ts","karma.conf.js","karma.config.js","prettier.config.js","prettier.config.ts","postcss.config.js","postcss.config.ts","gulpfile.js","Gulpfile.js",".eslintrc.js",".eslintrc.ts",".babelrc.js"],$=[/^\./,/\.config\.(js|ts|mjs|cjs)$/,/\.conf\.(js|ts|mjs|cjs)$/];for(let g of o){let L=q.join(t,g);if(u.includes(g))continue;let m;try{m=Z.statSync(L)}catch{continue}if(m.isDirectory())n.push(...this.findUntestedFiles(L,s));else if(g.match(/\.(ts|tsx|js|jsx|vue)$/)&&!g.includes(".spec.")&&!g.includes(".test.")){if(p.includes(g)||a.includes(g)||$.some(C=>C.test(g)))continue;let d=q.extname(g),l=g.slice(0,-d.length);if(![q.join(t,`${l}.spec${d}`),q.join(t,`${l}.test${d}`),q.join(t,`${l}.spec.js`),q.join(t,`${l}.test.js`),q.join(t,`${l}.spec.ts`),q.join(t,`${l}.test.ts`)].some(C=>Z.existsSync(C))){let C=q.relative(process.cwd(),L);if(c.some(v=>C.startsWith(v)))continue;s.includes(C)||n.push(C)}}}return n}};var wt=require("child_process"),fe=class{static async installMissingFramework(t,s=process.cwd()){if(t.testingFramework!=="none")return t;console.log(`
110
+ [Lisa.ai Auto-Installer] \u{1F6A8} No testing framework detected for ${t.type} architecture.`),console.log("[Lisa.ai Auto-Installer] \u{1FA84} Initiating Zero-Config Installation Protocol...");let n="",o="none";switch(t.type){case"angular":console.log("[Lisa.ai Auto-Installer] Provisioning Angular TestBed environment..."),n="npm install --save-dev karma karma-chrome-launcher karma-coverage karma-jasmine jasmine-core @types/jasmine",o="karma",t.suggestedTestCommand="npm run test";break;case"react":case"node":default:console.log("[Lisa.ai Auto-Installer] Provisioning Universal Jest environment..."),n="npm install --save-dev jest @types/jest ts-jest",o="jest",t.suggestedTestCommand="npx jest --coverage";break;case"vue":console.log("[Lisa.ai Auto-Installer] Provisioning Vue Vitest environment..."),n="npm install --save-dev vitest @vue/test-utils jsdom",o="vitest",t.suggestedTestCommand="npx vitest run --coverage";break}if(n){console.log(`[Lisa.ai Executing] ${n}`);let i=n.split(" "),r=process.platform==="win32"?`${i[0]}.cmd`:i[0];return(0,wt.spawnSync)(r,i.slice(1),{cwd:s,stdio:"inherit"}).status!==0&&(console.error(`
111
+ \u274C [Lisa.ai Auto-Installer] Failed to construct dynamic testing environment.`),process.exit(1)),console.log("\u2705 [Lisa.ai Auto-Installer] Framework successfully injected."),t.testingFramework=o,t}return t}};var Me=S(require("fs")),Ve=S(require("path"));var me=class{static async provisionConfigurationFiles(t,s,n,o=process.cwd()){if(t.testingFramework==="none")return;if(console.log(`
112
+ [Lisa.ai Auto-Generator] \u{1FA84} Analyzing ${t.type} architecture to generate ${t.testingFramework} configuration specs...`),["jest.config.js","jest.config.ts","karma.conf.js","vitest.config.ts","vitest.config.js"].some(c=>Me.existsSync(Ve.join(o,c)))){console.log("[Lisa.ai Auto-Generator] Setup file detected. Bypassing initialization.");return}let a=`You are an expert ${t.type} architect.
91
113
  Write a production-ready '${t.testingFramework}' configuration file for a standard '${t.type}' application.
92
114
  The application resides in the root directory.
93
115
 
@@ -95,8 +117,8 @@ Requirements:
95
117
  1. Ensure it specifically instruments code coverage.
96
118
  2. Ensure standard transpilation (ts-jest for jest, or standard karma-webpack/karma-typescript implementations).
97
119
  3. Do NOT wrap your response in markdown formatting (no \`\`\`javascript).
98
- 4. Return ONLY the raw code string block.`;try{let p=await ie(a,s,n),g="";t.testingFramework==="jest"&&(g="jest.config.js"),t.testingFramework==="karma"&&(g="karma.conf.js"),t.testingFramework==="vitest"&&(g="vitest.config.ts");let d=Te.join(o,g);Le.writeFileSync(d,p,"utf-8"),console.log(`\u2705 [Lisa.ai Auto-Generator] Natively wrote ${g} to repository root.`)}catch(p){console.error(`
99
- \u274C [Lisa.ai Auto-Generator] Failed to author configuration file: ${p.message}`),process.exit(1)}}};var ot=b(require("dotenv"));ot.config({quiet:!0});function le(e){let t=e.toLowerCase();return t.includes("karma")||t.includes("ng test")?"karma":t.includes("jest")?"jest":t.includes("vitest")?"vitest":t.includes("playwright")?"playwright":t.includes("cypress")?"cypress":t.includes("mocha")?"mocha":"unknown"}async function it(e,t,s){if(s==="local")return[];let n=process.env.LISA_CONTROL_PLANE_URL||"http://localhost:3088";try{let o=new URLSearchParams({projectId:s,errorLog:e.slice(0,1e3),framework:t}),i=await fetch(`${n}/api/v1/lisa/memory/lookup?${o}`);if(!i.ok)return[];let r=await i.json();return r.data??r}catch{return[]}}async function at(e,t,s,n){if(n==="local")return;let o=process.env.LISA_CONTROL_PLANE_URL||"http://localhost:3088";try{await fetch(`${o}/api/v1/lisa/memory/record`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:n,errorLog:e.slice(0,1e3),fixHint:t.slice(0,2e3),framework:s})}),console.log("[Lisa.ai Memory] Fix pattern recorded to Control Plane.")}catch(i){console.debug(`[Lisa.ai Agent Debug] Failed to record memory pattern: ${i.message}`)}}var D=b(require("fs")),O=b(require("path")),Re=require("child_process");function ke(e){if(D.existsSync(O.join(e,"playwright.config.ts"))||D.existsSync(O.join(e,"playwright.config.js")))return{framework:"playwright",configFile:D.existsSync(O.join(e,"playwright.config.ts"))?"playwright.config.ts":"playwright.config.js",command:"npx playwright test",installed:!0};if(D.existsSync(O.join(e,"cypress.config.ts"))||D.existsSync(O.join(e,"cypress.config.js"))||D.existsSync(O.join(e,"cypress.json")))return{framework:"cypress",configFile:D.existsSync(O.join(e,"cypress.config.ts"))?"cypress.config.ts":D.existsSync(O.join(e,"cypress.config.js"))?"cypress.config.js":"cypress.json",command:"npx cypress run",installed:!0};let t=O.join(e,"package.json");if(D.existsSync(t)){let s=JSON.parse(D.readFileSync(t,"utf-8")),n={...s.dependencies||{},...s.devDependencies||{}};if(n["@playwright/test"])return{framework:"playwright",configFile:null,command:"npx playwright test",installed:!0};if(n.cypress)return{framework:"cypress",configFile:null,command:"npx cypress run",installed:!0}}return{framework:"playwright",configFile:null,command:"npx playwright test",installed:!1}}function Ce(e){console.log("[Lisa.ai E2E] No E2E framework detected. Installing Playwright...");try{(0,Re.execSync)("npm install -D @playwright/test",{cwd:e,stdio:"pipe"}),console.log("[Lisa.ai E2E] Playwright installed.")}catch(s){throw console.error(`[Lisa.ai E2E] Failed to install Playwright: ${s.message}`),new Error("Could not install @playwright/test. Please install it manually.")}try{console.log("[Lisa.ai E2E] Installing Playwright browsers..."),(0,Re.execSync)("npx playwright install --with-deps chromium",{cwd:e,stdio:"pipe"}),console.log("[Lisa.ai E2E] Chromium browser installed.")}catch{console.warn("[Lisa.ai E2E Warning] Browser install failed. You may need to run 'npx playwright install' manually.")}D.existsSync(O.join(e,"playwright.config.ts"))||(D.writeFileSync(O.join(e,"playwright.config.ts"),`import { defineConfig } from '@playwright/test';
120
+ 4. Return ONLY the raw code string block.`;try{let c=await ge(a,s,n),u="";t.testingFramework==="jest"&&(u="jest.config.js"),t.testingFramework==="karma"&&(u="karma.conf.js"),t.testingFramework==="vitest"&&(u="vitest.config.ts");let p=Ve.join(o,u);Me.writeFileSync(p,c,"utf-8"),console.log(`\u2705 [Lisa.ai Auto-Generator] Natively wrote ${u} to repository root.`)}catch(c){console.error(`
121
+ \u274C [Lisa.ai Auto-Generator] Failed to author configuration file: ${c.message}`),process.exit(1)}}};var vt=S(require("dotenv"));vt.config({quiet:!0});function se(e){let t=e.toLowerCase();return t.includes("karma")||t.includes("ng test")?"karma":t.includes("jest")?"jest":t.includes("vitest")?"vitest":t.includes("playwright")?"playwright":t.includes("cypress")?"cypress":t.includes("mocha")?"mocha":"unknown"}async function Ne(e,t,s){if(s==="local")return[];let n=process.env.LISA_CONTROL_PLANE_URL||"http://localhost:3088";try{let o=new URLSearchParams({projectId:s,errorLog:e.slice(0,1e3),framework:t}),i=await fetch(`${n}/api/v1/lisa/memory/lookup?${o}`);if(!i.ok)return[];let r=await i.json();return r.data??r}catch{return[]}}async function We(e,t,s,n){if(n==="local")return;let o=process.env.LISA_CONTROL_PLANE_URL||"http://localhost:3088";try{await fetch(`${o}/api/v1/lisa/memory/record`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:n,errorLog:e.slice(0,1e3),fixHint:t.slice(0,2e3),framework:s})}),console.log("[Lisa.ai Memory] Fix pattern recorded to Control Plane.")}catch(i){console.debug(`[Lisa.ai Agent Debug] Failed to record memory pattern: ${i.message}`)}}var _=S(require("fs")),Y=S(require("path")),ze=require("child_process");function Ue(e){if(_.existsSync(Y.join(e,"playwright.config.ts"))||_.existsSync(Y.join(e,"playwright.config.js")))return{framework:"playwright",configFile:_.existsSync(Y.join(e,"playwright.config.ts"))?"playwright.config.ts":"playwright.config.js",command:"npx playwright test",installed:!0};if(_.existsSync(Y.join(e,"cypress.config.ts"))||_.existsSync(Y.join(e,"cypress.config.js"))||_.existsSync(Y.join(e,"cypress.json")))return{framework:"cypress",configFile:_.existsSync(Y.join(e,"cypress.config.ts"))?"cypress.config.ts":_.existsSync(Y.join(e,"cypress.config.js"))?"cypress.config.js":"cypress.json",command:"npx cypress run",installed:!0};let t=Y.join(e,"package.json");if(_.existsSync(t)){let s=JSON.parse(_.readFileSync(t,"utf-8")),n={...s.dependencies||{},...s.devDependencies||{}};if(n["@playwright/test"])return{framework:"playwright",configFile:null,command:"npx playwright test",installed:!0};if(n.cypress)return{framework:"cypress",configFile:null,command:"npx cypress run",installed:!0}}return{framework:"playwright",configFile:null,command:"npx playwright test",installed:!1}}function De(e){console.log("[Lisa.ai E2E] No E2E framework detected. Installing Playwright...");try{(0,ze.execSync)("npm install -D @playwright/test",{cwd:e,stdio:"pipe"}),console.log("[Lisa.ai E2E] Playwright installed.")}catch(s){throw console.error(`[Lisa.ai E2E] Failed to install Playwright: ${s.message}`),new Error("Could not install @playwright/test. Please install it manually.")}try{console.log("[Lisa.ai E2E] Installing Playwright browsers..."),(0,ze.execSync)("npx playwright install --with-deps chromium",{cwd:e,stdio:"pipe"}),console.log("[Lisa.ai E2E] Chromium browser installed.")}catch{console.warn("[Lisa.ai E2E Warning] Browser install failed. You may need to run 'npx playwright install' manually.")}_.existsSync(Y.join(e,"playwright.config.ts"))||(_.writeFileSync(Y.join(e,"playwright.config.ts"),`import { defineConfig } from '@playwright/test';
100
122
 
101
123
  export default defineConfig({
102
124
  testDir: './e2e',
@@ -113,95 +135,101 @@ export default defineConfig({
113
135
  { name: 'chromium', use: { browserName: 'chromium' } },
114
136
  ],
115
137
  });
116
- `,"utf-8"),console.log("[Lisa.ai E2E] Generated playwright.config.ts"));let t=O.join(e,"e2e");D.existsSync(t)||(D.mkdirSync(t,{recursive:!0}),console.log("[Lisa.ai E2E] Created e2e/ directory"))}var se=0,ge=0,fe=new Set;function Me(e){let s=[...we(e).matchAll(/Executed\s+(\d+)\s+of\s+(\d+)(?:\s+\((\d+)\s+FAILED\))?/g)];if(s.length===0)return null;let n=[...s].reverse().find(g=>g[3]!==void 0)??s[s.length-1],o=parseInt(n[2]),i=n[3]?parseInt(n[3]):0,r=parseInt(n[1])-i,a=o>0?Math.round(r/o*100):0;return` [${"\u2588".repeat(Math.round(a/5))+"\u2591".repeat(20-Math.round(a/5))}] ${a}% ${r} passed ${i} failed ${o} total`}function lt(e,t=10){let s=[];for(let n of we(e).split(`
117
- `)){let o=n.trim();if(/^FAILED/.test(o)||/ FAILED$/.test(o)){let r=o.replace(/^(?:Chrome|Firefox|Safari)(?:\s+Headless)?\s+[\d.]+(?:[\s.]\d+)*\s+\([^)]+\)\s+/,"").replace(/\s+FAILED$/,"").trim();if(s.push(r||o),s.length>=t)break}}return s}function Mt(e){let t=e.replace(/\.(spec|test)\.(ts|js|jsx|tsx)$/,".$2");if(t!==e&&H.existsSync(t))try{return console.log(` [Lisa.ai] \u{1F9E0} Sibling source found: ${Z.basename(t)}`),H.readFileSync(t,"utf-8")}catch{return}}function Nt(e,t){let s=e.toLowerCase(),n=Z.parse(t);if(s.includes("ng test")||s.includes("karma"))return`${e} --include **/${n.base}`;if(s.includes("jest")||s.includes("vitest")||s.includes("playwright"))return`${e} ${t}`;if(s.includes("cypress"))return`${e} --spec ${t}`;if(s.includes("npm")||s.includes("yarn")||s.includes("pnpm")){try{let i=JSON.parse(H.readFileSync(Z.resolve(process.cwd(),"package.json"),"utf8")),r="test";s.includes("npm run ")?r=s.split("npm run ")[1].split(" ")[0]:s.includes("yarn ")?r=s.split("yarn ")[1].split(" ")[0]:s.includes("pnpm ")&&(r=s.split("pnpm ")[1].split(" ")[0]);let a=i.scripts?.[r]?.toLowerCase()||"",p=s.includes("npm")?" --":"";if(a.includes("ng test")||a.includes("karma"))return`${e}${p} --include **/${n.base}`;if(a.includes("jest")||a.includes("vitest")||a.includes("playwright"))return`${e}${p} ${t}`}catch{}let o=s.includes("npm")?" --":"";return`${e}${o} ${t}`}return e}function Ne(e,t=!1){return new Promise((s,n)=>{let o=(0,rt.spawn)(e,{shell:!0,stdio:["ignore","pipe","pipe"]}),i="",r="";o.stdout?.on("data",a=>{let p=a.toString();if(i+=p,t)for(let g of p.split(`
118
- `)){let d=g.replace(/\x1B\[[0-9;]*[a-zA-Z]/g,"").trim();d&&(/Executed\s+\d+\s+of\s+\d+/.test(d)?process.stdout.write(`\r ${d.padEnd(72)}`):/^\s*FAILED\b/.test(d)&&(process.stdout.write(`
119
- `),console.log(` \u2717 ${d.trim()}`)))}}),o.stderr?.on("data",a=>{r+=a.toString()}),o.on("close",a=>{a===0?s({stdout:i,stderr:r}):n({message:`Process exited with code ${a}`,stdout:i,stderr:r})})})}function Dt(e,t,s){if(!t.match(/\.(spec|test)\.(ts|js|tsx|jsx|vue)$/))return;if((s||"").toLowerCase().includes("ng test")||(s||"").toLowerCase().includes("karma"))try{H.writeFileSync(e,`// Quarantined by Lisa.ai \u2014 could not be automatically healed
138
+ `,"utf-8"),console.log("[Lisa.ai E2E] Generated playwright.config.ts"));let t=Y.join(e,"e2e");_.existsSync(t)||(_.mkdirSync(t,{recursive:!0}),console.log("[Lisa.ai E2E] Created e2e/ directory"))}var ee=0,Le=0,he=0,xe=0,Ce=new Set;function Ze(e){let s=[...Ee(e).matchAll(/Executed\s+(\d+)\s+of\s+(\d+)(?:\s+\((\d+)\s+FAILED\))?/g)];if(s.length===0)return null;let n=[...s].reverse().find(u=>u[3]!==void 0)??s[s.length-1],o=parseInt(n[2]),i=n[3]?parseInt(n[3]):0,r=parseInt(n[1])-i,a=o>0?Math.round(r/o*100):0;return` [${"\u2588".repeat(Math.round(a/5))+"\u2591".repeat(20-Math.round(a/5))}] ${a}% ${r} passed ${i} failed ${o} total`}function Lt(e,t=10){let s=[];for(let n of Ee(e).split(`
139
+ `)){let o=n.trim();if(/^FAILED/.test(o)||/ FAILED$/.test(o)){let r=o.replace(/^(?:Chrome|Firefox|Safari)(?:\s+Headless)?\s+[\d.]+(?:[\s.]\d+)*\s+\([^)]+\)\s+/,"").replace(/\s+FAILED$/,"").trim();if(s.push(r||o),s.length>=t)break}}return s}function ts(e){let t=e.replace(/\.(spec|test)\.(ts|js|jsx|tsx)$/,".$2");if(t!==e&&B.existsSync(t))try{return console.log(` [Lisa.ai] \u{1F9E0} Sibling source found: ${te.basename(t)}`),B.readFileSync(t,"utf-8")}catch{return}}function Je(e,t){let s=e.toLowerCase(),n=te.parse(t);if(s.includes("ng test")||s.includes("karma"))return`${e} --include **/${n.base}`;if(s.includes("jest")||s.includes("vitest")||s.includes("playwright"))return`${e} ${t}`;if(s.includes("cypress"))return`${e} --spec ${t}`;if(s.includes("npm")||s.includes("yarn")||s.includes("pnpm")){try{let i=JSON.parse(B.readFileSync(te.resolve(process.cwd(),"package.json"),"utf8")),r="test";s.includes("npm run ")?r=s.split("npm run ")[1].split(" ")[0]:s.includes("yarn ")?r=s.split("yarn ")[1].split(" ")[0]:s.includes("pnpm ")&&(r=s.split("pnpm ")[1].split(" ")[0]);let a=i.scripts?.[r]?.toLowerCase()||"",c=s.includes("npm")?" --":"";if(a.includes("ng test")||a.includes("karma"))return`${e}${c} --include **/${n.base}`;if(a.includes("jest")||a.includes("vitest")||a.includes("playwright"))return`${e}${c} ${t}`}catch{}let o=s.includes("npm")?" --":"";return`${e}${o} ${t}`}return e}function ne(e,t=!1){return new Promise((s,n)=>{let o=(0,$t.spawn)(e,{shell:!0,stdio:["ignore","pipe","pipe"]}),i="",r="";o.stdout?.on("data",a=>{let c=a.toString();if(i+=c,t)for(let u of c.split(`
140
+ `)){let p=u.replace(/\x1B\[[0-9;]*[a-zA-Z]/g,"").trim();p&&(/Executed\s+\d+\s+of\s+\d+/.test(p)?process.stdout.write(`\r ${p.padEnd(72)}`):/^\s*FAILED\b/.test(p)&&(process.stdout.write(`
141
+ `),console.log(` \u2717 ${p.trim()}`)))}}),o.stderr?.on("data",a=>{r+=a.toString()}),o.on("close",a=>{a===0?s({stdout:i,stderr:r}):n({message:`Process exited with code ${a}`,stdout:i,stderr:r})})})}function ss(e,t,s){if(!t.match(/\.(spec|test)\.(ts|js|tsx|jsx|vue)$/))return;if((s||"").toLowerCase().includes("ng test")||(s||"").toLowerCase().includes("karma"))try{B.writeFileSync(e,`// Quarantined by Lisa.ai \u2014 could not be automatically healed
120
142
  describe('', () => {});
121
- `,"utf-8"),console.log(" \u{1F6A8} Replaced with empty stub (Angular requires valid TS).")}catch{}else try{H.renameSync(e,e+".broken"),console.log(` \u{1F6A8} Renamed to ${Z.basename(e)}.broken to skip in test runner.`)}catch{}}async function Ut(e,t,s,n,o,i,r,a,p,g){let d=1,x=!1,h=s,f,w="",l="",u=Mt(t),L=(await it(s,i,p)).filter($=>$.confidence>=.5).map($=>$.fixHint);for(L.length>0&&console.log(` [Memory] ${L.length} proven pattern(s) found \u2014 injecting as LLM hint.`);d<=a&&!x;){console.log(` [Attempt ${d}/${a}] Requesting fix from ${r}...`);let $=H.readFileSync(t,"utf-8"),m;for(let y=0;y<=3;y++)try{m=await ze(e,$,h,r,g,f,u,L);break}catch(v){let C=(v?.lastError??v)?.statusCode;if((C===529||C===500)&&y<3){let k=30*(y+1);console.warn(` \u26A0\uFE0F LLM overloaded (HTTP ${C}). Waiting ${k}s...`),await new Promise(E=>setTimeout(E,k*1e3))}else{console.error(` \u{1F6A8} LLM API failed: ${v?.message??String(v)}`);break}}if(m===void 0)break;H.writeFileSync(t,m,"utf-8"),w=`### Auto-Heal Analysis
143
+ `,"utf-8"),console.log(" \u{1F6A8} Replaced with empty stub (Angular requires valid TS).")}catch{}else try{B.renameSync(e,e+".broken"),console.log(` \u{1F6A8} Renamed to ${te.basename(e)}.broken to skip in test runner.`)}catch{}}async function Qe(e,t,s,n,o,i,r,a,c,u,p){let $=1,g=!1,L=s,m,d="",l="",y=ts(t),h=await Ne(s,i,c),C=h.filter(x=>x.confidence>=.5).map(x=>x.fixHint);C.length>0&&console.log(` [Memory] ${C.length} proven pattern(s) found \u2014 injecting as LLM hint.`);let v=h.filter(x=>x.confidence>=(p?.confidenceThreshold??.8));if(p?.enabled&&v.length>0){let x=v[0].confidence;console.log(` [Lisa LLM] High-confidence pattern (${x.toFixed(2)}) \u2014 trying ${p.model}...`);let f=B.readFileSync(t,"utf-8"),w=await dt(e,f,s,v.map(b=>b.fixHint),p);if(w){B.writeFileSync(t,w,"utf-8");try{return await ne(o,!1),console.log(" [Lisa LLM] \u2705 Fix verified. Zero API cost."),d=`### Auto-Heal (Lisa LLM)
144
+ **Model:** ${p.model}
145
+ **Fix:**
146
+ \`\`\`typescript
147
+ ${w}
148
+ \`\`\``,await We(s,w,i,c),{status:"healed",details:d,lastCode:w,resolvedBy:"lisa-llm"}}catch{console.log(" [Lisa LLM] \u274C Verification failed. Escalating to cloud..."),B.writeFileSync(t,f,"utf-8")}}else console.log(" [Lisa LLM] No usable output. Escalating to cloud...")}for(;$<=a&&!g;){console.log(` [Attempt ${$}/${a}] Requesting fix from ${r}...`);let x=B.readFileSync(t,"utf-8"),f;for(let w=0;w<=3;w++)try{f=await lt(e,x,L,r,u,m,y,C);break}catch(b){let F=(b?.lastError??b)?.statusCode;if((F===529||F===500)&&w<3){let E=30*(w+1);console.warn(` \u26A0\uFE0F LLM overloaded (HTTP ${F}). Waiting ${E}s...`),await new Promise(P=>setTimeout(P,E*1e3))}else{console.error(` \u{1F6A8} LLM API failed: ${b?.message??String(b)}`);break}}if(f===void 0)break;B.writeFileSync(t,f,"utf-8"),d=`### Auto-Heal Analysis
122
149
  **Error:**
123
150
  \`\`\`bash
124
- ${h.slice(0,2e3)}
151
+ ${L.slice(0,2e3)}
125
152
  \`\`\`
126
153
 
127
154
  **Fix (${r}):**
128
155
  \`\`\`typescript
129
- ${m}
130
- \`\`\``;try{await Ne(o,!1),console.log(" \u2705 Isolated verification passed."),x=!0,l=m}catch(y){let v=y.stdout?y.stdout.toString():"";h=(y.stderr?y.stderr.toString():"")+`
131
- `+v+`
132
- `+(y.message||""),console.log(" \u274C Isolated verification failed.");let k=Me(h);if(k&&console.log(k),lt(h,3).forEach(E=>console.log(` \u2717 ${E}`)),(n||"").toLowerCase().includes("ng test")||(n||"").toLowerCase().includes("karma")){let E=h.includes(Z.basename(e)+":"),G=/ FAILED/.test(h);if(!E&&!G){console.log(" \u2705 Fix verified (build error is from other spec files, not this one)."),x=!0,l=m;continue}}f=`### Attempt ${d} Failed
156
+ ${f}
157
+ \`\`\``;try{await ne(o,!1),console.log(" \u2705 Isolated verification passed."),g=!0,l=f}catch(w){let b=w.stdout?w.stdout.toString():"";L=(w.stderr?w.stderr.toString():"")+`
158
+ `+b+`
159
+ `+(w.message||""),console.log(" \u274C Isolated verification failed.");let E=Ze(L);if(E&&console.log(E),Lt(L,3).forEach(P=>console.log(` \u2717 ${P}`)),(n||"").toLowerCase().includes("ng test")||(n||"").toLowerCase().includes("karma")){let P=L.includes(te.basename(e)+":"),k=/ FAILED/.test(L);if(!P&&!k){console.log(" \u2705 Fix verified (build error is from other spec files, not this one)."),g=!0,l=f;continue}}m=`### Attempt ${$} Failed
133
160
  \`\`\`typescript
134
- ${m}
161
+ ${f}
135
162
  \`\`\`
136
163
 
137
164
  **New Error:**
138
- ${h}`,d++}}return{status:x?"healed":"quarantined",details:w,lastCode:l}}async function ce(e,t,s=1,n=3,o="local",i,r,a="unit",p,g=!1){se=0,ge=0,fe.clear();let d=a==="unit"?"":` (${a})`,x=P.load(process.cwd());if(x&&P.applyEnvDefaults(x),a==="e2e"){if(!e&&x?.e2eCommand&&(e=x.e2eCommand,console.log(`[Lisa.ai Config] Using e2eCommand from .lisai.json: ${e}`)),!e){console.log(`
139
- [Lisa.ai Heal${d}] Auto-detecting E2E framework...`);let y=ke(process.cwd());!y.installed&&y.framework==="playwright"&&Ce(process.cwd()),e=y.command,console.log(`[Lisa.ai Heal${d}] E2E command: ${e}`)}}else if(!e&&x?.testCommand&&(e=x.testCommand,console.log(`[Lisa.ai Config] Using testCommand from .lisai.json: ${e}`)),!e){console.log(`
140
- [Lisa.ai Auto-Discovery] No --command provided. Scanning framework...`);let y=V.scanRepository();y.testingFramework==="none"&&(y=await ae.installMissingFramework(y),await re.provisionConfigurationFiles(y,t,r)),y.suggestedTestCommand?(e=y.suggestedTestCommand,console.log(`[Lisa.ai Auto-Discovery] Discovered command: ${e}`)):(console.error(`
141
- \u{1F6A8} [Lisa.ai] Could not discover a test command. Pass --command explicitly.`),process.exit(1))}let h=le(e),f=[],w="",l=null,u;if(p&&p.length>0)u=p,console.log(`
142
- [Lisa.ai Heal${d}] Targeting ${p.length} file(s) from --files`),u.forEach(y=>console.log(` - ${y}`));else{console.log(`
143
- [Lisa.ai Heal${d}] Running test suite (discovery pass)...`),console.log(`[Lisa.ai Executing] ${e} Model: ${t}`);try{await Ne(e,!0),process.stdout.write(`
165
+ ${L}`,$++}}return{status:g?"healed":"quarantined",details:d,lastCode:l,resolvedBy:g?r:void 0}}async function ye(e,t,s=1,n=3,o="local",i,r,a="unit",c,u=!1,p){ee=0,Le=0,he=0,xe=0,Ce.clear();let $=a==="unit"?"":` (${a})`,g=R.load(process.cwd());if(g&&R.applyEnvDefaults(g),a==="e2e"){if(!e&&g?.e2eCommand&&(e=g.e2eCommand,console.log(`[Lisa.ai Config] Using e2eCommand from .lisai.json: ${e}`)),!e){console.log(`
166
+ [Lisa.ai Heal${$}] Auto-detecting E2E framework...`);let f=Ue(process.cwd());!f.installed&&f.framework==="playwright"&&De(process.cwd()),e=f.command,console.log(`[Lisa.ai Heal${$}] E2E command: ${e}`)}}else if(!e&&g?.testCommand&&(e=g.testCommand,console.log(`[Lisa.ai Config] Using testCommand from .lisai.json: ${e}`)),!e){console.log(`
167
+ [Lisa.ai Auto-Discovery] No --command provided. Scanning framework...`);let f=K.scanRepository();f.testingFramework==="none"&&(f=await fe.installMissingFramework(f),await me.provisionConfigurationFiles(f,t,r)),f.suggestedTestCommand?(e=f.suggestedTestCommand,console.log(`[Lisa.ai Auto-Discovery] Discovered command: ${e}`)):(console.error(`
168
+ \u{1F6A8} [Lisa.ai] Could not discover a test command. Pass --command explicitly.`),process.exit(1))}let L=se(e),m=[],d="",l=null,y;if(c&&c.length>0)y=c,console.log(`
169
+ [Lisa.ai Heal${$}] Targeting ${c.length} file(s) from --files`),y.forEach(f=>console.log(` - ${f}`));else{console.log(`
170
+ [Lisa.ai Heal${$}] Running test suite (discovery pass)...`),console.log(`[Lisa.ai Executing] ${e} Model: ${t}`);try{await ne(e,!0),process.stdout.write(`
144
171
  `),console.log(`
145
- \u2705 [Lisa.ai] All tests passing. Nothing to heal!`);let v={healedFiles:[],quarantinedFiles:[],testCounts:null,allPassing:!0};return g&&Ie({healedFiles:[],quarantinedFiles:[],testCounts:null,modelProvider:t,framework:"unknown",scope:a},null),v}catch(v){process.stdout.write(`
146
- `),w=(v.stderr||"")+`
147
- `+(v.stdout||"")+`
148
- `+(v.message||"")}l=Y(w);let y=Me(w);if(y){console.log(`
149
- ${y}`);let v=lt(w,10);if(v.length>0){let C=l?.failed??v.length;console.log(` Failing (${C}):`),v.forEach(k=>console.log(` \u2717 ${k}`)),C>v.length&&console.log(` ... and ${C-v.length} more`)}}if(u=Fe(w,process.cwd(),f),u.length===0){let v=ve(w,f,process.cwd());v||(console.error(`
150
- \u{1F6A8} [Lisa.ai] Could not identify any failing spec files. Output format may be unsupported.`),process.exit(1)),u=[v]}}let c=u.length;console.log(`
151
- [Lisa.ai] Found ${c} failing spec(s). Healing each in isolation...`),console.log(`${"\u2500".repeat(60)}`);for(let y of u)I({projectId:o,type:"heal",filePath:y,modelUsed:t,status:"running",details:"Queued for isolated healing.",...l&&{testTotal:l.total,testPassed:l.passed,testFailed:l.failed},testFramework:h});for(let y=0;y<u.length;y++){let v=u[y],C=Z.resolve(process.cwd(),v);if(console.log(`
152
- [${y+1}/${c}] ${v}`),!H.existsSync(C)){console.warn(" \u26A0\uFE0F File not found \u2014 skipping.");continue}if(/[\\/](node_modules|dist|build)[\\/]/.test(C)){console.warn(" \u26A0\uFE0F Library file \u2014 refusing to modify.");continue}let k=Nt(e,v),E=await Ut(v,C,w,e,k,h,t,n,o,r);E.status==="healed"?(se++,fe.add(v),console.log(` \u2705 Healed [${se} healed ${ge} quarantined so far]`),I({projectId:o,type:"heal",filePath:v,modelUsed:t,status:"success",details:E.details,...l&&{testTotal:l.total,testPassed:l.passed,testFailed:l.failed},testFramework:h}),await at(w,E.lastCode,h,o)):(ge++,f.push(v),console.warn(` \u{1F6A8} Quarantined [${se} healed ${ge} quarantined so far]`),I({projectId:o,type:"heal",filePath:v,modelUsed:t,status:"error",details:`Exhausted all ${n} attempts.
153
- `+E.details,...l&&{testTotal:l.total,testPassed:l.passed,testFailed:l.failed},testFramework:h}),Dt(C,v,e))}console.log(`
154
- ${"\u2500".repeat(60)}`);let L=!1;if(se>0){console.log("[Lisa.ai] Final verification run...");try{await Ne(e,!0),process.stdout.write(`
172
+ \u2705 [Lisa.ai] All tests passing. Nothing to heal!`);let w={healedFiles:[],quarantinedFiles:[],testCounts:null,allPassing:!0};return u&&Ye({healedFiles:[],quarantinedFiles:[],testCounts:null,modelProvider:t,framework:"unknown",scope:a},null),w}catch(w){process.stdout.write(`
173
+ `),d=(w.stderr||"")+`
174
+ `+(w.stdout||"")+`
175
+ `+(w.message||"")}l=G(d);let f=Ze(d);if(f){console.log(`
176
+ ${f}`);let w=Lt(d,10);if(w.length>0){let b=l?.failed??w.length;console.log(` Failing (${b}):`),w.forEach(F=>console.log(` \u2717 ${F}`)),b>w.length&&console.log(` ... and ${b-w.length} more`)}}if(y=Ge(d,process.cwd(),m),y.length===0){let w=Ae(d,m,process.cwd());w||(console.error(`
177
+ \u{1F6A8} [Lisa.ai] Could not identify any failing spec files. Output format may be unsupported.`),process.exit(1)),y=[w]}}let h=y.length;console.log(`
178
+ [Lisa.ai] Found ${h} failing spec(s). Healing each in isolation...`),console.log(`${"\u2500".repeat(60)}`);for(let f of y)N({projectId:o,type:"heal",filePath:f,modelUsed:t,status:"running",details:"Queued for isolated healing.",...l&&{testTotal:l.total,testPassed:l.passed,testFailed:l.failed},testFramework:L});for(let f=0;f<y.length;f++){let w=y[f],b=te.resolve(process.cwd(),w);if(console.log(`
179
+ [${f+1}/${h}] ${w}`),!B.existsSync(b)){console.warn(" \u26A0\uFE0F File not found \u2014 skipping.");continue}if(/[\\/](node_modules|dist|build)[\\/]/.test(b)){console.warn(" \u26A0\uFE0F Library file \u2014 refusing to modify.");continue}let F=Je(e,w),E=await Qe(w,b,d,e,F,L,t,n,o,r,p);E.status==="healed"?(ee++,E.resolvedBy==="lisa-llm"?he++:xe++,Ce.add(w),console.log(` \u2705 Healed [${ee} healed ${Le} quarantined so far]`),N({projectId:o,type:"heal",filePath:w,modelUsed:E.resolvedBy==="lisa-llm"?p.model:t,status:"success",details:E.details,...l&&{testTotal:l.total,testPassed:l.passed,testFailed:l.failed},testFramework:L,resolvedBy:E.resolvedBy}),E.resolvedBy!=="lisa-llm"&&await We(d,E.lastCode,L,o)):(Le++,m.push(w),console.warn(` \u{1F6A8} Quarantined [${ee} healed ${Le} quarantined so far]`),N({projectId:o,type:"heal",filePath:w,modelUsed:t,status:"error",details:`Exhausted all ${n} attempts.
180
+ `+E.details,...l&&{testTotal:l.total,testPassed:l.passed,testFailed:l.failed},testFramework:L}),ss(b,w,e))}console.log(`
181
+ ${"\u2500".repeat(60)}`);let C=!1;if(ee>0){console.log("[Lisa.ai] Final verification run...");try{await ne(e,!0),process.stdout.write(`
155
182
  `),console.log(`
156
- \u2705 All tests passing!`),L=!0}catch(y){process.stdout.write(`
157
- `);let v=(y.stderr||"")+`
158
- `+(y.stdout||"")+`
159
- `+(y.message||""),C=Me(v);C&&console.log(`
160
- ${C}`);let k=Fe(v,process.cwd(),[]),E=k.filter(M=>fe.has(M)),G=k.filter(M=>!fe.has(M)&&!f.includes(M));E.length>0&&(console.warn(`
161
- \u26A0\uFE0F ${E.length} spec(s) passed isolated verification but still fail globally:`),E.forEach(M=>console.warn(` \u2717 ${M}`)),console.warn(" These likely have cross-test shared state. Try higher maxRetries or fix manually.")),G.length>0&&(console.warn(`
162
- \u2139\uFE0F ${G.length} additional failing spec(s) not in this run's queue:`),G.forEach(M=>console.warn(` \u2717 ${M}`)),console.warn(" Run lisa-agent heal again to address these."))}}let $=(l?.passed??0)+se;console.log(`
163
- \u2705 Healed: ${se} / ${c}`),console.log(` \u{1F6A8} Quarantined: ${ge}`),l&&console.log(` \u{1F4CA} Suite: ${l.passed} passing \u2192 ~${$} passing (est.)`),console.log(`${"\u2500".repeat(60)}
164
- `);let m={healedFiles:[...fe],quarantinedFiles:[...f],testCounts:l,allPassing:L};if(g){let y={healedFiles:m.healedFiles,quarantinedFiles:m.quarantinedFiles,testCounts:m.testCounts,modelProvider:t,framework:h,scope:a},v=await et(y);Ie(y,v),m.allPassing||(process.exitCode=1)}return m}var ut=require("child_process"),W=b(require("fs")),N=b(require("path"));var Se=b(require("fs")),ct=b(require("path"));function dt(e){let t=ct.resolve(process.cwd(),e);if(!Se.existsSync(t))throw new Error(`[Lisa.ai Coverage Error] Coverage file not found at ${t}`);let s=Se.readFileSync(t,"utf-8"),n=JSON.parse(s),o=[];for(let[i,r]of Object.entries(n))i!=="total"&&(r.lines.pct<100||r.statements.pct<100||r.functions.pct<100||r.branches.pct<100)&&o.push(i);return o}var be=new Set,je=0,De=3;function _t(e){let t=e.testingFramework,s=process.cwd();return W.existsSync(N.join(s,"angular.json"))?"npx ng test --no-watch --code-coverage --browsers=ChromeHeadless":t==="jest"?"npx jest --coverage --coverageReporters=json-summary":t==="vitest"?"npx vitest run --coverage":[".mocharc.yml",".mocharc.yaml",".mocharc.json",".mocharc.js"].some(o=>W.existsSync(N.join(s,o)))?"npx nyc --reporter=json-summary mocha":null}async function pt(e,t,s=1,n=3,o="local",i,r){let a=P.load(process.cwd());a&&(P.applyEnvDefaults(a),!e&&a.testCommand&&(e=a.testCommand,console.log(`[Lisa.ai Config] Using testCommand from .lisai.json: ${e}`)));let p=V.scanRepository(),g=a?.testingFramework||(p.testingFramework!=="none"?p.testingFramework:void 0),d=a?.testTypes;if(!e){console.log(`
165
- [Lisa.ai Auto-Discovery] No explicit --command provided. Auto-detecting coverage command...`);let f=_t(p);if(f)e=f,console.log(`[Lisa.ai Auto-Discovery] Detected coverage command: ${e}`);else{let w=p;if(w.testingFramework==="none"&&(w=await ae.installMissingFramework(w),await re.provisionConfigurationFiles(w,t,i)),w.suggestedTestCommand){e=w.suggestedTestCommand;let l=w.testingFramework;(l==="jest"||l==="vitest")&&!e.includes("--coverage")&&(e=e.includes("npm run")?`${e} -- --coverage`:`${e} --coverage`,console.log(`[Lisa.ai Unit] Coverage flag appended: ${e}`)),console.log(`[Lisa.ai Auto-Discovery] Bootstrapping with discovered command: ${e}`)}else console.error(`
166
- [Lisa.ai Fatal Error] Could not auto-detect a test framework. Please pass --command explicitly or add a .lisai.json config.`),process.exit(1)}}console.log(`
167
- [Lisa.ai Unit] ${e} (Attempt ${s}/${n}) Using Model: ${t}`);let x=le(e);await I({projectId:o,type:"unit",filePath:"global-test-suite",modelUsed:t,status:"running",details:"Agent is executing unit test suite and validating coverage...",testFramework:x});let h=(f,w=!1)=>new Promise((l,u)=>{let c=(0,ut.spawn)(f,{shell:!0,stdio:["ignore","pipe","pipe"]}),L="",$="";c.stdout?.on("data",m=>{let y=m.toString();if(L+=y,w){let v=y.split(`
168
- `);for(let C of v){let k=C.match(/Executed\s+(\d+)\s+of\s+(\d+)/);if(k){let E=C.match(/(\d+)\s+FAILED/),G=E?E[1]:0,M=`\r[Lisa.ai Testing] Executed ${k[1]} of ${k[2]} (${G} FAILED) `;process.stdout.write(M)}}}}),c.stderr?.on("data",m=>{$+=m.toString()}),c.on("close",m=>{m===0?l({stdout:L,stderr:$}):u({message:`Test process exited with code ${m}`,stdout:L,stderr:$})})});try{console.log("[Lisa.ai Unit] Running tests with coverage. This may take a moment...");let f=await h(e,!0),w=f.stdout+`
169
- `+f.stderr,l=Y(w);l&&await I({projectId:o,type:"unit",filePath:"global-test-suite",modelUsed:t,status:"success",details:`Tests passed on attempt ${s}.`,testTotal:l.total,testPassed:l.passed,testFailed:l.failed,testFramework:x}),console.log(`
170
- [Lisa.ai Unit] Tests passed on attempt ${s}.`)}catch(f){let w=(f.stderr||"")+`
183
+ \u2705 All tests passing!`),C=!0}catch(f){process.stdout.write(`
184
+ `);let w=(f.stderr||"")+`
171
185
  `+(f.stdout||"")+`
172
- `+(f.message||"");ve(w,[],process.cwd())!==null?(console.log(`
173
- [Lisa.ai Unit] Tests failed. Delegating to Auto-Heal...`),await ce(e,t,1,n,o,void 0,i),console.log(`
186
+ `+(f.message||""),b=Ze(w);b&&console.log(`
187
+ ${b}`);let F=Ge(w,process.cwd(),[]),E=F.filter(k=>Ce.has(k)),P=F.filter(k=>!Ce.has(k)&&!m.includes(k));E.length>0&&(console.warn(`
188
+ \u26A0\uFE0F ${E.length} spec(s) passed isolated verification but still fail globally:`),E.forEach(k=>console.warn(` \u2717 ${k}`)),console.warn(" These likely have cross-test shared state. Try higher maxRetries or fix manually.")),P.length>0&&(console.warn(`
189
+ \u2139\uFE0F ${P.length} additional failing spec(s) not in this run's queue:`),P.forEach(k=>console.warn(` \u2717 ${k}`)),console.warn(" Run lisa-agent heal again to address these."))}}let v=(l?.passed??0)+ee;if(console.log(`
190
+ \u2705 Healed: ${ee} / ${h}`),p?.enabled&&(he>0||xe>0)){let f=ee>0?Math.round(he/ee*100):0;console.log(` \u{1F9E0} Lisa LLM: ${he} fix${he!==1?"es":""} (${f}%)`),console.log(` \u2601\uFE0F Cloud: ${xe} fix${xe!==1?"es":""}`)}console.log(` \u{1F6A8} Quarantined: ${Le}`),l&&console.log(` \u{1F4CA} Suite: ${l.passed} passing \u2192 ~${v} passing (est.)`),console.log(`${"\u2500".repeat(60)}
191
+ `);let x={healedFiles:[...Ce],quarantinedFiles:[...m],testCounts:l,allPassing:C};if(u){let f={healedFiles:x.healedFiles,quarantinedFiles:x.quarantinedFiles,testCounts:x.testCounts,modelProvider:t,framework:L,scope:a},w=await mt(f);Ye(f,w),x.allPassing||(process.exitCode=1)}return x}var kt=require("child_process"),J=S(require("fs")),O=S(require("path"));var Oe=S(require("fs")),xt=S(require("path"));function Ct(e){let t=xt.resolve(process.cwd(),e);if(!Oe.existsSync(t))throw new Error(`[Lisa.ai Coverage Error] Coverage file not found at ${t}`);let s=Oe.readFileSync(t,"utf-8"),n=JSON.parse(s),o=[];for(let[i,r]of Object.entries(n))i!=="total"&&(r.lines.pct<100||r.statements.pct<100||r.functions.pct<100||r.branches.pct<100)&&o.push(i);return o}var _e=new Set,ke=0,Xe=3;function ns(e){let t=e.testingFramework,s=process.cwd();return J.existsSync(O.join(s,"angular.json"))?"npx ng test --no-watch --code-coverage --browsers=ChromeHeadless":t==="jest"?"npx jest --coverage --coverageReporters=json-summary":t==="vitest"?"npx vitest run --coverage":[".mocharc.yml",".mocharc.yaml",".mocharc.json",".mocharc.js"].some(o=>J.existsSync(O.join(s,o)))?"npx nyc --reporter=json-summary mocha":null}async function bt(e,t,s=1,n=3,o="local",i,r,a){let c=R.load(process.cwd());c&&(R.applyEnvDefaults(c),!e&&c.testCommand&&(e=c.testCommand,console.log(`[Lisa.ai Config] Using testCommand from .lisai.json: ${e}`)));let u=K.scanRepository(),p=c?.testingFramework||(u.testingFramework!=="none"?u.testingFramework:void 0),$=c?.testTypes;if(!e){console.log(`
192
+ [Lisa.ai Auto-Discovery] No explicit --command provided. Auto-detecting coverage command...`);let m=ns(u);if(m)e=m,console.log(`[Lisa.ai Auto-Discovery] Detected coverage command: ${e}`);else{let d=u;if(d.testingFramework==="none"&&(d=await fe.installMissingFramework(d),await me.provisionConfigurationFiles(d,t,i)),d.suggestedTestCommand){e=d.suggestedTestCommand;let l=d.testingFramework;(l==="jest"||l==="vitest")&&!e.includes("--coverage")&&(e=e.includes("npm run")?`${e} -- --coverage`:`${e} --coverage`,console.log(`[Lisa.ai Unit] Coverage flag appended: ${e}`)),console.log(`[Lisa.ai Auto-Discovery] Bootstrapping with discovered command: ${e}`)}else console.error(`
193
+ [Lisa.ai Fatal Error] Could not auto-detect a test framework. Please pass --command explicitly or add a .lisai.json config.`),process.exit(1)}}console.log(`
194
+ [Lisa.ai Unit] ${e} (Attempt ${s}/${n}) Using Model: ${t}`);let g=se(e);await N({projectId:o,type:"unit",filePath:"global-test-suite",modelUsed:t,status:"running",details:"Agent is executing unit test suite and validating coverage...",testFramework:g});let L=(m,d=!1)=>new Promise((l,y)=>{let h=(0,kt.spawn)(m,{shell:!0,stdio:["ignore","pipe","pipe"]}),C="",v="";h.stdout?.on("data",x=>{let f=x.toString();if(C+=f,d){let w=f.split(`
195
+ `);for(let b of w){let F=b.match(/Executed\s+(\d+)\s+of\s+(\d+)/);if(F){let E=b.match(/(\d+)\s+FAILED/),P=E?E[1]:0,k=`\r[Lisa.ai Testing] Executed ${F[1]} of ${F[2]} (${P} FAILED) `;process.stdout.write(k)}}}}),h.stderr?.on("data",x=>{v+=x.toString()}),h.on("close",x=>{x===0?l({stdout:C,stderr:v}):y({message:`Test process exited with code ${x}`,stdout:C,stderr:v})})});try{console.log("[Lisa.ai Unit] Running tests with coverage. This may take a moment...");let m=await L(e,!0),d=m.stdout+`
196
+ `+m.stderr,l=G(d);l&&await N({projectId:o,type:"unit",filePath:"global-test-suite",modelUsed:t,status:"success",details:`Tests passed on attempt ${s}.`,testTotal:l.total,testPassed:l.passed,testFailed:l.failed,testFramework:g}),console.log(`
197
+ [Lisa.ai Unit] Tests passed on attempt ${s}.`)}catch(m){let d=(m.stderr||"")+`
198
+ `+(m.stdout||"")+`
199
+ `+(m.message||"");Ae(d,[],process.cwd())!==null?(console.log(`
200
+ [Lisa.ai Unit] Tests failed. Delegating to Auto-Heal...`),await ye(e,t,1,n,o,void 0,i,"unit",void 0,!1,a),console.log(`
174
201
  [Lisa.ai Unit] Auto-Heal complete. Continuing to test generation...`)):console.log(`
175
- [Lisa.ai Unit] No failing spec detected. Tests may not exist yet \u2014 initiating Cold-Start Discovery...`)}try{let f=[];if(r&&r.length>0)f=r,console.log(`
176
- [Lisa.ai Unit] Targeting ${r.length} file(s) from --files`),f.forEach(l=>console.log(` - ${l}`));else{let l=N.resolve(process.cwd(),"coverage/coverage-summary.json");if(W.existsSync(l))console.log("[Lisa.ai Unit] Evaluating coverage summary..."),f=dt("coverage/coverage-summary.json");else{if(console.log(`
177
- [Lisa.ai Unit] No coverage-summary.json found. Initiating Cold-Start Discovery...`),f=V.findUntestedFiles(process.cwd(),[...be]),f.length===0){console.log("[Lisa.ai Unit] No untested source files discovered.");return}console.log(`[Lisa.ai Unit] Discovered ${f.length} untested file(s). Generating specs...`)}let u=V.findUntestedFiles(process.cwd(),[...be]);if(u.length>0){let c=new Set(f.map($=>N.resolve(process.cwd(),$))),L=u.filter($=>!c.has(N.resolve(process.cwd(),$)));L.length>0&&(console.log(`[Lisa.ai Unit] Discovered ${L.length} additional source file(s) with no tests.`),f.push(...L))}if(f.length===0){console.log("[Lisa.ai Unit] 100% coverage achieved. No uncovered files remaining.");return}}console.log(`[Lisa.ai Unit] Found ${f.length} file(s) below threshold:`,f);let w=0;for(let l of f){if(be.has(l))continue;let u=N.resolve(process.cwd(),l),c=N.parse(u),L=[N.join(c.dir,`${c.name}.spec${c.ext}`),N.join(c.dir,`${c.name}.test${c.ext}`),N.join(c.dir,`${c.name}.spec.js`),N.join(c.dir,`${c.name}.test.js`),N.join(c.dir,`${c.name}.spec.ts`),N.join(c.dir,`${c.name}.test.ts`)],$=null,m=N.join(c.dir,`${c.name}.spec${c.ext}`);for(let k of L)if(W.existsSync(k)){m=k,$=W.readFileSync(k,"utf-8");break}let y="",v=!1,C=W.readFileSync(u,"utf-8");try{$?(console.log(`
178
- [Lisa.ai Unit] [${w+1}/${f.length}] Existing spec found for ${l}. Requesting coverage append...`),y=await Ze(l,C,N.relative(process.cwd(),m),$,t,i,g,d)):(console.log(`
179
- [Lisa.ai Unit] [${w+1}/${f.length}] Generating new spec for ${l}...`),y=await ee(l,C,t,i,g,d)),je=0,v=!0}catch(k){je++,be.add(l);let E=k.cause?.message?`${k.message} (cause: ${k.cause.message})`:k.message;if(console.error(`
180
- [Lisa.ai Unit] LLM call failed for ${l} \u2014 consecutive failure #${je}/${De}`),console.error(` Error: ${E}`),je>=De)throw new Error(`Systematic LLM failure: ${De} consecutive API calls failed.
202
+ [Lisa.ai Unit] No failing spec detected. Tests may not exist yet \u2014 initiating Cold-Start Discovery...`)}try{let m=[];if(r&&r.length>0)m=r,console.log(`
203
+ [Lisa.ai Unit] Targeting ${r.length} file(s) from --files`),m.forEach(l=>console.log(` - ${l}`));else{let l=O.resolve(process.cwd(),"coverage/coverage-summary.json");if(J.existsSync(l))console.log("[Lisa.ai Unit] Evaluating coverage summary..."),m=Ct("coverage/coverage-summary.json");else{if(console.log(`
204
+ [Lisa.ai Unit] No coverage-summary.json found. Initiating Cold-Start Discovery...`),m=K.findUntestedFiles(process.cwd(),[..._e]),m.length===0){console.log("[Lisa.ai Unit] No untested source files discovered.");return}console.log(`[Lisa.ai Unit] Discovered ${m.length} untested file(s). Generating specs...`)}let y=K.findUntestedFiles(process.cwd(),[..._e]);if(y.length>0){let h=new Set(m.map(v=>O.resolve(process.cwd(),v))),C=y.filter(v=>!h.has(O.resolve(process.cwd(),v)));C.length>0&&(console.log(`[Lisa.ai Unit] Discovered ${C.length} additional source file(s) with no tests.`),m.push(...C))}if(m.length===0){console.log("[Lisa.ai Unit] 100% coverage achieved. No uncovered files remaining.");return}}console.log(`[Lisa.ai Unit] Found ${m.length} file(s) below threshold:`,m);let d=0;for(let l of m){if(_e.has(l))continue;let y=O.resolve(process.cwd(),l),h=O.parse(y),C=[O.join(h.dir,`${h.name}.spec${h.ext}`),O.join(h.dir,`${h.name}.test${h.ext}`),O.join(h.dir,`${h.name}.spec.js`),O.join(h.dir,`${h.name}.test.js`),O.join(h.dir,`${h.name}.spec.ts`),O.join(h.dir,`${h.name}.test.ts`)],v=null,x=O.join(h.dir,`${h.name}.spec${h.ext}`);for(let F of C)if(J.existsSync(F)){x=F,v=J.readFileSync(F,"utf-8");break}let f="",w=!1,b=J.readFileSync(y,"utf-8");if(a?.enabled&&!v&&o!=="local"){let E=(await Ne(l,g,o)).filter(P=>P.confidence>=(a.confidenceThreshold??.8));if(E.length>0){console.log(`
205
+ [Lisa.ai Unit] [${d+1}/${m.length}] Trying Lisa LLM for ${l}...`);let P=await ut(l,b,E.map(k=>k.fixHint),a,p);P&&(f=P,ke=0,w=!0,console.log(" [Lisa LLM] \u2705 Test generated. Zero API cost."))}}if(!w)try{v?(console.log(`
206
+ [Lisa.ai Unit] [${d+1}/${m.length}] Existing spec found for ${l}. Requesting coverage append...`),f=await ct(l,b,O.relative(process.cwd(),x),v,t,i,p,$)):(console.log(`
207
+ [Lisa.ai Unit] [${d+1}/${m.length}] Generating new spec for ${l}...`),f=await X(l,b,t,i,p,$)),ke=0,w=!0}catch(F){ke++,_e.add(l);let E=F.cause?.message?`${F.message} (cause: ${F.cause.message})`:F.message;if(console.error(`
208
+ [Lisa.ai Unit] LLM call failed for ${l} \u2014 consecutive failure #${ke}/${Xe}`),console.error(` Error: ${E}`),ke>=Xe)throw new Error(`Systematic LLM failure: ${Xe} consecutive API calls failed.
181
209
  This usually means your API key has insufficient credits, hit a rate limit, or the model is unavailable.
182
210
  Last error: ${E}
183
- Tip: Check your API key, account credits, and rate-limit quota for provider '${t}'.`)}v&&(W.writeFileSync(m,y,"utf-8"),w++,console.log(`[Lisa.ai Unit] Wrote spec to ${m}`),await I({projectId:o,type:"unit",filePath:l,modelUsed:t,status:"success",details:`### Unit Test Generated
211
+ Tip: Check your API key, account credits, and rate-limit quota for provider '${t}'.`)}w&&(J.writeFileSync(x,f,"utf-8"),d++,console.log(`[Lisa.ai Unit] Wrote spec to ${x}`),await N({projectId:o,type:"unit",filePath:l,modelUsed:t,status:"success",details:`### Unit Test Generated
184
212
  **Auto-Generated Spec (${t}):**
185
213
  \`\`\`typescript
186
- ${y}
187
- \`\`\``,testFramework:x}))}if(console.log(`
188
- [Lisa.ai Unit] Generated ${w} spec file(s).`),w>0){console.log("[Lisa.ai Unit] Running verification pass...");try{let l=await h(e,!0),u=l.stdout+`
189
- `+l.stderr,c=Y(u);console.log(`
190
- [Lisa.ai Unit] Verification passed.`),c&&(console.log(`[Lisa.ai Unit] Final: ${c.passed}/${c.total} passing, ${c.failed} failing.`),await I({projectId:o,type:"unit",filePath:"global-test-suite",modelUsed:t,status:c.failed===0?"success":"error",details:`Verification after generating ${w} specs.`,testTotal:c.total,testPassed:c.passed,testFailed:c.failed,testFramework:x})),c&&c.failed>0&&s<n&&(console.log(`
191
- [Lisa.ai Unit] ${c.failed} generated test(s) failing. Delegating to Auto-Heal...`),await ce(e,t,1,n,o,void 0,i))}catch(l){let u=(l.stderr||"")+`
192
- `+(l.stdout||""),c=Y(u);c&&c.failed>0&&s<n?(console.log(`
193
- [Lisa.ai Unit] ${c.failed} generated test(s) failing. Delegating to Auto-Heal...`),await ce(e,t,1,n,o,void 0,i)):console.log(`
194
- [Lisa.ai Unit] Some generated tests failed. Run 'lisa-agent heal' to fix them.`)}}}catch(f){console.error("[Lisa.ai Unit loop failure]:",f.message),await I({projectId:o,type:"unit",filePath:"unit-loop",modelUsed:t,status:"error",details:`Unit test generation encountered an unrecoverable error: ${f.message}`,testFramework:x})}}var gt=require("child_process"),T=b(require("fs")),q=b(require("path"));function Ot(e){let t=[],s=["src/app/app.routes.ts","src/app/app-routing.module.ts"];for(let o of s){let i=q.join(e,o);if(T.existsSync(i)){let a=T.readFileSync(i,"utf-8").matchAll(/path:\s*['"`]([^'"`]+)['"`]/g);for(let p of a)p[1]&&p[1]!=="**"&&t.push(p[1])}}let n=["src/App.tsx","src/App.jsx","src/routes.tsx","src/routes.jsx"];for(let o of n){let i=q.join(e,o);if(T.existsSync(i)){let a=T.readFileSync(i,"utf-8").matchAll(/path=["']([^"']+)["']/g);for(let p of a)p[1]&&t.push(p[1])}}return[...new Set(t)].sort()}async function ft(e,t,s=1,n=3,o="local",i,r){if(s>n){console.log(`
195
- [Lisa.ai E2E] Reached maximum retries (${n}). Stopping.`);return}let a=process.cwd(),p=P.load(a);p&&(P.applyEnvDefaults(p),!e&&p.e2eCommand&&(e=p.e2eCommand,console.log(`[Lisa.ai Config] Using e2eCommand from .lisai.json: ${e}`)));let g=ke(a),d=p?.e2eFramework||g.framework;console.log(`
196
- [Lisa.ai E2E] Framework: ${d} (Attempt ${s}/${n}) Model: ${t}`),!g.installed&&d==="playwright"&&Ce(a),e||(e=g.command,console.log(`[Lisa.ai E2E] Using auto-detected command: ${e}`)),await I({projectId:o,type:"e2e",filePath:"e2e-suite",modelUsed:t,status:"running",details:`E2E test generation started with ${d}`,testFramework:d});let x=0;if(r&&r.length>0){console.log(`
197
- [Lisa.ai E2E] Targeting ${r.length} file(s) from --files`),r.forEach(c=>console.log(` - ${c}`));for(let c of r){let L=q.resolve(a,c);if(T.existsSync(L)){console.log(`[Lisa.ai E2E] Spec already exists: ${c} \u2014 will run as-is.`);continue}let $=q.dirname(L);T.existsSync($)||T.mkdirSync($,{recursive:!0}),console.log(`[Lisa.ai E2E] Generating E2E spec: ${c}...`);let m=`
214
+ ${f}
215
+ \`\`\``,testFramework:g}))}if(console.log(`
216
+ [Lisa.ai Unit] Generated ${d} spec file(s).`),d>0){console.log("[Lisa.ai Unit] Running verification pass...");try{let l=await L(e,!0),y=l.stdout+`
217
+ `+l.stderr,h=G(y);console.log(`
218
+ [Lisa.ai Unit] Verification passed.`),h&&(console.log(`[Lisa.ai Unit] Final: ${h.passed}/${h.total} passing, ${h.failed} failing.`),await N({projectId:o,type:"unit",filePath:"global-test-suite",modelUsed:t,status:h.failed===0?"success":"error",details:`Verification after generating ${d} specs.`,testTotal:h.total,testPassed:h.passed,testFailed:h.failed,testFramework:g})),h&&h.failed>0&&s<n&&(console.log(`
219
+ [Lisa.ai Unit] ${h.failed} generated test(s) failing. Delegating to Auto-Heal...`),await ye(e,t,1,n,o,void 0,i,"unit",void 0,!1,a))}catch(l){let y=(l.stderr||"")+`
220
+ `+(l.stdout||""),h=G(y);h&&h.failed>0&&s<n?(console.log(`
221
+ [Lisa.ai Unit] ${h.failed} generated test(s) failing. Delegating to Auto-Heal...`),await ye(e,t,1,n,o,void 0,i,"unit",void 0,!1,a)):console.log(`
222
+ [Lisa.ai Unit] Some generated tests failed. Run 'lisa-agent heal' to fix them.`)}}}catch(m){console.error("[Lisa.ai Unit loop failure]:",m.message),await N({projectId:o,type:"unit",filePath:"unit-loop",modelUsed:t,status:"error",details:`Unit test generation encountered an unrecoverable error: ${m.message}`,testFramework:g})}}var St=require("child_process"),U=S(require("fs")),V=S(require("path"));function os(e){let t=[],s=["src/app/app.routes.ts","src/app/app-routing.module.ts"];for(let o of s){let i=V.join(e,o);if(U.existsSync(i)){let a=U.readFileSync(i,"utf-8").matchAll(/path:\s*['"`]([^'"`]+)['"`]/g);for(let c of a)c[1]&&c[1]!=="**"&&t.push(c[1])}}let n=["src/App.tsx","src/App.jsx","src/routes.tsx","src/routes.jsx"];for(let o of n){let i=V.join(e,o);if(U.existsSync(i)){let a=U.readFileSync(i,"utf-8").matchAll(/path=["']([^"']+)["']/g);for(let c of a)c[1]&&t.push(c[1])}}return[...new Set(t)].sort()}async function Ft(e,t,s=1,n=3,o="local",i,r){if(s>n){console.log(`
223
+ [Lisa.ai E2E] Reached maximum retries (${n}). Stopping.`);return}let a=process.cwd(),c=R.load(a);c&&(R.applyEnvDefaults(c),!e&&c.e2eCommand&&(e=c.e2eCommand,console.log(`[Lisa.ai Config] Using e2eCommand from .lisai.json: ${e}`)));let u=Ue(a),p=c?.e2eFramework||u.framework;console.log(`
224
+ [Lisa.ai E2E] Framework: ${p} (Attempt ${s}/${n}) Model: ${t}`),!u.installed&&p==="playwright"&&De(a),e||(e=u.command,console.log(`[Lisa.ai E2E] Using auto-detected command: ${e}`)),await N({projectId:o,type:"e2e",filePath:"e2e-suite",modelUsed:t,status:"running",details:`E2E test generation started with ${p}`,testFramework:p});let $=0;if(r&&r.length>0){console.log(`
225
+ [Lisa.ai E2E] Targeting ${r.length} file(s) from --files`),r.forEach(y=>console.log(` - ${y}`));for(let y of r){let h=V.resolve(a,y);if(U.existsSync(h)){console.log(`[Lisa.ai E2E] Spec already exists: ${y} \u2014 will run as-is.`);continue}let C=V.dirname(h);U.existsSync(C)||U.mkdirSync(C,{recursive:!0}),console.log(`[Lisa.ai E2E] Generating E2E spec: ${y}...`);let v=`
198
226
  E2E Test Generation Context:
199
- - Framework: ${d}
200
- - Target file: ${c}
201
- - App Type: ${T.existsSync(q.join(a,"angular.json"))?"Angular":"Web App"}
227
+ - Framework: ${p}
228
+ - Target file: ${y}
229
+ - App Type: ${U.existsSync(V.join(a,"angular.json"))?"Angular":"Web App"}
202
230
  - Base URL: http://localhost:4200
203
231
 
204
- Generate a ${d} E2E test spec for "${c}".
232
+ Generate a ${p} E2E test spec for "${y}".
205
233
  The test should:
206
234
  1. Navigate to the relevant page
207
235
  2. Verify the page loads correctly
@@ -209,14 +237,14 @@ The test should:
209
237
  4. Assert critical UI elements are visible
210
238
 
211
239
  Use @playwright/test imports. Keep it concise and practical.
212
- `;try{let y=await ee(c,m,t,i,d,["e2e"]);T.writeFileSync(L,y,"utf-8"),console.log(`[Lisa.ai E2E] Wrote ${c}`),x++,await I({projectId:o,type:"e2e",filePath:c,modelUsed:t,status:"success",details:`Generated E2E spec: ${c}`,testFramework:d})}catch(y){console.error(`[Lisa.ai E2E] LLM failed for ${c}: ${y.message}`),await I({projectId:o,type:"e2e",filePath:c,modelUsed:t,status:"error",details:`LLM failed to generate E2E spec: ${y.message}`,testFramework:d})}}if(x===0&&r.every(c=>!T.existsSync(q.resolve(a,c)))){console.log("[Lisa.ai E2E] No specs generated. Check LLM connectivity with 'lisa-agent diagnose'.");return}}else{let c=Ot(a);c.length===0?(console.log("[Lisa.ai E2E] No routes discovered. Will generate basic smoke test."),c.push("")):console.log(`[Lisa.ai E2E] Discovered ${c.length} route(s):`,c);let L=q.join(a,"e2e");T.existsSync(L)||T.mkdirSync(L,{recursive:!0});let $=T.existsSync(L)?T.readdirSync(L).filter(m=>m.endsWith(".spec.ts")||m.endsWith(".test.ts")):[];for(let m of c){let v=`${(m||"home").replace(/\//g,"-")}.spec.ts`,C=q.join(L,v);if($.includes(v)){console.log(`[Lisa.ai E2E] Spec already exists for /${m} \u2014 skipping.`);continue}console.log(`[Lisa.ai E2E] Generating E2E spec for /${m}...`);try{let k=`
240
+ `;try{let x=await X(y,v,t,i,p,["e2e"]);U.writeFileSync(h,x,"utf-8"),console.log(`[Lisa.ai E2E] Wrote ${y}`),$++,await N({projectId:o,type:"e2e",filePath:y,modelUsed:t,status:"success",details:`Generated E2E spec: ${y}`,testFramework:p})}catch(x){console.error(`[Lisa.ai E2E] LLM failed for ${y}: ${x.message}`),await N({projectId:o,type:"e2e",filePath:y,modelUsed:t,status:"error",details:`LLM failed to generate E2E spec: ${x.message}`,testFramework:p})}}if($===0&&r.every(y=>!U.existsSync(V.resolve(a,y)))){console.log("[Lisa.ai E2E] No specs generated. Check LLM connectivity with 'lisa-agent diagnose'.");return}}else{let y=os(a);y.length===0?(console.log("[Lisa.ai E2E] No routes discovered. Will generate basic smoke test."),y.push("")):console.log(`[Lisa.ai E2E] Discovered ${y.length} route(s):`,y);let h=V.join(a,"e2e");U.existsSync(h)||U.mkdirSync(h,{recursive:!0});let C=U.existsSync(h)?U.readdirSync(h).filter(v=>v.endsWith(".spec.ts")||v.endsWith(".test.ts")):[];for(let v of y){let f=`${(v||"home").replace(/\//g,"-")}.spec.ts`,w=V.join(h,f);if(C.includes(f)){console.log(`[Lisa.ai E2E] Spec already exists for /${v} \u2014 skipping.`);continue}console.log(`[Lisa.ai E2E] Generating E2E spec for /${v}...`);try{let b=`
213
241
  E2E Test Generation Context:
214
- - Framework: ${d}
215
- - Route: /${m}
216
- - App Type: ${T.existsSync(q.join(a,"angular.json"))?"Angular":"Web App"}
242
+ - Framework: ${p}
243
+ - Route: /${v}
244
+ - App Type: ${U.existsSync(V.join(a,"angular.json"))?"Angular":"Web App"}
217
245
  - Base URL: http://localhost:4200
218
246
 
219
- Generate a ${d} E2E test spec for the route "/${m}".
247
+ Generate a ${p} E2E test spec for the route "/${v}".
220
248
  The test should:
221
249
  1. Navigate to the route
222
250
  2. Verify the page loads correctly
@@ -224,27 +252,27 @@ The test should:
224
252
  4. Assert critical UI elements are visible
225
253
 
226
254
  Use @playwright/test imports. Keep it concise and practical.
227
- `,E=await ee(`e2e/${v}`,k,t,i,d,["e2e"]);T.writeFileSync(C,E,"utf-8"),console.log(`[Lisa.ai E2E] Wrote ${v}`),x++,await I({projectId:o,type:"e2e",filePath:`e2e/${v}`,modelUsed:t,status:"success",details:`Generated E2E spec for route /${m}`,testFramework:d})}catch(k){console.error(`[Lisa.ai E2E] LLM failed for /${m}: ${k.message}`),await I({projectId:o,type:"e2e",filePath:`e2e/${v}`,modelUsed:t,status:"error",details:`LLM failed to generate E2E spec: ${k.message}`,testFramework:d})}}if(x===0&&$.length===0){console.log("[Lisa.ai E2E] No specs generated. Check LLM connectivity with 'lisa-agent diagnose'.");return}}console.log(`
228
- [Lisa.ai E2E] Running E2E tests: ${e}`);let h="",f="",w=!1;try{await new Promise((c,L)=>{let $=(0,gt.spawn)(e,{shell:!0,stdio:["ignore","pipe","pipe"],cwd:a});$.stdout?.on("data",m=>{let y=m.toString();h+=y,process.stdout.write(y)}),$.stderr?.on("data",m=>{let y=m.toString();f+=y,process.stderr.write(y)}),$.on("close",m=>{m===0?c():L(new Error(`E2E tests exited with code ${m}`))})}),w=!0,console.log(`
255
+ `,F=await X(`e2e/${f}`,b,t,i,p,["e2e"]);U.writeFileSync(w,F,"utf-8"),console.log(`[Lisa.ai E2E] Wrote ${f}`),$++,await N({projectId:o,type:"e2e",filePath:`e2e/${f}`,modelUsed:t,status:"success",details:`Generated E2E spec for route /${v}`,testFramework:p})}catch(b){console.error(`[Lisa.ai E2E] LLM failed for /${v}: ${b.message}`),await N({projectId:o,type:"e2e",filePath:`e2e/${f}`,modelUsed:t,status:"error",details:`LLM failed to generate E2E spec: ${b.message}`,testFramework:p})}}if($===0&&C.length===0){console.log("[Lisa.ai E2E] No specs generated. Check LLM connectivity with 'lisa-agent diagnose'.");return}}console.log(`
256
+ [Lisa.ai E2E] Running E2E tests: ${e}`);let g="",L="",m=!1;try{await new Promise((y,h)=>{let C=(0,St.spawn)(e,{shell:!0,stdio:["ignore","pipe","pipe"],cwd:a});C.stdout?.on("data",v=>{let x=v.toString();g+=x,process.stdout.write(x)}),C.stderr?.on("data",v=>{let x=v.toString();L+=x,process.stderr.write(x)}),C.on("close",v=>{v===0?y():h(new Error(`E2E tests exited with code ${v}`))})}),m=!0,console.log(`
229
257
  [Lisa.ai E2E] All E2E tests passed.`)}catch{console.log(`
230
- [Lisa.ai E2E] Some E2E tests failed. Run 'lisa-agent heal --type e2e' to auto-fix.`)}let l=h+`
231
- `+f,u=Y(l);await I({projectId:o,type:"e2e",filePath:"e2e-suite",modelUsed:t,status:w?"success":"error",details:`E2E generation complete. ${x} new spec(s) generated.`,...u&&{testTotal:u.total,testPassed:u.passed,testFailed:u.failed},testFramework:d})}var mt=require("child_process"),A=b(require("fs")),F=b(require("path"));function Gt(e){let t=F.join(e,"package.json");if(!A.existsSync(t))return"node";let s=JSON.parse(A.readFileSync(t,"utf-8")),n={...s.dependencies||{},...s.devDependencies||{}};return n["@angular/core"]?"angular":n.react?"react":n.vue?"vue":n["@nestjs/core"]?"nestjs":n.express?"express":"node"}function Ht(e,t){let s=[];if(t==="angular"){let n=F.join(e,"src","app");if(!A.existsSync(n))return s;let o=me(n,/\.(ts)$/).filter(i=>!i.includes(".spec.")&&!i.includes(".test.")&&!i.includes("node_modules"));for(let i of o){let r=A.readFileSync(i,"utf-8");if(r.includes("@Component")&&r.includes("inject(")){let a=F.relative(e,i),p=a.replace(/\.ts$/,".integration.spec.ts");if(A.existsSync(F.join(e,p)))continue;let d=[...r.matchAll(/inject\((\w+)\)/g)].map(h=>h[1]),x=[];for(let h of d){let f=me(n,new RegExp(`${qt(h)}\\.ts$`));x.push(...f.map(w=>F.relative(e,w)))}s.push({filePath:a,relatedFiles:x,description:`Angular component+service integration: ${F.basename(i)} injects ${d.join(", ")}`})}}}else if(t==="express"||t==="nestjs"){let n=["src","server","api","routes","controllers"];for(let o of n){let i=F.join(e,o);if(!A.existsSync(i))continue;let r=me(i,/\.(controller|route|router)\.(ts|js)$/).filter(a=>!a.includes(".spec.")&&!a.includes(".test.")&&!a.includes("node_modules"));for(let a of r){let p=F.relative(e,a),g=p.replace(/\.(ts|js)$/,".integration.spec.$1");A.existsSync(F.join(e,g))||s.push({filePath:p,relatedFiles:[],description:`API endpoint integration test for ${F.basename(a)} \u2014 test with supertest against real middleware chain`})}}}else{let n=F.join(e,"src");if(A.existsSync(n)){let o=me(n,/\.(ts|js|tsx|jsx)$/).filter(i=>!i.includes(".spec.")&&!i.includes(".test.")&&!i.includes("node_modules"));for(let i of o){let a=[...A.readFileSync(i,"utf-8").matchAll(/from\s+['"]\.\.?\//g)];if(a.length>=2){let p=F.relative(e,i),g=p.replace(/\.(ts|js|tsx|jsx)$/,".integration.spec.$1");if(A.existsSync(F.join(e,g)))continue;s.push({filePath:p,relatedFiles:[],description:`Module integration: ${F.basename(i)} imports ${a.length} local modules`})}}}}return s}function me(e,t){let s=[],n=["node_modules","dist","build",".git",".angular","coverage"];if(!A.existsSync(e))return s;let o=A.readdirSync(e);for(let i of o){if(n.includes(i))continue;let r=F.join(e,i);try{A.statSync(r).isDirectory()?s.push(...me(r,t)):t.test(i)&&s.push(r)}catch{continue}}return s}function qt(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}async function ht(e,t,s=1,n=3,o="local",i,r){if(s>n){console.log(`
232
- [Lisa.ai Integration] Reached maximum retries (${n}). Stopping.`);return}let a=process.cwd(),p=P.load(a);p&&(P.applyEnvDefaults(p),!e&&p.testCommand&&(e=p.testCommand,console.log(`[Lisa.ai Config] Using testCommand from .lisai.json: ${e}`)));let g=Gt(a),d=V.scanRepository(),x=p?.testingFramework||(d.testingFramework!=="none"?d.testingFramework:void 0);console.log(`
233
- [Lisa.ai Integration] App: ${g}, Framework: ${x||"auto"} (Attempt ${s}/${n}) Model: ${t}`),e||(d.suggestedTestCommand?e=d.suggestedTestCommand:A.existsSync(F.join(a,"angular.json"))?e="npx ng test --no-watch --browsers=ChromeHeadless":(console.error(`
234
- [Lisa.ai Fatal Error] Could not auto-detect a test command. Please pass --command explicitly.`),process.exit(1)),console.log(`[Lisa.ai Integration] Auto-detected command: ${e}`));let h=le(e);await I({projectId:o,type:"integration",filePath:"integration-suite",modelUsed:t,status:"running",details:`Integration test generation started for ${g} app`,testFramework:h});let f;if(r&&r.length>0)f=r.map(m=>({filePath:m,relatedFiles:[],description:"User-specified"})),console.log(`
235
- [Lisa.ai Integration] Targeting ${r.length} file(s) from --files`),f.forEach(m=>console.log(` - ${m.filePath}`));else{if(f=Ht(a,g),f.length===0){console.log("[Lisa.ai Integration] No integration targets discovered. The project may already have full integration coverage.");return}console.log(`[Lisa.ai Integration] Found ${f.length} integration target(s):`),f.forEach(m=>console.log(` - ${m.filePath}: ${m.description}`))}let w=0;for(let m of f){let y=F.resolve(a,m.filePath);if(!A.existsSync(y))continue;let v=F.parse(y),C=F.join(v.dir,`${v.name}.integration.spec${v.ext}`);if(A.existsSync(C)){console.log(`[Lisa.ai Integration] Spec exists for ${m.filePath} \u2014 skipping.`);continue}console.log(`[Lisa.ai Integration] Generating integration spec for ${m.filePath}...`);let k=A.readFileSync(y,"utf-8"),E="";for(let M of m.relatedFiles.slice(0,3)){let j=F.resolve(a,M);if(A.existsSync(j)){let U=A.readFileSync(j,"utf-8");E+=`
258
+ [Lisa.ai E2E] Some E2E tests failed. Run 'lisa-agent heal --type e2e' to auto-fix.`)}let d=g+`
259
+ `+L,l=G(d);await N({projectId:o,type:"e2e",filePath:"e2e-suite",modelUsed:t,status:m?"success":"error",details:`E2E generation complete. ${$} new spec(s) generated.`,...l&&{testTotal:l.total,testPassed:l.passed,testFailed:l.failed},testFramework:p})}var jt=require("child_process"),I=S(require("fs")),T=S(require("path"));function is(e){let t=T.join(e,"package.json");if(!I.existsSync(t))return"node";let s=JSON.parse(I.readFileSync(t,"utf-8")),n={...s.dependencies||{},...s.devDependencies||{}};return n["@angular/core"]?"angular":n.react?"react":n.vue?"vue":n["@nestjs/core"]?"nestjs":n.express?"express":"node"}function as(e,t){let s=[];if(t==="angular"){let n=T.join(e,"src","app");if(!I.existsSync(n))return s;let o=be(n,/\.(ts)$/).filter(i=>!i.includes(".spec.")&&!i.includes(".test.")&&!i.includes("node_modules"));for(let i of o){let r=I.readFileSync(i,"utf-8");if(r.includes("@Component")&&r.includes("inject(")){let a=T.relative(e,i),c=a.replace(/\.ts$/,".integration.spec.ts");if(I.existsSync(T.join(e,c)))continue;let p=[...r.matchAll(/inject\((\w+)\)/g)].map(g=>g[1]),$=[];for(let g of p){let L=be(n,new RegExp(`${rs(g)}\\.ts$`));$.push(...L.map(m=>T.relative(e,m)))}s.push({filePath:a,relatedFiles:$,description:`Angular component+service integration: ${T.basename(i)} injects ${p.join(", ")}`})}}}else if(t==="express"||t==="nestjs"){let n=["src","server","api","routes","controllers"];for(let o of n){let i=T.join(e,o);if(!I.existsSync(i))continue;let r=be(i,/\.(controller|route|router)\.(ts|js)$/).filter(a=>!a.includes(".spec.")&&!a.includes(".test.")&&!a.includes("node_modules"));for(let a of r){let c=T.relative(e,a),u=c.replace(/\.(ts|js)$/,".integration.spec.$1");I.existsSync(T.join(e,u))||s.push({filePath:c,relatedFiles:[],description:`API endpoint integration test for ${T.basename(a)} \u2014 test with supertest against real middleware chain`})}}}else{let n=T.join(e,"src");if(I.existsSync(n)){let o=be(n,/\.(ts|js|tsx|jsx)$/).filter(i=>!i.includes(".spec.")&&!i.includes(".test.")&&!i.includes("node_modules"));for(let i of o){let a=[...I.readFileSync(i,"utf-8").matchAll(/from\s+['"]\.\.?\//g)];if(a.length>=2){let c=T.relative(e,i),u=c.replace(/\.(ts|js|tsx|jsx)$/,".integration.spec.$1");if(I.existsSync(T.join(e,u)))continue;s.push({filePath:c,relatedFiles:[],description:`Module integration: ${T.basename(i)} imports ${a.length} local modules`})}}}}return s}function be(e,t){let s=[],n=["node_modules","dist","build",".git",".angular","coverage"];if(!I.existsSync(e))return s;let o=I.readdirSync(e);for(let i of o){if(n.includes(i))continue;let r=T.join(e,i);try{I.statSync(r).isDirectory()?s.push(...be(r,t)):t.test(i)&&s.push(r)}catch{continue}}return s}function rs(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}async function Et(e,t,s=1,n=3,o="local",i,r){if(s>n){console.log(`
260
+ [Lisa.ai Integration] Reached maximum retries (${n}). Stopping.`);return}let a=process.cwd(),c=R.load(a);c&&(R.applyEnvDefaults(c),!e&&c.testCommand&&(e=c.testCommand,console.log(`[Lisa.ai Config] Using testCommand from .lisai.json: ${e}`)));let u=is(a),p=K.scanRepository(),$=c?.testingFramework||(p.testingFramework!=="none"?p.testingFramework:void 0);console.log(`
261
+ [Lisa.ai Integration] App: ${u}, Framework: ${$||"auto"} (Attempt ${s}/${n}) Model: ${t}`),e||(p.suggestedTestCommand?e=p.suggestedTestCommand:I.existsSync(T.join(a,"angular.json"))?e="npx ng test --no-watch --browsers=ChromeHeadless":(console.error(`
262
+ [Lisa.ai Fatal Error] Could not auto-detect a test command. Please pass --command explicitly.`),process.exit(1)),console.log(`[Lisa.ai Integration] Auto-detected command: ${e}`));let g=se(e);await N({projectId:o,type:"integration",filePath:"integration-suite",modelUsed:t,status:"running",details:`Integration test generation started for ${u} app`,testFramework:g});let L;if(r&&r.length>0)L=r.map(v=>({filePath:v,relatedFiles:[],description:"User-specified"})),console.log(`
263
+ [Lisa.ai Integration] Targeting ${r.length} file(s) from --files`),L.forEach(v=>console.log(` - ${v.filePath}`));else{if(L=as(a,u),L.length===0){console.log("[Lisa.ai Integration] No integration targets discovered. The project may already have full integration coverage.");return}console.log(`[Lisa.ai Integration] Found ${L.length} integration target(s):`),L.forEach(v=>console.log(` - ${v.filePath}: ${v.description}`))}let m=0;for(let v of L){let x=T.resolve(a,v.filePath);if(!I.existsSync(x))continue;let f=T.parse(x),w=T.join(f.dir,`${f.name}.integration.spec${f.ext}`);if(I.existsSync(w)){console.log(`[Lisa.ai Integration] Spec exists for ${v.filePath} \u2014 skipping.`);continue}console.log(`[Lisa.ai Integration] Generating integration spec for ${v.filePath}...`);let b=I.readFileSync(x,"utf-8"),F="";for(let P of v.relatedFiles.slice(0,3)){let k=T.resolve(a,P);if(I.existsSync(k)){let H=I.readFileSync(k,"utf-8");F+=`
236
264
 
237
- // --- Related file: ${M} ---
238
- ${U.slice(0,5e3)}`}}let G=`
239
- INTEGRATION TEST \u2014 ${m.description}
265
+ // --- Related file: ${P} ---
266
+ ${H.slice(0,5e3)}`}}let E=`
267
+ INTEGRATION TEST \u2014 ${v.description}
240
268
 
241
269
  Generate an integration test that exercises real module interactions (NOT mocked).
242
- ${g==="angular"?`
270
+ ${u==="angular"?`
243
271
  - Use TestBed with real service providers (not jasmine.createSpyObj)
244
272
  - Import the actual component and its real dependencies
245
273
  - Test that the component and service work together correctly
246
274
  - Use HttpClientTestingModule for HTTP calls
247
- `:g==="express"||g==="nestjs"?`
275
+ `:u==="express"||u==="nestjs"?`
248
276
  - Use supertest to make real HTTP requests against the app
249
277
  - Test the full middleware chain (auth, validation, handler)
250
278
  - Use a test database or in-memory mock for data layer
@@ -255,32 +283,32 @@ ${g==="angular"?`
255
283
  `}
256
284
 
257
285
  Source file:
258
- ${k.slice(0,1e4)}
286
+ ${b.slice(0,1e4)}
259
287
 
260
- ${E?`Related modules:
261
- ${E}`:""}
262
- `;try{let M=await ee(m.filePath,G,t,i,x,["integration"]);A.writeFileSync(C,M,"utf-8"),console.log(`[Lisa.ai Integration] Wrote ${F.relative(a,C)}`),w++,await I({projectId:o,type:"integration",filePath:m.filePath,modelUsed:t,status:"success",details:`Generated integration spec: ${m.description}`,testFramework:h})}catch(M){console.error(`[Lisa.ai Integration] LLM failed for ${m.filePath}: ${M.message}`)}}if(w===0){console.log("[Lisa.ai Integration] No new integration specs generated.");return}console.log(`
263
- [Lisa.ai Integration] Running tests to verify generated specs: ${e}`);let l="",u="",c=!1;try{await new Promise((m,y)=>{let v=(0,mt.spawn)(e,{shell:!0,stdio:["ignore","pipe","pipe"],cwd:a});v.stdout?.on("data",C=>{let k=C.toString();l+=k,process.stdout.write(k)}),v.stderr?.on("data",C=>{let k=C.toString();u+=k,process.stderr.write(k)}),v.on("close",C=>{C===0?m():y(new Error(`Tests exited with code ${C}`))})}),c=!0,console.log(`
288
+ ${F?`Related modules:
289
+ ${F}`:""}
290
+ `;try{let P=await X(v.filePath,E,t,i,$,["integration"]);I.writeFileSync(w,P,"utf-8"),console.log(`[Lisa.ai Integration] Wrote ${T.relative(a,w)}`),m++,await N({projectId:o,type:"integration",filePath:v.filePath,modelUsed:t,status:"success",details:`Generated integration spec: ${v.description}`,testFramework:g})}catch(P){console.error(`[Lisa.ai Integration] LLM failed for ${v.filePath}: ${P.message}`)}}if(m===0){console.log("[Lisa.ai Integration] No new integration specs generated.");return}console.log(`
291
+ [Lisa.ai Integration] Running tests to verify generated specs: ${e}`);let d="",l="",y=!1;try{await new Promise((v,x)=>{let f=(0,jt.spawn)(e,{shell:!0,stdio:["ignore","pipe","pipe"],cwd:a});f.stdout?.on("data",w=>{let b=w.toString();d+=b,process.stdout.write(b)}),f.stderr?.on("data",w=>{let b=w.toString();l+=b,process.stderr.write(b)}),f.on("close",w=>{w===0?v():x(new Error(`Tests exited with code ${w}`))})}),y=!0,console.log(`
264
292
  [Lisa.ai Integration] All tests passed including integration specs.`)}catch{console.log(`
265
- [Lisa.ai Integration] Some tests failed. Run 'lisa-agent heal --type integration' to auto-fix.`)}let L=l+`
266
- `+u,$=Y(L);await I({projectId:o,type:"integration",filePath:"integration-suite",modelUsed:t,status:c?"success":"error",details:`Integration test generation complete. ${w} new spec(s) generated.`,...$&&{testTotal:$.total,testPassed:$.passed,testFailed:$.failed},testFramework:h})}var vt=b(require("dotenv")),xt=require("child_process"),Q=b(require("fs")),J=b(require("path"));vt.config({quiet:!0});function de(e){return new Promise(t=>{let s=(0,xt.spawn)(e,{shell:!0,stdio:["ignore","pipe","pipe"]}),n="",o="";s.stdout?.on("data",i=>{n+=i.toString()}),s.stderr?.on("data",i=>{o+=i.toString()}),s.on("close",i=>t({stdout:n,stderr:o,code:i??1}))})}function Bt(){return Q.existsSync(J.resolve(process.cwd(),"pnpm-lock.yaml"))?"pnpm":Q.existsSync(J.resolve(process.cwd(),"yarn.lock"))?"yarn":"npm"}var Yt={critical:"\u{1F534}",high:"\u{1F7E0}",moderate:"\u{1F7E1}",low:"\u{1F535}",info:"\u26AA"},yt={critical:5,high:4,moderate:3,low:2,info:1};function wt(e){let t=["critical","high","moderate","low","info"];for(let s of t){let n=e[s]??0;n>0&&console.log(` ${Yt[s]} ${s.padEnd(10)} ${n}`)}console.log(` ${"\u2500".repeat(22)}`),console.log(` ${"Total".padEnd(10)} ${e.total}`)}async function Ue(e){try{return JSON.parse(e)}catch{return null}}async function $t(e,t="local",s){Q.existsSync(J.resolve(process.cwd(),"package.json"))||(console.error(`
267
- \u{1F6A8} [Lisa.ai Audit] No package.json found in ${process.cwd()}.`),console.error(" The audit command currently supports Node.js / npm projects only."),process.exit(1));let n=Bt();console.log(`[Lisa.ai Audit] Package manager: ${n}`),console.log(`
268
- [Lisa.ai Audit] Scanning for vulnerabilities...`);let{stdout:o,code:i}=await de(n==="npm"?"npm audit --json":n==="yarn"?"yarn audit --json":"pnpm audit --json");if(i===0){console.log(`
269
- \u2705 [Lisa.ai Audit] No vulnerabilities found! Repository is clean.`);return}let r=await Ue(o);r||(console.error("[Lisa.ai Audit] Could not parse audit output. Run 'npm audit' manually to investigate."),process.exit(1));let a=r.metadata.vulnerabilities;console.log(`
270
- Vulnerabilities found:`),wt(a),console.log(`
271
- [Lisa.ai Audit] Applying safe automatic fixes (npm audit fix)...`);let{stdout:p}=await de(n==="npm"?"npm audit fix":n==="yarn"?"yarn upgrade":"pnpm audit fix");for(let j of p.split(`
272
- `)){let U=j.trim();U&&!U.startsWith("npm warn")&&!U.startsWith("npm notice")&&console.log(` ${U}`)}let g=n==="npm"?"npm audit --json":n==="yarn"?"yarn audit --json":"pnpm audit --json",{stdout:d,code:x}=await de(g);if(x===0){console.log(`
273
- \u2705 [Lisa.ai Audit] All vulnerabilities fixed by safe auto-fix!`);return}let h=await Ue(d);if(!h){console.warn("[Lisa.ai Audit] Could not parse post-fix audit output.");return}let f=Object.values(h.vulnerabilities),w=h.metadata.vulnerabilities,l=a.total-w.total;console.log(`
274
- [Lisa.ai Audit] Safe auto-fix resolved ${l} vulnerability(-ies).`),w.total>0&&(console.log(" Remaining:"),wt(w));let u=f.filter(j=>typeof j.fixAvailable=="object"&&!j.fixAvailable.isSemVerMajor).map(j=>j.fixAvailable),c=[...new Map(u.map(j=>[j.name,j])).values()];if(c.length>0){console.log(`
275
- [Lisa.ai Audit] Applying ${c.length} non-breaking targeted upgrade(s)...`);for(let oe of c){let B=`npm install ${oe.name}@${oe.version}`;console.log(` \u2192 ${B}`);let{stderr:ue}=await de(B);ue&&!ue.includes("npm warn")&&console.warn(` ${ue.trim()}`)}let{stdout:j,code:U}=await de(g);if(U===0){console.log(`
276
- \u2705 [Lisa.ai Audit] All vulnerabilities resolved!`);return}}let{stdout:L}=await de(g),$=await Ue(L)??h,y=Object.values($.vulnerabilities).sort((j,U)=>(yt[U.severity]??0)-(yt[j.severity]??0)).slice(0,10).filter(j=>j.fixAvailable===!1?!0:typeof j.fixAvailable=="object"?j.fixAvailable.isSemVerMajor:!1);if(y.length===0){console.log(`
293
+ [Lisa.ai Integration] Some tests failed. Run 'lisa-agent heal --type integration' to auto-fix.`)}let h=d+`
294
+ `+l,C=G(h);await N({projectId:o,type:"integration",filePath:"integration-suite",modelUsed:t,status:y?"success":"error",details:`Integration test generation complete. ${m} new spec(s) generated.`,...C&&{testTotal:C.total,testPassed:C.passed,testFailed:C.failed},testFramework:g})}var Pt=S(require("dotenv")),It=require("child_process"),ie=S(require("fs")),oe=S(require("path"));Pt.config({quiet:!0});function we(e){return new Promise(t=>{let s=(0,It.spawn)(e,{shell:!0,stdio:["ignore","pipe","pipe"]}),n="",o="";s.stdout?.on("data",i=>{n+=i.toString()}),s.stderr?.on("data",i=>{o+=i.toString()}),s.on("close",i=>t({stdout:n,stderr:o,code:i??1}))})}function ls(){return ie.existsSync(oe.resolve(process.cwd(),"pnpm-lock.yaml"))?"pnpm":ie.existsSync(oe.resolve(process.cwd(),"yarn.lock"))?"yarn":"npm"}var cs={critical:"\u{1F534}",high:"\u{1F7E0}",moderate:"\u{1F7E1}",low:"\u{1F535}",info:"\u26AA"},At={critical:5,high:4,moderate:3,low:2,info:1};function Tt(e){let t=["critical","high","moderate","low","info"];for(let s of t){let n=e[s]??0;n>0&&console.log(` ${cs[s]} ${s.padEnd(10)} ${n}`)}console.log(` ${"\u2500".repeat(22)}`),console.log(` ${"Total".padEnd(10)} ${e.total}`)}async function et(e){try{return JSON.parse(e)}catch{return null}}async function Rt(e,t="local",s){ie.existsSync(oe.resolve(process.cwd(),"package.json"))||(console.error(`
295
+ \u{1F6A8} [Lisa.ai Audit] No package.json found in ${process.cwd()}.`),console.error(" The audit command currently supports Node.js / npm projects only."),process.exit(1));let n=ls();console.log(`[Lisa.ai Audit] Package manager: ${n}`),console.log(`
296
+ [Lisa.ai Audit] Scanning for vulnerabilities...`);let{stdout:o,code:i}=await we(n==="npm"?"npm audit --json":n==="yarn"?"yarn audit --json":"pnpm audit --json");if(i===0){console.log(`
297
+ \u2705 [Lisa.ai Audit] No vulnerabilities found! Repository is clean.`);return}let r=await et(o);r||(console.error("[Lisa.ai Audit] Could not parse audit output. Run 'npm audit' manually to investigate."),process.exit(1));let a=r.metadata.vulnerabilities;console.log(`
298
+ Vulnerabilities found:`),Tt(a),console.log(`
299
+ [Lisa.ai Audit] Applying safe automatic fixes (npm audit fix)...`);let{stdout:c}=await we(n==="npm"?"npm audit fix":n==="yarn"?"yarn upgrade":"pnpm audit fix");for(let k of c.split(`
300
+ `)){let H=k.trim();H&&!H.startsWith("npm warn")&&!H.startsWith("npm notice")&&console.log(` ${H}`)}let u=n==="npm"?"npm audit --json":n==="yarn"?"yarn audit --json":"pnpm audit --json",{stdout:p,code:$}=await we(u);if($===0){console.log(`
301
+ \u2705 [Lisa.ai Audit] All vulnerabilities fixed by safe auto-fix!`);return}let g=await et(p);if(!g){console.warn("[Lisa.ai Audit] Could not parse post-fix audit output.");return}let L=Object.values(g.vulnerabilities),m=g.metadata.vulnerabilities,d=a.total-m.total;console.log(`
302
+ [Lisa.ai Audit] Safe auto-fix resolved ${d} vulnerability(-ies).`),m.total>0&&(console.log(" Remaining:"),Tt(m));let l=L.filter(k=>typeof k.fixAvailable=="object"&&!k.fixAvailable.isSemVerMajor).map(k=>k.fixAvailable),y=[...new Map(l.map(k=>[k.name,k])).values()];if(y.length>0){console.log(`
303
+ [Lisa.ai Audit] Applying ${y.length} non-breaking targeted upgrade(s)...`);for(let ue of y){let z=`npm install ${ue.name}@${ue.version}`;console.log(` \u2192 ${z}`);let{stderr:ve}=await we(z);ve&&!ve.includes("npm warn")&&console.warn(` ${ve.trim()}`)}let{stdout:k,code:H}=await we(u);if(H===0){console.log(`
304
+ \u2705 [Lisa.ai Audit] All vulnerabilities resolved!`);return}}let{stdout:h}=await we(u),C=await et(h)??g,x=Object.values(C.vulnerabilities).sort((k,H)=>(At[H.severity]??0)-(At[k.severity]??0)).slice(0,10).filter(k=>k.fixAvailable===!1?!0:typeof k.fixAvailable=="object"?k.fixAvailable.isSemVerMajor:!1);if(x.length===0){console.log(`
277
305
  \u2705 [Lisa.ai Audit] No breaking-change or unfixable vulnerabilities remain.`);return}console.log(`
278
- [Lisa.ai Audit] ${y.length} vulnerability(-ies) require manual attention.`),console.log(`[Lisa.ai Audit] Consulting ${e} for remediation guidance...`);let v={};try{v=JSON.parse(Q.readFileSync(J.resolve(process.cwd(),"package.json"),"utf8"))}catch{}let C={...v.dependencies??{},...v.devDependencies??{}},k=y.map(j=>{let U=j.fixAvailable,oe=U===!1?"no fix available yet":`upgrade to ${U.name}@${U.version} (BREAKING \u2014 major version bump)`,B=C[j.name]?`current: ${C[j.name]}`:"transitive dependency";return`\u2022 ${j.name} (${j.severity}) \u2014 ${B} \u2014 ${oe}`}).join(`
279
- `),E=`You are a Node.js security expert helping a developer fix npm vulnerabilities.
306
+ [Lisa.ai Audit] ${x.length} vulnerability(-ies) require manual attention.`),console.log(`[Lisa.ai Audit] Consulting ${e} for remediation guidance...`);let f={};try{f=JSON.parse(ie.readFileSync(oe.resolve(process.cwd(),"package.json"),"utf8"))}catch{}let w={...f.dependencies??{},...f.devDependencies??{}},b=x.map(k=>{let H=k.fixAvailable,ue=H===!1?"no fix available yet":`upgrade to ${H.name}@${H.version} (BREAKING \u2014 major version bump)`,z=w[k.name]?`current: ${w[k.name]}`:"transitive dependency";return`\u2022 ${k.name} (${k.severity}) \u2014 ${z} \u2014 ${ue}`}).join(`
307
+ `),F=`You are a Node.js security expert helping a developer fix npm vulnerabilities.
280
308
 
281
309
  These vulnerabilities remain after safe auto-fixes were applied. Each requires either a breaking upgrade or has no automated fix:
282
310
 
283
- ${k}
311
+ ${b}
284
312
 
285
313
  For each vulnerability:
286
314
  1. Briefly explain the security risk (1 sentence).
@@ -288,35 +316,135 @@ For each vulnerability:
288
316
  3. If the upgrade is breaking (major version), note the most likely code change needed (e.g. renamed API, changed import path).
289
317
  4. If no fix exists, suggest a workaround or safe alternative package.
290
318
 
291
- Be concrete. Use numbered items. If a vulnerability is a transitive dependency, explain how to force a resolution override in package.json.`;try{let j=await ie(E,e,s);console.log(`
319
+ Be concrete. Use numbered items. If a vulnerability is a transitive dependency, explain how to force a resolution override in package.json.`;try{let k=await ge(F,e,s);console.log(`
292
320
  Remediation guidance:
293
- `);for(let B of j.split(`
294
- `))console.log(` ${B}`);let U=J.resolve(process.cwd(),"lisa-audit-report.md"),oe=["# Lisa.ai Security Audit Report","",`Generated: ${new Date().toISOString()}`,`Project: ${v.name??J.basename(process.cwd())}`,"","## Summary","","| Severity | Initial | Remaining |","|----------|---------|-----------|",...["critical","high","moderate","low"].map(B=>{let ue=a[B]??0,bt=$.metadata.vulnerabilities[B]??0;return`| ${B} | ${ue} | ${bt} |`}),"","## Vulnerabilities Requiring Manual Action","",k,"",`## Remediation Guidance (${e})`,"",j].join(`
295
- `);Q.writeFileSync(U,oe,"utf-8"),console.log(`
296
- [Lisa.ai Audit] Full report saved to: lisa-audit-report.md`)}catch(j){console.error(`
297
- [Lisa.ai Audit] LLM guidance failed: ${j.message}`),console.log(" Run 'npm audit' manually and address the remaining vulnerabilities.")}let G=$.metadata.vulnerabilities,M=a.total-G.total;console.log(`
298
- ${"\u2500".repeat(50)}`),console.log(" Lisa.ai Audit Complete"),console.log(` \u2705 Fixed: ${M} / ${a.total}`),console.log(` \u26A0\uFE0F Remaining: ${G.total} (see lisa-audit-report.md)`),console.log(`${"\u2500".repeat(50)}
299
- `)}var St=Lt();function ne(){let e=St.version;console.log(`
321
+ `);for(let z of k.split(`
322
+ `))console.log(` ${z}`);let H=oe.resolve(process.cwd(),"lisa-audit-report.md"),ue=["# Lisa.ai Security Audit Report","",`Generated: ${new Date().toISOString()}`,`Project: ${f.name??oe.basename(process.cwd())}`,"","## Summary","","| Severity | Initial | Remaining |","|----------|---------|-----------|",...["critical","high","moderate","low"].map(z=>{let ve=a[z]??0,Kt=C.metadata.vulnerabilities[z]??0;return`| ${z} | ${ve} | ${Kt} |`}),"","## Vulnerabilities Requiring Manual Action","",b,"",`## Remediation Guidance (${e})`,"",k].join(`
323
+ `);ie.writeFileSync(H,ue,"utf-8"),console.log(`
324
+ [Lisa.ai Audit] Full report saved to: lisa-audit-report.md`)}catch(k){console.error(`
325
+ [Lisa.ai Audit] LLM guidance failed: ${k.message}`),console.log(" Run 'npm audit' manually and address the remaining vulnerabilities.")}let E=C.metadata.vulnerabilities,P=a.total-E.total;console.log(`
326
+ ${"\u2500".repeat(50)}`),console.log(" Lisa.ai Audit Complete"),console.log(` \u2705 Fixed: ${P} / ${a.total}`),console.log(` \u26A0\uFE0F Remaining: ${E.total} (see lisa-audit-report.md)`),console.log(`${"\u2500".repeat(50)}
327
+ `)}var Ut=S(require("readline")),Q=S(require("fs")),ae=S(require("path")),Dt=require("ai");var Mt=40,Nt=8e3,M="\x1B[38;2;99;102;241m",A="\x1B[0m",He="\x1B[2m",Ot="\x1B[1m";function ds(){let e="unknown";try{e=JSON.parse(Q.readFileSync(ae.resolve(process.cwd(),"package.json"),"utf-8")).name||"unknown"}catch{}let t={type:"unknown",testingFramework:"none"};try{t=K.scanRepository()}catch{}let s=R.get();return{packageName:e,frameworkType:t.type,testingFramework:s?.testingFramework||t.testingFramework,testCommand:s?.testCommand||t.suggestedTestCommand||null,e2eFramework:s?.e2eFramework||null,hasLisaiConfig:!!s}}function us(e){return`You are Lisa.ai, an autonomous CI/CD expert focused on test healing and generation.
328
+ You are chatting with a developer about their project in an interactive terminal session.
329
+
330
+ Project: ${e.packageName}
331
+ Framework: ${e.frameworkType}
332
+ Testing framework: ${e.testingFramework}
333
+ Test command: ${e.testCommand||"auto-detected"}
334
+
335
+ Guidelines:
336
+ - Be concise and code-focused.
337
+ - Use markdown code blocks for code snippets.
338
+ - When asked about test failures, analyze the root cause carefully.
339
+ - Do not generate full test files unless explicitly asked \u2014 prefer explaining the approach.
340
+ - If the user shares test output, analyze it and suggest specific fixes.
341
+ - The user can use slash commands (/heal, /test, /explain, /generate, /status, /help, /exit) \u2014 you don't need to explain them unless asked.`}function ps(){console.log(`
342
+ ${Ot}Available commands:${A}
343
+
344
+ ${M}/test${A} [cmd] Run tests and show results
345
+ ${M}/explain${A} <file> Analyze why a test is failing (no file changes)
346
+ ${M}/heal${A} <file> Auto-heal a specific failing test file
347
+ ${M}/generate${A} <file> Generate test spec for a source file
348
+ ${M}/status${A} Show test pass/fail summary
349
+ ${M}/help${A} Show this help
350
+ ${M}/exit${A} Exit chat
351
+
352
+ Or just type a question to chat with Lisa.ai.
353
+ `)}async function gs(e,t){let s=t.trim()||e.projectContext.testCommand;if(!s){console.log(`
354
+ ${M}Error:${A} No test command found. Use /test <command> or set testCommand in .lisai.json
355
+ `);return}console.log(`
356
+ Running: ${He}${s}${A}
357
+ `);try{let{stdout:n,stderr:o}=await ne(s,!0);process.stdout.write(`
358
+ `);let i=o+`
359
+ `+n,r=G(i);console.log(r?`
360
+ \u2705 ${r.passed} passed ${r.failed} failed ${r.total} total
361
+ `:`
362
+ \u2705 Tests passed.
363
+ `),e.lastTestOutput=i.slice(0,Nt),e.messages.push({role:"user",content:`[Test Output \u2014 all passing]
364
+ ${e.lastTestOutput}`})}catch(n){process.stdout.write(`
365
+ `);let o=(n.stderr||"")+`
366
+ `+(n.stdout||"")+`
367
+ `+(n.message||""),i=G(o);console.log(i?`
368
+ \u2717 ${i.passed} passed ${i.failed} failed ${i.total} total
369
+ `:`
370
+ \u2717 Tests failed.
371
+ `),e.lastTestOutput=o.slice(0,Nt),e.messages.push({role:"user",content:`[Test Output \u2014 failures detected]
372
+ ${e.lastTestOutput}`})}}async function fs(e,t){let s=t.trim();if(!s){console.log(`
373
+ ${M}Usage:${A} /explain <file-path>
374
+ `);return}let n=ae.resolve(process.cwd(),s);if(!Q.existsSync(n)){console.log(`
375
+ ${M}Error:${A} File not found: ${s}
376
+ `);return}let o=Q.readFileSync(n,"utf-8"),i=o.length>1e4?o.slice(0,1e4)+`
377
+ // ... (truncated)`:o,r=`The user wants you to analyze why a test file is failing. Do NOT generate a fix \u2014 just explain the root cause.
378
+
379
+ --- File: ${s} ---
380
+ ${i}`;e.lastTestOutput&&(r+=`
381
+
382
+ --- Recent Test Output ---
383
+ ${e.lastTestOutput.slice(0,4e3)}`),e.messages.push({role:"user",content:r}),console.log(),await _t(e)}async function ms(e,t){let s=t.trim();if(!s){console.log(`
384
+ ${M}Usage:${A} /heal <file-path>
385
+ `);return}let n=ae.resolve(process.cwd(),s);if(!Q.existsSync(n)){console.log(`
386
+ ${M}Error:${A} File not found: ${s}
387
+ `);return}let o=e.projectContext.testCommand;if(!o){console.log(`
388
+ ${M}Error:${A} No test command found. Set testCommand in .lisai.json
389
+ `);return}let i=se(o),r=Je(o,s),a="";try{await ne(r,!1),console.log(`
390
+ \u2705 ${s} is already passing. Nothing to heal.
391
+ `),e.messages.push({role:"user",content:`[Heal Result] ${s} \u2014 already passing, no changes needed.`});return}catch(u){a=(u.stderr||"")+`
392
+ `+(u.stdout||"")+`
393
+ `+(u.message||"")}console.log(`
394
+ Healing ${s}...
395
+ `);let c=await Qe(s,n,a,o,r,i,e.model,5,e.projectId,e.apiKey,e.lisaLlmConfig);if(c.status==="healed"){let u=c.resolvedBy==="lisa-llm"?"Lisa LLM":"Cloud";console.log(`
396
+ \u2705 Healed via ${u}.
397
+ `),e.messages.push({role:"user",content:`[Heal Result] ${s} \u2014 healed successfully via ${u} (${c.resolvedBy}).`})}else console.log(`
398
+ \u2717 Could not heal ${s} after all retries.
399
+ `),e.messages.push({role:"user",content:`[Heal Result] ${s} \u2014 failed to heal. Quarantined.`})}async function hs(e,t){let s=t.trim();if(!s){console.log(`
400
+ ${M}Usage:${A} /generate <source-file-path>
401
+ `);return}let n=ae.resolve(process.cwd(),s);if(!Q.existsSync(n)){console.log(`
402
+ ${M}Error:${A} File not found: ${s}
403
+ `);return}let o=Q.readFileSync(n,"utf-8"),i=e.projectContext.testingFramework!=="none"?e.projectContext.testingFramework:void 0;console.log(`
404
+ Generating test for ${s}...
405
+ `);try{let r=await X(s,o,e.model,e.apiKey,i),a=ae.extname(s),c=s.replace(a,`.spec${a}`),u=ae.resolve(process.cwd(),c);Q.writeFileSync(u,r,"utf-8"),console.log(` \u2705 Generated: ${c}
406
+ `),e.messages.push({role:"user",content:`[Generate Result] Test generated for ${s} \u2192 ${c}`})}catch(r){console.log(` \u2717 Generation failed: ${r.message}
407
+ `),e.messages.push({role:"user",content:`[Generate Result] Failed to generate test for ${s}: ${r.message}`})}}async function ys(e){let t=e.projectContext.testCommand;if(!t){console.log(`
408
+ ${M}Error:${A} No test command found.
409
+ `);return}console.log(`
410
+ Running: ${He}${t}${A}`);try{let{stdout:s,stderr:n}=await ne(t,!1),o=n+`
411
+ `+s,i=G(o);if(i){let r=i.total>0?Math.round(i.passed/i.total*100):0,a="\u2588".repeat(Math.round(r/5))+"\u2591".repeat(20-Math.round(r/5));console.log(` [${a}] ${r}% \u2705 ${i.passed} passed ${i.total} total
412
+ `)}else console.log(` \u2705 All tests passing.
413
+ `)}catch(s){let n=(s.stderr||"")+`
414
+ `+(s.stdout||"")+`
415
+ `+(s.message||""),o=G(n);if(o){let i=o.total>0?Math.round(o.passed/o.total*100):0,r="\u2588".repeat(Math.round(i/5))+"\u2591".repeat(20-Math.round(i/5));console.log(` [${r}] ${i}% ${o.passed} passed ${o.failed} failed ${o.total} total
416
+ `)}else console.log(` \u2717 Tests failing.
417
+ `)}}async function _t(e){try{let t=(0,Dt.streamText)({model:pe(e.model,e.apiKey),messages:e.messages}),s="";for await(let n of t.textStream)process.stdout.write(n),s+=n;if(process.stdout.write(`
418
+
419
+ `),e.messages.push({role:"assistant",content:s}),e.messages.length>Mt){let n=e.messages[0];e.messages=[n,...e.messages.slice(-(Mt-2))]}}catch(t){let s=t.message||String(t);s.includes("API key")?console.log(`
420
+ ${M}Error:${A} Invalid or missing API key for ${e.model}. Check your env vars.
421
+ `):console.log(`
422
+ ${M}Error:${A} ${s.slice(0,200)}
423
+ `)}}async function ws(e){let t=Ut.createInterface({input:process.stdin,output:process.stdout,prompt:`${M}lisa>${A} `});t.prompt(),t.on("line",async s=>{let n=s.trim();if(!n){t.prompt();return}if(t.pause(),n.startsWith("/")){let o=n.indexOf(" "),i=o>0?n.slice(0,o).toLowerCase():n.toLowerCase(),r=o>0?n.slice(o+1):"";switch(i){case"/exit":case"/quit":console.log(`
424
+ ${He}Goodbye!${A}
425
+ `),t.close();return;case"/help":ps();break;case"/test":await gs(e,r);break;case"/explain":await fs(e,r);break;case"/heal":await ms(e,r);break;case"/generate":await hs(e,r);break;case"/status":await ys(e);break;default:console.log(`
426
+ Unknown command: ${i}. Type /help for available commands.
427
+ `)}}else e.messages.push({role:"user",content:n}),console.log(),await _t(e);t.resume(),t.prompt()}),t.on("close",()=>{process.exit(0)})}async function Ht(e,t,s,n){let o=ds(),r={messages:[{role:"system",content:us(o)}],model:e,apiKey:s,projectId:t,projectContext:o,lisaLlmConfig:n},a=o;console.log(` ${M}\u2554\u2550\u2557${A} ${Ot}Interactive Mode${A}`),console.log(` ${M}\u2551${A}${M}\u26A1${M}\u2551${A} Type /help for commands, /exit to quit`),console.log(` ${M}\u255A\u2550\u255D${A} ${He}Project: ${a.packageName} | Framework: ${a.testingFramework} | Model: ${e}${A}`),console.log(),await ws(r)}var Yt=Gt();function le(){let e=Yt.version;console.log(`
300
428
  \x1B[38;2;99;102;241m\u2554\u2550\u2557\x1B[0m \x1B[1mLisa.ai Agent\x1B[0m v${e}
301
429
  \x1B[38;2;99;102;241m\u2551\x1B[38;2;129;140;248m\u26A1\x1B[38;2;99;102;241m\u2551\x1B[0m Autonomous CI/CD Platform
302
- \x1B[38;2;99;102;241m\u255A\u2550\u255D\x1B[0m \x1B[2mheal \xB7 unit \xB7 e2e \xB7 integration \xB7 audit\x1B[0m
303
- `)}async function Ee(e){let t=5,s=e.model,n,o=P.load(process.cwd()),i=e.projectId||o?.projectId||"local";if(i!=="local"){let r=await ye(i);if(!r.ok)r.reason==="not_found"?(console.error(`
430
+ \x1B[38;2;99;102;241m\u255A\u2550\u255D\x1B[0m \x1B[2mheal \xB7 unit \xB7 e2e \xB7 integration \xB7 audit \xB7 chat\x1B[0m
431
+ `)}async function Fe(e){let t=5,s=e.model,n,o=R.load(process.cwd()),i=e.projectId||o?.projectId||"local";if(i!=="local"){let a=await je(i);if(!a.ok)a.reason==="not_found"?(console.error(`
304
432
  [Lisa.ai Agent Error] Project '${i}' does not exist on the Control Plane. Please create it in the Dashboard first or run locally without a project ID.`),process.exit(1)):console.warn(`
305
- [Lisa.ai Warning] Control Plane is unreachable. Continuing with local CLI defaults (model=${s}, maxRetries=${t}).`);else{let a=r.config;console.log(`[Lisa.ai Agent] Dynamic Config Loaded: Provider=${a.modelProvider}, MaxRetries=${a.maxRetries}`),s=a.modelProvider,t=a.maxRetries,n=a.apiKey,a.agentEnabled===!1&&(console.log("[Lisa.ai Agent] Agent is disabled by Control Plane for this project."),process.exit(1))}}return o&&(P.applyEnvDefaults(o),o.maxRetries!==void 0&&(t=o.maxRetries),o.provider&&e.model==="gemini"&&(s=o.provider),P.printSummary(o)),t<5&&console.warn(`
306
- [Lisa.ai Warning] maxRetries is ${t}. Consider increasing to 5+ for complex projects.`),{model:s,maxRetries:t,apiKey:n,projectId:i}}var z=new kt.Command;z.name("lisa-agent").description("Lisa.ai - Autonomous CI/CD Platform Worker Agent").version(St.version);z.command("heal").description("Run tests and autonomously heal all failures via LLM + Memory Engine").option("-c, --command <type>","Test command to execute (auto-detected if omitted)").option("-m, --model <provider>","LLM provider to use (gemini, claude, openai)","gemini").option("-p, --project-id <id>","Control Plane Project ID").option("-t, --type <scope>","Test type to heal: unit (default), e2e, integration","unit").option("-f, --files <paths>","Target specific files (comma-separated, bypasses discovery)").option("--ci","CI mode: commit healed files, open PR, write GitHub Actions step summary").action(async e=>{ne();let t=["unit","e2e","integration"],s=e.type;t.includes(s)||(console.error(`
307
- [Lisa.ai Error] Invalid heal type '${e.type}'. Valid types: ${t.join(", ")}`),process.exit(1));let n=e.files?e.files.split(",").map(r=>r.trim()):void 0,o=e.ci===!0,i=await Ee(e);await ce(e.command,i.model,1,i.maxRetries,i.projectId,void 0,i.apiKey,s,n,o)});z.command("unit").description("Generate missing unit test specs to reach 100% coverage (auto-detects framework)").option("-c, --command <type>","Test+coverage command to execute (auto-detected if omitted)").option("-m, --model <provider>","LLM provider to use (gemini, claude, openai)","gemini").option("-p, --project-id <id>","Control Plane Project ID").option("-f, --files <paths>","Target specific files (comma-separated, bypasses discovery)").action(async e=>{ne();let t=e.files?e.files.split(",").map(n=>n.trim()):void 0,s=await Ee(e);await pt(e.command,s.model,1,s.maxRetries,s.projectId,s.apiKey,t)});z.command("e2e").description("Generate E2E tests via Playwright (auto-installs if none detected)").option("-c, --command <type>","E2E command to execute (auto-detected if omitted)").option("-m, --model <provider>","LLM provider to use (gemini, claude, openai)","gemini").option("-p, --project-id <id>","Control Plane Project ID").option("-f, --files <paths>","Target specific files (comma-separated, bypasses discovery)").action(async e=>{ne();let t=e.files?e.files.split(",").map(n=>n.trim()):void 0,s=await Ee(e);await ft(e.command,s.model,1,s.maxRetries,s.projectId,s.apiKey,t)});z.command("integration").description("Generate integration tests for module seams (component+service, API+DB)").option("-c, --command <type>","Test command to execute (auto-detected if omitted)").option("-m, --model <provider>","LLM provider to use (gemini, claude, openai)","gemini").option("-p, --project-id <id>","Control Plane Project ID").option("-f, --files <paths>","Target specific files (comma-separated, bypasses discovery)").action(async e=>{ne();let t=e.files?e.files.split(",").map(n=>n.trim()):void 0,s=await Ee(e);await ht(e.command,s.model,1,s.maxRetries,s.projectId,s.apiKey,t)});z.command("diagnose").description("Test LLM connectivity and API key health without running the full agent").option("-m, --model <provider>","LLM provider to test (gemini, claude, openai)","claude").option("-p, --project-id <id>","Control Plane Project ID to fetch API key from").action(async e=>{ne();let t=e.model,s,n=P.load(process.cwd()),o=e.projectId||n?.projectId||"local";if(o!=="local"){let a=await ye(o);a.ok?(t=a.config.modelProvider,s=a.config.apiKey,console.log(`[Lisa.ai Diagnose] Config fetched from Control Plane. Provider=${t}`)):console.warn(`[Lisa.ai Diagnose] Control Plane ${a.reason}. Using local env for API key.`)}let r={claude:process.env.LISA_CLAUDE_MODEL||"claude-haiku-4-5",openai:process.env.LISA_OPENAI_MODEL||"gpt-4o-mini",gemini:process.env.LISA_GOOGLE_MODEL||"gemini-2.0-flash"}[t]||t;console.log(`
308
- [Lisa.ai Diagnose] Testing ${t} \u2192 model ID: ${r}`);try{let a=await ie("Reply with exactly: LISA_OK",t,s);console.log(`
433
+ [Lisa.ai Warning] Control Plane is unreachable. Continuing with local CLI defaults (model=${s}, maxRetries=${t}).`);else{let c=a.config;console.log(`[Lisa.ai Agent] Dynamic Config Loaded: Provider=${c.modelProvider}, MaxRetries=${c.maxRetries}`),s=c.modelProvider,t=c.maxRetries,n=c.apiKey,c.agentEnabled===!1&&(console.log("[Lisa.ai Agent] Agent is disabled by Control Plane for this project."),process.exit(1))}}o&&(R.applyEnvDefaults(o),o.maxRetries!==void 0&&(t=o.maxRetries),o.provider&&e.model==="gemini"&&(s=o.provider),R.printSummary(o)),t<5&&console.warn(`
434
+ [Lisa.ai Warning] maxRetries is ${t}. Consider increasing to 5+ for complex projects.`);let r=Ke(o?.lisaLlm);return r.enabled&&console.log(`[Lisa.ai Config] Lisa LLM enabled: ${r.model} @ ${r.baseUrl}`),{model:s,maxRetries:t,apiKey:n,projectId:i,lisaLlmConfig:r}}var W=new Bt.Command;W.name("lisa-agent").description("Lisa.ai - Autonomous CI/CD Platform Worker Agent").version(Yt.version);W.command("heal").description("Run tests and autonomously heal all failures via LLM + Memory Engine").option("-c, --command <type>","Test command to execute (auto-detected if omitted)").option("-m, --model <provider>","LLM provider to use (gemini, claude, openai)","gemini").option("-p, --project-id <id>","Control Plane Project ID").option("-t, --type <scope>","Test type to heal: unit (default), e2e, integration","unit").option("-f, --files <paths>","Target specific files (comma-separated, bypasses discovery)").option("--ci","CI mode: commit healed files, open PR, write GitHub Actions step summary").action(async e=>{le();let t=["unit","e2e","integration"],s=e.type;t.includes(s)||(console.error(`
435
+ [Lisa.ai Error] Invalid heal type '${e.type}'. Valid types: ${t.join(", ")}`),process.exit(1));let n=e.files?e.files.split(",").map(r=>r.trim()):void 0,o=e.ci===!0,i=await Fe(e);await ye(e.command,i.model,1,i.maxRetries,i.projectId,void 0,i.apiKey,s,n,o,i.lisaLlmConfig)});W.command("unit").description("Generate missing unit test specs to reach 100% coverage (auto-detects framework)").option("-c, --command <type>","Test+coverage command to execute (auto-detected if omitted)").option("-m, --model <provider>","LLM provider to use (gemini, claude, openai)","gemini").option("-p, --project-id <id>","Control Plane Project ID").option("-f, --files <paths>","Target specific files (comma-separated, bypasses discovery)").action(async e=>{le();let t=e.files?e.files.split(",").map(n=>n.trim()):void 0,s=await Fe(e);await bt(e.command,s.model,1,s.maxRetries,s.projectId,s.apiKey,t,s.lisaLlmConfig)});W.command("e2e").description("Generate E2E tests via Playwright (auto-installs if none detected)").option("-c, --command <type>","E2E command to execute (auto-detected if omitted)").option("-m, --model <provider>","LLM provider to use (gemini, claude, openai)","gemini").option("-p, --project-id <id>","Control Plane Project ID").option("-f, --files <paths>","Target specific files (comma-separated, bypasses discovery)").action(async e=>{le();let t=e.files?e.files.split(",").map(n=>n.trim()):void 0,s=await Fe(e);await Ft(e.command,s.model,1,s.maxRetries,s.projectId,s.apiKey,t)});W.command("integration").description("Generate integration tests for module seams (component+service, API+DB)").option("-c, --command <type>","Test command to execute (auto-detected if omitted)").option("-m, --model <provider>","LLM provider to use (gemini, claude, openai)","gemini").option("-p, --project-id <id>","Control Plane Project ID").option("-f, --files <paths>","Target specific files (comma-separated, bypasses discovery)").action(async e=>{le();let t=e.files?e.files.split(",").map(n=>n.trim()):void 0,s=await Fe(e);await Et(e.command,s.model,1,s.maxRetries,s.projectId,s.apiKey,t)});W.command("diagnose").description("Test LLM connectivity and API key health without running the full agent").option("-m, --model <provider>","LLM provider to test (gemini, claude, openai)","claude").option("-p, --project-id <id>","Control Plane Project ID to fetch API key from").action(async e=>{le();let t=e.model,s,n=R.load(process.cwd()),o=e.projectId||n?.projectId||"local";if(o!=="local"){let a=await je(o);a.ok?(t=a.config.modelProvider,s=a.config.apiKey,console.log(`[Lisa.ai Diagnose] Config fetched from Control Plane. Provider=${t}`)):console.warn(`[Lisa.ai Diagnose] Control Plane ${a.reason}. Using local env for API key.`)}let r={claude:process.env.LISA_CLAUDE_MODEL||"claude-haiku-4-5",openai:process.env.LISA_OPENAI_MODEL||"gpt-4o-mini",gemini:process.env.LISA_GOOGLE_MODEL||"gemini-2.0-flash"}[t]||t;console.log(`
436
+ [Lisa.ai Diagnose] Testing ${t} \u2192 model ID: ${r}`);try{let a=await ge("Reply with exactly: LISA_OK",t,s);console.log(`
309
437
  [Lisa.ai Diagnose] ${t} is working correctly.`),console.log(` Model response: "${a}"`)}catch(a){console.error(`
310
438
  [Lisa.ai Diagnose] ${t} call FAILED.`),console.error(` Error: ${a.message}`),a.cause&&console.error(` Cause: ${a.cause?.message??a.cause}`),console.error(`
311
- Common causes:`),console.error(" - API key is invalid, expired, or has no credits"),console.error(" - Model ID is deprecated (current: claude-sonnet-4-6, gemini-2.0-flash, gpt-4o-mini)"),console.error(" - Rate limit exceeded \u2014 wait a minute and retry"),console.error(" - Network/proxy issue blocking api.anthropic.com"),process.exit(1)}});z.command("init").description("Interactively create a .lisai.json config file in the current project").option("--force","Overwrite existing .lisai.json if it exists").action(async e=>{let t=he.resolve(process.cwd(),te);X.existsSync(t)&&!e.force&&(console.error(`
312
- [Lisa.ai Init] ${te} already exists. Use --force to overwrite.`),process.exit(1));let s=Ct.createInterface({input:process.stdin,output:process.stdout}),n=(f,w="")=>new Promise(l=>s.question(w?`${f} [${w}]: `:`${f}: `,u=>l(u.trim()||w)));console.log(`
439
+ Common causes:`),console.error(" - API key is invalid, expired, or has no credits"),console.error(" - Model ID is deprecated (current: claude-sonnet-4-6, gemini-2.0-flash, gpt-4o-mini)"),console.error(" - Rate limit exceeded \u2014 wait a minute and retry"),console.error(" - Network/proxy issue blocking api.anthropic.com"),process.exit(1)}});W.command("init").description("Interactively create a .lisai.json config file in the current project").option("--force","Overwrite existing .lisai.json if it exists").action(async e=>{let t=Se.resolve(process.cwd(),de);re.existsSync(t)&&!e.force&&(console.error(`
440
+ [Lisa.ai Init] ${de} already exists. Use --force to overwrite.`),process.exit(1));let s=qt.createInterface({input:process.stdin,output:process.stdout}),n=(L,m="")=>new Promise(d=>s.question(m?`${L} [${m}]: `:`${L}: `,l=>d(l.trim()||m)));console.log(`
313
441
  Lisa.ai Project Setup \u2014 press Enter to accept the default shown in [ ]
314
- `);let o=await n("Control Plane project ID (leave empty for local-only mode)",""),i=await n("LLM provider (gemini / claude / openai)","gemini"),r=await n("Testing framework (jest / vitest / mocha / karma / jasmine \u2014 leave empty to auto-detect)",""),a=await n("E2E framework (playwright / cypress \u2014 leave empty for Playwright default)",""),p=await n("Test types to generate (unit / integration / e2e \u2014 comma-separated)","unit"),g=await n("Test command (leave empty for auto-discovery)",""),d=await n("E2E command (leave empty for auto-discovery)",""),x=await n("Max heal retries","5");s.close();let h={...o?{projectId:o}:{},provider:i,testTypes:p.split(",").map(f=>f.trim()).filter(Boolean),maxRetries:parseInt(x,10)||5,skipFiles:[],skipDirs:[],skipPaths:[]};r&&(h.testingFramework=r),a&&(h.e2eFramework=a),g&&(h.testCommand=g),d&&(h.e2eCommand=d),X.writeFileSync(t,JSON.stringify(h,null,2)+`
442
+ `);let o=await n("Control Plane project ID (leave empty for local-only mode)",""),i=await n("LLM provider (gemini / claude / openai)","gemini"),r=await n("Testing framework (jest / vitest / mocha / karma / jasmine \u2014 leave empty to auto-detect)",""),a=await n("E2E framework (playwright / cypress \u2014 leave empty for Playwright default)",""),c=await n("Test types to generate (unit / integration / e2e \u2014 comma-separated)","unit"),u=await n("Test command (leave empty for auto-discovery)",""),p=await n("E2E command (leave empty for auto-discovery)",""),$=await n("Max heal retries","5");s.close();let g={...o?{projectId:o}:{},provider:i,testTypes:c.split(",").map(L=>L.trim()).filter(Boolean),maxRetries:parseInt($,10)||5,skipFiles:[],skipDirs:[],skipPaths:[]};r&&(g.testingFramework=r),a&&(g.e2eFramework=a),u&&(g.testCommand=u),p&&(g.e2eCommand=p),re.writeFileSync(t,JSON.stringify(g,null,2)+`
315
443
  `,"utf-8"),console.log(`
316
- Created ${te}:
317
- `),console.log(JSON.stringify(h,null,2)),console.log(`
444
+ Created ${de}:
445
+ `),console.log(JSON.stringify(g,null,2)),console.log(`
318
446
  Tip: add "model" to pin a specific model ID (e.g. "claude-sonnet-4-6").`),console.log(` Edit skipFiles / skipDirs / skipPaths to exclude files from test analysis.
319
- `)});function Vt(e,t){return`# Lisa.ai Auto-Heal Workflow
447
+ `)});function $s(e,t){return`# Lisa.ai Auto-Heal Workflow
320
448
  # Generated by: lisa-agent init-ci
321
449
  # Docs: https://www.npmjs.com/package/@lisa.ai/agent
322
450
 
@@ -357,9 +485,9 @@ jobs:
357
485
  ${t}: \${{ secrets.${t} }}
358
486
  GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }}
359
487
  run: lisa-agent heal --model ${e} --ci
360
- `}z.command("init-ci").description("Generate a GitHub Actions workflow file for Lisa.ai CI/CD healing").option("--force","Overwrite existing workflow file").option("-m, --model <provider>","LLM provider for the workflow (gemini, claude, openai)","gemini").action(async e=>{ne();let t=he.resolve(process.cwd(),".github","workflows"),s=he.join(t,"lisa-heal.yml");X.existsSync(s)&&!e.force&&(console.error(`
361
- [Lisa.ai Init-CI] .github/workflows/lisa-heal.yml already exists. Use --force to overwrite.`),process.exit(1));let n={gemini:"GOOGLE_GENERATIVE_AI_API_KEY",claude:"ANTHROPIC_API_KEY",openai:"OPENAI_API_KEY"},o=e.model||"gemini",i=n[o]||"GOOGLE_GENERATIVE_AI_API_KEY",r=Vt(o,i);X.mkdirSync(t,{recursive:!0}),X.writeFileSync(s,r,"utf-8"),console.log(`
488
+ `}W.command("init-ci").description("Generate a GitHub Actions workflow file for Lisa.ai CI/CD healing").option("--force","Overwrite existing workflow file").option("-m, --model <provider>","LLM provider for the workflow (gemini, claude, openai)","gemini").action(async e=>{le();let t=Se.resolve(process.cwd(),".github","workflows"),s=Se.join(t,"lisa-heal.yml");re.existsSync(s)&&!e.force&&(console.error(`
489
+ [Lisa.ai Init-CI] .github/workflows/lisa-heal.yml already exists. Use --force to overwrite.`),process.exit(1));let n={gemini:"GOOGLE_GENERATIVE_AI_API_KEY",claude:"ANTHROPIC_API_KEY",openai:"OPENAI_API_KEY"},o=e.model||"gemini",i=n[o]||"GOOGLE_GENERATIVE_AI_API_KEY",r=$s(o,i);re.mkdirSync(t,{recursive:!0}),re.writeFileSync(s,r,"utf-8"),console.log(`
362
490
  Created: .github/workflows/lisa-heal.yml`),console.log(`
363
491
  Required repository secret: ${i}`),console.log(" Set it in: GitHub repo > Settings > Secrets and variables > Actions"),console.log(`
364
492
  The workflow will:`),console.log(" 1. Run on every push to main/master/develop"),console.log(" 2. Install dependencies + run lisa-agent heal --ci"),console.log(" 3. If tests fail and Lisa heals them, open a PR automatically"),console.log(` 4. If all tests pass or nothing can be healed, report status
365
- `)});z.command("audit").description("Scan for npm vulnerabilities and auto-fix where safe; consult LLM for manual fixes").option("-m, --model <provider>","LLM provider to use (gemini, claude, openai)","gemini").option("-p, --project-id <id>","Control Plane Project ID").action(async e=>{ne();let t=e.model,s,n=P.load(process.cwd()),o=e.projectId||n?.projectId||"local";if(o!=="local"){let i=await ye(o);i.ok?(t=i.config.modelProvider,s=i.config.apiKey,console.log(`[Lisa.ai Audit] Config fetched from Control Plane. Provider=${t}`)):console.warn(`[Lisa.ai Audit] Control Plane ${i.reason}. Using local env for API key.`)}await $t(t,o,s)});z.parse(process.argv);
493
+ `)});W.command("audit").description("Scan for npm vulnerabilities and auto-fix where safe; consult LLM for manual fixes").option("-m, --model <provider>","LLM provider to use (gemini, claude, openai)","gemini").option("-p, --project-id <id>","Control Plane Project ID").action(async e=>{le();let t=e.model,s,n=R.load(process.cwd()),o=e.projectId||n?.projectId||"local";if(o!=="local"){let i=await je(o);i.ok?(t=i.config.modelProvider,s=i.config.apiKey,console.log(`[Lisa.ai Audit] Config fetched from Control Plane. Provider=${t}`)):console.warn(`[Lisa.ai Audit] Control Plane ${i.reason}. Using local env for API key.`)}await Rt(t,o,s)});W.command("chat").description("Interactive chat \u2014 ask questions, heal files, run tests").option("-m, --model <provider>","LLM provider to use (gemini, claude, openai)","gemini").option("-p, --project-id <id>","Control Plane Project ID").action(async e=>{le();let t=await Fe(e);await Ht(t.model,t.projectId,t.apiKey,t.lisaLlmConfig)});W.parse(process.argv);