aicommit2 icon indicating copy to clipboard operation
aicommit2 copied to clipboard

feat: Enhance AI service configuration and logging

Open devxpain opened this issue 6 months ago • 1 comments
trafficstars

Issue

N/A

Description

This pull request introduces significant enhancements to the AI service configuration and logging mechanisms.

Key changes include:

  • Multi-model support: AI services can now be configured with multiple models, allowing for more flexible and powerful AI interactions. The configuration parser has been updated to handle comma-separated strings or arrays for model definitions.
  • Improved error handling: Centralized error handling in the base AI service, making response parsing more robust and providing clearer error messages for API and validation failures.
  • Flexible configuration paths: Adopted the XDG Base Directory Specification for configuration file locations, improving compatibility across different operating systems. Users can now specify custom environment variables for config paths, and relative paths for prompt files are supported.
  • Enhanced logging: Implemented file logging with daily rotation using winston-daily-rotate-file. Logging can now be configured with different levels and file paths, and can be optionally disabled. Log file paths now include date-based placeholders for better organization.
  • Refactored utilities: Moved ensureDirectoryExists to a more general utility file and renamed assertOpenAiToken to assertOpenAiKey for clarity.
  • Output improvements: Added diff character count to the staged message for better visibility.

These changes aim to improve the flexibility, robustness, and maintainability of the AI service and its surrounding infrastructure.

Testing

All existing unit and integration tests were run to ensure functionality. Specific tests were added or updated for:

  • Configuration path resolution, including XDG compliance and environment variable precedence.
  • Multi-model parsing in custom AI service configurations.
  • Error handling and message extraction in AI service responses.
  • Logger initialization and file logging behavior.

Additional context

This PR is a culmination of several smaller commits focused on improving the core infrastructure of the application, particularly around AI service integration, configuration management, and logging. It lays the groundwork for more advanced features and better debugging capabilities.


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

devxpain avatar May 22 '25 15:05 devxpain

@devxpain Wow.. that's a lot of commits! I'll review everything carefully and then merge. Thanks again for your contribution!

tak-bro avatar May 23 '25 07:05 tak-bro