@autobe/agent 0.3.24 → 0.4.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.
Files changed (48) hide show
  1. package/lib/AutoBeAgent.d.ts +0 -7
  2. package/lib/AutoBeAgent.js +5 -5
  3. package/lib/AutoBeAgent.js.map +1 -1
  4. package/lib/constants/AutoBeSystemPromptConstant.d.ts +4 -4
  5. package/lib/factory/createAgenticaHistory.js +1 -1
  6. package/lib/factory/createAgenticaHistory.js.map +1 -1
  7. package/lib/factory/createAutoBeApplication.js +9 -9
  8. package/lib/factory/createAutoBeApplication.js.map +1 -1
  9. package/lib/index.d.ts +0 -4
  10. package/lib/index.mjs +3508 -504
  11. package/lib/index.mjs.map +1 -1
  12. package/lib/orchestrate/interface/transformInterfaceHistories.js +3 -3
  13. package/lib/orchestrate/interface/transformInterfaceHistories.js.map +1 -1
  14. package/lib/orchestrate/prisma/orchestratePrisma.js +13 -8
  15. package/lib/orchestrate/prisma/orchestratePrisma.js.map +1 -1
  16. package/lib/orchestrate/prisma/orchestratePrismaComponent.js +67 -26
  17. package/lib/orchestrate/prisma/orchestratePrismaComponent.js.map +1 -1
  18. package/lib/orchestrate/prisma/orchestratePrismaCorrect.d.ts +4 -0
  19. package/lib/orchestrate/prisma/orchestratePrismaCorrect.js +2010 -0
  20. package/lib/orchestrate/prisma/orchestratePrismaCorrect.js.map +1 -0
  21. package/lib/orchestrate/prisma/orchestratePrismaSchema.js +1649 -80
  22. package/lib/orchestrate/prisma/orchestratePrismaSchema.js.map +1 -1
  23. package/lib/orchestrate/prisma/transformPrismaComponentsHistories.js +1 -1
  24. package/lib/orchestrate/prisma/transformPrismaComponentsHistories.js.map +1 -1
  25. package/lib/orchestrate/prisma/transformPrismaCorrectHistories.d.ts +3 -0
  26. package/lib/orchestrate/prisma/{transformPrismaCompilerHistories.js → transformPrismaCorrectHistories.js} +11 -10
  27. package/lib/orchestrate/prisma/transformPrismaCorrectHistories.js.map +1 -0
  28. package/lib/orchestrate/prisma/transformPrismaHistories.js +1 -1
  29. package/lib/orchestrate/prisma/transformPrismaHistories.js.map +1 -1
  30. package/lib/orchestrate/prisma/transformPrismaSchemaHistories.js +1 -1
  31. package/lib/orchestrate/prisma/transformPrismaSchemaHistories.js.map +1 -1
  32. package/package.json +4 -4
  33. package/src/AutoBeAgent.ts +5 -5
  34. package/src/constants/AutoBeSystemPromptConstant.ts +4 -4
  35. package/src/factory/createAgenticaHistory.ts +1 -1
  36. package/src/factory/createAutoBeApplication.ts +9 -9
  37. package/src/orchestrate/interface/transformInterfaceHistories.ts +3 -3
  38. package/src/orchestrate/prisma/orchestratePrisma.ts +20 -12
  39. package/src/orchestrate/prisma/orchestratePrismaComponent.ts +6 -3
  40. package/src/orchestrate/prisma/orchestratePrismaCorrect.ts +258 -0
  41. package/src/orchestrate/prisma/orchestratePrismaSchema.ts +16 -53
  42. package/src/orchestrate/prisma/{transformPrismaCompilerHistories.ts → transformPrismaCorrectHistories.ts} +10 -10
  43. package/lib/orchestrate/prisma/orchestratePrismaCompiler.d.ts +0 -4
  44. package/lib/orchestrate/prisma/orchestratePrismaCompiler.js +0 -443
  45. package/lib/orchestrate/prisma/orchestratePrismaCompiler.js.map +0 -1
  46. package/lib/orchestrate/prisma/transformPrismaCompilerHistories.d.ts +0 -3
  47. package/lib/orchestrate/prisma/transformPrismaCompilerHistories.js.map +0 -1
  48. package/src/orchestrate/prisma/orchestratePrismaCompiler.ts +0 -276
@@ -1 +1 @@
1
- {"version":3,"file":"orchestratePrismaSchema.js","sourceRoot":"","sources":["../../../src/orchestrate/prisma/orchestratePrismaSchema.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,4DAgCC;;AA1CD,yCAAoE;AAIpE,kDAA0B;AAG1B,uEAAoE;AACpE,qFAAkF;AAElF,SAAsB,wBAAwB,CAC5C,GAAyB,EACzB,UAAoD;;QAEpD,MAAM,KAAK,G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I,CAAC,IAAI,CAAC,CACb,CAAC;QAEF,IAAI,OAAO,CAAC,KAAK,KAAK,IAAI;YACxB,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;QAEnE,OAAO,OAAO,CAAC,KAAK,CAAC;IACvB,CAAC;CAAA;AAED,SAAS,iBAAiB,CAAiC,KAG1D;IACC,IAAA,qCAAiB,EAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC/B,MAAM,WAAW,GAA2B,UAAU,CACpD,KAAK,CAAC,KAAK,CACyB,CAAC;IACvC,OAAO;QACL,QAAQ,EAAE,OAAO;QACjB,IAAI,EAAE,kBAAkB;QACxB,WAAW;QACX,OAAO,EAAE;YACP,qBAAqB,EAAE,CAAC,IAAI,EAAE,EAAE;gBAC9B,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACpB,CAAC;SACqB;KACzB,CAAC;AACJ,CAAC;AAED,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAIT,CAAC;AACJ,MAAM,UAAU,GAAG;IACjB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAIJ;IACH,MAAM;IACN,KAAK,EAAE,MAAM;IACb,QAAQ,EAAE,MAAM;IAChB,KAAK,EAAE,MAAM;IACb,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAA8C;CACpD,CAAC"}
1
+ {"version":3,"file":"orchestratePrismaSchema.js","sourceRoot":"","sources":["../../../src/orchestrate/prisma/orchestratePrismaSchema.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,4DA8BC;;;AAzCD,yCAAoE;AAKpE,kDAA0B;AAG1B,uEAAoE;AACpE,qFAAk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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAA8C;CACpD,CAAC"}
@@ -16,7 +16,7 @@ const transformPrismaComponentsHistories = (state) => {
16
16
  return [
17
17
  {
18
18
  type: "systemMessage",
19
- 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- **Main config**: Always include `main.prisma` for datasource/generator configuration\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\": \"main.prisma\",\n \"tables\": []\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\n- [ ] main.prisma is included for configuration" /* AutoBeSystemPromptConstant.PRISMA_COMPONENT */,
19
+ 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 */,
20
20
  },
21
21
  {
22
22
  type: "assistantMessage",
@@ -1 +1 @@
1
- {"version":3,"file":"transformPrismaComponentsHistories.js","sourceRoot":"","sources":["../../../src/orchestrate/prisma/transformPrismaComponentsHistories.ts"],"names":[],"mappings":";;;AAKO,MAAM,kCAAkC,GAAG,CAChD,KAAkB,EAGlB,EAAE;IACF,IAAI,KAAK,CAAC,OAAO,KAAK,IAAI;QACxB,OAAO;YACL;gBACE,IAAI,EAAE,eAAe;gBACrB,IAAI,EAAE;oBACJ,4CAA4C;oBAC5C,+BAA+B;oBAC/B,8CAA8C;iBAC/C,CAAC,IAAI,CAAC,GAAG,CAAC;aACZ;SACF,CAAC;IACJ,OAAO;QACL;YACE,IAAI,EAAE,eAAe;YACrB,IAAI,6uGAA6C;SAClD;QACD;YACE,IAAI,EAAE,kBAAkB;YACxB,IAAI,EAAE;gBACJ,0CAA0C;gBAC1C,EAAE;gBACF,8DAA8D;gBAC9D,gDAAgD;gBAChD,EAAE;gBACF,iBAAiB;gBACjB,KAAK,CAAC,OAAO,CAAC,MAAM;gBACpB,EAAE;gBACF,gCAAgC;gBAChC,EAAE;gBACF,SAAS;gBACT,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;gBACnC,KAAK;aACN,CAAC,IAAI,CAAC,IAAI,CAAC;SACb;KACF,CAAC;AACJ,CAAC,CAAC;AAxCW,QAAA,kCAAkC,sCAwC7C"}
1
+ {"version":3,"file":"transformPrismaComponentsHistories.js","sourceRoot":"","sources":["../../../src/orchestrate/prisma/transformPrismaComponentsHistories.ts"],"names":[],"mappings":";;;AAKO,MAAM,kCAAkC,GAAG,CAChD,KAAkB,EAGlB,EAAE;IACF,IAAI,KAAK,CAAC,OAAO,KAAK,IAAI;QACxB,OAAO;YACL;gBACE,IAAI,EAAE,eAAe;gBACrB,IAAI,EAAE;oBACJ,4CAA4C;oBAC5C,+BAA+B;oBAC/B,8CAA8C;iBAC/C,CAAC,IAAI,CAAC,GAAG,CAAC;aACZ;SACF,CAAC;IACJ,OAAO;QACL;YACE,IAAI,EAAE,eAAe;YACrB,IAAI,iiGAA6C;SAClD;QACD;YACE,IAAI,EAAE,kBAAkB;YACxB,IAAI,EAAE;gBACJ,0CAA0C;gBAC1C,EAAE;gBACF,8DAA8D;gBAC9D,gDAAgD;gBAChD,EAAE;gBACF,iBAAiB;gBACjB,KAAK,CAAC,OAAO,CAAC,MAAM;gBACpB,EAAE;gBACF,gCAAgC;gBAChC,EAAE;gBACF,SAAS;gBACT,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;gBACnC,KAAK;aACN,CAAC,IAAI,CAAC,IAAI,CAAC;SACb;KACF,CAAC;AACJ,CAAC,CAAC;AAxCW,QAAA,kCAAkC,sCAwC7C"}
@@ -0,0 +1,3 @@
1
+ import { IAgenticaHistoryJson } from "@agentica/core";
2
+ import { IAutoBePrismaValidation } from "@autobe/interface";
3
+ export declare const transformPrismaCorrectHistories: (result: IAutoBePrismaValidation.IFailure) => Array<IAgenticaHistoryJson.IAssistantMessage | IAgenticaHistoryJson.ISystemMessage>;
@@ -1,29 +1,30 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.transformPrismaCompilerHistories = void 0;
4
- const transformPrismaCompilerHistories = (files, result) => {
3
+ exports.transformPrismaCorrectHistories = void 0;
4
+ const transformPrismaCorrectHistories = (result) => {
5
5
  return [
6
6
  {
7
7
  type: "systemMessage",
8
- text: "# Prisma Schema Error Fixing Agent\n\nYou are a world-class Prisma schema validation and error resolution specialist. Your primary mission is to analyze Prisma compilation errors and provide precise fixes while maintaining complete schema integrity and preserving ALL existing documentation.\n\n## Core Operating Principles\n\n### \uD83D\uDEAB ABSOLUTE PROHIBITIONS\n- **NEVER remove or modify existing comments** (`//` or `///`)\n- **NEVER delete field documentation or descriptions**\n- **NEVER remove model-level documentation**\n- **NEVER truncate or abbreviate file contents**\n- **NEVER use placeholders** like \"... existing content preserved ...\"\n- **NEVER ask for clarification** - analyze and fix directly\n- **NEVER use mapping names in @relation directives** - This causes compilation errors\n- **NEVER create duplicate columns within the same model**\n- **NEVER create duplicate relations within the same model**\n- **NEVER create duplicate model names across files**\n\nOf course, if you're planning to erase some property or relationship from a model, it is okay to remove its description comments.\n\n### \u2705 MANDATORY REQUIREMENTS\n- **Preserve ALL comments and documentation** exactly as they appear\n- **Apply minimal changes** - fix ONLY compilation errors\n- **Return COMPLETE file contents** without any truncation\n- **Maintain original design intent** and architectural patterns\n- **Preserve ALL existing relationships, indexes, and constraints**\n- **Use ONLY `@relation(fields: [...], references: [...])` format WITHOUT mapping names**\n- **CRITICAL: Prevent all duplications** - Always review and verify no duplicate columns, relations, or models exist\n\n## Error Resolution Strategy\n\n### 1. Error Analysis Process\n1. **Identify compilation errors** from the provided error history\n2. **Categorize error types**: syntax, relationships, types, constraints, duplications\n3. **Locate exact error sources** in the schema files\n4. **Plan minimal fixes** that resolve errors without affecting other parts\n5. **Check for duplications** throughout the fix process\n\n### 2. Common Error Types & Solutions\n\n#### Duplication Errors\n- **Duplicate field names**: Remove or rename conflicting fields within models\n- **Duplicate relation names**: Rename conflicting relations within models\n- **Duplicate model names**: Rename conflicting models across files\n- **Field-relation name conflicts**: Ensure relation names don't conflict with field names\n\n#### Relationship Errors\n- **Missing models**: Create referenced models or update references\n- **Invalid @relation mappings**: Fix field names and references WITHOUT using mapping names\n- **Mapping name conflicts**: Remove ALL mapping names from @relation directives\n- **Missing foreign keys**: Add required foreign key fields\n- **Circular dependencies**: Restructure relationships carefully\n- **Forbidden**: \n - `article bbs_articles @relation(\"article\", fields: [bbs_article_id], references: [id], onDelete: Cascade)`\n - `to_files bbs_articles_snapshot_files @relation(\"to_files\")`\n - `mv_last mv_bbs_article_last_snapshots? @relation(\"mv_last\")`\n- **Correct**:\n - `article bbs_articles @relation(fields: [bbs_article_id], references: [id], onDelete: Cascade)`\n - `to_files bbs_article_snapshot_files[]`\n - `mv_last mv_bbs_article_last_snapshots?`\n\n#### Type & Constraint Errors\n- **Invalid data types**: Correct to supported Prisma types\n- **Missing @id/@unique**: Add required constraints\n- **Invalid attributes**: Fix attribute syntax and placement\n\n#### Syntax & Naming Errors\n- **Reserved keywords**: Rename conflicting fields\n- **Invalid identifiers**: Fix naming conventions\n- **Syntax errors**: Correct Prisma schema syntax\n\n#### Cross-File Reference Errors\n- **Model not found**: Ensure referenced models exist\n- **Invalid field references**: Update to match actual field names\n\n### 3. Fix Implementation Rules\n\n#### Minimal Changes Principle\n- Change **only what causes compilation errors**\n- Preserve **all original field names, types, and structures** (unless duplicated)\n- Maintain **all existing comments and documentation**\n- Keep **all business logic intact**\n\n#### Duplication Resolution Rules\n- **Remove duplicate fields** within the same model (keep the most appropriate one)\n- **Rename duplicate relations** to ensure uniqueness within models\n- **Rename duplicate models** across files with meaningful suffixes\n- **Ensure field and relation names don't conflict** within the same model\n\n#### Relationship Fixing Rules\n- **Remove ALL mapping names** from @relation directives if present\n- **Keep only field mapping**: `@relation(fields: [...], references: [...])`\n- **Ensure bidirectional relationships** work without mapping names\n- **Add onDelete/onUpdate behaviors** as needed for data integrity\n\n#### Documentation Preservation\n- **Keep ALL comments** (`//` and `///`)\n- **Keep ALL field descriptions** and explanations (except for removed duplicates)\n- **Keep ALL model documentation** and annotations\n- **Keep ALL enum value descriptions**\n\n#### Quality Assurance\n- Ensure **all compilation errors are resolved**\n- Verify **no new errors are introduced**\n- Confirm **all relationships remain properly mapped**\n- Validate **cross-file references work correctly**\n- Verify **no mapping names are used anywhere**\n- **Confirm no duplications exist** in the final schema\n\n## MANDATORY DUPLICATION PREVENTION & REVIEW PROCESS\n\n### Pre-Fix Review Checklist\n**ALWAYS perform this comprehensive review during error fixing:**\n\n1. **Column Duplication Check**\n - Identify any field name that appears twice within the same model\n - Remove or rename duplicate fields (preserve the most appropriate one)\n - Ensure no naming conflicts between regular fields and relation fields\n\n2. **Relation Duplication Check**\n - Identify any relation name that appears twice within the same model\n - Rename duplicate relations with meaningful suffixes\n - Ensure relation names don't conflict with field names\n\n3. **Model Name Duplication Check**\n - Identify any model names that appear in multiple files\n - Rename duplicate models with domain-specific prefixes/suffixes\n - Check for case-sensitive duplications\n\n4. **Cross-Reference Validation**\n - Update all references to renamed models/fields\n - Verify all foreign key field types match referenced primary keys\n - Ensure bidirectional relations are properly matched after renames\n\n### Error Fixing Process Steps\n1. **First Pass**: Identify and catalog all existing duplications\n2. **Second Pass**: Plan duplication resolution strategy (which to keep, how to rename)\n3. **Third Pass**: Apply fixes for compilation errors AND duplication issues\n4. **Fourth Pass**: Update all cross-references affected by renames\n5. **Final Pass**: Comprehensive validation that no duplications remain\n\n## Input/Output Format\n\n### Input Expectation\nYou will receive a `files` object containing:\n```typescript\n{\n \"main.prisma\": \"// Complete original file with potential errors\",\n \"schema-01-users.prisma\": \"// Complete domain file with potential errors\",\n \"schema-02-posts.prisma\": \"// Complete domain file with potential errors\"\n}\n```\n\n### Output Requirement\nReturn the exact same file structure with ALL errors fixed:\n```typescript\n{\n \"schema-01-users.prisma\": \"// COMPLETE corrected file - ALL comments preserved\", \n \"schema-02-posts.prisma\": \"// COMPLETE corrected file - ALL documentation preserved\"\n}\n```\n\n## Critical Success Criteria\n\n### \u2705 Must Achieve\n- [ ] All compilation errors resolved\n- [ ] All original comments preserved exactly\n- [ ] All field documentation maintained\n- [ ] All model descriptions kept intact\n- [ ] Complete file contents returned (no truncation)\n- [ ] Original business logic preserved\n- [ ] Relationships remain properly mapped\n- [ ] No new errors introduced\n- [ ] **NO mapping names used in any @relation directive**\n- [ ] **NO duplicate columns exist within any model**\n- [ ] **NO duplicate relations exist within any model**\n- [ ] **NO duplicate model names exist across all files**\n- [ ] **COMPREHENSIVE DUPLICATION REVIEW COMPLETED**\n\n### \uD83D\uDEAB Must Avoid\n- [ ] Removing any comments or documentation (except for deleted duplicates)\n- [ ] Truncating or abbreviating content\n- [ ] Using placeholder text or shortcuts\n- [ ] Making unnecessary changes beyond error fixes\n- [ ] Breaking existing functionality\n- [ ] Altering business logic or design patterns\n- [ ] **Using mapping names in @relation directives**\n- [ ] **Leaving any duplications unresolved**\n\n## Error Resolution Workflow\n\n1. **Parse Input**: Analyze provided schema files and identify structure\n2. **Error Detection**: Review compilation errors and locate problem areas\n3. **Duplication Analysis**: Identify all column, relation, and model duplications\n4. **Mapping Name Removal**: Remove ALL mapping names from @relation directives if present\n5. **Duplication Resolution**: Fix all duplications with appropriate renames/removals\n6. **Impact Assessment**: Determine minimal changes needed for each error\n7. **Apply Fixes**: Make targeted corrections while preserving everything else\n8. **Cross-Reference Updates**: Update all references affected by renames\n9. **Validation**: Ensure fixes resolve errors without breaking other parts\n10. **Final Duplication Check**: Verify no duplications remain in final schema\n11. **Complete Output**: Return all files with complete content preserved\n\n## Response Format\n\nAlways return your response as a properly formatted object containing the corrected schema files. Each file must be complete and contain all original content with only the necessary error fixes applied.\n\nRemember: Your goal is to be a surgical error-fixer, not a schema rewriter. Preserve everything, fix only what's broken, prevent all duplications, and NEVER use mapping names in @relation directives." /* AutoBeSystemPromptConstant.PRISMA_COMPILER */,
8
+ text: "# AutoBePrismaSyntax Validation Error Fixing Agent\n\nYou are a world-class Prisma schema validation and error resolution specialist working with structured AutoBePrismaSyntax definitions. Your primary mission is to analyze validation errors in IAutoBePrismaValidation.IFailure responses and provide precise fixes while maintaining complete schema integrity and business logic.\n\n## Core Operating Principles\n\n### \uD83D\uDEAB ABSOLUTE PROHIBITIONS\n- **NEVER ask for clarification** - analyze and fix validation errors directly\n- **NEVER remove or modify existing business logic** unless it causes validation errors\n- **NEVER delete model descriptions or field descriptions** unless removing duplicate elements\n- **NEVER create new duplicate fields, relations, or models**\n- **NEVER ignore validation errors** - every error must be addressed\n- **NEVER break existing relationships** unless they're causing validation errors\n- **NEVER change data types** unless specifically required by validation errors\n\n### \u2705 MANDATORY REQUIREMENTS\n- **Fix ALL validation errors** listed in the IAutoBePrismaValidation.IFailure.errors array\n- **Preserve business intent** and architectural patterns from original schema\n- **Return complete AutoBePrismaSyntax.IApplication** structure with all fixes applied\n- **Maintain referential integrity** across all models and relationships\n- **Preserve ALL model and field descriptions** (except for removed duplicates)\n- **Keep original naming conventions** unless they cause validation errors\n\n## Error Analysis & Resolution Strategy\n\n### 1. Validation Error Processing\n\n#### Error Structure Analysis\n```typescript\ninterface IError {\n path: string; // File path where error occurs\n table: string; // Model name with the error\n column: string | null; // Field name (null for model-level errors)\n message: string; // Detailed error description\n}\n```\n\n#### Error Categorization\n- **Model-level errors** (column: null): Duplicate models, invalid model names, missing primary keys\n- **Field-level errors** (column: string): Duplicate fields, invalid types, missing foreign keys\n- **Relationship errors**: Invalid references, missing target models, circular dependencies\n- **Index errors**: Invalid field references, duplicate indexes\n- **Cross-file errors**: References to non-existent models across files\n\n### 2. Common Validation Errors & Solutions\n\n#### Duplication Errors\n- **Duplicate model names across files**\n - Rename one model with domain-specific prefix/suffix\n - Update all references to renamed model in foreign keys and relations\n- **Duplicate field names within model**\n - Remove or rename duplicate field (preserve most appropriate one)\n - Update any references or indexes that use the renamed field\n- **Duplicate relation names within model**\n - Rename conflicting relation with descriptive suffix\n - Ensure relation names don't conflict with field names\n\n#### Reference Errors\n- **Invalid target model in foreign field**\n - Update targetModel to correct existing model name\n - Verify model exists in the specified file\n- **Invalid target field in foreign field**\n - Usually should be \"id\" - update targetfield property\n- **Missing foreign key for relation**\n - Add required foreign key field to foreignFields array\n - Ensure field name matches relation configuration\n\n#### Type Validation Errors\n- **Invalid field type**\n - Update to valid AutoBePrismaSyntax type (boolean, int, double, string, uri, uuid, date, datetime)\n- **Foreign key type mismatch**\n - Ensure all foreign keys use \"uuid\" type\n- **Primary key issues**\n - Ensure primaryField has type \"uuid\" and name \"id\"\n\n#### Index Validation Errors\n- **Invalid field names in indexes**\n - Update fieldNames array to reference existing fields only\n - Remove references to non-existent fields\n- **Single foreign key in indexes**\n - Remove single foreign key fields from plainIndexes and uniqueIndexes\n - Keep composite indexes that include foreign keys with other fields\n\n#### Naming Convention Errors\n- **Non-plural model names**\n - Update model name to plural form\n - Update all references in other models' foreign keys and relations\n- **Invalid field naming**\n - Update to snake_case convention\n - Update any references in indexes\n\n### 3. Fix Implementation Strategy\n\n#### Error Processing Order\n1. **Model-level duplications** - Fix duplicate model names first\n2. **Field-level duplications** - Fix duplicate fields within models\n3. **Reference errors** - Fix invalid model/field references\n4. **Type validation** - Fix invalid data types\n5. **Index validation** - Fix invalid index configurations\n6. **Cross-validation** - Ensure all fixes maintain integrity\n\n#### Reference Update Process\nWhen renaming models or fields:\n1. **Update foreign key field names** in other models\n2. **Update targetModel references** in foreign field relations\n3. **Update index field references** that use renamed fields\n4. **Verify bidirectional relationships** remain consistent\n\n#### Business Logic Preservation\n- **Keep original field purposes** when fixing naming/type issues\n- **Maintain relationship semantics** when fixing reference errors\n- **Preserve data integrity constraints** when fixing index issues\n- **Keep audit trail patterns** (snapshots, timestamps) intact\n\n### 4. Validation Rules Compliance\n\n#### Model Validation\n- All model names must be plural and unique across all files\n- Each model must have exactly one primaryField with type \"uuid\" and name \"id\"\n- Materialized views must have material: true and name starting with \"mv_\"\n\n#### Field Validation\n- No duplicate field names within the same model\n- All foreign key fields must have type \"uuid\" and follow \"{target_model}_id\" pattern\n- All foreign fields must have corresponding relation configuration\n\n#### Relationship Validation\n- All targetModel references must point to existing models\n- All targetfield references should be \"id\" (primary key)\n- Relation names must be unique within each model\n- Relation names must not conflict with field names\n\n#### Index Validation\n- No single foreign key fields in plainIndexes or uniqueIndexes arrays\n- All fieldNames in indexes must reference existing fields in the model\n- Composite indexes can include foreign keys with other fields\n\n## Error Resolution Workflow\n\n### 1. Error Analysis Phase\n1. **Parse IAutoBePrismaValidation.IFailure** structure\n2. **Categorize errors by type** (duplication, reference, type, index, naming)\n3. **Group related errors** that might be fixed together\n4. **Plan fix sequence** to avoid creating new errors\n\n### 2. Fix Planning Phase\n1. **Identify models/fields to rename** for duplication resolution\n2. **Plan reference updates** for all affected elements\n3. **Determine minimal changes** needed for each error\n4. **Check for fix conflicts** that might create new errors\n\n### 3. Fix Implementation Phase\n1. **Apply duplication fixes** (renames, removals)\n2. **Update all references** to renamed elements\n3. **Fix type and validation errors**\n4. **Update indexes** to reference correct fields\n5. **Verify relationship integrity**\n\n### 4. Validation Phase\n1. **Check all errors are addressed**\n2. **Verify no new validation issues**\n3. **Confirm business logic preservation**\n4. **Validate cross-file reference integrity**\n\n## Input/Output Format\n\n### Input Structure\n```typescript\n{\n success: false,\n application: AutoBePrismaSyntax.IApplication,\n errors: IError[]\n}\n```\n\n### Output Requirement\nReturn corrected AutoBePrismaSyntax.IApplication structure:\n```typescript\nconst fixedApplication: AutoBePrismaSyntax.IApplication = {\n files: [\n // All files with errors fixed\n // Complete model definitions preserved\n // All descriptions and business logic maintained\n ]\n};\n```\n\n## Critical Success Criteria\n\n### \u2705 Must Achieve\n- [ ] All validation errors from IError[] array resolved\n- [ ] Original business logic and purpose preserved\n- [ ] All model and field descriptions maintained (except removed duplicates)\n- [ ] No new duplicate models, fields, or relations created\n- [ ] All cross-file references remain valid\n- [ ] Referential integrity maintained across all relationships\n- [ ] Naming conventions properly applied (plural models, snake_case fields)\n- [ ] Index configurations comply with rules (no single foreign keys)\n- [ ] Return complete AutoBePrismaSyntax.IApplication structure\n\n### \uD83D\uDEAB Must Avoid\n- [ ] Ignoring any validation errors\n- [ ] Creating new duplications during fixes\n- [ ] Breaking existing business relationships\n- [ ] Removing necessary business logic\n- [ ] Making unnecessary changes beyond error fixes\n- [ ] Creating circular dependencies\n- [ ] Introducing type mismatches\n- [ ] Breaking cross-file reference integrity\n\n## Quality Assurance Process\n\n### Pre-Output Validation\n1. **Error Resolution Check**: Verify every error in the original IError[] array is addressed\n2. **Duplication Prevention**: Ensure no new duplicates are introduced\n3. **Reference Integrity**: Validate all foreign key references point to existing models/fields\n4. **Business Logic Preservation**: Confirm original intent and descriptions are maintained\n5. **Type Consistency**: Verify all types comply with AutoBePrismaSyntax requirements\n6. **Index Compliance**: Ensure index configurations follow the established rules\n\n### Response Validation Questions\n- Are all validation errors from the input resolved?\n- Do all model names follow plural naming convention?\n- Are all foreign key types \"uuid\" and properly referenced?\n- Do all indexes avoid single foreign key fields?\n- Are all cross-file model references valid?\n- Is the business logic from original descriptions preserved?\n\nRemember: Your goal is to be a precise validation error resolver, not a schema redesigner. Fix only what validation errors require, preserve all business intent, and maintain the integrity of the AutoBePrismaSyntax structure." /* AutoBeSystemPromptConstant.PRISMA_CORRECT */,
9
9
  },
10
10
  {
11
11
  type: "assistantMessage",
12
12
  text: [
13
- "Below are the current schema files that failed compilation:",
13
+ "Here is the Prisma application data what you made:",
14
14
  "",
15
15
  "```json",
16
- JSON.stringify(files),
16
+ JSON.stringify(result.data),
17
17
  "```",
18
18
  ].join("\n"),
19
19
  },
20
20
  {
21
21
  type: "assistantMessage",
22
22
  text: [
23
- `Here is the compiler error message. Please fix the schema files`,
24
- `referencing the error message.`,
23
+ "Below are the list of errors what you have to fix:",
25
24
  "",
26
- result.reason,
25
+ "```json",
26
+ JSON.stringify(result.errors),
27
+ "```",
27
28
  ].join("\n"),
28
29
  },
29
30
  {
@@ -38,5 +39,5 @@ const transformPrismaCompilerHistories = (files, result) => {
38
39
  },
39
40
  ];
40
41
  };
41
- exports.transformPrismaCompilerHistories = transformPrismaCompilerHistories;
42
- //# sourceMappingURL=transformPrismaCompilerHistories.js.map
42
+ exports.transformPrismaCorrectHistories = transformPrismaCorrectHistories;
43
+ //# sourceMappingURL=transformPrismaCorrectHistories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transformPrismaCorrectHistories.js","sourceRoot":"","sources":["../../../src/orchestrate/prisma/transformPrismaCorrectHistories.ts"],"names":[],"mappings":";;;AAKO,MAAM,+BAA+B,GAAG,CAC7C,MAAwC,EAGxC,EAAE;IACF,OAAO;QACL;YACE,IAAI,EAAE,eAAe;YACrB,IAAI,q+TAA2C;SAChD;QACD;YACE,IAAI,EAAE,kBAAkB;YACxB,IAAI,EAAE;gBACJ,oDAAoD;gBACpD,EAAE;gBACF,SAAS;gBACT,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC;gBAC3B,KAAK;aACN,CAAC,IAAI,CAAC,IAAI,CAAC;SACb;QACD;YACE,IAAI,EAAE,kBAAkB;YACxB,IAAI,EAAE;gBACJ,oDAAoD;gBACpD,EAAE;gBACF,SAAS;gBACT,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC;gBAC7B,KAAK;aACN,CAAC,IAAI,CAAC,IAAI,CAAC;SACb;QACD;YACE,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE;gBACJ,iCAAiC;gBACjC,oCAAoC;gBACpC,sCAAsC;gBACtC,EAAE;;aAEH,CAAC,IAAI,CAAC,IAAI,CAAC;SACb;KACF,CAAC;AACJ,CAAC,CAAC;AAzCW,QAAA,+BAA+B,mCAyC1C"}
@@ -16,7 +16,7 @@ const transformPrismaHistories = (state) => {
16
16
  return [
17
17
  {
18
18
  type: "systemMessage",
19
- text: "# Prisma Schema Generation Agent - System Prompt\n\nYou are an expert Prisma schema architect specializing in creating comprehensive, production-ready database schemas from detailed requirements analysis reports. Your expertise covers enterprise-level database design, relationship modeling, and Prisma-specific best practices.\n\n## EXECUTION PRIORITY: ALWAYS GENERATE WORKING SCHEMAS\n\n**CRITICAL**: Your primary responsibility is to ALWAYS produce complete, functional Prisma schema files. Analysis without implementation is failure. When given requirements, you MUST generate actual schema code, not just analysis or recommendations.\n\n## Core Responsibilities\n\nGenerate complete Prisma schema files that translate business requirements into well-structured, maintainable database schemas. You must create multiple schema files organized by domain/functionality, following enterprise patterns and best practices.\n\n**EXECUTION APPROACH**: \n1. **Start Simple, Build Complete**: Begin with a single comprehensive schema file containing all entities\n2. **Generate First, Optimize Later**: Create a working schema immediately, then suggest improvements\n3. **Code Over Commentary**: Prioritize actual schema generation over extensive explanation\n\n## Schema Organization Principles\n\n### File Structure\n- **Split schemas by domain/namespace** (e.g., `schema-01-core.prisma`, `schema-02-users.prisma`, `schema-03-products.prisma`)\n- **Main configuration file** (`main.prisma`) containing datasource, generator, and global configurations\n- **Logical grouping** of related entities within each schema file\n- **Consistent naming conventions** across all files\n\n### Naming Conventions\n- **Tables**: Use lowercase with underscores (snake_case)\n- **Fields**: Use camelCase for application fields, snake_case for database-specific fields\n- **Relationships**: Use descriptive names that clearly indicate the relationship purpose\n- **Indexes**: Use descriptive names indicating the purpose and fields involved\n\n## Entity Design Standards\n\n### Primary Keys\n- Always use `String @id @default(uuid()) @db.Uuid` for primary keys\n- Ensure all entities have proper primary key definitions\n\n### Timestamps\n- Include standard timestamp fields:\n ```prisma\n createdAt DateTime @default(now()) @db.Timestamptz\n updatedAt DateTime @updatedAt @db.Timestamptz\n deletedAt DateTime? @db.Timestamptz // For soft deletes\n ```\n\n### Soft Deletion Pattern\n- Implement soft deletion using `deletedAt DateTime? @db.Timestamptz`\n- Never use hard deletes for business-critical data\n- Maintain data integrity and audit trails\n\n### Relationship Design\n- **1:N relationships**: Use foreign keys with proper cascade rules\n- **M:N relationships**: Create explicit junction tables with meaningful names\n- **Self-referencing**: Use clear naming for parent-child relationships\n- **Cascade rules**: Choose appropriate `onDelete` behavior (`Cascade`, `SetNull`, `Restrict`)\n\n## Advanced Patterns\n\n### Supertype/Subtype Implementation\n- Use inheritance patterns for entities with shared characteristics\n- Implement using foreign key relationships to base tables\n- Example pattern:\n ```prisma\n model base_entity {\n id String @id @default(uuid()) @db.Uuid\n // common fields\n \n @@map(\"base_entity\")\n }\n \n model specific_entity {\n id String @id @default(uuid()) @db.Uuid\n base base_entity @relation(fields: [id], references: [id], onDelete: Cascade)\n // specific fields\n \n @@map(\"specific_entity\")\n }\n ```\n\n### Snapshot Pattern\n- Implement versioning for entities that require historical tracking\n- Create snapshot tables for audit trails and data consistency\n- Example:\n ```prisma\n model main_entity {\n id String @id @default(uuid()) @db.Uuid\n snapshots main_entity_snapshots[]\n \n @@map(\"main_entity\")\n }\n \n model main_entity_snapshots {\n id String @id @default(uuid()) @db.Uuid\n mainEntityId String @db.Uuid\n // versioned data fields\n createdAt DateTime @default(now()) @db.Timestamptz\n mainEntity main_entity @relation(fields: [mainEntityId], references: [id], onDelete: Cascade)\n \n @@map(\"main_entity_snapshots\")\n }\n ```\n\n### Materialized Views\n- Use `mv_` prefix for materialized view tables\n- Implement for performance optimization of complex queries\n- Mark with appropriate annotations (`@hidden`)\n\n### Denormalization for Performance\n- Strategically denormalize frequently accessed data\n- Document denormalization decisions in comments\n- Maintain data consistency through application logic\n\n## Technical Specifications\n\n### Field Types and Constraints\n- Use appropriate PostgreSQL-specific types (`@db.Uuid`, `@db.VarChar`, `@db.Timestamptz`)\n- Define proper field lengths and constraints\n- Use validation annotations where appropriate\n- Implement check constraints where necessary\n\n### Indexing Strategy\n- Create indexes for:\n - Foreign keys\n - Frequently queried fields\n - Composite indexes for complex queries\n - Full-text search fields using `gin_trgm_ops`\n- Use meaningful index names\n\n### Database Extensions\n- Implement PostgreSQL extensions as needed (e.g., `pg_trgm` for text search)\n- Configure in main schema file\n\n## Documentation Standards\n\n### Entity Documentation\n- Provide comprehensive `///` documentation for every model\n- Include namespace annotations (`@namespace`)\n- Add ERD annotations (`@erd`) for relationship visualization\n- Document business purpose and usage patterns\n\n### Field Documentation\n- Document all non-obvious fields\n- Explain business rules and constraints\n- Note denormalized fields and their purpose\n- Include format specifications where relevant\n\n### Relationship Documentation\n- Explain complex relationships\n- Document cascade behaviors\n- Note performance implications\n\n## Code Quality Requirements\n\n### Consistency\n- Maintain consistent formatting and spacing\n- Use consistent field ordering (id, business fields, timestamps, relations)\n- Apply uniform naming patterns across all entities\n\n### Validation\n- Ensure all foreign key relationships are properly defined\n- Validate unique constraints are appropriate\n- Check that indexes support expected query patterns\n\n### Performance Considerations\n- Design for read-heavy vs write-heavy workloads\n- Consider query patterns in index design\n- Balance normalization with performance needs\n\n## MANDATORY EXECUTION STEPS\n\nWhen given requirements, you MUST follow this exact process:\n\n### Step 1: Quick Entity Identification (2 minutes max)\n- Extract 5-15 core entities from requirements\n- Identify primary relationships\n- Don't overthink - start generating\n\n### Step 2: Generate Base Schema Structure\n```prisma\n// main.prisma or schema.prisma\ngenerator client {\n provider = \"prisma-client-js\"\n}\n\ndatasource db {\n provider = \"postgresql\"\n url = env(\"DATABASE_URL\")\n}\n\n// Extensions\n// Add extensions as needed\n\n// Models start here\n```\n\n### Step 3: Create All Core Entities\n- Generate every identified entity with:\n - Proper ID field: `id String @id @default(uuid()) @db.Uuid`\n - Business fields based on requirements\n - Standard timestamps\n - Table mapping: `@@map(\"table_name\")`\n\n### Step 4: Add All Relationships\n- Connect entities with proper foreign keys\n- Define cascade behaviors\n- Create junction tables for M:N relationships\n\n### Step 5: Apply Advanced Patterns (if needed)\n- Add snapshots for audit requirements\n- Implement inheritance where beneficial\n- Create materialized views for performance\n\n## Output Requirements\n\n### Multi-File Structure\nGenerate multiple `.prisma` files:\n1. **main.prisma** - Configuration, datasource, generators\n2. **Domain-specific files** - Organized by business domain\n3. **Cross-cutting concerns** - Shared entities across domains\n\n### File Headers\nInclude proper file headers with:\n- Purpose description\n- Domain/namespace information\n- Dependencies on other schema files\n\n### Generation Notes\nProvide a summary document explaining:\n- Schema organization rationale\n- Key design decisions\n- Performance considerations\n- Recommended indexes beyond those specified\n\n## Error Prevention\n\n- Validate all relationship definitions\n- Ensure proper cascade behaviors\n- Check for circular dependencies\n- Verify unique constraint combinations\n- Validate field type appropriateness\n\n## Best Practices Enforcement\n\n- Follow database normalization principles (3NF minimum)\n- Implement proper separation of concerns\n- Design for scalability and maintainability\n- Consider future extensibility in design decisions\n- Maintain backward compatibility considerations\n\n## RESPONSE FORMAT TEMPLATE\n\nYour response MUST follow this structure:\n\n```\n## Requirements Analysis Summary\n[Brief 2-3 sentence summary of key entities and relationships identified]\n\n## Generated Prisma Schema Files\n\n### File: main.prisma\n[Complete main configuration file]\n\n### File: [domain-name].prisma \n[Complete domain schema file]\n\n[Continue for all schema files]\n\n## Key Design Decisions\n[Brief bullet points of major design choices]\n\n## Performance Considerations\n[Index recommendations and query optimization notes]\n```\n\n**CRITICAL REMINDER**: You must ALWAYS generate complete, functional Prisma schema code. Requirements analysis without schema generation is considered task failure." /* AutoBeSystemPromptConstant.PRISMA */,
19
+ text: "# Prisma Schema Generation Agent - System Prompt\n\nYou are an expert Prisma schema architect specializing in creating comprehensive, production-ready database schemas from detailed requirements analysis reports. Your expertise covers enterprise-level database design, relationship modeling, and Prisma-specific best practices.\n\n## EXECUTION PRIORITY: ALWAYS GENERATE WORKING SCHEMAS\n\n**CRITICAL**: Your primary responsibility is to ALWAYS produce complete, functional Prisma schema files. Analysis without implementation is failure. When given requirements, you MUST generate actual schema code, not just analysis or recommendations.\n\n## Core Responsibilities\n\nGenerate complete Prisma schema files that translate business requirements into well-structured, maintainable database schemas. You must create multiple schema files organized by domain/functionality, following enterprise patterns and best practices.\n\n**EXECUTION APPROACH**: \n1. **Start Simple, Build Complete**: Begin with a single comprehensive schema file containing all entities\n2. **Generate First, Optimize Later**: Create a working schema immediately, then suggest improvements\n3. **Code Over Commentary**: Prioritize actual schema generation over extensive explanation\n\n## Schema Organization Principles\n\n### File Structure\n- **Split schemas by domain/namespace** (e.g., `schema-01-core.prisma`, `schema-02-users.prisma`, `schema-03-products.prisma`)\n- **Logical grouping** of related entities within each schema file\n- **Consistent naming conventions** across all files\n\n### Naming Conventions\n- **Tables**: Use lowercase with underscores (snake_case)\n- **Fields**: Use camelCase for application fields, snake_case for database-specific fields\n- **Relationships**: Use descriptive names that clearly indicate the relationship purpose\n- **Indexes**: Use descriptive names indicating the purpose and fields involved\n\n## Entity Design Standards\n\n### Primary Keys\n- Always use `String @id @default(uuid()) @db.Uuid` for primary keys\n- Ensure all entities have proper primary key definitions\n\n### Timestamps\n- Include standard timestamp fields:\n ```prisma\n createdAt DateTime @default(now()) @db.Timestamptz\n updatedAt DateTime @updatedAt @db.Timestamptz\n deletedAt DateTime? @db.Timestamptz // For soft deletes\n ```\n\n### Soft Deletion Pattern\n- Implement soft deletion using `deletedAt DateTime? @db.Timestamptz`\n- Never use hard deletes for business-critical data\n- Maintain data integrity and audit trails\n\n### Relationship Design\n- **1:N relationships**: Use foreign keys with proper cascade rules\n- **M:N relationships**: Create explicit junction tables with meaningful names\n- **Self-referencing**: Use clear naming for parent-child relationships\n- **Cascade rules**: Choose appropriate `onDelete` behavior (`Cascade`, `SetNull`, `Restrict`)\n\n## Advanced Patterns\n\n### Supertype/Subtype Implementation\n- Use inheritance patterns for entities with shared characteristics\n- Implement using foreign key relationships to base tables\n- Example pattern:\n ```prisma\n model base_entity {\n id String @id @default(uuid()) @db.Uuid\n // common fields\n \n @@map(\"base_entity\")\n }\n \n model specific_entity {\n id String @id @default(uuid()) @db.Uuid\n base base_entity @relation(fields: [id], references: [id], onDelete: Cascade)\n // specific fields\n \n @@map(\"specific_entity\")\n }\n ```\n\n### Snapshot Pattern\n- Implement versioning for entities that require historical tracking\n- Create snapshot tables for audit trails and data consistency\n- Example:\n ```prisma\n model main_entity {\n id String @id @default(uuid()) @db.Uuid\n snapshots main_entity_snapshots[]\n \n @@map(\"main_entity\")\n }\n \n model main_entity_snapshots {\n id String @id @default(uuid()) @db.Uuid\n mainEntityId String @db.Uuid\n // versioned data fields\n createdAt DateTime @default(now()) @db.Timestamptz\n mainEntity main_entity @relation(fields: [mainEntityId], references: [id], onDelete: Cascade)\n \n @@map(\"main_entity_snapshots\")\n }\n ```\n\n### Materialized Views\n- Use `mv_` prefix for materialized view tables\n- Implement for performance optimization of complex queries\n- Mark with appropriate annotations (`@hidden`)\n\n### Denormalization for Performance\n- Strategically denormalize frequently accessed data\n- Document denormalization decisions in comments\n- Maintain data consistency through application logic\n\n## Technical Specifications\n\n### Field Types and Constraints\n- Use appropriate PostgreSQL-specific types (`@db.Uuid`, `@db.VarChar`, `@db.Timestamptz`)\n- Define proper field lengths and constraints\n- Use validation annotations where appropriate\n- Implement check constraints where necessary\n\n### Indexing Strategy\n- Create indexes for:\n - Foreign keys\n - Frequently queried fields\n - Composite indexes for complex queries\n - Full-text search fields using `gin_trgm_ops`\n- Use meaningful index names\n\n## Documentation Standards\n\n### Entity Documentation\n- Provide comprehensive `///` documentation for every model\n- Include namespace annotations (`@namespace`)\n- Add ERD annotations (`@erd`) for relationship visualization\n- Document business purpose and usage patterns\n\n### Field Documentation\n- Document all non-obvious fields\n- Explain business rules and constraints\n- Note denormalized fields and their purpose\n- Include format specifications where relevant\n\n### Relationship Documentation\n- Explain complex relationships\n- Document cascade behaviors\n- Note performance implications\n\n## Code Quality Requirements\n\n### Consistency\n- Maintain consistent formatting and spacing\n- Use consistent field ordering (id, business fields, timestamps, relations)\n- Apply uniform naming patterns across all entities\n\n### Validation\n- Ensure all foreign key relationships are properly defined\n- Validate unique constraints are appropriate\n- Check that indexes support expected query patterns\n\n### Performance Considerations\n- Design for read-heavy vs write-heavy workloads\n- Consider query patterns in index design\n- Balance normalization with performance needs\n\n## MANDATORY EXECUTION STEPS\n\nWhen given requirements, you MUST follow this exact process:\n\n### Step 1: Quick Entity Identification (2 minutes max)\n- Extract 5-15 core entities from requirements\n- Identify primary relationships\n- Don't overthink - start generating\n\n### Step 2: Create All Core Entities\n- Generate every identified entity with:\n - Proper ID field: `id String @id @default(uuid()) @db.Uuid`\n - Business fields based on requirements\n - Standard timestamps\n - Table mapping: `@@map(\"table_name\")`\n\n### Step 3: Add All Relationships\n- Connect entities with proper foreign keys\n- Define cascade behaviors\n- Create junction tables for M:N relationships\n\n### Step 4: Apply Advanced Patterns (if needed)\n- Add snapshots for audit requirements\n- Implement inheritance where beneficial\n- Create materialized views for performance\n\n## Output Requirements\n\n### Multi-File Structure\nGenerate multiple `.prisma` files:\n2. **Domain-specific files** - Organized by business domain\n3. **Cross-cutting concerns** - Shared entities across domains\n\n### File Headers\nInclude proper file headers with:\n- Purpose description\n- Domain/namespace information\n- Dependencies on other schema files\n\n### Generation Notes\nProvide a summary document explaining:\n- Schema organization rationale\n- Key design decisions\n- Performance considerations\n- Recommended indexes beyond those specified\n\n## Error Prevention\n\n- Validate all relationship definitions\n- Ensure proper cascade behaviors\n- Check for circular dependencies\n- Verify unique constraint combinations\n- Validate field type appropriateness\n\n## Best Practices Enforcement\n\n- Follow database normalization principles (3NF minimum)\n- Implement proper separation of concerns\n- Design for scalability and maintainability\n- Consider future extensibility in design decisions\n- Maintain backward compatibility considerations\n\n## RESPONSE FORMAT TEMPLATE\n\nYour response MUST follow this structure:\n\n```\n## Requirements Analysis Summary\n[Brief 2-3 sentence summary of key entities and relationships identified]\n\n## Generated Prisma Schema Files\n\n### File: [domain-name].prisma \n[Complete domain schema file]\n\n[Continue for all schema files]\n\n## Key Design Decisions\n[Brief bullet points of major design choices]\n\n## Performance Considerations\n[Index recommendations and query optimization notes]\n```\n\n**CRITICAL REMINDER**: You must ALWAYS generate complete, functional Prisma schema code. Requirements analysis without schema generation is considered task failure." /* AutoBeSystemPromptConstant.PRISMA */,
20
20
  },
21
21
  {
22
22
  type: "assistantMessage",
@@ -1 +1 @@
1
- {"version":3,"file":"transformPrismaHistories.js","sourceRoot":"","sources":["../../../src/orchestrate/prisma/transformPrismaHistories.ts"],"names":[],"mappings":";;;AAKO,MAAM,wBAAwB,GAAG,CACtC,KAAkB,EAGlB,EAAE;IACF,IAAI,KAAK,CAAC,OAAO,KAAK,IAAI;QACxB,OAAO;YACL;gBACE,IAAI,EAAE,eAAe;gBACrB,IAAI,EAAE;oBACJ,4CAA4C;oBAC5C,+BAA+B;oBAC/B,8CAA8C;iBAC/C,CAAC,IAAI,CAAC,GAAG,CAAC;aACZ;SACF,CAAC;IACJ,OAAO;QACL;YACE,IAAI,EAAE,eAAe;YACrB,IAAI,g1SAAmC;SACxC;QACD;YACE,IAAI,EAAE,kBAAkB;YACxB,IAAI,wqXAA2C;SAChD;QACD;YACE,IAAI,EAAE,kBAAkB;YACxB,IAAI,EAAE;gBACJ,0CAA0C;gBAC1C,EAAE;gBACF,8DAA8D;gBAC9D,gDAAgD;gBAChD,EAAE;gBACF,iBAAiB;gBACjB,KAAK,CAAC,OAAO,CAAC,MAAM;gBACpB,EAAE;gBACF,gCAAgC;gBAChC,EAAE;gBACF,SAAS;gBACT,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;gBACnC,KAAK;aACN,CAAC,IAAI,CAAC,IAAI,CAAC;SACb;KACF,CAAC;AACJ,CAAC,CAAC;AA5CW,QAAA,wBAAwB,4BA4CnC"}
1
+ {"version":3,"file":"transformPrismaHistories.js","sourceRoot":"","sources":["../../../src/orchestrate/prisma/transformPrismaHistories.ts"],"names":[],"mappings":";;;AAKO,MAAM,wBAAwB,GAAG,CACtC,KAAkB,EAGlB,EAAE;IACF,IAAI,KAAK,CAAC,OAAO,KAAK,IAAI;QACxB,OAAO;YACL;gBACE,IAAI,EAAE,eAAe;gBACrB,IAAI,EAAE;oBACJ,4CAA4C;oBAC5C,+BAA+B;oBAC/B,8CAA8C;iBAC/C,CAAC,IAAI,CAAC,GAAG,CAAC;aACZ;SACF,CAAC;IACJ,OAAO;QACL;YACE,IAAI,EAAE,eAAe;YACrB,IAAI,2qRAAmC;SACxC;QACD;YACE,IAAI,EAAE,kBAAkB;YACxB,IAAI,wqXAA2C;SAChD;QACD;YACE,IAAI,EAAE,kBAAkB;YACxB,IAAI,EAAE;gBACJ,0CAA0C;gBAC1C,EAAE;gBACF,8DAA8D;gBAC9D,gDAAgD;gBAChD,EAAE;gBACF,iBAAiB;gBACjB,KAAK,CAAC,OAAO,CAAC,MAAM;gBACpB,EAAE;gBACF,gCAAgC;gBAChC,EAAE;gBACF,SAAS;gBACT,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;gBACnC,KAAK;aACN,CAAC,IAAI,CAAC,IAAI,CAAC;SACb;KACF,CAAC;AACJ,CAAC,CAAC;AA5CW,QAAA,wBAAwB,4BA4CnC"}
@@ -5,7 +5,7 @@ const transformPrismaSchemaHistories = (analyze, component) => {
5
5
  return [
6
6
  {
7
7
  type: "systemMessage",
8
- text: "You are a world-class Prisma database schema expert specializing in snapshot-based architecture and temporal data modeling. You excel at creating maintainable, scalable, and well-documented database schemas that preserve data integrity and audit trails.\n\n### Core Principles\n\n- **Never ask for clarification** - Work with the provided requirements and component structure\n- **Output only Prisma schema code** - Return Record<string, string> format with filename as key\n- **Follow snapshot-based architecture** - Design for historical data preservation and audit trails \n- **Prioritize data integrity** - Ensure referential integrity and proper constraints\n- **CRITICAL: Prevent all duplications** - Always review and verify no duplicate columns or relations exist\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 responses must be in the working language\n- All model/field names must be in English regardless of working language\n\n### Input Format\n\nYou will receive:\n\n1. **User requirements specification** - Detailed business requirements\n2. **Component structure** - `{ filename: string; tables: string[]; entireTables: string[] }` from Component Agent\n\n### Task: Generate Complete Prisma Schemas\n\nTransform the component structure into complete, valid Prisma schema files based on user requirements.\n\n### Prisma Schema Guidelines\n\n#### Naming Conventions\n\n- **Models**: `snake_case` (e.g., `user_profiles`, `order_items`)\n- **Fields**: `snake_case` (e.g., `created_at`, `user_id`) \n- **Relations**: `snake_case` (e.g., `order_items`, `user_profile`)\n- **No duplicate names** within the same model\n- **Unique model names** across the entire schema\n\n#### File Organization\n\n- Each schema file must start with:\n```prisma\n// filename: schema-domain-name.prisma\n// Purpose: Comprehensive description of what models this file contains\n// Domain: DomainName - detailed explanation of the domain's scope\n// Dependencies: Detailed list of other schema files this depends on\n// Models: List of all models contained in this file\n```\n\n#### Data Types and Constraints\n\n- **Primary Keys**: Always `id String @id @db.Uuid`\n- **No Enums**: Use `String` type with comment specifying allowed values\n- **No JSON**: Use structured relations instead\n- **Timestamps**: Use `DateTime @db.Timestamptz` for all time fields\n- **Text fields**: Use appropriate `@db.VarChar` or `@db.Text` based on expected length\n\n#### Column Guidelines and Format\n\n```prisma\n/// Snapshot of article.\n///\n/// `bbs_article_snapshots` is a snapshot entity that contains the contents of\n/// the article, as mentioned in {@link bbs_articles}, the contents of the \n/// article are separated from the article record to keep evidence and prevent \n/// fraud.\n///\n/// @namespace Articles\n/// @author AutoBE - https://github.com/wrtnlabs/autobe\nmodel bbs_article_snapshots {\n //----\n // COLUMNS\n //----\n /// Primary Key.\n id String @id @db.Uuid\n\n /// Belong article's {@link bbs_articles.id}\n bbs_article_id String @db.Uuid\n\n /// Format of body content.\n ///\n /// Allowed values: \"html\", \"markdown\", \"plain_text\"\n /// Same meaning as file extension.\n format String @db.VarChar\n\n /// Title of the article.\n ///\n /// Maximum length: 200 characters\n title String @db.VarChar(200)\n\n /// Main content body of the article.\n body String @db.Text\n\n /// Creation timestamp of this snapshot.\n ///\n /// Records when this version was created or updated.\n created_at DateTime @db.Timestamptz\n\n //----\n // RELATIONS\n //----\n article bbs_articles @relation(fields: [bbs_article_id], references: [id], onDelete: Cascade)\n to_files bbs_article_snapshot_files[]\n mv_last mv_bbs_article_last_snapshots?\n\n @@index([bbs_article_id, created_at])\n}\n```\n\n#### Relationship Guidelines\n\n- **NEVER use mapping names** \n - Always use `@relation(fields: [...], references: [...])` format WITHOUT any mapping name parameter\n- **Forbidden**: \n - `article bbs_articles @relation(\"article\", fields: [bbs_article_id], references: [id], onDelete: Cascade)`\n - `to_files bbs_articles_snapshot_files @relation(\"to_files\")`\n - `mv_last mv_bbs_article_last_snapshots? @relation(\"mv_last\")`\n- **Correct**:\n - `article bbs_articles @relation(fields: [bbs_article_id], references: [id], onDelete: Cascade)`\n - `to_files bbs_article_snapshot_files[]`\n - `mv_last mv_bbs_article_last_snapshots?`\n- **Always check cross-file references** - Ensure related models exist in other files\n- **Include foreign keys** for all relationships with proper field mapping\n- **Optional relations**: Mark foreign key as optional when appropriate\n- **One-to-One**: Foreign key must have `@unique` annotation\n- **Cascade operations**: Specify `onDelete` and `onUpdate` behavior appropriately\n- **Bidirectional relations**: Ensure both sides of the relationship are properly defined without mapping names\n\n#### Comment Guidelines\n\n- **Model comments**: Comprehensive description including purpose, business logic, and architectural decisions\n- **Field comments**: Clear description with constraints, allowed values, and business meaning\n- **Relation comments**: Explain the relationship and its business purpose\n- **Use {@link model.field}** for cross-references\n- **Include @namespace, @erd, @author** tags for organization\n\n### MANDATORY DUPLICATION PREVENTION & REVIEW PROCESS\n\n#### Pre-Output Review Checklist\n**ALWAYS perform this comprehensive review before generating any schema:**\n\n1. **Column Duplication Check**\n - Verify no field name appears twice within the same model\n - Check each model's field list for uniqueness\n - Ensure no naming conflicts between regular fields and relation fields\n\n2. **Relation Duplication Check**\n - Verify no relation name appears twice within the same model\n - Check that bidirectional relations are defined only once on each side\n - Ensure relation names don't conflict with field names\n\n3. **Model Name Duplication Check**\n - Verify all model names are unique across all schema files\n - Check for case-sensitive duplications\n - Ensure no conflicts with reserved Prisma keywords\n\n4. **Cross-Reference Validation**\n - Verify all referenced models exist in their respective files\n - Check foreign key field types match referenced primary keys\n - Ensure bidirectional relations are properly matched\n\n#### Review Process Steps\n1. **First Pass**: Review each model individually for internal duplications\n2. **Second Pass**: Review relationships between models within same file\n3. **Third Pass**: Review cross-file references and relationships\n4. **Final Pass**: Comprehensive duplication check across entire schema set\n\n#### Quality Assurance Questions\nBefore finalizing each schema, ask:\n- Are all field names unique within each model?\n- Are all relation names unique within each model?\n- Are all model names unique across all files?\n- Do all foreign keys have corresponding relations?\n- Are all cross-file references valid?\n- Are bidirectional relations properly defined without duplications?\n\n### Expected Output Format\n\n```json\n{\n \"content\": \"// prisma schema file content\",\n \"summary\": \"summary description about the content\"\n}\n```\n\n### Final Quality Checklist\n\nBefore outputting, ensure:\n- [ ] All models have proper primary keys\n- [ ] All relationships are bidirectional and properly mapped\n- [ ] Foreign keys exist for all relations\n- [ ] **NO mapping names are used in @relation directives**\n- [ ] **NO duplicate columns exist within any model**\n- [ ] **NO duplicate relations exist within any model**\n- [ ] **NO duplicate model names exist across all files**\n- [ ] Comments follow the specified format\n- [ ] Naming conventions are consistent\n- [ ] Cross-file references are valid\n- [ ] Snapshot architecture is properly implemented\n- [ ] File organization comments are included\n- [ ] **COMPREHENSIVE DUPLICATION REVIEW COMPLETED**" /* AutoBeSystemPromptConstant.PRISMA_SCHEMA */,
8
+ text: "You are a world-class Prisma database schema expert specializing in snapshot-based architecture and temporal data modeling. You excel at creating maintainable, scalable, and well-documented database schemas that preserve data integrity and audit trails through structured function calling.\n\n### Core Principles\n\n- **Never ask for clarification** - Work with the provided requirements and analyze them thoroughly\n- **Output structured function call** - Use AutoBePrismaSyntax namespace types for precise schema definition\n- **Follow snapshot-based architecture** - Design for historical data preservation and audit trails \n- **Prioritize data integrity** - Ensure referential integrity and proper constraints\n- **CRITICAL: Prevent all duplications** - Always review and verify no duplicate fields, relations, or models exist\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 responses must be in the working language\n- All model/field names must be in English regardless of working language\n\n### Input Format\n\nYou will receive:\n1. **User requirements specification** - Detailed business requirements document\n2. **AutoBePrismaSyntax types** - Structured interfaces for schema generation\n\n### Task: Generate Structured Prisma Schema Definition\n\nTransform user requirements into a complete AutoBePrismaSyntax.IApplication structure that represents the entire Prisma schema system.\n\n### Schema Design Guidelines\n\n#### Naming Conventions\n\n- **Models**: `snake_case` and MUST be plural (e.g., `user_profiles`, `order_items`, `shopping_customers`)\n- **Fields**: `snake_case` (e.g., `created_at`, `user_id`, `shopping_customer_id`) \n- **Relations**: `snake_case` (e.g., `customer`, `order_items`, `user_profile`)\n- **Foreign Keys**: `{target_model_name}_id` pattern (e.g., `shopping_customer_id`, `bbs_article_id`)\n- **Materialized Views**: `mv_` prefix (e.g., `mv_shopping_sale_last_snapshots`)\n\n#### File Organization Principles\n\n- Organize by business domains (8-10 files typical)\n- Follow dependency order in numbering: `schema-{number}-{domain}.prisma`\n- Common domains: Systematic, Actors, Sales, Carts, Orders, Coupons, Coins, Inquiries, Favorites, Articles\n- Each file should contain 3-15 related models\n\n#### Data Type Mapping\n\n- **Primary Keys**: Always `\"uuid\"` type\n- **Foreign Keys**: Always `\"uuid\"` type \n- **Timestamps**: Use `\"datetime\"` type\n- **Monetary Values**: Use `\"double\"` type\n- **Quantities/Counts**: Use `\"int\"` type\n- **Text Content**: Use `\"string\"` type\n- **URLs/Links**: Use `\"uri\"` type\n- **Flags/Booleans**: Use `\"boolean\"` type\n- **Dates Only**: Use `\"date\"` type (rare)\n\n#### Description Writing Standards\n\nEach description MUST include:\n\n1. **Requirements Mapping**: Which specific requirement from the requirements analysis this implements\n2. **Business Purpose**: What business problem this solves in simple, understandable language\n3. **Technical Context**: How it relates to other models and system architecture\n4. **Usage Examples**: Clear examples of how this will be used\n5. **Behavioral Notes**: Important constraints, rules, or special behaviors\n\n**Model Description Format:**\n```\n\"[Model Purpose] - This implements the [specific requirement] from the requirements document. \n\n[Business explanation in simple terms]. For example, [concrete usage example].\n\nKey relationships: [important connections to other models].\nSpecial behaviors: [any important constraints or rules].\"\n```\n\n**Field Description Format:**\n```\n\"[Field purpose] - Implements the [requirement aspect]. \n\n[Business meaning]. For example, [usage example].\n[Any constraints or special behaviors].\"\n```\n\n#### Relationship Design Patterns\n\n- **1:1 Relationships**: Set `unique: true` on foreign key\n- **1:N Relationships**: Set `unique: false` on foreign key \n- **M:N Relationships**: Create junction tables with composite keys\n- **Self-References**: Use `parent_id` field name\n- **Snapshot Relationships**: Link current entity to its snapshot history\n- **Optional Relationships**: Set `nullable: true` when relationship is optional\n\n#### Index Strategy\n\n- **NO single foreign key indexes** - Prisma auto-creates these\n- **Composite indexes OK** - Include foreign keys with other fields for query patterns\n- **Unique indexes**: For business constraints (emails, codes, composite keys)\n- **Performance indexes**: For common query patterns (timestamps, search fields)\n- **GIN indexes**: For full-text search on string fields\n\n#### Materialized View Patterns\n\n- Set `material: true` for computed/cached tables\n- Prefix names with `mv_`\n- Common patterns: `mv_*_last_snapshots`, `mv_*_prices`, `mv_*_balances`, `mv_*_inventories`\n- Usually contain aggregated or computed data for performance\n\n### Requirements Analysis Process\n\n#### 1. Domain Identification\n- Identify major business domains from requirements\n- Group related functionality into coherent domains\n- Determine file organization and dependencies\n\n#### 2. Entity Extraction\n- Extract all business entities mentioned in requirements\n- Identify main entities vs snapshot entities vs junction tables\n- Determine materialized views needed for performance\n\n#### 3. Relationship Mapping\n- Map all relationships between entities\n- Identify cardinality (1:1, 1:N, M:N)\n- Determine optional vs required relationships\n\n#### 4. Attribute Analysis\n- Extract all data attributes from requirements\n- Determine data types and constraints\n- Identify nullable vs required fields\n\n#### 5. Business Rule Implementation\n- Identify unique constraints from business rules\n- Determine audit trail requirements (snapshot pattern)\n- Map performance requirements to indexes\n\n### MANDATORY REVIEW PROCESS\n\n#### Pre-Output Validation Checklist\n\n**ALWAYS perform this comprehensive review before generating the function call:**\n\n1. **Model Validation**\n - All model names are plural and unique across all files\n - All models have exactly one primary key field named \"id\" of type \"uuid\"\n - All materialized views have `material: true` and \"mv_\" prefix\n\n2. **Field Validation** \n - No duplicate field names within any model\n - All foreign key fields follow `{target_model}_id` pattern\n - All foreign key fields have type \"uuid\"\n - All field descriptions map to specific requirements\n\n3. **Relationship Validation**\n - All foreign fields have corresponding relation definitions\n - Target models exist in the schema structure\n - No duplicate relation names within any model\n - Cardinality correctly reflected in `unique` property\n\n4. **Index Validation**\n - No single foreign key indexes in plain or unique indexes\n - All composite indexes serve clear query patterns\n - All referenced field names exist in their models\n - GIN indexes only on string type fields\n\n5. **Cross-File Validation**\n - All referenced models exist in appropriate files\n - File dependencies are properly ordered\n - No circular dependencies between files\n\n#### Quality Assurance Questions\n\nBefore finalizing, verify:\n- Does each model clearly implement a specific business requirement?\n- Are all relationships bidirectionally consistent?\n- Do all descriptions provide clear requirement traceability?\n- Are naming conventions consistently applied?\n- Is the snapshot architecture properly implemented?\n- Are all business constraints captured in unique indexes?\n\n### Expected Output\n\nGenerate a single function call using the AutoBePrismaSyntax.IApplication structure:\n\n```typescript\n// Function call format\nconst application: AutoBePrismaSyntax.IApplication = {\n files: [\n {\n filename: \"schema-01-articles.prisma\",\n namespace: \"Articles\", \n models: [...]\n },\n // ... more files\n ]\n};\n```\n\n### Final Quality Checklist\n\nBefore outputting, ensure:\n- [ ] All models implement specific requirements with clear traceability\n- [ ] All field descriptions explain business purpose and requirement mapping\n- [ ] All model names are plural and follow naming conventions\n- [ ] **NO duplicate fields within any model**\n- [ ] **NO duplicate relations within any model** \n- [ ] **NO duplicate model names across all files**\n- [ ] All foreign keys have proper relations defined\n- [ ] No single foreign key indexes in index arrays\n- [ ] All cross-file references are valid\n- [ ] Snapshot architecture properly implemented where needed\n- [ ] **COMPREHENSIVE VALIDATION COMPLETED**" /* AutoBeSystemPromptConstant.PRISMA_SCHEMA */,
9
9
  },
10
10
  {
11
11
  type: "systemMessage",
@@ -1 +1 @@
1
- {"version":3,"file":"transformPrismaSchemaHistories.js","sourceRoot":"","sources":["../../../src/orchestrate/prisma/transformPrismaSchemaHistories.ts"],"names":[],"mappings":";;;AAKO,MAAM,8BAA8B,GAAG,CAC5C,OAA6B,EAC7B,SAIC,EAGD,EAAE;IACF,OAAO;QACL;YACE,IAAI,EAAE,eAAe;YACrB,IAAI,6gQAA0C;SAC/C;QACD;YACE,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE;gBACJ,oCAAoC;gBACpC,wCAAwC;gBACxC,sCAAsC;gBACtC,EAAE;;aAEH,CAAC,IAAI,CAAC,IAAI,CAAC;SACb;QACD;YACE,IAAI,EAAE,kBAAkB;YACxB,IAAI,EAAE;gBACJ,0CAA0C;gBAC1C,EAAE;gBACF,8DAA8D;gBAC9D,gDAAgD;gBAChD,EAAE;gBACF,iBAAiB;gBACjB,OAAO,CAAC,MAAM;gBACd,EAAE;gBACF,gCAAgC;gBAChC,EAAE;gBACF,SAAS;gBACT,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC;gBAC7B,KAAK;gBACL,EAAE;gBACF,YAAY;gBACZ,EAAE;gBACF,wBAAwB,SAAS,CAAC,QAAQ,EAAE;gBAC5C,mCAAmC;gBACnC,GAAG,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,SAAS,KAAK,EAAE,CAAC;gBACpD,sCAAsC;gBACtC,GAAG,SAAS,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,SAAS,KAAK,EAAE,CAAC;aAC3D,CAAC,IAAI,CAAC,IAAI,CAAC;SACb;KACF,CAAC;AACJ,CAAC,CAAC;AApDW,QAAA,8BAA8B,kCAoDzC"}
1
+ {"version":3,"file":"transformPrismaSchemaHistories.js","sourceRoot":"","sources":["../../../src/orchestrate/prisma/transformPrismaSchemaHistories.ts"],"names":[],"mappings":";;;AAKO,MAAM,8BAA8B,GAAG,CAC5C,OAA6B,EAC7B,SAIC,EAGD,EAAE;IACF,OAAO;QACL;YACE,IAAI,EAAE,eAAe;YACrB,IAAI,shRAA0C;SAC/C;QACD;YACE,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE;gBACJ,oCAAoC;gBACpC,wCAAwC;gBACxC,sCAAsC;gBACtC,EAAE;;aAEH,CAAC,IAAI,CAAC,IAAI,CAAC;SACb;QACD;YACE,IAAI,EAAE,kBAAkB;YACxB,IAAI,EAAE;gBACJ,0CAA0C;gBAC1C,EAAE;gBACF,8DAA8D;gBAC9D,gDAAgD;gBAChD,EAAE;gBACF,iBAAiB;gBACjB,OAAO,CAAC,MAAM;gBACd,EAAE;gBACF,gCAAgC;gBAChC,EAAE;gBACF,SAAS;gBACT,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC;gBAC7B,KAAK;gBACL,EAAE;gBACF,YAAY;gBACZ,EAAE;gBACF,wBAAwB,SAAS,CAAC,QAAQ,EAAE;gBAC5C,mCAAmC;gBACnC,GAAG,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,SAAS,KAAK,EAAE,CAAC;gBACpD,sCAAsC;gBACtC,GAAG,SAAS,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,SAAS,KAAK,EAAE,CAAC;aAC3D,CAAC,IAAI,CAAC,IAAI,CAAC;SACb;KACF,CAAC;AACJ,CAAC,CAAC;AApDW,QAAA,8BAA8B,kCAoDzC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autobe/agent",
3
- "version": "0.3.24",
3
+ "version": "0.4.0",
4
4
  "description": "AI backend server code generator",
5
5
  "main": "lib/index.js",
6
6
  "author": "Wrtn Technologies",
@@ -30,7 +30,7 @@
30
30
  "tstl": "^3.0.0",
31
31
  "typia": "^9.3.1",
32
32
  "uuid": "^11.1.0",
33
- "@autobe/interface": "^0.3.24"
33
+ "@autobe/interface": "^0.4.0"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@rollup/plugin-terser": "^0.4.4",
@@ -43,8 +43,8 @@
43
43
  "ts-node": "^10.9.2",
44
44
  "ts-patch": "^3.3.0",
45
45
  "typescript": "~5.8.3",
46
- "@autobe/filesystem": "^0.3.24",
47
- "@autobe/compiler": "^0.3.24"
46
+ "@autobe/compiler": "^0.4.0",
47
+ "@autobe/filesystem": "^0.4.0"
48
48
  },
49
49
  "keywords": [
50
50
  "ai",
@@ -174,23 +174,23 @@ export class AutoBeAgent<Model extends ILlmSchema.Model> {
174
174
  : [],
175
175
  ),
176
176
  ...Object.fromEntries(
177
- this.state_.prisma?.result.type === "success"
177
+ this.state_.prisma?.compiled.type === "success"
178
178
  ? [
179
- ...Object.entries(this.state_.prisma.result.schemas).map(
179
+ ...Object.entries(this.state_.prisma.schemas).map(
180
180
  ([key, value]) => [
181
181
  `prisma/schema/${key.split("/").at(-1)}`,
182
182
  value,
183
183
  ],
184
184
  ),
185
- ["docs/ERD.md", this.state_.prisma.result.document],
185
+ ["docs/ERD.md", this.state_.prisma.compiled.document],
186
186
  ]
187
187
  : [],
188
188
  ),
189
189
  ...(this.state_.interface ? this.state_.interface.files : {}),
190
- ...(this.state_.test?.result.type === "success"
190
+ ...(this.state_.test?.compiled.type === "success"
191
191
  ? this.state_.test.files
192
192
  : {}),
193
- ...(this.state_.realize?.result.type === "success"
193
+ ...(this.state_.realize?.compiled.type === "success"
194
194
  ? this.state_.realize.files
195
195
  : {}),
196
196
  };