@empiricalrun/test-gen 0.7.0 → 0.7.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,18 @@
1
1
  # @empiricalrun/test-gen
2
2
 
3
+ ## 0.7.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 9c3ee14: fix: import statements not getting detected correctly
8
+ - 6ec6f56: fix: flag getting picked incorrectly
9
+
10
+ ## 0.7.1
11
+
12
+ ### Patch Changes
13
+
14
+ - 0aaf594: fix: make it easier to open trace
15
+
3
16
  ## 0.7.0
4
17
 
5
18
  ### Minor Changes
@@ -5,6 +5,7 @@ export default class LLMTracing {
5
5
  name?: string;
6
6
  });
7
7
  get id(): string;
8
+ get url(): string;
8
9
  event({ name, input, metadata, output, }: {
9
10
  name: string;
10
11
  input?: any;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/bin/ai/trace/index.ts"],"names":[],"mappings":"AACA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAe5B,MAAM,CAAC,OAAO,OAAO,UAAU;IAC7B,OAAO,CAAC,KAAK,CAAsB;gBACvB,EAAE,IAAuB,EAAE,GAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAO;IAS/D,IAAI,EAAE,WAEL;IAED,KAAK,CAAC,EACJ,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,MAAM,GACP,EAAE;QACD,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE,GAAG,CAAC;QACZ,QAAQ,CAAC,EAAE,GAAG,CAAC;QACf,MAAM,CAAC,EAAE,GAAG,CAAC;KACd;IAID,MAAM,CAAC,EACL,KAAU,EACV,MAAW,EACX,QAAa,GACd,EAAE;QACD,KAAK,CAAC,EAAE,GAAG,CAAC;QACZ,MAAM,CAAC,EAAE,GAAG,CAAC;QACb,QAAQ,CAAC,EAAE,GAAG,CAAC;KACh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CAAM,EAC/B,QAAQ,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM;;oBAIJ,OAAO,MAAM,EAAE,GAAG,CAAC;;;IAMnD,eAAe,CAAC,EACd,IAAS,EACT,KAAU,EACV,UAAe,EACf,KAAU,GACX,EAAE;QACD,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAChC,KAAK,EAAE,GAAG,CAAC;KACZ;;oBAYa,MAAM;;cAEZ,IAAI;;CAcb"}
@@ -24,6 +24,9 @@ class LLMTracing {
24
24
  get id() {
25
25
  return this.trace.traceId;
26
26
  }
27
+ get url() {
28
+ return this.trace.getTraceUrl();
29
+ }
27
30
  event({ name, input, metadata, output, }) {
28
31
  this.trace.event({ name, input, metadata, output });
29
32
  }
package/dist/bin/index.js CHANGED
@@ -83,7 +83,11 @@ async function generateTest(scenarios, file, isUpdate) {
83
83
  counter += 1;
84
84
  if (counter > maxIteration) {
85
85
  trace.event({ name: "code-fix-iteration-max-out" });
86
- logger.error(`Unable to fix typescript errors. Please review ${file} manually and fix the typescript errors. Run the test-gen command again, once errors are fixed. [Trace: ${trace.id}]`);
86
+ logger.error([
87
+ `Unable to fix typescript errors. Please review ${file} manually and fix the typescript errors.`,
88
+ `Run the test-gen command again, once errors are fixed.`,
89
+ `[Trace: ${trace.url}]`,
90
+ ].join("\n"));
87
91
  break;
88
92
  }
89
93
  trace.event({ name: "Found errors fixing" });
@@ -115,7 +119,7 @@ async function generateTest(scenarios, file, isUpdate) {
115
119
  }
116
120
  trace.event({ name: "format-file" });
117
121
  await (0, web_1.formatCode)(file);
118
- logger.success("File formatted successfully!", `[Trace: ${trace.id}]`);
122
+ logger.success("File formatted successfully!", `[Trace: ${trace.url}]`);
119
123
  generatedScenarios.push(scenario);
120
124
  trace.update({ input: { scenario }, output: { response } });
121
125
  }
@@ -127,7 +131,7 @@ async function generateTest(scenarios, file, isUpdate) {
127
131
  process.exit(1);
128
132
  }
129
133
  const scenariosPath = process.argv[2];
130
- const scenario = process.argv[3];
134
+ const scenario = process.argv[3] === "-u" ? "" : process.argv[3];
131
135
  const isUpdate = process.argv.includes("-u");
132
136
  let testGenConfigs = await (0, scenarios_1.generateScenarios)(scenariosPath);
133
137
  if (scenario) {
@@ -4,10 +4,10 @@ exports.CustomLogger = void 0;
4
4
  const picocolors_1 = require("picocolors");
5
5
  class CustomLogger {
6
6
  log(message, ...optionalParams) {
7
- console.log("🪵 ", (0, picocolors_1.cyan)(message), ...optionalParams);
7
+ console.log("🪵", (0, picocolors_1.cyan)(message), ...optionalParams);
8
8
  }
9
9
  warn(message, ...optionalParams) {
10
- console.log("🟡 ", (0, picocolors_1.yellow)(message), ...optionalParams);
10
+ console.log("🟡", (0, picocolors_1.yellow)(message), ...optionalParams);
11
11
  }
12
12
  success(message, ...optionalParams) {
13
13
  console.log("✅", (0, picocolors_1.green)(message), ...optionalParams);
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/bin/utils/platform/web/index.ts"],"names":[],"mappings":"AAKA,wBAAgB,sBAAsB,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,0BAG3E;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAwC7D;AAED,wBAAsB,sBAAsB,CAAC,OAAO,EAAE,MAAM,qBAK3D;AAED,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,iBAOhD;AAED,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,iBAQhD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/bin/utils/platform/web/index.ts"],"names":[],"mappings":"AAKA,wBAAgB,sBAAsB,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,0BAG3E;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAwC7D;AAED,wBAAsB,sBAAsB,CAAC,OAAO,EAAE,MAAM,qBAM3D;AAED,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,iBAOhD;AAED,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,iBAQhD"}
@@ -52,8 +52,9 @@ function validateTypescript(filePath) {
52
52
  }
53
53
  exports.validateTypescript = validateTypescript;
54
54
  async function stripAndPrependImports(content) {
55
- const imports = content.match(/import.* from.*;/g);
56
- const strippedContent = content.replace(/import.* from.*;/g, "");
55
+ const importRegexp = /import\s+\{[^}]*\}\s+from\s+["'][^"']+["'];?/g;
56
+ const imports = content.match(importRegexp);
57
+ const strippedContent = content.replace(importRegexp, "");
57
58
  const prependContent = (imports?.join("\n") || "") + "\n\n";
58
59
  return [prependContent, strippedContent];
59
60
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empiricalrun/test-gen",
3
- "version": "0.7.0",
3
+ "version": "0.7.2",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"