@lisa.ai/agent 2.5.4 → 2.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +66 -65
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var qe=Object.create;var de=Object.defineProperty;var We=Object.getOwnPropertyDescriptor;var ze=Object.getOwnPropertyNames;var Je=Object.getPrototypeOf,Ke=Object.prototype.hasOwnProperty;var Ze=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Ve=(t,e,s,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of ze(e))!Ke.call(t,n)&&n!==s&&de(t,n,{get:()=>e[n],enumerable:!(o=We(e,n))||o.enumerable});return t};var L=(t,e,s)=>(s=t!=null?qe(Je(t)):{},Ve(e||!t||!t.__esModule?de(s,"default",{value:t,enumerable:!0}):s,t));var Ne=Ze((Ht,et)=>{et.exports={name:"@lisa.ai/agent",version:"2.5.4",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 Ue=require("commander"),se=L(require("fs")),He=L(require("path")),Ge=L(require("readline"));var pe=L(require("dotenv"));pe.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 Re=require("child_process"),j=L(require("fs")),_=L(require("path"));var C=L(require("path")),b=L(require("fs"));function J(t,e=[],s=process.cwd()){let o=t.replace(/\x1B\[[0-9;]*[a-zA-Z]/g,""),n=e.map(a=>C.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=C.isAbsolute(a)?a:C.resolve(s,a);if(!n.includes(h)&&b.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=C.isAbsolute(a)?a:C.resolve(s,a);if(!n.includes(h)&&b.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=C.isAbsolute(a)?a:C.resolve(s,a);if(!n.includes(h)&&b.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=ge(a,s,n);if(h)return C.relative(s,h)}}return null}function ge(t,e,s){if(!b.existsSync(e))return null;let o=b.readdirSync(e);for(let n of o){let i=C.join(e,n);if(n==="node_modules"||n==="dist"||n==="build"||n===".git"||n===".angular")continue;let r;try{r=b.statSync(i)}catch{continue}if(r.isDirectory()){let l=ge(t,i,s);if(l)return l}else if(n.match(/\.(ts|tsx|js|jsx|vue)$/)){let l=b.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=C.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(b.existsSync(c)){d=c;break}}if(!s.includes(C.resolve(d)))return d}}}return null}var Y=require("ai"),me=require("@ai-sdk/openai"),fe=require("@ai-sdk/anthropic"),he=require("@ai-sdk/google"),ye=L(require("dotenv"));ye.config({quiet:!0});var ie=15e3;function ve(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)+`
2
+ "use strict";var Je=Object.create;var pe=Object.defineProperty;var Ke=Object.getOwnPropertyDescriptor;var Ze=Object.getOwnPropertyNames;var Ve=Object.getPrototypeOf,Xe=Object.prototype.hasOwnProperty;var Qe=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var et=(t,e,s,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Ze(e))!Xe.call(t,n)&&n!==s&&pe(t,n,{get:()=>e[n],enumerable:!(o=Ke(e,n))||o.enumerable});return t};var v=(t,e,s)=>(s=t!=null?Je(Ve(t)):{},et(e||!t||!t.__esModule?pe(s,"default",{value:t,enumerable:!0}):s,t));var Ue=Qe((qt,ot)=>{ot.exports={name:"@lisa.ai/agent",version:"2.5.6",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 He=require("commander"),se=v(require("fs")),Ge=v(require("path")),Be=v(require("readline"));var ge=v(require("dotenv"));ge.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 De=require("child_process"),b=v(require("fs")),_=v(require("path"));var k=v(require("path")),S=v(require("fs"));function J(t,e=[],s=process.cwd()){let o=t.replace(/\x1B\[[0-9;]*[a-zA-Z]/g,""),n=e.map(r=>k.resolve(r)),i=/([a-zA-Z]:[a-zA-Z0-9_.\-\/\\]+\.(?:ts|tsx|js|jsx|vue)|[a-zA-Z0-9_.\-\/\\]+\.(?:ts|tsx|js|jsx|vue))(?:\s*[:(])/g,a;for(;(a=i.exec(o))!==null;){let r=a[1];if(r){if(/(?:^|[/\\])(node_modules|dist|build)[/\\]/.test(r))continue;let m=k.isAbsolute(r)?r:k.resolve(s,r);if(!n.includes(m)&&S.existsSync(m))return r}}let l=/FAIL\s+([a-zA-Z0-9_.\-\/\\]+\.(?:ts|tsx|js|jsx|vue))/gi,p;for(;(p=l.exec(o))!==null;){let r=p[1],m=k.isAbsolute(r)?r:k.resolve(s,r);if(!n.includes(m)&&S.existsSync(m))return r}let g=/([a-zA-Z]:[a-zA-Z0-9_.\-\/\\]+\.(?:ts|tsx|js|jsx|vue)|[a-zA-Z0-9_.\-\/\\]+\.(?:ts|tsx|js|jsx|vue))/g,f;for(;(f=g.exec(o))!==null;){let r=f[1];if(r){if(/(?:^|[/\\])(node_modules|dist|build)[/\\]/.test(r))continue;let m=k.isAbsolute(r)?r:k.resolve(s,r);if(!n.includes(m)&&S.existsSync(m))return r}}let u=/\b([A-Z][a-zA-Z0-9]{3,})\b/g,c,d=new Set,y=["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=u.exec(o))!==null;){let r=c[1];if(r&&!y.includes(r)&&!d.has(r)){d.add(r),console.log(`[Lisa.ai Parser] Discovered abstract symbol failure: ${r}. Scanning project tree...`);let m=me(r,s,n);if(m)return k.relative(s,m)}}return null}function me(t,e,s){if(!S.existsSync(e))return null;let o=S.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 a;try{a=S.statSync(i)}catch{continue}if(a.isDirectory()){let l=me(t,i,s);if(l)return l}else if(n.match(/\.(ts|tsx|js|jsx|vue)$/)){let l=S.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 p=i,g=k.extname(i),f=i.slice(0,-g.length);if(!n.includes(".spec.")&&!n.includes(".test.")){let u=[`${f}.spec${g}`,`${f}.test${g}`,`${f}.spec.js`,`${f}.test.js`];for(let c of u)if(S.existsSync(c)){p=c;break}}if(!s.includes(k.resolve(p)))return p}}}return null}var Y=require("ai"),fe=require("@ai-sdk/openai"),he=require("@ai-sdk/anthropic"),ye=require("@ai-sdk/google"),ve=v(require("dotenv"));ve.config({quiet:!0});var ie=15e3;function Le(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
- // ... (truncated)`)}function Le(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 we(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:
4
+ // ... (truncated)`)}function we(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 xe(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 K(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,fe.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,me.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,he.createGoogleGenerativeAI)({apiKey:s})(o)}async function xe(t,e,s,o,n,i,r,l){console.log(`[Lisa.ai Auto-Heal] Requesting fix from ${o} for ${t}...`);let d=K(o,n),g=`You are Lisa.ai, an autonomous CI/CD expert platform.
7
+ `}function K(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,he.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,fe.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,ye.createGoogleGenerativeAI)({apiKey:s})(o)}async function Ce(t,e,s,o,n,i,a,l){console.log(`[Lisa.ai Auto-Heal] Requesting fix from ${o} for ${t}...`);let p=K(o,n),g=`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,22 +21,22 @@ 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+)/),u=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(a){if(/standalone\s*:\s*true/.test(a)){let d=a.match(/export class (\w+)/),y=d?d[1]:"the component";g+=`
25
25
 
26
26
  --- CRITICAL ARCHITECTURAL REQUIREMENT ---
27
- The component `+u+` is marked as STANDALONE (standalone: true).
28
- You MUST add `+u+` to the 'imports' array within 'TestBed.configureTestingModule'.
29
- DO NOT add it to the 'declarations' array. If you omit `+u+" from 'imports', the test will fail."}g+=`
27
+ The component `+y+` is marked as STANDALONE (standalone: true).
28
+ You MUST add `+y+` to the 'imports' array within 'TestBed.configureTestingModule'.
29
+ DO NOT add it to the 'declarations' array. If you omit `+y+" from 'imports', the test will fail."}g+=`
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}l&&l.length>0&&(g+=`
34
+ `+a}l&&l.length>0&&(g+=`
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
- `+l.map((c,f)=>`
39
- [Pattern ${f+1}]
38
+ `+l.map((c,d)=>`
39
+ [Pattern ${d+1}]
40
40
  ${c}`).join(`
41
41
  `)),i&&(console.log(`[Lisa.ai Auto-Heal] Warning! Agent is looping on ${t}. Injecting previous failed context...`),g+=`
42
42
 
@@ -45,34 +45,34 @@ 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,Y.generateText)({model:d,prompt:g}),p=m.match(/```(?:typescript|ts|javascript|js)?\n([\s\S]*?)```/);return p?p[1].trim():m.trim()}async function Ce(t,e,s,o,n,i){console.log(`[Lisa.ai Coverage] Requesting test generation from ${s} for ${t}...`);let r=K(s,o),l=n?`3. You MUST use the '${n}' testing framework exclusively. All imports, describe/it/test blocks, and mock utilities must follow '${n}' 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:f}=await(0,Y.generateText)({model:p,prompt:g}),u=f.match(/```(?:typescript|ts|javascript|js)?\n([\s\S]*?)```/);return u?u[1].trim():f.trim()}async function ke(t,e,s,o,n,i){console.log(`[Lisa.ai Coverage] Requesting test generation from ${s} for ${t}...`);let a=K(s,o),l=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
- `,d=we(i),g=`You are Lisa.ai, an autonomous CI/CD expert platform.
50
+ `,p=xe(i),g=`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
- `+ve(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"+l+`4. Aim for 100% logic coverage.
55
- `+d,{text:m}=await(0,Y.generateText)({model:r,prompt:g}),p=m.match(/```(?:typescript|ts|javascript|js)?\n([\s\S]*?)```/),c=p?p[1].trim():m.trim();return Le(c,t),c}async function ke(t,e,s,o,n,i,r,l){console.log(`[Lisa.ai Coverage] Requesting test update from ${n} for ${t}...`);let d=K(n,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
+ `+Le(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"+l+`4. Aim for 100% logic coverage.
55
+ `+p,{text:f}=await(0,Y.generateText)({model:a,prompt:g}),u=f.match(/```(?:typescript|ts|javascript|js)?\n([\s\S]*?)```/),c=u?u[1].trim():f.trim();return we(c,t),c}async function $e(t,e,s,o,n,i,a,l){console.log(`[Lisa.ai Coverage] Requesting test update from ${n} for ${t}...`);let p=K(n,i),g=a?`3. You MUST use the '${a}' testing framework exclusively. All new tests must follow '${a}' 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=we(l),p=`You are Lisa.ai, an autonomous CI/CD expert platform.
57
+ `,f=xe(l),u=`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
- `+ve(e,t)+`
61
+ `+Le(e,t)+`
62
62
 
63
63
  --- Existing Test Suite (`+s+`) ---
64
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"+g+`4. Aim for 100% logic coverage across branches, lines, and functions.
65
- `+m,{text:c}=await(0,Y.generateText)({model:d,prompt:p}),f=c.match(/```(?:typescript|ts|javascript|js)?\n([\s\S]*?)```/),u=f?f[1].trim():c.trim();return Le(u,t),u}async function Z(t,e,s){let o=K(e,s),{text:n}=await(0,Y.generateText)({model:o,prompt:t}),i=n.match(/```(?:typescript|ts|javascript|js)?\n([\s\S]*?)```/);return i?i[1].trim():n.trim()}var $e=L(require("simple-git")),Ae=require("@octokit/rest"),ct=require("dotenv/config");async function je(t){console.log(`
66
- [Lisa.ai PR Engine] Initializing Pull Request for ${t}...`);let e=(0,$e.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 Ae.Octokit({auth:process.env.GITHUB_TOKEN}),l=process.env.GITHUB_REPOSITORY;if(l&&process.env.GITHUB_TOKEN){let[d,g]=l.split("/");console.log(`[Lisa.ai PR Engine] Opening Pull Request against ${d}/${g}...`);let m=await r.rest.pulls.create({owner:d,repo:g,title:n,body:`### Lisa.ai Auto-Healed Pull Request
65
+ `+f,{text:c}=await(0,Y.generateText)({model:p,prompt:u}),d=c.match(/```(?:typescript|ts|javascript|js)?\n([\s\S]*?)```/),y=d?d[1].trim():c.trim();return we(y,t),y}async function Z(t,e,s){let o=K(e,s),{text:n}=await(0,Y.generateText)({model:o,prompt:t}),i=n.match(/```(?:typescript|ts|javascript|js)?\n([\s\S]*?)```/);return i?i[1].trim():n.trim()}var Ae=v(require("simple-git")),je=require("@octokit/rest"),dt=require("dotenv/config");async function be(t){console.log(`
66
+ [Lisa.ai PR Engine] Initializing Pull Request for ${t}...`);let e=(0,Ae.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 a=new je.Octokit({auth:process.env.GITHUB_TOKEN}),l=process.env.GITHUB_REPOSITORY;if(l&&process.env.GITHUB_TOKEN){let[p,g]=l.split("/");console.log(`[Lisa.ai PR Engine] Opening Pull Request against ${p}/${g}...`);let f=await a.rest.pulls.create({owner:p,repo:g,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(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 be=L(require("dotenv"));be.config({quiet:!0});async function R(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 P=L(require("fs")),A=L(require("path"));var V=L(require("fs")),Se=L(require("path")),M=".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=Se.resolve(e,M);if(!V.existsSync(s))return null;try{let o=V.readFileSync(s,"utf-8");return this._config=JSON.parse(o),console.log(`[Lisa.ai Config] Loaded project config from ${M}`),this._config}catch(o){return console.warn(`[Lisa.ai Config] Warning: ${M} 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 O=class{static scanRepository(e=process.cwd()){let s=A.resolve(e,"package.json"),o={type:"unknown",testingFramework:"none"};if(!P.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(P.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(!P.existsSync(e))return o;let n=P.readdirSync(e),i=$.get(),r=i?.skipDirs??[],l=i?.skipFiles??[],d=i?.skipPaths??[],g=["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"],p=[/^\./,/\.config\.(js|ts|mjs|cjs)$/,/\.conf\.(js|ts|mjs|cjs)$/];for(let c of n){let f=A.join(e,c);if(g.includes(c))continue;let u;try{u=P.statSync(f)}catch{continue}if(u.isDirectory())o.push(...this.findUntestedFiles(f,s));else if(c.match(/\.(ts|tsx|js|jsx|vue)$/)&&!c.includes(".spec.")&&!c.includes(".test.")){if(m.includes(c)||l.includes(c)||p.some(y=>y.test(c)))continue;let a=A.extname(c),h=c.slice(0,-a.length);if(![A.join(e,`${h}.spec${a}`),A.join(e,`${h}.test${a}`),A.join(e,`${h}.spec.js`),A.join(e,`${h}.test.js`),A.join(e,`${h}.spec.ts`),A.join(e,`${h}.test.ts`)].some(y=>P.existsSync(y))){let y=A.relative(process.cwd(),f);if(d.some(S=>y.startsWith(S)))continue;s.includes(y)||o.push(y)}}}return o}};var Pe=require("child_process"),U=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,Pe.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 X=L(require("fs")),re=L(require("path"));var H=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(d=>X.existsSync(re.join(n,d)))){console.log("[Lisa.ai Auto-Generator] Setup file detected. Bypassing initialization.");return}let l=`You are an expert ${e.type} architect.
71
+ Please review the changes.`,head:o,base:i});console.log(`\u2705 [Lisa.ai PR Engine] Pull Request created successfully: ${f.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(a){console.error(`
72
+ \u{1F6A8} [Lisa.ai PR Engine Error] Failed to create Pull Request:`,a.message)}finally{try{await e.checkout(i)}catch{}}}var Se=v(require("dotenv"));Se.config({quiet:!0});async function R(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 E=v(require("fs")),j=v(require("path"));var V=v(require("fs")),Pe=v(require("path")),M=".lisai.json",x=class{static _config=null;static _loaded=!1;static load(e=process.cwd()){if(this._loaded)return this._config;this._loaded=!0;let s=Pe.resolve(e,M);if(!V.existsSync(s))return null;try{let o=V.readFileSync(s,"utf-8");return this._config=JSON.parse(o),console.log(`[Lisa.ai Config] Loaded project config from ${M}`),this._config}catch(o){return console.warn(`[Lisa.ai Config] Warning: ${M} 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 O=class{static scanRepository(e=process.cwd()){let s=j.resolve(e,"package.json"),o={type:"unknown",testingFramework:"none"};if(!E.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(E.readFileSync(s,"utf8")),i={...n.dependencies||{},...n.devDependencies||{}},a=n.scripts||{};return i["@angular/core"]?o.type="angular":i.react?o.type="react":i.vue?o.type="vue":o.type="node",i.jest||a.test?.includes("jest")?o.testingFramework="jest":i.karma||a.test?.includes("karma")||a.test?.includes("ng test")?o.testingFramework="karma":(i.vitest||a.test?.includes("vitest"))&&(o.testingFramework="vitest"),o.testingFramework!=="none"&&(a.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(!E.existsSync(e))return o;let n=E.readdirSync(e),i=x.get(),a=i?.skipDirs??[],l=i?.skipFiles??[],p=i?.skipPaths??[],g=["node_modules","dist","build",".git",".angular","coverage","public","assets",...a],f=["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"],u=[/^\./,/\.config\.(js|ts|mjs|cjs)$/,/\.conf\.(js|ts|mjs|cjs)$/];for(let c of n){let d=j.join(e,c);if(g.includes(c))continue;let y;try{y=E.statSync(d)}catch{continue}if(y.isDirectory())o.push(...this.findUntestedFiles(d,s));else if(c.match(/\.(ts|tsx|js|jsx|vue)$/)&&!c.includes(".spec.")&&!c.includes(".test.")){if(f.includes(c)||l.includes(c)||u.some(h=>h.test(c)))continue;let r=j.extname(c),m=c.slice(0,-r.length);if(![j.join(e,`${m}.spec${r}`),j.join(e,`${m}.test${r}`),j.join(e,`${m}.spec.js`),j.join(e,`${m}.test.js`),j.join(e,`${m}.spec.ts`),j.join(e,`${m}.test.ts`)].some(h=>E.existsSync(h))){let h=j.relative(process.cwd(),d);if(p.some(w=>h.startsWith(w)))continue;s.includes(h)||o.push(h)}}}return o}};var Ee=require("child_process"),U=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(" "),a=process.platform==="win32"?`${i[0]}.cmd`:i[0];return(0,Ee.spawnSync)(a,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 X=v(require("fs")),re=v(require("path"));var H=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(p=>X.existsSync(re.join(n,p)))){console.log("[Lisa.ai Auto-Generator] Setup file detected. Bypassing initialization.");return}let l=`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,76 +80,77 @@ 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 d=await Z(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 Ee=L(require("dotenv"));Ee.config({quiet:!0});function Te(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 Ie(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 Fe(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 Xe(t){let e=t.replace(/\.(spec|test)\.(ts|js|jsx|tsx)$/,".$2");if(e!==t&&j.existsSync(e))try{return console.log(`[Lisa.ai Context Engine] \u{1F9E0} Located sibling logic structure at ${e}`),j.readFileSync(e,"utf-8")}catch{return}}function Qe(t,e){let s=t.toLowerCase(),o=_.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=_.resolve(process.cwd(),"package.json");if(j.existsSync(i)){let r=JSON.parse(j.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 G(t,e,s=1,o=null,n=3,i="local",r,l,d=[],g=0,m={}){if(!t){console.log(`
85
- [Lisa.ai Auto-Discovery] No explicit --command provided. Initiating Autonomous Framework Fingerprinting...`);let c=O.scanRepository();c.testingFramework==="none"&&(c=await U.installMissingFramework(c),await H.provisionConfigurationFiles(c,e,l)),c.suggestedTestCommand?(t=c.suggestedTestCommand,console.log(`[Lisa.ai Auto-Discovery] Bootstrapping execution with natively discovered command: ${t}`)):(console.error(`
83
+ 4. Return ONLY the raw code string block.`;try{let p=await Z(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 f=re.join(n,g);X.writeFileSync(f,p,"utf-8"),console.log(`\u2705 [Lisa.ai Auto-Generator] Natively wrote ${g} to repository root.`)}catch(p){console.error(`
84
+ \u274C [Lisa.ai Auto-Generator] Failed to author configuration file: ${p.message}`),process.exit(1)}}};var Te=v(require("dotenv"));Te.config({quiet:!0});function Ie(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 Fe(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 Re(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 tt(t){let e=t.replace(/\.(spec|test)\.(ts|js|jsx|tsx)$/,".$2");if(e!==t&&b.existsSync(e))try{return console.log(`[Lisa.ai Context Engine] \u{1F9E0} Located sibling logic structure at ${e}`),b.readFileSync(e,"utf-8")}catch{return}}function st(t,e){let s=t.toLowerCase(),o=_.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=_.resolve(process.cwd(),"package.json");if(b.existsSync(i)){let a=JSON.parse(b.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 p=a.scripts?.[l]?.toLowerCase()||"",g=s.includes("npm")?" --":"";if(p.includes("ng test")||p.includes("karma"))return`${t}${g} --include **/${o.base}`;if(p.includes("jest")||p.includes("vitest")||p.includes("playwright"))return`${t}${g} ${e}`}}catch{}let n=s.includes("npm")?" --":"";return`${t}${n} ${e}`}return t}async function G(t,e,s=1,o=null,n=3,i="local",a,l,p=[],g=0,f={}){let u=x.load(process.cwd());if(u&&(x.applyEnvDefaults(u),!t&&u.testCommand&&(t=u.testCommand,console.log(`[Lisa.ai Config] Using testCommand from .lisai.json: ${t}`))),!t){console.log(`
85
+ [Lisa.ai Auto-Discovery] No explicit --command provided. Initiating Autonomous Framework Fingerprinting...`);let d=O.scanRepository();d.testingFramework==="none"&&(d=await U.installMissingFramework(d),await H.provisionConfigurationFiles(d,e,l)),d.suggestedTestCommand?(t=d.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
- [Lisa.ai Executing] ${t} (Global Engine) Using Model: ${e}`);let p=(c,f=!1)=>new Promise((u,a)=>{let h=(0,Re.spawn)(c,{shell:!0,stdio:["ignore","pipe","pipe"]}),w="",v="";h.stdout?.on("data",y=>{let S=y.toString();w+=S}),h.stderr?.on("data",y=>{v+=y.toString()}),h.on("close",y=>{y===0?u({stdout:w,stderr:v}):a({message:`Process exited with code ${y}`,stdout:w,stderr:v})})});try{console.log("\u23F3 [Lisa.ai Testing] Booting Headless Test Suite in background..."),await p(t,!1),console.log(`
88
- \u2705 [Lisa.ai Success] Global Command executed successfully.`),o&&await je(o);return}catch(c){console.log(`
89
- \u274C [Lisa.ai Failure] Global Command failed.`);let f=(c.stderr||"")+`
90
- `+(c.stdout||"")+`
91
- `+(c.message||"");console.log(`
92
- [Lisa.ai Auto-Heal] Analyzing errors...`);let u=J(f,d,process.cwd());u||(console.error(`
93
- \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 a=_.resolve(process.cwd(),u);j.existsSync(a)||(console.error(`
94
- \u{1F6A8} [Lisa.ai Error] Extracted file path does not exist: ${a}`),process.exit(1));let h=m[u]||0;if(h>=Q){console.warn(`
95
- [Lisa.ai Auto-Heal] \u26A0\uFE0F ${u} has failed globally ${h} time(s) \u2014 exceeds threshold of ${Q}. Permanently skipping.`),d.push(u),await G(t,e,1,null,n,i,void 0,l,d,0,m);return}console.log(`[Lisa.ai Auto-Heal] Identified bleeding file: ${u} (global fail count: ${h}/${Q})`);let w=1,v=!1,y=f,S,E="",x="",T=Qe(t,u),oe=Xe(a),W=Te(t),ne=(await Ie(f,W,i)).filter(I=>I.confidence>=.5).map(I=>I.fixHint);for(ne.length>0&&console.log(`[Lisa.ai Memory] Found ${ne.length} proven fix pattern(s) from Control Plane \u2014 injecting as LLM hint.`),await R({projectId:i,type:"heal",filePath:u,modelUsed:e,status:"running",details:"Agent is currently analyzing and applying patches..."});w<=n&&!v;){console.log(`
96
- [Lisa.ai Micro-Heal] Isolating ${u} (Attempt ${w}/${n})`);let I=j.readFileSync(a,"utf-8"),N=await xe(u,I,y,e,l,S,oe,ne);j.writeFileSync(a,N,"utf-8"),console.log(`[Lisa.ai Micro-Heal] Applied isolated patch to ${u}`),E=`### Auto-Heal Analysis Triggered
87
+ [Lisa.ai Executing] ${t} (Global Engine) Using Model: ${e}`);let c=(d,y=!1)=>new Promise((r,m)=>{let $=(0,De.spawn)(d,{shell:!0,stdio:["ignore","pipe","pipe"]}),L="",h="";$.stdout?.on("data",w=>{let P=w.toString();L+=P}),$.stderr?.on("data",w=>{h+=w.toString()}),$.on("close",w=>{w===0?r({stdout:L,stderr:h}):m({message:`Process exited with code ${w}`,stdout:L,stderr:h})})});try{console.log("\u23F3 [Lisa.ai Testing] Booting Headless Test Suite in background..."),await c(t,!1),console.log(`
88
+ \u2705 [Lisa.ai Success] Global Command executed successfully.`),o&&await be(o);return}catch(d){console.log(`
89
+ \u274C [Lisa.ai Failure] Global Command failed.`);let y=(d.stderr||"")+`
90
+ `+(d.stdout||"")+`
91
+ `+(d.message||"");console.log(`
92
+ [Lisa.ai Auto-Heal] Analyzing errors...`);let r=J(y,p,process.cwd());r||(console.error(`
93
+ \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 m=_.resolve(process.cwd(),r);b.existsSync(m)||(console.error(`
94
+ \u{1F6A8} [Lisa.ai Error] Extracted file path does not exist: ${m}`),process.exit(1)),/[\\/](node_modules|dist|build)[\\/]/.test(m)&&(console.error(`
95
+ \u{1F6A8} [Lisa.ai Error] Refusing to modify a library file outside the project source: ${m}`),process.exit(1));let $=f[r]||0;if($>=Q){console.warn(`
96
+ [Lisa.ai Auto-Heal] \u26A0\uFE0F ${r} has failed globally ${$} time(s) \u2014 exceeds threshold of ${Q}. Permanently skipping.`),p.push(r),await G(t,e,1,null,n,i,void 0,l,p,0,f);return}console.log(`[Lisa.ai Auto-Heal] Identified bleeding file: ${r} (global fail count: ${$}/${Q})`);let L=1,h=!1,w=y,P,C="",T="",W=st(t,r),oe=tt(m),le=Ie(t),ne=(await Fe(y,le,i)).filter(I=>I.confidence>=.5).map(I=>I.fixHint);for(ne.length>0&&console.log(`[Lisa.ai Memory] Found ${ne.length} proven fix pattern(s) from Control Plane \u2014 injecting as LLM hint.`),await R({projectId:i,type:"heal",filePath:r,modelUsed:e,status:"running",details:"Agent is currently analyzing and applying patches..."});L<=n&&!h;){console.log(`
97
+ [Lisa.ai Micro-Heal] Isolating ${r} (Attempt ${L}/${n})`);let I=b.readFileSync(m,"utf-8"),N=await Ce(r,I,w,e,l,P,oe,ne);b.writeFileSync(m,N,"utf-8"),console.log(`[Lisa.ai Micro-Heal] Applied isolated patch to ${r}`),C=`### Auto-Heal Analysis Triggered
97
98
  **Caught Error:**
98
99
  \`\`\`bash
99
- ${y}
100
+ ${w}
100
101
  \`\`\`
101
102
 
102
103
  **Applied Fix (${e}):**
103
104
  \`\`\`typescript
104
105
  ${N}
105
- \`\`\``;try{console.log(`[Lisa.ai Micro-Heal] Verifying fix with isolated command: ${T}`),await p(T,!1),console.log(`\u2705 [Lisa.ai Micro-Heal] Isolated verification passed for ${u}!`),v=!0,x=N}catch(F){console.log("\u274C [Lisa.ai Micro-Heal] Isolated verification failed.");let le=F.stdout?F.stdout.toString():"";y=(F.stderr?F.stderr.toString():"")+`
106
- `+le+`
107
- `+(F.message||"");let ue=(t||"").toLowerCase();if(ue.includes("ng test")||ue.includes("karma")){let Ye=_.basename(u);if(!y.includes(Ye+":")){console.log(`\u2705 [Lisa.ai Micro-Heal] Fix verified for ${u} \u2014 isolated error is from other spec files, not this one.`),v=!0,x=N;continue}}S=`### Attempt ${w} Failed
106
+ \`\`\``;try{console.log(`[Lisa.ai Micro-Heal] Verifying fix with isolated command: ${W}`),await c(W,!1),console.log(`\u2705 [Lisa.ai Micro-Heal] Isolated verification passed for ${r}!`),h=!0,T=N}catch(F){console.log("\u274C [Lisa.ai Micro-Heal] Isolated verification failed.");let ue=F.stdout?F.stdout.toString():"";w=(F.stderr?F.stderr.toString():"")+`
107
+ `+ue+`
108
+ `+(F.message||"");let de=(t||"").toLowerCase();if(de.includes("ng test")||de.includes("karma")){let qe=_.basename(r),We=w.includes(qe+":"),ze=/ FAILED/.test(w);if(!We&&!ze){console.log(`\u2705 [Lisa.ai Micro-Heal] Fix verified for ${r} \u2014 isolated error is from other spec files, not this one.`),h=!0,T=N;continue}}P=`### Attempt ${L} Failed
108
109
  \`\`\`typescript
109
110
  ${N}
110
111
  \`\`\`
111
112
 
112
113
  **New Error:**
113
- ${y}`,w++}}if(v)await R({projectId:i,type:"heal",filePath:u,modelUsed:e,status:"success",details:E}),await Fe(f,x,W,i);else if(console.warn(`
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 R({projectId:i,type:"heal",filePath:u,modelUsed:e,status:"error",details:`Agent exhausted all ${n} attempts without success.
114
+ ${w}`,L++}}if(h)await R({projectId:i,type:"heal",filePath:r,modelUsed:e,status:"success",details:C}),await Re(y,T,le,i);else if(console.warn(`
115
+ [Lisa.ai Auto-Heal] \u26A0\uFE0F Agent failed to locally heal ${r} after ${n} isolated attempts. Marking as Skipped to avoid infinite Loop.`),await R({projectId:i,type:"heal",filePath:r,modelUsed:e,status:"error",details:`Agent exhausted all ${n} attempts without success.
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 I=(t||"").toLowerCase();if(I.includes("ng test")||I.includes("karma"))try{j.writeFileSync(a,`// Quarantined by Lisa.ai \u2014 could not be automatically healed
117
+ `+C}),f[r]=(f[r]||0)+1,console.log(`[Lisa.ai Auto-Heal] Global fail counter for ${r}: ${f[r]}/${Q}`),p.push(r),r.match(/\.(spec|test)\.(ts|js|tsx|jsx|vue)$/)){let I=(t||"").toLowerCase();if(I.includes("ng test")||I.includes("karma"))try{b.writeFileSync(m,`// Quarantined by Lisa.ai \u2014 could not be automatically healed
117
118
  describe('', () => {});
118
- `,"utf-8"),console.log(`[Lisa.ai Auto-Heal] \u{1F6A8} Quarantined unhealable spec ${u} \u2014 replaced with empty stub to keep Angular build clean.`)}catch{}else{let F=a+".broken";try{j.renameSync(a,F),console.log(`[Lisa.ai Auto-Heal] \u{1F6A8} Renamed unhealable spec to ${u}.broken to force the test runner to bypass it!`)}catch{}}}await G(t,e,1,v?u:null,n,i,void 0,l,d,0,m)}}var _e=require("child_process"),D=L(require("fs")),k=L(require("path"));var ee=L(require("fs")),De=L(require("path"));function Me(t){let e=De.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 Oe=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=O.scanRepository(),d=r?.testingFramework||(l.testingFramework!=="none"?l.testingFramework:void 0),g=r?.testTypes;if(!t){console.log(`
119
- [Lisa.ai Auto-Discovery] No explicit --command provided. Initiating Autonomous Framework Fingerprinting...`);let p=l;if(p.testingFramework==="none"&&(p=await U.installMissingFramework(p),await H.provisionConfigurationFiles(p,e,i)),p.suggestedTestCommand){t=p.suggestedTestCommand;let c=p.testingFramework;(c==="jest"||c==="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(`
119
+ `,"utf-8"),console.log(`[Lisa.ai Auto-Heal] \u{1F6A8} Quarantined unhealable spec ${r} \u2014 replaced with empty stub to keep Angular build clean.`)}catch{}else{let F=m+".broken";try{b.renameSync(m,F),console.log(`[Lisa.ai Auto-Heal] \u{1F6A8} Renamed unhealable spec to ${r}.broken to force the test runner to bypass it!`)}catch{}}}await G(t,e,1,h?r:null,n,i,void 0,l,p,0,f)}}var Ne=require("child_process"),D=v(require("fs")),A=v(require("path"));var ee=v(require("fs")),Me=v(require("path"));function Oe(t){let e=Me.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,a]of Object.entries(o))i!=="total"&&(a.lines.pct<100||a.statements.pct<100||a.functions.pct<100||a.branches.pct<100)&&n.push(i);return n}var _e=new Set,te=0,ae=3;async function q(t,e,s=1,o=3,n="local",i){let a=x.load(process.cwd());a&&(x.applyEnvDefaults(a),!t&&a.testCommand&&(t=a.testCommand,console.log(`[Lisa.ai Config] Using testCommand from .lisai.json: ${t}`)));let l=O.scanRepository(),p=a?.testingFramework||(l.testingFramework!=="none"?l.testingFramework:void 0),g=a?.testTypes;if(!t){console.log(`
120
+ [Lisa.ai Auto-Discovery] No explicit --command provided. Initiating Autonomous Framework Fingerprinting...`);let u=l;if(u.testingFramework==="none"&&(u=await U.installMissingFramework(u),await H.provisionConfigurationFiles(u,e,i)),u.suggestedTestCommand){t=u.suggestedTestCommand;let c=u.testingFramework;(c==="jest"||c==="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(`
120
121
  \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(`
121
- [Lisa.ai Coverage] ${t} (Attempt ${s}/${o}) Using Model: ${e}`),await R({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=(p,c=!1)=>new Promise((f,u)=>{let a=(0,_e.spawn)(p,{shell:!0,stdio:["ignore","pipe","pipe"]}),h="",w="";a.stdout?.on("data",v=>{let y=v.toString();if(h+=y,c){let S=y.split(`
122
- `);for(let E of S){let x=E.match(/Executed\s+(\d+)\s+of\s+(\d+)/);if(x){let T=E.match(/(\d+)\s+FAILED/),oe=T?T[1]:0,W=`\r\u23F3 [Lisa.ai Testing] Executed ${x[1]} of ${x[2]} (${oe} FAILED) `;process.stdout.write(W)}}}}),a.stderr?.on("data",v=>{w+=v.toString()}),a.on("close",v=>{v===0?f():u({message:`Test process exited with code ${v}`,stdout:h,stderr:w})})});try{console.log("[Lisa.ai Coverage] Booting testing framework in the background. This may take a moment..."),await m(t,!0),console.log(`
123
- \u2705 [Lisa.ai Coverage] Tests passed successfully on attempt ${s}.`)}catch(p){let c=(p.stderr||"")+`
124
- `+(p.stdout||"")+`
125
- `+(p.message||"");if(J(c,[],process.cwd())!==null){console.log(`
122
+ [Lisa.ai Coverage] ${t} (Attempt ${s}/${o}) Using Model: ${e}`),await R({projectId:n,type:"coverage",filePath:"global-test-suite",modelUsed:e,status:"running",details:"Agent is currently executing testing suite and validating coverage drops..."});let f=(u,c=!1)=>new Promise((d,y)=>{let r=(0,Ne.spawn)(u,{shell:!0,stdio:["ignore","pipe","pipe"]}),m="",$="";r.stdout?.on("data",L=>{let h=L.toString();if(m+=h,c){let w=h.split(`
123
+ `);for(let P of w){let C=P.match(/Executed\s+(\d+)\s+of\s+(\d+)/);if(C){let T=P.match(/(\d+)\s+FAILED/),W=T?T[1]:0,oe=`\r\u23F3 [Lisa.ai Testing] Executed ${C[1]} of ${C[2]} (${W} FAILED) `;process.stdout.write(oe)}}}}),r.stderr?.on("data",L=>{$+=L.toString()}),r.on("close",L=>{L===0?d():y({message:`Test process exited with code ${L}`,stdout:m,stderr:$})})});try{console.log("[Lisa.ai Coverage] Booting testing framework in the background. This may take a moment..."),await f(t,!0),console.log(`
124
+ \u2705 [Lisa.ai Coverage] Tests passed successfully on attempt ${s}.`)}catch(u){let c=(u.stderr||"")+`
125
+ `+(u.stdout||"")+`
126
+ `+(u.message||"");if(J(c,[],process.cwd())!==null){console.log(`
126
127
  \u274C [Lisa.ai Coverage] Tests failed. Delegating to Auto-Heal...`),await G(t,e,1,null,o,n,void 0,i),console.log(`
127
128
  \u{1F504} [Lisa.ai Coverage] Auto-Heal successful. Restarting coverage analysis...`),await q(t,e,s+1,o,n,i);return}console.log(`
128
- [Lisa.ai Coverage] No failing spec file detected in error output. Tests may not exist yet \u2014 initiating Cold-Start Discovery...`)}try{let p=k.resolve(process.cwd(),"coverage/coverage-summary.json"),c=[];if(D.existsSync(p))console.log("[Lisa.ai Coverage] Evaluating summary..."),c=Me("coverage/coverage-summary.json");else{if(console.log(`
129
- [Lisa.ai Coverage] No coverage-summary.json found. Initiating Cold-Start Project Crawler...`),c=O.findUntestedFiles(process.cwd(),[...Oe]),c.length===0){console.log("\u2705 [Lisa.ai Coverage] Zero-Test scan complete. No untested source files discovered.");return}console.log(`[Lisa.ai Coverage] Discovered ${c.length} untested file(s). Seeding first test suite...`)}if(c.length===0){console.log("\u2705 [Lisa.ai Coverage] 100% Logic Coverage Verified! No un-covered files remaining.");return}console.log(`[Lisa.ai Coverage] Found ${c.length} file(s) below 100% threshold:`,c);let f=c[0],u=k.resolve(process.cwd(),f),a=k.parse(u),h=[k.join(a.dir,`${a.name}.spec${a.ext}`),k.join(a.dir,`${a.name}.test${a.ext}`),k.join(a.dir,`${a.name}.spec.js`),k.join(a.dir,`${a.name}.test.js`),k.join(a.dir,`${a.name}.spec.ts`),k.join(a.dir,`${a.name}.test.ts`)],w=null,v=k.join(a.dir,`${a.name}.spec${a.ext}`);for(let x of h)if(D.existsSync(x)){v=x,w=D.readFileSync(x,"utf-8");break}let y="",S=!1,E=D.readFileSync(u,"utf-8");try{w?(console.log(`[Lisa.ai Coverage] Existing test suite discovered for ${f}. Requesting single-pass logic coverage append...`),y=await ke(f,E,k.relative(process.cwd(),v),w,e,i,d,g)):(console.log(`[Lisa.ai Coverage] Requesting newly generated test suite for ${f}...`),y=await Ce(f,E,e,i,d,g)),te=0,S=!0}catch(x){te++,Oe.add(f);let T=x.cause?.message?`${x.message} (cause: ${x.cause.message})`:x.message;if(console.error(`
130
- \u274C [Lisa.ai Coverage] LLM call failed for ${f} \u2014 consecutive failure #${te}/${ae}`),console.error(` Error: ${T}`),te>=ae)throw new Error(`Systematic LLM failure: ${ae} consecutive API calls failed.
129
+ [Lisa.ai Coverage] No failing spec file detected in error output. Tests may not exist yet \u2014 initiating Cold-Start Discovery...`)}try{let u=A.resolve(process.cwd(),"coverage/coverage-summary.json"),c=[];if(D.existsSync(u))console.log("[Lisa.ai Coverage] Evaluating summary..."),c=Oe("coverage/coverage-summary.json");else{if(console.log(`
130
+ [Lisa.ai Coverage] No coverage-summary.json found. Initiating Cold-Start Project Crawler...`),c=O.findUntestedFiles(process.cwd(),[..._e]),c.length===0){console.log("\u2705 [Lisa.ai Coverage] Zero-Test scan complete. No untested source files discovered.");return}console.log(`[Lisa.ai Coverage] Discovered ${c.length} untested file(s). Seeding first test suite...`)}if(c.length===0){console.log("\u2705 [Lisa.ai Coverage] 100% Logic Coverage Verified! No un-covered files remaining.");return}console.log(`[Lisa.ai Coverage] Found ${c.length} file(s) below 100% threshold:`,c);let d=c[0],y=A.resolve(process.cwd(),d),r=A.parse(y),m=[A.join(r.dir,`${r.name}.spec${r.ext}`),A.join(r.dir,`${r.name}.test${r.ext}`),A.join(r.dir,`${r.name}.spec.js`),A.join(r.dir,`${r.name}.test.js`),A.join(r.dir,`${r.name}.spec.ts`),A.join(r.dir,`${r.name}.test.ts`)],$=null,L=A.join(r.dir,`${r.name}.spec${r.ext}`);for(let C of m)if(D.existsSync(C)){L=C,$=D.readFileSync(C,"utf-8");break}let h="",w=!1,P=D.readFileSync(y,"utf-8");try{$?(console.log(`[Lisa.ai Coverage] Existing test suite discovered for ${d}. Requesting single-pass logic coverage append...`),h=await $e(d,P,A.relative(process.cwd(),L),$,e,i,p,g)):(console.log(`[Lisa.ai Coverage] Requesting newly generated test suite for ${d}...`),h=await ke(d,P,e,i,p,g)),te=0,w=!0}catch(C){te++,_e.add(d);let T=C.cause?.message?`${C.message} (cause: ${C.cause.message})`:C.message;if(console.error(`
131
+ \u274C [Lisa.ai Coverage] LLM call failed for ${d} \u2014 consecutive failure #${te}/${ae}`),console.error(` Error: ${T}`),te>=ae)throw new Error(`Systematic LLM failure: ${ae} consecutive API calls failed.
131
132
  This usually means your API key has insufficient credits, hit a rate limit, or the model is unavailable.
132
133
  Last error: ${T}
133
- Tip: Check your API key, account credits, and rate-limit quota for provider '${e}'.`)}if(!S){await q(t,e,s+1,o,n,i);return}D.writeFileSync(v,y,"utf-8"),console.log(`[Lisa.ai Coverage] Wrote Spec File to ${v}`),await R({projectId:n,type:"coverage",filePath:f,modelUsed:e,status:"success",details:`### Logic Coverage Action Detected
134
+ Tip: Check your API key, account credits, and rate-limit quota for provider '${e}'.`)}if(!w){await q(t,e,s+1,o,n,i);return}D.writeFileSync(L,h,"utf-8"),console.log(`[Lisa.ai Coverage] Wrote Spec File to ${L}`),await R({projectId:n,type:"coverage",filePath:d,modelUsed:e,status:"success",details:`### Logic Coverage Action Detected
134
135
  **Auto-Generated Specification Append (${e}):**
135
136
  \`\`\`typescript
136
- ${y}
137
- \`\`\``}),await q(t,e,s+1,o,n,i)}catch(p){console.error("[Lisa.ai Coverage loop failure]:",p.message),await R({projectId:n,type:"coverage",filePath:"coverage-loop",modelUsed:e,status:"error",details:`Coverage loop encountered an unrecoverable error: ${p.message}`})}}var Be=Ne();function ce(){console.log(`
138
- ======================================================`),console.log(`\u2728 Lisa.ai Agent v${Be.version} Running... `),console.log(" Where pure magic happens! \u{1FA84}"),console.log(`======================================================
139
- `)}var B=new Ue.Command;B.name("lisa-agent").description("Lisa.ai - Autonomous CI/CD Platform Worker Agent").version(Be.version);B.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=>{ce();let e=5,s=t.model,o;if(t.projectId){let i=await z(t.projectId);if(!i.ok)i.reason==="not_found"?(console.error(`
137
+ ${h}
138
+ \`\`\``}),await q(t,e,s+1,o,n,i)}catch(u){console.error("[Lisa.ai Coverage loop failure]:",u.message),await R({projectId:n,type:"coverage",filePath:"coverage-loop",modelUsed:e,status:"error",details:`Coverage loop encountered an unrecoverable error: ${u.message}`})}}var Ye=Ue();function ce(){console.log(`
139
+ ======================================================`),console.log(`\u2728 Lisa.ai Agent v${Ye.version} Running... `),console.log(" Where pure magic happens! \u{1FA84}"),console.log(`======================================================
140
+ `)}var B=new He.Command;B.name("lisa-agent").description("Lisa.ai - Autonomous CI/CD Platform Worker Agent").version(Ye.version);B.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=>{ce();let e=5,s=t.model,o;if(t.projectId){let i=await z(t.projectId);if(!i.ok)i.reason==="not_found"?(console.error(`
140
141
  \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(`
141
- \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(`
142
- \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 G(t.command,s,1,null,e,t.projectId||"local",void 0,o)});B.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=>{ce();let e=5,s=t.model,o;if(t.projectId){let i=await z(t.projectId);if(!i.ok)i.reason==="not_found"?(console.error(`
142
+ \u26A0\uFE0F [Lisa.ai Warning] Control Plane is unreachable. Continuing with local CLI defaults (model=${s}, maxRetries=${e}).`);else{let a=i.config;console.log(`[Lisa.ai Agent] Dynamic Config Loaded: Provider=${a.modelProvider}, MaxRetries=${a.maxRetries}`),a.maxRetries<5&&console.warn(`
143
+ \u26A0\uFE0F [Lisa.ai Warning] Your Dashboard Analytics Config has maxRetries set to ${a.maxRetries}. Consider increasing this to 5+ in the WEB UI for complex Angular Healing!`),s=a.modelProvider,e=a.maxRetries,o=a.apiKey,a.autoHealEnabled===!1&&(console.log("[Lisa.ai Agent] Auto-heal is disabled by Control Plane."),process.exit(1))}}let n=x.load(process.cwd());n&&(x.applyEnvDefaults(n),!t.projectId&&n.maxRetries!==void 0&&(e=n.maxRetries),!t.projectId&&n.provider&&t.model==="gemini"&&(s=n.provider),x.printSummary(n)),await G(t.command,s,1,null,e,t.projectId||"local",void 0,o)});B.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=>{ce();let e=5,s=t.model,o;if(t.projectId){let i=await z(t.projectId);if(!i.ok)i.reason==="not_found"?(console.error(`
143
144
  \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 r=i.config;console.log(`[Lisa.ai Agent] Dynamic Config Loaded: Provider=${r.modelProvider}, MaxRetries=${r.maxRetries}`),r.maxRetries<5&&console.warn(`
145
- \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 q(t.command,s,1,e,t.projectId||"local",o)});B.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=>{ce();let e=t.model,s;if(t.projectId){let i=await z(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(`
145
+ \u26A0\uFE0F [Lisa.ai Warning] Control Plane is unreachable. Continuing with local CLI defaults (model=${s}, maxRetries=${e}).`);else{let a=i.config;console.log(`[Lisa.ai Agent] Dynamic Config Loaded: Provider=${a.modelProvider}, MaxRetries=${a.maxRetries}`),a.maxRetries<5&&console.warn(`
146
+ \u26A0\uFE0F [Lisa.ai Warning] Your Dashboard Analytics Config has maxRetries set to ${a.maxRetries}. Consider increasing this to 5+ in the WEB UI for complex Angular Healing!`),s=a.modelProvider,e=a.maxRetries,o=a.apiKey,a.autoHealEnabled===!1&&(console.log("[Lisa.ai Agent] Auto-heal is disabled by Control Plane."),process.exit(1))}}let n=x.load(process.cwd());n&&(x.applyEnvDefaults(n),!t.projectId&&n.maxRetries!==void 0&&(e=n.maxRetries),!t.projectId&&n.provider&&t.model==="gemini"&&(s=n.provider),x.printSummary(n)),await q(t.command,s,1,e,t.projectId||"local",o)});B.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=>{ce();let e=t.model,s;if(t.projectId){let i=await z(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(`
146
147
  [Lisa.ai Diagnose] Testing ${e} \u2192 model ID: ${n}`);try{let i=await Z("Reply with exactly: LISA_OK",e,s);console.log(`
147
148
  \u2705 [Lisa.ai Diagnose] ${e} is working correctly.`),console.log(` Model response: "${i}"`)}catch(i){console.error(`
148
149
  \u274C [Lisa.ai Diagnose] ${e} call FAILED.`),console.error(` Error: ${i.message}`),i.cause&&console.error(` Cause: ${i.cause?.message??i.cause}`),console.error(`
149
- 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)}});B.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=He.resolve(process.cwd(),M);se.existsSync(e)&&!t.force&&(console.error(`
150
- \u274C [Lisa.ai Init] ${M} already exists. Use --force to overwrite.`),process.exit(1));let s=Ge.createInterface({input:process.stdin,output:process.stdout}),o=(m,p="")=>new Promise(c=>s.question(p?`${m} [${p}]: `:`${m}: `,f=>c(f.trim()||p)));console.log(`
150
+ 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)}});B.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=Ge.resolve(process.cwd(),M);se.existsSync(e)&&!t.force&&(console.error(`
151
+ \u274C [Lisa.ai Init] ${M} already exists. Use --force to overwrite.`),process.exit(1));let s=Be.createInterface({input:process.stdin,output:process.stdout}),o=(f,u="")=>new Promise(c=>s.question(u?`${f} [${u}]: `:`${f}: `,d=>c(d.trim()||u)));console.log(`
151
152
  \u{1F680} Lisa.ai Project Setup \u2014 press Enter to accept the default shown in [ ]
152
- `);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"),l=await o("Test command (leave empty for auto-discovery)",""),d=await o("Max heal retries","5");s.close();let g={provider:n,testTypes:r.split(",").map(m=>m.trim()).filter(Boolean),maxRetries:parseInt(d,10)||5,skipFiles:[],skipDirs:[],skipPaths:[]};i&&(g.testingFramework=i),l&&(g.testCommand=l),se.writeFileSync(e,JSON.stringify(g,null,2)+`
153
+ `);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)",""),a=await o("Test types to generate (unit / integration / e2e \u2014 comma-separated)","unit"),l=await o("Test command (leave empty for auto-discovery)",""),p=await o("Max heal retries","5");s.close();let g={provider:n,testTypes:a.split(",").map(f=>f.trim()).filter(Boolean),maxRetries:parseInt(p,10)||5,skipFiles:[],skipDirs:[],skipPaths:[]};i&&(g.testingFramework=i),l&&(g.testCommand=l),se.writeFileSync(e,JSON.stringify(g,null,2)+`
153
154
  `,"utf-8"),console.log(`
154
155
  \u2705 Created ${M}:
155
156
  `),console.log(JSON.stringify(g,null,2)),console.log(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lisa.ai/agent",
3
- "version": "2.5.4",
3
+ "version": "2.5.6",
4
4
  "description": "Lisa.ai Autonomous CI/CD Worker Agent",
5
5
  "main": "dist/index.js",
6
6
  "bin": {