-
Notifications
You must be signed in to change notification settings - Fork 89
feat(compiler): new README of generated #803
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request refactors the backend agent's file generation pipeline to use a unified approach for template management and options handling. The main purpose is to consolidate template access through a single getTemplate method on the compiler interface, enhance README generation with dynamic status emojis and benchmarking metrics, and improve code maintainability.
Key changes:
- Renamed
stagetophaseinIAutoBeGetFilesOptionsand refactoredgetAutoBeGeneratedto accept a props object instead of individual parameters - Consolidated template access by moving
getTemplatemethods from individual compilers (interface, test, realize) to a unified method onIAutoBeCompiler - Enhanced README template with dynamic placeholder replacement for phase status emojis and benchmark metrics (aggregate and function-calling statistics)
Reviewed Changes
Copilot reviewed 24 out of 28 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
packages/interface/src/facade/IAutoBeGetFilesOptions.ts |
Renamed stage property to phase for clarity |
packages/interface/src/compiler/IAutoBeCompiler.ts |
Added unified getTemplate method accepting Required<IAutoBeGetFilesOptions> |
packages/interface/src/compiler/IAutoBeInterfaceCompiler.ts |
Updated write method to accept exclude parameter; removed individual getTemplate method |
packages/interface/src/compiler/IAutoBeTestCompiler.ts |
Removed getTemplate method (moved to parent interface) |
packages/interface/src/compiler/IAutoBeRealizeCompiler.ts |
Removed getTemplate method (moved to parent interface) |
packages/compiler/src/AutoBeCompiler.ts |
Implemented unified getTemplate method with phase-based template composition |
packages/compiler/src/interface/AutoBeInterfaceCompiler.ts |
Implemented exclude filtering; removed template spreading from write method |
packages/compiler/src/test/AutoBeTestCompiler.ts |
Removed getTemplate method implementation |
packages/compiler/src/realize/AutoBeRealizeCompiler.ts |
Removed getTemplate method implementation |
packages/compiler/build/template.ts |
Added build step for common template generation |
packages/agent/src/factory/getAutoBeGenerated.ts |
Refactored to use props object; added README placeholder replacement and benchmark helper functions |
packages/agent/src/factory/getAutoBeRealizeGenerated.ts |
Removed template spreading (now handled by caller) |
packages/agent/src/factory/getCriticalCompiler.ts |
Updated to use new unified getTemplate method and updated write signature |
packages/agent/src/AutoBeAgentBase.ts |
Updated getFiles call to use props object pattern |
packages/agent/src/orchestrate/test/compile/getTestScenarioArtifacts.ts |
Updated interface.write call to include empty exclude array |
packages/agent/src/orchestrate/realize/utils/getRealizeWriteDto.ts |
Updated interface.write call to include empty exclude array |
packages/agent/src/orchestrate/realize/orchestrateRealizeAuthorizationWrite.ts |
Updated to use unified getTemplate method |
packages/agent/src/orchestrate/realize/internal/compileRealizeFiles.ts |
Updated to use unified getTemplate method |
test/src/features/compiler/test_compiler_interface_write.ts |
Updated interface.write call to include empty exclude array |
test/src/features/compiler/test_compiler_interface_name.ts |
Updated interface.write call to include empty exclude array |
test/src/features/realize/internal/validate_agent_realize_correct.ts |
Updated to use unified getTemplate method with phase parameter |
test/src/features/realize/internal/validate_agent_realize_authorization_correct.ts |
Updated to use unified getTemplate method with phase parameter; added explicit type annotation |
test/src/features/realize/internal/validate_agent_realize_authorization.ts |
Updated to use unified getTemplate method with phase parameter; added explicit type annotation |
internals/template/common/README.md |
Enhanced with dynamic placeholder replacement for phase emojis and benchmark tables |
internals/template/common/LICENSE |
Added MIT license file for generated projects |
internals/template/common/.gitignore |
Added gitignore configuration for generated projects |
internals/template/common/.eslintrc.cjs |
Added ESLint configuration for generated projects |
internals/template/common/typos.toml |
Added typos spell checker configuration for generated projects |
Comments suppressed due to low confidence (1)
internals/template/common/README.md:120
- There's a spelling error in the column header. "Succcess" should be "Success" (three 'c's instead of two).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| authorizations: props.state.realize.authorizations, | ||
| functions: props.state.realize.functions, | ||
| options: { | ||
| dbms: options?.dbms ?? "postgres", |
Copilot
AI
Nov 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent variable reference. This uses options?.dbms ?? "postgres" which refers to props.options, but the local options variable (line 25) is of type Required<IAutoBeGetFilesOptions> with a guaranteed dbms property. Change this to options.dbms to use the local variable consistently.
| dbms: options?.dbms ?? "postgres", | |
| dbms: options.dbms, |
| ), | ||
| ); | ||
| if (options?.stage === "analyze") return ret; | ||
| if (props.options?.phase === "analyze") return ret; |
Copilot
AI
Nov 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent variable reference. This uses props.options?.phase but the local options variable (line 25) is of type Required<IAutoBeGetFilesOptions> with a guaranteed phase property. Change this to options.phase to use the local variable consistently.
| if (props.options?.phase === "analyze") return ret; | |
| if (options.phase === "analyze") return ret; |
| props.state.prisma.compiled.reason; | ||
| } | ||
| if (options?.stage === "prisma") return ret; | ||
| if (props.options?.phase === "prisma") return ret; |
Copilot
AI
Nov 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent variable reference. This uses props.options?.phase but the local options variable (line 25) is of type Required<IAutoBeGetFilesOptions> with a guaranteed phase property. Change this to options.phase to use the local variable consistently.
| ); | ||
| } | ||
| if (options?.stage === "interface") return ret; | ||
| if (props.options?.phase === "interface") return ret; |
Copilot
AI
Nov 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent variable reference. This uses props.options?.phase but the local options variable (line 25) is of type Required<IAutoBeGetFilesOptions> with a guaranteed phase property. Change this to options.phase to use the local variable consistently.
| import { AutoBeCompilerCommonTemplate } from "./raw/AutoBeCompilerCommonTemplate"; | ||
| import { AutoBeCompilerInterfaceTemplate } from "./raw/AutoBeCompilerInterfaceTemplate"; | ||
| import { AutoBeCompilerRealizeTemplateOfPostgres } from "./raw/AutoBeCompilerRealizeTemplateOfPostgres"; | ||
| import { AutoBeCompilerRealizeTemplateOfSQLite } from "./raw/AutoBeCompilerRealizeTemplateOfSQLite"; | ||
| import { AutoBeCompilerTestTemplate } from "./raw/AutoBeCompilerTestTemplate"; |
Copilot
AI
Nov 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AutoBeCompilerRealizeTemplate is not imported but is needed in the getTemplate method (lines 71-76) to include the base realize template files. The import statement should be added: import { AutoBeCompilerRealizeTemplate } from "./raw/AutoBeCompilerRealizeTemplate";
| if (options.phase === "realize") | ||
| Object.assign( | ||
| result, | ||
| options.dbms === "postgres" | ||
| ? AutoBeCompilerRealizeTemplateOfPostgres | ||
| : AutoBeCompilerRealizeTemplateOfSQLite, | ||
| ); |
Copilot
AI
Nov 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing base realize template. Before adding the dbms-specific templates, the base AutoBeCompilerRealizeTemplate should be included. Add Object.assign(result, AutoBeCompilerRealizeTemplate); before the conditional dbms-specific template assignment.
| }), | ||
| ); | ||
| if (options?.stage === "test") return ret; | ||
| if (props.options?.phase === "test") return ret; |
Copilot
AI
Nov 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent variable reference. This uses props.options?.phase but the local options variable (line 25) is of type Required<IAutoBeGetFilesOptions> with a guaranteed phase property. Change this to options.phase to use the local variable consistently.
| value.metric.validationFailure.toLocaleString(), | ||
| value.metric.invalidJson.toLocaleString(), | ||
| value.metric.success.toLocaleString(), | ||
| ((value.metric.success / value.metric.attempt) * 100).toFixed(2) + " %", |
Copilot
AI
Nov 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential division by zero. If value.metric.attempt is 0, this will produce NaN. Consider adding a check: value.metric.attempt > 0 ? ((value.metric.success / value.metric.attempt) * 100).toFixed(2) + " %" : "0.00 %".
| ((value.metric.success / value.metric.attempt) * 100).toFixed(2) + " %", | |
| value.metric.attempt > 0 | |
| ? ((value.metric.success / value.metric.attempt) * 100).toFixed(2) + " %" | |
| : "0.00 %", |
| const schemaFiles: Record<string, string> = | ||
| (options?.dbms ?? "postgres") === "postgres" | ||
| ? state.prisma.schemas | ||
| : await compiler.prisma.write(state.prisma.result.data, options!.dbms!); | ||
| ? props.state.prisma.schemas | ||
| : await props.compiler.prisma.write( | ||
| props.state.prisma.result.data, | ||
| options!.dbms!, | ||
| ); |
Copilot
AI
Nov 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable shadowing issue. This code uses options?.dbms ?? "postgres" and options!.dbms! which refer to props.options, but a local options variable of type Required<IAutoBeGetFilesOptions> is defined at line 25 with a guaranteed dbms property. This code should use the local options.dbms instead to avoid the optional chaining and non-null assertions.
| authorizations: props.state.realize.authorizations, | ||
| functions: props.state.realize.functions, | ||
| options: { | ||
| dbms: options?.dbms ?? "postgres", |
Copilot
AI
Nov 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable reference is inconsistent with the local options that was created at the top of the function. This line uses options?.dbms ?? "postgres" when it should just use options.dbms since options is already guaranteed to have a dbms property (defined as Required<IAutoBeGetFilesOptions>).
| dbms: options?.dbms ?? "postgres", | |
| dbms: options.dbms, |
This pull request introduces several improvements and refactoring to the backend agent codebase, focusing on template generation, phase handling, and benchmarking. The main changes include a refactor of the file generation pipeline to use a unified options object, enhanced README generation with dynamic benchmarking and status emojis, and consolidation of template access methods. These updates improve code clarity, flexibility, and provide better visibility into the agent's workflow and performance.
Template Generation and Phase Handling
getAutoBeGeneratedto accept a single props object instead of multiple parameters, and to use a unifiedphaseoption for determining which files to generate. This simplifies usage and makes phase selection explicit. [1] [2]getTemplatemethod, reducing duplicated logic and improving maintainability. [1] [2] [3]README and Benchmark Enhancements
Interface and Test File Generation
writemethod to accept an exclusion list, allowing selective file generation and simplifying downstream usage in orchestrators and DTO generation. [1] [2] [3]Build and Template Management
These changes collectively improve the flexibility, maintainability, and visibility of the backend agent's code and outputs.