@lisa.ai/agent 2.2.0 → 2.2.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.
|
@@ -44,6 +44,7 @@ const telemetry_service_1 = require("../services/telemetry.service");
|
|
|
44
44
|
const discovery_service_1 = require("../services/discovery.service");
|
|
45
45
|
const installer_service_1 = require("../services/installer.service");
|
|
46
46
|
const generator_service_1 = require("../services/generator.service");
|
|
47
|
+
const parser_1 = require("../utils/parser");
|
|
47
48
|
async function coverageCommand(command, modelProvider, attempt = 1, maxRetries = 3, projectId = 'local', apiKey) {
|
|
48
49
|
// Bug 8 fix: Always run scanRepository() so we have a framework fingerprint regardless of
|
|
49
50
|
// whether the user passed --command explicitly. scanRepository() is cheap (reads package.json)
|
|
@@ -60,6 +61,17 @@ async function coverageCommand(command, modelProvider, attempt = 1, maxRetries =
|
|
|
60
61
|
}
|
|
61
62
|
if (mutableFingerprint.suggestedTestCommand) {
|
|
62
63
|
command = mutableFingerprint.suggestedTestCommand;
|
|
64
|
+
// Ensure coverage reporting is enabled. Without --coverage the test runner never
|
|
65
|
+
// writes coverage-summary.json, so the agent stays permanently stuck in cold-start
|
|
66
|
+
// discovery mode no matter how many tests it generates.
|
|
67
|
+
// Karma instruments coverage via karma.conf.js — don't touch it.
|
|
68
|
+
const fw = mutableFingerprint.testingFramework;
|
|
69
|
+
if ((fw === 'jest' || fw === 'vitest') && !command.includes('--coverage')) {
|
|
70
|
+
command = command.includes('npm run')
|
|
71
|
+
? `${command} -- --coverage`
|
|
72
|
+
: `${command} --coverage`;
|
|
73
|
+
console.log(`[Lisa.ai Coverage] Coverage flag appended: ${command}`);
|
|
74
|
+
}
|
|
63
75
|
console.log(`[Lisa.ai Auto-Discovery] Bootstrapping execution with natively discovered command: ${command}`);
|
|
64
76
|
}
|
|
65
77
|
else {
|
|
@@ -120,14 +132,24 @@ async function coverageCommand(command, modelProvider, attempt = 1, maxRetries =
|
|
|
120
132
|
console.log(`\n✅ [Lisa.ai Coverage] Tests passed successfully on attempt ${attempt}.`);
|
|
121
133
|
}
|
|
122
134
|
catch (error) {
|
|
123
|
-
|
|
124
|
-
//
|
|
125
|
-
|
|
126
|
-
//
|
|
127
|
-
//
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
135
|
+
const errorLog = (error.stderr || '') + '\n' + (error.stdout || '') + '\n' + (error.message || '');
|
|
136
|
+
// Check whether the error output contains an actual broken source file.
|
|
137
|
+
// If it does → real compilation/runtime failure → delegate to healCommand.
|
|
138
|
+
// If it does NOT (e.g. Jest's "No tests found, exiting with code 1" on a cold-start
|
|
139
|
+
// project, or a jest config error with no file reference) → delegating to healCommand
|
|
140
|
+
// would crash with "Could not parse a valid failing file path". Instead, fall through
|
|
141
|
+
// to the cold-start discovery block below which will generate the first test files.
|
|
142
|
+
const hasHealableFile = (0, parser_1.extractFilePath)(errorLog, [], process.cwd()) !== null;
|
|
143
|
+
if (hasHealableFile) {
|
|
144
|
+
console.log(`\n❌ [Lisa.ai Coverage] Tests failed. Delegating to Auto-Heal...`);
|
|
145
|
+
await (0, heal_1.healCommand)(command, modelProvider, 1, null, maxRetries, projectId, undefined, apiKey);
|
|
146
|
+
console.log(`\n🔄 [Lisa.ai Coverage] Auto-Heal successful. Restarting coverage analysis...`);
|
|
147
|
+
await coverageCommand(command, modelProvider, attempt + 1, maxRetries, projectId, apiKey);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
// No file path found in the error — most likely cold-start (no test files yet).
|
|
151
|
+
// Fall through to the coverage evaluation block which will trigger cold-start discovery.
|
|
152
|
+
console.log(`\n[Lisa.ai Coverage] No failing spec file detected in error output. Tests may not exist yet — initiating Cold-Start Discovery...`);
|
|
131
153
|
}
|
|
132
154
|
// 2. Tests passed — evaluate coverage.
|
|
133
155
|
// Bug 5 fix: removed dead `executionPassed` variable. It was set to `true` on line 42
|
|
@@ -83,8 +83,19 @@ class AutoDiscoveryService {
|
|
|
83
83
|
result.suggestedTestCommand = 'npm run test';
|
|
84
84
|
}
|
|
85
85
|
else {
|
|
86
|
-
// They have the library but no script;
|
|
87
|
-
|
|
86
|
+
// They have the library but no script; execute the binary directly.
|
|
87
|
+
// Include --coverage for jest/vitest so coverage-summary.json is produced.
|
|
88
|
+
// Without it the coverage command has no report to evaluate and gets permanently
|
|
89
|
+
// stuck in cold-start discovery mode.
|
|
90
|
+
if (result.testingFramework === 'karma') {
|
|
91
|
+
result.suggestedTestCommand = 'npx karma start';
|
|
92
|
+
}
|
|
93
|
+
else if (result.testingFramework === 'jest') {
|
|
94
|
+
result.suggestedTestCommand = 'npx jest --coverage';
|
|
95
|
+
}
|
|
96
|
+
else if (result.testingFramework === 'vitest') {
|
|
97
|
+
result.suggestedTestCommand = 'npx vitest run --coverage';
|
|
98
|
+
}
|
|
88
99
|
}
|
|
89
100
|
}
|
|
90
101
|
return result;
|