@empiricalrun/test-gen 0.42.0 → 0.42.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @empiricalrun/test-gen
2
2
 
3
+ ## 0.42.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 87743d9: fix: fill action in case of multi page and context
8
+
9
+ ## 0.42.1
10
+
11
+ ### Patch Changes
12
+
13
+ - ce2b8c7: fix: filter allowed file extensions for repo agent input
14
+
3
15
  ## 0.42.0
4
16
 
5
17
  ### Minor Changes
@@ -1 +1 @@
1
- {"version":3,"file":"fill.d.ts","sourceRoot":"","sources":["../../src/actions/fill.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAIrD,eAAO,MAAM,2BAA2B,uBAAuB,CAAC;AAGhE,eAAO,MAAM,mBAAmB,EAAE,yBA6FjC,CAAC"}
1
+ {"version":3,"file":"fill.d.ts","sourceRoot":"","sources":["../../src/actions/fill.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAIrD,eAAO,MAAM,2BAA2B,uBAAuB,CAAC;AAGhE,eAAO,MAAM,mBAAmB,EAAE,yBAgGjC,CAAC"}
@@ -12,12 +12,14 @@ const fillActionGenerator = (page, options) => {
12
12
  execute: async ({ args }) => {
13
13
  const css = args.css_selector;
14
14
  const locator = await (0, utils_1.getPlaywrightLocatorUsingCssSelector)(css, args.xpath, page.pwPageInstance, args?.elementAnnotation);
15
- const stateVariableKeys = Object.keys(options?.stateVariables);
15
+ const concernedStateVariable = options?.stateVariables[args.variable_name]
16
+ ? args.variable_name
17
+ : "";
16
18
  const testCaseLine = `${locator}.fill(${options?.stateVariables[args.variable_name]
17
19
  ? args.variable_name
18
20
  : `"${args.text}"`})`;
19
- const exec = new Function("page", ...stateVariableKeys, `return page.${testCaseLine}`);
20
- await exec(page.pwPageInstance, ...stateVariableKeys.map((key) => options?.stateVariables[key]));
21
+ const exec = new Function("page", ...(concernedStateVariable ? [concernedStateVariable] : []), `return page.${testCaseLine}`);
22
+ await exec(page.pwPageInstance, options?.stateVariables[args.variable_name]);
21
23
  return {
22
24
  locator,
23
25
  testCaseLine,
@@ -1,5 +1,6 @@
1
1
  import { TraceClient } from "@empiricalrun/llm";
2
2
  import { ChatCompletionMessageParam } from "openai/resources/index.mjs";
3
+ import { CustomLogger } from "../../bin/logger";
3
4
  export declare function generateCodeUsingRepoAgent({ task, trace, repoFiles, }: {
4
5
  trace?: TraceClient;
5
6
  task: string;
@@ -14,9 +15,10 @@ export declare function generateCodeUsingRepoAgent({ task, trace, repoFiles, }:
14
15
  reason: string | undefined;
15
16
  }[];
16
17
  }>;
17
- export declare function repoEditAgent({ trace, task, }: {
18
+ export declare function repoEditAgent({ trace, task, logger, }: {
18
19
  trace?: TraceClient;
19
20
  task: string;
21
+ logger?: CustomLogger;
20
22
  }): Promise<{
21
23
  prompt: ChatCompletionMessageParam[];
22
24
  agentResponse: string;
@@ -1 +1 @@
1
- {"version":3,"file":"repo-edit.d.ts","sourceRoot":"","sources":["../../../src/agent/codegen/repo-edit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AAexE,wBAAsB,0BAA0B,CAAC,EAC/C,IAAI,EACJ,KAAK,EACL,SAAS,GACV,EAAE;IACD,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,OAAO,CAAC;IACV,MAAM,EAAE,0BAA0B,EAAE,CAAC;IACrC,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE;QACX,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;QAC7B,OAAO,EAAE,MAAM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S,CAAC;QAC5B,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;KAC5B,EAAE,CAAC;CACL,CAAC,CA6GD;AAED,wBAAsB,aAAa,CAAC,EAClC,KAAK,EACL,IAAI,EACJ,MAAM,GACP,EAAE;IACD,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB,GAAG,OAAO,CAAC;IACV,MAAM,EAAE,0BAA0B,EAAE,CAAC;IACrC,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE;QACX,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;QAC7B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;QAC5B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;QAC5B,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;KAC5B,EAAE,CAAC;CACL,CAAC,CAkED"}
@@ -122,9 +122,10 @@ Task: ${task}
122
122
  };
123
123
  }
124
124
  exports.generateCodeUsingRepoAgent = generateCodeUsingRepoAgent;
125
- async function repoEditAgent({ trace, task, }) {
125
+ async function repoEditAgent({ trace, task, logger, }) {
126
126
  const testgenUpdatesReporter = new reporter_1.TestGenUpdatesReporter();
127
127
  void testgenUpdatesReporter.sendMessage(`Updating test code as per the task. \n View [trace](${trace?.getTraceUrl()})`);
128
+ logger?.log(`Starting repo agent: ${trace?.getTraceUrl()}`);
128
129
  const { prompt: repoFiles } = await (0, context_1.generateTxtForRepository)();
129
130
  const repoAgentOutput = await generateCodeUsingRepoAgent({
130
131
  task,
@@ -1 +1 @@
1
- {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/codegen/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAMhE,OAAO,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAK7D,wBAAsB,YAAY,CAChC,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,oBAAoB,EAC7B,KAAK,CAAC,EAAE,WAAW,GAClB,OAAO,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC,CAkC5B"}
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/codegen/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAMhE,OAAO,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAK7D,wBAAsB,YAAY,CAChC,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,oBAAoB,EAC7B,KAAK,CAAC,EAAE,WAAW,GAClB,OAAO,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC,CAmC5B"}
@@ -41,6 +41,7 @@ async function generateTest(testCase, file, options, trace) {
41
41
  const repoAgentResponse = await (0, repo_edit_1.repoEditAgent)({
42
42
  trace,
43
43
  task: (0, utils_1.getTaskForCreateTest)({ testCase, file }),
44
+ logger,
44
45
  });
45
46
  createTestSpan?.end({ output: repoAgentResponse.fileChanges });
46
47
  await (0, llm_1.flushAllTraces)();
package/dist/bin/index.js CHANGED
@@ -78,6 +78,7 @@ async function runAgent(testGenConfig) {
78
78
  await (0, repo_edit_1.repoEditAgent)({
79
79
  trace,
80
80
  task: testGenConfig.testCase.steps.join("\n"),
81
+ logger,
81
82
  });
82
83
  return;
83
84
  }
@@ -5,6 +5,7 @@ export declare function contextForGeneration(file?: string): Promise<{
5
5
  nonSpecFilePrompt: string | undefined;
6
6
  testFileContent: string;
7
7
  }>;
8
+ export declare function createRepoEditFilter(): Promise<(filePath: string) => boolean>;
8
9
  export declare function generateTxtForRepository(): Promise<{
9
10
  prompt: string | undefined;
10
11
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/bin/utils/context.ts"],"names":[],"mappings":"AAQA,wBAAsB,yBAAyB,2CAe9C;AAED,wBAAsB,oBAAoB,CAAC,IAAI,CAAC,EAAE,MAAM;;;;;GAQvD;AAED,wBAAsB,wBAAwB;;GAK7C;AAED,wBAAsB,iBAAiB,oBAYtC"}
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/bin/utils/context.ts"],"names":[],"mappings":"AAQA,wBAAsB,yBAAyB,2CAe9C;AAED,wBAAsB,oBAAoB,CAAC,IAAI,CAAC,EAAE,MAAM;;;;;GAQvD;AAED,wBAAsB,oBAAoB,uBAItB,MAAM,cAMzB;AAED,wBAAsB,wBAAwB;;GAK7C;AAED,wBAAsB,iBAAiB,oBAYtC"}
@@ -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.fetchAppKnowledge = exports.generateTxtForRepository = exports.contextForGeneration = exports.createGitIgnoreFileFilter = void 0;
6
+ exports.fetchAppKnowledge = exports.generateTxtForRepository = exports.createRepoEditFilter = exports.contextForGeneration = exports.createGitIgnoreFileFilter = void 0;
7
7
  const fs_extra_1 = __importDefault(require("fs-extra"));
8
8
  const ignore_1 = __importDefault(require("ignore"));
9
9
  const fs_1 = require("./fs");
@@ -34,8 +34,17 @@ async function contextForGeneration(file) {
34
34
  };
35
35
  }
36
36
  exports.contextForGeneration = contextForGeneration;
37
+ async function createRepoEditFilter() {
38
+ const allowedExtensions = /\.(ts|js|mjs|json|md)$/i;
39
+ const gitIgnoreFilter = await createGitIgnoreFileFilter();
40
+ return (filePath) => {
41
+ return (gitIgnoreFilter(filePath) &&
42
+ (fs_extra_1.default.statSync(filePath).isDirectory() || allowedExtensions.test(filePath)));
43
+ };
44
+ }
45
+ exports.createRepoEditFilter = createRepoEditFilter;
37
46
  async function generateTxtForRepository() {
38
- const filter = await createGitIgnoreFileFilter();
47
+ const filter = await createRepoEditFilter();
39
48
  return {
40
49
  prompt: await (0, fs_1.generatePromptFromDirectory)(".", filter),
41
50
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empiricalrun/test-gen",
3
- "version": "0.42.0",
3
+ "version": "0.42.2",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"
@@ -71,9 +71,9 @@
71
71
  "ts-morph": "^24.0.0",
72
72
  "tsx": "^4.16.2",
73
73
  "typescript": "^5.3.3",
74
+ "@empiricalrun/reporter": "^0.22.0",
74
75
  "@empiricalrun/llm": "^0.9.29",
75
- "@empiricalrun/r2-uploader": "^0.3.8",
76
- "@empiricalrun/reporter": "^0.22.0"
76
+ "@empiricalrun/r2-uploader": "^0.3.8"
77
77
  },
78
78
  "devDependencies": {
79
79
  "@playwright/test": "1.49.1",