@lisa.ai/agent 2.8.0 → 2.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +4 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var jt=Object.create;var Oe=Object.defineProperty;var Ct=Object.getOwnPropertyDescriptor;var bt=Object.getOwnPropertyNames;var Et=Object.getPrototypeOf,At=Object.prototype.hasOwnProperty;var Ft=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Pt=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of bt(e))!At.call(t,i)&&i!==n&&Oe(t,i,{get:()=>e[i],enumerable:!(s=Ct(e,i))||s.enumerable});return t};var j=(t,e,n)=>(n=t!=null?jt(Et(t)):{},Pt(e||!t||!t.__esModule?Oe(n,"default",{value:t,enumerable:!0}):n,t));var vt=Ft((Zs,Bt)=>{Bt.exports={name:"@lisa.ai/agent",version:"2.8.
|
|
2
|
+
"use strict";var jt=Object.create;var Oe=Object.defineProperty;var Ct=Object.getOwnPropertyDescriptor;var bt=Object.getOwnPropertyNames;var Et=Object.getPrototypeOf,At=Object.prototype.hasOwnProperty;var Ft=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Pt=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of bt(e))!At.call(t,i)&&i!==n&&Oe(t,i,{get:()=>e[i],enumerable:!(s=Ct(e,i))||s.enumerable});return t};var j=(t,e,n)=>(n=t!=null?jt(Et(t)):{},Pt(e||!t||!t.__esModule?Oe(n,"default",{value:t,enumerable:!0}):n,t));var vt=Ft((Zs,Bt)=>{Bt.exports={name:"@lisa.ai/agent",version:"2.8.1",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 xt=require("commander"),je=j(require("fs")),Lt=j(require("path")),$t=j(require("readline"));var Ue=j(require("dotenv"));Ue.config({quiet:!0});async function ge(t){let e=process.env.LISA_CONTROL_PLANE_URL||"http://localhost:3000";try{let n=`${e}/api/config/${t}`;console.log(`[Lisa.ai Agent] Fetching dynamic configuration from ${n}...`);let s=await fetch(n);if(!s.ok){let o=s.status===404?"not_found":"unreachable";return console.warn(o==="not_found"?`[Lisa.ai Agent Warning] Control Plane returned 404. Project '${t}' not found.`:`[Lisa.ai Agent Warning] Control Plane returned ${s.status}. Falling back to local defaults.`),{ok:!1,reason:o}}return{ok:!0,config:await s.json()}}catch{return console.warn(`[Lisa.ai Agent Warning] Failed to reach Control Plane (${e}). Using local fallback configuration.`),{ok:!1,reason:"unreachable"}}}var ot=require("child_process"),G=j(require("fs")),Y=j(require("path"));var S=j(require("path")),P=j(require("fs"));function fe(t){return t.replace(/\x1B\[[0-9;]*[a-zA-Z]/g,"")}function V(t){let e=fe(t),n=[...e.matchAll(/Executed\s+(\d+)\s+of\s+(\d+)(?:\s+\((\d+)\s+FAILED\))?/g)];if(n.length>0){let d=[...n].reverse().find(m=>m[3]!==void 0)??n[n.length-1],g=parseInt(d[2]),y=d[3]?parseInt(d[3]):0,c=parseInt(d[1])-y;return{total:g,passed:c,failed:y}}let s=e.match(/Tests:\s+(?:(\d+)\s+failed,?\s*)?(?:(\d+)\s+passed,?\s*)?(\d+)\s+total/);if(s){let d=parseInt(s[3]),g=s[1]?parseInt(s[1]):0,y=s[2]?parseInt(s[2]):0;return{total:d,passed:y,failed:g}}let i=e.match(/(\d+)\s+failed/),o=e.match(/(\d+)\s+passed/);if(o||i){let d=i?parseInt(i[1]):0,g=o?parseInt(o[1]):0,y=e.match(/(\d+)\s+skipped/),c=y?parseInt(y[1]):0;return{total:g+d+c,passed:g,failed:d}}let r=e.match(/Tests\s+(?:(\d+)\s+failed\s*\|?\s*)?(\d+)\s+passed\s*\((\d+)\)/);if(r){let d=parseInt(r[3]),g=r[1]?parseInt(r[1]):0,y=parseInt(r[2]);return{total:d,passed:y,failed:g}}let a=e.match(/(\d+)\s+passing/),p=e.match(/(\d+)\s+failing/);if(a){let d=parseInt(a[1]),g=p?parseInt(p[1]):0;return{total:d+g,passed:d,failed:g}}return null}function be(t,e=process.cwd(),n=[]){let s=t.replace(/\x1B\[[0-9;]*[a-zA-Z]/g,""),i=n.map(f=>S.resolve(e,f)),o=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(s))!==null;){let u=p[1].trim().split(" ");for(let k=1;k<Math.min(u.length,6);k++){let $=u.slice(0,k).join(" ");if(r.has($))continue;r.add($);let l=Ee($,e,i);if(l){let v=S.resolve(l);o.has(v)||o.set(v,S.relative(e,l));break}}}let d=/^FAIL\s+([a-zA-Z0-9_./-\\]+\.(?:spec|test)\.(ts|tsx|js|jsx))/gm,g;for(;(g=d.exec(s))!==null;){let f=g[1],u=S.isAbsolute(f)?f:S.resolve(e,f);!i.includes(u)&&P.existsSync(u)&&!o.has(u)&&o.set(u,S.relative(e,u))}let y=/\[(?:chromium|firefox|webkit)\]\s+[>›]\s+([^\s:]+\.(?:spec|test)\.[tj]sx?):\d+:\d+\s+[>›]/g,c;for(;(c=y.exec(s))!==null;){let f=c[1],u=S.isAbsolute(f)?f:S.resolve(e,f);!i.includes(u)&&P.existsSync(u)&&!o.has(u)&&o.set(u,S.relative(e,u))}let m=/Running:\s+([^\s]+\.(?:cy|spec|test)\.[tj]sx?)/g,h;for(;(h=m.exec(s))!==null;){let f=h[1],u=S.isAbsolute(f)?f:S.resolve(e,f);if(!i.includes(u)&&P.existsSync(u)&&!o.has(u)){let k=f.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");new RegExp(k+"\\s+\\d+\\s+\\d+\\s+([1-9]\\d*)").test(s)&&o.set(u,S.relative(e,u))}}return[...o.values()]}function me(t,e=[],n=process.cwd()){let s=t.replace(/\x1B\[[0-9;]*[a-zA-Z]/g,""),i=e.map(f=>S.resolve(f));{let f=/(?:Chrome|Firefox|Safari)(?:\s+Headless)?\s+[\d.]+(?:\s+[\d.]+)*\s+\([^)]+\)\s+(.+?)\s+FAILED/g,u=new Set,k;for(;(k=f.exec(s))!==null;){let l=k[1].trim().split(" ");for(let v=1;v<Math.min(l.length,5);v++){let w=l.slice(0,v).join(" ");if(u.has(w))continue;u.add(w);let L=Ee(w,n,i);if(L)return S.relative(n,L)}}}let o=/([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=o.exec(s))!==null;){let f=r[1];if(f){if(/(?:^|[/\\])(node_modules|dist|build)[/\\]/.test(f))continue;let u=S.isAbsolute(f)?f:S.resolve(n,f);if(!i.includes(u)&&P.existsSync(u))return f}}let a=/FAIL\s+([a-zA-Z0-9_.\-\/\\]+\.(?:ts|tsx|js|jsx|vue))/gi,p;for(;(p=a.exec(s))!==null;){let f=p[1],u=S.isAbsolute(f)?f:S.resolve(n,f);if(!i.includes(u)&&P.existsSync(u))return f}{let f=/\[(?:chromium|firefox|webkit)\]\s+[>›]\s+([^\s:]+\.(?:spec|test)\.[tj]sx?):\d+:\d+\s+[>›]/g,u;for(;(u=f.exec(s))!==null;){let k=u[1],$=S.isAbsolute(k)?k:S.resolve(n,k);if(!i.includes($)&&P.existsSync($))return k}}let d=/([a-zA-Z]:[a-zA-Z0-9_.\-\/\\]+\.(?:ts|tsx|js|jsx|vue)|[a-zA-Z0-9_.\-\/\\]+\.(?:ts|tsx|js|jsx|vue))/g,g;for(;(g=d.exec(s))!==null;){let f=g[1];if(f){if(/(?:^|[/\\])(node_modules|dist|build)[/\\]/.test(f))continue;let u=S.isAbsolute(f)?f:S.resolve(n,f);if(!i.includes(u)&&P.existsSync(u))return f}}let y=/\b([A-Z][a-zA-Z0-9]{3,})\b/g,c,m=new Set,h=["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(;(c=y.exec(s))!==null;){let f=c[1];if(!f||h.includes(f)||m.has(f)||/^[A-Z][A-Z0-9]{5,11}$/.test(f)||/^[A-Za-z0-9]{16,}$/.test(f))continue;m.add(f);let u=_e(f,n,i);if(u)return S.relative(n,u)}return null}function Ee(t,e,n){if(!P.existsSync(e))return null;let s=P.readdirSync(e);for(let i of s){let o=S.join(e,i);if(["node_modules","dist","build",".git",".angular"].includes(i))continue;let r;try{r=P.statSync(o)}catch{continue}if(r.isDirectory()){let a=Ee(t,o,n);if(a)return a}else if(/\.(spec|test)\.(ts|tsx|js|jsx)$/.test(i)){if(n.includes(S.resolve(o)))continue;try{let a=P.readFileSync(o,"utf8");if(a.includes(`describe('${t}'`)||a.includes(`describe("${t}"`))return o}catch{continue}}}return null}function _e(t,e,n){if(!P.existsSync(e))return null;let s=P.readdirSync(e);for(let i of s){let o=S.join(e,i);if(i==="node_modules"||i==="dist"||i==="build"||i===".git"||i===".angular")continue;let r;try{r=P.statSync(o)}catch{continue}if(r.isDirectory()){let a=_e(t,o,n);if(a)return a}else if(i.match(/\.(ts|tsx|js|jsx|vue)$/)){let a=P.readFileSync(o,"utf8");if(a.includes(`class ${t}`)||a.includes(`function ${t}`)||a.includes(`const ${t}`)||a.includes(`let ${t}`)||a.includes(`exports.${t}`)||a.includes(`module.exports.${t}`)){let p=o,d=S.extname(o),g=o.slice(0,-d.length);if(!i.includes(".spec.")&&!i.includes(".test.")){let y=[`${g}.spec${d}`,`${g}.test${d}`,`${g}.spec.js`,`${g}.test.js`];for(let c of y)if(P.existsSync(c)){p=c;break}}if(!n.includes(S.resolve(p)))return p}}}return null}var ce=require("ai"),Ge=require("@ai-sdk/openai"),He=require("@ai-sdk/anthropic"),Be=require("@ai-sdk/google"),qe=j(require("dotenv"));qe.config({quiet:!0});var Ae=15e3;function We(t,e){return t.length<=Ae?t:(console.warn(`[Lisa.ai LLM] ${e} is ${t.length} chars \u2014 truncating to ${Ae} to stay within context window.`),t.slice(0,Ae)+`
|
|
3
3
|
|
|
4
4
|
// ... (truncated)`)}function Ye(t,e){if(!/\b(describe|it\(|test\(|expect\(|beforeEach|afterEach|suite|assert\.|cy\.)\b/.test(t))throw new Error(`LLM returned a non-code response for ${e} (possible context overflow). Skipping to prevent file corruption.`)}function Ke(t){if(!t||t.length===0)return"";let e={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
|
${t.map(s=>` \u2022 ${e[s]??s}`).join(`
|
|
@@ -186,7 +186,7 @@ Use @playwright/test imports. Keep it concise and practical.
|
|
|
186
186
|
`,A=await X(`e2e/${w}`,x,e,o,d,["e2e"]);D.writeFileSync(L,A,"utf-8"),console.log(`[Lisa.ai E2E] Wrote ${w}`),m++,await I({projectId:i,type:"e2e",filePath:`e2e/${w}`,modelUsed:e,status:"success",details:`Generated E2E spec for route /${l}`,testFramework:d})}catch(x){console.error(`[Lisa.ai E2E] LLM failed for /${l}: ${x.message}`),await I({projectId:i,type:"e2e",filePath:`e2e/${w}`,modelUsed:e,status:"error",details:`LLM failed to generate E2E spec: ${x.message}`,testFramework:d})}}if(m===0&&c.length===0){console.log("[Lisa.ai E2E] No specs generated. Check LLM connectivity with 'lisa-agent diagnose'.");return}console.log(`
|
|
187
187
|
[Lisa.ai E2E] Running E2E tests: ${t}`);let h="",f="",u=!1;try{await new Promise((l,v)=>{let w=(0,dt.spawn)(t,{shell:!0,stdio:["ignore","pipe","pipe"],cwd:r});w.stdout?.on("data",L=>{let x=L.toString();h+=x,process.stdout.write(x)}),w.stderr?.on("data",L=>{let x=L.toString();f+=x,process.stderr.write(x)}),w.on("close",L=>{L===0?l():v(new Error(`E2E tests exited with code ${L}`))})}),u=!0,console.log(`
|
|
188
188
|
[Lisa.ai E2E] All E2E tests passed.`)}catch{console.log(`
|
|
189
|
-
[Lisa.ai E2E] Some E2E tests failed. Run 'lisa-agent heal e2e' to auto-fix.`)}let k=h+`
|
|
189
|
+
[Lisa.ai E2E] Some E2E tests failed. Run 'lisa-agent heal --e2e' to auto-fix.`)}let k=h+`
|
|
190
190
|
`+f,$=V(k);await I({projectId:i,type:"e2e",filePath:"e2e-suite",modelUsed:e,status:u?"success":"error",details:`E2E generation complete. ${m} new spec(s) generated, ${c.length} existing.`,...$&&{testTotal:$.total,testPassed:$.passed,testFailed:$.failed},testFramework:d})}var pt=require("child_process"),E=j(require("fs")),b=j(require("path"));function Ot(t){let e=b.join(t,"package.json");if(!E.existsSync(e))return"node";let n=JSON.parse(E.readFileSync(e,"utf-8")),s={...n.dependencies||{},...n.devDependencies||{}};return s["@angular/core"]?"angular":s.react?"react":s.vue?"vue":s["@nestjs/core"]?"nestjs":s.express?"express":"node"}function Ut(t,e){let n=[];if(e==="angular"){let s=b.join(t,"src","app");if(!E.existsSync(s))return n;let i=ue(s,/\.(ts)$/).filter(o=>!o.includes(".spec.")&&!o.includes(".test.")&&!o.includes("node_modules"));for(let o of i){let r=E.readFileSync(o,"utf-8");if(r.includes("@Component")&&r.includes("inject(")){let a=b.relative(t,o),p=a.replace(/\.ts$/,".integration.spec.ts");if(E.existsSync(b.join(t,p)))continue;let g=[...r.matchAll(/inject\((\w+)\)/g)].map(c=>c[1]),y=[];for(let c of g){let m=ue(s,new RegExp(`${_t(c)}\\.ts$`));y.push(...m.map(h=>b.relative(t,h)))}n.push({filePath:a,relatedFiles:y,description:`Angular component+service integration: ${b.basename(o)} injects ${g.join(", ")}`})}}}else if(e==="express"||e==="nestjs"){let s=["src","server","api","routes","controllers"];for(let i of s){let o=b.join(t,i);if(!E.existsSync(o))continue;let r=ue(o,/\.(controller|route|router)\.(ts|js)$/).filter(a=>!a.includes(".spec.")&&!a.includes(".test.")&&!a.includes("node_modules"));for(let a of r){let p=b.relative(t,a),d=p.replace(/\.(ts|js)$/,".integration.spec.$1");E.existsSync(b.join(t,d))||n.push({filePath:p,relatedFiles:[],description:`API endpoint integration test for ${b.basename(a)} \u2014 test with supertest against real middleware chain`})}}}else{let s=b.join(t,"src");if(E.existsSync(s)){let i=ue(s,/\.(ts|js|tsx|jsx)$/).filter(o=>!o.includes(".spec.")&&!o.includes(".test.")&&!o.includes("node_modules"));for(let o of i){let a=[...E.readFileSync(o,"utf-8").matchAll(/from\s+['"]\.\.?\//g)];if(a.length>=2){let p=b.relative(t,o),d=p.replace(/\.(ts|js|tsx|jsx)$/,".integration.spec.$1");if(E.existsSync(b.join(t,d)))continue;n.push({filePath:p,relatedFiles:[],description:`Module integration: ${b.basename(o)} imports ${a.length} local modules`})}}}}return n}function ue(t,e){let n=[],s=["node_modules","dist","build",".git",".angular","coverage"];if(!E.existsSync(t))return n;let i=E.readdirSync(t);for(let o of i){if(s.includes(o))continue;let r=b.join(t,o);try{E.statSync(r).isDirectory()?n.push(...ue(r,e)):e.test(o)&&n.push(r)}catch{continue}}return n}function _t(t){return t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}async function gt(t,e,n=1,s=3,i="local",o){if(n>s){console.log(`
|
|
191
191
|
[Lisa.ai Integration] Reached maximum retries (${s}). Stopping.`);return}let r=process.cwd(),a=T.load(r);a&&(T.applyEnvDefaults(a),!t&&a.testCommand&&(t=a.testCommand,console.log(`[Lisa.ai Config] Using testCommand from .lisai.json: ${t}`)));let p=Ot(r),d=W.scanRepository(),g=a?.testingFramework||(d.testingFramework!=="none"?d.testingFramework:void 0);console.log(`
|
|
192
192
|
[Lisa.ai Integration] App: ${p}, Framework: ${g||"auto"} (Attempt ${n}/${s}) Model: ${e}`),t||(d.suggestedTestCommand?t=d.suggestedTestCommand:E.existsSync(b.join(r,"angular.json"))?t="npx ng test --no-watch --browsers=ChromeHeadless":(console.error(`
|
|
@@ -220,7 +220,7 @@ ${A}`:""}
|
|
|
220
220
|
`;try{let U=await X(l.filePath,F,e,o,g,["integration"]);E.writeFileSync(L,U,"utf-8"),console.log(`[Lisa.ai Integration] Wrote ${b.relative(r,L)}`),m++,await I({projectId:i,type:"integration",filePath:l.filePath,modelUsed:e,status:"success",details:`Generated integration spec: ${l.description}`,testFramework:y})}catch(U){console.error(`[Lisa.ai Integration] LLM failed for ${l.filePath}: ${U.message}`)}}if(m===0){console.log("[Lisa.ai Integration] No new integration specs generated.");return}console.log(`
|
|
221
221
|
[Lisa.ai Integration] Running tests to verify generated specs: ${t}`);let h="",f="",u=!1;try{await new Promise((l,v)=>{let w=(0,pt.spawn)(t,{shell:!0,stdio:["ignore","pipe","pipe"],cwd:r});w.stdout?.on("data",L=>{let x=L.toString();h+=x,process.stdout.write(x)}),w.stderr?.on("data",L=>{let x=L.toString();f+=x,process.stderr.write(x)}),w.on("close",L=>{L===0?l():v(new Error(`Tests exited with code ${L}`))})}),u=!0,console.log(`
|
|
222
222
|
[Lisa.ai Integration] All tests passed including integration specs.`)}catch{console.log(`
|
|
223
|
-
[Lisa.ai Integration] Some tests failed. Run 'lisa-agent heal integration' to auto-fix.`)}let k=h+`
|
|
223
|
+
[Lisa.ai Integration] Some tests failed. Run 'lisa-agent heal --integration' to auto-fix.`)}let k=h+`
|
|
224
224
|
`+f,$=V(k);await I({projectId:i,type:"integration",filePath:"integration-suite",modelUsed:e,status:u?"success":"error",details:`Integration test generation complete. ${m} new spec(s) generated.`,...$&&{testTotal:$.total,testPassed:$.passed,testFailed:$.failed},testFramework:y})}var ht=j(require("dotenv")),yt=require("child_process"),Z=j(require("fs")),z=j(require("path"));ht.config({quiet:!0});function re(t){return new Promise(e=>{let n=(0,yt.spawn)(t,{shell:!0,stdio:["ignore","pipe","pipe"]}),s="",i="";n.stdout?.on("data",o=>{s+=o.toString()}),n.stderr?.on("data",o=>{i+=o.toString()}),n.on("close",o=>e({stdout:s,stderr:i,code:o??1}))})}function Gt(){return Z.existsSync(z.resolve(process.cwd(),"pnpm-lock.yaml"))?"pnpm":Z.existsSync(z.resolve(process.cwd(),"yarn.lock"))?"yarn":"npm"}var Ht={critical:"\u{1F534}",high:"\u{1F7E0}",moderate:"\u{1F7E1}",low:"\u{1F535}",info:"\u26AA"},ft={critical:5,high:4,moderate:3,low:2,info:1};function mt(t){let e=["critical","high","moderate","low","info"];for(let n of e){let s=t[n]??0;s>0&&console.log(` ${Ht[n]} ${n.padEnd(10)} ${s}`)}console.log(` ${"\u2500".repeat(22)}`),console.log(` ${"Total".padEnd(10)} ${t.total}`)}async function Ne(t){try{return JSON.parse(t)}catch{return null}}async function wt(t,e="local",n){Z.existsSync(z.resolve(process.cwd(),"package.json"))||(console.error(`
|
|
225
225
|
\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 s=Gt();console.log(`[Lisa.ai Audit] Package manager: ${s}`),console.log(`
|
|
226
226
|
[Lisa.ai Audit] Scanning for vulnerabilities...`);let{stdout:i,code:o}=await re(s==="npm"?"npm audit --json":s==="yarn"?"yarn audit --json":"pnpm audit --json");if(o===0){console.log(`
|
|
@@ -259,8 +259,7 @@ ${"\u2500".repeat(50)}`),console.log(" Lisa.ai Audit Complete"),console.log(`
|
|
|
259
259
|
`)}async function Ce(t){let e=5,n=t.model,s;if(t.projectId){let o=await ge(t.projectId);if(!o.ok)o.reason==="not_found"?(console.error(`
|
|
260
260
|
[Lisa.ai Agent Error] Project '${t.projectId}' 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(`
|
|
261
261
|
[Lisa.ai Warning] Control Plane is unreachable. Continuing with local CLI defaults (model=${n}, maxRetries=${e}).`);else{let r=o.config;console.log(`[Lisa.ai Agent] Dynamic Config Loaded: Provider=${r.modelProvider}, MaxRetries=${r.maxRetries}`),r.maxRetries<5&&console.warn(`
|
|
262
|
-
[Lisa.ai Warning] maxRetries is ${r.maxRetries}. Consider increasing to 5+ for complex projects.`),n=r.modelProvider,e=r.maxRetries,s=r.apiKey,r.agentEnabled===!1&&(console.log("[Lisa.ai Agent] Agent is disabled by Control Plane for this project."),process.exit(1))}}let i=T.load(process.cwd());return i&&(T.applyEnvDefaults(i),!t.projectId&&i.maxRetries!==void 0&&(e=i.maxRetries),!t.projectId&&i.provider&&t.model==="gemini"&&(n=i.provider),T.printSummary(i)),{model:n,maxRetries:e,apiKey:s,projectId:t.projectId||"local"}}var K=new xt.Command;K.name("lisa-agent").description("Lisa.ai - Autonomous CI/CD Platform Worker Agent").version(kt.version);K.command("heal
|
|
263
|
-
[Lisa.ai Error] Invalid heal scope '${t}'. Valid scopes: ${n.join(", ")}`),process.exit(1));let i=await Ce(e);await $e(e.command,i.model,1,null,i.maxRetries,i.projectId,void 0,i.apiKey,s)});K.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").action(async t=>{ae();let e=await Ce(t);await de(t.command,e.model,1,e.maxRetries,e.projectId,e.apiKey)});K.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").action(async t=>{ae();let e=await Ce(t);await ut(t.command,e.model,1,e.maxRetries,e.projectId,e.apiKey)});K.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").action(async t=>{ae();let e=await Ce(t);await gt(t.command,e.model,1,e.maxRetries,e.projectId,e.apiKey)});K.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 t=>{ae();let e=t.model,n;if(t.projectId){let o=await ge(t.projectId);o.ok?(e=o.config.modelProvider,n=o.config.apiKey,console.log(`[Lisa.ai Diagnose] Config fetched from Control Plane. Provider=${e}`)):console.warn(`[Lisa.ai Diagnose] Control Plane ${o.reason}. Using local env for API key.`)}let i={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"}[e]||e;console.log(`
|
|
262
|
+
[Lisa.ai Warning] maxRetries is ${r.maxRetries}. Consider increasing to 5+ for complex projects.`),n=r.modelProvider,e=r.maxRetries,s=r.apiKey,r.agentEnabled===!1&&(console.log("[Lisa.ai Agent] Agent is disabled by Control Plane for this project."),process.exit(1))}}let i=T.load(process.cwd());return i&&(T.applyEnvDefaults(i),!t.projectId&&i.maxRetries!==void 0&&(e=i.maxRetries),!t.projectId&&i.provider&&t.model==="gemini"&&(n=i.provider),T.printSummary(i)),{model:n,maxRetries:e,apiKey:s,projectId:t.projectId||"local"}}var K=new xt.Command;K.name("lisa-agent").description("Lisa.ai - Autonomous CI/CD Platform Worker Agent").version(kt.version);K.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("--unit","Heal unit tests (default)").option("--e2e","Heal E2E tests (auto-detects Playwright/Cypress)").option("--integration","Heal integration tests").action(async t=>{ae();let e="unit";t.e2e?e="e2e":t.integration&&(e="integration");let n=await Ce(t);await $e(t.command,n.model,1,null,n.maxRetries,n.projectId,void 0,n.apiKey,e)});K.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").action(async t=>{ae();let e=await Ce(t);await de(t.command,e.model,1,e.maxRetries,e.projectId,e.apiKey)});K.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").action(async t=>{ae();let e=await Ce(t);await ut(t.command,e.model,1,e.maxRetries,e.projectId,e.apiKey)});K.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").action(async t=>{ae();let e=await Ce(t);await gt(t.command,e.model,1,e.maxRetries,e.projectId,e.apiKey)});K.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 t=>{ae();let e=t.model,n;if(t.projectId){let o=await ge(t.projectId);o.ok?(e=o.config.modelProvider,n=o.config.apiKey,console.log(`[Lisa.ai Diagnose] Config fetched from Control Plane. Provider=${e}`)):console.warn(`[Lisa.ai Diagnose] Control Plane ${o.reason}. Using local env for API key.`)}let i={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"}[e]||e;console.log(`
|
|
264
263
|
[Lisa.ai Diagnose] Testing ${e} \u2192 model ID: ${i}`);try{let o=await ee("Reply with exactly: LISA_OK",e,n);console.log(`
|
|
265
264
|
[Lisa.ai Diagnose] ${e} is working correctly.`),console.log(` Model response: "${o}"`)}catch(o){console.error(`
|
|
266
265
|
[Lisa.ai Diagnose] ${e} call FAILED.`),console.error(` Error: ${o.message}`),o.cause&&console.error(` Cause: ${o.cause?.message??o.cause}`),console.error(`
|