@lisa.ai/agent 1.0.9 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -41,7 +41,7 @@ const parser_1 = require("../utils/parser");
41
41
  const llm_service_1 = require("../services/llm.service");
42
42
  const git_service_1 = require("../services/git.service");
43
43
  const telemetry_service_1 = require("../services/telemetry.service");
44
- async function healCommand(command, modelProvider, attempt = 1, healedFilePath = null, maxRetries = 3, projectId = 'local', lastFixDetails, apiKey) {
44
+ async function healCommand(command, modelProvider, attempt = 1, healedFilePath = null, maxRetries = 3, projectId = 'local', lastFixDetails, apiKey, skipLedger = [], consecutiveFails = 0) {
45
45
  console.log(`\n[Lisa.ai Executing] ${command} (Attempt ${attempt}/${maxRetries}) Using Model: ${modelProvider}`);
46
46
  try {
47
47
  // Execute command synchronously
@@ -66,9 +66,9 @@ async function healCommand(command, modelProvider, attempt = 1, healedFilePath =
66
66
  process.exit(1);
67
67
  }
68
68
  console.log(`\n[Lisa.ai Auto-Heal] Analyzing errors...`);
69
- const filePath = (0, parser_1.extractFilePath)(errorLog);
69
+ const filePath = (0, parser_1.extractFilePath)(errorLog, skipLedger);
70
70
  if (!filePath) {
71
- console.error(`\n🚨 [Lisa.ai Error] Could not parse a valid failing file path from the logs.`);
71
+ console.error(`\n🚨 [Lisa.ai Error] Could not parse a valid failing file path from the logs (or all were explicitly skipped).`);
72
72
  process.exit(1);
73
73
  }
74
74
  const absolutePath = path.resolve(process.cwd(), filePath);
@@ -79,8 +79,17 @@ async function healCommand(command, modelProvider, attempt = 1, healedFilePath =
79
79
  console.log(`[Lisa.ai Auto-Heal] Identified failing file: ${filePath}`);
80
80
  // Read file contents to send to LLM
81
81
  const fileContent = fs.readFileSync(absolutePath, 'utf-8');
82
+ // Increment consecutive fail tracker if this is the exact same file as last time
83
+ let currentFails = (filePath === healedFilePath) ? consecutiveFails + 1 : 1;
84
+ if (currentFails >= 3) {
85
+ console.warn(`\n[Lisa.ai Auto-Heal] ⚠️ Warning: Agent failed to heal ${filePath} after 3 consecutive attempts. It may be missing dependencies. Marking as Skipped.`);
86
+ skipLedger.push(filePath);
87
+ // Immediately retry the loop but force the parser to skip this broken file
88
+ await healCommand(command, modelProvider, attempt + 1, healedFilePath, maxRetries, projectId, lastFixDetails, apiKey, skipLedger, 0);
89
+ return;
90
+ }
82
91
  // Pass previous attempted fix if we are stuck in a loop on the same file
83
- const previousContext = (filePath === healedFilePath) ? lastFixDetails : undefined;
92
+ const previousContext = (currentFails > 1) ? lastFixDetails : undefined;
84
93
  // Call LLM for a fix
85
94
  const fixedCode = await (0, llm_service_1.askLisaForFix)(filePath, fileContent, errorLog, modelProvider, apiKey, previousContext);
86
95
  // Write the fix to the file
@@ -96,7 +105,7 @@ async function healCommand(command, modelProvider, attempt = 1, healedFilePath =
96
105
  status: 'success',
97
106
  details: generatedDetails
98
107
  });
99
- // Recursive retry, passing the healed file path state
100
- await healCommand(command, modelProvider, attempt + 1, filePath, maxRetries, projectId, generatedDetails, apiKey);
108
+ // Recursive retry, passing the healed file path state and updated limits
109
+ await healCommand(command, modelProvider, attempt + 1, filePath, maxRetries, projectId, generatedDetails, apiKey, skipLedger, currentFails);
101
110
  }
102
111
  }
@@ -75,10 +75,11 @@ ${errorLog}
75
75
  ${fileContent}
76
76
 
77
77
  --- Constraints ---
78
- 1. Do not delete business logic.
78
+ 1. Do not delete business logic unless absolutely necessary to resolve a missing dependency.
79
79
  2. Do not suppress TypeScript errors with @ts-ignore or any type assertions unless absolutely unavoidable.
80
80
  3. Fix the underlying type or logic issue.
81
- 4. Return the code wrapped in a markdown code block (\`\`\`typescript ... \`\`\`). Do not include any explanation or intro text.`;
81
+ 4. CRITICAL AGILE RULE: If the error is 'Cannot find module' or 'Property DOES NOT EXIST' and you do NOT know the correct import path or cannot resolve it from the context, you MUST silently comment out the failing import and completely comment out/stub the code that relies on it. Your ultimate goal is to make the file compile successfully so the Agent can proceed to the next file.
82
+ 5. Return the code wrapped in a markdown code block (\`\`\`typescript ... \`\`\`). Do not include any explanation or intro text.`;
82
83
  if (previousFixAttempt) {
83
84
  console.log(`[Lisa.ai Auto-Heal] Warning! Agent is looping on ${filePath}. Injecting previous failed context...`);
84
85
  prompt += `\n\n--- CRITICAL WARNING ---\nYou previously attempted to fix this file but the compiler REJECTED your fix!
@@ -1,20 +1,67 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
3
36
  exports.extractFilePath = extractFilePath;
4
- function extractFilePath(errorLog) {
37
+ const path = __importStar(require("path"));
38
+ function extractFilePath(errorLog, skipFiles = []) {
5
39
  // Sanitize invisible ANSI color codes (e.g. \x1b[96m) from CLI output logs
6
40
  const cleanLog = errorLog.replace(/\x1B\[[0-9;]*[a-zA-Z]/g, '');
7
- // Matches typical TS/Angular error patterns:
41
+ // Normalize skip files for reliable absolute path comparison
42
+ const normalizedSkips = skipFiles.map(p => path.resolve(p));
43
+ // 1. First Pass: Try to match typical TS/Angular error patterns
8
44
  // e.g., "src/app/app.component.ts:12:3 - error TS2322:"
9
- // e.g., "Error: src/app/app.component.ts:12:3"
10
- // Try to match path near an error
11
- const tsErrorRegex = /([a-zA-Z0-9_.\-\/\\]+\.ts)(?:[:(])/;
12
- const match = tsErrorRegex.exec(cleanLog);
13
- if (match && match[1]) {
14
- return match[1];
45
+ const tsErrorRegex = /([a-zA-Z0-9_.\-\/\\]+\.ts)(?:[:(])/g;
46
+ let match;
47
+ // Loop through all matches in the error log
48
+ while ((match = tsErrorRegex.exec(cleanLog)) !== null) {
49
+ const foundPath = match[1];
50
+ // If this path is NOT in our skip ledger, we return it as the target
51
+ if (foundPath && !normalizedSkips.includes(path.resolve(foundPath))) {
52
+ return foundPath;
53
+ }
54
+ }
55
+ // 2. Second Pass (Fallback): Find anything that looks like a .ts file
56
+ // Note: We use the 'g' flag so we can iterate through multiple matches if the first is skipped
57
+ const fallbackRegex = /([a-zA-Z0-9_.\-\/\\]+\.ts)/g;
58
+ let fallbackMatch;
59
+ while ((fallbackMatch = fallbackRegex.exec(cleanLog)) !== null) {
60
+ const foundPath = fallbackMatch[1];
61
+ if (foundPath && !normalizedSkips.includes(path.resolve(foundPath))) {
62
+ return foundPath;
63
+ }
15
64
  }
16
- // Fallback: Just try to find anything that looks like a .ts file path
17
- const fallbackRegex = /([a-zA-Z0-9_.\-\/\\]+\.ts)/;
18
- const fallbackMatch = fallbackRegex.exec(cleanLog);
19
- return fallbackMatch ? fallbackMatch[1] : null;
65
+ // Exhausted all options and couldn't find an un-skipped file
66
+ return null;
20
67
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lisa.ai/agent",
3
- "version": "1.0.9",
3
+ "version": "1.1.1",
4
4
  "description": "Lisa.ai Autonomous CI/CD Worker Agent",
5
5
  "main": "dist/index.js",
6
6
  "bin": {