@autobe/agent 0.23.1 → 0.24.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/lib/constants/AutoBeSystemPromptConstant.d.ts +30 -29
  2. package/lib/constants/AutoBeSystemPromptConstant.js.map +1 -1
  3. package/lib/factory/consentFunctionCall.js +1 -1
  4. package/lib/factory/consentFunctionCall.js.map +1 -1
  5. package/lib/factory/createAutoBeContext.js +3 -3
  6. package/lib/factory/createAutoBeContext.js.map +1 -1
  7. package/lib/index.mjs +683 -260
  8. package/lib/index.mjs.map +1 -1
  9. package/lib/orchestrate/analyze/histories/transformAnalyzeReviewHistories.js +1 -1
  10. package/lib/orchestrate/analyze/histories/transformAnalyzeReviewHistories.js.map +1 -1
  11. package/lib/orchestrate/analyze/histories/transformAnalyzeScenarioHistories.js +2 -2
  12. package/lib/orchestrate/analyze/histories/transformAnalyzeScenarioHistories.js.map +1 -1
  13. package/lib/orchestrate/analyze/histories/transformAnalyzeWriteHistories.js +1 -1
  14. package/lib/orchestrate/analyze/histories/transformAnalyzeWriteHistories.js.map +1 -1
  15. package/lib/orchestrate/common/histories/transformCommonCorrectCastingHistories.js +1 -1
  16. package/lib/orchestrate/common/histories/transformCommonCorrectCastingHistories.js.map +1 -1
  17. package/lib/orchestrate/common/histories/transformCommonCorrectDateHistories.d.ts +9 -0
  18. package/lib/orchestrate/common/histories/transformCommonCorrectDateHistories.js +48 -0
  19. package/lib/orchestrate/common/histories/transformCommonCorrectDateHistories.js.map +1 -0
  20. package/lib/orchestrate/common/structures/IAutoBeCommonCorrectDateApplication.d.ts +35 -0
  21. package/lib/orchestrate/common/structures/IAutoBeCommonCorrectDateApplication.js +3 -0
  22. package/lib/orchestrate/common/structures/IAutoBeCommonCorrectDateApplication.js.map +1 -0
  23. package/lib/orchestrate/facade/transformFacadeStateMessage.js +1 -1
  24. package/lib/orchestrate/facade/transformFacadeStateMessage.js.map +1 -1
  25. package/lib/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.js +1 -1
  26. package/lib/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.js.map +1 -1
  27. package/lib/orchestrate/interface/histories/transformInterfaceComplementHistories.js +3 -3
  28. package/lib/orchestrate/interface/histories/transformInterfaceComplementHistories.js.map +1 -1
  29. package/lib/orchestrate/interface/histories/transformInterfaceEndpointHistories.js +1 -1
  30. package/lib/orchestrate/interface/histories/transformInterfaceEndpointHistories.js.map +1 -1
  31. package/lib/orchestrate/interface/histories/transformInterfaceEndpointsReviewHistories.js +2 -2
  32. package/lib/orchestrate/interface/histories/transformInterfaceEndpointsReviewHistories.js.map +1 -1
  33. package/lib/orchestrate/interface/histories/transformInterfaceGroupHistories.js +2 -2
  34. package/lib/orchestrate/interface/histories/transformInterfaceGroupHistories.js.map +1 -1
  35. package/lib/orchestrate/interface/histories/transformInterfaceOperationHistories.js +1 -1
  36. package/lib/orchestrate/interface/histories/transformInterfaceOperationHistories.js.map +1 -1
  37. package/lib/orchestrate/interface/histories/transformInterfaceOperationsReviewHistories.js +2 -2
  38. package/lib/orchestrate/interface/histories/transformInterfaceOperationsReviewHistories.js.map +1 -1
  39. package/lib/orchestrate/interface/histories/transformInterfaceSchemaHistories.js +1 -1
  40. package/lib/orchestrate/interface/histories/transformInterfaceSchemaHistories.js.map +1 -1
  41. package/lib/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.js +2 -2
  42. package/lib/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.js.map +1 -1
  43. package/lib/orchestrate/prisma/histories/transformPrismaComponentsHistories.js +1 -1
  44. package/lib/orchestrate/prisma/histories/transformPrismaComponentsHistories.js.map +1 -1
  45. package/lib/orchestrate/prisma/histories/transformPrismaCorrectHistories.js +1 -1
  46. package/lib/orchestrate/prisma/histories/transformPrismaCorrectHistories.js.map +1 -1
  47. package/lib/orchestrate/prisma/histories/transformPrismaReviewHistories.js +2 -2
  48. package/lib/orchestrate/prisma/histories/transformPrismaReviewHistories.js.map +1 -1
  49. package/lib/orchestrate/prisma/histories/transformPrismaSchemaHistories.js +1 -1
  50. package/lib/orchestrate/prisma/histories/transformPrismaSchemaHistories.js.map +1 -1
  51. package/lib/orchestrate/realize/histories/transformRealizeAuthorization.js +1 -1
  52. package/lib/orchestrate/realize/histories/transformRealizeAuthorization.js.map +1 -1
  53. package/lib/orchestrate/realize/histories/transformRealizeAuthorizationCorrectHistories.js +2 -2
  54. package/lib/orchestrate/realize/histories/transformRealizeAuthorizationCorrectHistories.js.map +1 -1
  55. package/lib/orchestrate/realize/histories/transformRealizeCorrectHistories.js +2 -2
  56. package/lib/orchestrate/realize/histories/transformRealizeCorrectHistories.js.map +1 -1
  57. package/lib/orchestrate/realize/histories/transformRealizeWriteHistories.js +2 -2
  58. package/lib/orchestrate/realize/histories/transformRealizeWriteHistories.js.map +1 -1
  59. package/lib/orchestrate/realize/orchestRateRealizeCorrectCasting.js +4 -3
  60. package/lib/orchestrate/realize/orchestRateRealizeCorrectCasting.js.map +1 -1
  61. package/lib/orchestrate/realize/orchestrateRealize.js +6 -10
  62. package/lib/orchestrate/realize/orchestrateRealize.js.map +1 -1
  63. package/lib/orchestrate/realize/orchestrateRealizeCorrect.js +46 -61
  64. package/lib/orchestrate/realize/orchestrateRealizeCorrect.js.map +1 -1
  65. package/lib/orchestrate/realize/orchestrateRealizeCorrectDate.d.ts +4 -0
  66. package/lib/orchestrate/realize/orchestrateRealizeCorrectDate.js +540 -0
  67. package/lib/orchestrate/realize/orchestrateRealizeCorrectDate.js.map +1 -0
  68. package/lib/orchestrate/realize/orchestrateRealizeWrite.js +37 -55
  69. package/lib/orchestrate/realize/orchestrateRealizeWrite.js.map +1 -1
  70. package/lib/orchestrate/realize/structures/IAutoBeRealizeCorrectApplication.d.ts +8 -8
  71. package/lib/orchestrate/realize/structures/IAutoBeRealizeWriteApplication.d.ts +20 -264
  72. package/lib/orchestrate/realize/utils/filterDiagnostics.d.ts +13 -0
  73. package/lib/orchestrate/realize/utils/filterDiagnostics.js +20 -0
  74. package/lib/orchestrate/realize/utils/filterDiagnostics.js.map +1 -0
  75. package/lib/orchestrate/test/histories/transformTestCorrectHistories.js +1 -1
  76. package/lib/orchestrate/test/histories/transformTestCorrectHistories.js.map +1 -1
  77. package/lib/orchestrate/test/histories/transformTestCorrectInvalidRequestHistories.js +1 -1
  78. package/lib/orchestrate/test/histories/transformTestCorrectInvalidRequestHistories.js.map +1 -1
  79. package/lib/orchestrate/test/histories/transformTestScenarioHistories.js +1 -1
  80. package/lib/orchestrate/test/histories/transformTestScenarioHistories.js.map +1 -1
  81. package/lib/orchestrate/test/histories/transformTestWriteHistories.js +1 -1
  82. package/lib/orchestrate/test/histories/transformTestWriteHistories.js.map +1 -1
  83. package/lib/structures/IAutoBeConfig.d.ts +34 -1
  84. package/lib/utils/{TimeoutConversation.d.ts → TimedConversation.d.ts} +2 -2
  85. package/lib/utils/{TimeoutConversation.js → TimedConversation.js} +20 -6
  86. package/lib/utils/TimedConversation.js.map +1 -0
  87. package/package.json +6 -6
  88. package/src/constants/AutoBeSystemPromptConstant.ts +30 -29
  89. package/src/factory/createAutoBeContext.ts +5 -5
  90. package/src/orchestrate/common/histories/transformCommonCorrectDateHistories.ts +60 -0
  91. package/src/orchestrate/common/structures/IAutoBeCommonCorrectDateApplication.ts +40 -0
  92. package/src/orchestrate/realize/histories/transformRealizeWriteHistories.ts +1 -1
  93. package/src/orchestrate/realize/orchestRateRealizeCorrectCasting.ts +4 -3
  94. package/src/orchestrate/realize/orchestrateRealize.ts +22 -16
  95. package/src/orchestrate/realize/orchestrateRealizeCorrect.ts +44 -16
  96. package/src/orchestrate/realize/orchestrateRealizeCorrectDate.ts +372 -0
  97. package/src/orchestrate/realize/orchestrateRealizeWrite.ts +3 -3
  98. package/src/orchestrate/realize/structures/IAutoBeRealizeCorrectApplication.ts +8 -10
  99. package/src/orchestrate/realize/structures/IAutoBeRealizeWriteApplication.ts +21 -267
  100. package/src/orchestrate/realize/utils/filterDiagnostics.ts +21 -0
  101. package/src/structures/IAutoBeConfig.ts +34 -1
  102. package/src/utils/{TimeoutConversation.ts → TimedConversation.ts} +18 -3
  103. package/lib/utils/TimeoutConversation.js.map +0 -1
@@ -98,16 +98,16 @@ function orchestrateRealizeWrite(ctx, props) {
98
98
  });
99
99
  if (pointer.value === null)
100
100
  throw new Error("Failed to write code.");
101
- pointer.value.implementationCode = yield (0, replaceImportStatements_1.replaceImportStatements)(ctx, {
101
+ pointer.value.final = yield (0, replaceImportStatements_1.replaceImportStatements)(ctx, {
102
102
  operation: props.scenario.operation,
103
- code: pointer.value.implementationCode,
103
+ code: pointer.value.final,
104
104
  decoratorType: (_a = props.authorization) === null || _a === void 0 ? void 0 : _a.payload.name,
105
105
  });
106
106
  const event = {
107
107
  type: "realizeWrite",
108
108
  id: (0, uuid_1.v7)(),
109
109
  location: props.scenario.location,
110
- content: pointer.value.implementationCode,
110
+ content: pointer.value.final,
111
111
  tokenUsage,
112
112
  completed: ++props.progress.completed,
113
113
  total: props.progress.total,
@@ -142,61 +142,52 @@ const claude = {
142
142
  {
143
143
  name: "coding",
144
144
  parameters: {
145
- description: " Properties containing the multi-phase implementation plan and code\n\n------------------------------\n\nDescription of the current {@link IAutoBeRealizeWriteApplication.IProps} type:\n\n> Properties for the Realize Write Application following Chain of Thinking (CoT).\n> \n> Each field represents a distinct phase in the reasoning and implementation process,\n> building upon the previous step to create a complete, error-free implementation.\n> This structured approach ensures clarity, debuggability, and systematic thinking.",
145
+ description: " Properties containing the multi-phase implementation plan and\ncode\n\n------------------------------\n\nDescription of the current {@link IAutoBeRealizeWriteApplication.IProps} type:\n\n> Properties for the Realize Write Application following Chain of Thinking\n> (CoT).\n> \n> Each field represents a distinct phase in the implementation process.\n> Detailed guidelines are in REALIZE_WRITE.md.",
146
146
  type: "object",
147
147
  properties: {
148
148
  plan: {
149
- description: "Step 1 - Planning Phase (CoT: Initial Reasoning)\n\n\uD83E\uDDE0 Provider Function Implementation Plan\n\nThis field outlines the strategic plan for implementing the provider\nfunction according to the Realize Coder Agent specification. Before\nwriting the actual code, think through the logic and structure.\n\nThe plan follows a SCHEMA-FIRST APPROACH:\n\n\uD83D\uDCCB STEP 1 - PRISMA SCHEMA VERIFICATION:\n\nDO:\n\n- Examine the actual Prisma schema model definition\n- List EVERY field that exists in the model with exact types\n- Explicitly note fields that DO NOT exist\n- Verify database compatibility (PostgreSQL AND SQLite)\n\nDO NOT:\n\n- Assume common fields exist without verification\n- Use fields like deleted_at, created_by, updated_by, is_deleted, is_active\n without checking\n- Use PostgreSQL-specific features like mode: \"insensitive\"\n\n\uD83D\uDCCB STEP 2 - FIELD INVENTORY:\n\n- List ONLY fields confirmed to exist in schema\n- Example: \"Verified fields in user model: id (String), email (String),\n created_at (DateTime), updated_at (DateTime)\"\n- Example: \"Fields that DO NOT exist: deleted_at, is_active, created_by\"\n\n\uD83D\uDCCB STEP 3 - FIELD ACCESS STRATEGY:\n\n- Plan which verified fields will be used in select, update, create\n operations\n- For complex operations with type errors, plan to use separate queries\n instead of nested operations\n\n\uD83D\uDCCB STEP 4 - TYPE COMPATIBILITY:\n\n- Plan DateTime to ISO string conversions using toISOStringSafe()\n- Plan handling of nullable vs required fields\n\n\uD83D\uDCCB STEP 5 - IMPLEMENTATION APPROACH:\n\n- \uD83E\uDDE9 Required business entities (e.g., users, posts, logs) and their\n relationships\n- \uD83D\uDEE0 Operations needed to fulfill the business scenario (e.g., fetch,\n create, update) using ONLY verified fields\n- \uD83D\uDD04 Data dependencies between steps (e.g., use userId to fetch related\n data)\n- \u2705 Validation points (based on business rules, not field presence)\n- \uD83D\uDEA7 Error and edge cases that must be handled explicitly (e.g., missing\n records)\n- \uD83C\uDFD7 Structure: always a single `async function`, using only `parameters`\n and `body`\n\n\u26A0\uFE0F Important Constraints:\n\n- Do NOT perform input validation \u2014 assume `parameters` and `body` are\n already valid\n- Use `typia.random<T>()` with an explanatory comment if logic can't be\n implemented\n- Never use `any` or make assumptions without sufficient context\n- Use only allowed imports \u2014 DTOs and Prisma types\n- Use `MyGlobal.prisma` for DB access and respect Prisma typing rules\n\n\u26A0\uFE0F TypeScript-specific considerations:\n\n- Do **not** use native `Date` objects directly; always convert all dates\n using `toISOStringSafe()` and brand as `string &\n tags.Format<'date-time'>`. This rule applies throughout all phases.\n- Prefer `satisfies` for DTO conformance instead of unsafe `as` casts\n- Avoid weak typing such as `any`, `as any`, or `satisfies any`\n- Use branded types (e.g., `tags.Format<'uuid'>`) and literal unions where\n applicable\n\n\u2705 Example Structure:\n\n```ts\nexport async function doSomething(\n user: { id: string & tags.Format<\"uuid\">; type: string },\n parameters: IParams,\n body: IBody\n): Promise<IReturn> {\n const { id } = parameters;\n const { name } = body;\n const user = await MyGlobal.prisma.users.findFirst({ where: { id } });\n if (!user) throw new Error(\"User not found\");\n ...\n return result;\n}\n```\n\n\uD83D\uDD0D Feasibility Analysis Requirement:\n\n- Before generating any code, the agent **must analyze** whether the\n requested implementation is **feasible based on the given Prisma schema\n and DTO types**.\n- If required fields or relationships are **missing or incompatible**, the\n plan should explicitly state that the implementation is **not\n possible** with the current schema/DTO, and no code should be generated\n in later stages.\n- In such cases, only a detailed **comment in the `implementationCode`**\n should be returned explaining why the logic cannot be implemented.\n\n\uD83D\uDD25 Error Handling Plan:\n\nIf an error is expected or encountered during implementation:\n\n- Clearly document the error message(s) and TypeScript error codes.\n- Analyze the root cause (e.g., type mismatch, missing field, nullability\n issue).\n- Define concrete steps to resolve the issue, such as:\n\n - Adjusting type declarations or using Prisma-generated input types.\n - Using `?? undefined` to normalize nullable fields.\n - Applying correct relation handling (e.g., `connect` instead of direct\n foreign key assignment).\n - Ensuring all date fields use `.toISOString()` and proper branding.\n- Include fallback or workaround plans if a direct fix is complex.\n- If no error is present, simply omit this section.\n\nThis plan ensures the function will:\n\n- Respect the global architecture and coding conventions\n- Be safe, predictable, and aligned with upstream logic",
149
+ description: "Step 1 - Planning Phase (CoT: Initial Reasoning)\n\nStrategic plan following SCHEMA-FIRST APPROACH:\n\n1. Verify Prisma schema fields (list existing and non-existing)\n2. Plan field usage in operations\n3. Plan type conversions and nullable handling\n4. Define implementation approach with error handling\n\nSee REALIZE_WRITE.md for detailed requirements.",
150
150
  type: "string"
151
151
  },
152
- prisma_schemas: {
153
- description: "Step 2 - Schema Definition (CoT: Context Establishment)\n\nThe Prisma schema string that will be used to validate the implementation\nlogic in this file.\n\nYou must **explicitly specify only the relevant models and fields** from\nyour full schema that are used in this implementation. This ensures that\nyour logic is aligned with the expected database structure without\naccidentally introducing unrelated fields or models.\n\n\u26A0\uFE0F Important: The value of this field must be a valid Prisma schema\nstring containing only the models used in this code \u2014 not the entire\nschema.\n\nThis acts as a safeguard against:\n\n- Forgetting required fields used in this implementation\n- Including fields or models that are not actually used",
154
- type: "string"
155
- },
156
- draft_without_date_type: {
157
- description: "Step 3 - Initial Draft (CoT: First Implementation Attempt)\n\nDraft WITHOUT using native Date type.\n\nThis is the initial drafting phase where you outline the basic skeleton\nof the function.\n\nDO NOT: Use the native Date type.\n\n- The function signature must correctly include `user`, `parameters`, and\n `body` arguments.\n- Design the main flow of business logic, such as DB fetches and early\n returns based on conditions.\n- Mark any incomplete or missing parts clearly with placeholders (e.g.,\n comments or temporary values).\n\nImport rules:\n\nDO NOT:\n\n- Add any new import statements manually\n- Write import statements directly (this causes compile errors)\n\nNote: All necessary imports are provided globally or by the system\nautomatically.\n\n\u2705 Requirements:\n\n- Avoid using the `any` type at all costs to ensure type safety.\n- NEVER declare variables with `: Date` type\n- ALWAYS use `string & tags.Format<'date-time'>` for date values\n- Use `toISOStringSafe(new Date())` for current timestamps\n- Maintain a single-function structure; avoid using classes.",
152
+ prismaSchemas: {
153
+ description: "Step 2 - Relevant Prisma schema models and fields",
158
154
  type: "string"
159
155
  },
160
156
  review: {
161
- description: "Step 4 - Review and Refinement (CoT: Self-Reflection)\n\nA refined version of the draft with improved completeness.\n\n- Replace placeholder logic with real DTO-conformant operations.\n- Add error handling (`throw new Error(...)`) where necessary.\n- Begin resolving structural or type mismatches.\n\n\u2705 Requirements:\n\n- Use `satisfies` to ensure DTO conformity.\n- Avoid unsafe `as` casts unless only for branding or literal narrowing.\n- Use `toISOStringSafe()` for all date conversions (NOT `.toISOString()`).\n- Ensure all object keys strictly conform to the expected type definitions.\n- NEVER use `mode: \"insensitive\"` in string operations (breaks SQLite).",
157
+ description: "Step 3 - Refined version with real operations",
162
158
  type: "string"
163
159
  },
164
- implementationCode: {
165
- description: "Step 5 - Complete Implementation (CoT: Final Synthesis)\n\nThe complete and fully correct TypeScript function implementation.\n\n- Passes strict type checking without errors.\n- Uses only safe branding or literal type assertions.\n- Converts all date values properly using `toISOStringSafe()`.\n- Follows DTO structures using `satisfies`.\n- Avoids any weak typing such as `any`, `as any`, or `satisfies any`.\n- Uses only allowed imports (e.g., from `../api/structures` and\n `MyGlobal.prisma`).\n- NEVER creates intermediate variables for Prisma operations.\n- NEVER uses `mode: \"insensitive\"` (PostgreSQL-only, breaks SQLite).\n\n\u26A0\uFE0F Fallback Behavior:\n\n- If the `plan` phase explicitly determines that the requested logic is\n **not feasible** due to mismatches or limitations in the provided\n Prisma schema and DTO types:\n\n - The implementation must still return a syntactically valid function.\n - In such cases, return mock data using `typia.random<T>()` wrapped in the\n correct structure, along with a comment explaining the limitation.\n\n Example fallback:\n\n```ts\n // \u26A0\uFE0F Cannot implement logic due to missing relation between A and B\n export async function someFunction(...) {\n return typia.random<IReturn>(); // mocked output\n }\n```\n\n\u26A0\uFE0F Prohibited Practices:\n\n- Do NOT add or modify import statements manually. Imports are handled\n automatically by the system.\n- Do NOT use `any`, `as any`, or `satisfies any` to bypass type checking.\n- Do NOT assign native `Date` objects directly; always convert them using\n `toISOStringSafe()`.\n- Do NOT use unsafe type assertions except for safe branding or literal\n narrowing.\n- Do NOT write code outside the single async function structure (e.g., no\n classes or multiple functions).\n- Do NOT perform any input validation \u2014 assume all inputs are already\n validated.\n- Do NOT use dynamic import expressions (`import()`); all imports must be\n static.\n- Do NOT use Prisma-generated input types; always use types from\n `../api/structures`.\n- Do NOT use `Object.prototype.hasOwnProperty.call()` for field checks.\n- Do NOT escape newlines or quotes in the implementation string (e.g., no\n `\\\\n` or `\\\"`); use a properly formatted template literal with actual\n line breaks instead.",
160
+ final: {
161
+ description: "Step 4 - Final implementation See REALIZE_WRITE.md for requirements",
166
162
  type: "string"
167
163
  }
168
164
  },
169
165
  required: [
170
166
  "plan",
171
- "prisma_schemas",
172
- "draft_without_date_type",
167
+ "prismaSchemas",
173
168
  "review",
174
- "implementationCode"
169
+ "final"
175
170
  ],
176
171
  additionalProperties: false,
177
172
  $defs: {}
178
173
  },
179
- description: "Generates provider function implementation through multi-phase development.\n\nThis method implements a systematic approach to generate NestJS provider\nfunctions that handle business logic for API operations. It follows a\nschema-first approach with multiple refinement phases to ensure type-safe,\nerror-free code generation.\n\nThe generation process includes:\n1. Strategic planning based on Prisma schema analysis\n2. Initial draft without Date type usage\n3. Review and refinement for completeness\n4. Compiler feedback integration if errors detected\n5. Final implementation with all validations and type safety",
180
- validate: (() => { const _io0 = input => "string" === typeof input.plan && "string" === typeof input.prisma_schemas && "string" === typeof input.draft_without_date_type && "string" === typeof input.review && "string" === typeof input.implementationCode; const _vo0 = (input, _path, _exceptionable = true) => ["string" === typeof input.plan || _report(_exceptionable, {
174
+ description: "Generates provider function implementation through multi-phase development.\n\nThis method implements a systematic approach to generate NestJS provider\nfunctions that handle business logic for API operations. It follows a\nschema-first approach with multiple refinement phases to ensure type-safe,\nerror-free code generation.\n\nThe generation process includes:\n\n1. Strategic planning based on Prisma schema analysis\n2. Schema definition for relevant models\n3. Review and refinement for completeness\n4. Final implementation with all validations and type safety",
175
+ validate: (() => { const _io0 = input => "string" === typeof input.plan && "string" === typeof input.prismaSchemas && "string" === typeof input.review && "string" === typeof input.final; const _vo0 = (input, _path, _exceptionable = true) => ["string" === typeof input.plan || _report(_exceptionable, {
181
176
  path: _path + ".plan",
182
177
  expected: "string",
183
178
  value: input.plan
184
- }), "string" === typeof input.prisma_schemas || _report(_exceptionable, {
185
- path: _path + ".prisma_schemas",
186
- expected: "string",
187
- value: input.prisma_schemas
188
- }), "string" === typeof input.draft_without_date_type || _report(_exceptionable, {
189
- path: _path + ".draft_without_date_type",
179
+ }), "string" === typeof input.prismaSchemas || _report(_exceptionable, {
180
+ path: _path + ".prismaSchemas",
190
181
  expected: "string",
191
- value: input.draft_without_date_type
182
+ value: input.prismaSchemas
192
183
  }), "string" === typeof input.review || _report(_exceptionable, {
193
184
  path: _path + ".review",
194
185
  expected: "string",
195
186
  value: input.review
196
- }), "string" === typeof input.implementationCode || _report(_exceptionable, {
197
- path: _path + ".implementationCode",
187
+ }), "string" === typeof input.final || _report(_exceptionable, {
188
+ path: _path + ".final",
198
189
  expected: "string",
199
- value: input.implementationCode
190
+ value: input.final
200
191
  })].every(flag => flag); const __is = input => "object" === typeof input && null !== input && _io0(input); let errors; let _report; return input => {
201
192
  if (false === __is(input)) {
202
193
  errors = [];
@@ -240,61 +231,52 @@ const collection = {
240
231
  {
241
232
  name: "coding",
242
233
  parameters: {
243
- description: " Properties containing the multi-phase implementation plan and code\n\n------------------------------\n\nDescription of the current {@link IAutoBeRealizeWriteApplication.IProps} type:\n\n> Properties for the Realize Write Application following Chain of Thinking (CoT).\n> \n> Each field represents a distinct phase in the reasoning and implementation process,\n> building upon the previous step to create a complete, error-free implementation.\n> This structured approach ensures clarity, debuggability, and systematic thinking.",
234
+ description: " Properties containing the multi-phase implementation plan and\ncode\n\n------------------------------\n\nDescription of the current {@link IAutoBeRealizeWriteApplication.IProps} type:\n\n> Properties for the Realize Write Application following Chain of Thinking\n> (CoT).\n> \n> Each field represents a distinct phase in the implementation process.\n> Detailed guidelines are in REALIZE_WRITE.md.",
244
235
  type: "object",
245
236
  properties: {
246
237
  plan: {
247
- description: "Step 1 - Planning Phase (CoT: Initial Reasoning)\n\n\uD83E\uDDE0 Provider Function Implementation Plan\n\nThis field outlines the strategic plan for implementing the provider\nfunction according to the Realize Coder Agent specification. Before\nwriting the actual code, think through the logic and structure.\n\nThe plan follows a SCHEMA-FIRST APPROACH:\n\n\uD83D\uDCCB STEP 1 - PRISMA SCHEMA VERIFICATION:\n\nDO:\n\n- Examine the actual Prisma schema model definition\n- List EVERY field that exists in the model with exact types\n- Explicitly note fields that DO NOT exist\n- Verify database compatibility (PostgreSQL AND SQLite)\n\nDO NOT:\n\n- Assume common fields exist without verification\n- Use fields like deleted_at, created_by, updated_by, is_deleted, is_active\n without checking\n- Use PostgreSQL-specific features like mode: \"insensitive\"\n\n\uD83D\uDCCB STEP 2 - FIELD INVENTORY:\n\n- List ONLY fields confirmed to exist in schema\n- Example: \"Verified fields in user model: id (String), email (String),\n created_at (DateTime), updated_at (DateTime)\"\n- Example: \"Fields that DO NOT exist: deleted_at, is_active, created_by\"\n\n\uD83D\uDCCB STEP 3 - FIELD ACCESS STRATEGY:\n\n- Plan which verified fields will be used in select, update, create\n operations\n- For complex operations with type errors, plan to use separate queries\n instead of nested operations\n\n\uD83D\uDCCB STEP 4 - TYPE COMPATIBILITY:\n\n- Plan DateTime to ISO string conversions using toISOStringSafe()\n- Plan handling of nullable vs required fields\n\n\uD83D\uDCCB STEP 5 - IMPLEMENTATION APPROACH:\n\n- \uD83E\uDDE9 Required business entities (e.g., users, posts, logs) and their\n relationships\n- \uD83D\uDEE0 Operations needed to fulfill the business scenario (e.g., fetch,\n create, update) using ONLY verified fields\n- \uD83D\uDD04 Data dependencies between steps (e.g., use userId to fetch related\n data)\n- \u2705 Validation points (based on business rules, not field presence)\n- \uD83D\uDEA7 Error and edge cases that must be handled explicitly (e.g., missing\n records)\n- \uD83C\uDFD7 Structure: always a single `async function`, using only `parameters`\n and `body`\n\n\u26A0\uFE0F Important Constraints:\n\n- Do NOT perform input validation \u2014 assume `parameters` and `body` are\n already valid\n- Use `typia.random<T>()` with an explanatory comment if logic can't be\n implemented\n- Never use `any` or make assumptions without sufficient context\n- Use only allowed imports \u2014 DTOs and Prisma types\n- Use `MyGlobal.prisma` for DB access and respect Prisma typing rules\n\n\u26A0\uFE0F TypeScript-specific considerations:\n\n- Do **not** use native `Date` objects directly; always convert all dates\n using `toISOStringSafe()` and brand as `string &\n tags.Format<'date-time'>`. This rule applies throughout all phases.\n- Prefer `satisfies` for DTO conformance instead of unsafe `as` casts\n- Avoid weak typing such as `any`, `as any`, or `satisfies any`\n- Use branded types (e.g., `tags.Format<'uuid'>`) and literal unions where\n applicable\n\n\u2705 Example Structure:\n\n```ts\nexport async function doSomething(\n user: { id: string & tags.Format<\"uuid\">; type: string },\n parameters: IParams,\n body: IBody\n): Promise<IReturn> {\n const { id } = parameters;\n const { name } = body;\n const user = await MyGlobal.prisma.users.findFirst({ where: { id } });\n if (!user) throw new Error(\"User not found\");\n ...\n return result;\n}\n```\n\n\uD83D\uDD0D Feasibility Analysis Requirement:\n\n- Before generating any code, the agent **must analyze** whether the\n requested implementation is **feasible based on the given Prisma schema\n and DTO types**.\n- If required fields or relationships are **missing or incompatible**, the\n plan should explicitly state that the implementation is **not\n possible** with the current schema/DTO, and no code should be generated\n in later stages.\n- In such cases, only a detailed **comment in the `implementationCode`**\n should be returned explaining why the logic cannot be implemented.\n\n\uD83D\uDD25 Error Handling Plan:\n\nIf an error is expected or encountered during implementation:\n\n- Clearly document the error message(s) and TypeScript error codes.\n- Analyze the root cause (e.g., type mismatch, missing field, nullability\n issue).\n- Define concrete steps to resolve the issue, such as:\n\n - Adjusting type declarations or using Prisma-generated input types.\n - Using `?? undefined` to normalize nullable fields.\n - Applying correct relation handling (e.g., `connect` instead of direct\n foreign key assignment).\n - Ensuring all date fields use `.toISOString()` and proper branding.\n- Include fallback or workaround plans if a direct fix is complex.\n- If no error is present, simply omit this section.\n\nThis plan ensures the function will:\n\n- Respect the global architecture and coding conventions\n- Be safe, predictable, and aligned with upstream logic",
238
+ description: "Step 1 - Planning Phase (CoT: Initial Reasoning)\n\nStrategic plan following SCHEMA-FIRST APPROACH:\n\n1. Verify Prisma schema fields (list existing and non-existing)\n2. Plan field usage in operations\n3. Plan type conversions and nullable handling\n4. Define implementation approach with error handling\n\nSee REALIZE_WRITE.md for detailed requirements.",
248
239
  type: "string"
249
240
  },
250
- prisma_schemas: {
251
- description: "Step 2 - Schema Definition (CoT: Context Establishment)\n\nThe Prisma schema string that will be used to validate the implementation\nlogic in this file.\n\nYou must **explicitly specify only the relevant models and fields** from\nyour full schema that are used in this implementation. This ensures that\nyour logic is aligned with the expected database structure without\naccidentally introducing unrelated fields or models.\n\n\u26A0\uFE0F Important: The value of this field must be a valid Prisma schema\nstring containing only the models used in this code \u2014 not the entire\nschema.\n\nThis acts as a safeguard against:\n\n- Forgetting required fields used in this implementation\n- Including fields or models that are not actually used",
252
- type: "string"
253
- },
254
- draft_without_date_type: {
255
- description: "Step 3 - Initial Draft (CoT: First Implementation Attempt)\n\nDraft WITHOUT using native Date type.\n\nThis is the initial drafting phase where you outline the basic skeleton\nof the function.\n\nDO NOT: Use the native Date type.\n\n- The function signature must correctly include `user`, `parameters`, and\n `body` arguments.\n- Design the main flow of business logic, such as DB fetches and early\n returns based on conditions.\n- Mark any incomplete or missing parts clearly with placeholders (e.g.,\n comments or temporary values).\n\nImport rules:\n\nDO NOT:\n\n- Add any new import statements manually\n- Write import statements directly (this causes compile errors)\n\nNote: All necessary imports are provided globally or by the system\nautomatically.\n\n\u2705 Requirements:\n\n- Avoid using the `any` type at all costs to ensure type safety.\n- NEVER declare variables with `: Date` type\n- ALWAYS use `string & tags.Format<'date-time'>` for date values\n- Use `toISOStringSafe(new Date())` for current timestamps\n- Maintain a single-function structure; avoid using classes.",
241
+ prismaSchemas: {
242
+ description: "Step 2 - Relevant Prisma schema models and fields",
256
243
  type: "string"
257
244
  },
258
245
  review: {
259
- description: "Step 4 - Review and Refinement (CoT: Self-Reflection)\n\nA refined version of the draft with improved completeness.\n\n- Replace placeholder logic with real DTO-conformant operations.\n- Add error handling (`throw new Error(...)`) where necessary.\n- Begin resolving structural or type mismatches.\n\n\u2705 Requirements:\n\n- Use `satisfies` to ensure DTO conformity.\n- Avoid unsafe `as` casts unless only for branding or literal narrowing.\n- Use `toISOStringSafe()` for all date conversions (NOT `.toISOString()`).\n- Ensure all object keys strictly conform to the expected type definitions.\n- NEVER use `mode: \"insensitive\"` in string operations (breaks SQLite).",
246
+ description: "Step 3 - Refined version with real operations",
260
247
  type: "string"
261
248
  },
262
- implementationCode: {
263
- description: "Step 5 - Complete Implementation (CoT: Final Synthesis)\n\nThe complete and fully correct TypeScript function implementation.\n\n- Passes strict type checking without errors.\n- Uses only safe branding or literal type assertions.\n- Converts all date values properly using `toISOStringSafe()`.\n- Follows DTO structures using `satisfies`.\n- Avoids any weak typing such as `any`, `as any`, or `satisfies any`.\n- Uses only allowed imports (e.g., from `../api/structures` and\n `MyGlobal.prisma`).\n- NEVER creates intermediate variables for Prisma operations.\n- NEVER uses `mode: \"insensitive\"` (PostgreSQL-only, breaks SQLite).\n\n\u26A0\uFE0F Fallback Behavior:\n\n- If the `plan` phase explicitly determines that the requested logic is\n **not feasible** due to mismatches or limitations in the provided\n Prisma schema and DTO types:\n\n - The implementation must still return a syntactically valid function.\n - In such cases, return mock data using `typia.random<T>()` wrapped in the\n correct structure, along with a comment explaining the limitation.\n\n Example fallback:\n\n```ts\n // \u26A0\uFE0F Cannot implement logic due to missing relation between A and B\n export async function someFunction(...) {\n return typia.random<IReturn>(); // mocked output\n }\n```\n\n\u26A0\uFE0F Prohibited Practices:\n\n- Do NOT add or modify import statements manually. Imports are handled\n automatically by the system.\n- Do NOT use `any`, `as any`, or `satisfies any` to bypass type checking.\n- Do NOT assign native `Date` objects directly; always convert them using\n `toISOStringSafe()`.\n- Do NOT use unsafe type assertions except for safe branding or literal\n narrowing.\n- Do NOT write code outside the single async function structure (e.g., no\n classes or multiple functions).\n- Do NOT perform any input validation \u2014 assume all inputs are already\n validated.\n- Do NOT use dynamic import expressions (`import()`); all imports must be\n static.\n- Do NOT use Prisma-generated input types; always use types from\n `../api/structures`.\n- Do NOT use `Object.prototype.hasOwnProperty.call()` for field checks.\n- Do NOT escape newlines or quotes in the implementation string (e.g., no\n `\\\\n` or `\\\"`); use a properly formatted template literal with actual\n line breaks instead.",
249
+ final: {
250
+ description: "Step 4 - Final implementation See REALIZE_WRITE.md for requirements",
264
251
  type: "string"
265
252
  }
266
253
  },
267
254
  required: [
268
255
  "plan",
269
- "prisma_schemas",
270
- "draft_without_date_type",
256
+ "prismaSchemas",
271
257
  "review",
272
- "implementationCode"
258
+ "final"
273
259
  ],
274
260
  additionalProperties: false,
275
261
  $defs: {}
276
262
  },
277
- description: "Generates provider function implementation through multi-phase development.\n\nThis method implements a systematic approach to generate NestJS provider\nfunctions that handle business logic for API operations. It follows a\nschema-first approach with multiple refinement phases to ensure type-safe,\nerror-free code generation.\n\nThe generation process includes:\n1. Strategic planning based on Prisma schema analysis\n2. Initial draft without Date type usage\n3. Review and refinement for completeness\n4. Compiler feedback integration if errors detected\n5. Final implementation with all validations and type safety",
278
- validate: (() => { const _io0 = input => "string" === typeof input.plan && "string" === typeof input.prisma_schemas && "string" === typeof input.draft_without_date_type && "string" === typeof input.review && "string" === typeof input.implementationCode; const _vo0 = (input, _path, _exceptionable = true) => ["string" === typeof input.plan || _report(_exceptionable, {
263
+ description: "Generates provider function implementation through multi-phase development.\n\nThis method implements a systematic approach to generate NestJS provider\nfunctions that handle business logic for API operations. It follows a\nschema-first approach with multiple refinement phases to ensure type-safe,\nerror-free code generation.\n\nThe generation process includes:\n\n1. Strategic planning based on Prisma schema analysis\n2. Schema definition for relevant models\n3. Review and refinement for completeness\n4. Final implementation with all validations and type safety",
264
+ validate: (() => { const _io0 = input => "string" === typeof input.plan && "string" === typeof input.prismaSchemas && "string" === typeof input.review && "string" === typeof input.final; const _vo0 = (input, _path, _exceptionable = true) => ["string" === typeof input.plan || _report(_exceptionable, {
279
265
  path: _path + ".plan",
280
266
  expected: "string",
281
267
  value: input.plan
282
- }), "string" === typeof input.prisma_schemas || _report(_exceptionable, {
283
- path: _path + ".prisma_schemas",
284
- expected: "string",
285
- value: input.prisma_schemas
286
- }), "string" === typeof input.draft_without_date_type || _report(_exceptionable, {
287
- path: _path + ".draft_without_date_type",
268
+ }), "string" === typeof input.prismaSchemas || _report(_exceptionable, {
269
+ path: _path + ".prismaSchemas",
288
270
  expected: "string",
289
- value: input.draft_without_date_type
271
+ value: input.prismaSchemas
290
272
  }), "string" === typeof input.review || _report(_exceptionable, {
291
273
  path: _path + ".review",
292
274
  expected: "string",
293
275
  value: input.review
294
- }), "string" === typeof input.implementationCode || _report(_exceptionable, {
295
- path: _path + ".implementationCode",
276
+ }), "string" === typeof input.final || _report(_exceptionable, {
277
+ path: _path + ".final",
296
278
  expected: "string",
297
- value: input.implementationCode
279
+ value: input.final
298
280
  })].every(flag => flag); const __is = input => "object" === typeof input && null !== input && _io0(input); let errors; let _report; return input => {
299
281
  if (false === __is(input)) {
300
282
  errors = [];
@@ -1 +1 @@
1
- {"version":3,"file":"orchestrateRealizeWrite.js","sourceRoot":"","sources":["../../../src/orchestrate/realize/orchestrateRealizeWrite.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,0DAuEC;;AArFD,yCAA2C;AAG3C,kDAA0B;AAC1B,+BAA0B;AAG1B,uEAAoE;AACpE,+FAA4F;AAG5F,mEAAgE;AAChE,6EAA0E;AAE1E,SAAsB,uBAAuB,CAC3C,GAAyB,EACzB,KAMC;;;QAED,MAAM,OAAO,GAA2D;YACtE,KAAK,EAAE,IAAI;SACZ,CAAC;QAEF,MAAM,GAAG,GAAG,MAAM,IAAA,uCAAkB,EAAC,GAAG,EAAE,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QACpE,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,GAAG,CAAC,UAAU,CAAC;YAC1C,MAAM,EAAE,cAAc;YACtB,SAAS,EAAE,IAAA,+DAA8B,EAAC;gBACxC,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE;g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,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACrC,CAAC;QACF,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACpB,OAAO,KAAK,CAAC;IACf,CAAC;CAAA;AAED,SAAS,gBAAgB,CAAiC,KAGzD;IACC,IAAA,qCAAiB,EAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAE/B,MAAM,WAAW,GAA2B,UAAU,CACpD,KAAK,CAAC,KAAK,CACwD,CAAC;IAEtE,OAAO;QACL,QAAQ,EAAE,OAAO;QACjB,IAAI,EAAE,YAAY;QAClB,WAAW;QACX,OAAO,EAAE;YACP,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;gBACf,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACpB,CAAC;SACuC;KAC3C,CAAC;AACJ,CAAC;AAED,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAGT,CAAC;AACJ,MAAM,UAAU,GAAG;IACjB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAAoE;IAC3E,MAAM;IACN,KAAK,EAAE,MAAM;IACb,QAAQ,EAAE,MAAM;IAChB,KAAK,EAAE,MAAM;CACd,CAAC"}
1
+ {"version":3,"file":"orchestrateRealizeWrite.js","sourceRoot":"","sources":["../../../src/orchestrate/realize/orchestrateRealizeWrite.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,0DAuEC;;AArFD,yCAA2C;AAG3C,kDAA0B;AAC1B,+BAA0B;AAG1B,uEAAoE;AACpE,+FAA4F;AAG5F,mEAAgE;AAChE,6EAA0E;AAE1E,SAAsB,uBAAuB,CA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ChB,KAAK,EAAE,MAAM;CACd,CAAC"}
@@ -21,19 +21,19 @@ export declare namespace IAutoBeRealizeCorrectApplication {
21
21
  revise: IRevise;
22
22
  }
23
23
  interface IRevise {
24
- /** Step 1: Compilation error analysis and resolution strategy. */
24
+ /**
25
+ * Step 1: TypeScript compilation error analysis and resolution strategy.
26
+ * Analyzes TypeScript compiler diagnostics (error codes, messages) to understand
27
+ * type mismatches, missing properties, nullable conflicts, and other compilation issues.
28
+ */
25
29
  errorAnalysis?: string;
26
30
  /** Step 2: Provider function implementation plan. */
27
31
  plan?: string;
28
32
  /** Step 3: Relevant Prisma schema definitions. */
29
33
  prismaSchemas?: string;
30
- /** Step 4: Initial draft without using native Date type. */
31
- draftWithoutDateType?: string;
32
- /** Step 5: Refined version with improved completeness. */
34
+ /** Step 4: Refined version with improved completeness. */
33
35
  review?: string;
34
- /** Step 6: Corrected implementation after compiler feedback. */
35
- withCompilerFeedback?: string;
36
- /** Step 7: Final complete TypeScript function implementation. */
37
- implementationCode: string;
36
+ /** Step 5: Final complete TypeScript function implementation. */
37
+ final: string;
38
38
  }
39
39
  }
@@ -8,288 +8,44 @@ export interface IAutoBeRealizeWriteApplication {
8
8
  * error-free code generation.
9
9
  *
10
10
  * The generation process includes:
11
+ *
11
12
  * 1. Strategic planning based on Prisma schema analysis
12
- * 2. Initial draft without Date type usage
13
+ * 2. Schema definition for relevant models
13
14
  * 3. Review and refinement for completeness
14
- * 4. Compiler feedback integration if errors detected
15
- * 5. Final implementation with all validations and type safety
15
+ * 4. Final implementation with all validations and type safety
16
16
  *
17
- * @param next Properties containing the multi-phase implementation plan and code
17
+ * @param next Properties containing the multi-phase implementation plan and
18
+ * code
18
19
  */
19
20
  coding: (next: IAutoBeRealizeWriteApplication.IProps) => void;
20
21
  }
21
22
  export declare namespace IAutoBeRealizeWriteApplication {
22
23
  /**
23
- * Properties for the Realize Write Application following Chain of Thinking (CoT).
24
+ * Properties for the Realize Write Application following Chain of Thinking
25
+ * (CoT).
24
26
  *
25
- * Each field represents a distinct phase in the reasoning and implementation process,
26
- * building upon the previous step to create a complete, error-free implementation.
27
- * This structured approach ensures clarity, debuggability, and systematic thinking.
27
+ * Each field represents a distinct phase in the implementation process.
28
+ * Detailed guidelines are in REALIZE_WRITE.md.
28
29
  */
29
30
  interface IProps {
30
31
  /**
31
32
  * Step 1 - Planning Phase (CoT: Initial Reasoning)
32
33
  *
33
- * 🧠 Provider Function Implementation Plan
34
- *
35
- * This field outlines the strategic plan for implementing the provider
36
- * function according to the Realize Coder Agent specification. Before
37
- * writing the actual code, think through the logic and structure.
38
- *
39
- * The plan follows a SCHEMA-FIRST APPROACH:
40
- *
41
- * 📋 STEP 1 - PRISMA SCHEMA VERIFICATION:
42
- *
43
- * DO:
44
- *
45
- * - Examine the actual Prisma schema model definition
46
- * - List EVERY field that exists in the model with exact types
47
- * - Explicitly note fields that DO NOT exist
48
- * - Verify database compatibility (PostgreSQL AND SQLite)
49
- *
50
- * DO NOT:
51
- *
52
- * - Assume common fields exist without verification
53
- * - Use fields like deleted_at, created_by, updated_by, is_deleted, is_active
54
- * without checking
55
- * - Use PostgreSQL-specific features like mode: "insensitive"
56
- *
57
- * 📋 STEP 2 - FIELD INVENTORY:
58
- *
59
- * - List ONLY fields confirmed to exist in schema
60
- * - Example: "Verified fields in user model: id (String), email (String),
61
- * created_at (DateTime), updated_at (DateTime)"
62
- * - Example: "Fields that DO NOT exist: deleted_at, is_active, created_by"
63
- *
64
- * 📋 STEP 3 - FIELD ACCESS STRATEGY:
65
- *
66
- * - Plan which verified fields will be used in select, update, create
67
- * operations
68
- * - For complex operations with type errors, plan to use separate queries
69
- * instead of nested operations
70
- *
71
- * 📋 STEP 4 - TYPE COMPATIBILITY:
72
- *
73
- * - Plan DateTime to ISO string conversions using toISOStringSafe()
74
- * - Plan handling of nullable vs required fields
75
- *
76
- * 📋 STEP 5 - IMPLEMENTATION APPROACH:
77
- *
78
- * - 🧩 Required business entities (e.g., users, posts, logs) and their
79
- * relationships
80
- * - 🛠 Operations needed to fulfill the business scenario (e.g., fetch,
81
- * create, update) using ONLY verified fields
82
- * - 🔄 Data dependencies between steps (e.g., use userId to fetch related
83
- * data)
84
- * - ✅ Validation points (based on business rules, not field presence)
85
- * - 🚧 Error and edge cases that must be handled explicitly (e.g., missing
86
- * records)
87
- * - 🏗 Structure: always a single `async function`, using only `parameters`
88
- * and `body`
34
+ * Strategic plan following SCHEMA-FIRST APPROACH:
89
35
  *
90
- * ⚠️ Important Constraints:
36
+ * 1. Verify Prisma schema fields (list existing and non-existing)
37
+ * 2. Plan field usage in operations
38
+ * 3. Plan type conversions and nullable handling
39
+ * 4. Define implementation approach with error handling
91
40
  *
92
- * - Do NOT perform input validation — assume `parameters` and `body` are
93
- * already valid
94
- * - Use `typia.random<T>()` with an explanatory comment if logic can't be
95
- * implemented
96
- * - Never use `any` or make assumptions without sufficient context
97
- * - Use only allowed imports — DTOs and Prisma types
98
- * - Use `MyGlobal.prisma` for DB access and respect Prisma typing rules
99
- *
100
- * ⚠️ TypeScript-specific considerations:
101
- *
102
- * - Do **not** use native `Date` objects directly; always convert all dates
103
- * using `toISOStringSafe()` and brand as `string &
104
- * tags.Format<'date-time'>`. This rule applies throughout all phases.
105
- * - Prefer `satisfies` for DTO conformance instead of unsafe `as` casts
106
- * - Avoid weak typing such as `any`, `as any`, or `satisfies any`
107
- * - Use branded types (e.g., `tags.Format<'uuid'>`) and literal unions where
108
- * applicable
109
- *
110
- * ✅ Example Structure:
111
- *
112
- * ```ts
113
- * export async function doSomething(
114
- * user: { id: string & tags.Format<"uuid">; type: string },
115
- * parameters: IParams,
116
- * body: IBody
117
- * ): Promise<IReturn> {
118
- * const { id } = parameters;
119
- * const { name } = body;
120
- * const user = await MyGlobal.prisma.users.findFirst({ where: { id } });
121
- * if (!user) throw new Error("User not found");
122
- * ...
123
- * return result;
124
- * }
125
- * ```
126
- *
127
- * 🔍 Feasibility Analysis Requirement:
128
- *
129
- * - Before generating any code, the agent **must analyze** whether the
130
- * requested implementation is **feasible based on the given Prisma schema
131
- * and DTO types**.
132
- * - If required fields or relationships are **missing or incompatible**, the
133
- * plan should explicitly state that the implementation is **not
134
- * possible** with the current schema/DTO, and no code should be generated
135
- * in later stages.
136
- * - In such cases, only a detailed **comment in the `implementationCode`**
137
- * should be returned explaining why the logic cannot be implemented.
138
- *
139
- * 🔥 Error Handling Plan:
140
- *
141
- * If an error is expected or encountered during implementation:
142
- *
143
- * - Clearly document the error message(s) and TypeScript error codes.
144
- * - Analyze the root cause (e.g., type mismatch, missing field, nullability
145
- * issue).
146
- * - Define concrete steps to resolve the issue, such as:
147
- *
148
- * - Adjusting type declarations or using Prisma-generated input types.
149
- * - Using `?? undefined` to normalize nullable fields.
150
- * - Applying correct relation handling (e.g., `connect` instead of direct
151
- * foreign key assignment).
152
- * - Ensuring all date fields use `.toISOString()` and proper branding.
153
- * - Include fallback or workaround plans if a direct fix is complex.
154
- * - If no error is present, simply omit this section.
155
- *
156
- * This plan ensures the function will:
157
- *
158
- * - Respect the global architecture and coding conventions
159
- * - Be safe, predictable, and aligned with upstream logic
41
+ * See REALIZE_WRITE.md for detailed requirements.
160
42
  */
161
43
  plan: string;
162
- /**
163
- * Step 2 - Schema Definition (CoT: Context Establishment)
164
- *
165
- * The Prisma schema string that will be used to validate the implementation
166
- * logic in this file.
167
- *
168
- * You must **explicitly specify only the relevant models and fields** from
169
- * your full schema that are used in this implementation. This ensures that
170
- * your logic is aligned with the expected database structure without
171
- * accidentally introducing unrelated fields or models.
172
- *
173
- * ⚠️ Important: The value of this field must be a valid Prisma schema
174
- * string containing only the models used in this code — not the entire
175
- * schema.
176
- *
177
- * This acts as a safeguard against:
178
- *
179
- * - Forgetting required fields used in this implementation
180
- * - Including fields or models that are not actually used
181
- */
182
- prisma_schemas: string;
183
- /**
184
- * Step 3 - Initial Draft (CoT: First Implementation Attempt)
185
- *
186
- * Draft WITHOUT using native Date type.
187
- *
188
- * This is the initial drafting phase where you outline the basic skeleton
189
- * of the function.
190
- *
191
- * DO NOT: Use the native Date type.
192
- *
193
- * - The function signature must correctly include `user`, `parameters`, and
194
- * `body` arguments.
195
- * - Design the main flow of business logic, such as DB fetches and early
196
- * returns based on conditions.
197
- * - Mark any incomplete or missing parts clearly with placeholders (e.g.,
198
- * comments or temporary values).
199
- *
200
- * Import rules:
201
- *
202
- * DO NOT:
203
- *
204
- * - Add any new import statements manually
205
- * - Write import statements directly (this causes compile errors)
206
- *
207
- * Note: All necessary imports are provided globally or by the system
208
- * automatically.
209
- *
210
- * ✅ Requirements:
211
- *
212
- * - Avoid using the `any` type at all costs to ensure type safety.
213
- * - NEVER declare variables with `: Date` type
214
- * - ALWAYS use `string & tags.Format<'date-time'>` for date values
215
- * - Use `toISOStringSafe(new Date())` for current timestamps
216
- * - Maintain a single-function structure; avoid using classes.
217
- */
218
- draft_without_date_type: string;
219
- /**
220
- * Step 4 - Review and Refinement (CoT: Self-Reflection)
221
- *
222
- * A refined version of the draft with improved completeness.
223
- *
224
- * - Replace placeholder logic with real DTO-conformant operations.
225
- * - Add error handling (`throw new Error(...)`) where necessary.
226
- * - Begin resolving structural or type mismatches.
227
- *
228
- * ✅ Requirements:
229
- *
230
- * - Use `satisfies` to ensure DTO conformity.
231
- * - Avoid unsafe `as` casts unless only for branding or literal narrowing.
232
- * - Use `toISOStringSafe()` for all date conversions (NOT `.toISOString()`).
233
- * - Ensure all object keys strictly conform to the expected type definitions.
234
- * - NEVER use `mode: "insensitive"` in string operations (breaks SQLite).
235
- */
44
+ /** Step 2 - Relevant Prisma schema models and fields */
45
+ prismaSchemas: string;
46
+ /** Step 3 - Refined version with real operations */
236
47
  review: string;
237
- /**
238
- * Step 5 - Complete Implementation (CoT: Final Synthesis)
239
- *
240
- * The complete and fully correct TypeScript function implementation.
241
- *
242
- * - Passes strict type checking without errors.
243
- * - Uses only safe branding or literal type assertions.
244
- * - Converts all date values properly using `toISOStringSafe()`.
245
- * - Follows DTO structures using `satisfies`.
246
- * - Avoids any weak typing such as `any`, `as any`, or `satisfies any`.
247
- * - Uses only allowed imports (e.g., from `../api/structures` and
248
- * `MyGlobal.prisma`).
249
- * - NEVER creates intermediate variables for Prisma operations.
250
- * - NEVER uses `mode: "insensitive"` (PostgreSQL-only, breaks SQLite).
251
- *
252
- * ⚠️ Fallback Behavior:
253
- *
254
- * - If the `plan` phase explicitly determines that the requested logic is
255
- * **not feasible** due to mismatches or limitations in the provided
256
- * Prisma schema and DTO types:
257
- *
258
- * - The implementation must still return a syntactically valid function.
259
- * - In such cases, return mock data using `typia.random<T>()` wrapped in the
260
- * correct structure, along with a comment explaining the limitation.
261
- *
262
- * Example fallback:
263
- *
264
- * ```ts
265
- * // ⚠️ Cannot implement logic due to missing relation between A and B
266
- * export async function someFunction(...) {
267
- * return typia.random<IReturn>(); // mocked output
268
- * }
269
- * ```
270
- *
271
- * ⚠️ Prohibited Practices:
272
- *
273
- * - Do NOT add or modify import statements manually. Imports are handled
274
- * automatically by the system.
275
- * - Do NOT use `any`, `as any`, or `satisfies any` to bypass type checking.
276
- * - Do NOT assign native `Date` objects directly; always convert them using
277
- * `toISOStringSafe()`.
278
- * - Do NOT use unsafe type assertions except for safe branding or literal
279
- * narrowing.
280
- * - Do NOT write code outside the single async function structure (e.g., no
281
- * classes or multiple functions).
282
- * - Do NOT perform any input validation — assume all inputs are already
283
- * validated.
284
- * - Do NOT use dynamic import expressions (`import()`); all imports must be
285
- * static.
286
- * - Do NOT use Prisma-generated input types; always use types from
287
- * `../api/structures`.
288
- * - Do NOT use `Object.prototype.hasOwnProperty.call()` for field checks.
289
- * - Do NOT escape newlines or quotes in the implementation string (e.g., no
290
- * `\\n` or `\"`); use a properly formatted template literal with actual
291
- * line breaks instead.
292
- */
293
- implementationCode: string;
48
+ /** Step 4 - Final implementation See REALIZE_WRITE.md for requirements */
49
+ final: string;
294
50
  }
295
51
  }
@@ -0,0 +1,13 @@
1
+ import { IAutoBeRealizeFunctionFailure } from "../structures/IAutoBeRealizeFunctionFailure";
2
+ /**
3
+ * Filter diagnostic failures to only include those matching the given
4
+ * locations.
5
+ *
6
+ * @param failures - Array of function failures with diagnostic information
7
+ * @param locations - Array of file locations to filter by
8
+ * @returns Filtered array of failures matching the specified locations
9
+ * @warning This function assumes f.function and f.function.location are always defined.
10
+ * If f.function is undefined, this will throw a runtime error.
11
+ * Consider using optional chaining: f.function?.location
12
+ */
13
+ export declare function filterDiagnostics(failures: IAutoBeRealizeFunctionFailure[], locations: string[]): IAutoBeRealizeFunctionFailure[];
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.filterDiagnostics = filterDiagnostics;
4
+ /**
5
+ * Filter diagnostic failures to only include those matching the given
6
+ * locations.
7
+ *
8
+ * @param failures - Array of function failures with diagnostic information
9
+ * @param locations - Array of file locations to filter by
10
+ * @returns Filtered array of failures matching the specified locations
11
+ * @warning This function assumes f.function and f.function.location are always defined.
12
+ * If f.function is undefined, this will throw a runtime error.
13
+ * Consider using optional chaining: f.function?.location
14
+ */
15
+ function filterDiagnostics(failures, locations) {
16
+ return failures
17
+ .filter((f) => f.function.location.startsWith("src/providers"))
18
+ .filter((f) => locations.includes(f.function.location));
19
+ }
20
+ //# sourceMappingURL=filterDiagnostics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filterDiagnostics.js","sourceRoot":"","sources":["../../../../src/orchestrate/realize/utils/filterDiagnostics.ts"],"names":[],"mappings":";;AAaA,8CAOC;AAlBD;;;;;;;;;;GAUG;AACH,SAAgB,iBAAiB,CAC/B,QAAyC,EACzC,SAAmB;IAEnB,OAAO,QAAQ;SACZ,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;SAC9D,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC5D,CAAC"}