fix(ai-services): Prevent TTY errors during AI streaming output
The function used terminal manipulation functions (like , ) for the CLI streaming progress indicator. This caused errors when Task Master commands involving AI streaming were run in non-interactive terminals (e.g., via output redirection, some CI environments, or integrated terminals). This commit adds a check for to the condition that controls the display of the CLI progress indicator, ensuring these functions are only called when standard output is a fully interactive TTY.
This commit is contained in:
@@ -155,6 +155,38 @@ export function getClient(model) {
|
||||
7. Include default fallback models
|
||||
8. Testing approach: Write unit tests to verify config reading/writing and model validation logic
|
||||
|
||||
<info added on 2025-04-14T21:54:28.887Z>
|
||||
Here's the additional information to add:
|
||||
|
||||
```
|
||||
The configuration management module should:
|
||||
|
||||
1. Use a `.taskmasterconfig` JSON file in the project root directory to store model settings
|
||||
2. Structure the config file with two main keys: `main` and `research` for respective model selections
|
||||
3. Implement functions to locate the project root directory (using package.json as reference)
|
||||
4. Define constants for valid models:
|
||||
```javascript
|
||||
const VALID_MAIN_MODELS = ['gpt-4', 'gpt-3.5-turbo', 'gpt-4-turbo'];
|
||||
const VALID_RESEARCH_MODELS = ['gpt-4', 'gpt-4-turbo', 'claude-2'];
|
||||
const DEFAULT_MAIN_MODEL = 'gpt-3.5-turbo';
|
||||
const DEFAULT_RESEARCH_MODEL = 'gpt-4';
|
||||
```
|
||||
5. Implement model getters with priority order:
|
||||
- First check `.taskmasterconfig` file
|
||||
- Fall back to environment variables if config file missing/invalid
|
||||
- Use defaults as last resort
|
||||
6. Implement model setters that validate input against valid model lists before updating config
|
||||
7. Keep API key management in `ai-services.js` using environment variables (don't store keys in config file)
|
||||
8. Add helper functions for config file operations:
|
||||
```javascript
|
||||
function getConfigPath() { /* locate .taskmasterconfig */ }
|
||||
function readConfig() { /* read and parse config file */ }
|
||||
function writeConfig(config) { /* stringify and write config */ }
|
||||
```
|
||||
9. Include error handling for file operations and invalid configurations
|
||||
```
|
||||
</info added on 2025-04-14T21:54:28.887Z>
|
||||
|
||||
## 2. Implement CLI Command Parser for Model Management [pending]
|
||||
### Dependencies: 61.1
|
||||
### Description: Extend the CLI command parser to handle the new 'models' command and associated flags for model management.
|
||||
|
||||
@@ -2752,7 +2752,7 @@
|
||||
"title": "Create Configuration Management Module",
|
||||
"description": "Develop a centralized configuration module to manage AI model settings and preferences, leveraging the Strategy pattern for model selection.",
|
||||
"dependencies": [],
|
||||
"details": "1. Create a new `config-manager.js` module to handle model configuration\n2. Implement functions to read/write model preferences to a local config file\n3. Define model validation logic with clear error messages\n4. Create mapping of valid models for main and research operations\n5. Implement getters and setters for model configuration\n6. Add utility functions to validate model names against available options\n7. Include default fallback models\n8. Testing approach: Write unit tests to verify config reading/writing and model validation logic",
|
||||
"details": "1. Create a new `config-manager.js` module to handle model configuration\n2. Implement functions to read/write model preferences to a local config file\n3. Define model validation logic with clear error messages\n4. Create mapping of valid models for main and research operations\n5. Implement getters and setters for model configuration\n6. Add utility functions to validate model names against available options\n7. Include default fallback models\n8. Testing approach: Write unit tests to verify config reading/writing and model validation logic\n\n<info added on 2025-04-14T21:54:28.887Z>\nHere's the additional information to add:\n\n```\nThe configuration management module should:\n\n1. Use a `.taskmasterconfig` JSON file in the project root directory to store model settings\n2. Structure the config file with two main keys: `main` and `research` for respective model selections\n3. Implement functions to locate the project root directory (using package.json as reference)\n4. Define constants for valid models:\n ```javascript\n const VALID_MAIN_MODELS = ['gpt-4', 'gpt-3.5-turbo', 'gpt-4-turbo'];\n const VALID_RESEARCH_MODELS = ['gpt-4', 'gpt-4-turbo', 'claude-2'];\n const DEFAULT_MAIN_MODEL = 'gpt-3.5-turbo';\n const DEFAULT_RESEARCH_MODEL = 'gpt-4';\n ```\n5. Implement model getters with priority order:\n - First check `.taskmasterconfig` file\n - Fall back to environment variables if config file missing/invalid\n - Use defaults as last resort\n6. Implement model setters that validate input against valid model lists before updating config\n7. Keep API key management in `ai-services.js` using environment variables (don't store keys in config file)\n8. Add helper functions for config file operations:\n ```javascript\n function getConfigPath() { /* locate .taskmasterconfig */ }\n function readConfig() { /* read and parse config file */ }\n function writeConfig(config) { /* stringify and write config */ }\n ```\n9. Include error handling for file operations and invalid configurations\n```\n</info added on 2025-04-14T21:54:28.887Z>",
|
||||
"status": "pending",
|
||||
"parentTaskId": 61
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user