Skip to content
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

PROD <- SB #2208

Merged
12 commits merged into from
Mar 14, 2024
Merged

PROD <- SB #2208

12 commits merged into from
Mar 14, 2024

Conversation

Blokh
Copy link
Collaborator

@Blokh Blokh commented Mar 14, 2024

User description

invokedAt fix


Type

enhancement, bug_fix


Description

  • Introduced setTimeToRecordUTC method in HelpersTransformer class and added tests for it.
  • Enhanced Case Creation display in backoffice-v2 with fallbacks and formatting.
  • Fixed invokedAt parsing in Workflow Service to ensure correct date handling.
  • Updated dependencies across multiple packages and services, including workflow-core, workflow-browser-sdk, and workflow-node-sdk.
  • Added optional displayName field to WorkflowDefinition model and created a corresponding database migration.

Changes walkthrough

Relevant files
Enhancement
7 files
CaseCreation.tsx
Enhance Case Creation Display with Fallbacks and Formatting

apps/backoffice-v2/src/pages/Entities/components/CaseCreation/CaseCreation.tsx

  • Added utility imports (valueOrNA, ctw, titleCase) for better data
    handling and display.
  • Replaced direct workflow definition name usage with a formatted and
    fallback-supported name display.
  • Utilized utility functions to handle potentially undefined values
    gracefully.
  • +21/-6   
    Entities.page.tsx
    Refactor Entities Page for Conditional Case Creation Rendering

    apps/backoffice-v2/src/pages/Entities/Entities.page.tsx

  • Renamed showCaseCreation to isManualCaseCreationEnabled for clarity.
  • Conditionally rendered CaseCreation component based on manual case
    creation flag.
  • +4/-4     
    helpers-transformer.ts
    Introduce New Helper Method for UTC Time Setting                 

    packages/workflow-core/src/lib/utils/context-transformers/helpers-transformer.ts

  • Introduced setTimeToRecordUTC method in HelpersTransformer class.
  • +11/-1   
    useEntities.tsx
    Refactor useEntities Hook for Manual Case Creation Flag   

    apps/backoffice-v2/src/pages/Entities/hooks/useEntities/useEntities.tsx

  • Removed unused showCaseCreation flag.
  • Added isManualCaseCreationEnabled to hook return value for conditional
    rendering logic.
  • +1/-1     
    api-plugin.ts
    Remove Redundant `invokedAt` from API Plugin Success Response

    packages/workflow-core/src/lib/plugins/external-plugin/api-plugin.ts

  • Removed invokedAt from the success response object to avoid
    redundancy.
  • +1/-4     
    schema.prisma
    Add Optional DisplayName Field to WorkflowDefinition Model

    services/workflows-service/prisma/schema.prisma

    • Added optional displayName field to WorkflowDefinition model.
    +1/-0     
    migration.sql
    Database Migration for DisplayName in WorkflowDefinition 

    services/workflows-service/prisma/migrations/20240314123948_definition_display_name/migration.sql

  • SQL migration to add displayName column to WorkflowDefinition table.
  • +2/-0     
    Tests
    1 files
    helpers-transformer.test.ts
    Add Tests for New `setTimeToRecordUTC` Helper Method         

    packages/workflow-core/src/lib/utils/context-transformers/helpers-transformer.test.ts

    • Added tests for setTimeToRecordUTC helper method.
    +25/-0   
    Configuration changes
    1 files
    user-session-audit.middleware.intg.test.ts
    Update Import Path for PrismaService in Middleware Test   

    services/workflows-service/src/common/middlewares/user-session-audit.middleware.intg.test.ts

    • Updated import path for PrismaService.
    +1/-1     
    Bug fix
    1 files
    workflow.service.ts
    Fix `invokedAt` Parsing in Workflow Service                           

    services/workflows-service/src/workflow/workflow.service.ts

  • Fixed handling of invokedAt to ensure it is parsed as a number before
    converting to a date.
  • +6/-2     
    Dependencies
    7 files
    package.json
    Update Dependencies and Version for Workflow-Service         

    services/workflows-service/package.json

  • Updated version and dependencies for workflow-service.
  • Removed unused dependencies.
  • +6/-20   
    package.json
    Update Dependencies and Version for Backoffice-v2               

    apps/backoffice-v2/package.json

    • Updated version and dependencies for backoffice-v2.
    +3/-3     
    package.json
    Update Dependencies and Version for KYB-App                           

    apps/kyb-app/package.json

    • Updated version and dependencies for kyb-app.
    +2/-2     
    package.json
    Update Dependencies and Version for Headless-Example         

    examples/headless-example/package.json

    • Updated version and dependencies for headless-example.
    +2/-2     
    package.json
    Update Dependencies and Version for Workflow-Browser-SDK 

    sdks/workflow-browser-sdk/package.json

    • Updated version and dependencies for workflow-browser-sdk.
    +2/-2     
    package.json
    Update Dependencies and Version for Workflow-Node-SDK       

    sdks/workflow-node-sdk/package.json

    • Updated version and dependencies for workflow-node-sdk.
    +2/-2     
    package.json
    Update Version for Workflow-Core                                                 

    packages/workflow-core/package.json

    • Updated version for workflow-core.
    +1/-1     

    PR-Agent usage:
    Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    MatanYadaev and others added 12 commits March 13, 2024 11:24
    * fix: removed hardcoded invoked at from plugins
    
    * fix: fixed tests
    * fix: removed hardcoded invoked at from plugins
    
    * fix: fixed tests
    Co-authored-by: Alon Peretz <Alonp99@gmail.com>
    * refactor(backoffice-v2): changed case creation to use displayName over name
    
    * refactor(backoffice-v2): changed fallback of display name
    Copy link

    changeset-bot bot commented Mar 14, 2024

    ⚠️ No Changeset found

    Latest commit: 5b5aece

    Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

    This PR includes no changesets

    When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

    Click here to learn what changesets are, and how to add one.

    Click here if you're a maintainer who wants to add a changeset to this PR

    @Blokh Blokh self-assigned this Mar 14, 2024
    @Blokh Blokh requested a review from alonp99 March 14, 2024 14:52
    @github-actions github-actions bot added enhancement New feature or request bug_fix labels Mar 14, 2024
    Copy link
    Contributor

    PR Description updated to latest commit (b99f84b)

    1 similar comment
    Copy link
    Contributor

    PR Description updated to latest commit (b99f84b)

    Copy link
    Contributor

    github-actions bot commented Mar 14, 2024

    PR Review

    (Review updated until commit b99f84b)

    ⏱️ Estimated effort to review [1-5]

    4, due to the extensive changes across multiple files and packages, including backend and frontend modifications, database schema updates, and dependency updates. The PR encompasses enhancements, bug fixes, and updates that span across the application's architecture, requiring a thorough review of code logic, integration points, and potential side effects.

    🧪 Relevant tests

    Yes

    🔍 Possible issues

    Possible Bug: The setTimeToRecordUTC method in HelpersTransformer class returns new Date().getUTCDate() which only provides the day of the month in UTC. This might not be the intended behavior as it does not return a full UTC date-time. Consider using new Date().toISOString() or Date.now() for a full date-time.

    Inconsistent Naming: The renaming of showCaseCreation to isManualCaseCreationEnabled in some files but not updating all instances might lead to confusion or bugs. Ensure consistent naming across the entire codebase.

    🔒 Security concerns

    No

    Code feedback:
    relevant filepackages/workflow-core/src/lib/utils/context-transformers/helpers-transformer.ts
    suggestion      

    Replace return new Date().getUTCDate(); with return Date.now(); to ensure the method returns the full UTC timestamp instead of just the day of the month. This change is important to maintain consistency in date handling across the application. [important]

    relevant linereturn new Date().getUTCDate();

    relevant fileservices/workflows-service/src/workflow/workflow.service.ts
    suggestion      

    Ensure that pluginValue.invokedAt is correctly parsed as a number before creating a new Date object. Consider adding a validation or a fallback mechanism if pluginValue.invokedAt is not a valid number. This is crucial to avoid runtime errors in date parsing. [important]

    relevant lineconst parsedDate = new Date(Number(pluginValue.invokedAt));

    relevant fileapps/backoffice-v2/src/pages/Entities/components/CaseCreation/CaseCreation.tsx
    suggestion      

    Consider adding error handling or a fallback UI rendering logic when workflowDefinitionName is not available. This ensures that the UI gracefully handles scenarios where workflow definition names or display names are missing or undefined. [medium]

    relevant line{valueOrNA(workflowDefinitionName)}

    relevant fileservices/workflows-service/src/common/middlewares/user-session-audit.middleware.intg.test.ts
    suggestion      

    Update the import statement for PrismaService to ensure consistency across the test files. This change improves maintainability and readability of the codebase. [medium]

    relevant lineimport { PrismaService } from '@/prisma/prisma.service';


    ✨ Review tool usage guide:

    Overview:
    The review tool scans the PR code changes, and generates a PR review. The tool can be triggered automatically every time a new PR is opened, or can be invoked manually by commenting on any PR.
    When commenting, to edit configurations related to the review tool (pr_reviewer section), use the following template:

    /review --pr_reviewer.some_config1=... --pr_reviewer.some_config2=...
    

    With a configuration file, use the following template:

    [pr_reviewer]
    some_config1=...
    some_config2=...
    
    Utilizing extra instructions

    The review tool can be configured with extra instructions, which can be used to guide the model to a feedback tailored to the needs of your project.

    Be specific, clear, and concise in the instructions. With extra instructions, you are the prompter. Specify the relevant sub-tool, and the relevant aspects of the PR that you want to emphasize.

    Examples for extra instructions:

    [pr_reviewer] # /review #
    extra_instructions="""
    In the 'possible issues' section, emphasize the following:
    - Does the code logic cover relevant edge cases?
    - Is the code logic clear and easy to understand?
    - Is the code logic efficient?
    ...
    """
    

    Use triple quotes to write multi-line instructions. Use bullet points to make the instructions more readable.

    How to enable\disable automation
    • When you first install PR-Agent app, the default mode for the review tool is:
    pr_commands = ["/review", ...]
    

    meaning the review tool will run automatically on every PR, with the default configuration.
    Edit this field to enable/disable the tool, or to change the used configurations

    Auto-labels

    The review tool can auto-generate two specific types of labels for a PR:

    • a possible security issue label, that detects possible security issues (enable_review_labels_security flag)
    • a Review effort [1-5]: x label, where x is the estimated effort to review the PR (enable_review_labels_effort flag)
    Extra sub-tools

    The review tool provides a collection of possible feedbacks about a PR.
    It is recommended to review the possible options, and choose the ones relevant for your use case.
    Some of the feature that are disabled by default are quite useful, and should be considered for enabling. For example:
    require_score_review, require_soc2_ticket, and more.

    Auto-approve PRs

    By invoking:

    /review auto_approve
    

    The tool will automatically approve the PR, and add a comment with the approval.

    To ensure safety, the auto-approval feature is disabled by default. To enable auto-approval, you need to actively set in a pre-defined configuration file the following:

    [pr_reviewer]
    enable_auto_approval = true
    

    (this specific flag cannot be set with a command line argument, only in the configuration file, committed to the repository)

    You can also enable auto-approval only if the PR meets certain requirements, such as that the estimated_review_effort is equal or below a certain threshold, by adjusting the flag:

    [pr_reviewer]
    maximal_review_effort = 5
    
    More PR-Agent commands

    To invoke the PR-Agent, add a comment using one of the following commands:

    • /review: Request a review of your Pull Request.
    • /describe: Update the PR title and description based on the contents of the PR.
    • /improve [--extended]: Suggest code improvements. Extended mode provides a higher quality feedback.
    • /ask <QUESTION>: Ask a question about the PR.
    • /update_changelog: Update the changelog based on the PR's contents.
    • /add_docs 💎: Generate docstring for new components introduced in the PR.
    • /generate_labels 💎: Generate labels for the PR based on the PR's contents.
    • /analyze 💎: Automatically analyzes the PR, and presents changes walkthrough for each component.

    See the tools guide for more details.
    To list the possible configuration parameters, add a /config comment.

    See the review usage page for a comprehensive guide on using this tool.

    Copy link
    Contributor

    github-actions bot commented Mar 14, 2024

    PR Code Suggestions

    CategorySuggestions                                                                                                                                                       
    Enhancement
    Change displayName to be optional instead of nullable.

    Consider making displayName optional instead of nullable if there's no specific need for
    it to explicitly hold a null value. This can simplify checks and usage throughout the
    code.

    apps/backoffice-v2/src/domains/workflow-definitions/fetchers.ts [28]

    -displayName: z.string().nullable(),
    +displayName: z.string().optional(),
     
    Add descriptions to changelog entries for clarity.

    To maintain consistency and clarity in your changelog, consider using a uniform format for
    all entries. The entries for versions 0.5.52, 0.5.51, and 0.5.50 mention
    "@ballerine/workflow-browser-sdk" updates but do not specify what changes were made.
    Including a brief description of the changes can provide more context to the reader.

    examples/headless-example/CHANGELOG.md [7]

    -- @ballerine/workflow-browser-sdk@0.5.52
    +- Updated @ballerine/workflow-browser-sdk to 0.5.52 to include [specific changes or improvements].
     
    Provide detailed descriptions of patch changes.

    For the "Patch Changes" section, it's beneficial to provide more detailed descriptions of
    the changes made. For instance, "fix invoked at" could be expanded to explain what issue
    was fixed or how the behavior was improved.

    packages/workflow-core/CHANGELOG.md [7]

    -- fix invoked at
    +- Fixed an issue where the 'invokedAt' property was incorrectly set, ensuring accurate timestamps.
     
    Maintainability
    Simplify conditional class assignment for readability.

    To improve readability and maintainability, consider extracting the conditional class
    logic into a separate function or utilizing a more concise approach with a template
    literal.

    apps/backoffice-v2/src/pages/Entities/Entities.page.tsx [42-43]

    -'h-[calc(100vh-300px)]': isManualCaseCreationEnabled,
    -'h-[calc(100vh-240px)]': !isManualCaseCreationEnabled,
    +`h-[calc(100vh-${isManualCaseCreationEnabled ? '300' : '240'}px)]`
     
    Best practice
    Ensure string existence before applying titleCase.

    Instead of using titleCase directly on potentially undefined values, ensure that
    workflowDefinition?.name is a string before applying transformations. This prevents
    passing undefined to titleCase, which may lead to unexpected behavior.

    apps/backoffice-v2/src/pages/Entities/components/CaseCreation/CaseCreation.tsx [17]

    -workflowDefinition?.displayName || titleCase(workflowDefinition?.name ?? '');
    +workflowDefinition?.displayName || (workflowDefinition?.name ? titleCase(workflowDefinition.name) : '');
     
    Avoid returning empty objects in favor of null or descriptive objects.

    Returning an empty object might be misleading if the consumer expects specific properties.
    Consider returning null or a more descriptive object indicating the absence of data.

    packages/workflow-core/src/lib/plugins/external-plugin/api-plugin.ts [92]

    -return {};
    +return null; // Or return { message: 'No action required' };
     
    Use more specific version ranges for dependencies.

    Consider using a more specific version range for your dependencies to ensure compatibility
    and prevent automatic updates to versions that might introduce breaking changes. For
    example, instead of using "^0.7.49" for "@ballerine/common", you could specify a more
    controlled version range or an exact version.

    apps/kyb-app/package.json [18]

    -"@ballerine/common": "^0.7.49",
    +"@ballerine/common": "0.7.49",
     
    Use tilde version range for dependencies for better update control.

    It's a good practice to keep your dependencies up to date, but also to ensure that major
    versions are explicitly updated after testing for compatibility. The dependency
    "@nestjs/common" is currently using a caret (^) version range, which automatically updates
    to newer major versions. Consider using a tilde (~) range or an exact version for better
    control over updates.

    services/workflows-service/package.json [50]

    -"@nestjs/common": "^9.3.12",
    +"@nestjs/common": "~9.3.12",
     
    Consider making new fields required if applicable.

    When adding new fields to your Prisma schema, consider if they should be required or
    optional. The displayName field is currently optional. If every WorkflowDefinition is
    expected to have a displayName, you should make this field required by removing the ?.

    services/workflows-service/prisma/schema.prisma [149]

    -displayName     String?
    +displayName     String
     
    Bug
    Validate invokedAt before converting to Date.

    Ensure pluginValue.invokedAt is a valid number before creating a Date object to avoid
    runtime errors with invalid dates.

    services/workflows-service/src/workflow/workflow.service.ts [293]

    -const parsedDate = new Date(Number(pluginValue.invokedAt));
    +const invokedAt = Number(pluginValue.invokedAt);
    +const parsedDate = !isNaN(invokedAt) ? new Date(invokedAt) : new Date();
     

    ✨ Improve tool usage guide:

    Overview:
    The improve tool scans the PR code changes, and automatically generates suggestions for improving the PR code. The tool can be triggered automatically every time a new PR is opened, or can be invoked manually by commenting on a PR.
    When commenting, to edit configurations related to the improve tool (pr_code_suggestions section), use the following template:

    /improve --pr_code_suggestions.some_config1=... --pr_code_suggestions.some_config2=...
    

    With a configuration file, use the following template:

    [pr_code_suggestions]
    some_config1=...
    some_config2=...
    
    Enabling\disabling automation

    When you first install the app, the default mode for the improve tool is:

    pr_commands = ["/improve --pr_code_suggestions.summarize=true", ...]
    

    meaning the improve tool will run automatically on every PR, with summarization enabled. Delete this line to disable the tool from running automatically.

    Utilizing extra instructions

    Extra instructions are very important for the improve tool, since they enable to guide the model to suggestions that are more relevant to the specific needs of the project.

    Be specific, clear, and concise in the instructions. With extra instructions, you are the prompter. Specify relevant aspects that you want the model to focus on.

    Examples for extra instructions:

    [pr_code_suggestions] # /improve #
    extra_instructions="""
    Emphasize the following aspects:
    - Does the code logic cover relevant edge cases?
    - Is the code logic clear and easy to understand?
    - Is the code logic efficient?
    ...
    """
    

    Use triple quotes to write multi-line instructions. Use bullet points to make the instructions more readable.

    A note on code suggestions quality
    • While the current AI for code is getting better and better (GPT-4), it's not flawless. Not all the suggestions will be perfect, and a user should not accept all of them automatically.
    • Suggestions are not meant to be simplistic. Instead, they aim to give deep feedback and raise questions, ideas and thoughts to the user, who can then use his judgment, experience, and understanding of the code base.
    • Recommended to use the 'extra_instructions' field to guide the model to suggestions that are more relevant to the specific needs of the project, or use the custom suggestions 💎 tool
    • With large PRs, best quality will be obtained by using 'improve --extended' mode.
    More PR-Agent commands

    To invoke the PR-Agent, add a comment using one of the following commands:

    • /review: Request a review of your Pull Request.
    • /describe: Update the PR title and description based on the contents of the PR.
    • /improve [--extended]: Suggest code improvements. Extended mode provides a higher quality feedback.
    • /ask <QUESTION>: Ask a question about the PR.
    • /update_changelog: Update the changelog based on the PR's contents.
    • /add_docs 💎: Generate docstring for new components introduced in the PR.
    • /generate_labels 💎: Generate labels for the PR based on the PR's contents.
    • /analyze 💎: Automatically analyzes the PR, and presents changes walkthrough for each component.

    See the tools guide for more details.
    To list the possible configuration parameters, add a /config comment.

    See the improve usage page for a more comprehensive guide on using this tool.

    Copy link
    Contributor

    Persistent review updated to latest commit b99f84b

    Copy link
    Contributor

    github-actions bot commented Mar 14, 2024

    PR Code Suggestions

    CategorySuggestions                                                                                                                                                       
    Enhancement
    Make displayName optional instead of nullable.

    Consider making displayName optional instead of nullable if there's no explicit need to
    distinguish between null and undefined. This can simplify checks and usage throughout your
    code.

    apps/backoffice-v2/src/domains/workflow-definitions/fetchers.ts [28]

    -displayName: z.string().nullable(),
    +displayName: z.string().optional(),
     
    Add a comment explaining the purpose of the displayName field.

    Consider adding a comment above the displayName field in the WorkflowDefinition model to
    explain its purpose or usage within the system. This can improve the readability and
    maintainability of the schema, especially for new developers or for future reference.

    services/workflows-service/prisma/schema.prisma [149]

    +// The display name for the workflow definition, used for UI rendering
     displayName     String?
     
    Add a description for the Docker Compose setup command.

    To improve the clarity of the Docker Compose setup instructions, consider adding a brief
    description before the command snippet. This description could explain what the command
    does, such as starting the service using Docker Compose.

    services/workflows-service/README.md [40]

    -In the `server` subdirectory, run:
    +To start the service using Docker Compose, navigate to the `server` subdirectory and run the following command:
     
    Maintainability
    Use a ternary operator for setting height class based on a condition.

    To improve readability and maintainability, consider using a single ternary operator to
    set the height class instead of two separate conditions.

    apps/backoffice-v2/src/pages/Entities/Entities.page.tsx [42-43]

    -'h-[calc(100vh-300px)]': isManualCaseCreationEnabled,
    -'h-[calc(100vh-240px)]': !isManualCaseCreationEnabled,
    +[`h-[calc(100vh-${isManualCaseCreationEnabled ? '300px' : '240px'})]`]: true,
     
    Encapsulate logic for determining workflow definition name into a utility function.

    Instead of manually checking for displayName and then falling back to titleCase(name),
    consider creating a utility function that encapsulates this logic. This will make the code
    cleaner and easier to maintain.

    apps/backoffice-v2/src/pages/Entities/components/CaseCreation/CaseCreation.tsx [16-17]

    -const workflowDefinitionName =
    +const getWorkflowDefinitionName = (workflowDefinition) => 
       workflowDefinition?.displayName || titleCase(workflowDefinition?.name ?? '');
    +const workflowDefinitionName = getWorkflowDefinitionName(workflowDefinition);
     
    Possible issue
    Ensure consistency in API response structure.

    Ensure consistency in the response object structure. If invokedAt was previously included
    in the success response but is no longer needed, consider if other parts of your
    application depend on this field. If not, this change is fine. Otherwise, you might need
    to adjust the consumer code or reconsider this removal.

    packages/workflow-core/src/lib/plugins/external-plugin/api-plugin.ts [92]

    -return {};
    +return { /* other fields if necessary */ };
     
    Verify the version bump follows semantic versioning guidelines.

    Ensure that the version bump from 0.1.50 to 0.1.53 is intentional and follows the semantic
    versioning guidelines, especially if there are breaking changes or new features that
    justify skipping versions.

    apps/kyb-app/package.json [4]

    -"version": "0.1.53",
    +"version": "0.1.53",  // Ensure versioning follows semantic versioning guidelines
     
    Bug
    Correct the return value of setTimeToRecordUTC to return a full UTC timestamp.

    The setTimeToRecordUTC method currently returns the day of the month in UTC, which seems
    incorrect for setting a timestamp. It should return a full UTC timestamp instead.

    packages/workflow-core/src/lib/utils/context-transformers/helpers-transformer.ts [81]

    -return new Date().getUTCDate();
    +return Date.now();
     
    Best practice
    Include a comment in the migration file explaining the new column addition.

    It's recommended to include a comment within the migration file explaining the purpose of
    the new column being added to the WorkflowDefinition table. This can be beneficial for
    understanding the context of the migration in the future.

    services/workflows-service/prisma/migrations/20240314123948_definition_display_name/migration.sql [2]

    -ALTER TABLE "WorkflowDefinition" ADD COLUMN     "displayName" TEXT;
    +-- Adds a new column 'displayName' to store the display name of workflow definitions for better UI representation
    +ALTER TABLE "WorkflowDefinition" ADD COLUMN "displayName" TEXT;
     
    Pin the version of @nestjs/common to ensure consistent behavior.

    Consider pinning the version of @nestjs/common to ^9.3.12 without the caret (^) to ensure
    consistent behavior across different environments. Using a fixed version can help avoid
    unexpected issues when a new version of the package is released.

    services/workflows-service/package.json [50]

    -"@nestjs/common": "^9.3.12",
    +"@nestjs/common": "9.3.12",
     

    ✨ Improve tool usage guide:

    Overview:
    The improve tool scans the PR code changes, and automatically generates suggestions for improving the PR code. The tool can be triggered automatically every time a new PR is opened, or can be invoked manually by commenting on a PR.
    When commenting, to edit configurations related to the improve tool (pr_code_suggestions section), use the following template:

    /improve --pr_code_suggestions.some_config1=... --pr_code_suggestions.some_config2=...
    

    With a configuration file, use the following template:

    [pr_code_suggestions]
    some_config1=...
    some_config2=...
    
    Enabling\disabling automation

    When you first install the app, the default mode for the improve tool is:

    pr_commands = ["/improve --pr_code_suggestions.summarize=true", ...]
    

    meaning the improve tool will run automatically on every PR, with summarization enabled. Delete this line to disable the tool from running automatically.

    Utilizing extra instructions

    Extra instructions are very important for the improve tool, since they enable to guide the model to suggestions that are more relevant to the specific needs of the project.

    Be specific, clear, and concise in the instructions. With extra instructions, you are the prompter. Specify relevant aspects that you want the model to focus on.

    Examples for extra instructions:

    [pr_code_suggestions] # /improve #
    extra_instructions="""
    Emphasize the following aspects:
    - Does the code logic cover relevant edge cases?
    - Is the code logic clear and easy to understand?
    - Is the code logic efficient?
    ...
    """
    

    Use triple quotes to write multi-line instructions. Use bullet points to make the instructions more readable.

    A note on code suggestions quality
    • While the current AI for code is getting better and better (GPT-4), it's not flawless. Not all the suggestions will be perfect, and a user should not accept all of them automatically.
    • Suggestions are not meant to be simplistic. Instead, they aim to give deep feedback and raise questions, ideas and thoughts to the user, who can then use his judgment, experience, and understanding of the code base.
    • Recommended to use the 'extra_instructions' field to guide the model to suggestions that are more relevant to the specific needs of the project, or use the custom suggestions 💎 tool
    • With large PRs, best quality will be obtained by using 'improve --extended' mode.
    More PR-Agent commands

    To invoke the PR-Agent, add a comment using one of the following commands:

    • /review: Request a review of your Pull Request.
    • /describe: Update the PR title and description based on the contents of the PR.
    • /improve [--extended]: Suggest code improvements. Extended mode provides a higher quality feedback.
    • /ask <QUESTION>: Ask a question about the PR.
    • /update_changelog: Update the changelog based on the PR's contents.
    • /add_docs 💎: Generate docstring for new components introduced in the PR.
    • /generate_labels 💎: Generate labels for the PR based on the PR's contents.
    • /analyze 💎: Automatically analyzes the PR, and presents changes walkthrough for each component.

    See the tools guide for more details.
    To list the possible configuration parameters, add a /config comment.

    See the improve usage page for a more comprehensive guide on using this tool.

    @alonp99 alonp99 closed this pull request by merging all changes into prod in 5b5aece Mar 14, 2024
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    None yet

    4 participants