@lisa.ai/agent 2.5.0 → 2.5.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 +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var Be=Object.create;var le=Object.defineProperty;var Ye=Object.getOwnPropertyDescriptor;var qe=Object.getOwnPropertyNames;var We=Object.getPrototypeOf,ze=Object.prototype.hasOwnProperty;var Je=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Ze=(t,e,s,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of qe(e))!ze.call(t,n)&&n!==s&&le(t,n,{get:()=>e[n],enumerable:!(o=Ye(e,n))||o.enumerable});return t};var v=(t,e,s)=>(s=t!=null?Be(We(t)):{},Ze(e||!t||!t.__esModule?le(s,"default",{value:t,enumerable:!0}):s,t));var Oe=Je((Nt,Xe)=>{Xe.exports={name:"@lisa.ai/agent",version:"2.5.
|
|
2
|
+
"use strict";var Be=Object.create;var le=Object.defineProperty;var Ye=Object.getOwnPropertyDescriptor;var qe=Object.getOwnPropertyNames;var We=Object.getPrototypeOf,ze=Object.prototype.hasOwnProperty;var Je=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Ze=(t,e,s,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of qe(e))!ze.call(t,n)&&n!==s&&le(t,n,{get:()=>e[n],enumerable:!(o=Ye(e,n))||o.enumerable});return t};var v=(t,e,s)=>(s=t!=null?Be(We(t)):{},Ze(e||!t||!t.__esModule?le(s,"default",{value:t,enumerable:!0}):s,t));var Oe=Je((Nt,Xe)=>{Xe.exports={name:"@lisa.ai/agent",version:"2.5.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 _e=require("commander"),se=v(require("fs")),Ne=v(require("path")),Ue=v(require("readline"));var ue=v(require("dotenv"));ue.config({quiet:!0});async function z(t){let e=process.env.LISA_CONTROL_PLANE_URL||"http://localhost:3000";try{let s=`${e}/api/config/${t}`;console.log(`[Lisa.ai Agent] Fetching dynamic configuration from ${s}...`);let o=await fetch(s);if(!o.ok){let i=o.status===404?"not_found":"unreachable";return console.warn(i==="not_found"?`[Lisa.ai Agent Warning] Control Plane returned 404. Project '${t}' not found.`:`[Lisa.ai Agent Warning] Control Plane returned ${o.status}. Falling back to local defaults.`),{ok:!1,reason:i}}return{ok:!0,config:await o.json()}}catch{return console.warn(`[Lisa.ai Agent Warning] Failed to reach Control Plane (${e}). Using local fallback configuration.`),{ok:!1,reason:"unreachable"}}}var Ie=require("child_process"),S=v(require("fs")),Y=v(require("path"));var x=v(require("path")),j=v(require("fs"));function J(t,e=[],s=process.cwd()){let o=t.replace(/\x1B\[[0-9;]*[a-zA-Z]/g,""),n=e.map(a=>x.resolve(a)),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(o))!==null;){let a=r[1];if(a){if(/[/\\](node_modules|dist|build)[/\\]/.test(a))continue;let h=x.isAbsolute(a)?a:x.resolve(s,a);if(!n.includes(h)&&j.existsSync(h))return a}}let l=/FAIL\s+([a-zA-Z0-9_.\-\/\\]+\.(?:ts|tsx|js|jsx|vue))/gi,d;for(;(d=l.exec(o))!==null;){let a=d[1],h=x.isAbsolute(a)?a:x.resolve(s,a);if(!n.includes(h)&&j.existsSync(h))return a}let g=/([a-zA-Z]:[a-zA-Z0-9_.\-\/\\]+\.(?:ts|tsx|js|jsx|vue)|[a-zA-Z0-9_.\-\/\\]+\.(?:ts|tsx|js|jsx|vue))/g,m;for(;(m=g.exec(o))!==null;){let a=m[1];if(a){if(/[/\\](node_modules|dist|build)[/\\]/.test(a))continue;let h=x.isAbsolute(a)?a:x.resolve(s,a);if(!n.includes(h)&&j.existsSync(h))return a}}let p=/\b([A-Z][a-zA-Z0-9]{3,})\b/g,c,f=new Set,u=["Error","TypeError","SyntaxError","ReferenceError","RangeError","NullInjectorError","Object","Boolean","String","Number","Array","Chrome","Windows","Linux","Macintosh","UserContext","TestBed","Module","Unexpected","Expected","ChromeHeadless","Users","AppData","Local","Temp","Process","Component","Validation","Directory","Configuration","Documentation"];for(;(c=p.exec(o))!==null;){let a=c[1];if(a&&!u.includes(a)&&!f.has(a)){f.add(a),console.log(`[Lisa.ai Parser] Discovered abstract symbol failure: ${a}. Scanning project tree...`);let h=de(a,s,n);if(h)return x.relative(s,h)}}return null}function de(t,e,s){if(!j.existsSync(e))return null;let o=j.readdirSync(e);for(let n of o){let i=x.join(e,n);if(n==="node_modules"||n==="dist"||n==="build"||n===".git"||n===".angular")continue;let r;try{r=j.statSync(i)}catch{continue}if(r.isDirectory()){let l=de(t,i,s);if(l)return l}else if(n.match(/\.(ts|tsx|js|jsx|vue)$/)){let l=j.readFileSync(i,"utf8");if(l.includes(`class ${t}`)||l.includes(`function ${t}`)||l.includes(`const ${t}`)||l.includes(`let ${t}`)||l.includes(`exports.${t}`)||l.includes(`module.exports.${t}`)){let d=i,g=x.extname(i),m=i.slice(0,-g.length);if(!n.includes(".spec.")&&!n.includes(".test.")){let p=[`${m}.spec${g}`,`${m}.test${g}`,`${m}.spec.js`,`${m}.test.js`];for(let c of p)if(j.existsSync(c)){d=c;break}}if(!s.includes(x.resolve(d)))return d}}}return null}var B=require("ai"),pe=require("@ai-sdk/openai"),ge=require("@ai-sdk/anthropic"),me=require("@ai-sdk/google"),fe=v(require("dotenv"));fe.config({quiet:!0});var ie=15e3;function he(t,e){return t.length<=ie?t:(console.warn(`[Lisa.ai LLM] ${e} is ${t.length} chars \u2014 truncating to ${ie} to stay within context window.`),t.slice(0,ie)+`
|
|
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 ve(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(o=>` \u2022 ${e[o]??o}`).join(`
|
|
@@ -81,7 +81,7 @@ Requirements:
|
|
|
81
81
|
2. Ensure standard transpilation (ts-jest for jest, or standard karma-webpack/karma-typescript implementations).
|
|
82
82
|
3. Do NOT wrap your response in markdown formatting (no \`\`\`javascript).
|
|
83
83
|
4. Return ONLY the raw code string block.`;try{let d=await V(l,s,o),g="";e.testingFramework==="jest"&&(g="jest.config.js"),e.testingFramework==="karma"&&(g="karma.conf.js"),e.testingFramework==="vitest"&&(g="vitest.config.ts");let m=re.join(n,g);X.writeFileSync(m,d,"utf-8"),console.log(`\u2705 [Lisa.ai Auto-Generator] Natively wrote ${g} to repository root.`)}catch(d){console.error(`
|
|
84
|
-
\u274C [Lisa.ai Auto-Generator] Failed to author configuration file: ${d.message}`),process.exit(1)}}};var be=v(require("dotenv"));be.config({quiet:!0});function Pe(t){let e=t.toLowerCase();return e.includes("karma")||e.includes("ng test")?"karma":e.includes("jest")?"jest":e.includes("vitest")?"vitest":e.includes("playwright")?"playwright":e.includes("cypress")?"cypress":e.includes("mocha")?"mocha":"unknown"}async function Ee(t,e,s){if(s==="local")return[];let o=process.env.LISA_CONTROL_PLANE_URL||"http://localhost:3000";try{let n=new URLSearchParams({projectId:s,errorLog:t.slice(0,1e3),framework:e}),i=await fetch(`${o}/api/memory/lookup?${n}`);return i.ok?await i.json():[]}catch{return[]}}async function Te(t,e,s,o){if(o==="local")return;let n=process.env.LISA_CONTROL_PLANE_URL||"http://localhost:3000";fetch(`${n}/api/memory/record`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:o,errorLog:t.slice(0,1e3),fixHint:e.slice(0,2e3),framework:s})}).catch(i
|
|
84
|
+
\u274C [Lisa.ai Auto-Generator] Failed to author configuration file: ${d.message}`),process.exit(1)}}};var be=v(require("dotenv"));be.config({quiet:!0});function Pe(t){let e=t.toLowerCase();return e.includes("karma")||e.includes("ng test")?"karma":e.includes("jest")?"jest":e.includes("vitest")?"vitest":e.includes("playwright")?"playwright":e.includes("cypress")?"cypress":e.includes("mocha")?"mocha":"unknown"}async function Ee(t,e,s){if(s==="local")return[];let o=process.env.LISA_CONTROL_PLANE_URL||"http://localhost:3000";try{let n=new URLSearchParams({projectId:s,errorLog:t.slice(0,1e3),framework:e}),i=await fetch(`${o}/api/memory/lookup?${n}`);return i.ok?await i.json():[]}catch{return[]}}async function Te(t,e,s,o){if(o==="local")return;let n=process.env.LISA_CONTROL_PLANE_URL||"http://localhost:3000";try{await fetch(`${n}/api/memory/record`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:o,errorLog:t.slice(0,1e3),fixHint:e.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 Q=3;function Ve(t){let e=t.replace(/\.(spec|test)\.(ts|js|jsx|tsx)$/,".$2");if(e!==t&&S.existsSync(e))try{return console.log(`[Lisa.ai Context Engine] \u{1F9E0} Located sibling logic structure at ${e}`),S.readFileSync(e,"utf-8")}catch{return}}function Ke(t,e){let s=t.toLowerCase(),o=Y.parse(e);if(s.includes("ng test")||s.includes("karma"))return`${t} --include **/${o.base}`;if(s.includes("jest")||s.includes("vitest")||s.includes("playwright"))return`${t} ${e}`;if(s.includes("cypress"))return`${t} --spec ${e}`;if(s.includes("npm")||s.includes("yarn")||s.includes("pnpm")){try{let i=Y.resolve(process.cwd(),"package.json");if(S.existsSync(i)){let r=JSON.parse(S.readFileSync(i,"utf8")),l="test";s.includes("npm run ")?l=s.split("npm run ")[1].split(" ")[0]:s.includes("yarn ")?l=s.split("yarn ")[1].split(" ")[0]:s.includes("pnpm ")&&(l=s.split("pnpm ")[1].split(" ")[0]);let d=r.scripts?.[l]?.toLowerCase()||"",g=s.includes("npm")?" --":"";if(d.includes("ng test")||d.includes("karma"))return`${t}${g} --include **/${o.base}`;if(d.includes("jest")||d.includes("vitest")||d.includes("playwright"))return`${t}${g} ${e}`}}catch{}let n=s.includes("npm")?" --":"";return`${t}${n} ${e}`}return t}async function N(t,e,s=1,o=null,n=3,i="local",r,l,d=[],g=0,m={}){if(!t){console.log(`
|
|
85
85
|
[Lisa.ai Auto-Discovery] No explicit --command provided. Initiating Autonomous Framework Fingerprinting...`);let c=M.scanRepository();c.testingFramework==="none"&&(c=await O.installMissingFramework(c),await _.provisionConfigurationFiles(c,e,l)),c.suggestedTestCommand?(t=c.suggestedTestCommand,console.log(`[Lisa.ai Auto-Discovery] Bootstrapping execution with natively discovered command: ${t}`)):(console.error(`
|
|
86
86
|
\u{1F6A8} [Lisa.ai Fatal Error] Agent could not dynamically extrapolate a testing command for a Generic Node Environment. Please pass --command explicitly.`),process.exit(1))}console.log(`
|
|
87
87
|
[Lisa.ai Executing] ${t} (Global Engine) Using Model: ${e}`);let p=(c,f=!1)=>new Promise((u,a)=>{let h=(0,Ie.spawn)(c,{shell:!0,stdio:["ignore","pipe","pipe"]}),w="",L="";h.stdout?.on("data",y=>{let b=y.toString();w+=b}),h.stderr?.on("data",y=>{L+=y.toString()}),h.on("close",y=>{y===0?u({stdout:w,stderr:L}):a({message:`Process exited with code ${y}`,stdout:w,stderr:L})})});try{console.log("\u23F3 [Lisa.ai Testing] Booting Headless Test Suite in background..."),await p(t,!1),console.log(`
|
|
@@ -110,7 +110,7 @@ ${H}
|
|
|
110
110
|
\`\`\`
|
|
111
111
|
|
|
112
112
|
**New Error:**
|
|
113
|
-
${y}`,w++}}if(L)await I({projectId:i,type:"heal",filePath:u,modelUsed:e,status:"success",details:E}),Te(f,C,W,i);else if(console.warn(`
|
|
113
|
+
${y}`,w++}}if(L)await I({projectId:i,type:"heal",filePath:u,modelUsed:e,status:"success",details:E}),await Te(f,C,W,i);else if(console.warn(`
|
|
114
114
|
[Lisa.ai Auto-Heal] \u26A0\uFE0F Agent failed to locally heal ${u} after ${n} isolated attempts. Marking as Skipped to avoid infinite Loop.`),await I({projectId:i,type:"heal",filePath:u,modelUsed:e,status:"error",details:`Agent exhausted all ${n} attempts without success.
|
|
115
115
|
|
|
116
116
|
`+E}),m[u]=(m[u]||0)+1,console.log(`[Lisa.ai Auto-Heal] Global fail counter for ${u}: ${m[u]}/${Q}`),d.push(u),u.match(/\.(spec|test)\.(ts|js|tsx|jsx|vue)$/)){let R=a+".broken";try{S.renameSync(a,R),console.log(`[Lisa.ai Auto-Heal] \u{1F6A8} Renamed unhealable spec to ${u}.broken to force the test runner to bypass it!`)}catch{}}await N(t,e,1,L?u:null,n,i,void 0,l,d,0,m)}}var Me=require("child_process"),F=v(require("fs")),k=v(require("path"));var ee=v(require("fs")),Fe=v(require("path"));function Re(t){let e=Fe.resolve(process.cwd(),t);if(!ee.existsSync(e))throw new Error(`[Lisa.ai Coverage Error] Coverage file not found at ${e}`);let s=ee.readFileSync(e,"utf-8"),o=JSON.parse(s),n=[];for(let[i,r]of Object.entries(o))i!=="total"&&(r.lines.pct<100||r.statements.pct<100||r.functions.pct<100||r.branches.pct<100)&&n.push(i);return n}var De=new Set,te=0,ae=3;async function q(t,e,s=1,o=3,n="local",i){let r=$.load(process.cwd());r&&($.applyEnvDefaults(r),!t&&r.testCommand&&(t=r.testCommand,console.log(`[Lisa.ai Config] Using testCommand from .lisai.json: ${t}`)));let l=M.scanRepository(),d=r?.testingFramework||(l.testingFramework!=="none"?l.testingFramework:void 0),g=r?.testTypes;if(!t){console.log(`
|