@autobe/agent 0.5.1 → 0.6.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/lib/AutoBeAgent.js +25 -6
- package/lib/AutoBeAgent.js.map +1 -1
- package/lib/constants/AutoBeSystemPromptConstant.d.ts +3 -3
- package/lib/context/AutoBeContext.d.ts +2 -2
- package/lib/context/IAutoBeApplicationProps.d.ts +6 -0
- package/lib/factory/createAgenticaHistory.js +1 -0
- package/lib/factory/createAgenticaHistory.js.map +1 -1
- package/lib/factory/createAutoBeApplication.js +16 -16
- package/lib/factory/createAutoBeApplication.js.map +1 -1
- package/lib/index.mjs +4608 -4644
- package/lib/index.mjs.map +1 -1
- package/lib/{analyze → orchestrate/analyze}/AutoBeAnalyzeAgent.d.ts +4 -8
- package/lib/{analyze → orchestrate/analyze}/AutoBeAnalyzeAgent.js +10 -2
- package/lib/orchestrate/analyze/AutoBeAnalyzeAgent.js.map +1 -0
- package/lib/orchestrate/analyze/AutoBeAnalyzeFileSystem.js.map +1 -0
- package/lib/orchestrate/analyze/AutoBeAnalyzePointer.d.ts +9 -0
- package/lib/orchestrate/analyze/AutoBeAnalyzePointer.js +3 -0
- package/lib/orchestrate/analyze/AutoBeAnalyzePointer.js.map +1 -0
- package/lib/{analyze → orchestrate/analyze}/AutoBeAnalyzeReviewer.d.ts +1 -1
- package/lib/{analyze → orchestrate/analyze}/AutoBeAnalyzeReviewer.js +5 -0
- package/lib/orchestrate/analyze/AutoBeAnalyzeReviewer.js.map +1 -0
- package/lib/orchestrate/{orchestrateAnalyze.d.ts → analyze/orchestrateAnalyze.d.ts} +2 -2
- package/lib/orchestrate/{orchestrateAnalyze.js → analyze/orchestrateAnalyze.js} +101 -38
- package/lib/orchestrate/analyze/orchestrateAnalyze.js.map +1 -0
- package/lib/orchestrate/facade/transformFacadeStateMessage.js +1 -1
- package/lib/orchestrate/facade/transformFacadeStateMessage.js.map +1 -1
- package/lib/orchestrate/index.d.ts +3 -3
- package/lib/orchestrate/index.js +6 -6
- package/lib/orchestrate/index.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceComplement.js +5 -0
- package/lib/orchestrate/interface/orchestrateInterfaceComplement.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceComponents.js +3 -0
- package/lib/orchestrate/interface/orchestrateInterfaceComponents.js.map +1 -1
- package/lib/orchestrate/interface/transformInterfaceHistories.js +15 -0
- package/lib/orchestrate/interface/transformInterfaceHistories.js.map +1 -1
- package/lib/orchestrate/prisma/orchestratePrismaCorrect.js +764 -915
- package/lib/orchestrate/prisma/orchestratePrismaCorrect.js.map +1 -1
- package/lib/orchestrate/prisma/transformPrismaComponentsHistories.js +7 -0
- package/lib/orchestrate/prisma/transformPrismaComponentsHistories.js.map +1 -1
- package/lib/orchestrate/prisma/transformPrismaCorrectHistories.js +10 -1
- package/lib/orchestrate/prisma/transformPrismaCorrectHistories.js.map +1 -1
- package/lib/orchestrate/prisma/transformPrismaHistories.js +9 -0
- package/lib/orchestrate/prisma/transformPrismaHistories.js.map +1 -1
- package/lib/orchestrate/prisma/transformPrismaSchemaHistories.js +8 -1
- package/lib/orchestrate/prisma/transformPrismaSchemaHistories.js.map +1 -1
- package/lib/structures/IAutoBeVendor.d.ts +45 -2
- package/package.json +6 -6
- package/src/AutoBeAgent.ts +32 -3
- package/src/constants/AutoBeSystemPromptConstant.ts +3 -3
- package/src/context/AutoBeContext.ts +2 -2
- package/src/context/IAutoBeApplicationProps.ts +6 -0
- package/src/factory/createAgenticaHistory.ts +1 -0
- package/src/factory/createAutoBeApplication.ts +1 -1
- package/src/{analyze → orchestrate/analyze}/AutoBeAnalyzeAgent.ts +20 -15
- package/src/orchestrate/analyze/AutoBeAnalyzePointer.ts +10 -0
- package/src/{analyze → orchestrate/analyze}/AutoBeAnalyzeReviewer.ts +7 -2
- package/src/orchestrate/{orchestrateAnalyze.ts → analyze/orchestrateAnalyze.ts} +43 -24
- package/src/orchestrate/index.ts +3 -3
- package/src/orchestrate/interface/orchestrateInterfaceComplement.ts +5 -0
- package/src/orchestrate/interface/orchestrateInterfaceComponents.ts +3 -0
- package/src/orchestrate/interface/transformInterfaceHistories.ts +15 -0
- package/src/orchestrate/prisma/orchestratePrismaCorrect.ts +112 -79
- package/src/orchestrate/prisma/transformPrismaComponentsHistories.ts +7 -0
- package/src/orchestrate/prisma/transformPrismaCorrectHistories.ts +9 -0
- package/src/orchestrate/prisma/transformPrismaHistories.ts +9 -0
- package/src/orchestrate/prisma/transformPrismaSchemaHistories.ts +7 -0
- package/src/structures/IAutoBeVendor.ts +48 -2
- package/lib/analyze/AnalyzeAgent.d.ts +0 -24
- package/lib/analyze/AnalyzeAgent.js +0 -942
- package/lib/analyze/AnalyzeAgent.js.map +0 -1
- package/lib/analyze/AutoBeAnalyzeAgent.js.map +0 -1
- package/lib/analyze/AutoBeAnalyzeFileSystem.js.map +0 -1
- package/lib/analyze/AutoBeAnalyzeReviewer.js.map +0 -1
- package/lib/orchestrate/orchestrateAnalyze.js.map +0 -1
- package/src/analyze/AnalyzeAgent.ts +0 -183
- /package/lib/{analyze → orchestrate/analyze}/AutoBeAnalyzeFileSystem.d.ts +0 -0
- /package/lib/{analyze → orchestrate/analyze}/AutoBeAnalyzeFileSystem.js +0 -0
- /package/src/{analyze → orchestrate/analyze}/AutoBeAnalyzeFileSystem.ts +0 -0
|
@@ -4,20 +4,17 @@ import {
|
|
|
4
4
|
AutoBeAssistantMessageHistory,
|
|
5
5
|
} from "@autobe/interface";
|
|
6
6
|
import { ILlmApplication, ILlmSchema } from "@samchon/openapi";
|
|
7
|
-
import { IPointer } from "tstl";
|
|
8
7
|
import typia from "typia";
|
|
9
8
|
import { v4 } from "uuid";
|
|
10
9
|
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
|
|
19
|
-
type Filename = string;
|
|
20
|
-
type FileContent = string;
|
|
10
|
+
import { AutoBeSystemPromptConstant } from "../../constants/AutoBeSystemPromptConstant";
|
|
11
|
+
import { AutoBeContext } from "../../context/AutoBeContext";
|
|
12
|
+
import { IAutoBeApplicationProps } from "../../context/IAutoBeApplicationProps";
|
|
13
|
+
import { assertSchemaModel } from "../../context/assertSchemaModel";
|
|
14
|
+
import { AutoBeAnalyzeAgent } from "./AutoBeAnalyzeAgent";
|
|
15
|
+
import { IFile } from "./AutoBeAnalyzeFileSystem";
|
|
16
|
+
import { AutoBeAnalyzePointer } from "./AutoBeAnalyzePointer";
|
|
17
|
+
import { AutoBeAnalyzeReviewer } from "./AutoBeAnalyzeReviewer";
|
|
21
18
|
|
|
22
19
|
/** @todo Kakasoo */
|
|
23
20
|
export const orchestrateAnalyze =
|
|
@@ -98,14 +95,16 @@ export const orchestrateAnalyze =
|
|
|
98
95
|
}
|
|
99
96
|
|
|
100
97
|
const described = determined.find((el) => el.type === "describe");
|
|
101
|
-
const
|
|
98
|
+
const describedFiles = Array.from(
|
|
102
99
|
new Set(
|
|
103
100
|
described
|
|
104
101
|
? described.executes
|
|
105
102
|
.flatMap((el) => {
|
|
106
103
|
if (el.protocol === "class") {
|
|
107
104
|
return (
|
|
108
|
-
el.arguments as {
|
|
105
|
+
el.arguments as {
|
|
106
|
+
files: Array<Pick<IFile, "filename" | "reason">>;
|
|
107
|
+
}
|
|
109
108
|
).files;
|
|
110
109
|
}
|
|
111
110
|
return null;
|
|
@@ -115,33 +114,49 @@ export const orchestrateAnalyze =
|
|
|
115
114
|
),
|
|
116
115
|
);
|
|
117
116
|
|
|
117
|
+
if (describedFiles.length === 0) {
|
|
118
|
+
const history: AutoBeAssistantMessageHistory = {
|
|
119
|
+
id: v4(),
|
|
120
|
+
type: "assistantMessage",
|
|
121
|
+
text: "The current requirements are insufficient, so file generation will be suspended. It would be better to continue the conversation.",
|
|
122
|
+
created_at,
|
|
123
|
+
completed_at: new Date().toISOString(),
|
|
124
|
+
};
|
|
125
|
+
ctx.dispatch({
|
|
126
|
+
type: "assistantMessage",
|
|
127
|
+
text: "The current requirements are insufficient, so file generation will be suspended. It would be better to continue the conversation.",
|
|
128
|
+
created_at,
|
|
129
|
+
});
|
|
130
|
+
return history;
|
|
131
|
+
}
|
|
132
|
+
|
|
118
133
|
const pointers = await Promise.all(
|
|
119
|
-
|
|
120
|
-
const pointer:
|
|
121
|
-
files: Record<Filename, FileContent>;
|
|
122
|
-
} | null> = {
|
|
123
|
-
value: null,
|
|
124
|
-
};
|
|
134
|
+
describedFiles.map(async ({ filename, reason }) => {
|
|
135
|
+
const pointer: AutoBeAnalyzePointer = { value: null };
|
|
125
136
|
|
|
126
137
|
const agent = new AutoBeAnalyzeAgent(
|
|
127
138
|
AutoBeAnalyzeReviewer,
|
|
128
139
|
ctx,
|
|
129
140
|
pointer,
|
|
130
|
-
|
|
141
|
+
describedFiles.map((el) => el.filename),
|
|
131
142
|
);
|
|
132
143
|
|
|
133
144
|
await agent.conversate(
|
|
134
145
|
[
|
|
135
|
-
|
|
146
|
+
`# Instruction`,
|
|
147
|
+
`The names of all the files are as follows: ${describedFiles.join(",")}`,
|
|
136
148
|
"Assume that all files are in the same folder. Also, when pointing to the location of a file, go to the relative path.",
|
|
137
149
|
"",
|
|
138
150
|
`Among the various documents, the part you decided to take care of is as follows.: ${filename}`,
|
|
139
151
|
`Only write this document named '${filename}'.`,
|
|
140
152
|
"Never write other documents.",
|
|
141
153
|
"",
|
|
154
|
+
"# User Planning Requirements",
|
|
142
155
|
"```md",
|
|
143
156
|
JSON.stringify(userPlanningRequirements),
|
|
144
157
|
"```",
|
|
158
|
+
"The reason why this document needs to be written is as follows.",
|
|
159
|
+
`- reason: ${reason}`,
|
|
145
160
|
].join("\n"),
|
|
146
161
|
);
|
|
147
162
|
|
|
@@ -193,16 +208,20 @@ export const orchestrateAnalyze =
|
|
|
193
208
|
|
|
194
209
|
class DeterminingFiles {
|
|
195
210
|
/**
|
|
196
|
-
* Determining the Initial File List
|
|
211
|
+
* Determining the Initial File List.
|
|
197
212
|
*
|
|
198
213
|
* Design a list of initial documents that you need to create for that
|
|
199
214
|
* requirement. The list of documents is determined only by the name of the
|
|
200
|
-
* file.
|
|
215
|
+
* file. If you determine from the conversation that the user's requirements
|
|
216
|
+
* have not been fully gathered, you must stop the analysis and continue
|
|
217
|
+
* collecting the remaining requirements. In this case, you do not need to
|
|
218
|
+
* generate any files. Simply pass an empty array to `input.files`, which is
|
|
219
|
+
* the input value for the `determine` tool.
|
|
201
220
|
*
|
|
202
221
|
* @param input
|
|
203
222
|
* @returns
|
|
204
223
|
*/
|
|
205
|
-
determine(input: { files: Array<Pick<IFile, "filename">> }) {
|
|
224
|
+
determine(input: { files: Array<Pick<IFile, "filename" | "reason">> }) {
|
|
206
225
|
return input;
|
|
207
226
|
}
|
|
208
227
|
}
|
package/src/orchestrate/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { orchestrateAnalyze as analyze } from "./orchestrateAnalyze";
|
|
1
|
+
export { orchestrateAnalyze as analyze } from "./analyze/orchestrateAnalyze";
|
|
2
2
|
export { orchestrateInterface as interface } from "./interface/orchestrateInterface";
|
|
3
|
-
export { orchestratePrisma as prisma } from "./prisma/orchestratePrisma";
|
|
4
|
-
export { orchestrateTest as test } from "./orchestrateTest";
|
|
5
3
|
export { orchestrateRealize as realize } from "./orchestrateRealize";
|
|
4
|
+
export { orchestrateTest as test } from "./orchestrateTest";
|
|
5
|
+
export { orchestratePrisma as prisma } from "./prisma/orchestratePrisma";
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
import { OpenApiV3_1Emender } from "@samchon/openapi/lib/converters/OpenApiV3_1Emender";
|
|
9
9
|
import { IPointer } from "tstl";
|
|
10
10
|
import typia from "typia";
|
|
11
|
+
import { v4 } from "uuid";
|
|
11
12
|
|
|
12
13
|
import { AutoBeSystemPromptConstant } from "../../constants/AutoBeSystemPromptConstant";
|
|
13
14
|
import { AutoBeContext } from "../../context/AutoBeContext";
|
|
@@ -51,6 +52,8 @@ async function step<Model extends ILlmSchema.Model>(
|
|
|
51
52
|
AutoBeSystemPromptConstant.INTERFACE_COMPLEMENT,
|
|
52
53
|
),
|
|
53
54
|
{
|
|
55
|
+
id: v4(),
|
|
56
|
+
created_at: new Date().toISOString(),
|
|
54
57
|
type: "assistantMessage",
|
|
55
58
|
text: [
|
|
56
59
|
"Here is the OpenAPI document what you've made:",
|
|
@@ -61,6 +64,8 @@ async function step<Model extends ILlmSchema.Model>(
|
|
|
61
64
|
].join("\n"),
|
|
62
65
|
},
|
|
63
66
|
{
|
|
67
|
+
id: v4(),
|
|
68
|
+
created_at: new Date().toISOString(),
|
|
64
69
|
type: "assistantMessage",
|
|
65
70
|
text: [
|
|
66
71
|
"You have missed below schema types in the document.components.schemas:",
|
|
@@ -4,6 +4,7 @@ import { ILlmApplication, ILlmSchema } from "@samchon/openapi";
|
|
|
4
4
|
import { OpenApiV3_1Emender } from "@samchon/openapi/lib/converters/OpenApiV3_1Emender";
|
|
5
5
|
import { IPointer } from "tstl";
|
|
6
6
|
import typia from "typia";
|
|
7
|
+
import { v4 } from "uuid";
|
|
7
8
|
|
|
8
9
|
import { AutoBeSystemPromptConstant } from "../../constants/AutoBeSystemPromptConstant";
|
|
9
10
|
import { AutoBeContext } from "../../context/AutoBeContext";
|
|
@@ -113,6 +114,8 @@ async function process<Model extends ILlmSchema.Model>(
|
|
|
113
114
|
AutoBeSystemPromptConstant.INTERFACE_SCHEMA,
|
|
114
115
|
),
|
|
115
116
|
{
|
|
117
|
+
id: v4(),
|
|
118
|
+
created_at: new Date().toISOString(),
|
|
116
119
|
type: "assistantMessage",
|
|
117
120
|
text: [
|
|
118
121
|
"Here is the OpenAPI operations generated by phase 2.",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IAgenticaHistoryJson } from "@agentica/core";
|
|
2
|
+
import { v4 } from "uuid";
|
|
2
3
|
|
|
3
4
|
import { AutoBeState } from "../../context/AutoBeState";
|
|
4
5
|
|
|
@@ -11,6 +12,8 @@ export const transformInterfaceHistories = (
|
|
|
11
12
|
if (state.analyze === null)
|
|
12
13
|
return [
|
|
13
14
|
{
|
|
15
|
+
id: v4(),
|
|
16
|
+
created_at: new Date().toISOString(),
|
|
14
17
|
type: "systemMessage",
|
|
15
18
|
text: [
|
|
16
19
|
"Requirement analysis is not yet completed.",
|
|
@@ -22,6 +25,8 @@ export const transformInterfaceHistories = (
|
|
|
22
25
|
else if (state.prisma === null)
|
|
23
26
|
return [
|
|
24
27
|
{
|
|
28
|
+
id: v4(),
|
|
29
|
+
created_at: new Date().toISOString(),
|
|
25
30
|
type: "systemMessage",
|
|
26
31
|
text: [
|
|
27
32
|
"Prisma DB schema generation is not yet completed.",
|
|
@@ -33,6 +38,8 @@ export const transformInterfaceHistories = (
|
|
|
33
38
|
else if (state.analyze.step !== state.prisma.step)
|
|
34
39
|
return [
|
|
35
40
|
{
|
|
41
|
+
id: v4(),
|
|
42
|
+
created_at: new Date().toISOString(),
|
|
36
43
|
type: "systemMessage",
|
|
37
44
|
text: [
|
|
38
45
|
"Prisma DB schema generation has not been updated",
|
|
@@ -45,6 +52,8 @@ export const transformInterfaceHistories = (
|
|
|
45
52
|
else if (state.prisma.compiled.type !== "success")
|
|
46
53
|
return [
|
|
47
54
|
{
|
|
55
|
+
id: v4(),
|
|
56
|
+
created_at: new Date().toISOString(),
|
|
48
57
|
type: "systemMessage",
|
|
49
58
|
text: [
|
|
50
59
|
"Prisma DB schema generation has not been updated",
|
|
@@ -56,10 +65,14 @@ export const transformInterfaceHistories = (
|
|
|
56
65
|
];
|
|
57
66
|
return [
|
|
58
67
|
{
|
|
68
|
+
id: v4(),
|
|
69
|
+
created_at: new Date().toISOString(),
|
|
59
70
|
type: "systemMessage",
|
|
60
71
|
text: systemMessage,
|
|
61
72
|
},
|
|
62
73
|
{
|
|
74
|
+
id: v4(),
|
|
75
|
+
created_at: new Date().toISOString(),
|
|
63
76
|
type: "assistantMessage",
|
|
64
77
|
text: [
|
|
65
78
|
"Requirement analysis and Prisma DB schema generation are ready.",
|
|
@@ -81,6 +94,8 @@ export const transformInterfaceHistories = (
|
|
|
81
94
|
].join("\n"),
|
|
82
95
|
},
|
|
83
96
|
{
|
|
97
|
+
id: v4(),
|
|
98
|
+
created_at: new Date().toISOString(),
|
|
84
99
|
type: "assistantMessage",
|
|
85
100
|
text: [
|
|
86
101
|
"Database schema and entity relationship diagrams are ready.",
|
|
@@ -13,6 +13,14 @@ export function orchestratePrismaCorrect<Model extends ILlmSchema.Model>(
|
|
|
13
13
|
application: AutoBePrisma.IApplication,
|
|
14
14
|
retry: number = 8,
|
|
15
15
|
): Promise<IAutoBePrismaValidation> {
|
|
16
|
+
const unique: Set<string> = new Set();
|
|
17
|
+
for (const file of application.files)
|
|
18
|
+
file.models = file.models.filter((model) => {
|
|
19
|
+
if (unique.has(model.name)) return false;
|
|
20
|
+
unique.add(model.name);
|
|
21
|
+
return true;
|
|
22
|
+
});
|
|
23
|
+
application.files = application.files.filter((f) => f.models.length !== 0);
|
|
16
24
|
return step(ctx, application, retry);
|
|
17
25
|
}
|
|
18
26
|
|
|
@@ -76,12 +84,20 @@ async function step<Model extends ILlmSchema.Model>(
|
|
|
76
84
|
return result; // unreachable
|
|
77
85
|
}
|
|
78
86
|
|
|
87
|
+
const correction: AutoBePrisma.IApplication = {
|
|
88
|
+
files: application.files.map((file) => ({
|
|
89
|
+
filename: file.filename,
|
|
90
|
+
namespace: file.namespace,
|
|
91
|
+
models: file.models.map((model) => {
|
|
92
|
+
const newbie = pointer.value!.models.find((m) => m.name === model.name);
|
|
93
|
+
return newbie ?? model;
|
|
94
|
+
}),
|
|
95
|
+
})),
|
|
96
|
+
};
|
|
79
97
|
ctx.dispatch({
|
|
80
98
|
type: "prismaCorrect",
|
|
81
99
|
failure: result,
|
|
82
|
-
correction
|
|
83
|
-
files: pointer.value.files,
|
|
84
|
-
},
|
|
100
|
+
correction,
|
|
85
101
|
planning: pointer.value.planning,
|
|
86
102
|
step: ctx.state().analyze?.step ?? 0,
|
|
87
103
|
created_at: new Date().toISOString(),
|
|
@@ -89,7 +105,7 @@ async function step<Model extends ILlmSchema.Model>(
|
|
|
89
105
|
return step(
|
|
90
106
|
ctx,
|
|
91
107
|
{
|
|
92
|
-
files:
|
|
108
|
+
files: correction.files,
|
|
93
109
|
},
|
|
94
110
|
life - 1,
|
|
95
111
|
);
|
|
@@ -135,124 +151,141 @@ const collection = {
|
|
|
135
151
|
|
|
136
152
|
interface IApplication {
|
|
137
153
|
/**
|
|
138
|
-
* Fixes validation errors in AutoBePrisma
|
|
139
|
-
*
|
|
154
|
+
* Fixes validation errors in specific AutoBePrisma models while preserving
|
|
155
|
+
* ALL existing business logic and model descriptions.
|
|
140
156
|
*
|
|
141
157
|
* ## Core Rules
|
|
142
158
|
*
|
|
143
|
-
* 1. Fix ONLY validation errors - never remove business
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
159
|
+
* 1. Fix ONLY validation errors in provided models - never remove business
|
|
160
|
+
* descriptions
|
|
161
|
+
* 2. Apply minimal changes to error models only - preserve original design
|
|
162
|
+
* intent
|
|
163
|
+
* 3. Return ONLY corrected models - unchanged models remain in original schema
|
|
164
|
+
* 4. Maintain referential integrity with unchanged models
|
|
147
165
|
*
|
|
148
|
-
* ##
|
|
166
|
+
* ## Targeted Scope
|
|
149
167
|
*
|
|
150
|
-
* -
|
|
151
|
-
* -
|
|
152
|
-
* -
|
|
153
|
-
* -
|
|
168
|
+
* - Process ONLY models with validation errors from IError[] array
|
|
169
|
+
* - Exclude models without errors from processing and output
|
|
170
|
+
* - Minimize context usage by returning corrected models only
|
|
171
|
+
* - Preserve unchanged models in their original state
|
|
154
172
|
*
|
|
155
173
|
* ## Fix Strategy
|
|
156
174
|
*
|
|
157
|
-
* - Resolve
|
|
158
|
-
* -
|
|
159
|
-
* -
|
|
160
|
-
* - Ensure naming conventions and index rules compliance
|
|
175
|
+
* - Resolve validation errors within specific models only
|
|
176
|
+
* - Fix field duplications, invalid references, and type mismatches
|
|
177
|
+
* - Update cross-model references without modifying target models
|
|
178
|
+
* - Ensure naming conventions and index rules compliance in corrected models
|
|
161
179
|
*/
|
|
162
180
|
correctPrismaSchemaFiles(props: IModifyPrismaSchemaFilesProps): void;
|
|
163
181
|
}
|
|
164
182
|
|
|
165
183
|
interface IModifyPrismaSchemaFilesProps {
|
|
166
184
|
/**
|
|
167
|
-
* Detailed execution plan for fixing AutoBePrisma validation errors
|
|
185
|
+
* Detailed execution plan for fixing `AutoBePrisma` validation errors in
|
|
186
|
+
* specific models.
|
|
168
187
|
*
|
|
169
188
|
* 🎯 Purpose: Enable systematic reasoning and step-by-step error resolution
|
|
170
|
-
* approach for
|
|
189
|
+
* approach for targeted model validation issues
|
|
171
190
|
*
|
|
172
191
|
* 📋 Required Planning Content:
|
|
173
192
|
*
|
|
174
|
-
* 1. **Error Analysis
|
|
193
|
+
* 1. **Error Scope Analysis**
|
|
175
194
|
*
|
|
176
195
|
* - List all validation errors from IAutoBePrismaValidation.IError[] array
|
|
177
|
-
* -
|
|
178
|
-
* -
|
|
179
|
-
*
|
|
196
|
+
* - Extract unique table names from errors to identify affected models
|
|
197
|
+
* - Categorize errors by type (field duplications, references, types, indexes)
|
|
198
|
+
* - Identify which models need correction vs. which remain unchanged
|
|
199
|
+
* 2. **Targeted Fix Strategy**
|
|
180
200
|
*
|
|
181
|
-
* -
|
|
182
|
-
* - Outline minimal changes needed for each
|
|
183
|
-
* -
|
|
184
|
-
*
|
|
201
|
+
* - Focus ONLY on models mentioned in validation errors
|
|
202
|
+
* - Outline minimal changes needed for each affected model
|
|
203
|
+
* - Plan cross-model reference updates (if any) without modifying non-error
|
|
204
|
+
* models
|
|
205
|
+
* - Ensure unchanged models maintain valid references to corrected models
|
|
206
|
+
* 3. **Model-Specific Fix Plan**
|
|
185
207
|
*
|
|
186
|
-
* - Model-by-model modification plan
|
|
187
|
-
* - Exact field additions,
|
|
188
|
-
* - Reference updates
|
|
189
|
-
* - Index corrections to
|
|
190
|
-
* 4. **
|
|
208
|
+
* - Model-by-model modification plan for ONLY affected models
|
|
209
|
+
* - Exact field additions, renames, or type corrections required
|
|
210
|
+
* - Reference updates within corrected models only
|
|
211
|
+
* - Index corrections limited to affected models
|
|
212
|
+
* 4. **Minimal Scope Validation**
|
|
191
213
|
*
|
|
192
|
-
* - Confirm which
|
|
193
|
-
* - List
|
|
194
|
-
* - Identify cross-model dependencies
|
|
195
|
-
*
|
|
214
|
+
* - Confirm which models will be included in output (error models only)
|
|
215
|
+
* - List models that will remain unchanged in original schema
|
|
216
|
+
* - Identify cross-model dependencies without including unchanged models
|
|
217
|
+
* - Preserve all business logic within corrected models
|
|
218
|
+
* 5. **Targeted Impact Assessment**
|
|
196
219
|
*
|
|
197
|
-
* - Potential
|
|
198
|
-
* -
|
|
199
|
-
* - Ensure no new validation errors
|
|
220
|
+
* - Potential effects of fixes on unchanged models (reference validation)
|
|
221
|
+
* - Verification points for corrected models only
|
|
222
|
+
* - Ensure no new validation errors in targeted models
|
|
223
|
+
* - Confirm minimal output scope compliance
|
|
200
224
|
*
|
|
201
225
|
* 💡 Example Planning Structure:
|
|
202
226
|
*
|
|
203
|
-
* ## Error
|
|
204
|
-
* -
|
|
205
|
-
* -
|
|
227
|
+
* ## Error Scope
|
|
228
|
+
* - Target Models: shopping_customers, shopping_orders (2 models only)
|
|
229
|
+
* - Unchanged Models: All others remain in original schema
|
|
206
230
|
*
|
|
207
|
-
* ##
|
|
208
|
-
*
|
|
209
|
-
*
|
|
231
|
+
* ## Targeted Fixes
|
|
232
|
+
* - shopping_customers: Remove duplicate 'email' field
|
|
233
|
+
* - shopping_orders: Update targetModel reference to 'shopping_customers'
|
|
210
234
|
*
|
|
211
|
-
* ##
|
|
212
|
-
*
|
|
213
|
-
*
|
|
235
|
+
* ## Output Scope
|
|
236
|
+
* - Return: Only shopping_customers and shopping_orders models
|
|
237
|
+
* - Preserve: All other models unchanged in original schema
|
|
214
238
|
*
|
|
215
|
-
* ##
|
|
216
|
-
* -
|
|
217
|
-
* -
|
|
218
|
-
* - Preserve all indexes and constraints
|
|
239
|
+
* ## Cross-Model Impact
|
|
240
|
+
* - Verify: shopping_orders still references shopping_customers correctly
|
|
241
|
+
* - No changes needed in other models referencing these
|
|
219
242
|
*/
|
|
220
243
|
planning: string;
|
|
221
244
|
|
|
222
245
|
/**
|
|
223
|
-
*
|
|
224
|
-
*
|
|
246
|
+
* ONLY the specific models that contain validation errors and need
|
|
247
|
+
* correction.
|
|
225
248
|
*
|
|
226
249
|
* 📥 Input Structure:
|
|
227
250
|
*
|
|
228
|
-
* -
|
|
229
|
-
* - Each
|
|
230
|
-
* -
|
|
231
|
-
*
|
|
251
|
+
* - Contains ONLY models mentioned in IAutoBePrismaValidation.IError[] array
|
|
252
|
+
* - Each model has specific validation errors that need targeted correction
|
|
253
|
+
* - Models not mentioned in errors are excluded from this input
|
|
254
|
+
* - Represents minimal scope for error correction
|
|
255
|
+
*
|
|
256
|
+
* 🔍 Expected Validation Issues (Model-Specific):
|
|
257
|
+
*
|
|
258
|
+
* - Duplicate field/relation names within these specific models
|
|
259
|
+
* - Invalid foreign key references from these models to other models
|
|
260
|
+
* - Single foreign key fields in index arrays within these models
|
|
261
|
+
* - Invalid naming conventions within these specific models
|
|
262
|
+
* - Type validation errors in fields of these models
|
|
232
263
|
*
|
|
233
|
-
*
|
|
264
|
+
* 📝 Model Content Analysis (Targeted Scope):
|
|
234
265
|
*
|
|
235
|
-
* -
|
|
236
|
-
* -
|
|
237
|
-
* -
|
|
238
|
-
* -
|
|
239
|
-
* -
|
|
266
|
+
* - Complete field definitions for each error model only
|
|
267
|
+
* - Relationships from these models (may reference unchanged models)
|
|
268
|
+
* - Indexes within these models that need correction
|
|
269
|
+
* - Business descriptions specific to these models
|
|
270
|
+
* - Cross-model references that need validation (read-only for targets)
|
|
240
271
|
*
|
|
241
|
-
*
|
|
272
|
+
* ⚠️ Processing Notes (Focused Approach):
|
|
242
273
|
*
|
|
243
|
-
* -
|
|
244
|
-
* -
|
|
245
|
-
* -
|
|
246
|
-
*
|
|
247
|
-
* -
|
|
274
|
+
* - Input contains ONLY models with validation errors
|
|
275
|
+
* - May reference other models not included in this input
|
|
276
|
+
* - Cross-model references must be validated but target models won't be
|
|
277
|
+
* modified
|
|
278
|
+
* - Output should return corrected versions of ONLY these input models
|
|
279
|
+
* - All business logic and descriptions within these models must be preserved
|
|
280
|
+
* - Corrections must not break references from unchanged models
|
|
248
281
|
*
|
|
249
|
-
*
|
|
282
|
+
* 🎯 Correction Scope:
|
|
250
283
|
*
|
|
251
|
-
* -
|
|
252
|
-
* -
|
|
253
|
-
* -
|
|
254
|
-
* -
|
|
255
|
-
* -
|
|
284
|
+
* - Fix validation errors within these specific models
|
|
285
|
+
* - Update internal model structure (fields, relations, indexes)
|
|
286
|
+
* - Correct references to external models (without modifying targets)
|
|
287
|
+
* - Maintain compatibility with unchanged models in the full schema
|
|
288
|
+
* - Return corrected versions of ONLY these models
|
|
256
289
|
*/
|
|
257
|
-
|
|
290
|
+
models: AutoBePrisma.IModel[];
|
|
258
291
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IAgenticaHistoryJson } from "@agentica/core";
|
|
2
|
+
import { v4 } from "uuid";
|
|
2
3
|
|
|
3
4
|
import { AutoBeSystemPromptConstant } from "../../constants/AutoBeSystemPromptConstant";
|
|
4
5
|
import { AutoBeState } from "../../context/AutoBeState";
|
|
@@ -11,6 +12,8 @@ export const transformPrismaComponentsHistories = (
|
|
|
11
12
|
if (state.analyze === null)
|
|
12
13
|
return [
|
|
13
14
|
{
|
|
15
|
+
id: v4(),
|
|
16
|
+
created_at: new Date().toISOString(),
|
|
14
17
|
type: "systemMessage",
|
|
15
18
|
text: [
|
|
16
19
|
"Requirement analysis is not yet completed.",
|
|
@@ -21,10 +24,14 @@ export const transformPrismaComponentsHistories = (
|
|
|
21
24
|
];
|
|
22
25
|
return [
|
|
23
26
|
{
|
|
27
|
+
id: v4(),
|
|
28
|
+
created_at: new Date().toISOString(),
|
|
24
29
|
type: "systemMessage",
|
|
25
30
|
text: AutoBeSystemPromptConstant.PRISMA_COMPONENT,
|
|
26
31
|
},
|
|
27
32
|
{
|
|
33
|
+
id: v4(),
|
|
34
|
+
created_at: new Date().toISOString(),
|
|
28
35
|
type: "assistantMessage",
|
|
29
36
|
text: [
|
|
30
37
|
"Here is the requirement analysis report.",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { IAgenticaHistoryJson } from "@agentica/core";
|
|
2
2
|
import { IAutoBePrismaValidation } from "@autobe/interface";
|
|
3
|
+
import { v4 } from "uuid";
|
|
3
4
|
|
|
4
5
|
import { AutoBeSystemPromptConstant } from "../../constants/AutoBeSystemPromptConstant";
|
|
5
6
|
|
|
@@ -10,10 +11,14 @@ export const transformPrismaCorrectHistories = (
|
|
|
10
11
|
> => {
|
|
11
12
|
return [
|
|
12
13
|
{
|
|
14
|
+
id: v4(),
|
|
15
|
+
created_at: new Date().toISOString(),
|
|
13
16
|
type: "systemMessage",
|
|
14
17
|
text: AutoBeSystemPromptConstant.PRISMA_CORRECT,
|
|
15
18
|
},
|
|
16
19
|
{
|
|
20
|
+
id: v4(),
|
|
21
|
+
created_at: new Date().toISOString(),
|
|
17
22
|
type: "assistantMessage",
|
|
18
23
|
text: [
|
|
19
24
|
"Here is the Prisma application data what you made:",
|
|
@@ -24,6 +29,8 @@ export const transformPrismaCorrectHistories = (
|
|
|
24
29
|
].join("\n"),
|
|
25
30
|
},
|
|
26
31
|
{
|
|
32
|
+
id: v4(),
|
|
33
|
+
created_at: new Date().toISOString(),
|
|
27
34
|
type: "assistantMessage",
|
|
28
35
|
text: [
|
|
29
36
|
"Below are the list of errors what you have to fix:",
|
|
@@ -34,6 +41,8 @@ export const transformPrismaCorrectHistories = (
|
|
|
34
41
|
].join("\n"),
|
|
35
42
|
},
|
|
36
43
|
{
|
|
44
|
+
id: v4(),
|
|
45
|
+
created_at: new Date().toISOString(),
|
|
37
46
|
type: "systemMessage",
|
|
38
47
|
text: [
|
|
39
48
|
"Before fixing the schema files,",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IAgenticaHistoryJson } from "@agentica/core";
|
|
2
|
+
import { v4 } from "uuid";
|
|
2
3
|
|
|
3
4
|
import { AutoBeSystemPromptConstant } from "../../constants/AutoBeSystemPromptConstant";
|
|
4
5
|
import { AutoBeState } from "../../context/AutoBeState";
|
|
@@ -11,6 +12,8 @@ export const transformPrismaHistories = (
|
|
|
11
12
|
if (state.analyze === null)
|
|
12
13
|
return [
|
|
13
14
|
{
|
|
15
|
+
id: v4(),
|
|
16
|
+
created_at: new Date().toISOString(),
|
|
14
17
|
type: "systemMessage",
|
|
15
18
|
text: [
|
|
16
19
|
"Requirement analysis is not yet completed.",
|
|
@@ -21,14 +24,20 @@ export const transformPrismaHistories = (
|
|
|
21
24
|
];
|
|
22
25
|
return [
|
|
23
26
|
{
|
|
27
|
+
id: v4(),
|
|
28
|
+
created_at: new Date().toISOString(),
|
|
24
29
|
type: "systemMessage",
|
|
25
30
|
text: AutoBeSystemPromptConstant.PRISMA,
|
|
26
31
|
},
|
|
27
32
|
{
|
|
33
|
+
id: v4(),
|
|
34
|
+
created_at: new Date().toISOString(),
|
|
28
35
|
type: "assistantMessage",
|
|
29
36
|
text: AutoBeSystemPromptConstant.PRISMA_EXAMPLE,
|
|
30
37
|
},
|
|
31
38
|
{
|
|
39
|
+
id: v4(),
|
|
40
|
+
created_at: new Date().toISOString(),
|
|
32
41
|
type: "assistantMessage",
|
|
33
42
|
text: [
|
|
34
43
|
"Here is the requirement analysis report.",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { IAgenticaHistoryJson } from "@agentica/core";
|
|
2
2
|
import { AutoBeAnalyzeHistory } from "@autobe/interface";
|
|
3
|
+
import { v4 } from "uuid";
|
|
3
4
|
|
|
4
5
|
import { AutoBeSystemPromptConstant } from "../../constants/AutoBeSystemPromptConstant";
|
|
5
6
|
|
|
@@ -15,10 +16,14 @@ export const transformPrismaSchemaHistories = (
|
|
|
15
16
|
> => {
|
|
16
17
|
return [
|
|
17
18
|
{
|
|
19
|
+
id: v4(),
|
|
20
|
+
created_at: new Date().toISOString(),
|
|
18
21
|
type: "systemMessage",
|
|
19
22
|
text: AutoBeSystemPromptConstant.PRISMA_SCHEMA,
|
|
20
23
|
},
|
|
21
24
|
{
|
|
25
|
+
id: v4(),
|
|
26
|
+
created_at: new Date().toISOString(),
|
|
22
27
|
type: "systemMessage",
|
|
23
28
|
text: [
|
|
24
29
|
"Before making prisma schema files,",
|
|
@@ -29,6 +34,8 @@ export const transformPrismaSchemaHistories = (
|
|
|
29
34
|
].join("\n"),
|
|
30
35
|
},
|
|
31
36
|
{
|
|
37
|
+
id: v4(),
|
|
38
|
+
created_at: new Date().toISOString(),
|
|
32
39
|
type: "assistantMessage",
|
|
33
40
|
text: [
|
|
34
41
|
"Here is the requirement analysis report.",
|