@lisa.ai/agent 2.5.8 → 2.5.9
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 +82 -77
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var
|
|
2
|
+
"use strict";var Xe=Object.create;var ye=Object.defineProperty;var Qe=Object.getOwnPropertyDescriptor;var et=Object.getOwnPropertyNames;var tt=Object.getPrototypeOf,st=Object.prototype.hasOwnProperty;var ot=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var nt=(t,e,s,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of et(e))!st.call(t,n)&&n!==s&&ye(t,n,{get:()=>e[n],enumerable:!(o=Qe(e,n))||o.enumerable});return t};var L=(t,e,s)=>(s=t!=null?Xe(tt(t)):{},nt(e||!t||!t.__esModule?ye(s,"default",{value:t,enumerable:!0}):s,t));var Ye=ot((Jt,lt)=>{lt.exports={name:"@lisa.ai/agent",version:"2.5.9",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 We=require("commander"),ce=L(require("fs")),ze=L(require("path")),Ze=L(require("readline"));var ve=L(require("dotenv"));ve.config({quiet:!0});async function V(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 Ue=require("child_process"),P=L(require("fs")),U=L(require("path"));var k=L(require("path")),I=L(require("fs"));function X(t,e=[],s=process.cwd()){let o=t.replace(/\x1B\[[0-9;]*[a-zA-Z]/g,""),n=e.map(a=>k.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 c=k.isAbsolute(a)?a:k.resolve(s,a);if(!n.includes(c)&&I.existsSync(c))return a}}let u=/FAIL\s+([a-zA-Z0-9_.\-\/\\]+\.(?:ts|tsx|js|jsx|vue))/gi,g;for(;(g=u.exec(o))!==null;){let a=g[1],c=k.isAbsolute(a)?a:k.resolve(s,a);if(!n.includes(c)&&I.existsSync(c))return a}let f=/([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=f.exec(o))!==null;){let a=m[1];if(a){if(/(?:^|[/\\])(node_modules|dist|build)[/\\]/.test(a))continue;let c=k.isAbsolute(a)?a:k.resolve(s,a);if(!n.includes(c)&&I.existsSync(c))return a}}let d=/\b([A-Z][a-zA-Z0-9]{3,})\b/g,l,p=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(;(l=d.exec(o))!==null;){let a=l[1];if(!a||h.includes(a)||p.has(a)||/^[A-Z][A-Z0-9]{5,11}$/.test(a)||/^[A-Za-z0-9]{16,}$/.test(a))continue;p.add(a);let c=Le(a,s,n);if(c)return k.relative(s,c)}return null}function Le(t,e,s){if(!I.existsSync(e))return null;let o=I.readdirSync(e);for(let n of o){let i=k.join(e,n);if(n==="node_modules"||n==="dist"||n==="build"||n===".git"||n===".angular")continue;let r;try{r=I.statSync(i)}catch{continue}if(r.isDirectory()){let u=Le(t,i,s);if(u)return u}else if(n.match(/\.(ts|tsx|js|jsx|vue)$/)){let u=I.readFileSync(i,"utf8");if(u.includes(`class ${t}`)||u.includes(`function ${t}`)||u.includes(`const ${t}`)||u.includes(`let ${t}`)||u.includes(`exports.${t}`)||u.includes(`module.exports.${t}`)){let g=i,f=k.extname(i),m=i.slice(0,-f.length);if(!n.includes(".spec.")&&!n.includes(".test.")){let d=[`${m}.spec${f}`,`${m}.test${f}`,`${m}.spec.js`,`${m}.test.js`];for(let l of d)if(I.existsSync(l)){g=l;break}}if(!s.includes(k.resolve(g)))return g}}}return null}var Z=require("ai"),we=require("@ai-sdk/openai"),xe=require("@ai-sdk/anthropic"),Ce=require("@ai-sdk/google"),$e=L(require("dotenv"));$e.config({quiet:!0});var de=15e3;function ke(t,e){return t.length<=de?t:(console.warn(`[Lisa.ai LLM] ${e} is ${t.length} chars \u2014 truncating to ${de} to stay within context window.`),t.slice(0,de)+`
|
|
3
3
|
|
|
4
|
-
// ... (truncated)`)}function
|
|
4
|
+
// ... (truncated)`)}function Ae(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 Se(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(`
|
|
6
6
|
`)}
|
|
7
|
-
`}function
|
|
7
|
+
`}function Q(t,e){if(t==="claude"){let n=e||process.env.ANTHROPIC_API_KEY;if(!n)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,xe.createAnthropic)({apiKey:n})(i)}if(t==="openai"){let n=e||process.env.OPENAI_API_KEY;if(!n)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,we.createOpenAI)({apiKey:n})(i)}let s=e||process.env.GOOGLE_GENERATIVE_AI_API_KEY;if(!s)throw new Error("No Google API key provided by local ENV or Control Plane");let o=process.env.LISA_GOOGLE_MODEL||"gemini-2.0-flash";return(0,Ce.createGoogleGenerativeAI)({apiKey:s})(o)}async function je(t,e,s,o,n,i,r,u){console.log(`[Lisa.ai Auto-Heal] Requesting fix from ${o} for ${t}...`);let g=Q(o,n),f=`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,58 +21,58 @@ 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(
|
|
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 p=r.match(/export class (\w+)/),h=p?p[1]:"the component";f+=`
|
|
25
25
|
|
|
26
26
|
--- CRITICAL ARCHITECTURAL REQUIREMENT ---
|
|
27
|
-
The component `+
|
|
28
|
-
You MUST add `+
|
|
29
|
-
DO NOT add it to the 'declarations' array. If you omit `+
|
|
27
|
+
The component `+h+` is marked as STANDALONE (standalone: true).
|
|
28
|
+
You MUST add `+h+` to the 'imports' array within 'TestBed.configureTestingModule'.
|
|
29
|
+
DO NOT add it to the 'declarations' array. If you omit `+h+" from 'imports', the test will fail."}f+=`
|
|
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
|
-
`+
|
|
34
|
+
`+r}u&&u.length>0&&(f+=`
|
|
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
|
-
`+
|
|
39
|
-
[Pattern ${
|
|
40
|
-
${
|
|
41
|
-
`)),i&&(console.log(`[Lisa.ai Auto-Heal] Warning! Agent is looping on ${t}. Injecting previous failed context...`),
|
|
38
|
+
`+u.map((l,p)=>`
|
|
39
|
+
[Pattern ${p+1}]
|
|
40
|
+
${l}`).join(`
|
|
41
|
+
`)),i&&(console.log(`[Lisa.ai Auto-Heal] Warning! Agent is looping on ${t}. Injecting previous failed context...`),f+=`
|
|
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:m}=await(0,
|
|
48
|
+
DO NOT repeat the identical code changes. Try a completely different programming approach, fix syntax typos, or check for missing imports.`);let{text:m}=await(0,Z.generateText)({model:g,prompt:f}),d=m.match(/```(?:typescript|ts|javascript|js)?\n([\s\S]*?)```/);return d?d[1].trim():m.trim()}async function be(t,e,s,o,n,i){console.log(`[Lisa.ai Coverage] Requesting test generation from ${s} for ${t}...`);let r=Q(s,o),u=n?`3. You MUST use the '${n}' testing framework exclusively. All imports, describe/it/test blocks, and mock utilities must follow '${n}' conventions.
|
|
49
49
|
`:`3. Include all necessary imports assuming a standard testing framework (Jest/Karma/Vitest) is available.
|
|
50
|
-
`,
|
|
50
|
+
`,g=Se(i),f=`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 (`+t+`) ---
|
|
54
|
-
`+
|
|
55
|
-
`+
|
|
54
|
+
`+ke(e,t)+"\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"+u+`4. Aim for 100% logic coverage.
|
|
55
|
+
`+g,{text:m}=await(0,Z.generateText)({model:r,prompt:f}),d=m.match(/```(?:typescript|ts|javascript|js)?\n([\s\S]*?)```/),l=d?d[1].trim():m.trim();return Ae(l,t),l}async function Ee(t,e,s,o,n,i,r,u){console.log(`[Lisa.ai Coverage] Requesting test update from ${n} for ${t}...`);let g=Q(n,i),f=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
|
-
`,m
|
|
57
|
+
`,m=Se(u),d=`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 (`+t+`) ---
|
|
61
|
-
`+
|
|
61
|
+
`+ke(e,t)+`
|
|
62
62
|
|
|
63
63
|
--- Existing Test Suite (`+s+`) ---
|
|
64
|
-
`+o+"\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"+
|
|
65
|
-
`+m,{text:
|
|
66
|
-
[Lisa.ai PR Engine] Initializing Pull Request for ${t}...`);let e=(0,
|
|
64
|
+
`+o+"\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"+f+`4. Aim for 100% logic coverage across branches, lines, and functions.
|
|
65
|
+
`+m,{text:l}=await(0,Z.generateText)({model:g,prompt:d}),p=l.match(/```(?:typescript|ts|javascript|js)?\n([\s\S]*?)```/),h=p?p[1].trim():l.trim();return Ae(h,t),h}async function ee(t,e,s){let o=Q(e,s),{text:n}=await(0,Z.generateText)({model:o,prompt:t}),i=n.match(/```(?:typescript|ts|javascript|js)?\n([\s\S]*?)```/);return i?i[1].trim():n.trim()}var Pe=L(require("simple-git")),Ie=require("@octokit/rest"),ht=require("dotenv/config");async function Te(t){console.log(`
|
|
66
|
+
[Lisa.ai PR Engine] Initializing Pull Request for ${t}...`);let e=(0,Pe.default)(),o=`lisa-fix/build-error-${new Date().getTime()}`,n=`fix: automated auto-heal by Lisa.ai for ${t}`,i="main";try{i=(await e.revparse(["--abbrev-ref","HEAD"])).trim()}catch{}try{await e.addConfig("user.name","Lisa.ai"),await e.addConfig("user.email","lisa@lisa.ai"),await e.checkoutLocalBranch(o),await e.add(t),await e.commit(n),console.log(`[Lisa.ai PR Engine] Committed changes to branch ${o}`),console.log("[Lisa.ai PR Engine] Pushing branch to remote origin..."),await e.push("origin",o,{"--set-upstream":null});let r=new Ie.Octokit({auth:process.env.GITHUB_TOKEN}),u=process.env.GITHUB_REPOSITORY;if(u&&process.env.GITHUB_TOKEN){let[g,f]=u.split("/");console.log(`[Lisa.ai PR Engine] Opening Pull Request against ${g}/${f}...`);let m=await r.rest.pulls.create({owner:g,repo:f,title:n,body:`### Lisa.ai Auto-Healed Pull Request
|
|
67
67
|
This PR was automatically generated by Lisa.ai to resolve a failing compilation/build step.
|
|
68
68
|
|
|
69
69
|
**Healed File:** \`${t}\`
|
|
70
70
|
|
|
71
|
-
Please review the changes.`,head:o,base:i});console.log(`\u2705 [Lisa.ai PR Engine] Pull Request created successfully: ${m.data.html_url}`)}else console.log("\u26A0\uFE0F [Lisa.ai PR Engine] GITHUB_TOKEN or GITHUB_REPOSITORY not set. Skipping GitHub Pull Request creation.")}catch(
|
|
72
|
-
\u{1F6A8} [Lisa.ai PR Engine Error] Failed to create Pull Request:`,
|
|
73
|
-
[Lisa.ai Auto-Installer] \u{1F6A8} No testing framework detected for ${e.type} architecture.`),console.log("[Lisa.ai Auto-Installer] \u{1FA84} Initiating Zero-Config Installation Protocol...");let o="",n="none";switch(e.type){case"angular":console.log("[Lisa.ai Auto-Installer] Provisioning Angular TestBed environment..."),o="npm install --save-dev karma karma-chrome-launcher karma-coverage karma-jasmine jasmine-core @types/jasmine",n="karma",e.suggestedTestCommand="npm run test";break;case"react":case"node":default:console.log("[Lisa.ai Auto-Installer] Provisioning Universal Jest environment..."),o="npm install --save-dev jest @types/jest ts-jest",n="jest",e.suggestedTestCommand="npx jest --coverage";break;case"vue":console.log("[Lisa.ai Auto-Installer] Provisioning Vue Vitest environment..."),o="npm install --save-dev vitest @vue/test-utils jsdom",n="vitest",e.suggestedTestCommand="npx vitest run --coverage";break}if(o){console.log(`[Lisa.ai Executing] ${o}`);let i=o.split(" "),
|
|
74
|
-
\u274C [Lisa.ai Auto-Installer] Failed to construct dynamic testing environment.`),process.exit(1)),console.log("\u2705 [Lisa.ai Auto-Installer] Framework successfully injected."),e.testingFramework=n,e}return e}};var
|
|
75
|
-
[Lisa.ai Auto-Generator] \u{1FA84} Analyzing ${e.type} architecture to generate ${e.testingFramework} configuration specs...`),["jest.config.js","jest.config.ts","karma.conf.js","vitest.config.ts","vitest.config.js"].some(
|
|
71
|
+
Please review the changes.`,head:o,base:i});console.log(`\u2705 [Lisa.ai PR Engine] Pull Request created successfully: ${m.data.html_url}`)}else console.log("\u26A0\uFE0F [Lisa.ai PR Engine] GITHUB_TOKEN or GITHUB_REPOSITORY not set. Skipping GitHub Pull Request creation.")}catch(r){console.error(`
|
|
72
|
+
\u{1F6A8} [Lisa.ai PR Engine Error] Failed to create Pull Request:`,r.message)}finally{try{await e.checkout(i)}catch{}}}var Fe=L(require("dotenv"));Fe.config({quiet:!0});async function D(t){let s=`${process.env.LISA_CONTROL_PLANE_URL||"http://localhost:3000"}/api/telemetry`;fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}).catch(o=>{console.debug(`[Lisa.ai Agent Debug] Failed to report telemetry: ${o.message}`)})}var R=L(require("fs")),E=L(require("path"));var te=L(require("fs")),Re=L(require("path")),_=".lisai.json",$=class{static _config=null;static _loaded=!1;static load(e=process.cwd()){if(this._loaded)return this._config;this._loaded=!0;let s=Re.resolve(e,_);if(!te.existsSync(s))return null;try{let o=te.readFileSync(s,"utf-8");return this._config=JSON.parse(o),console.log(`[Lisa.ai Config] Loaded project config from ${_}`),this._config}catch(o){return console.warn(`[Lisa.ai Config] Warning: ${_} found but failed to parse \u2014 ${o.message}. Using defaults.`),null}}static get(){return this._config}static applyEnvDefaults(e){if(!e.model)return;let s={claude:"LISA_CLAUDE_MODEL",openai:"LISA_OPENAI_MODEL",gemini:"LISA_GOOGLE_MODEL"},o=e.provider;o&&s[o]&&!process.env[s[o]]&&(process.env[s[o]]=e.model,console.log(`[Lisa.ai Config] Model override applied: ${o} \u2192 ${e.model}`))}static printSummary(e){let s=[];e.provider&&s.push(`provider=${e.provider}`),e.model&&s.push(`model=${e.model}`),e.testingFramework&&s.push(`testingFramework=${e.testingFramework}`),e.testTypes?.length&&s.push(`testTypes=[${e.testTypes.join(",")}]`),e.maxRetries!==void 0&&s.push(`maxRetries=${e.maxRetries}`),e.testCommand&&s.push(`testCommand="${e.testCommand}"`),s.length&&console.log(`[Lisa.ai Config] Settings: ${s.join(", ")}`),e.skipFiles?.length&&console.log(`[Lisa.ai Config] Extra skip files : ${e.skipFiles.join(", ")}`),e.skipDirs?.length&&console.log(`[Lisa.ai Config] Extra skip dirs : ${e.skipDirs.join(", ")}`),e.skipPaths?.length&&console.log(`[Lisa.ai Config] Extra skip paths : ${e.skipPaths.join(", ")}`)}};var N=class{static scanRepository(e=process.cwd()){let s=E.resolve(e,"package.json"),o={type:"unknown",testingFramework:"none"};if(!R.existsSync(s))return console.warn(`[Lisa.ai AutoDiscovery] No package.json found at ${s}. Defaulting to Generic Node.`),o.type="node",o;let n=JSON.parse(R.readFileSync(s,"utf8")),i={...n.dependencies||{},...n.devDependencies||{}},r=n.scripts||{};return i["@angular/core"]?o.type="angular":i.react?o.type="react":i.vue?o.type="vue":o.type="node",i.jest||r.test?.includes("jest")?o.testingFramework="jest":i.karma||r.test?.includes("karma")||r.test?.includes("ng test")?o.testingFramework="karma":(i.vitest||r.test?.includes("vitest"))&&(o.testingFramework="vitest"),o.testingFramework!=="none"&&(r.test?o.suggestedTestCommand="npm run test":o.testingFramework==="karma"?o.suggestedTestCommand="npx karma start":o.testingFramework==="jest"?o.suggestedTestCommand="npx jest --coverage":o.testingFramework==="vitest"&&(o.suggestedTestCommand="npx vitest run --coverage")),o}static findUntestedFiles(e,s=[]){let o=[];if(!R.existsSync(e))return o;let n=R.readdirSync(e),i=$.get(),r=i?.skipDirs??[],u=i?.skipFiles??[],g=i?.skipPaths??[],f=["node_modules","dist","build",".git",".angular","coverage","public","assets",...r],m=["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"],d=[/^\./,/\.config\.(js|ts|mjs|cjs)$/,/\.conf\.(js|ts|mjs|cjs)$/];for(let l of n){let p=E.join(e,l);if(f.includes(l))continue;let h;try{h=R.statSync(p)}catch{continue}if(h.isDirectory())o.push(...this.findUntestedFiles(p,s));else if(l.match(/\.(ts|tsx|js|jsx|vue)$/)&&!l.includes(".spec.")&&!l.includes(".test.")){if(m.includes(l)||u.includes(l)||d.some(y=>y.test(l)))continue;let a=E.extname(l),c=l.slice(0,-a.length);if(![E.join(e,`${c}.spec${a}`),E.join(e,`${c}.test${a}`),E.join(e,`${c}.spec.js`),E.join(e,`${c}.test.js`),E.join(e,`${c}.spec.ts`),E.join(e,`${c}.test.ts`)].some(y=>R.existsSync(y))){let y=E.relative(process.cwd(),p);if(g.some(x=>y.startsWith(x)))continue;s.includes(y)||o.push(y)}}}return o}};var De=require("child_process"),B=class{static async installMissingFramework(e,s=process.cwd()){if(e.testingFramework!=="none")return e;console.log(`
|
|
73
|
+
[Lisa.ai Auto-Installer] \u{1F6A8} No testing framework detected for ${e.type} architecture.`),console.log("[Lisa.ai Auto-Installer] \u{1FA84} Initiating Zero-Config Installation Protocol...");let o="",n="none";switch(e.type){case"angular":console.log("[Lisa.ai Auto-Installer] Provisioning Angular TestBed environment..."),o="npm install --save-dev karma karma-chrome-launcher karma-coverage karma-jasmine jasmine-core @types/jasmine",n="karma",e.suggestedTestCommand="npm run test";break;case"react":case"node":default:console.log("[Lisa.ai Auto-Installer] Provisioning Universal Jest environment..."),o="npm install --save-dev jest @types/jest ts-jest",n="jest",e.suggestedTestCommand="npx jest --coverage";break;case"vue":console.log("[Lisa.ai Auto-Installer] Provisioning Vue Vitest environment..."),o="npm install --save-dev vitest @vue/test-utils jsdom",n="vitest",e.suggestedTestCommand="npx vitest run --coverage";break}if(o){console.log(`[Lisa.ai Executing] ${o}`);let i=o.split(" "),r=process.platform==="win32"?`${i[0]}.cmd`:i[0];return(0,De.spawnSync)(r,i.slice(1),{cwd:s,stdio:"inherit"}).status!==0&&(console.error(`
|
|
74
|
+
\u274C [Lisa.ai Auto-Installer] Failed to construct dynamic testing environment.`),process.exit(1)),console.log("\u2705 [Lisa.ai Auto-Installer] Framework successfully injected."),e.testingFramework=n,e}return e}};var se=L(require("fs")),pe=L(require("path"));var q=class{static async provisionConfigurationFiles(e,s,o,n=process.cwd()){if(e.testingFramework==="none")return;if(console.log(`
|
|
75
|
+
[Lisa.ai Auto-Generator] \u{1FA84} Analyzing ${e.type} architecture to generate ${e.testingFramework} configuration specs...`),["jest.config.js","jest.config.ts","karma.conf.js","vitest.config.ts","vitest.config.js"].some(g=>se.existsSync(pe.join(n,g)))){console.log("[Lisa.ai Auto-Generator] Setup file detected. Bypassing initialization.");return}let u=`You are an expert ${e.type} architect.
|
|
76
76
|
Write a production-ready '${e.testingFramework}' configuration file for a standard '${e.type}' application.
|
|
77
77
|
The application resides in the root directory.
|
|
78
78
|
|
|
@@ -80,81 +80,86 @@ Requirements:
|
|
|
80
80
|
1. Ensure it specifically instruments code coverage.
|
|
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
|
-
4. Return ONLY the raw code string block.`;try{let
|
|
84
|
-
\u274C [Lisa.ai Auto-Generator] Failed to author configuration file: ${
|
|
85
|
-
[Lisa.ai
|
|
83
|
+
4. Return ONLY the raw code string block.`;try{let g=await ee(u,s,o),f="";e.testingFramework==="jest"&&(f="jest.config.js"),e.testingFramework==="karma"&&(f="karma.conf.js"),e.testingFramework==="vitest"&&(f="vitest.config.ts");let m=pe.join(n,f);se.writeFileSync(m,g,"utf-8"),console.log(`\u2705 [Lisa.ai Auto-Generator] Natively wrote ${f} to repository root.`)}catch(g){console.error(`
|
|
84
|
+
\u274C [Lisa.ai Auto-Generator] Failed to author configuration file: ${g.message}`),process.exit(1)}}};var Me=L(require("dotenv"));Me.config({quiet:!0});function Oe(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 _e(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 Ne(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 oe=3,ne=0,ie=0;function it(t){let e=t.match(/Executed\s+(\d+)\s+of\s+(\d+)(?:\s+\((\d+)\s+FAILED\))?/);if(!e)return null;let s=parseInt(e[2]),o=e[3]?parseInt(e[3]):0,n=parseInt(e[1])-o,i=s>0?Math.round(n/s*100):0;return` [${"\u2588".repeat(Math.round(i/5))+"\u2591".repeat(20-Math.round(i/5))}] ${i}% ${n} passed ${o} failed ${s} total`}function rt(t){let e=[];for(let s of t.split(`
|
|
85
|
+
`)){let o=s.replace(/\x1B\[[0-9;]*[a-zA-Z]/g,"").trim();if((/^FAILED/.test(o)||/ FAILED$/.test(o))&&(e.push(o),e.length>=5))break}return e}function at(t){let e=t.replace(/\.(spec|test)\.(ts|js|jsx|tsx)$/,".$2");if(e!==t&&P.existsSync(e))try{return console.log(`[Lisa.ai Context Engine] \u{1F9E0} Located sibling logic structure at ${e}`),P.readFileSync(e,"utf-8")}catch{return}}function ct(t,e){let s=t.toLowerCase(),o=U.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=U.resolve(process.cwd(),"package.json");if(P.existsSync(i)){let r=JSON.parse(P.readFileSync(i,"utf8")),u="test";s.includes("npm run ")?u=s.split("npm run ")[1].split(" ")[0]:s.includes("yarn ")?u=s.split("yarn ")[1].split(" ")[0]:s.includes("pnpm ")&&(u=s.split("pnpm ")[1].split(" ")[0]);let g=r.scripts?.[u]?.toLowerCase()||"",f=s.includes("npm")?" --":"";if(g.includes("ng test")||g.includes("karma"))return`${t}${f} --include **/${o.base}`;if(g.includes("jest")||g.includes("vitest")||g.includes("playwright"))return`${t}${f} ${e}`}}catch{}let n=s.includes("npm")?" --":"";return`${t}${n} ${e}`}return t}async function Y(t,e,s=1,o=null,n=3,i="local",r,u,g=[],f=0,m={}){let d=$.load(process.cwd());if(d&&($.applyEnvDefaults(d),!t&&d.testCommand&&(t=d.testCommand,console.log(`[Lisa.ai Config] Using testCommand from .lisai.json: ${t}`))),!t){console.log(`
|
|
86
|
+
[Lisa.ai Auto-Discovery] No explicit --command provided. Initiating Autonomous Framework Fingerprinting...`);let p=N.scanRepository();p.testingFramework==="none"&&(p=await B.installMissingFramework(p),await q.provisionConfigurationFiles(p,e,u)),p.suggestedTestCommand?(t=p.suggestedTestCommand,console.log(`[Lisa.ai Auto-Discovery] Bootstrapping execution with natively discovered command: ${t}`)):(console.error(`
|
|
86
87
|
\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
|
-
[Lisa.ai Executing] ${t} (Global Engine) Using Model: ${e}`);let
|
|
88
|
-
\
|
|
89
|
-
\
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
[Lisa.ai
|
|
97
|
-
[Lisa.ai
|
|
98
|
-
\
|
|
99
|
-
|
|
88
|
+
[Lisa.ai Executing] ${t} (Global Engine) Using Model: ${e}`);let l=(p,h=!1)=>new Promise((a,c)=>{let v=(0,Ue.spawn)(p,{shell:!0,stdio:["ignore","pipe","pipe"]}),w="",y="";v.stdout?.on("data",x=>{let A=x.toString();if(w+=A,h)for(let C of A.split(`
|
|
89
|
+
`)){let S=C.replace(/\x1B\[[0-9;]*[a-zA-Z]/g,"").trim();S&&(/Executed\s+\d+\s+of\s+\d+/.test(S)?process.stdout.write(`\r ${S.padEnd(72)}`):/^\s*FAILED\b/.test(S)&&(process.stdout.write(`
|
|
90
|
+
`),console.log(` \u2717 ${S.trim()}`)))}}),v.stderr?.on("data",x=>{y+=x.toString()}),v.on("close",x=>{x===0?a({stdout:w,stderr:y}):c({message:`Process exited with code ${x}`,stdout:w,stderr:y})})});try{console.log("\u23F3 [Lisa.ai Testing] Booting Headless Test Suite..."),await l(t,!0),console.log(`
|
|
91
|
+
\u2705 [Lisa.ai Success] Global Command executed successfully.`),o&&await Te(o);return}catch(p){process.stdout.write(`
|
|
92
|
+
`),console.log("\u274C [Lisa.ai Failure] Global Command failed.");let h=(p.stderr||"")+`
|
|
93
|
+
`+(p.stdout||"")+`
|
|
94
|
+
`+(p.message||""),a=it(h);if(a){console.log(`
|
|
95
|
+
${a}`);let T=rt(h);T.length>0&&(console.log(" Failing:"),T.forEach(F=>console.log(` \u2717 ${F}`)))}(ne>0||ie>0)&&console.log(` Session: ${ne} healed ${ie} quarantined`),console.log(`
|
|
96
|
+
[Lisa.ai Auto-Heal] Analyzing errors...`);let c=X(h,g,process.cwd());c||(console.error(`
|
|
97
|
+
\u{1F6A8} [Lisa.ai Error] Could not parse a valid failing file path from the logs (or all were explicitly skipped).`),process.exit(1));let v=U.resolve(process.cwd(),c);P.existsSync(v)||(console.error(`
|
|
98
|
+
\u{1F6A8} [Lisa.ai Error] Extracted file path does not exist: ${v}`),process.exit(1)),/[\\/](node_modules|dist|build)[\\/]/.test(v)&&(console.error(`
|
|
99
|
+
\u{1F6A8} [Lisa.ai Error] Refusing to modify a library file outside the project source: ${v}`),process.exit(1));let w=m[c]||0;if(w>=oe){console.warn(`
|
|
100
|
+
[Lisa.ai Auto-Heal] \u26A0\uFE0F ${c} has failed globally ${w} time(s) \u2014 exceeds threshold of ${oe}. Permanently skipping.`),g.push(c),await Y(t,e,1,null,n,i,void 0,u,g,0,m);return}console.log(`[Lisa.ai Auto-Heal] Identified bleeding file: ${c} (global fail count: ${w}/${oe})`);let y=1,x=!1,A=h,C,S="",z="",J=ct(t,c),Je=at(v),me=Oe(t),le=(await _e(h,me,i)).filter(T=>T.confidence>=.5).map(T=>T.fixHint);for(le.length>0&&console.log(`[Lisa.ai Memory] Found ${le.length} proven fix pattern(s) from Control Plane \u2014 injecting as LLM hint.`),await D({projectId:i,type:"heal",filePath:c,modelUsed:e,status:"running",details:"Agent is currently analyzing and applying patches..."});y<=n&&!x;){console.log(`
|
|
101
|
+
[Lisa.ai Micro-Heal] Isolating ${c} (Attempt ${y}/${n})`);let T=P.readFileSync(v,"utf-8"),F;for(let b=0;b<=3;b++)try{F=await je(c,T,A,e,u,C,Je,le);break}catch(O){let H=(O?.lastError??O)?.statusCode;if((H===529||H===500)&&b<3){let G=30*(b+1);console.warn(`
|
|
102
|
+
\u26A0\uFE0F [Lisa.ai LLM] API overloaded (HTTP ${H}). Waiting ${G}s before retry (${b+1}/3)...`),await new Promise(ue=>setTimeout(ue,G*1e3))}else{let G=O?.message??String(O);console.error(`
|
|
103
|
+
\u{1F6A8} [Lisa.ai LLM Error] API call failed for ${c}: ${G}`),console.warn("[Lisa.ai LLM Error] All retries exhausted \u2014 skipping this file for the current run.");break}}if(F===void 0)break;P.writeFileSync(v,F,"utf-8"),console.log(`[Lisa.ai Micro-Heal] Applied isolated patch to ${c}`),S=`### Auto-Heal Analysis Triggered
|
|
100
104
|
**Caught Error:**
|
|
101
105
|
\`\`\`bash
|
|
102
|
-
${
|
|
106
|
+
${A}
|
|
103
107
|
\`\`\`
|
|
104
108
|
|
|
105
109
|
**Applied Fix (${e}):**
|
|
106
110
|
\`\`\`typescript
|
|
107
|
-
${
|
|
108
|
-
\`\`\``;try{console.log(`[Lisa.ai Micro-Heal] Verifying fix with isolated command: ${
|
|
111
|
+
${F}
|
|
112
|
+
\`\`\``;try{console.log(`[Lisa.ai Micro-Heal] Verifying fix with isolated command: ${J}`),await l(J,!1),console.log(`\u2705 [Lisa.ai Micro-Heal] Isolated verification passed for ${c}!`),x=!0,z=F}catch(b){console.log("\u274C [Lisa.ai Micro-Heal] Isolated verification failed.");let O=b.stdout?b.stdout.toString():"";A=(b.stderr?b.stderr.toString():"")+`
|
|
109
113
|
`+O+`
|
|
110
|
-
`+(b.message||"");let H=(t||"").toLowerCase();if(H.includes("ng test")||H.includes("karma")){let
|
|
114
|
+
`+(b.message||"");let H=(t||"").toLowerCase();if(H.includes("ng test")||H.includes("karma")){let he=U.basename(c),G=A.includes(he+":"),ue=/ FAILED/.test(A);if(!G&&!ue){console.log(`\u2705 [Lisa.ai Micro-Heal] Fix verified for ${c} \u2014 isolated error is from other spec files, not this one.`),x=!0,z=F;continue}}C=`### Attempt ${y} Failed
|
|
111
115
|
\`\`\`typescript
|
|
112
|
-
${
|
|
116
|
+
${F}
|
|
113
117
|
\`\`\`
|
|
114
118
|
|
|
115
119
|
**New Error:**
|
|
116
|
-
${
|
|
117
|
-
|
|
120
|
+
${A}`,y++}}if(x)ne++,console.log(`
|
|
121
|
+
Healed: ${c}`),console.log(` Session: ${ne} healed ${ie} quarantined`),await D({projectId:i,type:"heal",filePath:c,modelUsed:e,status:"success",details:S}),await Ne(h,z,me,i);else if(ie++,console.warn(`
|
|
122
|
+
[Lisa.ai Auto-Heal] \u26A0\uFE0F Agent failed to locally heal ${c} after ${n} isolated attempts. Marking as Skipped to avoid infinite Loop.`),await D({projectId:i,type:"heal",filePath:c,modelUsed:e,status:"error",details:`Agent exhausted all ${n} attempts without success.
|
|
118
123
|
|
|
119
|
-
`+
|
|
124
|
+
`+S}),m[c]=(m[c]||0)+1,console.log(`[Lisa.ai Auto-Heal] Global fail counter for ${c}: ${m[c]}/${oe}`),g.push(c),c.match(/\.(spec|test)\.(ts|js|tsx|jsx|vue)$/)){let T=(t||"").toLowerCase();if(T.includes("ng test")||T.includes("karma"))try{P.writeFileSync(v,`// Quarantined by Lisa.ai \u2014 could not be automatically healed
|
|
120
125
|
describe('', () => {});
|
|
121
|
-
`,"utf-8"),console.log(`[Lisa.ai Auto-Heal] \u{1F6A8} Quarantined unhealable spec ${
|
|
122
|
-
[Lisa.ai Auto-Discovery] No explicit --command provided. Initiating Autonomous Framework Fingerprinting...`);let u
|
|
126
|
+
`,"utf-8"),console.log(`[Lisa.ai Auto-Heal] \u{1F6A8} Quarantined unhealable spec ${c} \u2014 replaced with empty stub to keep Angular build clean.`)}catch{}else{let b=v+".broken";try{P.renameSync(v,b),console.log(`[Lisa.ai Auto-Heal] \u{1F6A8} Renamed unhealable spec to ${c}.broken to force the test runner to bypass it!`)}catch{}}}await Y(t,e,1,x?c:null,n,i,void 0,u,g,0,m)}}var qe=require("child_process"),M=L(require("fs")),j=L(require("path"));var re=L(require("fs")),He=L(require("path"));function Ge(t){let e=He.resolve(process.cwd(),t);if(!re.existsSync(e))throw new Error(`[Lisa.ai Coverage Error] Coverage file not found at ${e}`);let s=re.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 Be=new Set,ae=0,ge=3;async function K(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 u=N.scanRepository(),g=r?.testingFramework||(u.testingFramework!=="none"?u.testingFramework:void 0),f=r?.testTypes;if(!t){console.log(`
|
|
127
|
+
[Lisa.ai Auto-Discovery] No explicit --command provided. Initiating Autonomous Framework Fingerprinting...`);let d=u;if(d.testingFramework==="none"&&(d=await B.installMissingFramework(d),await q.provisionConfigurationFiles(d,e,i)),d.suggestedTestCommand){t=d.suggestedTestCommand;let l=d.testingFramework;(l==="jest"||l==="vitest")&&!t.includes("--coverage")&&(t=t.includes("npm run")?`${t} -- --coverage`:`${t} --coverage`,console.log(`[Lisa.ai Coverage] Coverage flag appended: ${t}`)),console.log(`[Lisa.ai Auto-Discovery] Bootstrapping execution with natively discovered command: ${t}`)}else console.error(`
|
|
123
128
|
\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(`
|
|
124
|
-
[Lisa.ai Coverage] ${t} (Attempt ${s}/${o}) Using Model: ${e}`),await D({projectId:n,type:"coverage",filePath:"global-test-suite",modelUsed:e,status:"running",details:"Agent is currently executing testing suite and validating coverage drops..."});let m=(
|
|
125
|
-
`);for(let
|
|
126
|
-
\u2705 [Lisa.ai Coverage] Tests passed successfully on attempt ${s}.`)}catch(
|
|
127
|
-
`+(
|
|
128
|
-
`+(
|
|
129
|
-
\u274C [Lisa.ai Coverage] Tests failed. Delegating to Auto-Heal...`),await
|
|
130
|
-
\u{1F504} [Lisa.ai Coverage] Auto-Heal successful. Restarting coverage analysis...`),await
|
|
131
|
-
[Lisa.ai Coverage] No failing spec file detected in error output. Tests may not exist yet \u2014 initiating Cold-Start Discovery...`)}try{let
|
|
132
|
-
[Lisa.ai Coverage] No coverage-summary.json found. Initiating Cold-Start Project Crawler...`),
|
|
133
|
-
\u274C [Lisa.ai Coverage] LLM call failed for ${
|
|
129
|
+
[Lisa.ai Coverage] ${t} (Attempt ${s}/${o}) Using Model: ${e}`),await D({projectId:n,type:"coverage",filePath:"global-test-suite",modelUsed:e,status:"running",details:"Agent is currently executing testing suite and validating coverage drops..."});let m=(d,l=!1)=>new Promise((p,h)=>{let a=(0,qe.spawn)(d,{shell:!0,stdio:["ignore","pipe","pipe"]}),c="",v="";a.stdout?.on("data",w=>{let y=w.toString();if(c+=y,l){let x=y.split(`
|
|
130
|
+
`);for(let A of x){let C=A.match(/Executed\s+(\d+)\s+of\s+(\d+)/);if(C){let S=A.match(/(\d+)\s+FAILED/),z=S?S[1]:0,J=`\r\u23F3 [Lisa.ai Testing] Executed ${C[1]} of ${C[2]} (${z} FAILED) `;process.stdout.write(J)}}}}),a.stderr?.on("data",w=>{v+=w.toString()}),a.on("close",w=>{w===0?p():h({message:`Test process exited with code ${w}`,stdout:c,stderr:v})})});try{console.log("[Lisa.ai Coverage] Booting testing framework in the background. This may take a moment..."),await m(t,!0),console.log(`
|
|
131
|
+
\u2705 [Lisa.ai Coverage] Tests passed successfully on attempt ${s}.`)}catch(d){let l=(d.stderr||"")+`
|
|
132
|
+
`+(d.stdout||"")+`
|
|
133
|
+
`+(d.message||"");if(X(l,[],process.cwd())!==null){console.log(`
|
|
134
|
+
\u274C [Lisa.ai Coverage] Tests failed. Delegating to Auto-Heal...`),await Y(t,e,1,null,o,n,void 0,i),console.log(`
|
|
135
|
+
\u{1F504} [Lisa.ai Coverage] Auto-Heal successful. Restarting coverage analysis...`),await K(t,e,s+1,o,n,i);return}console.log(`
|
|
136
|
+
[Lisa.ai Coverage] No failing spec file detected in error output. Tests may not exist yet \u2014 initiating Cold-Start Discovery...`)}try{let d=j.resolve(process.cwd(),"coverage/coverage-summary.json"),l=[];if(M.existsSync(d))console.log("[Lisa.ai Coverage] Evaluating summary..."),l=Ge("coverage/coverage-summary.json");else{if(console.log(`
|
|
137
|
+
[Lisa.ai Coverage] No coverage-summary.json found. Initiating Cold-Start Project Crawler...`),l=N.findUntestedFiles(process.cwd(),[...Be]),l.length===0){console.log("\u2705 [Lisa.ai Coverage] Zero-Test scan complete. No untested source files discovered.");return}console.log(`[Lisa.ai Coverage] Discovered ${l.length} untested file(s). Seeding first test suite...`)}if(l.length===0){console.log("\u2705 [Lisa.ai Coverage] 100% Logic Coverage Verified! No un-covered files remaining.");return}console.log(`[Lisa.ai Coverage] Found ${l.length} file(s) below 100% threshold:`,l);let p=l[0],h=j.resolve(process.cwd(),p),a=j.parse(h),c=[j.join(a.dir,`${a.name}.spec${a.ext}`),j.join(a.dir,`${a.name}.test${a.ext}`),j.join(a.dir,`${a.name}.spec.js`),j.join(a.dir,`${a.name}.test.js`),j.join(a.dir,`${a.name}.spec.ts`),j.join(a.dir,`${a.name}.test.ts`)],v=null,w=j.join(a.dir,`${a.name}.spec${a.ext}`);for(let C of c)if(M.existsSync(C)){w=C,v=M.readFileSync(C,"utf-8");break}let y="",x=!1,A=M.readFileSync(h,"utf-8");try{v?(console.log(`[Lisa.ai Coverage] Existing test suite discovered for ${p}. Requesting single-pass logic coverage append...`),y=await Ee(p,A,j.relative(process.cwd(),w),v,e,i,g,f)):(console.log(`[Lisa.ai Coverage] Requesting newly generated test suite for ${p}...`),y=await be(p,A,e,i,g,f)),ae=0,x=!0}catch(C){ae++,Be.add(p);let S=C.cause?.message?`${C.message} (cause: ${C.cause.message})`:C.message;if(console.error(`
|
|
138
|
+
\u274C [Lisa.ai Coverage] LLM call failed for ${p} \u2014 consecutive failure #${ae}/${ge}`),console.error(` Error: ${S}`),ae>=ge)throw new Error(`Systematic LLM failure: ${ge} consecutive API calls failed.
|
|
134
139
|
This usually means your API key has insufficient credits, hit a rate limit, or the model is unavailable.
|
|
135
|
-
Last error: ${
|
|
136
|
-
Tip: Check your API key, account credits, and rate-limit quota for provider '${e}'.`)}if(!
|
|
140
|
+
Last error: ${S}
|
|
141
|
+
Tip: Check your API key, account credits, and rate-limit quota for provider '${e}'.`)}if(!x){await K(t,e,s+1,o,n,i);return}M.writeFileSync(w,y,"utf-8"),console.log(`[Lisa.ai Coverage] Wrote Spec File to ${w}`),await D({projectId:n,type:"coverage",filePath:p,modelUsed:e,status:"success",details:`### Logic Coverage Action Detected
|
|
137
142
|
**Auto-Generated Specification Append (${e}):**
|
|
138
143
|
\`\`\`typescript
|
|
139
|
-
${
|
|
140
|
-
\`\`\``}),await
|
|
141
|
-
======================================================`),console.log(`\u2728 Lisa.ai Agent v${
|
|
142
|
-
`)}var W=new
|
|
144
|
+
${y}
|
|
145
|
+
\`\`\``}),await K(t,e,s+1,o,n,i)}catch(d){console.error("[Lisa.ai Coverage loop failure]:",d.message),await D({projectId:n,type:"coverage",filePath:"coverage-loop",modelUsed:e,status:"error",details:`Coverage loop encountered an unrecoverable error: ${d.message}`})}}var Ke=Ye();function fe(){console.log(`
|
|
146
|
+
======================================================`),console.log(`\u2728 Lisa.ai Agent v${Ke.version} Running... `),console.log(" Where pure magic happens! \u{1FA84}"),console.log(`======================================================
|
|
147
|
+
`)}var W=new We.Command;W.name("lisa-agent").description("Lisa.ai - Autonomous CI/CD Platform Worker Agent").version(Ke.version);W.command("heal").description("Run a command and autonomously heal errors").option("-c, --command <type>","Command to execute (Optional for Auto-Discovery)").option("-m, --model <provider>","LLM provider to use (gemini, claude, openai)","gemini").option("-p, --project-id <id>","Control Plane Project ID to fetch dynamic config").action(async t=>{fe();let e=5,s=t.model,o;if(t.projectId){let i=await V(t.projectId);if(!i.ok)i.reason==="not_found"?(console.error(`
|
|
143
148
|
\u{1F6A8} [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(`
|
|
144
|
-
\u26A0\uFE0F [Lisa.ai Warning] Control Plane is unreachable. Continuing with local CLI defaults (model=${s}, maxRetries=${e}).`);else{let
|
|
145
|
-
\u26A0\uFE0F [Lisa.ai Warning] Your Dashboard Analytics Config has maxRetries set to ${
|
|
149
|
+
\u26A0\uFE0F [Lisa.ai Warning] Control Plane is unreachable. Continuing with local CLI defaults (model=${s}, maxRetries=${e}).`);else{let r=i.config;console.log(`[Lisa.ai Agent] Dynamic Config Loaded: Provider=${r.modelProvider}, MaxRetries=${r.maxRetries}`),r.maxRetries<5&&console.warn(`
|
|
150
|
+
\u26A0\uFE0F [Lisa.ai Warning] Your Dashboard Analytics Config has maxRetries set to ${r.maxRetries}. Consider increasing this to 5+ in the WEB UI for complex Angular Healing!`),s=r.modelProvider,e=r.maxRetries,o=r.apiKey,r.autoHealEnabled===!1&&(console.log("[Lisa.ai Agent] Auto-heal is disabled by Control Plane."),process.exit(1))}}let n=$.load(process.cwd());n&&($.applyEnvDefaults(n),!t.projectId&&n.maxRetries!==void 0&&(e=n.maxRetries),!t.projectId&&n.provider&&t.model==="gemini"&&(s=n.provider),$.printSummary(n)),await Y(t.command,s,1,null,e,t.projectId||"local",void 0,o)});W.command("coverage").description("Run test command dynamically generating missing specs for 100% coverage").option("-c, --command <type>","Test command to execute (Optional for Auto-Discovery)").option("-m, --model <provider>","LLM provider to use (gemini, claude, openai)","gemini").option("-p, --project-id <id>","Control Plane Project ID to fetch dynamic config").action(async t=>{fe();let e=5,s=t.model,o;if(t.projectId){let i=await V(t.projectId);if(!i.ok)i.reason==="not_found"?(console.error(`
|
|
146
151
|
\u{1F6A8} [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(`
|
|
147
|
-
\u26A0\uFE0F [Lisa.ai Warning] Control Plane is unreachable. Continuing with local CLI defaults (model=${s}, maxRetries=${e}).`);else{let
|
|
148
|
-
\u26A0\uFE0F [Lisa.ai Warning] Your Dashboard Analytics Config has maxRetries set to ${
|
|
149
|
-
[Lisa.ai Diagnose] Testing ${e} \u2192 model ID: ${n}`);try{let i=await
|
|
152
|
+
\u26A0\uFE0F [Lisa.ai Warning] Control Plane is unreachable. Continuing with local CLI defaults (model=${s}, maxRetries=${e}).`);else{let r=i.config;console.log(`[Lisa.ai Agent] Dynamic Config Loaded: Provider=${r.modelProvider}, MaxRetries=${r.maxRetries}`),r.maxRetries<5&&console.warn(`
|
|
153
|
+
\u26A0\uFE0F [Lisa.ai Warning] Your Dashboard Analytics Config has maxRetries set to ${r.maxRetries}. Consider increasing this to 5+ in the WEB UI for complex Angular Healing!`),s=r.modelProvider,e=r.maxRetries,o=r.apiKey,r.autoHealEnabled===!1&&(console.log("[Lisa.ai Agent] Auto-heal is disabled by Control Plane."),process.exit(1))}}let n=$.load(process.cwd());n&&($.applyEnvDefaults(n),!t.projectId&&n.maxRetries!==void 0&&(e=n.maxRetries),!t.projectId&&n.provider&&t.model==="gemini"&&(s=n.provider),$.printSummary(n)),await K(t.command,s,1,e,t.projectId||"local",o)});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 t=>{fe();let e=t.model,s;if(t.projectId){let i=await V(t.projectId);i.ok?(e=i.config.modelProvider,s=i.config.apiKey,console.log(`[Lisa.ai Diagnose] Config fetched from Control Plane. Provider=${e}`)):console.warn(`[Lisa.ai Diagnose] Control Plane ${i.reason}. Using local env for API key.`)}let n={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(`
|
|
154
|
+
[Lisa.ai Diagnose] Testing ${e} \u2192 model ID: ${n}`);try{let i=await ee("Reply with exactly: LISA_OK",e,s);console.log(`
|
|
150
155
|
\u2705 [Lisa.ai Diagnose] ${e} is working correctly.`),console.log(` Model response: "${i}"`)}catch(i){console.error(`
|
|
151
156
|
\u274C [Lisa.ai Diagnose] ${e} call FAILED.`),console.error(` Error: ${i.message}`),i.cause&&console.error(` Cause: ${i.cause?.message??i.cause}`),console.error(`
|
|
152
|
-
Common causes:`),console.error(" \u2022 API key is invalid, expired, or has no credits"),console.error(" \u2022 Model ID is deprecated (current: claude-sonnet-4-6, gemini-2.0-flash, gpt-4o-mini)"),console.error(" \u2022 Rate limit exceeded \u2014 wait a minute and retry"),console.error(" \u2022 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 t=>{let e=
|
|
153
|
-
\u274C [Lisa.ai Init] ${_} already exists. Use --force to overwrite.`),process.exit(1));let s=
|
|
157
|
+
Common causes:`),console.error(" \u2022 API key is invalid, expired, or has no credits"),console.error(" \u2022 Model ID is deprecated (current: claude-sonnet-4-6, gemini-2.0-flash, gpt-4o-mini)"),console.error(" \u2022 Rate limit exceeded \u2014 wait a minute and retry"),console.error(" \u2022 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 t=>{let e=ze.resolve(process.cwd(),_);ce.existsSync(e)&&!t.force&&(console.error(`
|
|
158
|
+
\u274C [Lisa.ai Init] ${_} already exists. Use --force to overwrite.`),process.exit(1));let s=Ze.createInterface({input:process.stdin,output:process.stdout}),o=(m,d="")=>new Promise(l=>s.question(d?`${m} [${d}]: `:`${m}: `,p=>l(p.trim()||d)));console.log(`
|
|
154
159
|
\u{1F680} Lisa.ai Project Setup \u2014 press Enter to accept the default shown in [ ]
|
|
155
|
-
`);let n=await o("LLM provider (gemini / claude / openai)","gemini"),i=await o("Testing framework (jest / vitest / mocha / karma / cypress / playwright \u2014 leave empty to auto-detect)",""),
|
|
160
|
+
`);let n=await o("LLM provider (gemini / claude / openai)","gemini"),i=await o("Testing framework (jest / vitest / mocha / karma / cypress / playwright \u2014 leave empty to auto-detect)",""),r=await o("Test types to generate (unit / integration / e2e \u2014 comma-separated)","unit"),u=await o("Test command (leave empty for auto-discovery)",""),g=await o("Max heal retries","5");s.close();let f={provider:n,testTypes:r.split(",").map(m=>m.trim()).filter(Boolean),maxRetries:parseInt(g,10)||5,skipFiles:[],skipDirs:[],skipPaths:[]};i&&(f.testingFramework=i),u&&(f.testCommand=u),ce.writeFileSync(e,JSON.stringify(f,null,2)+`
|
|
156
161
|
`,"utf-8"),console.log(`
|
|
157
162
|
\u2705 Created ${_}:
|
|
158
|
-
`),console.log(JSON.stringify(
|
|
163
|
+
`),console.log(JSON.stringify(f,null,2)),console.log(`
|
|
159
164
|
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 coverage analysis.
|
|
160
165
|
`)});W.parse(process.argv);
|