@empiricalrun/test-gen 0.47.3 → 0.48.0
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 +41 -0
- package/dist/agent/browsing/run.d.ts +4 -10
- package/dist/agent/browsing/run.d.ts.map +1 -1
- package/dist/agent/browsing/run.js +10 -17
- package/dist/agent/browsing/utils.d.ts +16 -13
- package/dist/agent/browsing/utils.d.ts.map +1 -1
- package/dist/agent/browsing/utils.js +33 -41
- package/dist/agent/chat.d.ts +7 -0
- package/dist/agent/chat.d.ts.map +1 -0
- package/dist/agent/chat.js +111 -0
- package/dist/agent/codegen/create-test-block.d.ts +2 -3
- package/dist/agent/codegen/create-test-block.d.ts.map +1 -1
- package/dist/agent/codegen/create-test-block.js +4 -9
- package/dist/agent/codegen/fix-ts-errors.d.ts +2 -3
- package/dist/agent/codegen/fix-ts-errors.d.ts.map +1 -1
- package/dist/agent/codegen/fix-ts-errors.js +4 -5
- package/dist/agent/codegen/run.d.ts +6 -4
- package/dist/agent/codegen/run.d.ts.map +1 -1
- package/dist/agent/codegen/run.js +8 -6
- package/dist/agent/codegen/update-flow.d.ts +7 -5
- package/dist/agent/codegen/update-flow.d.ts.map +1 -1
- package/dist/agent/codegen/update-flow.js +9 -49
- package/dist/agent/codegen/utils.d.ts +2 -4
- package/dist/agent/codegen/utils.d.ts.map +1 -1
- package/dist/agent/codegen/utils.js +1 -2
- package/dist/agent/diagnosis-agent/index.d.ts +2 -9
- package/dist/agent/diagnosis-agent/index.d.ts.map +1 -1
- package/dist/agent/diagnosis-agent/index.js +1 -8
- package/dist/agent/enrich-prompt/index.d.ts.map +1 -1
- package/dist/agent/enrich-prompt/index.js +0 -1
- package/dist/agent/infer-agent/index.d.ts.map +1 -1
- package/dist/agent/infer-agent/index.js +0 -9
- package/dist/agent/master/browser-tests/skills.spec.js +3 -0
- package/dist/agent/master/run.d.ts +1 -0
- package/dist/agent/master/run.d.ts.map +1 -1
- package/dist/agent/master/run.js +4 -2
- package/dist/bin/index.js +53 -35
- package/dist/bin/utils/index.d.ts +1 -0
- package/dist/bin/utils/index.d.ts.map +1 -1
- package/dist/bin/utils/index.js +9 -3
- package/dist/file/server.d.ts +2 -0
- package/dist/file/server.d.ts.map +1 -1
- package/dist/file/server.js +18 -1
- package/dist/tools/browser-agent.d.ts +3 -0
- package/dist/tools/browser-agent.d.ts.map +1 -0
- package/dist/tools/browser-agent.js +120 -0
- package/dist/tools/codegen-agent.d.ts +3 -0
- package/dist/tools/codegen-agent.d.ts.map +1 -0
- package/dist/tools/codegen-agent.js +56 -0
- package/dist/tools/diagnosis-fetcher.d.ts +3 -0
- package/dist/tools/diagnosis-fetcher.d.ts.map +1 -0
- package/dist/tools/diagnosis-fetcher.js +88 -0
- package/dist/tools/test-run.d.ts +3 -0
- package/dist/tools/test-run.d.ts.map +1 -0
- package/dist/tools/test-run.js +49 -0
- package/dist/tools/types.d.ts +11 -0
- package/dist/tools/types.d.ts.map +1 -0
- package/dist/tools/types.js +2 -0
- package/dist/utils/git.d.ts +2 -0
- package/dist/utils/git.d.ts.map +1 -0
- package/dist/utils/git.js +11 -0
- package/dist/utils/repo-tree.d.ts +2 -0
- package/dist/utils/repo-tree.d.ts.map +1 -0
- package/dist/utils/repo-tree.js +75 -0
- package/package.json +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,46 @@
|
|
|
1
1
|
# @empiricalrun/test-gen
|
|
2
2
|
|
|
3
|
+
## 0.48.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- fc952c9: feat: Add new tool call to fetch diagnosis details
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 32eaf6f: feat: add repo tree in ascii to chat system prompt
|
|
12
|
+
- 6cc97ca: feat: use claude3.7 in chat agent for diagnosis auto-fix scenarios
|
|
13
|
+
- 2e28c20: fix: master agent should not throw when used in tool call
|
|
14
|
+
- f03ff97: feat: update master agent tool call to use TODO(agent) preparation method
|
|
15
|
+
- ed273c2: fix: disable skills usage in master agent
|
|
16
|
+
- 049102a: fix: support suites in agent tool calls
|
|
17
|
+
- Updated dependencies [6cc97ca]
|
|
18
|
+
- Updated dependencies [0fee9bf]
|
|
19
|
+
- Updated dependencies [1f95e4b]
|
|
20
|
+
- Updated dependencies [049102a]
|
|
21
|
+
- @empiricalrun/llm@0.10.0
|
|
22
|
+
- @empiricalrun/test-run@0.7.2
|
|
23
|
+
|
|
24
|
+
## 0.47.4
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- 007ef65: feat: master agent tool call returns git patch on successful runs
|
|
29
|
+
- c4ddc2c: feat: chat can use codegen agent as a tool call
|
|
30
|
+
- e1903b7: feat: add master agent as a tool call for chat
|
|
31
|
+
- 4b18733: chore: simplify interface to prepare for tool call
|
|
32
|
+
- 6328aaf: feat: test-gen can use test-run package as a tool call
|
|
33
|
+
- e4bf218: fix: update append-create-test prompt to emphasize task without location hints
|
|
34
|
+
- 7748c7b: chore: remove options from prepare file workflow
|
|
35
|
+
- 72a8cf2: feat: chat agent only needs prompt string
|
|
36
|
+
- d995e4c: feat: enable conversation along with test-run tool call
|
|
37
|
+
- 848cb88: fix: trace hierarchy in prep for master agent
|
|
38
|
+
- Updated dependencies [72a8cf2]
|
|
39
|
+
- Updated dependencies [242f659]
|
|
40
|
+
- Updated dependencies [6328aaf]
|
|
41
|
+
- Updated dependencies [d995e4c]
|
|
42
|
+
- @empiricalrun/test-run@0.7.1
|
|
43
|
+
|
|
3
44
|
## 0.47.3
|
|
4
45
|
|
|
5
46
|
### Patch Changes
|
|
@@ -5,15 +5,9 @@ type GenerateTestsType = {
|
|
|
5
5
|
testGenToken: string;
|
|
6
6
|
repoDir: string;
|
|
7
7
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
* @param {GenerateTestsType} {
|
|
13
|
-
* testFilePath,
|
|
14
|
-
* filePathToUpdate,
|
|
15
|
-
* }
|
|
16
|
-
*/
|
|
17
|
-
export declare function generateTestsUsingMasterAgent({ testFilePath, filePathToUpdate, pwProjectsFilter, testGenToken, repoDir, }: GenerateTestsType): Promise<void>;
|
|
8
|
+
export declare function generateTestsUsingMasterAgent({ testFilePath, filePathToUpdate, pwProjectsFilter, testGenToken, repoDir, }: GenerateTestsType): Promise<{
|
|
9
|
+
isError: boolean;
|
|
10
|
+
error: string;
|
|
11
|
+
}>;
|
|
18
12
|
export {};
|
|
19
13
|
//# sourceMappingURL=run.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/run.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/run.ts"],"names":[],"mappings":"AAiBA,KAAK,iBAAiB,GAAG;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,wBAAsB,6BAA6B,CAAC,EAClD,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EACZ,OAAO,GACR,EAAE,iBAAiB;;;GA8EnB"}
|
|
@@ -10,19 +10,10 @@ const web_1 = require("../../bin/utils/platform/web");
|
|
|
10
10
|
const server_1 = require("../../file/server");
|
|
11
11
|
const exec_1 = require("../../utils/exec");
|
|
12
12
|
const utils_1 = require("./utils");
|
|
13
|
-
/**
|
|
14
|
-
*
|
|
15
|
-
* Function to generate tests using master agent
|
|
16
|
-
* @export
|
|
17
|
-
* @param {GenerateTestsType} {
|
|
18
|
-
* testFilePath,
|
|
19
|
-
* filePathToUpdate,
|
|
20
|
-
* }
|
|
21
|
-
*/
|
|
22
13
|
async function generateTestsUsingMasterAgent({ testFilePath, filePathToUpdate, pwProjectsFilter, testGenToken, repoDir, }) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
14
|
+
if (!fs_extra_1.default.existsSync(testFilePath)) {
|
|
15
|
+
throw new Error(`File for master agent to run not found: ${testFilePath}`);
|
|
16
|
+
}
|
|
26
17
|
// detect available http port on the machine
|
|
27
18
|
const port = await (0, detect_port_1.default)(3030);
|
|
28
19
|
// start a file service to handle file updates from agent
|
|
@@ -45,7 +36,8 @@ async function generateTestsUsingMasterAgent({ testFilePath, filePathToUpdate, p
|
|
|
45
36
|
await teardowns.skipAll();
|
|
46
37
|
}
|
|
47
38
|
const command = `npx playwright test ${testFilePath} --retries 0 --project ${project} --timeout 0 --headed`;
|
|
48
|
-
let isError = false
|
|
39
|
+
let isError = false;
|
|
40
|
+
let error = "";
|
|
49
41
|
try {
|
|
50
42
|
await (0, exec_1.cmd)(command.split(" "), {
|
|
51
43
|
env: {
|
|
@@ -80,9 +72,10 @@ async function generateTestsUsingMasterAgent({ testFilePath, filePathToUpdate, p
|
|
|
80
72
|
}
|
|
81
73
|
// remove the test only from the file
|
|
82
74
|
await (0, web_1.removeTestOnly)(testFilePath);
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
75
|
+
await fileService.stop();
|
|
76
|
+
return {
|
|
77
|
+
isError,
|
|
78
|
+
error,
|
|
79
|
+
};
|
|
87
80
|
}
|
|
88
81
|
exports.generateTestsUsingMasterAgent = generateTestsUsingMasterAgent;
|
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
import { TraceClient } from "@empiricalrun/llm";
|
|
2
|
-
import type {
|
|
2
|
+
import type { TestCase } from "@empiricalrun/shared-types";
|
|
3
3
|
import { Page } from "playwright";
|
|
4
4
|
import { PlaywrightTestConfig } from "playwright/test";
|
|
5
5
|
export declare function isRegExp(obj: any): obj is RegExp;
|
|
6
6
|
export declare function prepareBrowsingAgentTask(steps: string[]): string;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export declare function
|
|
7
|
+
export declare function replaceTodoWithCreateTest({ testFilePath, testCaseName, testCaseSuites, }: {
|
|
8
|
+
testFilePath: string;
|
|
9
|
+
testCaseName: string;
|
|
10
|
+
testCaseSuites: string[];
|
|
11
|
+
}): Promise<void>;
|
|
12
|
+
export declare function markTestAsOnly({ testCaseName, testCaseSuites, specPath, }: {
|
|
13
|
+
testCaseName: string;
|
|
14
|
+
testCaseSuites: string[];
|
|
15
|
+
specPath: string;
|
|
16
|
+
}): Promise<void>;
|
|
17
|
+
export declare function prepareFileForMasterAgent({ testCase, specPath, trace, }: {
|
|
18
|
+
testCase: TestCase;
|
|
19
|
+
specPath: string;
|
|
20
|
+
trace?: TraceClient;
|
|
21
|
+
}): Promise<string>;
|
|
13
22
|
export declare function injectPwLocatorGenerator(page: Page): Promise<void>;
|
|
14
|
-
/**
|
|
15
|
-
* Function to validate if the test file path are valid.
|
|
16
|
-
* @throws if there are any missing dependencies for master agent to run.
|
|
17
|
-
* @param {string} filePath
|
|
18
|
-
*/
|
|
19
|
-
export declare function canRunMasterAgent(filePath: string): void;
|
|
20
23
|
/**
|
|
21
24
|
* function to read playwright config from the source repo
|
|
22
25
|
* @return {*} {Promise<PlaywrightTestConfig>}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAe,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAe,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAIxE,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAsBvD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,MAAM,CAKhD;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,UAIvD;AAiFD,wBAAsB,yBAAyB,CAAC,EAC9C,YAAY,EACZ,YAAY,EACZ,cAAc,GACf,EAAE;IACD,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,EAAE,CAAC;CAC1B,iBAkBA;AAED,wBAAsB,cAAc,CAAC,EACnC,YAAY,EACZ,cAAc,EACd,QAAQ,GACT,EAAE;IACD,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;CAClB,iBAoBA;AAED,wBAAsB,yBAAyB,CAAC,EAC9C,QAAQ,EACR,QAAQ,EACR,KAAK,GACN,EAAE;IACD,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB,GAAG,OAAO,CAAC,MAAM,CAAC,CAyDlB;AAyBD,wBAAsB,wBAAwB,CAAC,IAAI,EAAE,IAAI,iBA2HxD;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,oBAAoB,CAAC,CAM/B;AAWD;;;;;GAKG;AACH,wBAAsB,iBAAiB,CACrC,YAAY,EAAE,MAAM,EACpB,gBAAgB,EAAE,oBAAoB,EACtC,gBAAgB,GAAE,MAAM,EAAU,GACjC,OAAO,CAAC,MAAM,CAAC,CA+CjB;AAED,qBAAa,eAAe;IACd,OAAO,CAAC,SAAS;gBAAT,SAAS,EAAE,MAAM;IACrC,OAAO,CAAC,aAAa,CAAqB;YAE5B,mBAAmB;YAUnB,gBAAgB;IAsBjB,OAAO;IAuBb,SAAS;CAKjB"}
|
|
@@ -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.TeardownManager = exports.detectProjectName = exports.readPlaywrightConfig = exports.
|
|
6
|
+
exports.TeardownManager = exports.detectProjectName = exports.readPlaywrightConfig = exports.injectPwLocatorGenerator = exports.prepareFileForMasterAgent = exports.markTestAsOnly = exports.replaceTodoWithCreateTest = exports.prepareBrowsingAgentTask = exports.isRegExp = void 0;
|
|
7
7
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
8
8
|
const minimatch_1 = require("minimatch");
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
@@ -37,12 +37,7 @@ async function addImportForCreateTest(testFilePath) {
|
|
|
37
37
|
}
|
|
38
38
|
await fs_extra_1.default.writeFile(testFilePath, (0, web_1.addNewImport)(await fs_extra_1.default.readFile(testFilePath, "utf-8"), ["createTest"], importSource));
|
|
39
39
|
}
|
|
40
|
-
|
|
41
|
-
* Function to prepare test file for update scenarios for master agent to run
|
|
42
|
-
* @param {TestGenConfig} genConfig
|
|
43
|
-
*/
|
|
44
|
-
async function prepareFileForUpdateScenario(genConfig, trace) {
|
|
45
|
-
const { specPath, testCase } = genConfig;
|
|
40
|
+
async function prepareFileForUpdateScenario({ testCase, specPath, trace, }) {
|
|
46
41
|
const { name, suites } = testCase;
|
|
47
42
|
await (0, web_1.addUserContextFixture)({
|
|
48
43
|
scenarioName: name,
|
|
@@ -55,7 +50,6 @@ async function prepareFileForUpdateScenario(genConfig, trace) {
|
|
|
55
50
|
testCase,
|
|
56
51
|
file: specPath,
|
|
57
52
|
validateTypes: false,
|
|
58
|
-
options: genConfig.options,
|
|
59
53
|
});
|
|
60
54
|
const createTestFilePath = suggestion?.updatedFiles[0] || "";
|
|
61
55
|
console.log("appending to existing test block");
|
|
@@ -78,15 +72,7 @@ async function prepareFileForUpdateScenario(genConfig, trace) {
|
|
|
78
72
|
},
|
|
79
73
|
});
|
|
80
74
|
await (0, web_1.appendScopeToCreateTest)(createTestFilePath, scopeVariables);
|
|
81
|
-
// extract the createTest function and pass the scoped vars
|
|
82
|
-
const updateFileSpan = trace?.span({
|
|
83
|
-
name: "update-file-span",
|
|
84
|
-
input: {
|
|
85
|
-
createTestFilePath,
|
|
86
|
-
},
|
|
87
|
-
});
|
|
88
75
|
await addImportForCreateTest(createTestFilePath);
|
|
89
|
-
updateFileSpan?.end();
|
|
90
76
|
const { pomPrompt, nonSpecFilePrompt } = await (0, context_1.contextForGeneration)(createTestFilePath);
|
|
91
77
|
await (0, fix_ts_errors_1.validateAndFixTypescriptErrors)({
|
|
92
78
|
trace,
|
|
@@ -94,13 +80,33 @@ async function prepareFileForUpdateScenario(genConfig, trace) {
|
|
|
94
80
|
pomCode: pomPrompt,
|
|
95
81
|
nonSpecFileCode: nonSpecFilePrompt,
|
|
96
82
|
testCase: testCase,
|
|
97
|
-
options: genConfig.options,
|
|
98
83
|
});
|
|
84
|
+
await markTestAsOnly({
|
|
85
|
+
testCaseName: name,
|
|
86
|
+
testCaseSuites: suites,
|
|
87
|
+
specPath,
|
|
88
|
+
});
|
|
89
|
+
return createTestFilePath;
|
|
90
|
+
}
|
|
91
|
+
async function replaceTodoWithCreateTest({ testFilePath, testCaseName, testCaseSuites, }) {
|
|
92
|
+
// This method is an alternative to prepareFileForUpdateScenario
|
|
93
|
+
// TODO: Does not support multiple pages, scoped variables, updates in POM files
|
|
94
|
+
const fileContent = await fs_extra_1.default.readFile(testFilePath, "utf-8");
|
|
95
|
+
await fs_extra_1.default.writeFile(testFilePath, fileContent.replace(/\/\/ TODO\(agent\): (.*)/, (_, todoText) => `await createTest("${todoText.replace(/"/g, '\\"')}", page)`));
|
|
96
|
+
await addImportForCreateTest(testFilePath);
|
|
97
|
+
await markTestAsOnly({
|
|
98
|
+
testCaseName,
|
|
99
|
+
testCaseSuites,
|
|
100
|
+
specPath: testFilePath,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
exports.replaceTodoWithCreateTest = replaceTodoWithCreateTest;
|
|
104
|
+
async function markTestAsOnly({ testCaseName, testCaseSuites, specPath, }) {
|
|
99
105
|
const testFileContent = await fs_extra_1.default.readFile(specPath, "utf-8");
|
|
100
106
|
const { testBlock, testNode } = (0, web_1.getTypescriptTestBlock)({
|
|
101
|
-
scenarioName:
|
|
107
|
+
scenarioName: testCaseName,
|
|
102
108
|
content: testFileContent,
|
|
103
|
-
suites,
|
|
109
|
+
suites: testCaseSuites,
|
|
104
110
|
});
|
|
105
111
|
const parentDescribe = (0, web_1.findFirstSerialDescribeBlock)(testNode);
|
|
106
112
|
const isFileMarkedSerial = await (0, web_1.hasTopLevelDescribeConfigureWithSerialMode)(specPath);
|
|
@@ -109,19 +115,13 @@ async function prepareFileForUpdateScenario(genConfig, trace) {
|
|
|
109
115
|
const updatedTestFileContent = newContentsWithTestOnly(testFileContent, testBlock, testBlock, parentDescribe?.getText() || "");
|
|
110
116
|
await fs_extra_1.default.writeFile(specPath, updatedTestFileContent);
|
|
111
117
|
}
|
|
112
|
-
return createTestFilePath;
|
|
113
118
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
* @param {TestGenConfig} genConfig
|
|
117
|
-
* @return {*} {Promise<string>}
|
|
118
|
-
*/
|
|
119
|
-
async function prepareFileForMasterAgent(genConfig, trace) {
|
|
119
|
+
exports.markTestAsOnly = markTestAsOnly;
|
|
120
|
+
async function prepareFileForMasterAgent({ testCase, specPath, trace, }) {
|
|
120
121
|
const prepareFileSpan = trace?.span({
|
|
121
122
|
name: "prepare-file-for-master-agent",
|
|
122
123
|
});
|
|
123
124
|
new logger_1.CustomLogger({ useReporter: true }).log(`Preparing file for master agent. [view trace](${trace?.getTraceUrl()})`);
|
|
124
|
-
const { specPath, testCase } = genConfig;
|
|
125
125
|
const { name, suites } = testCase;
|
|
126
126
|
// check if the spec file exists
|
|
127
127
|
// if no then create a new file with test and expect imports
|
|
@@ -144,9 +144,8 @@ async function prepareFileForMasterAgent(genConfig, trace) {
|
|
|
144
144
|
if (!testBlock) {
|
|
145
145
|
const newTestBlock = await (0, create_test_block_1.createEmptyTestCaseBlock)({
|
|
146
146
|
trace: prepareFileSpan,
|
|
147
|
-
testCase
|
|
147
|
+
testCase,
|
|
148
148
|
file: specPath,
|
|
149
|
-
options: genConfig.options,
|
|
150
149
|
});
|
|
151
150
|
await fs_extra_1.default.writeFile(specPath, `${existingContents} \n\n ${newTestBlock}`, "utf-8");
|
|
152
151
|
const updatedContent = (0, web_1.injectCodeSnippetBySuiteChain)({
|
|
@@ -156,7 +155,11 @@ async function prepareFileForMasterAgent(genConfig, trace) {
|
|
|
156
155
|
});
|
|
157
156
|
await fs_extra_1.default.writeFile(specPath, updatedContent, "utf-8");
|
|
158
157
|
}
|
|
159
|
-
const updatePath = await prepareFileForUpdateScenario(
|
|
158
|
+
const updatePath = await prepareFileForUpdateScenario({
|
|
159
|
+
testCase,
|
|
160
|
+
specPath,
|
|
161
|
+
trace,
|
|
162
|
+
});
|
|
160
163
|
return updatePath;
|
|
161
164
|
}
|
|
162
165
|
exports.prepareFileForMasterAgent = prepareFileForMasterAgent;
|
|
@@ -280,17 +283,6 @@ async function injectPwLocatorGenerator(page) {
|
|
|
280
283
|
}
|
|
281
284
|
}
|
|
282
285
|
exports.injectPwLocatorGenerator = injectPwLocatorGenerator;
|
|
283
|
-
/**
|
|
284
|
-
* Function to validate if the test file path are valid.
|
|
285
|
-
* @throws if there are any missing dependencies for master agent to run.
|
|
286
|
-
* @param {string} filePath
|
|
287
|
-
*/
|
|
288
|
-
function canRunMasterAgent(filePath) {
|
|
289
|
-
if (!fs_extra_1.default.existsSync(filePath)) {
|
|
290
|
-
throw new Error(`File for master agent to run not found: ${filePath}`);
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
exports.canRunMasterAgent = canRunMasterAgent;
|
|
294
286
|
/**
|
|
295
287
|
* function to read playwright config from the source repo
|
|
296
288
|
* @return {*} {Promise<PlaywrightTestConfig>}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TraceClient } from "@empiricalrun/llm";
|
|
2
|
+
import type { Anthropic } from "@empiricalrun/llm/claude";
|
|
3
|
+
export declare function chatAgent({ prompt, }: {
|
|
4
|
+
prompt: string;
|
|
5
|
+
trace?: TraceClient;
|
|
6
|
+
}): Promise<Anthropic.Messages.MessageParam[]>;
|
|
7
|
+
//# sourceMappingURL=chat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../src/agent/chat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AA6D1D,wBAAsB,SAAS,CAAC,EAC9B,MAAM,GACP,EAAE;IACD,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB,8CAmEA"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.chatAgent = void 0;
|
|
7
|
+
const claude_1 = require("@empiricalrun/llm/claude");
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const human_in_the_loop_1 = require("../human-in-the-loop");
|
|
10
|
+
const browser_agent_1 = require("../tools/browser-agent");
|
|
11
|
+
const diagnosis_fetcher_1 = require("../tools/diagnosis-fetcher");
|
|
12
|
+
const test_run_1 = require("../tools/test-run");
|
|
13
|
+
const repo_tree_1 = require("../utils/repo-tree");
|
|
14
|
+
const systemPrompt = `
|
|
15
|
+
You are a helpful assistant that can answer questions and help with tasks.
|
|
16
|
+
You are given a set of tools to use to fulfill the user's request. Read their descriptions to
|
|
17
|
+
understand what each tool does.
|
|
18
|
+
|
|
19
|
+
For example, if the user asks you to run a test, you could use the runTest tool.
|
|
20
|
+
Once the test is run, you will receive the results in the form of a JSON object.
|
|
21
|
+
Summarize the results in a few sentences.
|
|
22
|
+
|
|
23
|
+
If the user provides a diagnosis URL, you can use the fetchDiagnosisDetails tool
|
|
24
|
+
to get more information about the test case and its results.
|
|
25
|
+
|
|
26
|
+
Or if the user asks you to modify a test, you could use the generateTestWithBrowserAgent tool. If you suspect
|
|
27
|
+
that a UI selector needs to be updated, using the browser agent is a good idea.
|
|
28
|
+
|
|
29
|
+
Before using generateTestWithBrowserAgent, you need to prepare the test code for the browser agent.
|
|
30
|
+
You can do this by using the str_replace_editor tool to add a TODO comment to the test code. This
|
|
31
|
+
comment should explain to the browser agent what to do.
|
|
32
|
+
|
|
33
|
+
For example, if the expected modification is to click on a login button, you could add the following comment.
|
|
34
|
+
|
|
35
|
+
// TODO(agent): Click on the login button
|
|
36
|
+
|
|
37
|
+
The position of the comment is important: the browser agent will look for this comment and replace it with
|
|
38
|
+
the actual code to click on the login button. If you are fixing a failing test, your comment should be
|
|
39
|
+
around the failing line of code, so that it can be replaced/modified.
|
|
40
|
+
|
|
41
|
+
You are running as a CLI tool inside the directory of the repo where this test file is located. Here is
|
|
42
|
+
the repo directory structure:
|
|
43
|
+
|
|
44
|
+
${(0, repo_tree_1.generateAsciiTree)(process.cwd())}
|
|
45
|
+
|
|
46
|
+
While specifying paths to files, use relative paths from the current working directory. For example:
|
|
47
|
+
- Correct path: "tests/lesson.spec.ts"
|
|
48
|
+
- Incorrect path: "/repo/tests/lesson.spec.ts" or "${path_1.default.basename(process.cwd())}/tests/lesson.spec.ts"
|
|
49
|
+
`;
|
|
50
|
+
const tools = [test_run_1.runTestTool, browser_agent_1.browserAgentTool, diagnosis_fetcher_1.diagnosisTool];
|
|
51
|
+
const toolExecutors = {
|
|
52
|
+
...Object.fromEntries(tools.map((tool) => [tool.schema.function.name, tool.execute])),
|
|
53
|
+
str_replace_editor: claude_1.strReplaceEditorTool,
|
|
54
|
+
};
|
|
55
|
+
async function chatAgent({ prompt, }) {
|
|
56
|
+
let userPrompt = prompt;
|
|
57
|
+
let chatState = new claude_1.ChatState();
|
|
58
|
+
chatState.pushTextMessage({ message: { role: "user", content: userPrompt } });
|
|
59
|
+
let shouldAskUserForInput = false;
|
|
60
|
+
while (!userPrompt.toLowerCase().includes("stop")) {
|
|
61
|
+
const toolUse = chatState.getPendingToolCall();
|
|
62
|
+
if (toolUse) {
|
|
63
|
+
console.log("Executing tool:", toolUse.name, "with args:", toolUse.input);
|
|
64
|
+
const toolExecutor = toolExecutors[toolUse.name];
|
|
65
|
+
if (!toolExecutor) {
|
|
66
|
+
throw new Error(`Tool ${toolUse.name} not found`);
|
|
67
|
+
}
|
|
68
|
+
const toolResult = await toolExecutor(toolUse.input);
|
|
69
|
+
chatState.pushToolResultToMessages({
|
|
70
|
+
toolCall: toolUse,
|
|
71
|
+
isError: toolResult.isError,
|
|
72
|
+
result: toolResult.result,
|
|
73
|
+
});
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
if (shouldAskUserForInput) {
|
|
77
|
+
userPrompt = await human_in_the_loop_1.humanLoop.getFeedback({
|
|
78
|
+
message: "Your response?",
|
|
79
|
+
});
|
|
80
|
+
chatState.pushTextMessage({
|
|
81
|
+
message: { role: "user", content: userPrompt },
|
|
82
|
+
});
|
|
83
|
+
shouldAskUserForInput = false;
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
const response = await (0, claude_1.createChatCompletion)(systemPrompt, chatState.getMessages(), [
|
|
87
|
+
...tools.map((tool) => (0, claude_1.convertOpenAISchemaToAnthropic)(tool.schema)),
|
|
88
|
+
{
|
|
89
|
+
type: "text_editor_20250124",
|
|
90
|
+
name: "str_replace_editor",
|
|
91
|
+
},
|
|
92
|
+
]);
|
|
93
|
+
if (!response) {
|
|
94
|
+
throw new Error("No response from LLM");
|
|
95
|
+
}
|
|
96
|
+
chatState.pushTextMessage({
|
|
97
|
+
message: { role: "assistant", content: response.content },
|
|
98
|
+
});
|
|
99
|
+
const textBlock = response.content.find((b) => b.type === "text");
|
|
100
|
+
const toolUseBlock = response.content.find((b) => b.type === "tool_use");
|
|
101
|
+
console.log("Assistant response:", textBlock?.text);
|
|
102
|
+
if (toolUseBlock) {
|
|
103
|
+
chatState.addPendingToolCall({ toolCall: toolUseBlock });
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
shouldAskUserForInput = true;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return chatState.getMessages();
|
|
110
|
+
}
|
|
111
|
+
exports.chatAgent = chatAgent;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { TraceClient } from "@empiricalrun/llm";
|
|
2
|
-
import type { TestCase
|
|
3
|
-
export declare function createEmptyTestCaseBlock({ testCase, file,
|
|
2
|
+
import type { TestCase } from "@empiricalrun/shared-types";
|
|
3
|
+
export declare function createEmptyTestCaseBlock({ testCase, file, trace, }: {
|
|
4
4
|
testCase: TestCase;
|
|
5
5
|
file: string;
|
|
6
|
-
options?: TestGenConfigOptions;
|
|
7
6
|
trace?: TraceClient;
|
|
8
7
|
}): Promise<string | undefined>;
|
|
9
8
|
//# sourceMappingURL=create-test-block.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-test-block.d.ts","sourceRoot":"","sources":["../../../src/agent/codegen/create-test-block.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,WAAW,EACZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"create-test-block.d.ts","sourceRoot":"","sources":["../../../src/agent/codegen/create-test-block.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,WAAW,EACZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAc3D,wBAAsB,wBAAwB,CAAC,EAC7C,QAAQ,EACR,IAAI,EACJ,KAAK,GACN,EAAE;IACD,QAAQ,EAAE,QAAQ,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB,+BA+CA"}
|
|
@@ -8,7 +8,7 @@ const web_1 = require("../../bin/utils/platform/web");
|
|
|
8
8
|
const constants_1 = require("../../constants");
|
|
9
9
|
const promptTemplate_0 = "{{#section \"system\"}}\nYou are a software test engineer who is given a task to write an empty test block.\nBased on the inputs you need to create an empty playwright test block with correctly imported fixture.\n\nThe test will contain a test name which you will need to use to build the empty test case block.\n\nYou will be provided with current tests, fixtures and page object models for you to use and create test case block as\nper the task provided to you.\n\nBefore responding you need to ensure that the code change is minimal and the change is reusable across tests. You need\nto ensure the code follows DRY principle.\n\nHere is the list of current tests and fixtures:\n\n{{testFiles}}\n\nHere is the list of current page object models:\n\n{{pageFiles}}\n{{/section}}\n\n{{#section \"user\"}}\nFollowing is the test scenario for which you need to write the empty test case block:\ntest name:\n{{scenarioName}}\n\ntask:\ncreate an empty test case block for the following test steps:\n{{scenario}}\n\ntest file path: {{scenarioFile}}\n\n------\n\nYou also need to ensure that the empty test case block has a starting page to begin test.\n\nIn order to identify the right page with which the test should start, follow the steps:\n- based on the similarities with other test cases mentioned in the file, identify the right page fixture to be imported\n- Read the page fixture methods step by step. Identify whether the fixture handles navigating to a page.\n- Identify whether other tests using the page fixture had to add separate steps for navigation or not\n- Based on the above analysis there will be following cases and choose either for the given test scenario:\n-- Case 1: if the test case scenario provided inside the task mentions about page navigation, then use that page\nnavigation. skip other cases if this case is satisfied.\n-- Case 2: refer other test cases which import similar fixtures and infer the first page navigation of this test case.\nYou should prefer tests which are in the same file. Tests within same file have higher overlaps in first page\nnavigation.\n- Once the page fixture is decided, look for userContext fixture in files. If its available then add \"userContext\" to\nthe test case block\n\n\n\nFollow these instructions before responding with output:\n- Read the code line by line and achieve the task provided to you\n- Read the dependencies of the code block by scanning through file paths and file provided to you. refer the same file\npath while responding with update\n- Focus only on the test case provided and associated JS methods called from the test case.\n- Respond only with the new empty test case block to be created and nothing else.\n- DO NOT respond with any backticks or markdown syntax\n- If \"userContext\" fixture is available in fixtures file, ensure importing that fixture in the test case block.\n- Provide a reason based on the test steps provided to you on why you chose the fixture or page.goto statement. The\nreason should be one of the list steps provided to you and mention why the case was chosen\n{{/section}}";
|
|
10
10
|
const session_1 = require("../../session");
|
|
11
|
-
async function createEmptyTestCaseBlock({ testCase, file,
|
|
11
|
+
async function createEmptyTestCaseBlock({ testCase, file, trace, }) {
|
|
12
12
|
const logger = new logger_1.CustomLogger({ useReporter: false });
|
|
13
13
|
logger.log("Creating new test block");
|
|
14
14
|
const context = await (0, context_1.contextForGeneration)(file);
|
|
@@ -20,10 +20,6 @@ async function createEmptyTestCaseBlock({ testCase, file, options, trace, }) {
|
|
|
20
20
|
name: "create-empty-test-block",
|
|
21
21
|
id: crypto.randomUUID(),
|
|
22
22
|
release: session.version,
|
|
23
|
-
tags: [
|
|
24
|
-
options?.metadata.projectName || "",
|
|
25
|
-
options?.metadata.environment || "",
|
|
26
|
-
].filter((s) => !!s),
|
|
27
23
|
});
|
|
28
24
|
const promptSpan = trace?.span({
|
|
29
25
|
name: "build-create-empty-test-case-prompt",
|
|
@@ -38,15 +34,14 @@ async function createEmptyTestCaseBlock({ testCase, file, options, trace, }) {
|
|
|
38
34
|
promptSpan?.end({ output: { prompt } });
|
|
39
35
|
const llm = new llm_1.LLM({
|
|
40
36
|
trace,
|
|
41
|
-
provider:
|
|
42
|
-
defaultModel:
|
|
43
|
-
providerApiKey: constants_1.MODEL_API_KEYS[
|
|
37
|
+
provider: constants_1.DEFAULT_MODEL_PROVIDER,
|
|
38
|
+
defaultModel: constants_1.DEFAULT_MODEL,
|
|
39
|
+
providerApiKey: constants_1.MODEL_API_KEYS[constants_1.DEFAULT_MODEL_PROVIDER],
|
|
44
40
|
});
|
|
45
41
|
const firstShotMessage = await llm.createChatCompletion({
|
|
46
42
|
messages: prompt,
|
|
47
43
|
modelParameters: {
|
|
48
44
|
...constants_1.DEFAULT_MODEL_PARAMETERS,
|
|
49
|
-
...options?.modelParameters,
|
|
50
45
|
},
|
|
51
46
|
});
|
|
52
47
|
const markdownRemoverSpan = trace?.span({
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { TraceClient } from "@empiricalrun/llm";
|
|
2
|
-
import type { TestCase
|
|
2
|
+
import type { TestCase } from "@empiricalrun/shared-types";
|
|
3
3
|
import { CustomLogger } from "../../bin/logger";
|
|
4
|
-
export declare function validateAndFixTypescriptErrors({ trace, logger, file, pomCode, nonSpecFileCode, testCase,
|
|
4
|
+
export declare function validateAndFixTypescriptErrors({ trace, logger, file, pomCode, nonSpecFileCode, testCase, }: {
|
|
5
5
|
trace?: TraceClient;
|
|
6
6
|
logger?: CustomLogger;
|
|
7
7
|
file: string;
|
|
8
8
|
pomCode: string;
|
|
9
9
|
nonSpecFileCode: string;
|
|
10
10
|
testCase: TestCase;
|
|
11
|
-
options?: TestGenConfigOptions;
|
|
12
11
|
}): Promise<void>;
|
|
13
12
|
//# sourceMappingURL=fix-ts-errors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fix-ts-errors.d.ts","sourceRoot":"","sources":["../../../src/agent/codegen/fix-ts-errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"fix-ts-errors.d.ts","sourceRoot":"","sources":["../../../src/agent/codegen/fix-ts-errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAG3D,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAUhD,wBAAsB,8BAA8B,CAAC,EACnD,KAAK,EACL,MAA2B,EAC3B,IAAI,EACJ,OAAO,EACP,eAAe,EACf,QAAQ,GACT,EAAE;IACD,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,QAAQ,CAAC;CACpB,iBAsEA"}
|
|
@@ -10,7 +10,7 @@ const logger_1 = require("../../bin/logger");
|
|
|
10
10
|
const web_1 = require("../../bin/utils/platform/web");
|
|
11
11
|
const constants_1 = require("../../constants");
|
|
12
12
|
const promptTemplate_0 = "{{#section \"system\"}}\nYou are a software engineer who is given a task to fix semantic and syntactical errors in a typescript file\n'{{scenarioFile}}' provided to you.\nYou will be provided with fixtures and page object models to use and fix errors.\n\nHere is the list of fixtures available:\n\n{{fixtureFiles}}\n\nHere is the list of current page object models available to you:\n\n{{pageFiles}}\n\nUse the above files to fix the errors.\n\nFollow these guidelines before responding with output\n- Ensure there are no type issues in the given {{scenarioFile}} file\n- For the given file respond with only the code\n- Do not respond with markdown syntax or backticks\n- Do not modify anything else apart from the code required to fix typescript error\n- Do not modify any other scenarios apart from the provided scenario name\n- Do not respond with any explanation. Respond only with the updated code.\n{{/section}}\n\n{{#section \"user\"}}\n'{{scenarioFile}}' with scenario name '{{scenarioName}}', has following typescript errors which you need to fix:\n{{errors}}\n\nHere is the content of the '{{scenarioFile}}':\n\n{{fileContent}}\n{{/section}}";
|
|
13
|
-
async function validateAndFixTypescriptErrors({ trace, logger = new logger_1.CustomLogger(), file, pomCode, nonSpecFileCode, testCase,
|
|
13
|
+
async function validateAndFixTypescriptErrors({ trace, logger = new logger_1.CustomLogger(), file, pomCode, nonSpecFileCode, testCase, }) {
|
|
14
14
|
const validateTypesSpan = trace?.span({ name: "detect-type-errors-in-file" });
|
|
15
15
|
logger.log("Validating types...");
|
|
16
16
|
let errors = (0, web_1.validateTypescript)(file);
|
|
@@ -46,15 +46,14 @@ async function validateAndFixTypescriptErrors({ trace, logger = new logger_1.Cus
|
|
|
46
46
|
promptSpan?.end({ output: { instruction } });
|
|
47
47
|
const llm = new llm_1.LLM({
|
|
48
48
|
trace,
|
|
49
|
-
provider:
|
|
50
|
-
defaultModel:
|
|
51
|
-
providerApiKey: constants_1.MODEL_API_KEYS[
|
|
49
|
+
provider: constants_1.DEFAULT_MODEL_PROVIDER,
|
|
50
|
+
defaultModel: constants_1.DEFAULT_MODEL,
|
|
51
|
+
providerApiKey: constants_1.MODEL_API_KEYS[constants_1.DEFAULT_MODEL_PROVIDER],
|
|
52
52
|
});
|
|
53
53
|
const message = await llm.createChatCompletion({
|
|
54
54
|
messages: instruction,
|
|
55
55
|
modelParameters: {
|
|
56
56
|
...constants_1.DEFAULT_MODEL_PARAMETERS,
|
|
57
|
-
...options?.modelParameters,
|
|
58
57
|
},
|
|
59
58
|
});
|
|
60
59
|
const response = message?.content || "";
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import { TraceClient } from "@empiricalrun/llm";
|
|
2
|
-
import type { TestCase
|
|
2
|
+
import type { TestCase } from "@empiricalrun/shared-types";
|
|
3
3
|
import OpenAI from "openai";
|
|
4
|
-
import { CustomLogger } from "../../bin/logger";
|
|
5
4
|
import { CreateTestCodeUpdate } from "./types";
|
|
6
5
|
export declare function createTestWithCodeAgent({ testCase, file, repoFiles, trace, }: {
|
|
7
6
|
testCase: TestCase;
|
|
8
7
|
file: string;
|
|
9
8
|
repoFiles: string | undefined;
|
|
10
9
|
trace?: TraceClient;
|
|
11
|
-
logger?: CustomLogger;
|
|
12
10
|
}): Promise<{
|
|
13
11
|
prompt: OpenAI.Chat.Completions.ChatCompletionMessageParam[];
|
|
14
12
|
agentResponse: string;
|
|
15
13
|
fileChanges: CreateTestCodeUpdate[];
|
|
16
14
|
}>;
|
|
17
|
-
export declare function
|
|
15
|
+
export declare function generateTestWithCodegen({ testCase, file, trace, }: {
|
|
16
|
+
testCase: TestCase;
|
|
17
|
+
file: string;
|
|
18
|
+
trace?: TraceClient;
|
|
19
|
+
}): Promise<TestCase[] | void>;
|
|
18
20
|
//# sourceMappingURL=run.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/codegen/run.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/codegen/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAE3D,OAAO,MAAM,MAAM,QAAQ,CAAC;AAc5B,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAQ/C,wBAAsB,uBAAuB,CAAC,EAC5C,QAAQ,EACR,IAAI,EACJ,SAAS,EACT,KAAK,GACN,EAAE;IACD,QAAQ,EAAE,QAAQ,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB,GAAG,OAAO,CAAC;IACV,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,0BAA0B,EAAE,CAAC;IAC7D,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,oBAAoB,EAAE,CAAC;CACrC,CAAC,CAyDD;AAED,wBAAsB,uBAAuB,CAAC,EAC5C,QAAQ,EACR,IAAI,EACJ,KAAK,GACN,EAAE;IACD,QAAQ,EAAE,QAAQ,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB,GAAG,OAAO,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC,CAgE7B"}
|
|
@@ -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.
|
|
6
|
+
exports.generateTestWithCodegen = exports.createTestWithCodeAgent = void 0;
|
|
7
7
|
const llm_1 = require("@empiricalrun/llm");
|
|
8
8
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
9
9
|
const logger_1 = require("../../bin/logger");
|
|
@@ -65,7 +65,7 @@ ${testCase.steps.join("\n")}`;
|
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
67
|
exports.createTestWithCodeAgent = createTestWithCodeAgent;
|
|
68
|
-
async function
|
|
68
|
+
async function generateTestWithCodegen({ testCase, file, trace, }) {
|
|
69
69
|
const logger = new logger_1.CustomLogger();
|
|
70
70
|
if (!fs_extra_1.default.existsSync(file)) {
|
|
71
71
|
logger.log(`Creating a new spec file: ${file}`);
|
|
@@ -82,7 +82,11 @@ async function generateTest(testCase, file, options, trace) {
|
|
|
82
82
|
const isUpdate = !!testBlock;
|
|
83
83
|
if (isUpdate) {
|
|
84
84
|
logger.log(`Updating the test '${testCase.name}': [View trace](${trace?.getTraceUrl()})`);
|
|
85
|
-
return await (0, update_flow_1.updateTest)(
|
|
85
|
+
return await (0, update_flow_1.updateTest)({
|
|
86
|
+
testCase,
|
|
87
|
+
file,
|
|
88
|
+
trace,
|
|
89
|
+
});
|
|
86
90
|
}
|
|
87
91
|
const testgenUpdatesReporter = new reporter_1.TestGenUpdatesReporter();
|
|
88
92
|
void testgenUpdatesReporter.sendMessage(`Updating test code as per the task. \n View [trace](${trace?.getTraceUrl()})`);
|
|
@@ -94,7 +98,6 @@ async function generateTest(testCase, file, options, trace) {
|
|
|
94
98
|
file,
|
|
95
99
|
repoFiles,
|
|
96
100
|
trace,
|
|
97
|
-
logger,
|
|
98
101
|
});
|
|
99
102
|
await (0, utils_1.applyFileChangesForCreateTest)({
|
|
100
103
|
trace,
|
|
@@ -114,6 +117,5 @@ async function generateTest(testCase, file, options, trace) {
|
|
|
114
117
|
}
|
|
115
118
|
})();
|
|
116
119
|
}));
|
|
117
|
-
await (0, llm_1.flushAllTraces)();
|
|
118
120
|
}
|
|
119
|
-
exports.
|
|
121
|
+
exports.generateTestWithCodegen = generateTestWithCodegen;
|