@empiricalrun/test-gen 0.63.0 → 0.64.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 +38 -0
- package/dist/agent/browsing/run.d.ts +2 -1
- package/dist/agent/browsing/run.d.ts.map +1 -1
- package/dist/agent/browsing/run.js +25 -12
- package/dist/agent/browsing/utils.d.ts +1 -1
- package/dist/agent/browsing/utils.d.ts.map +1 -1
- package/dist/agent/browsing/utils.js +5 -4
- package/dist/agent/chat/index.d.ts.map +1 -1
- package/dist/agent/chat/index.js +2 -0
- package/dist/agent/chat/models.js +1 -1
- package/dist/agent/cua/computer.d.ts.map +1 -1
- package/dist/agent/cua/computer.js +45 -24
- package/dist/agent/cua/pw-codegen/element-from-point.d.ts +3 -1
- package/dist/agent/cua/pw-codegen/element-from-point.d.ts.map +1 -1
- package/dist/agent/cua/pw-codegen/element-from-point.js +73 -56
- package/dist/agent/cua/pw-codegen/types.d.ts +2 -1
- package/dist/agent/cua/pw-codegen/types.d.ts.map +1 -1
- package/dist/artifacts/utils.d.ts +21 -0
- package/dist/artifacts/utils.d.ts.map +1 -0
- package/dist/artifacts/utils.js +102 -0
- package/dist/bin/index.js +2 -1
- package/dist/bin/utils/platform/web/index.d.ts.map +1 -1
- package/dist/bin/utils/platform/web/index.js +2 -0
- package/dist/file/server.js +1 -1
- package/dist/test-build/index.js +1 -1
- package/dist/tool-call-service/index.d.ts +5 -2
- package/dist/tool-call-service/index.d.ts.map +1 -1
- package/dist/tool-call-service/index.js +11 -2
- package/dist/tool-call-service/utils.d.ts +1 -0
- package/dist/tool-call-service/utils.d.ts.map +1 -1
- package/dist/tool-call-service/utils.js +6 -2
- package/dist/tools/commit-and-create-pr.d.ts +1 -1
- package/dist/tools/commit-and-create-pr.d.ts.map +1 -1
- package/dist/tools/commit-and-create-pr.js +1 -1
- package/dist/tools/diagnosis-fetcher.d.ts +1 -1
- package/dist/tools/diagnosis-fetcher.d.ts.map +1 -1
- package/dist/tools/diagnosis-fetcher.js +1 -1
- package/dist/tools/download-build.d.ts +1 -1
- package/dist/tools/download-build.d.ts.map +1 -1
- package/dist/tools/download-build.js +1 -1
- package/dist/tools/environment-crud.d.ts +1 -1
- package/dist/tools/environment-crud.d.ts.map +1 -1
- package/dist/tools/environment-crud.js +1 -1
- package/dist/tools/grep/index.d.ts +1 -1
- package/dist/tools/grep/index.d.ts.map +1 -1
- package/dist/tools/grep/index.js +4 -3
- package/dist/tools/str_replace_editor.d.ts +5 -7
- package/dist/tools/str_replace_editor.d.ts.map +1 -1
- package/dist/tools/str_replace_editor.js +259 -247
- package/dist/tools/test-gen-browser.d.ts +1 -1
- package/dist/tools/test-gen-browser.d.ts.map +1 -1
- package/dist/tools/test-gen-browser.js +45 -20
- package/dist/tools/test-run-fetcher/index.d.ts +1 -1
- package/dist/tools/test-run-fetcher/index.d.ts.map +1 -1
- package/dist/tools/test-run-fetcher/index.js +1 -1
- package/dist/tools/test-run.d.ts +1 -1
- package/dist/tools/test-run.d.ts.map +1 -1
- package/dist/tools/test-run.js +35 -12
- package/dist/tools/utils/index.d.ts +0 -13
- package/dist/tools/utils/index.d.ts.map +1 -1
- package/dist/tools/utils/index.js +0 -47
- package/dist/utils/exec.d.ts +4 -4
- package/dist/utils/exec.d.ts.map +1 -1
- package/dist/utils/exec.js +2 -4
- package/dist/utils/file-tree.d.ts.map +1 -1
- package/dist/utils/file-tree.js +2 -0
- package/package.json +4 -4
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/tools/codegen-agent.d.ts +0 -3
- package/dist/tools/codegen-agent.d.ts.map +0 -1
- package/dist/tools/codegen-agent.js +0 -40
|
@@ -5,7 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.generateTestWithBrowserAgent = void 0;
|
|
7
7
|
const test_run_1 = require("@empiricalrun/test-run");
|
|
8
|
-
const
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
9
10
|
const zod_1 = require("zod");
|
|
10
11
|
const run_1 = require("../agent/browsing/run");
|
|
11
12
|
const utils_1 = require("../agent/browsing/utils");
|
|
@@ -17,12 +18,18 @@ const BrowserAgentSchema = zod_1.z.object({
|
|
|
17
18
|
testSuites: zod_1.z
|
|
18
19
|
.array(zod_1.z.string())
|
|
19
20
|
.describe("The suites (describe blocks) where the test is located"),
|
|
20
|
-
|
|
21
|
+
filePath: zod_1.z
|
|
21
22
|
.string()
|
|
22
|
-
.describe("
|
|
23
|
+
.describe("Path of the file where the test is located. Path must be relative to the root of the repository. File name must end with .spec.ts. For example: tests/lesson.spec.ts"),
|
|
23
24
|
project: zod_1.z
|
|
24
25
|
.string()
|
|
25
26
|
.describe("The Playwright project to run tests against (e.g. 'chromium' or 'firefox')"),
|
|
27
|
+
buildUrl: zod_1.z
|
|
28
|
+
.string()
|
|
29
|
+
.optional()
|
|
30
|
+
.describe(`The URL of the build to run the test on.
|
|
31
|
+
This is ONLY useful for preview deployments that are dynamically created on every pull request, like Vercel preview deployments.
|
|
32
|
+
For all other cases, the build url does not need to be provided, since it is already hard coded in the test repo.`),
|
|
26
33
|
changeToMake: zod_1.z.string().describe("The change to make to the test"),
|
|
27
34
|
});
|
|
28
35
|
const BROWSER_AGENT_DESCRIPTION = `
|
|
@@ -88,12 +95,17 @@ exports.generateTestWithBrowserAgent = {
|
|
|
88
95
|
description: BROWSER_AGENT_DESCRIPTION,
|
|
89
96
|
parameters: BrowserAgentSchema,
|
|
90
97
|
},
|
|
91
|
-
execute: async (input, repoPath,
|
|
92
|
-
const
|
|
93
|
-
const
|
|
98
|
+
execute: async ({ input, repoPath, trace, collectArtifacts, }) => {
|
|
99
|
+
const { filePath, project } = input;
|
|
100
|
+
const absoluteFilePath = path_1.default.join(repoPath, filePath);
|
|
101
|
+
if (!fs_1.default.existsSync(absoluteFilePath)) {
|
|
102
|
+
return {
|
|
103
|
+
isError: true,
|
|
104
|
+
result: `Could not find file in repository: ${filePath}. Did you use the full path relative to the root of the repository?`,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
94
107
|
try {
|
|
95
|
-
const { projects } = await (0, test_run_1.getAllPlaywrightProjects)(
|
|
96
|
-
// TODO: Check that file path is valid for this project
|
|
108
|
+
const { projects } = await (0, test_run_1.getAllPlaywrightProjects)(repoPath);
|
|
97
109
|
if (!projects.includes(project)) {
|
|
98
110
|
return {
|
|
99
111
|
isError: true,
|
|
@@ -108,20 +120,25 @@ exports.generateTestWithBrowserAgent = {
|
|
|
108
120
|
result: `Error reading playwright config: ${error}`,
|
|
109
121
|
};
|
|
110
122
|
}
|
|
111
|
-
|
|
123
|
+
const { testName, testSuites } = input;
|
|
124
|
+
if (!(0, web_1.hasTestBlock)({
|
|
125
|
+
testName,
|
|
126
|
+
testSuites,
|
|
127
|
+
filePath: absoluteFilePath,
|
|
128
|
+
})) {
|
|
112
129
|
return {
|
|
113
130
|
isError: true,
|
|
114
|
-
result: `Test block not found for test name: "${testName}" in file: "${
|
|
131
|
+
result: `Test block not found for test name: "${testName}" in file: "${filePath}" with describe blocks: "${testSuites.join(", ")}"`,
|
|
115
132
|
};
|
|
116
133
|
}
|
|
117
134
|
// Prepare the file for the browser agent
|
|
118
|
-
const fileBackup =
|
|
135
|
+
const fileBackup = fs_1.default.readFileSync(absoluteFilePath, "utf-8");
|
|
119
136
|
try {
|
|
120
|
-
await (0, utils_1.replaceTodoWithCreateTest)(
|
|
137
|
+
await (0, utils_1.replaceTodoWithCreateTest)(filePath, repoPath);
|
|
121
138
|
}
|
|
122
139
|
catch (error) {
|
|
123
140
|
// Undo the TODO -> createTest and test.only changes
|
|
124
|
-
|
|
141
|
+
fs_1.default.writeFileSync(absoluteFilePath, fileBackup, "utf-8");
|
|
125
142
|
return {
|
|
126
143
|
isError: true,
|
|
127
144
|
result: `Error running tool: ${error}`,
|
|
@@ -130,27 +147,35 @@ exports.generateTestWithBrowserAgent = {
|
|
|
130
147
|
try {
|
|
131
148
|
// Prepare playwright for codegen
|
|
132
149
|
console.log("[generateTestWithBrowserAgent] Preparing playwright for codegen");
|
|
133
|
-
await (0, pw_pause_1.preparePlaywrightForCodegen)(
|
|
150
|
+
await (0, pw_pause_1.preparePlaywrightForCodegen)(repoPath);
|
|
134
151
|
}
|
|
135
152
|
catch (err) {
|
|
136
153
|
console.warn("[generateTestWithBrowserAgent] Error preparing playwright for codegen", err);
|
|
137
154
|
}
|
|
138
|
-
|
|
155
|
+
let envOverrides = {};
|
|
156
|
+
if (input.buildUrl) {
|
|
157
|
+
envOverrides = {
|
|
158
|
+
...envOverrides,
|
|
159
|
+
BUILD_URL: input.buildUrl,
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
const testGenToken = (0, scenarios_1.buildTokenFromOptions)({ name: testName, file: filePath, prompt: input.changeToMake }, { useComputerUseAgent: true });
|
|
139
163
|
console.log("[generateTestWithBrowserAgent] Validations passed, starting agent");
|
|
140
164
|
const toolResult = await (0, run_1.generateTestsUsingMasterAgent)({
|
|
141
165
|
testCaseName: testName,
|
|
142
166
|
testCaseSuites: testSuites,
|
|
143
|
-
testFilePath:
|
|
144
|
-
filePathToUpdate:
|
|
167
|
+
testFilePath: filePath,
|
|
168
|
+
filePathToUpdate: filePath,
|
|
145
169
|
projectName: project,
|
|
146
170
|
traceId: trace?.id,
|
|
147
171
|
testGenToken,
|
|
148
|
-
repoDir,
|
|
172
|
+
repoDir: repoPath,
|
|
149
173
|
editFileWithGeneratedCode: false,
|
|
174
|
+
envOverrides,
|
|
150
175
|
});
|
|
151
176
|
// Cleanup: Undo the TODO -> createTest changes
|
|
152
|
-
await (0, pw_pause_1.revertToOriginalPwCode)(
|
|
153
|
-
|
|
177
|
+
await (0, pw_pause_1.revertToOriginalPwCode)(repoPath);
|
|
178
|
+
fs_1.default.writeFileSync(absoluteFilePath, fileBackup, "utf-8");
|
|
154
179
|
const { isError, error, actionsSummary, artifacts } = toolResult;
|
|
155
180
|
if (artifacts) {
|
|
156
181
|
void collectArtifacts?.(artifacts);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Tool } from "@empiricalrun/
|
|
1
|
+
import type { Tool } from "@empiricalrun/shared-types";
|
|
2
2
|
export declare function extractPathAfterSourceRepo(fullPath: string): string;
|
|
3
3
|
export declare const fetchTestRunReportTool: Tool;
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/test-run-fetcher/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/test-run-fetcher/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAcvD,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAOnE;AAED,eAAO,MAAM,sBAAsB,EAAE,IA+HpC,CAAC"}
|
|
@@ -24,7 +24,7 @@ exports.fetchTestRunReportTool = {
|
|
|
24
24
|
description: "Fetch details about a test run using its URL",
|
|
25
25
|
parameters: TestRunSchema,
|
|
26
26
|
},
|
|
27
|
-
execute: async (input,
|
|
27
|
+
execute: async ({ input, apiKey, }) => {
|
|
28
28
|
const { testRunUrl } = input;
|
|
29
29
|
// Remove query parameters if they exist
|
|
30
30
|
const urlWithoutParams = testRunUrl.split("?")[0] || testRunUrl;
|
package/dist/tools/test-run.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-run.d.ts","sourceRoot":"","sources":["../../src/tools/test-run.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"test-run.d.ts","sourceRoot":"","sources":["../../src/tools/test-run.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAc,MAAM,4BAA4B,CAAC;AAsDnE,eAAO,MAAM,WAAW,EAAE,IAiFzB,CAAC"}
|
package/dist/tools/test-run.js
CHANGED
|
@@ -1,19 +1,30 @@
|
|
|
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 });
|
|
3
6
|
exports.runTestTool = void 0;
|
|
4
7
|
const test_run_1 = require("@empiricalrun/test-run");
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
5
10
|
const zod_1 = require("zod");
|
|
6
11
|
const artifacts_1 = require("../artifacts");
|
|
7
|
-
const utils_1 = require("
|
|
12
|
+
const utils_1 = require("../artifacts/utils");
|
|
8
13
|
const RunTestSchema = zod_1.z.object({
|
|
9
14
|
testName: zod_1.z.string().describe("The name of the test to run"),
|
|
10
15
|
suites: zod_1.z
|
|
11
16
|
.array(zod_1.z.string())
|
|
12
17
|
.describe("The suites (describe blocks) where the test is located."),
|
|
13
|
-
|
|
18
|
+
filePath: zod_1.z
|
|
14
19
|
.string()
|
|
15
|
-
.describe("
|
|
20
|
+
.describe("Path of the file where the test is located. Path must be relative to the root of the repository. File name must end with .spec.ts. For example: tests/lesson.spec.ts"),
|
|
16
21
|
project: zod_1.z.string().describe("The project to run the test on"),
|
|
22
|
+
buildUrl: zod_1.z
|
|
23
|
+
.string()
|
|
24
|
+
.optional()
|
|
25
|
+
.describe(`The URL of the build to run the test on.
|
|
26
|
+
This is ONLY useful for preview deployments that are dynamically created on every pull request, like Vercel preview deployments.
|
|
27
|
+
For all other cases, the build url does not need to be provided, since it is already hard coded in the test repo.`),
|
|
17
28
|
});
|
|
18
29
|
function buildReportUrl(projectName, testRunId) {
|
|
19
30
|
return `https://reports.empirical.run/${projectName}/${testRunId}/index.html`;
|
|
@@ -34,9 +45,9 @@ exports.runTestTool = {
|
|
|
34
45
|
description: "Run a test",
|
|
35
46
|
parameters: RunTestSchema,
|
|
36
47
|
},
|
|
37
|
-
execute: async (input, repoPath,
|
|
48
|
+
execute: async ({ input, repoPath, collectArtifacts, }) => {
|
|
38
49
|
let reportUrl = undefined;
|
|
39
|
-
let envOverrides =
|
|
50
|
+
let envOverrides = {};
|
|
40
51
|
if ((0, artifacts_1.isArtifactCollectionEnabled)()) {
|
|
41
52
|
const projectName = "test-gen-chat-agent";
|
|
42
53
|
const testRunId = Date.now().toString();
|
|
@@ -49,16 +60,28 @@ exports.runTestTool = {
|
|
|
49
60
|
else {
|
|
50
61
|
console.warn("R2 credentials not found: report artifacts will not be uploaded");
|
|
51
62
|
}
|
|
52
|
-
const {
|
|
53
|
-
const
|
|
63
|
+
const { filePath } = input;
|
|
64
|
+
const absoluteFilePath = path_1.default.join(repoPath, filePath);
|
|
65
|
+
if (!fs_1.default.existsSync(absoluteFilePath)) {
|
|
66
|
+
return {
|
|
67
|
+
isError: true,
|
|
68
|
+
result: `File ${filePath} does not exist.`,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
if (input.buildUrl) {
|
|
72
|
+
envOverrides = {
|
|
73
|
+
...envOverrides,
|
|
74
|
+
BUILD_URL: input.buildUrl,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
54
77
|
try {
|
|
55
78
|
const result = await (0, test_run_1.runSingleTest)({
|
|
56
|
-
testName,
|
|
57
|
-
suites,
|
|
58
|
-
|
|
59
|
-
|
|
79
|
+
testName: input.testName,
|
|
80
|
+
suites: input.suites,
|
|
81
|
+
filePath,
|
|
82
|
+
repoDir: repoPath,
|
|
83
|
+
projects: [input.project],
|
|
60
84
|
envOverrides,
|
|
61
|
-
repoDir,
|
|
62
85
|
});
|
|
63
86
|
const attachments = (0, utils_1.extractAttachmentsFromPlaywrightJSONReport)(result.summaryJson);
|
|
64
87
|
void collectArtifacts?.(attachments);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { JSONReport as PlaywrightJSONReport } from "@playwright/test/reporter";
|
|
2
1
|
export declare function makeDashboardRequest<T>({ path, method, body, apiKey, }: {
|
|
3
2
|
path: string;
|
|
4
3
|
method?: string;
|
|
@@ -11,16 +10,4 @@ export declare function callGitHubProxy({ method, url, body, apiKey, }: {
|
|
|
11
10
|
body?: any;
|
|
12
11
|
apiKey: string;
|
|
13
12
|
}): Promise<unknown>;
|
|
14
|
-
type AttachmentInfo = {
|
|
15
|
-
name: string;
|
|
16
|
-
path: string;
|
|
17
|
-
contentType: string;
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* Extracts attachment information from a Playwright JSON report.
|
|
21
|
-
* @param report The Playwright JSON report to extract attachments from
|
|
22
|
-
* @returns An array of objects containing path and contentType for each attachment
|
|
23
|
-
*/
|
|
24
|
-
export declare function extractAttachmentsFromPlaywrightJSONReport(report: PlaywrightJSONReport): AttachmentInfo[];
|
|
25
|
-
export {};
|
|
26
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/utils/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/utils/index.ts"],"names":[],"mappings":"AAAA,wBAAsB,oBAAoB,CAAC,CAAC,EAAE,EAC5C,IAAI,EACJ,MAAc,EACd,IAAI,EACJ,MAAM,GACP,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CAAC,CAAC,CAAC,CAmBb;AAED,wBAAsB,eAAe,CAAC,EACpC,MAAM,EACN,GAAG,EACH,IAAI,EACJ,MAAM,GACP,EAAE;IACD,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;CAChB,oBAYA"}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.makeDashboardRequest = makeDashboardRequest;
|
|
4
4
|
exports.callGitHubProxy = callGitHubProxy;
|
|
5
|
-
exports.extractAttachmentsFromPlaywrightJSONReport = extractAttachmentsFromPlaywrightJSONReport;
|
|
6
5
|
async function makeDashboardRequest({ path, method = "GET", body, apiKey, }) {
|
|
7
6
|
const requestHeaders = {
|
|
8
7
|
"Content-Type": "application/json",
|
|
@@ -34,49 +33,3 @@ async function callGitHubProxy({ method, url, body, apiKey, }) {
|
|
|
34
33
|
apiKey,
|
|
35
34
|
});
|
|
36
35
|
}
|
|
37
|
-
/**
|
|
38
|
-
* Extracts attachment information from a Playwright JSON report.
|
|
39
|
-
* @param report The Playwright JSON report to extract attachments from
|
|
40
|
-
* @returns An array of objects containing path and contentType for each attachment
|
|
41
|
-
*/
|
|
42
|
-
function extractAttachmentsFromPlaywrightJSONReport(report) {
|
|
43
|
-
const attachments = [];
|
|
44
|
-
if (!report) {
|
|
45
|
-
return attachments;
|
|
46
|
-
}
|
|
47
|
-
function processSpec(spec) {
|
|
48
|
-
const testTitle = spec.title;
|
|
49
|
-
for (const test of spec.tests) {
|
|
50
|
-
for (const result of test.results) {
|
|
51
|
-
if (!result.attachments)
|
|
52
|
-
continue;
|
|
53
|
-
for (const attachment of result.attachments) {
|
|
54
|
-
if (attachment.path && attachment.contentType) {
|
|
55
|
-
attachments.push({
|
|
56
|
-
name: `${testTitle} ${attachment.name}`,
|
|
57
|
-
path: attachment.path,
|
|
58
|
-
contentType: attachment.contentType,
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
for (const suite of report.suites) {
|
|
66
|
-
// Process nested suites
|
|
67
|
-
if (suite.suites) {
|
|
68
|
-
for (const nestedSuite of suite.suites) {
|
|
69
|
-
for (const spec of nestedSuite.specs) {
|
|
70
|
-
processSpec(spec);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
// Process specs in current suite
|
|
75
|
-
if (suite.specs) {
|
|
76
|
-
for (const spec of suite.specs) {
|
|
77
|
-
processSpec(spec);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
return attachments;
|
|
82
|
-
}
|
package/dist/utils/exec.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
export declare class ProcessManager {
|
|
2
2
|
private childProcess;
|
|
3
3
|
execute(command: string, args: string[], options: {
|
|
4
|
-
|
|
5
|
-
cwd
|
|
4
|
+
envOverrides: Record<string, string>;
|
|
5
|
+
cwd: string;
|
|
6
6
|
}): Promise<number>;
|
|
7
7
|
terminate(): void;
|
|
8
8
|
isRunning(): boolean;
|
|
9
9
|
}
|
|
10
10
|
export declare function cmd(command: string, args: string[], options: {
|
|
11
|
-
|
|
12
|
-
cwd
|
|
11
|
+
envOverrides: Record<string, string>;
|
|
12
|
+
cwd: string;
|
|
13
13
|
}): Promise<number>;
|
|
14
14
|
//# sourceMappingURL=exec.d.ts.map
|
package/dist/utils/exec.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exec.d.ts","sourceRoot":"","sources":["../../src/utils/exec.ts"],"names":[],"mappings":"AAmBA,qBAAa,cAAc;IACzB,OAAO,CAAC,YAAY,CAA6B;IAE3C,OAAO,CACX,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"exec.d.ts","sourceRoot":"","sources":["../../src/utils/exec.ts"],"names":[],"mappings":"AAmBA,qBAAa,cAAc;IACzB,OAAO,CAAC,YAAY,CAA6B;IAE3C,OAAO,CACX,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,EAAE;QAAE,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,GAC7D,OAAO,CAAC,MAAM,CAAC;IAoDlB,SAAS,IAAI,IAAI;IASjB,SAAS,IAAI,OAAO;CAGrB;AAED,wBAAsB,GAAG,CACvB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,EAAE;IAAE,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAC7D,OAAO,CAAC,MAAM,CAAC,CAGjB"}
|
package/dist/utils/exec.js
CHANGED
|
@@ -21,9 +21,7 @@ function isAcceptableExit(exitCode, signal) {
|
|
|
21
21
|
}
|
|
22
22
|
class ProcessManager {
|
|
23
23
|
childProcess = null;
|
|
24
|
-
async execute(command, args,
|
|
25
|
-
// TODO: Make these required when all tools use repoPath
|
|
26
|
-
options) {
|
|
24
|
+
async execute(command, args, options) {
|
|
27
25
|
console.log(`Executing command: ${command} with args: ${args}`);
|
|
28
26
|
if (this.childProcess) {
|
|
29
27
|
throw new Error("Process is already running");
|
|
@@ -35,7 +33,7 @@ class ProcessManager {
|
|
|
35
33
|
return;
|
|
36
34
|
}
|
|
37
35
|
const p = (0, child_process_1.spawn)(command, args, {
|
|
38
|
-
env: { ...process_1.default.env, ...options.
|
|
36
|
+
env: { ...process_1.default.env, ...options.envOverrides },
|
|
39
37
|
cwd: options.cwd,
|
|
40
38
|
detached: true, // Create process group so we can terminate all child processes
|
|
41
39
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-tree.d.ts","sourceRoot":"","sources":["../../src/utils/file-tree.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC,wBAAsB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"file-tree.d.ts","sourceRoot":"","sources":["../../src/utils/file-tree.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC,wBAAsB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAsC5E"}
|
package/dist/utils/file-tree.js
CHANGED
|
@@ -7,6 +7,7 @@ exports.getFileInfoFromFS = getFileInfoFromFS;
|
|
|
7
7
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
async function getFileInfoFromFS(directory) {
|
|
10
|
+
// TODO: This traverses all node_modules - can be excluded with DEFAULT_EXCLUDE
|
|
10
11
|
let currentDirName = path_1.default.basename(directory);
|
|
11
12
|
let currentDir = {
|
|
12
13
|
isDirectory: true,
|
|
@@ -21,6 +22,7 @@ async function getFileInfoFromFS(directory) {
|
|
|
21
22
|
const files = await promises_1.default.readdir(directory);
|
|
22
23
|
for (const file of files) {
|
|
23
24
|
const filePath = path_1.default.join(directory, file);
|
|
25
|
+
// TODO: Symlinks fail here
|
|
24
26
|
const stats = await promises_1.default.stat(filePath);
|
|
25
27
|
if (stats.isDirectory()) {
|
|
26
28
|
currentDir.children.push(await getFileInfoFromFS(filePath));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empiricalrun/test-gen",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.64.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org/",
|
|
6
6
|
"access": "public"
|
|
@@ -62,9 +62,9 @@
|
|
|
62
62
|
"tsx": "^4.16.2",
|
|
63
63
|
"typescript": "^5.3.3",
|
|
64
64
|
"zod": "^3.23.8",
|
|
65
|
-
"@empiricalrun/llm": "^0.17.
|
|
65
|
+
"@empiricalrun/llm": "^0.17.3",
|
|
66
66
|
"@empiricalrun/r2-uploader": "^0.3.9",
|
|
67
|
-
"@empiricalrun/test-run": "^0.
|
|
67
|
+
"@empiricalrun/test-run": "^0.10.0"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@playwright/test": "1.47.1",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"playwright": "1.47.1",
|
|
80
80
|
"serve-handler": "^6.1.6",
|
|
81
81
|
"ts-patch": "^3.3.0",
|
|
82
|
-
"@empiricalrun/shared-types": "0.4.
|
|
82
|
+
"@empiricalrun/shared-types": "0.4.1"
|
|
83
83
|
},
|
|
84
84
|
"scripts": {
|
|
85
85
|
"dev": "tspc --build --watch",
|
package/tsconfig.tsbuildinfo
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["./src/index.ts","./src/actions/assert.ts","./src/actions/click.ts","./src/actions/done.ts","./src/actions/fill.ts","./src/actions/goto.ts","./src/actions/hover.ts","./src/actions/index.ts","./src/actions/next-task.ts","./src/actions/press.ts","./src/actions/skill.ts","./src/actions/text-content.ts","./src/actions/constants/index.ts","./src/actions/utils/index.ts","./src/agent/browsing/index.ts","./src/agent/browsing/run.ts","./src/agent/browsing/utils.ts","./src/agent/chat/agent-loop.ts","./src/agent/chat/exports.ts","./src/agent/chat/index.ts","./src/agent/chat/models.ts","./src/agent/chat/prompt.ts","./src/agent/chat/repo.ts","./src/agent/chat/state.ts","./src/agent/chat/types.ts","./src/agent/chat/utils.ts","./src/agent/codegen/create-test-block.ts","./src/agent/codegen/fix-ts-errors.ts","./src/agent/codegen/generate-code-apply-changes.ts","./src/agent/codegen/lexical-scoped-vars.ts","./src/agent/codegen/repo-edit.ts","./src/agent/codegen/run.ts","./src/agent/codegen/skills-retriever.ts","./src/agent/codegen/test-update-feedback.ts","./src/agent/codegen/types.ts","./src/agent/codegen/update-flow.ts","./src/agent/codegen/use-skill.ts","./src/agent/codegen/utils.ts","./src/agent/cua/computer.ts","./src/agent/cua/index.ts","./src/agent/cua/model.ts","./src/agent/cua/pw-codegen/element-from-point.ts","./src/agent/cua/pw-codegen/types.ts","./src/agent/cua/pw-codegen/pw-pause/index.ts","./src/agent/cua/pw-codegen/pw-pause/utils.ts","./src/agent/diagnosis-agent/index.ts","./src/agent/diagnosis-agent/strict-mode-violation.ts","./src/agent/enrich-prompt/index.ts","./src/agent/enrich-prompt/utils.ts","./src/agent/infer-agent/index.ts","./src/agent/master/action-tool-calls.ts","./src/agent/master/element-annotation.ts","./src/agent/master/execute-browser-action.ts","./src/agent/master/execute-skill-action.ts","./src/agent/master/next-action.ts","./src/agent/master/planner.ts","./src/agent/master/run.ts","./src/agent/master/scroller.ts","./src/agent/master/with-hints.ts","./src/agent/master/browser-tests/cua.spec.ts","./src/agent/master/browser-tests/fixtures.ts","./src/agent/master/browser-tests/index.spec.ts","./src/agent/master/browser-tests/skills.spec.ts","./src/agent/master/icon-descriptor/index.ts","./src/agent/master/icon-descriptor/normalize-svg.ts","./src/agent/planner/run-time-planner.ts","./src/agent/planner/run.ts","./src/artifacts/index.ts","./src/bin/index.ts","./src/bin/logger/index.ts","./src/bin/utils/context.ts","./src/bin/utils/index.ts","./src/bin/utils/fs/index.ts","./src/bin/utils/platform/web/index.ts","./src/bin/utils/platform/web/test-files/ts-path-import-validate.ts","./src/bin/utils/scenarios/index.ts","./src/browser-injected-scripts/annotate-elements.spec.ts","./src/constants/index.ts","./src/errors/index.ts","./src/evals/add-scenario-agent.evals.ts","./src/evals/append-create-test-agent.evals.ts","./src/evals/fetch-pom-skills-agent.evals.ts","./src/evals/infer-master-or-code-agent.evals.ts","./src/evals/master-agent.evals.ts","./src/evals/type.ts","./src/evals/update-scenario-agent.evals.ts","./src/file/client.ts","./src/file/server.ts","./src/human-in-the-loop/cli.ts","./src/human-in-the-loop/index.ts","./src/human-in-the-loop/ipc.ts","./src/page/index.ts","./src/prompts/lib/ts-transformer.ts","./src/reporter/index.ts","./src/reporter/lib.ts","./src/session/index.ts","./src/test-build/index.ts","./src/tool-call-service/index.ts","./src/tool-call-service/utils.ts","./src/tools/
|
|
1
|
+
{"root":["./src/index.ts","./src/actions/assert.ts","./src/actions/click.ts","./src/actions/done.ts","./src/actions/fill.ts","./src/actions/goto.ts","./src/actions/hover.ts","./src/actions/index.ts","./src/actions/next-task.ts","./src/actions/press.ts","./src/actions/skill.ts","./src/actions/text-content.ts","./src/actions/constants/index.ts","./src/actions/utils/index.ts","./src/agent/browsing/index.ts","./src/agent/browsing/run.ts","./src/agent/browsing/utils.ts","./src/agent/chat/agent-loop.ts","./src/agent/chat/exports.ts","./src/agent/chat/index.ts","./src/agent/chat/models.ts","./src/agent/chat/prompt.ts","./src/agent/chat/repo.ts","./src/agent/chat/state.ts","./src/agent/chat/types.ts","./src/agent/chat/utils.ts","./src/agent/codegen/create-test-block.ts","./src/agent/codegen/fix-ts-errors.ts","./src/agent/codegen/generate-code-apply-changes.ts","./src/agent/codegen/lexical-scoped-vars.ts","./src/agent/codegen/repo-edit.ts","./src/agent/codegen/run.ts","./src/agent/codegen/skills-retriever.ts","./src/agent/codegen/test-update-feedback.ts","./src/agent/codegen/types.ts","./src/agent/codegen/update-flow.ts","./src/agent/codegen/use-skill.ts","./src/agent/codegen/utils.ts","./src/agent/cua/computer.ts","./src/agent/cua/index.ts","./src/agent/cua/model.ts","./src/agent/cua/pw-codegen/element-from-point.ts","./src/agent/cua/pw-codegen/types.ts","./src/agent/cua/pw-codegen/pw-pause/index.ts","./src/agent/cua/pw-codegen/pw-pause/utils.ts","./src/agent/diagnosis-agent/index.ts","./src/agent/diagnosis-agent/strict-mode-violation.ts","./src/agent/enrich-prompt/index.ts","./src/agent/enrich-prompt/utils.ts","./src/agent/infer-agent/index.ts","./src/agent/master/action-tool-calls.ts","./src/agent/master/element-annotation.ts","./src/agent/master/execute-browser-action.ts","./src/agent/master/execute-skill-action.ts","./src/agent/master/next-action.ts","./src/agent/master/planner.ts","./src/agent/master/run.ts","./src/agent/master/scroller.ts","./src/agent/master/with-hints.ts","./src/agent/master/browser-tests/cua.spec.ts","./src/agent/master/browser-tests/fixtures.ts","./src/agent/master/browser-tests/index.spec.ts","./src/agent/master/browser-tests/skills.spec.ts","./src/agent/master/icon-descriptor/index.ts","./src/agent/master/icon-descriptor/normalize-svg.ts","./src/agent/planner/run-time-planner.ts","./src/agent/planner/run.ts","./src/artifacts/index.ts","./src/artifacts/utils.ts","./src/bin/index.ts","./src/bin/logger/index.ts","./src/bin/utils/context.ts","./src/bin/utils/index.ts","./src/bin/utils/fs/index.ts","./src/bin/utils/platform/web/index.ts","./src/bin/utils/platform/web/test-files/ts-path-import-validate.ts","./src/bin/utils/scenarios/index.ts","./src/browser-injected-scripts/annotate-elements.spec.ts","./src/constants/index.ts","./src/errors/index.ts","./src/evals/add-scenario-agent.evals.ts","./src/evals/append-create-test-agent.evals.ts","./src/evals/fetch-pom-skills-agent.evals.ts","./src/evals/infer-master-or-code-agent.evals.ts","./src/evals/master-agent.evals.ts","./src/evals/type.ts","./src/evals/update-scenario-agent.evals.ts","./src/file/client.ts","./src/file/server.ts","./src/human-in-the-loop/cli.ts","./src/human-in-the-loop/index.ts","./src/human-in-the-loop/ipc.ts","./src/page/index.ts","./src/prompts/lib/ts-transformer.ts","./src/reporter/index.ts","./src/reporter/lib.ts","./src/session/index.ts","./src/test-build/index.ts","./src/tool-call-service/index.ts","./src/tool-call-service/utils.ts","./src/tools/commit-and-create-pr.ts","./src/tools/diagnosis-fetcher.ts","./src/tools/download-build.ts","./src/tools/environment-crud.ts","./src/tools/str_replace_editor.ts","./src/tools/test-gen-browser.ts","./src/tools/test-run.ts","./src/tools/grep/index.ts","./src/tools/grep/ripgrep/index.ts","./src/tools/grep/ripgrep/types.ts","./src/tools/test-run-fetcher/index.ts","./src/tools/test-run-fetcher/types.ts","./src/tools/utils/index.ts","./src/types/handlebars.d.ts","./src/types/index.ts","./src/uploader/index.ts","./src/uploader/utils.ts","./src/utils/checkpoint.ts","./src/utils/env.ts","./src/utils/exec.ts","./src/utils/file-tree.ts","./src/utils/file.ts","./src/utils/git.ts","./src/utils/html.ts","./src/utils/index.ts","./src/utils/repo-tree.ts","./src/utils/slug.ts","./src/utils/string.ts","./src/utils/stripAnsi.ts"],"version":"5.8.3"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"codegen-agent.d.ts","sourceRoot":"","sources":["../../src/tools/codegen-agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAmBnD,eAAO,MAAM,WAAW,EAAE,IAyBzB,CAAC"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.codegenTool = void 0;
|
|
4
|
-
const zod_1 = require("zod");
|
|
5
|
-
const run_1 = require("../agent/codegen/run");
|
|
6
|
-
const CodegenSchema = zod_1.z.object({
|
|
7
|
-
testName: zod_1.z.string().describe("The name of the test to create or modify"),
|
|
8
|
-
testSuites: zod_1.z
|
|
9
|
-
.array(zod_1.z.string())
|
|
10
|
-
.describe("The suites (describe blocks) where the test is located"),
|
|
11
|
-
fileName: zod_1.z
|
|
12
|
-
.string()
|
|
13
|
-
.describe("The name of the file where the test is located. File name must end with .spec.ts"),
|
|
14
|
-
changeToMake: zod_1.z.string().describe("The change to make to the test"),
|
|
15
|
-
});
|
|
16
|
-
exports.codegenTool = {
|
|
17
|
-
schema: {
|
|
18
|
-
name: "generateTestWithCodegen",
|
|
19
|
-
description: "Create or modify a test case with code generation. This is useful when modifications can be done with TypeScript only, and don't require any browser interactions or element selectors.",
|
|
20
|
-
parameters: CodegenSchema,
|
|
21
|
-
},
|
|
22
|
-
execute: async (input) => {
|
|
23
|
-
const { testName, testSuites, fileName, changeToMake } = input;
|
|
24
|
-
const testCase = {
|
|
25
|
-
id: 0,
|
|
26
|
-
name: testName,
|
|
27
|
-
filePath: fileName,
|
|
28
|
-
suites: testSuites,
|
|
29
|
-
steps: [changeToMake],
|
|
30
|
-
};
|
|
31
|
-
const result = await (0, run_1.generateTestWithCodegen)({
|
|
32
|
-
testCase,
|
|
33
|
-
file: fileName,
|
|
34
|
-
});
|
|
35
|
-
return {
|
|
36
|
-
result: JSON.stringify(result),
|
|
37
|
-
isError: false,
|
|
38
|
-
};
|
|
39
|
-
},
|
|
40
|
-
};
|