@autobe/benchmark 0.29.0 → 0.29.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.
Files changed (32) hide show
  1. package/lib/example/AutoBeExampleArchiver.d.ts +18 -0
  2. package/lib/example/AutoBeExampleArchiver.js +237 -0
  3. package/lib/example/AutoBeExampleArchiver.js.map +1 -0
  4. package/lib/example/AutoBeExampleBenchmark.d.ts +15 -0
  5. package/lib/example/AutoBeExampleBenchmark.js +110 -0
  6. package/lib/example/AutoBeExampleBenchmark.js.map +1 -0
  7. package/lib/example/AutoBeExampleStorage.d.ts +2 -1
  8. package/lib/example/AutoBeExampleStorage.js +42 -41
  9. package/lib/example/AutoBeExampleStorage.js.map +1 -1
  10. package/lib/example/index.d.ts +2 -0
  11. package/lib/example/index.js +2 -0
  12. package/lib/example/index.js.map +1 -1
  13. package/lib/replay/AutoBeReplayComputer.js +2 -2
  14. package/lib/replay/AutoBeReplayComputer.js.map +1 -1
  15. package/lib/replay/AutoBeReplayStorage.d.ts +5 -0
  16. package/lib/replay/AutoBeReplayStorage.js +15 -0
  17. package/lib/replay/AutoBeReplayStorage.js.map +1 -1
  18. package/lib/structures/IAutoBeExampleBenchmarkState.d.ts +24 -0
  19. package/lib/structures/IAutoBeExampleBenchmarkState.js +3 -0
  20. package/lib/structures/IAutoBeExampleBenchmarkState.js.map +1 -0
  21. package/lib/structures/index.d.ts +1 -0
  22. package/lib/structures/index.js +18 -0
  23. package/lib/structures/index.js.map +1 -0
  24. package/package.json +4 -5
  25. package/src/example/AutoBeExampleArchiver.ts +334 -0
  26. package/src/example/AutoBeExampleBenchmark.ts +143 -0
  27. package/src/example/AutoBeExampleStorage.ts +45 -44
  28. package/src/example/index.ts +2 -0
  29. package/src/replay/AutoBeReplayComputer.ts +1 -1
  30. package/src/replay/AutoBeReplayStorage.ts +29 -0
  31. package/src/structures/IAutoBeExampleBenchmarkState.ts +29 -0
  32. package/src/structures/index.ts +1 -0
@@ -14,6 +14,8 @@ import { Singleton, VariadicSingleton } from "tstl";
14
14
  import { v7 } from "uuid";
15
15
 
16
16
  export namespace AutoBeExampleStorage {
17
+ export const TEST_ROOT: string = `${__dirname}/../../../../test`;
18
+
17
19
  export const repository = (): string => examples.get();
18
20
  export const getDirectory = (props: {
19
21
  vendor: string;
@@ -24,7 +26,7 @@ export namespace AutoBeExampleStorage {
24
26
  export const save = async (props: {
25
27
  vendor: string;
26
28
  project: AutoBeExampleProject;
27
- files: Record<string, string>;
29
+ files: Record<string, string | null>;
28
30
  }): Promise<void> => {
29
31
  await saveWithGzip({
30
32
  root: `${getDirectory(props)}`,
@@ -166,52 +168,51 @@ export namespace AutoBeExampleStorage {
166
168
  if (replaceSlash) model = model.replaceAll("/", "-");
167
169
  return model;
168
170
  };
169
- }
170
171
 
171
- const PROMPT_TEMPLATE = {
172
- prisma: "Design the database schema.",
173
- interface: "Create the API interface specification.",
174
- test: "Make the e2e test functions.",
175
- realize: "Implement API functions.",
176
- };
177
- const TEST_ROOT: string = `${__dirname}/../../../../test`;
172
+ const PROMPT_TEMPLATE = {
173
+ prisma: "Design the database schema.",
174
+ interface: "Create the API interface specification.",
175
+ test: "Make the e2e test functions.",
176
+ realize: "Implement API functions.",
177
+ };
178
178
 
179
- const examples = new Singleton(() => {
180
- const location: string = `${TEST_ROOT}/../../autobe-examples`;
181
- if (fs.existsSync(location) === false) {
182
- cp.execSync(`git clone https://github.com/wrtnlabs/autobe-examples`, {
183
- cwd: `${TEST_ROOT}/../../`,
184
- stdio: "inherit",
185
- });
186
- }
187
- cp.execSync("git pull", {
188
- cwd: location,
189
- stdio: "ignore",
179
+ const examples = new Singleton(() => {
180
+ const location: string = `${TEST_ROOT}/../../autobe-examples`;
181
+ if (fs.existsSync(location) === false)
182
+ cp.execSync(`git clone https://github.com/wrtnlabs/autobe-examples`, {
183
+ cwd: `${TEST_ROOT}/../../`,
184
+ stdio: "inherit",
185
+ });
186
+ if (fs.existsSync(`${location}/raw`) === false)
187
+ fs.mkdirSync(`${location}/raw`);
188
+ return location;
190
189
  });
191
- if (fs.existsSync(`${location}/raw`) === false)
192
- fs.mkdirSync(`${location}/raw`);
193
- return location;
194
- });
195
190
 
196
- const saveWithGzip = async (props: {
197
- root: string;
198
- files: Record<string, string>;
199
- overwrite?: boolean;
200
- }): Promise<void> => {
201
- if (props.overwrite !== true && fs.existsSync(props.root))
202
- await fs.promises.rm(props.root, {
203
- recursive: true,
204
- });
205
- const directory = new VariadicSingleton(async (location: string) => {
206
- try {
207
- await fs.promises.mkdir(location, {
191
+ const saveWithGzip = async (props: {
192
+ root: string;
193
+ files: Record<string, string | null>;
194
+ overwrite?: boolean;
195
+ }): Promise<void> => {
196
+ if (props.overwrite !== true && fs.existsSync(props.root))
197
+ await fs.promises.rm(props.root, {
208
198
  recursive: true,
209
199
  });
210
- } catch {}
211
- });
212
- for (const [key, value] of Object.entries(props.files)) {
213
- const file: string = path.resolve(`${props.root}/${key}.gz`);
214
- await directory.get(path.dirname(file));
215
- await fs.promises.writeFile(file, await CompressUtil.gzip(value ?? ""));
216
- }
217
- };
200
+ const directory = new VariadicSingleton(async (location: string) => {
201
+ try {
202
+ await fs.promises.mkdir(location, {
203
+ recursive: true,
204
+ });
205
+ } catch {}
206
+ });
207
+ for (const [key, value] of Object.entries(props.files)) {
208
+ const file: string = path.resolve(`${props.root}/${key}.gz`);
209
+ await directory.get(path.dirname(file));
210
+ if (value !== null)
211
+ await fs.promises.writeFile(file, await CompressUtil.gzip(value ?? ""));
212
+ else
213
+ try {
214
+ await fs.promises.unlink(file);
215
+ } catch {}
216
+ }
217
+ };
218
+ }
@@ -1 +1,3 @@
1
+ export * from "./AutoBeExampleArchiver";
2
+ export * from "./AutoBeExampleBenchmark";
1
3
  export * from "./AutoBeExampleStorage";
@@ -1,4 +1,3 @@
1
- import { AutoBeProcessAggregateFactory } from "@autobe/agent/src/factory/AutoBeProcessAggregateFactory";
2
1
  import {
3
2
  AutoBeExampleProject,
4
3
  AutoBeHistory,
@@ -6,6 +5,7 @@ import {
6
5
  IAutoBePlaygroundBenchmarkScore,
7
6
  IAutoBePlaygroundReplay,
8
7
  } from "@autobe/interface";
8
+ import { AutoBeProcessAggregateFactory } from "@autobe/utils";
9
9
 
10
10
  export namespace AutoBeReplayComputer {
11
11
  export const SIGNIFICANT_PROJECTS: AutoBeExampleProject[] = [
@@ -1,3 +1,4 @@
1
+ import { CompressUtil } from "@autobe/filesystem";
1
2
  import {
2
3
  AutoBeEventSnapshot,
3
4
  AutoBeExampleProject,
@@ -5,6 +6,7 @@ import {
5
6
  AutoBePhase,
6
7
  IAutoBePlaygroundReplay,
7
8
  } from "@autobe/interface";
9
+ import fs from "fs";
8
10
  import typia from "typia";
9
11
 
10
12
  import { AutoBeExampleStorage } from "../example/AutoBeExampleStorage";
@@ -28,6 +30,22 @@ export namespace AutoBeReplayStorage {
28
30
  return replays.filter((r) => r !== null);
29
31
  };
30
32
 
33
+ export const getAllSummaries = async (
34
+ vendor: string,
35
+ projectFilter?: (project: AutoBeExampleProject) => boolean,
36
+ ): Promise<IAutoBePlaygroundReplay.ISummary[]> => {
37
+ const projects: AutoBeExampleProject[] = typia.misc
38
+ .literals<AutoBeExampleProject>()
39
+ .filter(projectFilter ?? (() => true));
40
+ const summaries: Array<IAutoBePlaygroundReplay.ISummary | null> =
41
+ await Promise.all(
42
+ projects.map((project) =>
43
+ AutoBeReplayStorage.getSummary({ vendor, project }),
44
+ ),
45
+ );
46
+ return summaries.filter((s) => s !== null);
47
+ };
48
+
31
49
  export const get = async (props: {
32
50
  vendor: string;
33
51
  project: AutoBeExampleProject;
@@ -60,6 +78,17 @@ export namespace AutoBeReplayStorage {
60
78
  };
61
79
  };
62
80
 
81
+ export const getSummary = async (props: {
82
+ vendor: string;
83
+ project: AutoBeExampleProject;
84
+ }): Promise<IAutoBePlaygroundReplay.ISummary | null> => {
85
+ const location: string = `${AutoBeExampleStorage.getDirectory(props)}/summary.json.gz`;
86
+ if (fs.existsSync(location) === false) return null;
87
+ return JSON.parse(
88
+ await CompressUtil.gunzip(await fs.promises.readFile(location)),
89
+ );
90
+ };
91
+
63
92
  const getHistories = async (props: {
64
93
  vendor: string;
65
94
  project: AutoBeExampleProject;
@@ -0,0 +1,29 @@
1
+ import {
2
+ AutoBeEventSnapshot,
3
+ AutoBeExampleProject,
4
+ AutoBePhase,
5
+ } from "@autobe/interface";
6
+
7
+ export interface IAutoBeExampleBenchmarkState {
8
+ vendors: IAutoBeExampleBenchmarkState.IOfVendor[];
9
+ }
10
+ export namespace IAutoBeExampleBenchmarkState {
11
+ export interface IOfVendor {
12
+ name: string;
13
+ projects: IOfProject[];
14
+ }
15
+ export interface IOfProject {
16
+ name: AutoBeExampleProject;
17
+ phases: IOfPhase[];
18
+ success: boolean | null;
19
+ started_at: Date;
20
+ completed_at: Date | null;
21
+ }
22
+ export interface IOfPhase {
23
+ name: AutoBePhase;
24
+ snapshot: AutoBeEventSnapshot | null;
25
+ success: boolean | null;
26
+ started_at: Date;
27
+ completed_at: Date | null;
28
+ }
29
+ }
@@ -0,0 +1 @@
1
+ export * from "./IAutoBeExampleBenchmarkState";