@lisa.ai/agent 1.0.7 → 1.0.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/commands/coverage.js +3 -2
- package/dist/commands/heal.js +13 -10
- package/dist/services/llm.service.js +10 -2
- package/package.json +1 -1
|
@@ -46,8 +46,9 @@ async function coverageCommand(command, modelProvider, attempt = 1, maxRetries =
|
|
|
46
46
|
let executionPassed = true;
|
|
47
47
|
try {
|
|
48
48
|
// 1. Run the test command which should ideally produce coverage-summary.json
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
// Use 'inherit' so that long-running test commands (like Angular/Karma) print their progress
|
|
50
|
+
// in real-time directly to the user's terminal instead of appearing frozen.
|
|
51
|
+
(0, child_process_1.execSync)(command, { encoding: 'utf-8', stdio: 'inherit' });
|
|
51
52
|
console.log(`\n✅ [Lisa.ai Coverage] Tests passed successfully on attempt ${attempt}.`);
|
|
52
53
|
}
|
|
53
54
|
catch (error) {
|
package/dist/commands/heal.js
CHANGED
|
@@ -53,14 +53,6 @@ async function healCommand(command, modelProvider, attempt = 1, healedFilePath =
|
|
|
53
53
|
console.log(`\n✅ [Lisa.ai Success] Command executed successfully on attempt ${attempt}.`);
|
|
54
54
|
// If we successfully executed and had previously healed a file, PR it
|
|
55
55
|
if (healedFilePath) {
|
|
56
|
-
await (0, telemetry_service_1.reportTelemetry)({
|
|
57
|
-
projectId,
|
|
58
|
-
type: 'heal',
|
|
59
|
-
filePath: healedFilePath,
|
|
60
|
-
modelUsed: modelProvider,
|
|
61
|
-
status: 'success',
|
|
62
|
-
details: lastFixDetails
|
|
63
|
-
});
|
|
64
56
|
await (0, git_service_1.createPullRequestForHeal)(healedFilePath);
|
|
65
57
|
}
|
|
66
58
|
}
|
|
@@ -87,13 +79,24 @@ async function healCommand(command, modelProvider, attempt = 1, healedFilePath =
|
|
|
87
79
|
console.log(`[Lisa.ai Auto-Heal] Identified failing file: ${filePath}`);
|
|
88
80
|
// Read file contents to send to LLM
|
|
89
81
|
const fileContent = fs.readFileSync(absolutePath, 'utf-8');
|
|
82
|
+
// Pass previous attempted fix if we are stuck in a loop on the same file
|
|
83
|
+
const previousContext = (filePath === healedFilePath) ? lastFixDetails : undefined;
|
|
90
84
|
// Call LLM for a fix
|
|
91
|
-
const fixedCode = await (0, llm_service_1.askLisaForFix)(filePath, fileContent, errorLog, modelProvider, apiKey);
|
|
85
|
+
const fixedCode = await (0, llm_service_1.askLisaForFix)(filePath, fileContent, errorLog, modelProvider, apiKey, previousContext);
|
|
92
86
|
// Write the fix to the file
|
|
93
87
|
fs.writeFileSync(absolutePath, fixedCode, 'utf-8');
|
|
94
88
|
console.log(`[Lisa.ai Auto-Heal] Applied patch to ${filePath}`);
|
|
95
|
-
// Recursive retry, passing the healed file path state
|
|
96
89
|
const generatedDetails = `### Auto-Heal Analysis Triggered\n**Caught Error:**\n\`\`\`bash\n${errorLog}\n\`\`\`\n\n**Applied Fix (${modelProvider}):**\n\`\`\`typescript\n${fixedCode}\n\`\`\``;
|
|
90
|
+
// Dispatch telemetry instantly so the dashboard updates in real-time exactly when the file is patched
|
|
91
|
+
await (0, telemetry_service_1.reportTelemetry)({
|
|
92
|
+
projectId,
|
|
93
|
+
type: 'heal',
|
|
94
|
+
filePath: filePath,
|
|
95
|
+
modelUsed: modelProvider,
|
|
96
|
+
status: 'success',
|
|
97
|
+
details: generatedDetails
|
|
98
|
+
});
|
|
99
|
+
// Recursive retry, passing the healed file path state
|
|
97
100
|
await healCommand(command, modelProvider, attempt + 1, filePath, maxRetries, projectId, generatedDetails, apiKey);
|
|
98
101
|
}
|
|
99
102
|
}
|
|
@@ -62,10 +62,10 @@ function getProvider(provider, apiKey) {
|
|
|
62
62
|
throw new Error('No Google API key provided by local ENV or Control Plane');
|
|
63
63
|
return (0, google_1.createGoogleGenerativeAI)({ apiKey: key })('gemini-1.5-pro-latest');
|
|
64
64
|
}
|
|
65
|
-
async function askLisaForFix(filePath, fileContent, errorLog, modelProvider, apiKey) {
|
|
65
|
+
async function askLisaForFix(filePath, fileContent, errorLog, modelProvider, apiKey, previousFixAttempt) {
|
|
66
66
|
console.log(`[Lisa.ai Auto-Heal] Requesting fix from ${modelProvider} for ${filePath}...`);
|
|
67
67
|
const model = getProvider(modelProvider, apiKey);
|
|
68
|
-
|
|
68
|
+
let prompt = `You are Lisa.ai, an autonomous CI/CD expert platform.
|
|
69
69
|
A build/compilation error occurred. Your task is to fix the provided file so that the error resolves.
|
|
70
70
|
|
|
71
71
|
--- Error Log ---
|
|
@@ -79,6 +79,14 @@ ${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. Return the code wrapped in a markdown code block (\`\`\`typescript ... \`\`\`). Do not include any explanation or intro text.`;
|
|
82
|
+
if (previousFixAttempt) {
|
|
83
|
+
console.log(`[Lisa.ai Auto-Heal] Warning! Agent is looping on ${filePath}. Injecting previous failed context...`);
|
|
84
|
+
prompt += `\n\n--- CRITICAL WARNING ---\nYou previously attempted to fix this file but the compiler REJECTED your fix!
|
|
85
|
+
Here is the previous analysis and failed fix you attempted:
|
|
86
|
+
${previousFixAttempt}
|
|
87
|
+
|
|
88
|
+
DO NOT repeat the identical code changes. Try a completely different programming approach, fix syntax typos, or check for missing imports.`;
|
|
89
|
+
}
|
|
82
90
|
const { text } = await (0, ai_1.generateText)({
|
|
83
91
|
model,
|
|
84
92
|
prompt,
|