@lisa.ai/agent 1.0.0 → 1.0.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.
- package/dist/commands/coverage.js +2 -1
- package/dist/commands/heal.js +5 -3
- package/dist/index.js +16 -12
- package/dist/services/llm.service.js +11 -6
- package/package.json +1 -1
- package/dist/utils/math.js +0 -9
- package/dist/utils/math.spec.js +0 -19
|
@@ -93,7 +93,8 @@ async function coverageCommand(command, modelProvider, attempt = 1, maxRetries =
|
|
|
93
93
|
type: 'coverage',
|
|
94
94
|
filePath: targetFilePath,
|
|
95
95
|
modelUsed: modelProvider,
|
|
96
|
-
status: 'success'
|
|
96
|
+
status: 'success',
|
|
97
|
+
details: `### Missing Logic Coverage Detected\n**Auto-Generated Specification Suite (${modelProvider}):**\n\`\`\`typescript\n${testCode}\n\`\`\``
|
|
97
98
|
});
|
|
98
99
|
// 4. Recursive iteration to verify newly written test and hunt for next gap
|
|
99
100
|
await coverageCommand(command, modelProvider, attempt + 1, maxRetries, projectId);
|
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') {
|
|
44
|
+
async function healCommand(command, modelProvider, attempt = 1, healedFilePath = null, maxRetries = 3, projectId = 'local', lastFixDetails) {
|
|
45
45
|
console.log(`\n[Lisa.ai Executing] ${command} (Attempt ${attempt}/${maxRetries}) Using Model: ${modelProvider}`);
|
|
46
46
|
try {
|
|
47
47
|
// Execute command synchronously
|
|
@@ -58,7 +58,8 @@ async function healCommand(command, modelProvider, attempt = 1, healedFilePath =
|
|
|
58
58
|
type: 'heal',
|
|
59
59
|
filePath: healedFilePath,
|
|
60
60
|
modelUsed: modelProvider,
|
|
61
|
-
status: 'success'
|
|
61
|
+
status: 'success',
|
|
62
|
+
details: lastFixDetails
|
|
62
63
|
});
|
|
63
64
|
await (0, git_service_1.createPullRequestForHeal)(healedFilePath);
|
|
64
65
|
}
|
|
@@ -92,6 +93,7 @@ async function healCommand(command, modelProvider, attempt = 1, healedFilePath =
|
|
|
92
93
|
fs.writeFileSync(absolutePath, fixedCode, 'utf-8');
|
|
93
94
|
console.log(`[Lisa.ai Auto-Heal] Applied patch to ${filePath}`);
|
|
94
95
|
// Recursive retry, passing the healed file path state
|
|
95
|
-
|
|
96
|
+
const generatedDetails = `### Auto-Heal Analysis Triggered\n**Caught Error:**\n\`\`\`bash\n${errorLog}\n\`\`\`\n\n**Applied Fix (${modelProvider}):**\n\`\`\`typescript\n${fixedCode}\n\`\`\``;
|
|
97
|
+
await healCommand(command, modelProvider, attempt + 1, filePath, maxRetries, projectId, generatedDetails);
|
|
96
98
|
}
|
|
97
99
|
}
|
package/dist/index.js
CHANGED
|
@@ -20,14 +20,16 @@ program
|
|
|
20
20
|
let model = options.model;
|
|
21
21
|
if (options.projectId) {
|
|
22
22
|
const config = await (0, config_service_1.fetchRemoteConfig)(options.projectId);
|
|
23
|
-
if (config) {
|
|
24
|
-
console.
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
23
|
+
if (!config) {
|
|
24
|
+
console.error(`\n🚨 [Lisa.ai Agent Error] Project '${options.projectId}' does not exist on the Control Plane. Please create it in the Dashboard first or run locally without a project ID.`);
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
console.log(`[Lisa.ai Agent] Dynamic Config Loaded: Provider=${config.modelProvider}, MaxRetries=${config.maxRetries}`);
|
|
28
|
+
model = config.modelProvider;
|
|
29
|
+
maxRetries = config.maxRetries;
|
|
30
|
+
if (config.autoHealEnabled === false) {
|
|
31
|
+
console.log(`[Lisa.ai Agent] Auto-heal is disabled by Control Plane.`);
|
|
32
|
+
process.exit(1);
|
|
31
33
|
}
|
|
32
34
|
}
|
|
33
35
|
(0, heal_1.healCommand)(options.command, model, 1, null, maxRetries, options.projectId || 'local');
|
|
@@ -43,11 +45,13 @@ program
|
|
|
43
45
|
let model = options.model;
|
|
44
46
|
if (options.projectId) {
|
|
45
47
|
const config = await (0, config_service_1.fetchRemoteConfig)(options.projectId);
|
|
46
|
-
if (config) {
|
|
47
|
-
console.
|
|
48
|
-
|
|
49
|
-
maxRetries = config.maxRetries;
|
|
48
|
+
if (!config) {
|
|
49
|
+
console.error(`\n🚨 [Lisa.ai Agent Error] Project '${options.projectId}' does not exist on the Control Plane. Please create it in the Dashboard first or run locally without a project ID.`);
|
|
50
|
+
process.exit(1);
|
|
50
51
|
}
|
|
52
|
+
console.log(`[Lisa.ai Agent] Dynamic Config Loaded: Provider=${config.modelProvider}, MaxRetries=${config.maxRetries}`);
|
|
53
|
+
model = config.modelProvider;
|
|
54
|
+
maxRetries = config.maxRetries;
|
|
51
55
|
}
|
|
52
56
|
(0, coverage_1.coverageCommand)(options.command, model, 1, maxRetries, options.projectId || 'local');
|
|
53
57
|
});
|
|
@@ -40,7 +40,10 @@ const openai_1 = require("@ai-sdk/openai");
|
|
|
40
40
|
const anthropic_1 = require("@ai-sdk/anthropic");
|
|
41
41
|
const google_1 = require("@ai-sdk/google");
|
|
42
42
|
const path = __importStar(require("path"));
|
|
43
|
-
require("dotenv
|
|
43
|
+
const dotenv = __importStar(require("dotenv"));
|
|
44
|
+
// Force dotenv to load the `.env` file from the agent's root directory
|
|
45
|
+
// regardless of which folder the user is currently running the CLI inside.
|
|
46
|
+
dotenv.config({ path: path.resolve(__dirname, '../../.env') });
|
|
44
47
|
async function askLisaForFix(filePath, fileContent, errorLog, modelProvider) {
|
|
45
48
|
console.log(`[Lisa.ai Auto-Heal] Requesting fix from ${modelProvider} for ${filePath}...`);
|
|
46
49
|
let model;
|
|
@@ -72,7 +75,7 @@ ${fileContent}
|
|
|
72
75
|
1. Do not delete business logic.
|
|
73
76
|
2. Do not suppress TypeScript errors with @ts-ignore or any type assertions unless absolutely unavoidable.
|
|
74
77
|
3. Fix the underlying type or logic issue.
|
|
75
|
-
4. Return
|
|
78
|
+
4. Return the code wrapped in a markdown code block (\`\`\`typescript ... \`\`\`). Do not include any explanation or intro text.`;
|
|
76
79
|
// Provide a mock bypass if keys are not present to test the Git loop
|
|
77
80
|
if (!process.env.GOOGLE_GENERATIVE_AI_API_KEY && !process.env.OPENAI_API_KEY && !process.env.ANTHROPIC_API_KEY) {
|
|
78
81
|
console.log(`[Lisa.ai Warning] No API keys found in environment. Using mock LLM fix for testing.`);
|
|
@@ -82,7 +85,8 @@ ${fileContent}
|
|
|
82
85
|
model,
|
|
83
86
|
prompt,
|
|
84
87
|
});
|
|
85
|
-
|
|
88
|
+
const match = text.match(/```(?:typescript|ts)?\n([\s\S]*?)```/);
|
|
89
|
+
return match ? match[1].trim() : text.trim();
|
|
86
90
|
}
|
|
87
91
|
async function generateTestForFile(sourceFilePath, sourceFileContent, modelProvider) {
|
|
88
92
|
console.log(`[Lisa.ai Coverage] Requesting test generation from ${modelProvider} for ${sourceFilePath}...`);
|
|
@@ -108,8 +112,8 @@ A TypeScript/Angular file lacks 100% test coverage. Your task is to generate a c
|
|
|
108
112
|
${sourceFileContent}
|
|
109
113
|
|
|
110
114
|
--- Constraints ---
|
|
111
|
-
1. Return
|
|
112
|
-
2. Do not include
|
|
115
|
+
1. Return the generated TypeScript test code wrapped in a markdown code block (\`\`\`typescript ... \`\`\`).
|
|
116
|
+
2. Do not include any explanation or intro text.
|
|
113
117
|
3. Include all necessary imports assuming Jest is available.
|
|
114
118
|
4. Aim for 100% logic coverage.`;
|
|
115
119
|
// Provide a mock bypass if keys are not present
|
|
@@ -120,5 +124,6 @@ ${sourceFileContent}
|
|
|
120
124
|
model,
|
|
121
125
|
prompt,
|
|
122
126
|
});
|
|
123
|
-
|
|
127
|
+
const match = text.match(/```(?:typescript|ts)?\n([\s\S]*?)```/);
|
|
128
|
+
return match ? match[1].trim() : text.trim();
|
|
124
129
|
}
|
package/package.json
CHANGED
package/dist/utils/math.js
DELETED
package/dist/utils/math.spec.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const math_1 = require("./math");
|
|
4
|
-
describe('MathUtils', () => {
|
|
5
|
-
describe('add', () => {
|
|
6
|
-
it('should add two positive numbers', () => {
|
|
7
|
-
expect(math_1.MathUtils.add(2, 3)).toBe(5);
|
|
8
|
-
});
|
|
9
|
-
it('should add two negative numbers', () => {
|
|
10
|
-
expect(math_1.MathUtils.add(-2, -3)).toBe(-5);
|
|
11
|
-
});
|
|
12
|
-
it('should add a positive and a negative number', () => {
|
|
13
|
-
expect(math_1.MathUtils.add(2, -3)).toBe(-1);
|
|
14
|
-
});
|
|
15
|
-
it('should add zero to a number', () => {
|
|
16
|
-
expect(math_1.MathUtils.add(2, 0)).toBe(2);
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
});
|