Hu-Fi / Mr.Market

Mr. Market is the exchange oracle of HuFi, and a CeFi crypto bot on Mixin Messenger
https://mr-market-one.vercel.app
GNU Affero General Public License v3.0
1 stars 6 forks source link

Adding Custom Logger, Adding more tests for cov + minor fixes #39

Closed Faouzijedidi1 closed 6 months ago

Faouzijedidi1 commented 6 months ago

User description


Type

enhancement, tests


Description


Changes walkthrough

Relevant files
Enhancement
14 files
app.controller.ts
Add New Get Route Handler in App Controller                           

server/src/app.controller.ts
  • Added a new @Get() route handler getHello to return the result of
    appService.getHello().
  • +4/-0     
    app.module.ts
    Integrate Custom Logger into AppModule                                     

    server/src/app.module.ts
  • Imported LoggerModule and CustomLogger to the AppModule.
  • Added LoggerModule to the imports array.
  • Added CustomLogger to the providers array.
  • +4/-1     
    subscriptionKey.ts
    Refactor Subscription Key Helper Functions                             

    server/src/common/helpers/subscriptionKey.ts
  • Refactored decodeCompositeKey function to use a switch statement.
  • Added array splitting for tickers type in decodeCompositeKey.
  • +13/-11 
    main.ts
    Use Custom Logger and Make Port Configurable in Main         

    server/src/main.ts
  • Integrated CustomLogger for logging incoming requests.
  • Made the server port configurable via environment variable.
  • +7/-3     
    health.service.ts
    Use CustomLogger in Health Service                                             

    server/src/modules/health/health.service.ts - Replaced `Logger` with `CustomLogger` for logging.
    +2/-1     
    logger.module.ts
    Implement Logger Module                                                                   

    server/src/modules/logger/logger.module.ts - Created a new LoggerModule with `CustomLogger` as a provider.
    +9/-0     
    logger.service.ts
    Implement Custom Logger Service                                                   

    server/src/modules/logger/logger.service.ts
  • Implemented CustomLogger extending NestJS Logger with file logging
    capabilities.
  • +69/-0   
    marketdata.gateway.ts
    Configure WebSocket Port and Use CustomLogger in MarketData Gateway

    server/src/modules/marketdata/marketdata.gateway.ts
  • Made WebSocket port configurable via environment variable.
  • Replaced Logger with CustomLogger.
  • +4/-2     
    marketdata.service.ts
    Use CustomLogger in Marketdata Service                                     

    server/src/modules/marketdata/marketdata.service.ts - Replaced `Logger` with `CustomLogger` for logging.
    +2/-1     
    strategy.module.ts
    Import LoggerModule into StrategyModule                                   

    server/src/modules/strategy/strategy.module.ts - Imported `LoggerModule` into StrategyModule.
    +2/-1     
    strategy.service.ts
    Use CustomLogger and Add Logging for Stopping Strategy in
    StrategyService

    server/src/modules/strategy/strategy.service.ts
  • Replaced Logger with CustomLogger for logging.
  • Added logging for strategy stopping.
  • +19/-8   
    trade.controller.ts
    Use CustomLogger in Trade Controller                                         

    server/src/modules/trade/trade.controller.ts - Replaced `Logger` with `CustomLogger` for logging.
    +2/-1     
    trade.module.ts
    Export TradeRepository from TradeModule                                   

    server/src/modules/trade/trade.module.ts - Exported `TradeRepository` from TradeModule.
    +1/-1     
    trade.service.ts
    Use CustomLogger in Trade Service                                               

    server/src/modules/trade/trade.service.ts - Replaced `Logger` with `CustomLogger` for logging.
    +3/-2     
    Tests
    8 files
    subscriptionKey.spec.ts
    Add Tests for Subscription Key Helpers                                     

    server/src/common/helpers/subscriptionKey.spec.ts
  • Added tests for createCompositeKey and decodeCompositeKey functions.
  • +77/-0   
    coingecko.service.spec.ts
    Add Tests for CoingeckoProxyService                                           

    server/src/modules/coingecko/coingecko.service.spec.ts
  • Added tests for CoingeckoProxyService methods with mock
    implementations.
  • +100/-3 
    health.service.spec.ts
    Add Health Service Tests                                                                 

    server/src/modules/health/health.service.spec.ts
  • Added tests for HealthService including ping and getExchangeHealth
    methods.
  • +27/-14 
    marketdata.service.spec.ts
    Add Tests for MarketdataService                                                   

    server/src/modules/marketdata/marketdata.service.spec.ts
  • Added tests for MarketdataService methods with mock implementations.
  • +91/-7   
    performance.controller.spec.ts
    Mock PerformanceService in PerformanceController Tests     

    server/src/modules/performance/performance.controller.spec.ts
  • Added mock PerformanceService for testing PerformanceController.
  • +12/-0   
    strategy.controller.spec.ts
    Mock StrategyService in StrategyController Tests                 

    server/src/modules/strategy/strategy.controller.spec.ts - Added mock `StrategyService` for testing `StrategyController`.
    +13/-0   
    strategy.service.spec.ts
    Add Comprehensive Tests for StrategyService                           

    server/src/modules/strategy/strategy.service.spec.ts
  • Added comprehensive tests for StrategyService including strategy
    execution and cancellation.
  • +120/-1 
    trade.service.spec.ts
    Add Comprehensive Tests for TradeService                                 

    server/src/modules/trade/trade.service.spec.ts
  • Added comprehensive tests for TradeService including limit and market
    trade execution.
  • +109/-61
    Configuration changes
    2 files
    jest.config.js
    Add Jest Configuration File                                                           

    server/jest.config.js
  • Added Jest configuration for specifying module file extensions, test
    environment, and test regex.
  • +15/-0   
    jest-e2e.json
    Configure moduleNameMapper for Jest e2e Tests                       

    server/test/jest-e2e.json - Added `moduleNameMapper` configuration for Jest e2e tests.
    +3/-0     
    Dependencies
    1 files
    package.json
    Add Winston Package and Update Jest Scripts                           

    server/package.json
  • Added winston package for logging.
  • Updated Jest test scripts to use the Jest configuration file.
  • +5/-4     

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

    vercel[bot] commented 6 months ago

    The latest updates on your projects. Learn more about Vercel for Git ↗︎

    Name Status Preview Comments Updated (UTC)
    mr-market ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 5, 2024 2:32am
    mr-market-back ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 5, 2024 2:32am
    github-actions[bot] commented 6 months ago

    PR Description updated to latest commit (https://github.com/Hu-Fi/Mr.Market/commit/b3f56a81b8c3aafd06adc217c7def87d04776a4b)

    github-actions[bot] commented 6 months ago

    PR Review

    ⏱️ Estimated effort to review [1-5] 4, due to the extensive changes across multiple files, including the addition of new modules, services, and tests. The complexity of integrating a custom logger and modifying existing services to use it, alongside the introduction of environment variable configurations for ports, requires careful consideration of the overall architecture and potential side effects.
    🧪 Relevant tests Yes
    🔍 Possible issues Possible Bug: In `server/src/modules/marketdata/marketdata.gateway.ts`, the conversion of `webSocketPort` from string to number using `parseInt` without specifying a radix might lead to unexpected results. It's recommended to always specify a radix of 10 for decimal numbers.
    Performance Concern: The use of synchronous file operations in `server/src/modules/logger/logger.service.ts` could potentially block the event loop, especially under high load. Consider using asynchronous file operations instead.
    Error Handling: Several services and controllers lack comprehensive error handling, which could lead to unhandled exceptions and affect the stability of the application.
    🔒 Security concerns No
    Code feedback:
    relevant fileserver/src/modules/marketdata/marketdata.gateway.ts
    suggestion       Consider specifying a radix of 10 when using `parseInt` for converting `webSocketPort` to a number. This ensures the string is always interpreted in the decimal numeral system, avoiding potential bugs. [important]
    relevant lineconst webSocketPort = process.env.WS_PORT || "3012";

    relevant fileserver/src/modules/logger/logger.service.ts
    suggestion       Replace synchronous file operations with their asynchronous counterparts to prevent blocking the event loop. This change enhances the performance and scalability of the application by ensuring that logging operations do not interfere with the main application flow. [important]
    relevant linefs.appendFile(filePath, message, (err) => {

    relevant fileserver/src/modules/trade/trade.service.ts
    suggestion       Implement comprehensive error handling for external API calls and database operations. This could include try-catch blocks around API calls and checks for successful database operations, logging the errors and potentially retrying operations or gracefully degrading functionality. [important]
    relevant lineservice['exchanges'].get('binance').createOrder = jest.fn().mockResolvedValue(mockOrder);

    relevant fileserver/src/modules/strategy/strategy.service.ts
    suggestion       Validate the existence and configuration of exchanges before attempting to use them in strategies. This can prevent `InternalServerErrorException` by ensuring that only configured exchanges are used, improving the robustness of the application. [medium]
    relevant lineconst exchangeA: ccxt.Exchange = this.exchanges.get(exchangeAName);


    ✨ Review tool usage guide:
    **Overview:** The `review` tool scans the PR code changes, and generates a PR review. The tool can be triggered [automatically](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#github-app-automatic-tools) every time a new PR is opened, or can be invoked manually by commenting on any PR. When commenting, to edit [configurations](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml#L19) 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](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#working-with-github-app), 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](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#github-app-automatic-tools) 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](https://github.com/Codium-ai/pr-agent/blob/tr/user_description/pr_agent/settings/pr_reviewer_prompts.toml#L136) (`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](https://github.com/Codium-ai/pr-agent/blob/main/docs/REVIEW.md#enabledisable-features), 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 \**: 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](https://github.com/Codium-ai/pr-agent/blob/main/docs/TOOLS_GUIDE.md) for more details. >To list the possible configuration parameters, add a **/config** comment.
    See the [review usage](https://github.com/Codium-ai/pr-agent/blob/main/docs/REVIEW.md) page for a comprehensive guide on using this tool.
    github-actions[bot] commented 6 months ago

    PR Code Suggestions

    CategorySuggestions                                                                                                                                                       
    Best practice
    Use explicit route paths in HTTP method decorators. ___ **Consider using explicit HTTP method decorators like @Get('route') to define the route
    path, enhancing the readability and maintainability of your code.** [server/src/app.controller.ts [13-15]](https://github.com/Hu-Fi/Mr.Market/pull/39/files#diff-d6b00218afe61827db5e730e12a60688660e3d5c99d13b419f1dfd9947974e40R13-R15) ```diff -@Get() +@Get('/hello') getHello(){ return this.appService.getHello(); } ```
    Use join(',') instead of toString() for arrays to ensure consistent comma-separated strings. ___ **To avoid potential issues with the toString() method on arrays, consider using join(',')
    for creating a comma-separated string from an array. This ensures consistent behavior
    across different environments.** [server/src/common/helpers/subscriptionKey.spec.ts [31]](https://github.com/Hu-Fi/Mr.Market/pull/39/files#diff-e806f911f37fa044e1364955535d9f8254238a6bbbabc26e8da9efaf97d43a5eR31-R31) ```diff -const expectedKey = `tickers:binance:${symbols.toString()}`; +const expectedKey = `tickers:binance:${symbols.join(',')}`; ```
    Use a configuration service for managing application settings. ___ **For better scalability and environment management, consider using a configuration service
    or module to manage application settings like port numbers instead of directly accessing
    process.env.** [server/src/main.ts [32-33]](https://github.com/Hu-Fi/Mr.Market/pull/39/files#diff-efcd503ed2db1beff4ecb4063d7ff5cfb7de483a66d9f9a4ff296daea9f8e868R32-R33) ```diff -const port = process.env.PORT || 3000; +const port = this.configService.get('PORT') || 3000; await app.listen(port); ```
    Add type annotations to variables. ___ **Consider adding explicit type annotations to cacheManager to improve code readability and
    maintainability.** [server/src/modules/marketdata/marketdata.service.spec.ts [37]](https://github.com/Hu-Fi/Mr.Market/pull/39/files#diff-0a03bee273d95898e425e715195d805b0064968d18423edb7f9090de1d024173R37-R37) ```diff -let cacheManager; +let cacheManager: Cache; ```
    Use readonly for constants. ___ **Initialize cachingTTL with a readonly modifier to prevent accidental reassignment and
    clarify its constant nature.** [server/src/modules/marketdata/marketdata.service.ts [18]](https://github.com/Hu-Fi/Mr.Market/pull/39/files#diff-0dd39c41f8551fc930baf35b0c2b376e2ac0d12e686a82d86d7cee070f4bf16aR18-R18) ```diff -private cachingTTL: 10; // 10s +private readonly cachingTTL: number = 10; // 10s ```
    Avoid using any type for better type safety. ___ **Avoid using any type for service['tradeService'] to ensure type safety. Define an
    interface or use an existing one if available.** [server/src/modules/strategy/strategy.service.ts [126]](https://github.com/Hu-Fi/Mr.Market/pull/39/files#diff-413cb1b28e0d47a46768f97d10145a8e14d9e46b0a195768786127305916d944R126-R126) ```diff -service['tradeService'] = { executeLimitTrade: executeLimitTradeMock } as any; +service['tradeService'] = { executeLimitTrade: executeLimitTradeMock } as Partial; ```
    Add type annotations to the mockTradeRepository object. ___ **Consider adding explicit type annotations to the mockTradeRepository object to ensure type
    safety and improve code readability.** [server/src/modules/trade/trade.service.spec.ts [23-26]](https://github.com/Hu-Fi/Mr.Market/pull/39/files#diff-81f72944db3b1b77fd408110e28d0460e05facb92b2416e4732d6c1d478bb00eR23-R26) ```diff -mockTradeRepository = { +mockTradeRepository: TradeRepository = { createTrade: jest.fn(), updateTradeStatus: jest.fn(), }; ```
    Add detailed logging before critical operations. ___ **For better error handling and debugging, consider adding more detailed logging, especially
    before performing critical operations like executing trades.** [server/src/modules/trade/trade.service.ts [69]](https://github.com/Hu-Fi/Mr.Market/pull/39/files#diff-4432350be63f9e2463145381a3748ee74fcf5656391b0269244b96a3bd55bd3eR69-R69) ```diff -this.logger.log(`Market trade executed`, order.toString()); +this.logger.log(`Attempting to execute market trade with order details: ${JSON.stringify(order)}`); +// Followed by the execution ```
    Mock external dependencies more comprehensively in tests. ___ **To improve the robustness of your tests, consider mocking external dependencies more
    comprehensively. For example, mock the ccxt library's behavior more thoroughly to simulate
    different trading scenarios and responses.** [server/src/modules/trade/trade.service.spec.ts [7-15]](https://github.com/Hu-Fi/Mr.Market/pull/39/files#diff-81f72944db3b1b77fd408110e28d0460e05facb92b2416e4732d6c1d478bb00eR7-R15) ```diff jest.mock('ccxt', () => ({ pro: { binance: jest.fn().mockImplementation(() => ({ - createOrder: jest.fn(), - cancelOrder: jest.fn().mockResolvedValue, + createOrder: jest.fn().mockImplementation((symbol, type, side, amount, price) => { + // Simulate different responses based on input + }), + cancelOrder: jest.fn().mockResolvedValue(/* Simulate realistic cancellation response */), })), - bitfinex: jest.fn().mockImplementation(() => ({})), - mexc: jest.fn().mockImplementation(() => ({})), + bitfinex: jest.fn().mockImplementation(() => ({ + // Implement mocking for bitfinex + })), + mexc: jest.fn().mockImplementation(() => ({ + // Implement mocking for mexc + })), }, })); ```
    Maintainability
    Organize imports by separating external and internal modules. ___ **It's a good practice to organize imports by external and internal modules, separated by a
    newline, to improve code readability.** [server/src/app.module.ts [23-25]](https://github.com/Hu-Fi/Mr.Market/pull/39/files#diff-4e8033eb0f9fd87924c445b7ac0f1c1192d4890fc1589b2fad2679797d4f4ce0R23-R25) ```diff import { LoggerModule } from './modules/logger/logger.module'; import { CustomLogger } from './modules/logger/logger.service'; + dotenv.config(); ```
    Enhancement
    Implement log rotation to manage log file sizes. ___ **To ensure that log files are not excessively large, consider implementing a log rotation
    mechanism or using a third-party library that supports log rotation out of the box.** [server/src/modules/logger/logger.service.ts [31-37]](https://github.com/Hu-Fi/Mr.Market/pull/39/files#diff-fe4be3a82b6895fc7a5ea6b903fc41dd6b40ea08412f72a46ca9a3dd3962046fR31-R37) ```diff +// Example using a third-party library for log rotation private writeToFile(filePath: string, message: string): void { - fs.appendFile(filePath, message, (err) => { - if (err) { - console.error('Failed to write log:', err); - } - }); + // Implement log rotation mechanism here } ```
    Simplify function parameters with destructuring. ___ **Use destructuring in function parameters to simplify the code and improve readability.** [server/src/modules/strategy/strategy.service.ts [78]](https://github.com/Hu-Fi/Mr.Market/pull/39/files#diff-413cb1b28e0d47a46768f97d10145a8e14d9e46b0a195768786127305916d944R78-R78) ```diff -async startArbitrageStrategyForUser(strategyParamsDto: ArbitrageStrategyDto) { +async startArbitrageStrategyForUser({ userId, clientId, pair, exchangeAName, exchangeBName }: ArbitrageStrategyDto) { ```
    Use a mapping object for conditional assignments. ___ **Replace the if statements with a switch case or a mapping object for strategyType to
    enhance code readability and maintainability.** [server/src/modules/strategy/strategy.service.ts [132-137]](https://github.com/Hu-Fi/Mr.Market/pull/39/files#diff-413cb1b28e0d47a46768f97d10145a8e14d9e46b0a195768786127305916d944R132-R137) ```diff -if (strategyType === 'Arbitrage') { -if (strategyType === 'pureMarketMaking') { +const strategyKeys = { + Arbitrage: `${userId}-${clientId}-Arbitrage`, + pureMarketMaking: `${userId}-${clientId}-pureMarketMaking`, +}; +strategyKey = strategyKeys[strategyType]; ```
    Verify mock method calls with expected arguments in tests. ___ **To improve test reliability, consider verifying that mockTradeRepository.createTrade and
    mockTradeRepository.updateTradeStatus are called with the expected arguments in your test
    cases.** [server/src/modules/trade/trade.service.spec.ts [70-80]](https://github.com/Hu-Fi/Mr.Market/pull/39/files#diff-81f72944db3b1b77fd408110e28d0460e05facb92b2416e4732d6c1d478bb00eR70-R80) ```diff -expect(mockTradeRepository.createTrade).toHaveBeenCalledWith({ +expect(mockTradeRepository.createTrade).toHaveBeenCalledWith(expect.objectContaining({ userId: 'user123', clientId: 'client123', symbol: 'BTC/USD', side: 'sell', type: 'limit', amount: 1, price: 50000, status: 'closed', orderId: 'order123', -}); +})); ```
    Add tests for partial failures or exceptions during trade execution. ___ **To ensure that your tests cover all possible scenarios, consider adding tests for partial
    failures or exceptions during the trade execution process, such as network issues or
    partial order fulfillment.** [server/src/modules/trade/trade.service.spec.ts [107-120]](https://github.com/Hu-Fi/Mr.Market/pull/39/files#diff-81f72944db3b1b77fd408110e28d0460e05facb92b2416e4732d6c1d478bb00eR107-R120) ```diff -it('should throw InternalServerErrorException on createOrder failure', async () => { - const limitTradeDto = { - userId: 'user123', - clientId: 'client123', - exchange: 'binance', - symbol: 'BTC/USD', - side: 'sell', - amount: 1, - price: 50000, - }; - - ccxt.pro.binance.prototype.createOrder = jest.fn().mockRejectedValue(new Error('API Error')); - - await expect(service.executeLimitTrade(limitTradeDto)).rejects.toThrow(InternalServerErrorException); +// Example of an additional test case +it('should handle partial order fulfillment', async () => { + // Setup partial fulfillment scenario + // Assert the expected behavior }); ```

    ✨ 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](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#github-app-automatic-tools) every time a new PR is opened, or can be invoked manually by commenting on a PR. When commenting, to edit [configurations](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml#L69) 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](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#working-with-github-app), use the following template: ``` [pr_code_suggestions] some_config1=... some_config2=... ```
    Enabling\disabling automation
    When you first install the app, the [default mode](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#github-app-automatic-tools) 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 :gem:](https://github.com/Codium-ai/pr-agent/blob/main/docs/CUSTOM_SUGGESTIONS.md) 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 \**: 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](https://github.com/Codium-ai/pr-agent/blob/main/docs/TOOLS_GUIDE.md) for more details. >To list the possible configuration parameters, add a **/config** comment.
    See the [improve usage](https://github.com/Codium-ai/pr-agent/blob/main/docs/IMPROVE.md) page for a more comprehensive guide on using this tool.