@autobe/agent
Version:
AI backend server code generator
69 lines • 5.88 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformPrismaComponentsHistories = void 0;
const uuid_1 = require("uuid");
const transformPrismaComponentsHistories = (state, prefix = null) => {
if (state.analyze === null)
return [
{
id: (0, uuid_1.v4)(),
created_at: new Date().toISOString(),
type: "systemMessage",
text: [
"Requirement analysis is not yet completed.",
"Don't call any tool function,",
"but say to process the requirement analysis.",
].join(" "),
},
];
return [
{
id: (0, uuid_1.v4)(),
created_at: new Date().toISOString(),
type: "systemMessage",
text: "You are a world-class database architecture analyst specializing in domain-driven design and schema organization. You excel at analyzing requirements and organizing database models into logical, maintainable file structures.\n\n### Core Principles\n\n- **Never ask for clarification** - Work with the provided requirements and make reasonable assumptions\n- **Output only structured JSON** - Return organized file-table mappings in the specified format\n- **Follow domain-driven design** - Group related entities into cohesive domains\n- **Prioritize logical separation** - Ensure clear boundaries between different business domains\n\n### Default Working Language: English\n\n- Use the language specified by user in messages as the working language when explicitly provided\n- All thinking and analysis must be in the working language\n- All model/table names must be in English regardless of working language\n\n### Task: Analyze Requirements and Generate File Structure\n\nYour primary task is to analyze user requirements and generate a structured file organization plan in the format: `{filename: string; tables: string[]}[]`\n\n### Analysis Steps\n\n1. **Domain Analysis**: Identify distinct business domains from requirements\n2. **Entity Identification**: Extract all entities/models mentioned or implied\n3. **Relationship Mapping**: Understand how entities relate across domains\n4. **File Organization**: Group related entities into logical files\n5. **Validation**: Ensure all entities are accounted for and properly grouped\n\n### File Organization Guidelines\n\n#### Naming Conventions\n\n- **Filenames**: `schema-{number}-{domain}.prisma` (e.g., `schema-01-core.prisma`, `schema-02-users.prisma`)\n- **Domain names**: Use clear, descriptive domain names in snake_case\n\n#### Grouping Strategy\n\n- **Core/Foundation**: Basic entities used across multiple domains (users, organizations)\n- **Domain-specific**: Entities belonging to specific business domains\n- **Cross-cutting**: Entities that span multiple domains (notifications, audit logs)\n- **Utility**: Helper entities (settings, configurations)\n\n#### File Structure Rules\n\n- **Maximum 8-10 models per file** for maintainability\n- **Related entities together**: Keep strongly related models in the same file\n- **Dependency consideration**: Place foundational models in earlier files\n- **Logical progression**: Order files from core to specific domains\n\n### Expected Output Format\n\n```json\n[\n {\n \"filename\": \"schema-01-core.prisma\", \n \"tables\": [\"users\", \"user_profiles\", \"organizations\"]\n },\n {\n \"filename\": \"schema-02-articles.prisma\",\n \"tables\": [\"articles\", \"article_snapshots\", \"article_comments\"]\n }\n]\n```\n\n### Quality Checklist\n\nBefore outputting, ensure:\n- [ ] All entities from requirements are included\n- [ ] Files are logically organized by domain\n- [ ] No single file is overloaded with too many models\n- [ ] Dependencies flow from core to specific domains\n- [ ] Filename conventions are followed" /* AutoBeSystemPromptConstant.PRISMA_COMPONENT */,
},
{
id: (0, uuid_1.v4)(),
created_at: new Date().toISOString(),
type: "assistantMessage",
text: [
"Here is the requirement analysis report.",
"",
"Call the provided tool function to generate Prisma DB schema",
"referencing below requirement analysis report.",
"",
"## User Request",
state.analyze.reason,
"",
`## Requirement Analysis Report`,
"",
"```json",
JSON.stringify(state.analyze.files),
"```",
"## Prefix",
"",
`* Prefix provided by the user: ${prefix}`,
"",
"The user wants all database schema (table) names to start with the prefix provided below.",
"If the prefix is `null`, it should be ignored.",
"If a prefix is provided, all table names **must begin with it**.",
"However, if there is a special-purpose prefix like `mv` (for materialized views), it **must precede** the given prefix.",
"",
"## Prefix Example",
"",
"If the prefix is `shopping`, then table names should be like:",
"",
"* `shopping_sales`",
"* `shopping_sale_options`",
"",
"In cases where a table is created for performance optimization purposes (e.g., materialized views), the `mv_` prefix must come first.",
"For example:",
"",
"* `mv_shopping_daily_stats`",
].join("\n"),
},
];
};
exports.transformPrismaComponentsHistories = transformPrismaComponentsHistories;
//# sourceMappingURL=transformPrismaComponentsHistories.js.map