fix: bedrock set model and other fixes (#641)

This commit is contained in:
Ralph Khreish
2025-06-02 14:44:35 +02:00
committed by GitHub
parent e0438c8fb8
commit ad612763ff
21 changed files with 128 additions and 84 deletions

View File

@@ -0,0 +1,5 @@
---
"task-master-ai": patch
---
Fix bedrock issues

View File

@@ -0,0 +1,5 @@
---
"task-master-ai": patch
---
Update rules for new directory structure

View File

@@ -0,0 +1,5 @@
---
"task-master-ai": patch
---
Fix MCP crashing after certain commands due to console logs

View File

@@ -26,6 +26,7 @@
"defaultPriority": "medium",
"projectName": "Taskmaster",
"ollamaBaseURL": "http://localhost:11434/api",
"bedrockBaseURL": "https://bedrock.us-east-1.amazonaws.com",
"userId": "1234567890",
"azureBaseURL": "https://your-endpoint.azure.com/"
}

View File

@@ -1,32 +0,0 @@
{
"models": {
"main": {
"provider": "anthropic",
"modelId": "claude-sonnet-4-20250514",
"maxTokens": 50000,
"temperature": 0.2
},
"research": {
"provider": "perplexity",
"modelId": "sonar-pro",
"maxTokens": 8700,
"temperature": 0.1
},
"fallback": {
"provider": "anthropic",
"modelId": "claude-3-7-sonnet-20250219",
"maxTokens": 128000,
"temperature": 0.2
}
},
"global": {
"logLevel": "info",
"debug": false,
"defaultSubtasks": 5,
"defaultPriority": "medium",
"projectName": "Taskmaster",
"ollamaBaseURL": "http://localhost:11434/api",
"userId": "1234567890",
"azureBaseURL": "https://your-endpoint.azure.com/"
}
}

View File

@@ -56,20 +56,24 @@ task-master generate # Update task markd
```
project/
├── tasks/
│ ├── tasks.json # Main task database
│ ├── task-1.md # Individual task files
── task-2.md
├── scripts/
│ ├── prd.txt # Product requirements
└── task-complexity-report.json
├── .taskmaster/
│ ├── tasks/ # Task files directory
│ ├── tasks.json # Main task database
│ ├── task-1.md # Individual task files
│ │ └── task-2.md
│ ├── docs/ # Documentation directory
│ ├── prd.txt # Product requirements
│ ├── reports/ # Analysis reports directory
│ │ └── task-complexity-report.json
│ ├── templates/ # Template files
│ │ └── example_prd.txt # Example PRD template
│ └── config.json # AI models & settings
├── .claude/
│ ├── settings.json # Claude Code configuration
│ └── commands/ # Custom slash commands
├── .taskmasterconfig # AI models & settings
├── .env # API keys
── .mcp.json # MCP configuration
└── CLAUDE.md # This file - auto-loaded by Claude Code
│ ├── settings.json # Claude Code configuration
│ └── commands/ # Custom slash commands
├── .env # API keys
├── .mcp.json # MCP configuration
── CLAUDE.md # This file - auto-loaded by Claude Code
```
## MCP Integration
@@ -384,7 +388,7 @@ These commands make AI calls and may take up to a minute:
### File Management
- Never manually edit `tasks.json` - use commands instead
- Never manually edit `.taskmasterconfig` - use `task-master models`
- Never manually edit `.taskmaster/config.json` - use `task-master models`
- Task markdown files in `tasks/` are auto-generated
- Run `task-master generate` after manual changes to tasks.json

View File

@@ -26,6 +26,7 @@
"defaultPriority": "medium",
"projectName": "Taskmaster",
"ollamaBaseURL": "http://localhost:11434/api",
"azureOpenaiBaseURL": "https://your-endpoint.openai.azure.com/"
"azureOpenaiBaseURL": "https://your-endpoint.openai.azure.com/",
"bedrockBaseURL": "https://bedrock.us-east-1.amazonaws.com"
}
}

View File

@@ -5,5 +5,5 @@ OPENAI_API_KEY="your_openai_api_key_here" # Optional, for OpenAI/Ope
GOOGLE_API_KEY="your_google_api_key_here" # Optional, for Google Gemini models.
MISTRAL_API_KEY="your_mistral_key_here" # Optional, for Mistral AI models.
XAI_API_KEY="YOUR_XAI_KEY_HERE" # Optional, for xAI AI models.
AZURE_OPENAI_API_KEY="your_azure_key_here" # Optional, for Azure OpenAI models (requires endpoint in .taskmasterconfig).
AZURE_OPENAI_API_KEY="your_azure_key_here" # Optional, for Azure OpenAI models (requires endpoint in .taskmaster/config.json).
OLLAMA_API_KEY="your_ollama_api_key_here" # Optional: For remote Ollama servers that require authentication.

View File

@@ -20,7 +20,7 @@ In an AI-driven development process—particularly with tools like [Cursor](http
Task Master configuration is now managed through two primary methods:
1. **`.taskmasterconfig` File (Project Root - Primary)**
1. **`.taskmaster/config.json` File (Project Root - Primary)**
- Stores AI model selections (`main`, `research`, `fallback`), model parameters (`maxTokens`, `temperature`), `logLevel`, `defaultSubtasks`, `defaultPriority`, `projectName`, etc.
- Managed using the `task-master models --setup` command or the `models` MCP tool.
@@ -192,7 +192,7 @@ Notes:
## AI Integration (Updated)
- The script now uses a unified AI service layer (`ai-services-unified.js`).
- Model selection (e.g., Claude vs. Perplexity for `--research`) is determined by the configuration in `.taskmasterconfig` based on the requested `role` (`main` or `research`).
- Model selection (e.g., Claude vs. Perplexity for `--research`) is determined by the configuration in `.taskmaster/config.json` based on the requested `role` (`main` or `research`).
- API keys are automatically resolved from your `.env` file (for CLI) or MCP session environment.
- To use the research capabilities (e.g., `expand --research`), ensure you have:
1. Configured a model for the `research` role using `task-master models --setup` (Perplexity models are recommended).
@@ -357,25 +357,25 @@ The output report structure is:
```json
{
"meta": {
"generatedAt": "2023-06-15T12:34:56.789Z",
"tasksAnalyzed": 20,
"thresholdScore": 5,
"projectName": "Your Project Name",
"usedResearch": true
},
"complexityAnalysis": [
{
"taskId": 8,
"taskTitle": "Develop Implementation Drift Handling",
"complexityScore": 9.5,
"recommendedSubtasks": 6,
"expansionPrompt": "Create subtasks that handle detecting...",
"reasoning": "This task requires sophisticated logic...",
"expansionCommand": "task-master expand --id=8 --num=6 --prompt=\"Create subtasks...\" --research"
}
// More tasks sorted by complexity score (highest first)
]
"meta": {
"generatedAt": "2023-06-15T12:34:56.789Z",
"tasksAnalyzed": 20,
"thresholdScore": 5,
"projectName": "Your Project Name",
"usedResearch": true
},
"complexityAnalysis": [
{
"taskId": 8,
"taskTitle": "Develop Implementation Drift Handling",
"complexityScore": 9.5,
"recommendedSubtasks": 6,
"expansionPrompt": "Create subtasks that handle detecting...",
"reasoning": "This task requires sophisticated logic...",
"expansionCommand": "task-master expand --id=8 --num=6 --prompt=\"Create subtasks...\" --research"
}
// More tasks sorted by complexity score (highest first)
]
}
```

View File

@@ -47,7 +47,6 @@ export function registerModelsTool(server) {
),
projectRoot: z
.string()
.optional()
.describe('The directory of the project. Must be an absolute path.'),
openrouter: z
.boolean()

View File

@@ -32,7 +32,6 @@ export function registerParsePRDTool(server) {
.describe('Absolute path to the PRD document file (.txt, .md, etc.)'),
projectRoot: z
.string()
.optional()
.describe('The directory of the project. Must be an absolute path.'),
output: z
.string()

View File

@@ -509,9 +509,9 @@ function createProjectStructure(addAliases, dryRun, options) {
replacements
);
// Copy .taskmasterconfig with project name to NEW location
// Copy config.json with project name to NEW location
copyTemplateFile(
'.taskmasterconfig',
'config.json',
path.join(targetDir, TASKMASTER_CONFIG_FILE),
{
...replacements

View File

@@ -22,6 +22,7 @@ import {
isApiKeySet,
getOllamaBaseURL,
getAzureBaseURL,
getBedrockBaseURL,
getVertexProjectId,
getVertexLocation
} from './config-manager.js';
@@ -410,6 +411,10 @@ async function _unifiedServiceRunner(serviceType, params) {
// For Ollama, use the global Ollama base URL if role-specific URL is not configured
baseURL = getOllamaBaseURL(effectiveProjectRoot);
log('debug', `Using global Ollama base URL: ${baseURL}`);
} else if (providerName?.toLowerCase() === 'bedrock' && !baseURL) {
// For Bedrock, use the global Bedrock base URL if role-specific URL is not configured
baseURL = getBedrockBaseURL(effectiveProjectRoot);
log('debug', `Using global Bedrock base URL: ${baseURL}`);
}
// Get AI parameters for the current role

View File

@@ -61,7 +61,8 @@ const DEFAULTS = {
defaultSubtasks: 5,
defaultPriority: 'medium',
projectName: 'Task Master',
ollamaBaseURL: 'http://localhost:11434/api'
ollamaBaseURL: 'http://localhost:11434/api',
bedrockBaseURL: 'https://bedrock.us-east-1.amazonaws.com'
}
};
@@ -382,6 +383,11 @@ function getAzureBaseURL(explicitRoot = null) {
return getGlobalConfig(explicitRoot).azureBaseURL;
}
function getBedrockBaseURL(explicitRoot = null) {
// Directly return value from config
return getGlobalConfig(explicitRoot).bedrockBaseURL;
}
/**
* Gets the Google Cloud project ID for Vertex AI from configuration
* @param {string|null} explicitRoot - Optional explicit path to the project root.
@@ -779,6 +785,7 @@ export {
getProjectName,
getOllamaBaseURL,
getAzureBaseURL,
getBedrockBaseURL,
getParametersForRole,
getUserId,
// API Key Checkers (still relevant)

View File

@@ -482,6 +482,11 @@ async function setModel(role, modelId, options = {}) {
`Model ID "${modelId}" not found in the Ollama instance. Please verify the model is pulled and available. You can check available models with: curl ${tagsUrl}`
);
}
} else if (providerHint === 'bedrock') {
// Set provider without model validation since Bedrock models are managed by AWS
determinedProvider = 'bedrock';
warningMessage = `Warning: Custom Bedrock model '${modelId}' set. Please ensure the model ID is valid and accessible in your AWS account.`;
report('warn', warningMessage);
} else {
// Invalid provider hint - should not happen
throw new Error(`Invalid provider hint received: ${providerHint}`);

View File

@@ -24,7 +24,10 @@ import {
} from './task-manager.js';
import { getProjectName, getDefaultSubtasks } from './config-manager.js';
import { TASK_STATUS_OPTIONS } from '../../src/constants/task-status.js';
import { TASKMASTER_TASKS_FILE } from '../../src/constants/paths.js';
import {
TASKMASTER_CONFIG_FILE,
TASKMASTER_TASKS_FILE
} from '../../src/constants/paths.js';
import { getTaskMasterVersion } from '../../src/utils/getVersion.js';
// Create a color gradient for the banner
@@ -687,7 +690,7 @@ function displayHelp() {
configTable.push(
[
`${chalk.yellow('.taskmasterconfig')}${chalk.reset('')}`,
`${chalk.yellow(TASKMASTER_CONFIG_FILE)}${chalk.reset('')}`,
`${chalk.white('AI model configuration file (project root)')}${chalk.reset('')}`,
`${chalk.dim('Managed by models cmd')}${chalk.reset('')}`
],
@@ -1851,7 +1854,7 @@ function displayApiKeyStatus(statusReport) {
console.log(table.toString());
console.log(
chalk.gray(
' Note: Some providers (e.g., Azure, Ollama) may require additional endpoint configuration in .taskmasterconfig.'
` Note: Some providers (e.g., Azure, Ollama) may require additional endpoint configuration in ${TASKMASTER_CONFIG_FILE}.`
)
);
}

31
src/utils/logger-utils.js Normal file
View File

@@ -0,0 +1,31 @@
/**
* Logger utility functions for Task Master
* Provides standardized logging patterns for both CLI and utility contexts
*/
import { log as utilLog } from '../../scripts/modules/utils.js';
/**
* Creates a standard logger object that wraps the utility log function
* This provides a consistent logger interface across different parts of the application
* @returns {Object} A logger object with standard logging methods (info, warn, error, debug, success)
*/
export function createStandardLogger() {
return {
info: (msg, ...args) => utilLog('info', msg, ...args),
warn: (msg, ...args) => utilLog('warn', msg, ...args),
error: (msg, ...args) => utilLog('error', msg, ...args),
debug: (msg, ...args) => utilLog('debug', msg, ...args),
success: (msg, ...args) => utilLog('success', msg, ...args)
};
}
/**
* Creates a logger using either the provided logger or a default standard logger
* This is the recommended pattern for functions that accept an optional logger parameter
* @param {Object|null} providedLogger - Optional logger object passed from caller
* @returns {Object} A logger object with standard logging methods
*/
export function getLoggerOrDefault(providedLogger = null) {
return providedLogger || createStandardLogger();
}

View File

@@ -14,6 +14,7 @@ import {
TASKMASTER_CONFIG_FILE,
LEGACY_CONFIG_FILE
} from '../constants/paths.js';
import { getLoggerOrDefault } from './logger-utils.js';
/**
* Find the project root directory by looking for project markers
@@ -59,7 +60,8 @@ export function findProjectRoot(startDir = process.cwd()) {
* @returns {string|null} - Resolved tasks.json path or null if not found
*/
export function findTasksPath(explicitPath = null, args = null, log = null) {
const logger = log || console;
// Use the passed logger if available, otherwise use the default logger
const logger = getLoggerOrDefault(log);
// 1. If explicit path is provided, use it (highest priority)
if (explicitPath) {
@@ -130,7 +132,7 @@ export function findTasksPath(explicitPath = null, args = null, log = null) {
* @returns {string|null} - Resolved PRD document path or null if not found
*/
export function findPRDPath(explicitPath = null, args = null, log = null) {
const logger = log || console;
const logger = getLoggerOrDefault(log);
// 1. If explicit path is provided, use it (highest priority)
if (explicitPath) {
@@ -199,7 +201,7 @@ export function findComplexityReportPath(
args = null,
log = null
) {
const logger = log || console;
const logger = getLoggerOrDefault(log);
// 1. If explicit path is provided, use it (highest priority)
if (explicitPath) {
@@ -268,7 +270,7 @@ export function resolveTasksOutputPath(
args = null,
log = null
) {
const logger = log || console;
const logger = getLoggerOrDefault(log);
// 1. If explicit path is provided, use it
if (explicitPath) {
@@ -309,7 +311,7 @@ export function resolveComplexityReportOutputPath(
args = null,
log = null
) {
const logger = log || console;
const logger = getLoggerOrDefault(log);
// 1. If explicit path is provided, use it
if (explicitPath) {
@@ -348,7 +350,7 @@ export function resolveComplexityReportOutputPath(
* @returns {string|null} - Resolved config file path or null if not found
*/
export function findConfigPath(explicitPath = null, args = null, log = null) {
const logger = log || console;
const logger = getLoggerOrDefault(log);
// 1. If explicit path is provided, use it (highest priority)
if (explicitPath) {

View File

@@ -43,6 +43,7 @@ const mockGetBaseUrlForRole = jest.fn();
const mockGetAllProviders = jest.fn();
const mockGetOllamaBaseURL = jest.fn();
const mockGetAzureBaseURL = jest.fn();
const mockGetBedrockBaseURL = jest.fn();
const mockGetVertexProjectId = jest.fn();
const mockGetVertexLocation = jest.fn();
const mockGetAvailableModels = jest.fn();
@@ -113,6 +114,7 @@ jest.unstable_mockModule('../../scripts/modules/config-manager.js', () => ({
getAllProviders: mockGetAllProviders,
getOllamaBaseURL: mockGetOllamaBaseURL,
getAzureBaseURL: mockGetAzureBaseURL,
getBedrockBaseURL: mockGetBedrockBaseURL,
getVertexProjectId: mockGetVertexProjectId,
getVertexLocation: mockGetVertexLocation,
getMcpApiKeyStatus: mockGetMcpApiKeyStatus

View File

@@ -139,7 +139,8 @@ const DEFAULT_CONFIG = {
defaultSubtasks: 5,
defaultPriority: 'medium',
projectName: 'Task Master',
ollamaBaseURL: 'http://localhost:11434/api'
ollamaBaseURL: 'http://localhost:11434/api',
bedrockBaseURL: 'https://bedrock.us-east-1.amazonaws.com'
}
};

View File

@@ -127,6 +127,7 @@ jest.unstable_mockModule(
getProjectName: jest.fn(() => 'Test Project'),
getOllamaBaseURL: jest.fn(() => 'http://localhost:11434/api'),
getAzureBaseURL: jest.fn(() => undefined),
getBedrockBaseURL: jest.fn(() => undefined),
getParametersForRole: jest.fn(() => ({
maxTokens: 4000,
temperature: 0.7