Open
Description
Description
Based on the analysis of issue #397, there are several improvements that could be made to MyCoder's configuration handling to make it more user-friendly and robust:
Current Issues
- When a configuration file is not loaded correctly, MyCoder silently falls back to defaults without warning the user
- The error message about Anthropic API is confusing when the user has configured a different provider
- The ESM vs CommonJS format requirements are not clearly documented
- Environment variables for the default provider are checked even when a different provider is specified
Proposed Improvements
-
Better Configuration Loading Feedback:
- Log which configuration file was loaded and from where
- Warn when no configuration file was found
- Provide clear error messages for syntax or format errors in configuration files
-
Provider-Specific Validation:
- Only check for environment variables related to the configured provider
- Add a validation step that verifies the required environment variables are present before attempting to use them
-
Improved Error Messages:
- When an API call fails, include information about which provider was being used
- Provide clearer guidance on how to set up the required environment variables
- Add a troubleshooting section to error messages
-
Documentation Updates:
- Clarify the naming and format requirements for configuration files
- Add examples for different locations (project-level vs global)
- Document Node.js version requirements for ESM support
Implementation Ideas
- Add a debug log in
loadConfig()
that shows which files were checked and which one was loaded - Modify the provider factory to validate environment variables before attempting to create the provider
- Update error handling in API calls to include more context
- Add a configuration validation step that runs before executing commands
Related Issues
- MyCoder is not recognizing my config file #397 - MyCoder is not recognizing my config file
Priority
Medium - This would significantly improve the user experience, especially for new users setting up MyCoder for the first time.