@empiricalrun/test-gen 0.43.2 → 0.44.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 +17 -0
- package/dist/agent/codegen/run.d.ts.map +1 -1
- package/dist/agent/codegen/run.js +3 -1
- package/dist/agent/planner/run.d.ts +1 -1
- package/dist/agent/planner/run.d.ts.map +1 -1
- package/dist/agent/planner/run.js +91 -28
- package/dist/bin/index.js +5 -2
- package/dist/bin/utils/index.d.ts +1 -0
- package/dist/bin/utils/index.d.ts.map +1 -1
- package/dist/bin/utils/scenarios/index.d.ts.map +1 -1
- package/dist/bin/utils/scenarios/index.js +3 -2
- package/dist/file/client.d.ts +1 -0
- package/dist/file/client.d.ts.map +1 -1
- package/dist/file/client.js +16 -0
- package/dist/file/server.d.ts.map +1 -1
- package/dist/file/server.js +2 -0
- package/dist/human-in-the-loop/cli.d.ts +2 -0
- package/dist/human-in-the-loop/cli.d.ts.map +1 -0
- package/dist/human-in-the-loop/cli.js +24 -0
- package/dist/human-in-the-loop/index.d.ts +10 -0
- package/dist/human-in-the-loop/index.d.ts.map +1 -0
- package/dist/human-in-the-loop/index.js +24 -0
- package/dist/human-in-the-loop/ipc.d.ts +4 -0
- package/dist/human-in-the-loop/ipc.d.ts.map +1 -0
- package/dist/human-in-the-loop/ipc.js +48 -0
- package/dist/prompts/lib/ts-transformer.d.ts.map +1 -1
- package/dist/prompts/lib/ts-transformer.js +3 -1
- package/package.json +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @empiricalrun/test-gen
|
|
2
2
|
|
|
3
|
+
## 0.44.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- c206ea8: feat: Add suites CLI flag for test generation
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 57ea65d: fix: prompt for create test using code agent to honour the file name and test case name
|
|
12
|
+
|
|
13
|
+
## 0.43.3
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- 0b4cffa: feat: add human in the loop for planner
|
|
18
|
+
- 694e202: fix: report gen assets should not throw in cli
|
|
19
|
+
|
|
3
20
|
## 0.43.2
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/codegen/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,WAAW,EACZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EACV,QAAQ,EACR,oBAAoB,EACrB,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAmBhD,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;IACpB,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB;;;;
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/codegen/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,WAAW,EACZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EACV,QAAQ,EACR,oBAAoB,EACrB,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAmBhD,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;IACpB,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB;;;;GAyDA;AAED,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,CA8D5B"}
|
|
@@ -10,7 +10,7 @@ const logger_1 = require("../../bin/logger");
|
|
|
10
10
|
const context_1 = require("../../bin/utils/context");
|
|
11
11
|
const web_1 = require("../../bin/utils/platform/web");
|
|
12
12
|
const constants_1 = require("../../constants");
|
|
13
|
-
const promptTemplate_0 = "{{#section \"system\"}}\nYou are a software test engineer who is given a task to write test cases in a Playwright test repository.\nYou will be provided with current test files, fixtures and page object models for you to use and update code as per the\ntask provided to you.\nYou need to respond with file path, the new test code block to be updated in the file and the reason for the change.\n\nHere is the list of files:\n\n{{repoFiles}}\n{{/section}}\n\n{{#section \"user\"}}\nTask: {{task}}\n\n## Follow these instructions before responding with output:\n-
|
|
13
|
+
const promptTemplate_0 = "{{#section \"system\"}}\nYou are a software test engineer who is given a task to write test cases in a Playwright test repository.\nYou will be provided with current test files, fixtures and page object models for you to use and update code as per the\ntask provided to you.\nYou need to respond with file path, the new test code block to be updated in the file and the reason for the change.\n\nHere is the list of files:\n\n{{repoFiles}}\n{{/section}}\n\n{{#section \"user\"}}\nTask: {{task}}\n\n## Follow these instructions before responding with output:\n- Scan the file '{{testFilePath}}' and check whether test case with name '{{testCaseName}}' exists in the file\n- If it exists do not update the file\n- else respond with <file_path></file_path>, <code_block></code_block> and <change></change> as xml tags\n- Only respond with single code_block in the response containing only the test code block to be updated\n{{/section}}";
|
|
14
14
|
const reporter_1 = require("../../reporter");
|
|
15
15
|
const update_flow_1 = require("./update-flow");
|
|
16
16
|
const utils_1 = require("./utils");
|
|
@@ -27,6 +27,8 @@ ${testCase.steps.join("\n")}`;
|
|
|
27
27
|
const prompt = (0, llm_1.compilePrompt)(promptTemplate_0, {
|
|
28
28
|
task,
|
|
29
29
|
repoFiles,
|
|
30
|
+
testCaseName: testCase.name,
|
|
31
|
+
testFilePath: file,
|
|
30
32
|
});
|
|
31
33
|
const createTestSpan = trace?.span({
|
|
32
34
|
name: "create-test",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/planner/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/planner/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAapE,wBAAsB,QAAQ,CAAC,EAC7B,IAAI,EACJ,QAAQ,EACR,KAAK,GACN,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB,gBA0HA"}
|
|
@@ -3,24 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.planTask = void 0;
|
|
4
4
|
const llm_1 = require("@empiricalrun/llm");
|
|
5
5
|
const context_1 = require("../../bin/utils/context");
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
const result = {
|
|
9
|
-
createSubTasks: "",
|
|
10
|
-
verfiedSubTasks: "",
|
|
11
|
-
enrichedSubTasks: "",
|
|
12
|
-
finalPlan: "",
|
|
13
|
-
};
|
|
14
|
-
const regex = /<create_sub_tasks>([\s\S]*?)<\/create_sub_tasks>[\s\S]*?<enriched_sub_tasks>([\s\S]*?)<\/enriched_sub_tasks>[\s\S]*?<final_plan>([\s\S]*?)<\/final_plan>/g;
|
|
15
|
-
let match;
|
|
16
|
-
while ((match = regex.exec(input)) !== null) {
|
|
17
|
-
const [, createSubTasks, enrichedSubTasks, finalPlan] = match;
|
|
18
|
-
result.createSubTasks = createSubTasks?.trim() || "";
|
|
19
|
-
result.enrichedSubTasks = enrichedSubTasks?.trim() || "";
|
|
20
|
-
result.finalPlan = finalPlan?.trim() || "";
|
|
21
|
-
}
|
|
22
|
-
return result;
|
|
23
|
-
}
|
|
6
|
+
const human_in_the_loop_1 = require("../../human-in-the-loop");
|
|
7
|
+
const promptTemplate_0 = "{{#section \"system\"}}\nYou are an expert software engineer in test and have capability to collaborate with user to generate a test plan.\nYou are given a task to provide a high level plan to create a test for a given scenario.\n\nYou will be provided with already added Playwright tests and page object object models which you can use generate the test plan.\nTest plan should be a list of bullet points and each bullet point representing each test step.\nYou will be provided with app knowledge which can help you groom the steps in the plan.\n\n{{#if humanLoopRequired}}\nDo NOT finish until you have a complete understanding of the plan and have all the minute details of how the test should look like.\n\nALWAYS VERIFY THE PLAN WITH USER BEFORE FINISHING. THE USER SHOULD BE ABLE TO REVIEW AND GIVE GO AHEAD TO THE PLAN.\n\nDO NOT FINISH UNTIL USER EXPLICITLY CONFIRMS THE PLAN IS GOOD TO GO.\n{{/if}}\n\n### Test Plan Creation Guidelines\n\n- **Create Subtasks:**\n - Read the task step by step and create subtasks from the given task.\n - Do not add any new steps that are not mentioned in the task.\n\n- **Enrich Subtasks:**\n - Read the provided app knowledge.\n - Enrich the subtasks based on the information from the app knowledge.\n\n- **Plan:**\n - Once all subtasks are enriched, list them as bullet points.\n - Each bullet point must start with one of the following actions: \n - Open page \n - Click on \n - Fill in \n - Assert \n - Hover on \n - Press \n - Extract textContent\n - Do not include any bullet points that do not start with the above actions.\n\n- **Additional Notes:**\n - The final output should only contain bullet points listing the test steps.\n - Do not add any assertions that are not mentioned in the task or app knowledge.\n - The plan should not reference the knowledge base used to generate it.\n\n{{/section}}\n\n{{#section \"user\"}}\n\nApp knowledge:\n{{appKnowledge}}\n\n-----\n\nCurrent tests and page object model references:\n{{fileContext}}\n\n------\n\nTask:\n{{task}}\n\n------\n{{/section}}";
|
|
24
8
|
async function planTask({ task, specPath, trace, }) {
|
|
25
9
|
let fileContext = "";
|
|
26
10
|
try {
|
|
@@ -39,27 +23,106 @@ ${pomPrompt}
|
|
|
39
23
|
task,
|
|
40
24
|
},
|
|
41
25
|
});
|
|
26
|
+
// if the code in running in ci worker or github actions, disable human loop
|
|
27
|
+
const humanLoopRequired = process.env.CI !== "true";
|
|
42
28
|
const appKnowledge = await (0, context_1.fetchAppKnowledge)();
|
|
43
29
|
const messages = (0, llm_1.compilePrompt)(promptTemplate_0, {
|
|
44
30
|
appKnowledge,
|
|
45
31
|
fileContext,
|
|
46
32
|
task,
|
|
33
|
+
humanLoopRequired,
|
|
47
34
|
});
|
|
48
35
|
const llm = new llm_1.LLM({
|
|
49
36
|
provider: "openai",
|
|
50
|
-
//TODO: change to o1
|
|
51
37
|
defaultModel: "gpt-4o",
|
|
52
38
|
});
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
39
|
+
let maxRetries = 10;
|
|
40
|
+
// TODO: this should be environment driven
|
|
41
|
+
const hl = new human_in_the_loop_1.HumanLoop({ method: "ipc" });
|
|
42
|
+
const tools = [
|
|
43
|
+
{
|
|
44
|
+
type: "function",
|
|
45
|
+
function: {
|
|
46
|
+
name: "finish",
|
|
47
|
+
description: "Final output of the conversation",
|
|
48
|
+
parameters: {
|
|
49
|
+
type: "object",
|
|
50
|
+
properties: {
|
|
51
|
+
plan: {
|
|
52
|
+
type: "string",
|
|
53
|
+
description: "Final plan which is verified by the user",
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
required: ["plan"],
|
|
57
|
+
additionalProperties: false,
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
];
|
|
62
|
+
if (humanLoopRequired) {
|
|
63
|
+
tools.push({
|
|
64
|
+
type: "function",
|
|
65
|
+
function: {
|
|
66
|
+
name: "send_user_message",
|
|
67
|
+
description: "Send user message",
|
|
68
|
+
parameters: {
|
|
69
|
+
type: "object",
|
|
70
|
+
properties: {
|
|
71
|
+
message: {
|
|
72
|
+
type: "string",
|
|
73
|
+
description: "Message to be sent to the user for any confirmation or clarification",
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
required: ["message"],
|
|
77
|
+
additionalProperties: false,
|
|
78
|
+
},
|
|
79
|
+
strict: true,
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
while (maxRetries--) {
|
|
84
|
+
const response = await llm.createChatCompletion({
|
|
85
|
+
trace: plannerSpan,
|
|
86
|
+
traceName: "planner-llm",
|
|
87
|
+
messages,
|
|
88
|
+
tools,
|
|
89
|
+
modelParameters: {
|
|
90
|
+
temperature: 0.5,
|
|
91
|
+
tool_choice: "required",
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
const toolCall = response?.tool_calls?.[0];
|
|
95
|
+
const respStr = toolCall?.function.arguments;
|
|
96
|
+
const resp = JSON.parse(respStr || "{}");
|
|
97
|
+
// TODO: handle this as a part of actions handler
|
|
98
|
+
if (toolCall?.function.name === "send_user_message") {
|
|
99
|
+
const feedback = await hl.getFeedback({
|
|
100
|
+
message: resp.message,
|
|
101
|
+
});
|
|
102
|
+
messages.push(response);
|
|
103
|
+
messages.push({
|
|
104
|
+
role: "tool",
|
|
105
|
+
tool_call_id: toolCall?.id,
|
|
106
|
+
content: feedback,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
const plan = resp.plan;
|
|
111
|
+
plannerSpan?.end({
|
|
112
|
+
output: {
|
|
113
|
+
plan,
|
|
114
|
+
},
|
|
115
|
+
});
|
|
116
|
+
return plan;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
// TODO: handle planner failure scenario
|
|
120
|
+
plannerSpan?.end({
|
|
121
|
+
output: {
|
|
122
|
+
plan: "",
|
|
123
|
+
error: "Failed to generate test plan",
|
|
59
124
|
},
|
|
60
125
|
});
|
|
61
|
-
|
|
62
|
-
plannerSpan?.end({ output: plan?.finalPlan });
|
|
63
|
-
return plan?.finalPlan;
|
|
126
|
+
return "";
|
|
64
127
|
}
|
|
65
128
|
exports.planTask = planTask;
|
package/dist/bin/index.js
CHANGED
|
@@ -154,7 +154,8 @@ async function runAgent(testGenConfig, testGenToken, span) {
|
|
|
154
154
|
specPath,
|
|
155
155
|
trace,
|
|
156
156
|
});
|
|
157
|
-
new logger_1.CustomLogger({ useReporter: false }).log("Generated Plan:"
|
|
157
|
+
new logger_1.CustomLogger({ useReporter: false }).log("Generated Plan:");
|
|
158
|
+
console.log(plan);
|
|
158
159
|
await new reporter_1.TestGenUpdatesReporter().sendMessage(plan);
|
|
159
160
|
}
|
|
160
161
|
else if (agent === "code") {
|
|
@@ -185,6 +186,7 @@ async function runAgent(testGenConfig, testGenToken, span) {
|
|
|
185
186
|
.option("--name <test-name>", "Name of the test case")
|
|
186
187
|
.option("--prompt <prompt>", "Prompt for the test case")
|
|
187
188
|
.option("--file <test-file>", "File path of the test case (inside tests dir)")
|
|
189
|
+
.option("--suites <suites>", "Comma separated list of describe blocks")
|
|
188
190
|
.parse(process.argv);
|
|
189
191
|
const options = program.opts();
|
|
190
192
|
(0, utils_2.validateCliOptions)(options);
|
|
@@ -221,7 +223,8 @@ async function runAgent(testGenConfig, testGenToken, span) {
|
|
|
221
223
|
if (agentUsed &&
|
|
222
224
|
agentUsed !== "code" &&
|
|
223
225
|
agentUsed !== "plan" &&
|
|
224
|
-
testGenConfig.testCase.name
|
|
226
|
+
testGenConfig.testCase.name &&
|
|
227
|
+
testGenConfig.options) {
|
|
225
228
|
await new reporter_1.TestGenUpdatesReporter().reportGenAssets({
|
|
226
229
|
projectRepoName: testGenConfig.options.metadata.projectRepoName,
|
|
227
230
|
testName: testGenConfig.testCase.name,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/bin/utils/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,oBAA2B,CAAC;AACpD,eAAO,MAAM,OAAO,oBAA6B,CAAC;AAElD,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI,CAS5D"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/bin/utils/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,oBAA2B,CAAC;AACpD,eAAO,MAAM,OAAO,oBAA6B,CAAC;AAElD,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI,CAS5D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/bin/utils/scenarios/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,aAAa,EAEd,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAetC,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,GACjC,MAAM,CAgBR;AAED,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,GACjC,aAAa,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/bin/utils/scenarios/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,aAAa,EAEd,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAetC,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,GACjC,MAAM,CAgBR;AAED,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,GACjC,aAAa,CAaf;AAED,wBAAgB,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,aAAa,CAmBnE"}
|
|
@@ -27,8 +27,9 @@ function buildTestConfigFromOptions(options) {
|
|
|
27
27
|
name: options.name,
|
|
28
28
|
steps: [options.prompt],
|
|
29
29
|
filePath: options.file,
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
suites: options.suites
|
|
31
|
+
? options.suites.split(",").map((s) => s.trim())
|
|
32
|
+
: [],
|
|
32
33
|
},
|
|
33
34
|
};
|
|
34
35
|
}
|
package/dist/file/client.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/file/client.ts"],"names":[],"mappings":"AAAA,cAAM,eAAe;IACnB,OAAO,EAAE,MAAM,CAAC;gBACJ,IAAI,EAAE,MAAM;IAIlB,UAAU,CAAC,EACf,aAAa,EACb,IAAI,EACJ,WAAW,GACZ,EAAE;QACD,aAAa,EAAE,MAAM,CAAC;QACtB,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,EAAE,CAAC;KACvB;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/file/client.ts"],"names":[],"mappings":"AAAA,cAAM,eAAe;IACnB,OAAO,EAAE,MAAM,CAAC;gBACJ,IAAI,EAAE,MAAM;IAIlB,UAAU,CAAC,EACf,aAAa,EACb,IAAI,EACJ,WAAW,GACZ,EAAE;QACD,aAAa,EAAE,MAAM,CAAC;QACtB,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,EAAE,CAAC;KACvB;IAgBK,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG;CAgBnC;AAED,eAAe,eAAe,CAAC"}
|
package/dist/file/client.js
CHANGED
|
@@ -20,5 +20,21 @@ class TestFileService {
|
|
|
20
20
|
console.log("Generated and updated test successfully");
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
+
async post(path, body) {
|
|
24
|
+
const resp = await fetch(`${this.baseUrl}${path}`, {
|
|
25
|
+
method: "POST",
|
|
26
|
+
headers: {
|
|
27
|
+
"Content-Type": "application/json",
|
|
28
|
+
},
|
|
29
|
+
body: JSON.stringify(body),
|
|
30
|
+
});
|
|
31
|
+
if (!resp.ok) {
|
|
32
|
+
throw new Error(`API failed with status ${resp.statusText}`);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
const data = await resp.json();
|
|
36
|
+
return data;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
23
39
|
}
|
|
24
40
|
exports.default = TestFileService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/file/server.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/file/server.ts"],"names":[],"mappings":"AAWA,qBAAa,WAAW;IACtB,OAAO,CAAC,IAAI,CAAa;IACzB,OAAO,CAAC,QAAQ,CAAc;IAC9B,OAAO,CAAC,OAAO,CAAc;gBAEjB,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE;IAKhE,WAAW,CAAC,QAAQ,EAAE,MAAM;IAItB,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC;CAyC1C;AAED,wBAAsB,gBAAgB,kBAAK"}
|
package/dist/file/server.js
CHANGED
|
@@ -8,6 +8,7 @@ const express_1 = __importDefault(require("express"));
|
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
10
10
|
const web_1 = require("../bin/utils/platform/web");
|
|
11
|
+
const ipc_1 = require("../human-in-the-loop/ipc");
|
|
11
12
|
class FileService {
|
|
12
13
|
port = 0;
|
|
13
14
|
filePath = "";
|
|
@@ -22,6 +23,7 @@ class FileService {
|
|
|
22
23
|
async startFileService() {
|
|
23
24
|
const app = (0, express_1.default)();
|
|
24
25
|
app.use(express_1.default.json());
|
|
26
|
+
(0, ipc_1.humanLoopRoute)(app);
|
|
25
27
|
app.post("/test", async (req, res) => {
|
|
26
28
|
const { generatedCode, importPaths } = req.body;
|
|
27
29
|
try {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/human-in-the-loop/cli.ts"],"names":[],"mappings":"AAEA,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAe1E"}
|
|
@@ -0,0 +1,24 @@
|
|
|
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.getFeedbackUsingCli = void 0;
|
|
7
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
8
|
+
async function getFeedbackUsingCli(message) {
|
|
9
|
+
const answers = await inquirer_1.default.prompt([
|
|
10
|
+
{
|
|
11
|
+
type: "input",
|
|
12
|
+
name: "feedback",
|
|
13
|
+
message: message || "Does this plan look good?",
|
|
14
|
+
validate: (input) => {
|
|
15
|
+
if (input.trim().length === 0) {
|
|
16
|
+
return "Feedback cannot be empty";
|
|
17
|
+
}
|
|
18
|
+
return true;
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
]);
|
|
22
|
+
return answers.feedback;
|
|
23
|
+
}
|
|
24
|
+
exports.getFeedbackUsingCli = getFeedbackUsingCli;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/human-in-the-loop/index.ts"],"names":[],"mappings":"AAQA,qBAAa,SAAS;IAER,OAAO,CAAC,OAAO;gBAAP,OAAO,EAAE;QAAE,MAAM,EAAE,KAAK,GAAG,KAAK,CAAA;KAAE;IAChD,WAAW,CAAC,EAAE,OAAO,EAAE,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE;CAOnD"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HumanLoop = void 0;
|
|
4
|
+
const cli_1 = require("./cli");
|
|
5
|
+
const ipc_1 = require("./ipc");
|
|
6
|
+
// TODO: how to make this more conversational
|
|
7
|
+
// do we need a layer to understand the feedback ?
|
|
8
|
+
// we need a layer to put the feedback in the context again
|
|
9
|
+
// and then we need to generate final output which the user can review
|
|
10
|
+
class HumanLoop {
|
|
11
|
+
options;
|
|
12
|
+
// TODO: have a better name for this
|
|
13
|
+
constructor(options) {
|
|
14
|
+
this.options = options;
|
|
15
|
+
}
|
|
16
|
+
async getFeedback({ message }) {
|
|
17
|
+
// this needs to have a provider based on environment
|
|
18
|
+
if (this.options.method === "ipc") {
|
|
19
|
+
return await (0, ipc_1.getFeedbackUsingIPC)(message);
|
|
20
|
+
}
|
|
21
|
+
return await (0, cli_1.getFeedbackUsingCli)(message);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.HumanLoop = HumanLoop;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ipc.d.ts","sourceRoot":"","sources":["../../src/human-in-the-loop/ipc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAKvC,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,QAwB1C;AAED,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAa1E"}
|
|
@@ -0,0 +1,48 @@
|
|
|
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.getFeedbackUsingIPC = exports.humanLoopRoute = void 0;
|
|
7
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
8
|
+
const client_1 = __importDefault(require("../file/client"));
|
|
9
|
+
function humanLoopRoute(app) {
|
|
10
|
+
app.post("/converse", async (req, res) => {
|
|
11
|
+
const { message } = req.body;
|
|
12
|
+
try {
|
|
13
|
+
const answers = await inquirer_1.default.prompt([
|
|
14
|
+
{
|
|
15
|
+
type: "input",
|
|
16
|
+
name: "feedback",
|
|
17
|
+
message: message || "Does this plan look good?",
|
|
18
|
+
validate: (input) => {
|
|
19
|
+
if (input.trim().length === 0) {
|
|
20
|
+
return "Feedback cannot be empty";
|
|
21
|
+
}
|
|
22
|
+
return true;
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
]);
|
|
26
|
+
return res.send({
|
|
27
|
+
...answers,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
catch (e) {
|
|
31
|
+
console.error(e);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
exports.humanLoopRoute = humanLoopRoute;
|
|
36
|
+
async function getFeedbackUsingIPC(message) {
|
|
37
|
+
const port = process.env.APP_PORT || 3030;
|
|
38
|
+
const fileService = new client_1.default(Number(port));
|
|
39
|
+
try {
|
|
40
|
+
const resp = await fileService.post("/converse", { message });
|
|
41
|
+
return resp.feedback;
|
|
42
|
+
}
|
|
43
|
+
catch (e) {
|
|
44
|
+
console.error("[getFeedbackUsingIPC] Error while fetching feedback using IPC", e);
|
|
45
|
+
throw e;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.getFeedbackUsingIPC = getFeedbackUsingIPC;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ts-transformer.d.ts","sourceRoot":"","sources":["../../../src/prompts/lib/ts-transformer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC,iBAAS,2BAA2B,IAAI,EAAE,CAAC,kBAAkB,CAAC,EAAE,CAAC,UAAU,CAAC,
|
|
1
|
+
{"version":3,"file":"ts-transformer.d.ts","sourceRoot":"","sources":["../../../src/prompts/lib/ts-transformer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC,iBAAS,2BAA2B,IAAI,EAAE,CAAC,kBAAkB,CAAC,EAAE,CAAC,UAAU,CAAC,CAsG3E;AAED,eAAe,2BAA2B,CAAC"}
|
|
@@ -32,7 +32,9 @@ function createHandlebarsTransformer() {
|
|
|
32
32
|
const importToVarMap = new Map();
|
|
33
33
|
const visitor = (node) => {
|
|
34
34
|
// Handle references to the imported identifiers
|
|
35
|
-
if (ts.isIdentifier(node) &&
|
|
35
|
+
if (ts.isIdentifier(node) &&
|
|
36
|
+
importToVarMap.has(node.text) &&
|
|
37
|
+
!ts.isPropertyAccessExpression(node.parent)) {
|
|
36
38
|
return ts.factory.createIdentifier(importToVarMap.get(node.text));
|
|
37
39
|
}
|
|
38
40
|
return ts.visitEachChild(node, visitor, context);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empiricalrun/test-gen",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.44.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org/",
|
|
6
6
|
"access": "public"
|
|
@@ -58,6 +58,7 @@
|
|
|
58
58
|
"google-auth-library": "^9.10.0",
|
|
59
59
|
"google-spreadsheet": "^4.1.2",
|
|
60
60
|
"ignore": "^5.3.1",
|
|
61
|
+
"inquirer": "^12.4.2",
|
|
61
62
|
"lodash.isequal": "^4.5.0",
|
|
62
63
|
"md5": "^2.3.0",
|
|
63
64
|
"mime": "^4.0.4",
|
|
@@ -73,8 +74,8 @@
|
|
|
73
74
|
"tsx": "^4.16.2",
|
|
74
75
|
"typescript": "^5.3.3",
|
|
75
76
|
"@empiricalrun/r2-uploader": "^0.3.8",
|
|
76
|
-
"@empiricalrun/
|
|
77
|
-
"@empiricalrun/
|
|
77
|
+
"@empiricalrun/reporter": "^0.23.1",
|
|
78
|
+
"@empiricalrun/llm": "^0.9.35"
|
|
78
79
|
},
|
|
79
80
|
"devDependencies": {
|
|
80
81
|
"@playwright/test": "1.47.1",
|