@empiricalrun/test-gen 0.41.1 → 0.41.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/CHANGELOG.md +9 -0
- package/dist/agent/codegen/repo-edit.d.ts.map +1 -1
- package/dist/agent/codegen/repo-edit.js +10 -10
- package/dist/agent/codegen/run.d.ts.map +1 -1
- package/dist/agent/codegen/run.js +5 -8
- package/dist/agent/codegen/utils.d.ts +4 -0
- package/dist/agent/codegen/utils.d.ts.map +1 -1
- package/dist/agent/codegen/utils.js +14 -1
- package/dist/agent/enrich-prompt/index.d.ts +14 -0
- package/dist/agent/enrich-prompt/index.d.ts.map +1 -0
- package/dist/agent/enrich-prompt/index.js +83 -0
- package/dist/agent/enrich-prompt/utils.d.ts +6 -0
- package/dist/agent/enrich-prompt/utils.d.ts.map +1 -0
- package/dist/agent/enrich-prompt/utils.js +12 -0
- package/dist/evals/add-scenario-agent.evals.d.ts.map +1 -1
- package/dist/evals/add-scenario-agent.evals.js +11 -9
- package/dist/reporter/index.d.ts.map +1 -1
- package/dist/reporter/index.js +4 -0
- package/package.json +5 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @empiricalrun/test-gen
|
|
2
2
|
|
|
3
|
+
## 0.41.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 8d6f8be: fix: enable type check in repo agent
|
|
8
|
+
- 6573a58: fix: move generate requested change method to test-gen package
|
|
9
|
+
- 54e7e03: fix: avoid uploading screenshots if reporter config is not set
|
|
10
|
+
- 3eff6a8: fix: updated prompt for create test
|
|
11
|
+
|
|
3
12
|
## 0.41.1
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repo-edit.d.ts","sourceRoot":"","sources":["../../../src/agent/codegen/repo-edit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,WAAW,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AAC,EAC/C,IAAI,EACJ,KAAK,EACL,SAAS,GACV,EAAE;IACD,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,OAAO,CAAC;IACV,MAAM,EAAE,0BAA0B,EAAE,CAAC;IACrC,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE;QACX,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;QAC7B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;QAC5B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;QAC5B,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;KAC5B,EAAE,CAAC;CACL,CAAC,CA6GD;AAED,wBAAsB,aAAa,CAAC,EAClC,KAAK,EACL,IAAI,GACL,EAAE;IACD,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd,GAAG,OAAO,CAAC;IACV,MAAM,EAAE,0BAA0B,EAAE,CAAC;IACrC,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE;QACX,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;QAC7B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;QAC5B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;QAC5B,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;KAC5B,EAAE,CAAC;CACL,CAAC,CAuED"}
|
|
@@ -29,7 +29,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
29
|
exports.repoEditAgent = exports.generateCodeUsingRepoAgent = void 0;
|
|
30
30
|
const llm_1 = require("@empiricalrun/llm");
|
|
31
31
|
const fsSync = __importStar(require("fs"));
|
|
32
|
-
const
|
|
32
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
33
33
|
const path_1 = require("path");
|
|
34
34
|
const context_1 = require("../../bin/utils/context");
|
|
35
35
|
const web_1 = require("../../bin/utils/platform/web");
|
|
@@ -147,6 +147,7 @@ Task: ${task}
|
|
|
147
147
|
}
|
|
148
148
|
exports.generateCodeUsingRepoAgent = generateCodeUsingRepoAgent;
|
|
149
149
|
async function repoEditAgent({ trace, task, }) {
|
|
150
|
+
console.log("mock test", fs_extra_1.default.readdir(""));
|
|
150
151
|
const testgenUpdatesReporter = new reporter_1.TestGenUpdatesReporter();
|
|
151
152
|
void testgenUpdatesReporter.sendMessage(`Updating test code as per the task. \n View [trace](${trace?.getTraceUrl()})`);
|
|
152
153
|
const { prompt: repoFiles } = await (0, context_1.generateTxtForRepository)();
|
|
@@ -178,23 +179,22 @@ async function repoEditAgent({ trace, task, }) {
|
|
|
178
179
|
fileChanges: updatedFileChanges,
|
|
179
180
|
});
|
|
180
181
|
}
|
|
181
|
-
await (0, utils_1.validateTypesAndFormatCode)({
|
|
182
|
-
validateTypes: false,
|
|
183
|
-
trace,
|
|
184
|
-
testCase: {},
|
|
185
|
-
fileChanges: updates.filter((f) => f.filePath && fsSync.existsSync(f.filePath)),
|
|
186
|
-
});
|
|
187
182
|
const newFileUpdates = updates.filter((f) => !fsSync.existsSync(f.filePath));
|
|
188
183
|
await Promise.all(newFileUpdates.map((f) => {
|
|
189
184
|
return (async () => {
|
|
190
|
-
await
|
|
191
|
-
await
|
|
185
|
+
await fs_extra_1.default.mkdir((0, path_1.dirname)(f.filePath), { recursive: true });
|
|
186
|
+
await fs_extra_1.default.writeFile(f.filePath, f.newCode, "utf-8");
|
|
192
187
|
})();
|
|
193
188
|
}));
|
|
189
|
+
await (0, utils_1.validateTypesAndFormatCode)({
|
|
190
|
+
validateTypes: true,
|
|
191
|
+
trace,
|
|
192
|
+
testCase: {},
|
|
193
|
+
fileChanges: updates,
|
|
194
|
+
});
|
|
194
195
|
await Promise.all(updates.map((f) => {
|
|
195
196
|
return (async () => {
|
|
196
197
|
if (fsSync.existsSync(f.filePath)) {
|
|
197
|
-
await (0, web_1.formatCode)(f.filePath);
|
|
198
198
|
await (0, web_1.lintErrors)(f.filePath);
|
|
199
199
|
}
|
|
200
200
|
})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/codegen/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAMhE,OAAO,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/codegen/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAMhE,OAAO,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAK7D,wBAAsB,YAAY,CAChC,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,oBAAoB,EAC7B,KAAK,CAAC,EAAE,WAAW,GAClB,OAAO,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC,CAkC5B"}
|
|
@@ -11,6 +11,7 @@ const context_1 = require("../../bin/utils/context");
|
|
|
11
11
|
const web_1 = require("../../bin/utils/platform/web");
|
|
12
12
|
const repo_edit_1 = require("./repo-edit");
|
|
13
13
|
const update_flow_1 = require("./update-flow");
|
|
14
|
+
const utils_1 = require("./utils");
|
|
14
15
|
async function generateTest(testCase, file, options, trace) {
|
|
15
16
|
const logger = new logger_1.CustomLogger();
|
|
16
17
|
if (!fs_extra_1.default.existsSync(file)) {
|
|
@@ -37,14 +38,10 @@ async function generateTest(testCase, file, options, trace) {
|
|
|
37
38
|
testFilePath: file,
|
|
38
39
|
},
|
|
39
40
|
});
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
Test suite: ${testCase.suites?.join("->") || "-"}
|
|
45
|
-
Scenario: ${testCase.steps.join("\n")}
|
|
46
|
-
`;
|
|
47
|
-
const repoAgentResponse = await (0, repo_edit_1.repoEditAgent)({ trace, task });
|
|
41
|
+
const repoAgentResponse = await (0, repo_edit_1.repoEditAgent)({
|
|
42
|
+
trace,
|
|
43
|
+
task: (0, utils_1.getTaskForCreateTest)({ testCase, file }),
|
|
44
|
+
});
|
|
48
45
|
createTestSpan?.end({ output: repoAgentResponse.fileChanges });
|
|
49
46
|
await (0, llm_1.flushAllTraces)();
|
|
50
47
|
}
|
|
@@ -84,4 +84,8 @@ export declare function validateTypesAndFormatCode({ validateTypes, trace, testC
|
|
|
84
84
|
pomPrompt?: string;
|
|
85
85
|
nonSpecFilePrompt?: string;
|
|
86
86
|
}): Promise<void>;
|
|
87
|
+
export declare function getTaskForCreateTest({ testCase, file, }: {
|
|
88
|
+
testCase: TestCase;
|
|
89
|
+
file: string;
|
|
90
|
+
}): string;
|
|
87
91
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/agent/codegen/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIhE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAMhD,OAAO,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAG7D;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG;IACjD,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B,EAAE,CAiBF;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG;IACvD,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,cAAc,E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,EACpB,KAAK,EACL,QAAQ,EACR,WAAW,EACX,MAAM,EACN,cAAc,EACd,SAAS,EACT,iBAAiB,GAClB,EAAE;IACD,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,QAAQ,EAAE,QAAQ,CAAC;IACnB,WAAW,EAAE;QACX,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;QAC7B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;QAC5B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;QAC5B,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;KAC5B,EAAE,CAAC;IACJ,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,cAAc,CAAC,EAAE,oBAAoB,CAAC;IACtC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,iBA6BA;AAED,wBAAgB,oBAAoB,CAAC,EACnC,QAAQ,EACR,IAAI,GACL,EAAE;IACD,QAAQ,EAAE,QAAQ,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;CACd,UAaA"}
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.validateTypesAndFormatCode = exports.applyFileChanges = exports.extractTestStepsSuggestions = exports.extractAppendTestUpdates = exports.extractTestUpdates = void 0;
|
|
6
|
+
exports.getTaskForCreateTest = exports.validateTypesAndFormatCode = exports.applyFileChanges = exports.extractTestStepsSuggestions = exports.extractAppendTestUpdates = exports.extractTestUpdates = void 0;
|
|
7
7
|
const llm_1 = require("@empiricalrun/llm");
|
|
8
8
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
9
9
|
const ts_morph_1 = require("ts-morph");
|
|
@@ -229,3 +229,16 @@ async function validateTypesAndFormatCode({ validateTypes = true, trace, testCas
|
|
|
229
229
|
await (0, llm_1.flushAllTraces)();
|
|
230
230
|
}
|
|
231
231
|
exports.validateTypesAndFormatCode = validateTypesAndFormatCode;
|
|
232
|
+
function getTaskForCreateTest({ testCase, file, }) {
|
|
233
|
+
return `
|
|
234
|
+
Create a new test case with name '${testCase.name}' at file path '${file}'
|
|
235
|
+
${testCase.suites.length
|
|
236
|
+
? `
|
|
237
|
+
Put this test case inside describe blocks named: ${testCase.suites.join(" > ")}`
|
|
238
|
+
: ""}
|
|
239
|
+
|
|
240
|
+
In the above test, write code that performs these actions and ONLY these actions:
|
|
241
|
+
${testCase.steps.join("\n")}
|
|
242
|
+
`;
|
|
243
|
+
}
|
|
244
|
+
exports.getTaskForCreateTest = getTaskForCreateTest;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TraceClient } from "@empiricalrun/llm";
|
|
2
|
+
type ArgsT = {
|
|
3
|
+
testBlock: string;
|
|
4
|
+
testFilePath: string;
|
|
5
|
+
suggestionForFix: string;
|
|
6
|
+
trace?: TraceClient;
|
|
7
|
+
};
|
|
8
|
+
export declare const enrichPromptWithFailingLine: ({ trace, testBlock, testFilePath, suggestionForFix, }: ArgsT) => Promise<{
|
|
9
|
+
output: string;
|
|
10
|
+
is_user_message_enriched: boolean;
|
|
11
|
+
reason_for_output: string;
|
|
12
|
+
}>;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/enrich-prompt/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAKhE,KAAK,KAAK,GAAG;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB,CAAC;AAgCF,eAAO,MAAM,2BAA2B,0DAKrC,KAAK;YACE,MAAM;8BACY,OAAO;uBACd,MAAM;EA+D1B,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.enrichPromptWithFailingLine = void 0;
|
|
4
|
+
const llm_1 = require("@empiricalrun/llm");
|
|
5
|
+
const constants_1 = require("../../constants");
|
|
6
|
+
const utils_1 = require("./utils");
|
|
7
|
+
const promptName = "generate-self-heal-requested-change";
|
|
8
|
+
const responseFormat = {
|
|
9
|
+
type: "json_schema",
|
|
10
|
+
json_schema: {
|
|
11
|
+
name: "analyze_user_message_and_conditionally_enrich_it",
|
|
12
|
+
strict: true,
|
|
13
|
+
schema: {
|
|
14
|
+
type: "object",
|
|
15
|
+
properties: {
|
|
16
|
+
reason_for_output: {
|
|
17
|
+
type: "string",
|
|
18
|
+
description: "provide reason in both cases whether the user message was enriched or not",
|
|
19
|
+
},
|
|
20
|
+
is_user_message_enriched: {
|
|
21
|
+
type: "boolean",
|
|
22
|
+
description: "whether the user message should be enriched or not",
|
|
23
|
+
},
|
|
24
|
+
output: {
|
|
25
|
+
type: "string",
|
|
26
|
+
description: "This is the final output after analyzing the user message, and optionally enriching it.",
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
required: ["is_user_message_enriched", "output", "reason_for_output"],
|
|
30
|
+
additionalProperties: false,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
// TODO: fix the format
|
|
35
|
+
const enrichPromptWithFailingLine = async ({ trace, testBlock, testFilePath, suggestionForFix, }) => {
|
|
36
|
+
let output = {
|
|
37
|
+
output: suggestionForFix,
|
|
38
|
+
is_user_message_enriched: false,
|
|
39
|
+
reason_for_output: "",
|
|
40
|
+
};
|
|
41
|
+
try {
|
|
42
|
+
const instructions = await (0, llm_1.getPrompt)(promptName, {
|
|
43
|
+
testBlock,
|
|
44
|
+
testFilePath,
|
|
45
|
+
userMessage: suggestionForFix,
|
|
46
|
+
}, 26);
|
|
47
|
+
trace?.event({
|
|
48
|
+
name: "get prompt",
|
|
49
|
+
input: {
|
|
50
|
+
promptName,
|
|
51
|
+
testBlock,
|
|
52
|
+
testFilePath,
|
|
53
|
+
userMessage: suggestionForFix,
|
|
54
|
+
},
|
|
55
|
+
output: { instructions },
|
|
56
|
+
});
|
|
57
|
+
const llm = new llm_1.LLM({
|
|
58
|
+
trace,
|
|
59
|
+
providerApiKey: constants_1.MODEL_API_KEYS["anthropic"],
|
|
60
|
+
provider: "anthropic",
|
|
61
|
+
defaultModel: "claude-3-5-sonnet-latest",
|
|
62
|
+
});
|
|
63
|
+
const llmResponse = await llm.createChatCompletion({
|
|
64
|
+
messages: instructions,
|
|
65
|
+
trace,
|
|
66
|
+
modelParameters: {
|
|
67
|
+
temperature: 0.5,
|
|
68
|
+
},
|
|
69
|
+
responseFormat,
|
|
70
|
+
});
|
|
71
|
+
const generateRequestedChangeResponse = (0, utils_1.extractGenerateRequestedChange)(llmResponse?.content);
|
|
72
|
+
output = {
|
|
73
|
+
output: generateRequestedChangeResponse.output,
|
|
74
|
+
is_user_message_enriched: generateRequestedChangeResponse.is_user_message_enriched,
|
|
75
|
+
reason_for_output: generateRequestedChangeResponse.reason_for_output,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
catch (e) {
|
|
79
|
+
console.error(`Failed to generate requested change for test - "${testBlock}", suggestion - "${suggestionForFix}"`, e);
|
|
80
|
+
}
|
|
81
|
+
return output;
|
|
82
|
+
};
|
|
83
|
+
exports.enrichPromptWithFailingLine = enrichPromptWithFailingLine;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/agent/enrich-prompt/utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,MAAM,GAAG;IAC7D,iBAAiB,EAAE,MAAM,CAAC;IAC1B,wBAAwB,EAAE,OAAO,CAAC;IAClC,MAAM,EAAE,MAAM,CAAC;CAChB,CAQA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extractGenerateRequestedChange = void 0;
|
|
4
|
+
function extractGenerateRequestedChange(input) {
|
|
5
|
+
const regex = /<reason_for_output>([\s\S]*?)<\/reason_for_output>[\s\S]*?<is_user_message_enriched>([\s\S]*?)<\/is_user_message_enriched>[\s\S]*?<output>([\s\S]*?)<\/output>/g;
|
|
6
|
+
const match = regex.exec(input);
|
|
7
|
+
const reason_for_output = match[1]?.trim() || "";
|
|
8
|
+
const is_user_message_enriched = match[2]?.trim() === "true";
|
|
9
|
+
const output = match[3]?.trim() || "";
|
|
10
|
+
return { reason_for_output, is_user_message_enriched, output };
|
|
11
|
+
}
|
|
12
|
+
exports.extractGenerateRequestedChange = extractGenerateRequestedChange;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-scenario-agent.evals.d.ts","sourceRoot":"","sources":["../../src/evals/add-scenario-agent.evals.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"add-scenario-agent.evals.d.ts","sourceRoot":"","sources":["../../src/evals/add-scenario-agent.evals.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAqCpC,QAAA,MAAM,4BAA4B,EAAE,UAqBnC,CAAC;AAEF,eAAe,4BAA4B,CAAC"}
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const path_1 = __importDefault(require("path"));
|
|
3
7
|
const repo_edit_1 = require("../agent/codegen/repo-edit");
|
|
8
|
+
const utils_1 = require("../agent/codegen/utils");
|
|
4
9
|
function evaluateEqualityScore({ currentOutput, expectedOutput, }) {
|
|
5
10
|
for (const expectedFile of expectedOutput) {
|
|
6
11
|
if (!currentOutput.find((output) => {
|
|
7
|
-
|
|
12
|
+
if (output.filePath && expectedFile.filePath) {
|
|
13
|
+
return (path_1.default.basename(output.filePath) ===
|
|
14
|
+
path_1.default.basename(expectedFile.filePath));
|
|
15
|
+
}
|
|
16
|
+
return false;
|
|
8
17
|
})) {
|
|
9
18
|
return 0;
|
|
10
19
|
}
|
|
@@ -13,16 +22,9 @@ function evaluateEqualityScore({ currentOutput, expectedOutput, }) {
|
|
|
13
22
|
}
|
|
14
23
|
const addScenarioCodeAgentEvaluate = async ({ item, trace }) => {
|
|
15
24
|
const { testCase, testFilePath, pageFiles, testFiles } = item.input;
|
|
16
|
-
const task = `
|
|
17
|
-
Create a new test at the given test file path and perform the relevant changes required:\n
|
|
18
|
-
Scenario name: ${testCase.name}
|
|
19
|
-
Test file path: ${testFilePath}
|
|
20
|
-
Test suite: ${testCase.suites?.join("->") || "-"}
|
|
21
|
-
Scenario: ${testCase.steps.join("\n")}
|
|
22
|
-
`;
|
|
23
25
|
const repoFiles = pageFiles + testFiles;
|
|
24
26
|
const repoAgentOutput = await (0, repo_edit_1.generateCodeUsingRepoAgent)({
|
|
25
|
-
task,
|
|
27
|
+
task: (0, utils_1.getTaskForCreateTest)({ testCase, file: testFilePath }),
|
|
26
28
|
trace,
|
|
27
29
|
repoFiles,
|
|
28
30
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/reporter/index.ts"],"names":[],"mappings":"AACA,OAAO,EAA4B,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAa5E,KAAK,kBAAkB,GAAG;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,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AC,IAAI,CAAC;IAY1C,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAWxD"}
|
package/dist/reporter/index.js
CHANGED
|
@@ -95,6 +95,10 @@ class TestGenUpdatesReporter {
|
|
|
95
95
|
logger.log("Skipped uploading current view screenshot");
|
|
96
96
|
return;
|
|
97
97
|
}
|
|
98
|
+
if (!reporterConfig) {
|
|
99
|
+
logger.log("Reporter config is not set skipping screenshot uploads.");
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
98
102
|
try {
|
|
99
103
|
// upload current screenshot to r2 and report it to reporter
|
|
100
104
|
if (!fs_extra_1.default.existsSync(path_1.default.join(process.cwd(), "gen-assets"))) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empiricalrun/test-gen",
|
|
3
|
-
"version": "0.41.
|
|
3
|
+
"version": "0.41.2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org/",
|
|
6
6
|
"access": "public"
|
|
@@ -22,6 +22,10 @@
|
|
|
22
22
|
"types": "./dist/agent/master/planner.d.ts",
|
|
23
23
|
"default": "./dist/agent/master/planner.js"
|
|
24
24
|
},
|
|
25
|
+
"./agent/enrich-prompt": {
|
|
26
|
+
"types": "./dist/agent/enrich-prompt/index.d.ts",
|
|
27
|
+
"default": "./dist/agent/enrich-prompt/index.js"
|
|
28
|
+
},
|
|
25
29
|
"./types": {
|
|
26
30
|
"types": "./dist/types/index.d.ts",
|
|
27
31
|
"default": "./dist/types/index.js"
|