feat(config): Restructure .taskmasterconfig and enhance gateway integration

Config Structure Changes and Gateway Integration

## Configuration Structure Changes
- Restructured .taskmasterconfig to use 'account' section for user settings
- Moved userId, userEmail, mode, telemetryEnabled from global to account section
- API keys remain isolated in .env file (not accessible to AI)
- Enhanced getUserId() to always return value, never null (sets default '1234567890')

## Gateway Integration Enhancements
- Updated registerUserWithGateway() to accept both email and userId parameters
- Enhanced /auth/init endpoint integration for existing user validation
- API key updates automatically written to .env during registration process
- Improved user identification and validation flow

## Code Updates for New Structure
- Fixed config-manager.js getter functions for account section access
- Updated user-management.js to use config.account.userId/mode
- Modified telemetry-submission.js to read from account section
- Added getTelemetryEnabled() function with proper account section access
- Enhanced telemetry configuration reading with new structure

## Comprehensive Test Updates
- Updated integration tests (init-config.test.js) for new config structure
- Fixed unit tests (config-manager.test.js) with updated default config
- Updated telemetry tests (telemetry-submission.test.js) for account structure
- Added missing getTelemetryEnabled mock to ai-services-unified.test.js
- Fixed all test expectations to use config.account.* instead of config.global.*
- Removed references to deprecated config.subscription object

## Configuration Access Consistency
- Standardized configuration access patterns across entire codebase
- Clean separation: user settings in account, API keys in .env, models/global in respective sections
- All tests passing with new configuration structure
- Maintained backward compatibility during transition

Changes support enhanced telemetry system with proper user management and gateway integration while maintaining security through API key isolation.
This commit is contained in:
Eyal Toledano
2025-05-30 18:53:16 -04:00
parent e573db3b3b
commit 4e9d58a1b0
18 changed files with 1900 additions and 1609 deletions

View File

@@ -113,6 +113,40 @@ TDD COMPLETE - Subtask 90.1 Implementation Finished:
**Ready for subtask 90.2**: Send telemetry data to remote database endpoint
</info added on 2025-05-28T18:25:47.900Z>
<info added on 2025-05-30T22:16:38.344Z>
Configuration Structure Refactoring Complete:
- Moved telemetryEnabled from separate telemetry object to account section for better organization
- Consolidated userId, mode, and userEmail into account section (previously scattered across config)
- Removed subscription object to simplify configuration structure
- Updated config-manager.js to handle new configuration structure properly
- Verified new structure works correctly with test commands
- Configuration now has cleaner, more logical organization with account-related settings grouped together
</info added on 2025-05-30T22:16:38.344Z>
<info added on 2025-05-30T22:30:56.872Z>
Configuration Structure Migration Complete - All Code and Tests Updated:
**Code Updates:**
- Fixed user-management.js to use config.account.userId/mode instead of deprecated config.global paths
- Updated telemetry-submission.js to read userId from config.account.userId for proper telemetry data association
- Enhanced telemetry opt-out validation to use getTelemetryEnabled() function for consistent config access
- Improved registerUserWithGateway() function to accept both email and userId parameters for comprehensive user validation
**Test Suite Updates:**
- Updated tests/integration/init-config.test.js to validate new config.account structure
- Migrated all test assertions from config.global.userId to config.account.userId
- Updated config.mode references to config.account.mode throughout test files
- Changed telemetry validation from config.telemetryEnabled to config.account.telemetryEnabled
- Removed obsolete config.subscription object references from all test cases
- Fixed tests/unit/scripts/modules/telemetry-submission.test.js to match new configuration schema
**Gateway Integration Enhancements:**
- registerUserWithGateway() now sends both email and userId to /auth/init endpoint for proper user identification
- Gateway can validate existing users and provide appropriate authentication responses
- API key updates are automatically persisted to .env file upon successful registration
- Complete user validation and authentication flow implemented and tested
All configuration structure changes are now consistent across codebase. Ready for end-to-end testing with gateway integration.
</info added on 2025-05-30T22:30:56.872Z>
## 2. Send telemetry data to remote database endpoint [done]
### Dependencies: None