@empiricalrun/test-gen 0.18.0 → 0.19.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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @empiricalrun/test-gen
|
|
2
2
|
|
|
3
|
+
## 0.19.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [b7797f9]
|
|
8
|
+
- @empiricalrun/reporter@0.12.3
|
|
9
|
+
|
|
10
|
+
## 0.19.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- 2087461: feat: remove LLMTracing class and use native methods
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [2087461]
|
|
19
|
+
- @empiricalrun/llm@0.4.0
|
|
20
|
+
|
|
3
21
|
## 0.18.0
|
|
4
22
|
|
|
5
23
|
### Minor Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAWlC,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAInD,KAAK,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC,GAAG;IAC1D,YAAY,CAAC,EAAE;QACb,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;KAC9B,CAAC;CACH,CAAC;AAEF,wBAAsB,aAAa,CACjC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,oBAAoB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAWlC,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAInD,KAAK,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC,GAAG;IAC1D,YAAY,CAAC,EAAE;QACb,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;KAC9B,CAAC;CACH,CAAC;AAEF,wBAAsB,aAAa,CACjC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,oBAAoB,mBAkG9B"}
|
|
@@ -10,9 +10,11 @@ const html_1 = require("../../utils/html");
|
|
|
10
10
|
const utils_1 = require("./utils");
|
|
11
11
|
async function browsingAgent(task, page, options) {
|
|
12
12
|
const logger = new logger_1.CustomLogger();
|
|
13
|
-
const
|
|
13
|
+
const session = (0, session_1.getSessionDetails)();
|
|
14
|
+
const trace = llm_1.langfuseInstance.trace({
|
|
14
15
|
name: "browsing-agent",
|
|
15
|
-
|
|
16
|
+
id: session.id,
|
|
17
|
+
release: session.version,
|
|
16
18
|
tags: [
|
|
17
19
|
options.metadata?.projectName,
|
|
18
20
|
options.metadata?.environment,
|
|
@@ -26,13 +28,13 @@ async function browsingAgent(task, page, options) {
|
|
|
26
28
|
trace.update({ input: { task } });
|
|
27
29
|
let lastActionExecTrace = "";
|
|
28
30
|
while (!isTaskDone) {
|
|
29
|
-
const pageContentSpan = trace.
|
|
31
|
+
const pageContentSpan = trace.span({ name: "page-content" });
|
|
30
32
|
const pageContent = await page.content();
|
|
31
33
|
pageContentSpan.end({ output: { pageContent } });
|
|
32
|
-
const sanitizationSpan = trace.
|
|
34
|
+
const sanitizationSpan = trace.span({ name: "page-sanitization" });
|
|
33
35
|
const pageSnapshot = (0, html_1.sanitizeHtml)(pageContent, options.htmlSanitize);
|
|
34
36
|
sanitizationSpan.end({ output: { pageSnapshot } });
|
|
35
|
-
const promptSpan = trace.
|
|
37
|
+
const promptSpan = trace.span({ name: "page-prompt" });
|
|
36
38
|
// extract all successful actions
|
|
37
39
|
const successfulActions = executedActions
|
|
38
40
|
.filter((a) => !a.isError)
|
|
@@ -93,7 +95,7 @@ async function browsingAgent(task, page, options) {
|
|
|
93
95
|
const code = actions.generateCode();
|
|
94
96
|
trace.update({ input: { task }, output: { code } });
|
|
95
97
|
logger.success("Successfully generated code for the given task");
|
|
96
|
-
logger.log(`Trace: ${trace.
|
|
98
|
+
logger.log(`Trace: ${trace.getTraceUrl()}`);
|
|
97
99
|
return code;
|
|
98
100
|
}
|
|
99
101
|
exports.browsingAgent = browsingAgent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/codegen/run.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAE7D,wBAAsB,YAAY,CAChC,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,QAAQ,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/codegen/run.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAE7D,wBAAsB,YAAY,CAChC,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,QAAQ,EAAE,CAAC,CAmJrB"}
|
|
@@ -21,9 +21,11 @@ async function generateTest(testCase, file, options) {
|
|
|
21
21
|
const { codePrompt, pomPrompt, testFileContent } = context;
|
|
22
22
|
const generatedTestCases = [];
|
|
23
23
|
logger.logEmptyLine();
|
|
24
|
-
const
|
|
24
|
+
const session = (0, session_1.getSessionDetails)();
|
|
25
|
+
const trace = llm_1.langfuseInstance.trace({
|
|
25
26
|
name: "generate-test",
|
|
26
|
-
|
|
27
|
+
id: session.id,
|
|
28
|
+
release: session.version,
|
|
27
29
|
tags: [options.metadata.projectName, options.metadata.environment].filter((s) => !!s),
|
|
28
30
|
});
|
|
29
31
|
trace.event({
|
|
@@ -36,7 +38,9 @@ async function generateTest(testCase, file, options) {
|
|
|
36
38
|
});
|
|
37
39
|
trace.update({ input: { testCase } });
|
|
38
40
|
const isUpdate = testFileContent.includes(`test("${testCase?.name}"`);
|
|
39
|
-
const promptSpan = trace.
|
|
41
|
+
const promptSpan = trace.span({
|
|
42
|
+
name: isUpdate ? "update-scenario-prompt" : "add-scenario-prompt",
|
|
43
|
+
});
|
|
40
44
|
const promptName = isUpdate ? "update-scenario" : "add-scenario";
|
|
41
45
|
const instruction = await (0, llm_1.getPrompt)(promptName, {
|
|
42
46
|
testFiles: codePrompt,
|
|
@@ -59,7 +63,7 @@ async function generateTest(testCase, file, options) {
|
|
|
59
63
|
});
|
|
60
64
|
let response = firstShotMessage?.content || "";
|
|
61
65
|
logger.success("Test generated successfully!");
|
|
62
|
-
const readWriteFileSpan = trace.
|
|
66
|
+
const readWriteFileSpan = trace.span({ name: "write-to-file" });
|
|
63
67
|
let contents = fs_extra_1.default.readFileSync(file, "utf-8");
|
|
64
68
|
const [prependContent, strippedContent] = await (0, web_1.stripAndPrependImports)(response);
|
|
65
69
|
let updatedContent = prependContent + contents + `\n\n${strippedContent}`;
|
|
@@ -73,7 +77,7 @@ async function generateTest(testCase, file, options) {
|
|
|
73
77
|
logger.log("Linting generated code...");
|
|
74
78
|
trace.event({ name: "lint-file" });
|
|
75
79
|
await (0, web_1.lintErrors)(file);
|
|
76
|
-
const validateTypesSpan = trace.
|
|
80
|
+
const validateTypesSpan = trace.span({ name: "detect-type-errors-in-file" });
|
|
77
81
|
logger.log("Validating types...");
|
|
78
82
|
let errors = (0, web_1.validateTypescript)(file);
|
|
79
83
|
validateTypesSpan.end({ output: { errors } });
|
|
@@ -90,7 +94,7 @@ async function generateTest(testCase, file, options) {
|
|
|
90
94
|
logger.error([
|
|
91
95
|
`Unable to fix typescript errors. Please review ${file} manually and fix the typescript errors.`,
|
|
92
96
|
`Run the test-gen command again, once errors are fixed.`,
|
|
93
|
-
`Trace: ${trace.
|
|
97
|
+
`Trace: ${trace.getTraceUrl()}`,
|
|
94
98
|
].join("\n"));
|
|
95
99
|
break;
|
|
96
100
|
}
|
|
@@ -98,7 +102,7 @@ async function generateTest(testCase, file, options) {
|
|
|
98
102
|
logger.warn("Found few errors while validating types:");
|
|
99
103
|
errors.forEach((e) => logger.warn(e));
|
|
100
104
|
logger.log("Trying to fix above errors...");
|
|
101
|
-
const promptSpan = trace.
|
|
105
|
+
const promptSpan = trace.span({ name: "fix-type-errors-prompt" });
|
|
102
106
|
const instruction = await (0, llm_1.getPrompt)("fix-file-errors-ts", {
|
|
103
107
|
testFiles: codePrompt || "",
|
|
104
108
|
pageFiles: pomPrompt || "",
|
|
@@ -120,12 +124,14 @@ async function generateTest(testCase, file, options) {
|
|
|
120
124
|
},
|
|
121
125
|
});
|
|
122
126
|
response = message?.content || "";
|
|
123
|
-
const readWriteFileSpan = trace.
|
|
127
|
+
const readWriteFileSpan = trace.span({ name: "write-to-file" });
|
|
124
128
|
await fs_extra_1.default.writeFile(file, response, "utf-8");
|
|
125
129
|
readWriteFileSpan.end({ output: { response } });
|
|
126
130
|
trace.event({ name: "lint-file" });
|
|
127
131
|
await (0, web_1.lintErrors)(file);
|
|
128
|
-
const validateTypesSpan = trace.
|
|
132
|
+
const validateTypesSpan = trace.span({
|
|
133
|
+
name: "detect-type-errors-in-file",
|
|
134
|
+
});
|
|
129
135
|
errors = (0, web_1.validateTypescript)(file);
|
|
130
136
|
validateTypesSpan.end({ output: { errors } });
|
|
131
137
|
if (!errors.length) {
|
|
@@ -135,7 +141,7 @@ async function generateTest(testCase, file, options) {
|
|
|
135
141
|
trace.event({ name: "format-file" });
|
|
136
142
|
await (0, web_1.formatCode)(file);
|
|
137
143
|
logger.success("File formatted successfully!");
|
|
138
|
-
logger.log(`Trace: ${trace.
|
|
144
|
+
logger.log(`Trace: ${trace.getTraceUrl()}`);
|
|
139
145
|
generatedTestCases.push(testCase);
|
|
140
146
|
trace.update({ input: { testCase }, output: { response } });
|
|
141
147
|
return generatedTestCases;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empiricalrun/test-gen",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org/",
|
|
6
6
|
"access": "public"
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"slugify": "^1.6.6",
|
|
41
41
|
"tsx": "^4.16.2",
|
|
42
42
|
"typescript": "^5.3.3",
|
|
43
|
-
"@empiricalrun/llm": "^0.
|
|
44
|
-
"@empiricalrun/reporter": "^0.12.
|
|
43
|
+
"@empiricalrun/llm": "^0.4.0",
|
|
44
|
+
"@empiricalrun/reporter": "^0.12.3"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/detect-port": "^1.3.5",
|