@autobe/benchmark 0.29.0 → 0.29.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.
Files changed (39) hide show
  1. package/lib/example/AutoBeExampleArchiver.d.ts +19 -0
  2. package/lib/example/AutoBeExampleArchiver.js +239 -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 +124 -0
  6. package/lib/example/AutoBeExampleBenchmark.js.map +1 -0
  7. package/lib/example/AutoBeExampleDocumentation.d.ts +4 -0
  8. package/lib/example/AutoBeExampleDocumentation.js +70 -0
  9. package/lib/example/AutoBeExampleDocumentation.js.map +1 -0
  10. package/lib/example/AutoBeExampleStorage.d.ts +2 -1
  11. package/lib/example/AutoBeExampleStorage.js +42 -41
  12. package/lib/example/AutoBeExampleStorage.js.map +1 -1
  13. package/lib/example/index.d.ts +3 -0
  14. package/lib/example/index.js +3 -0
  15. package/lib/example/index.js.map +1 -1
  16. package/lib/replay/AutoBeReplayComputer.js +2 -2
  17. package/lib/replay/AutoBeReplayComputer.js.map +1 -1
  18. package/lib/replay/AutoBeReplayDocumentation.js +3 -2
  19. package/lib/replay/AutoBeReplayDocumentation.js.map +1 -1
  20. package/lib/replay/AutoBeReplayStorage.d.ts +5 -0
  21. package/lib/replay/AutoBeReplayStorage.js +15 -0
  22. package/lib/replay/AutoBeReplayStorage.js.map +1 -1
  23. package/lib/structures/IAutoBeExampleBenchmarkState.d.ts +25 -0
  24. package/lib/structures/IAutoBeExampleBenchmarkState.js +3 -0
  25. package/lib/structures/IAutoBeExampleBenchmarkState.js.map +1 -0
  26. package/lib/structures/index.d.ts +1 -0
  27. package/lib/structures/index.js +18 -0
  28. package/lib/structures/index.js.map +1 -0
  29. package/package.json +4 -5
  30. package/src/example/AutoBeExampleArchiver.ts +337 -0
  31. package/src/example/AutoBeExampleBenchmark.ts +159 -0
  32. package/src/example/AutoBeExampleDocumentation.ts +84 -0
  33. package/src/example/AutoBeExampleStorage.ts +45 -44
  34. package/src/example/index.ts +3 -0
  35. package/src/replay/AutoBeReplayComputer.ts +1 -1
  36. package/src/replay/AutoBeReplayDocumentation.ts +3 -2
  37. package/src/replay/AutoBeReplayStorage.ts +29 -0
  38. package/src/structures/IAutoBeExampleBenchmarkState.ts +30 -0
  39. package/src/structures/index.ts +1 -0
@@ -0,0 +1,19 @@
1
+ import { AutoBeEventSnapshot, AutoBeExampleProject, AutoBeHistory, IAutoBeAgent, IAutoBeTokenUsageJson } from "@autobe/interface";
2
+ export declare namespace AutoBeExampleArchiver {
3
+ interface IContext {
4
+ vendor: string;
5
+ project: AutoBeExampleProject;
6
+ agent: (props: IAgentProps) => Promise<IAutoBeAgent>;
7
+ on: (snapshot: AutoBeEventSnapshot) => void;
8
+ }
9
+ interface IAgentProps {
10
+ vendor: string;
11
+ histories: AutoBeHistory[];
12
+ tokenUsage: IAutoBeTokenUsageJson;
13
+ }
14
+ const archiveAnalyze: (ctx: IContext) => Promise<boolean>;
15
+ const archivePrisma: (ctx: IContext) => Promise<boolean>;
16
+ const archiveInterface: (ctx: IContext) => Promise<boolean>;
17
+ const archiveTest: (ctx: IContext) => Promise<boolean>;
18
+ const archiveRealize: (ctx: IContext) => Promise<boolean>;
19
+ }
@@ -0,0 +1,239 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.AutoBeExampleArchiver = void 0;
16
+ const filesystem_1 = require("@autobe/filesystem");
17
+ const utils_1 = require("@autobe/utils");
18
+ const typia_1 = __importDefault(require("typia"));
19
+ const replay_1 = require("../replay");
20
+ const AutoBeExampleStorage_1 = require("./AutoBeExampleStorage");
21
+ var AutoBeExampleArchiver;
22
+ (function (AutoBeExampleArchiver) {
23
+ AutoBeExampleArchiver.archiveAnalyze = (ctx) => archive(ctx, {
24
+ phase: "analyze",
25
+ trial: (conversate) => __awaiter(this, void 0, void 0, function* () {
26
+ return (yield conversate(yield AutoBeExampleStorage_1.AutoBeExampleStorage.getUserMessage({
27
+ project: ctx.project,
28
+ phase: "analyze",
29
+ }).then((r) => r.contents))) ||
30
+ (yield conversate("I'm not familiar with the analyze feature. Please determine everything by yourself, and just show me the analysis report.")) ||
31
+ (yield conversate("I already told you to publish the analysis report. Never ask me anything, and just do it right now."));
32
+ }),
33
+ predicate: (histories) => histories.some((h) => h.type === "analyze"),
34
+ });
35
+ AutoBeExampleArchiver.archivePrisma = (ctx) => archive(ctx, {
36
+ phase: "prisma",
37
+ trial: getTrial({
38
+ project: ctx.project,
39
+ phase: "prisma",
40
+ }),
41
+ predicate: (histories) => {
42
+ const prisma = histories.find((h) => h.type === "prisma");
43
+ return prisma !== undefined && prisma.compiled.type === "success";
44
+ },
45
+ });
46
+ AutoBeExampleArchiver.archiveInterface = (ctx) => archive(ctx, {
47
+ phase: "interface",
48
+ trial: getTrial({
49
+ project: ctx.project,
50
+ phase: "interface",
51
+ }),
52
+ predicate: (histories) => {
53
+ const interfaceHistory = histories.find((h) => h.type === "interface");
54
+ return (interfaceHistory !== undefined && interfaceHistory.missed.length === 0);
55
+ },
56
+ });
57
+ AutoBeExampleArchiver.archiveTest = (ctx) => archive(ctx, {
58
+ phase: "test",
59
+ trial: getTrial({
60
+ project: ctx.project,
61
+ phase: "test",
62
+ }),
63
+ predicate: (histories) => {
64
+ const testHistory = histories.find((h) => h.type === "test");
65
+ return (testHistory !== undefined && testHistory.compiled.type === "success");
66
+ },
67
+ });
68
+ AutoBeExampleArchiver.archiveRealize = (ctx) => archive(ctx, {
69
+ phase: "realize",
70
+ trial: getTrial({
71
+ project: ctx.project,
72
+ phase: "realize",
73
+ }),
74
+ predicate: (histories) => {
75
+ const realizeHistory = histories.find((h) => h.type === "realize");
76
+ return (realizeHistory !== undefined &&
77
+ realizeHistory.compiled.type === "success");
78
+ },
79
+ });
80
+ const archive = (ctx, props) => __awaiter(this, void 0, void 0, function* () {
81
+ // INITIALIZE AGENT
82
+ const asset = yield getAsset({
83
+ vendor: ctx.vendor,
84
+ project: ctx.project,
85
+ phase: props.phase,
86
+ });
87
+ const agent = yield ctx.agent(asset);
88
+ const snapshots = [];
89
+ for (const type of typia_1.default.misc.literals()) {
90
+ agent.on(type, (e) => {
91
+ const s = {
92
+ event: e,
93
+ tokenUsage: agent.getTokenUsage(),
94
+ };
95
+ ctx.on(s);
96
+ snapshots.push(s);
97
+ });
98
+ }
99
+ const summarize = (histories, error) => __awaiter(this, void 0, void 0, function* () {
100
+ const replay = {
101
+ vendor: ctx.vendor,
102
+ project: ctx.project,
103
+ histories,
104
+ analyze: null,
105
+ prisma: null,
106
+ interface: null,
107
+ test: null,
108
+ realize: null,
109
+ };
110
+ for (const phase of PHASES)
111
+ if (phase === props.phase) {
112
+ replay[phase] = snapshots;
113
+ break;
114
+ }
115
+ else
116
+ replay[phase] = yield AutoBeExampleStorage_1.AutoBeExampleStorage.getSnapshots({
117
+ vendor: ctx.vendor,
118
+ project: ctx.project,
119
+ phase,
120
+ });
121
+ const summary = replay_1.AutoBeReplayComputer.summarize(replay);
122
+ if (error === true) {
123
+ const aggregates = utils_1.AutoBeProcessAggregateFactory.createCollection();
124
+ for (const { event } of snapshots) {
125
+ if (typia_1.default.is(event) === false)
126
+ continue;
127
+ utils_1.AutoBeProcessAggregateFactory.emplaceEvent(aggregates, event);
128
+ }
129
+ summary[props.phase] = {
130
+ aggregates,
131
+ success: false,
132
+ elapsed: 0,
133
+ commodity: {},
134
+ };
135
+ }
136
+ yield AutoBeExampleStorage_1.AutoBeExampleStorage.save({
137
+ vendor: ctx.vendor,
138
+ project: ctx.project,
139
+ files: {
140
+ [`summary.json`]: JSON.stringify(summary),
141
+ },
142
+ });
143
+ });
144
+ try {
145
+ // CONVERSATE
146
+ const go = (c) => __awaiter(this, void 0, void 0, function* () {
147
+ const result = yield agent.conversate(c);
148
+ return result.some((h) => h.type === props.phase);
149
+ });
150
+ const done = yield props.trial(go);
151
+ if (done === false)
152
+ throw new Error(`Failed to function calling in the "${props.phase}" phase of the "${ctx.project}" project.`);
153
+ // AGGREGATE
154
+ const histories = agent.getHistories();
155
+ try {
156
+ yield filesystem_1.FileSystemIterator.save({
157
+ root: `${AutoBeExampleStorage_1.AutoBeExampleStorage.TEST_ROOT}/results/${AutoBeExampleStorage_1.AutoBeExampleStorage.slugModel(ctx.vendor, false)}/${ctx.project}/${props.phase}`,
158
+ files: Object.assign(Object.assign({}, (yield agent.getFiles())), Object.fromEntries(histories
159
+ .filter((h) => h.type === "prisma" ||
160
+ h.type === "interface" ||
161
+ h.type === "test" ||
162
+ h.type === "realize")
163
+ .map((h) => [`autobe/${h.type}.instruction.md`, h.instruction]))),
164
+ });
165
+ }
166
+ catch (_a) { }
167
+ yield AutoBeExampleStorage_1.AutoBeExampleStorage.save({
168
+ vendor: ctx.vendor,
169
+ project: ctx.project,
170
+ files: {
171
+ [`${props.phase}.histories.json`]: JSON.stringify(histories),
172
+ [`${props.phase}.snapshots.json`]: JSON.stringify(snapshots),
173
+ [`${props.phase}.error.json`]: null,
174
+ },
175
+ });
176
+ yield summarize([...asset.histories, ...histories], false);
177
+ return props.predicate(histories);
178
+ }
179
+ catch (error) {
180
+ if (error instanceof Error)
181
+ yield AutoBeExampleStorage_1.AutoBeExampleStorage.save({
182
+ vendor: ctx.vendor,
183
+ project: ctx.project,
184
+ files: {
185
+ [`${props.phase}.snapshots.json`]: JSON.stringify(snapshots),
186
+ [`${props.phase}.error.json`]: JSON.stringify(Object.assign(Object.assign({}, error), { name: error.name, message: error.message, stack: error.stack })),
187
+ },
188
+ });
189
+ yield summarize(asset.histories, true);
190
+ throw error;
191
+ }
192
+ });
193
+ const getTrial = (props) => (conversate) => __awaiter(this, void 0, void 0, function* () {
194
+ return (yield conversate(yield AutoBeExampleStorage_1.AutoBeExampleStorage.getUserMessage(props).then((r) => r.contents))) ||
195
+ (yield conversate("Don't ask me to do that, and just do it right now.")) ||
196
+ (yield conversate(`I already told you to do ${props.phase} process. Never ask me anything, and just do it right now. Go go go!`));
197
+ });
198
+ const getAsset = (props) => __awaiter(this, void 0, void 0, function* () {
199
+ var _a;
200
+ const previous = (_a = PHASES[PHASES.indexOf(props.phase) - 1]) !== null && _a !== void 0 ? _a : null;
201
+ if (previous === null)
202
+ return {
203
+ vendor: props.vendor,
204
+ histories: [],
205
+ tokenUsage: {
206
+ aggregate: utils_1.TokenUsageComputer.zero(),
207
+ facade: utils_1.TokenUsageComputer.zero(),
208
+ analyze: utils_1.TokenUsageComputer.zero(),
209
+ prisma: utils_1.TokenUsageComputer.zero(),
210
+ interface: utils_1.TokenUsageComputer.zero(),
211
+ test: utils_1.TokenUsageComputer.zero(),
212
+ realize: utils_1.TokenUsageComputer.zero(),
213
+ },
214
+ };
215
+ const histories = yield AutoBeExampleStorage_1.AutoBeExampleStorage.getHistories({
216
+ vendor: props.vendor,
217
+ project: props.project,
218
+ phase: previous,
219
+ });
220
+ const tokenUsage = yield AutoBeExampleStorage_1.AutoBeExampleStorage.getTokenUsage({
221
+ vendor: props.vendor,
222
+ project: props.project,
223
+ phase: previous,
224
+ });
225
+ return {
226
+ vendor: props.vendor,
227
+ histories,
228
+ tokenUsage,
229
+ };
230
+ });
231
+ })(AutoBeExampleArchiver || (exports.AutoBeExampleArchiver = AutoBeExampleArchiver = {}));
232
+ const PHASES = [
233
+ "analyze",
234
+ "prisma",
235
+ "interface",
236
+ "test",
237
+ "realize",
238
+ ];
239
+ //# sourceMappingURL=AutoBeExampleArchiver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AutoBeExampleArchiver.js","sourceRoot":"","sources":["../../src/example/AutoBeExampleArchiver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mDAAwD;AAexD,yCAGuB;AACvB,kDAA0B;AAE1B,sCAAiD;AACjD,iEAA8D;AAE9D,IAAiB,qBAAqB,CAgTrC;AAhTD,WAAiB,qBAAqB;IAcvB,oCAAc,GAAG,CAAC,GAAa,EAAoB,EAAE,CAChE,OAAO,CAAC,GAAG,EAAE;QACX,KAAK,EAAE,SAAS;QAChB,KAAK,EAAE,CAAO,UAAU,EAAoB,EAAE;YAC5C,OAAA,CAAC,MAAM,UAAU,CACf,MAAM,2CAAoB,CAAC,cAAc,CAAC;gBACxC,OAAO,EAAE,GAAG,CAAC,OAAO;gBACpB,KAAK,EAAE,SAAS;aACjB,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAC3B,CAAC;gBACF,CAAC,MAAM,UAAU,CACf,2HAA2H,CAC5H,CAAC;gBACF,CAAC,MAAM,UAAU,CACf,qGAAqG,CACtG,CAAC,CAAA;UAAA;QACJ,SAAS,EAAE,CAAC,SAAS,EAAW,EAAE,CAChC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,SAAS,CAAC;KAC9C,CAAC,CAAC;IAEQ,mCAAa,GAAG,CAAC,GAAa,EAAoB,EAAE,CAC/D,OAAO,CAAC,GAAG,EAAE;QACX,KAAK,EAAE,QAAQ;QACf,KAAK,EAAE,QAAQ,CAAC;YACd,OAAO,EAAE,GAAG,CAAC,OAAO;YACpB,KAAK,EAAE,QAAQ;SAChB,CAAC;QACF,SAAS,EAAE,CAA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B,CAAC,IAAI,EAAE;iBACnC;aACF,CAAC;QACJ,MAAM,SAAS,GAAoB,MAAM,2CAAoB,CAAC,YAAY,CAAC;YACzE,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,KAAK,EAAE,QAAQ;SAChB,CAAC,CAAC;QACH,MAAM,UAAU,GACd,MAAM,2CAAoB,CAAC,aAAa,CAAC;YACvC,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,KAAK,EAAE,QAAQ;SAChB,CAAC,CAAC;QACL,OAAO;YACL,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,SAAS;YACT,UAAU;SACX,CAAC;IACJ,CAAC,CAAA,CAAC;AACJ,CAAC,EAhTgB,qBAAqB,qCAArB,qBAAqB,QAgTrC;AAED,MAAM,MAAM,GAAkB;IAC5B,SAAS;IACT,QAAQ;IACR,WAAW;IACX,MAAM;IACN,SAAS;CACV,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { AutoBeEvent, AutoBeExampleProject, AutoBePhase, IAutoBeAgent } from "@autobe/interface";
2
+ import { IAutoBeExampleBenchmarkState } from "../structures/IAutoBeExampleBenchmarkState";
3
+ import { AutoBeExampleArchiver } from "./AutoBeExampleArchiver";
4
+ export declare namespace AutoBeExampleBenchmark {
5
+ interface IContext {
6
+ createAgent: (props: AutoBeExampleArchiver.IAgentProps) => Promise<IAutoBeAgent>;
7
+ }
8
+ const execute: (ctx: IContext, props: {
9
+ vendors: string[];
10
+ projects?: AutoBeExampleProject[];
11
+ phases?: AutoBePhase[];
12
+ progress: (state: IAutoBeExampleBenchmarkState) => void;
13
+ on?: (event: AutoBeEvent) => void;
14
+ }) => Promise<void>;
15
+ }
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.AutoBeExampleBenchmark = void 0;
13
+ const AutoBeExampleArchiver_1 = require("./AutoBeExampleArchiver");
14
+ var AutoBeExampleBenchmark;
15
+ (function (AutoBeExampleBenchmark) {
16
+ AutoBeExampleBenchmark.execute = (ctx, props) => __awaiter(this, void 0, void 0, function* () {
17
+ const state = {
18
+ vendors: props.vendors.map((vendor) => ({
19
+ name: vendor,
20
+ projects: PROJECT_SEQUENCE.filter((p) => !props.projects || props.projects.includes(p)).map((project) => ({
21
+ name: project,
22
+ phases: [],
23
+ success: null,
24
+ started_at: null,
25
+ completed_at: null,
26
+ })),
27
+ })),
28
+ };
29
+ const report = () => props.progress(state);
30
+ yield Promise.all(state.vendors.map((vendor) => executeVendor(ctx, {
31
+ phases: props.phases,
32
+ vendorState: vendor,
33
+ on: props.on,
34
+ report,
35
+ })));
36
+ });
37
+ const executeVendor = (ctx, props) => __awaiter(this, void 0, void 0, function* () {
38
+ for (const project of props.vendorState.projects)
39
+ yield executeProject(ctx, {
40
+ vendor: props.vendorState.name,
41
+ projectState: project,
42
+ phases: props.phases,
43
+ report: props.report,
44
+ on: props.on,
45
+ });
46
+ });
47
+ const executeProject = (ctx, props) => __awaiter(this, void 0, void 0, function* () {
48
+ props.projectState.started_at = new Date();
49
+ for (const phase of PHASE_SEQUENCE) {
50
+ if (props.phases && props.phases.includes(phase) === false)
51
+ continue;
52
+ const phaseState = {
53
+ name: phase,
54
+ snapshot: null,
55
+ success: null,
56
+ started_at: new Date(),
57
+ completed_at: null,
58
+ trial: 0,
59
+ };
60
+ props.projectState.phases.push(phaseState);
61
+ for (let i = 0; i < 3; ++i) {
62
+ try {
63
+ ++phaseState.trial;
64
+ phaseState.started_at = new Date();
65
+ phaseState.completed_at = null;
66
+ const success = yield getArchiver(phase)({
67
+ vendor: props.vendor,
68
+ project: props.projectState.name,
69
+ agent: (next) => ctx.createAgent(next),
70
+ on: (s) => {
71
+ const event = s.event;
72
+ if (event.type !== "jsonValidateError" &&
73
+ event.type !== "jsonParseError" &&
74
+ event.type !== "preliminary" &&
75
+ event.type !== "consentFunctionCall")
76
+ phaseState.snapshot = s;
77
+ props.report();
78
+ if (props.on)
79
+ props.on(s.event);
80
+ },
81
+ });
82
+ phaseState.success = success;
83
+ phaseState.completed_at = new Date();
84
+ props.report();
85
+ if (success === true)
86
+ break;
87
+ }
88
+ catch (error) {
89
+ continue;
90
+ }
91
+ }
92
+ if (phaseState.success === null)
93
+ break;
94
+ else if (phaseState.success === false && phaseState.name !== "test")
95
+ break;
96
+ }
97
+ props.projectState.completed_at = new Date();
98
+ props.projectState.success = props.projectState.phases.every((phase) => phase.success === true);
99
+ props.report();
100
+ });
101
+ })(AutoBeExampleBenchmark || (exports.AutoBeExampleBenchmark = AutoBeExampleBenchmark = {}));
102
+ const getArchiver = (phase) => {
103
+ if (phase === "analyze")
104
+ return AutoBeExampleArchiver_1.AutoBeExampleArchiver.archiveAnalyze;
105
+ else if (phase === "prisma")
106
+ return AutoBeExampleArchiver_1.AutoBeExampleArchiver.archivePrisma;
107
+ else if (phase === "interface")
108
+ return AutoBeExampleArchiver_1.AutoBeExampleArchiver.archiveInterface;
109
+ else if (phase === "test")
110
+ return AutoBeExampleArchiver_1.AutoBeExampleArchiver.archiveTest;
111
+ else if (phase === "realize")
112
+ return AutoBeExampleArchiver_1.AutoBeExampleArchiver.archiveRealize;
113
+ phase;
114
+ throw new Error(`Unknown phase: ${phase}`);
115
+ };
116
+ const PROJECT_SEQUENCE = ["todo", "bbs", "reddit", "shopping"];
117
+ const PHASE_SEQUENCE = [
118
+ "analyze",
119
+ "prisma",
120
+ "interface",
121
+ "test",
122
+ "realize",
123
+ ];
124
+ //# sourceMappingURL=AutoBeExampleBenchmark.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AutoBeExampleBenchmark.js","sourceRoot":"","sources":["../../src/example/AutoBeExampleBenchmark.ts"],"names":[],"mappings":";;;;;;;;;;;;AAQA,mEAAgE;AAEhE,IAAiB,sBAAsB,CAiItC;AAjID,WAAiB,sBAAsB;IAOxB,8BAAO,GAAG,CACrB,GAAa,EACb,KAMC,EACc,EAAE;QACjB,MAAM,KAAK,GAAiC;YAC1C,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,CACxB,CAAC,MAAM,EAA0C,EAAE,CAAC,CAAC;gBACnD,IAAI,EAAE,MAAM;gBACZ,QAAQ,EAAE,gBAAgB,CAAC,MAAM,CAC/B,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CACrD,CAAC,GAAG,CACH,CAAC,OAAO,EAA2C,EAAE,CAAC,CAAC;oBACrD,IAAI,EAAE,OAAO;oBACb,MAAM,EAAE,EAAE;oBACV,OAAO,EAAE,IAAI;oBACb,UAAU,EAAE,IAAI;oBAChB,YAAY,EAAE,IAAI;iBACnB,CAAC,CACH;aACF,CAAC,CACH;SACF,CAAC;QACF,MAAM,MAAM,GAAG,GAAG,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAC3C,MAAM,OAAO,CAAC,GAAG,CACf,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAC3B,aAAa,CAAC,GAAG,EAAE;YACjB,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,WAAW,EAAE,MAAM;YACnB,EAAE,EAAE,KAAK,CAAC,EAAE;YACZ,MAAM;SACP,CAAC,CACH,CACF,CAAC;IAC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AK,CAC1D,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,KAAK,IAAI,CAClC,CAAC;QACF,KAAK,CAAC,MAAM,EAAE,CAAC;IACjB,CAAC,CAAA,CAAC;AACJ,CAAC,EAjIgB,sBAAsB,sCAAtB,sBAAsB,QAiItC;AAED,MAAM,WAAW,GAAG,CAAC,KAAkB,EAAE,EAAE;IACzC,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,6CAAqB,CAAC,cAAc,CAAC;SAChE,IAAI,KAAK,KAAK,QAAQ;QAAE,OAAO,6CAAqB,CAAC,aAAa,CAAC;SACnE,IAAI,KAAK,KAAK,WAAW;QAAE,OAAO,6CAAqB,CAAC,gBAAgB,CAAC;SACzE,IAAI,KAAK,KAAK,MAAM;QAAE,OAAO,6CAAqB,CAAC,WAAW,CAAC;SAC/D,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,6CAAqB,CAAC,cAAc,CAAC;IAC1E,KAAqB,CAAC;IACtB,MAAM,IAAI,KAAK,CAAC,kBAAkB,KAAK,EAAE,CAAC,CAAC;AAC7C,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,CAAU,CAAC;AACxE,MAAM,cAAc,GAAG;IACrB,SAAS;IACT,QAAQ;IACR,WAAW;IACX,MAAM;IACN,SAAS;CACD,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { IAutoBeExampleBenchmarkState } from "../structures";
2
+ export declare namespace AutoBeExampleDocumentation {
3
+ const markdown: (state: IAutoBeExampleBenchmarkState) => string;
4
+ }
@@ -0,0 +1,70 @@
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.AutoBeExampleDocumentation = void 0;
7
+ const utils_1 = require("@autobe/utils");
8
+ const typia_1 = __importDefault(require("typia"));
9
+ var AutoBeExampleDocumentation;
10
+ (function (AutoBeExampleDocumentation) {
11
+ AutoBeExampleDocumentation.markdown = (state) => utils_1.StringUtil.trim `
12
+ # AutoBe Example Benchmark Report
13
+
14
+ ${markdownIndex(state)}
15
+
16
+ ${state.vendors.map(markdownVendor).join("\n\n")}
17
+ `;
18
+ const markdownIndex = (state) => utils_1.StringUtil.trim `
19
+ ## Table of Contents
20
+
21
+ ${state.vendors
22
+ .map((vendor) => `- [\`${vendor.name}\`](#${vendor.name
23
+ .replaceAll("/", "")
24
+ .replaceAll(":", "")})`)
25
+ .join("\n")}
26
+ `;
27
+ const markdownVendor = (state) => utils_1.StringUtil.trim `
28
+ ## \`${state.name}\`
29
+
30
+ Project | Phase | State | Elapsed Time
31
+ :-------|:------|:------|-------------:
32
+ ${state.projects.map(markdownProject).join("\n")}
33
+ `;
34
+ const markdownProject = (state) => {
35
+ // yellow circle emoji:
36
+ const phase = state.phases.at(-1);
37
+ return [
38
+ state.name,
39
+ !!(phase === null || phase === void 0 ? void 0 : phase.name) ? `${phase.name} (${phase.trial})` : "-",
40
+ state.completed_at !== null
41
+ ? state.success
42
+ ? "🟢 success"
43
+ : "🔴 failure"
44
+ : phase !== undefined && phase.snapshot !== null
45
+ ? [
46
+ phase.trial !== 1 ? "🟠" : "🟡",
47
+ `\`${phase.snapshot.event.type}\``,
48
+ ...(typia_1.default.is(phase.snapshot.event)
49
+ ? [
50
+ `(${phase.snapshot.event.completed} of ${phase.snapshot.event.total})`,
51
+ ]
52
+ : []),
53
+ ].join(" ")
54
+ : "-",
55
+ state.started_at !== null
56
+ ? elapsedTime({
57
+ started_at: state.started_at,
58
+ completed_at: state.completed_at,
59
+ })
60
+ : "-",
61
+ ].join(" | ");
62
+ };
63
+ })(AutoBeExampleDocumentation || (exports.AutoBeExampleDocumentation = AutoBeExampleDocumentation = {}));
64
+ const elapsedTime = (props) => {
65
+ var _a;
66
+ return Math.round((((_a = props.completed_at) !== null && _a !== void 0 ? _a : new Date()).getTime() -
67
+ props.started_at.getTime()) /
68
+ 1000).toLocaleString() + " sec";
69
+ };
70
+ //# sourceMappingURL=AutoBeExampleDocumentation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AutoBeExampleDocumentation.js","sourceRoot":"","sources":["../../src/example/AutoBeExampleDocumentation.ts"],"names":[],"mappings":";;;;;;AACA,yCAA2C;AAC3C,kDAA0B;AAI1B,IAAiB,0BAA0B,CAmE1C;AAnED,WAAiB,0BAA0B;IAC5B,mCAAQ,GAAG,CAAC,KAAmC,EAAU,EAAE,CACtE,kBAAU,CAAC,IAAI,CAAA;;;QAGX,aAAa,CAAC,KAAK,CAAC;;QAEpB,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;KACjD,CAAC;IAEJ,MAAM,aAAa,GAAG,CACpB,KAAmC,EAC3B,EAAE,CAAC,kBAAU,CAAC,IAAI,CAAA;;;MAGxB,KAAK,CAAC,OAAO;SACZ,GAAG,CACF,CAAC,MAAM,EAAE,EAAE,CACT,QAAQ,MAAM,CAAC,IAAI,QAAQ,MAAM,CAAC,IAAI;SACnC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC;SACnB,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAC5B;SACA,IAAI,CAAC,IAAI,CAAC;GACd,CAAC;IAEF,MAAM,cAAc,GAAG,CACrB,KAA6C,EACrC,EAAE,CAAC,kBAAU,CAAC,IAAI,CAAA;WACnB,KAAK,CAAC,IAAI;;;;MAIf,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;GACjD,CAAC;IAEF,MAAM,eAAe,GAAG,CACtB,KAA8C,EACtC,EAAE;QACV,uBAAuB;QACvB,MAAM,KAAK,GACT,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QACtB,OAAO;YACL,KAAK,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AC,CAAC,MAAA,KAAK,CAAC,YAAY,mCAAI,IAAI,IAAI,EAAE,CAAC,CAAC,OAAO,EAAE;QAC3C,KAAK,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;QAC3B,IAAK,CACR,CAAC,cAAc,EAAE,GAAG,MAAM,CAAA;CAAA,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import { AutoBeEventSnapshot, AutoBeExampleProject, AutoBeHistory, AutoBePhase, AutoBeUserMessageHistory, IAutoBeTokenUsageJson } from "@autobe/interface";
2
2
  export declare namespace AutoBeExampleStorage {
3
+ const TEST_ROOT: string;
3
4
  const repository: () => string;
4
5
  const getDirectory: (props: {
5
6
  vendor: string;
@@ -8,7 +9,7 @@ export declare namespace AutoBeExampleStorage {
8
9
  const save: (props: {
9
10
  vendor: string;
10
11
  project: AutoBeExampleProject;
11
- files: Record<string, string>;
12
+ files: Record<string, string | null>;
12
13
  }) => Promise<void>;
13
14
  const getUserMessage: (props: {
14
15
  project: AutoBeExampleProject;
@@ -21,6 +21,7 @@ const tstl_1 = require("tstl");
21
21
  const uuid_1 = require("uuid");
22
22
  var AutoBeExampleStorage;
23
23
  (function (AutoBeExampleStorage) {
24
+ AutoBeExampleStorage.TEST_ROOT = `${__dirname}/../../../../test`;
24
25
  AutoBeExampleStorage.repository = () => examples.get();
25
26
  AutoBeExampleStorage.getDirectory = (props) => `${examples.get()}/raw/${AutoBeExampleStorage.slugModel(props.vendor, false)}/${props.project}`;
26
27
  AutoBeExampleStorage.save = (props) => __awaiter(this, void 0, void 0, function* () {
@@ -31,10 +32,10 @@ var AutoBeExampleStorage;
31
32
  });
32
33
  });
33
34
  AutoBeExampleStorage.getUserMessage = (props) => __awaiter(this, void 0, void 0, function* () {
34
- const full = `${TEST_ROOT}/scripts/${props.project}/${props.phase}`;
35
+ const full = `${AutoBeExampleStorage.TEST_ROOT}/scripts/${props.project}/${props.phase}`;
35
36
  if (fs_1.default.existsSync(`${full}.md`) === false) {
36
37
  const text = props.phase === "analyze"
37
- ? yield fs_1.default.promises.readFile(`${TEST_ROOT}/scripts/${props.project}.md`, "utf8")
38
+ ? yield fs_1.default.promises.readFile(`${AutoBeExampleStorage.TEST_ROOT}/scripts/${props.project}.md`, "utf8")
38
39
  : PROMPT_TEMPLATE[props.phase];
39
40
  return {
40
41
  type: "userMessage",
@@ -124,47 +125,47 @@ var AutoBeExampleStorage;
124
125
  model = model.replaceAll("/", "-");
125
126
  return model;
126
127
  };
127
- })(AutoBeExampleStorage || (exports.AutoBeExampleStorage = AutoBeExampleStorage = {}));
128
- const PROMPT_TEMPLATE = {
129
- prisma: "Design the database schema.",
130
- interface: "Create the API interface specification.",
131
- test: "Make the e2e test functions.",
132
- realize: "Implement API functions.",
133
- };
134
- const TEST_ROOT = `${__dirname}/../../../../test`;
135
- const examples = new tstl_1.Singleton(() => {
136
- const location = `${TEST_ROOT}/../../autobe-examples`;
137
- if (fs_1.default.existsSync(location) === false) {
138
- child_process_1.default.execSync(`git clone https://github.com/wrtnlabs/autobe-examples`, {
139
- cwd: `${TEST_ROOT}/../../`,
140
- stdio: "inherit",
141
- });
142
- }
143
- child_process_1.default.execSync("git pull", {
144
- cwd: location,
145
- stdio: "ignore",
128
+ const PROMPT_TEMPLATE = {
129
+ prisma: "Design the database schema.",
130
+ interface: "Create the API interface specification.",
131
+ test: "Make the e2e test functions.",
132
+ realize: "Implement API functions.",
133
+ };
134
+ const examples = new tstl_1.Singleton(() => {
135
+ const location = `${AutoBeExampleStorage.TEST_ROOT}/../../autobe-examples`;
136
+ if (fs_1.default.existsSync(location) === false)
137
+ child_process_1.default.execSync(`git clone https://github.com/wrtnlabs/autobe-examples`, {
138
+ cwd: `${AutoBeExampleStorage.TEST_ROOT}/../../`,
139
+ stdio: "inherit",
140
+ });
141
+ if (fs_1.default.existsSync(`${location}/raw`) === false)
142
+ fs_1.default.mkdirSync(`${location}/raw`);
143
+ return location;
146
144
  });
147
- if (fs_1.default.existsSync(`${location}/raw`) === false)
148
- fs_1.default.mkdirSync(`${location}/raw`);
149
- return location;
150
- });
151
- const saveWithGzip = (props) => __awaiter(void 0, void 0, void 0, function* () {
152
- if (props.overwrite !== true && fs_1.default.existsSync(props.root))
153
- yield fs_1.default.promises.rm(props.root, {
154
- recursive: true,
155
- });
156
- const directory = new tstl_1.VariadicSingleton((location) => __awaiter(void 0, void 0, void 0, function* () {
157
- try {
158
- yield fs_1.default.promises.mkdir(location, {
145
+ const saveWithGzip = (props) => __awaiter(this, void 0, void 0, function* () {
146
+ if (props.overwrite !== true && fs_1.default.existsSync(props.root))
147
+ yield fs_1.default.promises.rm(props.root, {
159
148
  recursive: true,
160
149
  });
150
+ const directory = new tstl_1.VariadicSingleton((location) => __awaiter(this, void 0, void 0, function* () {
151
+ try {
152
+ yield fs_1.default.promises.mkdir(location, {
153
+ recursive: true,
154
+ });
155
+ }
156
+ catch (_a) { }
157
+ }));
158
+ for (const [key, value] of Object.entries(props.files)) {
159
+ const file = path_1.default.resolve(`${props.root}/${key}.gz`);
160
+ yield directory.get(path_1.default.dirname(file));
161
+ if (value !== null)
162
+ yield fs_1.default.promises.writeFile(file, yield filesystem_1.CompressUtil.gzip(value !== null && value !== void 0 ? value : ""));
163
+ else
164
+ try {
165
+ yield fs_1.default.promises.unlink(file);
166
+ }
167
+ catch (_a) { }
161
168
  }
162
- catch (_a) { }
163
- }));
164
- for (const [key, value] of Object.entries(props.files)) {
165
- const file = path_1.default.resolve(`${props.root}/${key}.gz`);
166
- yield directory.get(path_1.default.dirname(file));
167
- yield fs_1.default.promises.writeFile(file, yield filesystem_1.CompressUtil.gzip(value !== null && value !== void 0 ? value : ""));
168
- }
169
- });
169
+ });
170
+ })(AutoBeExampleStorage || (exports.AutoBeExampleStorage = AutoBeExampleStorage = {}));
170
171
  //# sourceMappingURL=AutoBeExampleStorage.js.map