@lisa.ai/agent 1.1.1 → 1.1.2
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/commands/heal.js
CHANGED
|
@@ -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, skipLedger = [], consecutiveFails = 0) {
|
|
44
|
+
async function healCommand(command, modelProvider, attempt = 1, healedFilePath = null, maxRetries = 3, projectId = 'local', lastFixDetails, apiKey, skipLedger = [], consecutiveFails = 0, failTracker = {}) {
|
|
45
45
|
console.log(`\n[Lisa.ai Executing] ${command} (Attempt ${attempt}/${maxRetries}) Using Model: ${modelProvider}`);
|
|
46
46
|
try {
|
|
47
47
|
// Execute command synchronously
|
|
@@ -79,17 +79,18 @@ 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
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
82
|
+
// Increment global fail tracker for this specific file
|
|
83
|
+
failTracker[filePath] = (failTracker[filePath] || 0) + 1;
|
|
84
|
+
const totalFails = failTracker[filePath];
|
|
85
|
+
if (totalFails >= 3) {
|
|
86
|
+
console.warn(`\n[Lisa.ai Auto-Heal] ⚠️ Warning: Agent failed to heal ${filePath} after 3 overall attempts in this session. Marking as Skipped to avoid infinite Loop.`);
|
|
86
87
|
skipLedger.push(filePath);
|
|
87
88
|
// 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
|
+
await healCommand(command, modelProvider, attempt + 1, healedFilePath, maxRetries, projectId, lastFixDetails, apiKey, skipLedger, 0, failTracker);
|
|
89
90
|
return;
|
|
90
91
|
}
|
|
91
92
|
// Pass previous attempted fix if we are stuck in a loop on the same file
|
|
92
|
-
const previousContext = (
|
|
93
|
+
const previousContext = (totalFails > 1) ? lastFixDetails : undefined;
|
|
93
94
|
// Call LLM for a fix
|
|
94
95
|
const fixedCode = await (0, llm_service_1.askLisaForFix)(filePath, fileContent, errorLog, modelProvider, apiKey, previousContext);
|
|
95
96
|
// Write the fix to the file
|
|
@@ -106,6 +107,6 @@ async function healCommand(command, modelProvider, attempt = 1, healedFilePath =
|
|
|
106
107
|
details: generatedDetails
|
|
107
108
|
});
|
|
108
109
|
// Recursive retry, passing the healed file path state and updated limits
|
|
109
|
-
await healCommand(command, modelProvider, attempt + 1, filePath, maxRetries, projectId, generatedDetails, apiKey, skipLedger,
|
|
110
|
+
await healCommand(command, modelProvider, attempt + 1, filePath, maxRetries, projectId, generatedDetails, apiKey, skipLedger, 0, failTracker);
|
|
110
111
|
}
|
|
111
112
|
}
|
|
@@ -79,7 +79,8 @@ ${fileContent}
|
|
|
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
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.
|
|
82
|
+
5. ANGULAR TEST RULE: If fixing a ".spec.ts" file and the error is 'NullInjectorError: No provider for X', you MUST add X to the 'providers' array in 'TestBed.configureTestingModule' or import the required testing module (e.g., 'HttpClientTestingModule'). If the error is 'Unexpected "X" found in the "declarations" array...marked as standalone', you MUST move X from the 'declarations' array to the 'imports' array in 'TestBed.configureTestingModule'.
|
|
83
|
+
6. Return the code wrapped in a markdown code block (\`\`\`typescript ... \`\`\`). Do not include any explanation or intro text.`;
|
|
83
84
|
if (previousFixAttempt) {
|
|
84
85
|
console.log(`[Lisa.ai Auto-Heal] Warning! Agent is looping on ${filePath}. Injecting previous failed context...`);
|
|
85
86
|
prompt += `\n\n--- CRITICAL WARNING ---\nYou previously attempted to fix this file but the compiler REJECTED your fix!
|