Skip to content

An AI-powered task-management system you can drop into Cursor, Lovable, Windsurf, Roo, and others.

chore: adds a warning when custom openrouter model is a free model which suffers from lower rate limits, restricted context, and, worst of all, no access to tool_use.

Eyal Toledanocc04d5372031
diff --git a/.taskmaster/config.json b/.taskmaster/config.json
index 442dfc1c..20cdb49c 100644
--- a/.taskmaster/config.json
+++ b/.taskmaster/config.json
@@ -1,8 +1,8 @@
{
"models": {
"main": {
- "provider": "anthropic",
- "modelId": "claude-sonnet-4-20250514",
+ "provider": "openrouter",
+ "modelId": "qwen/qwen3-235b-a22b:free",
"maxTokens": 50000,
"temperature": 0.2
},
diff --git a/.taskmaster/tasks/task_097.txt b/.taskmaster/tasks/task_097.txt
new file mode 100644
index 00000000..2ef43dd6
--- /dev/null
+++ b/.taskmaster/tasks/task_097.txt
@@ -0,0 +1,35 @@
+# Task ID: 97
+# Title: Create Taskmaster Jingle Implementation
+# Status: pending
+# Dependencies: 95, 57, 3, 2
+# Priority: medium
+# Description: Develop a musical jingle system for Taskmaster that plays sound effects during key CLI interactions to enhance user experience.
+# Details:
+This task involves implementing a sound system that plays audio cues during Taskmaster CLI operations. Key implementation steps include:
+
+1. Audio System Integration:
+ - Research and select appropriate audio library compatible with Node.js CLI applications
+ - Implement cross-platform audio playback (Windows, macOS, Linux)
+ - Create sound configuration options in .taskmasterconfig
+
+2. Jingle Design:
+ - Define sound triggers for key events (task creation, completion, errors, etc.)
+ - Create or source appropriate sound files (WAV/MP3 format)
+ - Implement volume control and mute option in settings
+
+3. CLI Integration:
+ - Add sound playback to core CLI commands (init, create, update, delete)
+ - Implement optional sound effects toggle via command line flags
+ - Ensure audio playback doesn't interfere with CLI performance
+
+4. Documentation:
+ - Update user guide with sound configuration instructions
+ - Add troubleshooting section for audio playback issues
+
+# Test Strategy:
+1. Verify audio plays correctly during each supported CLI operation
+2. Test sound configuration options across different platforms
+3. Confirm volume control and mute functionality works as expected
+4. Validate that audio playback doesn't affect CLI performance
+5. Test edge cases (no audio hardware, invalid sound files, etc.)
+6. Ensure sound effects can be disabled via configuration and CLI flags
diff --git a/.taskmaster/tasks/tasks.json b/.taskmaster/tasks/tasks.json
index c8cd9c33..8cc174d5 100644
--- a/.taskmaster/tasks/tasks.json
+++ b/.taskmaster/tasks/tasks.json
@@ -5871,6 +5871,22 @@
"parentTaskId": 96
}
]
+ },
+ {
+ "id": 97,
+ "title": "Create Taskmaster Jingle Implementation",
+ "description": "Develop a musical jingle system for Taskmaster that plays sound effects during key CLI interactions to enhance user experience.",
+ "details": "This task involves implementing a sound system that plays audio cues during Taskmaster CLI operations. Key implementation steps include:\n\n1. Audio System Integration:\n - Research and select appropriate audio library compatible with Node.js CLI applications\n - Implement cross-platform audio playback (Windows, macOS, Linux)\n - Create sound configuration options in .taskmasterconfig\n\n2. Jingle Design:\n - Define sound triggers for key events (task creation, completion, errors, etc.)\n - Create or source appropriate sound files (WAV/MP3 format)\n - Implement volume control and mute option in settings\n\n3. CLI Integration:\n - Add sound playback to core CLI commands (init, create, update, delete)\n - Implement optional sound effects toggle via command line flags\n - Ensure audio playback doesn't interfere with CLI performance\n\n4. Documentation:\n - Update user guide with sound configuration instructions\n - Add troubleshooting section for audio playback issues",
+ "testStrategy": "1. Verify audio plays correctly during each supported CLI operation\n2. Test sound configuration options across different platforms\n3. Confirm volume control and mute functionality works as expected\n4. Validate that audio playback doesn't affect CLI performance\n5. Test edge cases (no audio hardware, invalid sound files, etc.)\n6. Ensure sound effects can be disabled via configuration and CLI flags",
+ "status": "pending",
+ "dependencies": [
+ 95,
+ 57,
+ 3,
+ 2
+ ],
+ "priority": "medium",
+ "subtasks": []
}
]
}
\ No newline at end of file
diff --git a/scripts/modules/supported-models.json b/scripts/modules/supported-models.json
index 3dbb4109..fac3da0d 100644
--- a/scripts/modules/supported-models.json
+++ b/scripts/modules/supported-models.json
@@ -388,13 +388,6 @@
"allowed_roles": ["main", "fallback"],
"max_tokens": 24000
},
- {
- "id": "qwen/qwen3-235b-a22b:free",
- "swe_score": 0,
- "cost_per_1m_tokens": { "input": 0.14, "output": 2 },
- "allowed_roles": ["main", "fallback"],
- "max_tokens": 24000
- },
{
"id": "mistralai/mistral-small-3.1-24b-instruct:free",
"swe_score": 0,
diff --git a/scripts/modules/task-manager/models.js b/scripts/modules/task-manager/models.js
index 8416c616..5fe02d8a 100644
--- a/scripts/modules/task-manager/models.js
+++ b/scripts/modules/task-manager/models.js
@@ -3,71 +3,71 @@
* Core functionality for managing AI model configurations
*/
-import https from 'https';
-import http from 'http';
+import https from "https";
+import http from "http";
import {
- getMainModelId,
- getResearchModelId,
- getFallbackModelId,
- getAvailableModels,
- getMainProvider,
- getResearchProvider,
- getFallbackProvider,
- isApiKeySet,
- getMcpApiKeyStatus,
- getConfig,
- writeConfig,
- isConfigFilePresent,
- getAllProviders,
- getBaseUrlForRole
-} from '../config-manager.js';
-import { findConfigPath } from '../../../src/utils/path-utils.js';
-import { log } from '../utils.js';
+ getMainModelId,
+ getResearchModelId,
+ getFallbackModelId,
+ getAvailableModels,
+ getMainProvider,
+ getResearchProvider,
+ getFallbackProvider,
+ isApiKeySet,
+ getMcpApiKeyStatus,
+ getConfig,
+ writeConfig,
+ isConfigFilePresent,
+ getAllProviders,
+ getBaseUrlForRole,
+} from "../config-manager.js";
+import { findConfigPath } from "../../../src/utils/path-utils.js";
+import { log } from "../utils.js";
/**
* Fetches the list of models from OpenRouter API.
* @returns {Promise<Array|null>} A promise that resolves with the list of model IDs or null if fetch fails.
*/
function fetchOpenRouterModels() {
- return new Promise((resolve) => {
- const options = {
- hostname: 'openrouter.ai',
- path: '/api/v1/models',
- method: 'GET',
- headers: {
- Accept: 'application/json'
- }
- };
-
- const req = https.request(options, (res) => {
- let data = '';
- res.on('data', (chunk) => {
- data += chunk;
- });
- res.on('end', () => {
- if (res.statusCode === 200) {
- try {
- const parsedData = JSON.parse(data);
- resolve(parsedData.data || []); // Return the array of models
- } catch (e) {
- console.error('Error parsing OpenRouter response:', e);
- resolve(null); // Indicate failure
- }
- } else {
- console.error(
- `OpenRouter API request failed with status code: ${res.statusCode}`
- );
- resolve(null); // Indicate failure
- }
- });
- });
-
- req.on('error', (e) => {
- console.error('Error fetching OpenRouter models:', e);
- resolve(null); // Indicate failure
- });
- req.end();
- });
+ return new Promise((resolve) => {
+ const options = {
+ hostname: "openrouter.ai",
+ path: "/api/v1/models",
+ method: "GET",
+ headers: {
+ Accept: "application/json",
+ },
+ };
+
+ const req = https.request(options, (res) => {
+ let data = "";
+ res.on("data", (chunk) => {
+ data += chunk;
+ });
+ res.on("end", () => {
+ if (res.statusCode === 200) {
+ try {
+ const parsedData = JSON.parse(data);
+ resolve(parsedData.data || []); // Return the array of models
+ } catch (e) {
+ console.error("Error parsing OpenRouter response:", e);
+ resolve(null); // Indicate failure
+ }
+ } else {
+ console.error(
+ `OpenRouter API request failed with status code: ${res.statusCode}`
+ );
+ resolve(null); // Indicate failure
+ }
+ });
+ });
+
+ req.on("error", (e) => {
+ console.error("Error fetching OpenRouter models:", e);
+ resolve(null); // Indicate failure
+ });
+ req.end();
+ });
}
/**
@@ -75,61 +75,61 @@ function fetchOpenRouterModels() {
* @param {string} baseURL - The base URL for the Ollama API (e.g., "http://localhost:11434/api")
* @returns {Promise<Array|null>} A promise that resolves with the list of model objects or null if fetch fails.
*/
-function fetchOllamaModels(baseURL = 'http://localhost:11434/api') {
- return new Promise((resolve) => {
- try {
- // Parse the base URL to extract hostname, port, and base path
- const url = new URL(baseURL);
- const isHttps = url.protocol === 'https:';
- const port = url.port || (isHttps ? 443 : 80);
- const basePath = url.pathname.endsWith('/')
- ? url.pathname.slice(0, -1)
- : url.pathname;
-
- const options = {
- hostname: url.hostname,
- port: parseInt(port, 10),
- path: `${basePath}/tags`,
- method: 'GET',
- headers: {
- Accept: 'application/json'
- }
- };
-
- const requestLib = isHttps ? https : http;
- const req = requestLib.request(options, (res) => {
- let data = '';
- res.on('data', (chunk) => {
- data += chunk;
- });
- res.on('end', () => {
- if (res.statusCode === 200) {
- try {
- const parsedData = JSON.parse(data);
- resolve(parsedData.models || []); // Return the array of models
- } catch (e) {
- console.error('Error parsing Ollama response:', e);
- resolve(null); // Indicate failure
- }
- } else {
- console.error(
- `Ollama API request failed with status code: ${res.statusCode}`
- );
- resolve(null); // Indicate failure
- }
- });
- });
-
- req.on('error', (e) => {
- console.error('Error fetching Ollama models:', e);
- resolve(null); // Indicate failure
- });
- req.end();
- } catch (e) {
- console.error('Error parsing Ollama base URL:', e);
- resolve(null); // Indicate failure
- }
- });
+function fetchOllamaModels(baseURL = "http://localhost:11434/api") {
+ return new Promise((resolve) => {
+ try {
+ // Parse the base URL to extract hostname, port, and base path
+ const url = new URL(baseURL);
+ const isHttps = url.protocol === "https:";
+ const port = url.port || (isHttps ? 443 : 80);
+ const basePath = url.pathname.endsWith("/")
+ ? url.pathname.slice(0, -1)
+ : url.pathname;
+
+ const options = {
+ hostname: url.hostname,
+ port: parseInt(port, 10),
+ path: `${basePath}/tags`,
+ method: "GET",
+ headers: {
+ Accept: "application/json",
+ },
+ };
+
+ const requestLib = isHttps ? https : http;
+ const req = requestLib.request(options, (res) => {
+ let data = "";
+ res.on("data", (chunk) => {
+ data += chunk;
+ });
+ res.on("end", () => {
+ if (res.statusCode === 200) {
+ try {
+ const parsedData = JSON.parse(data);
+ resolve(parsedData.models || []); // Return the array of models
+ } catch (e) {
+ console.error("Error parsing Ollama response:", e);
+ resolve(null); // Indicate failure
+ }
+ } else {
+ console.error(
+ `Ollama API request failed with status code: ${res.statusCode}`
+ );
+ resolve(null); // Indicate failure
+ }
+ });
+ });
+
+ req.on("error", (e) => {
+ console.error("Error fetching Ollama models:", e);
+ resolve(null); // Indicate failure
+ });
+ req.end();
+ } catch (e) {
+ console.error("Error parsing Ollama base URL:", e);
+ resolve(null); // Indicate failure
+ }
+ });
}
/**
@@ -141,125 +141,125 @@ function fetchOllamaModels(baseURL = 'http://localhost:11434/api') {
* @returns {Object} RESTful response with current model configuration
*/
async function getModelConfiguration(options = {}) {
- const { mcpLog, projectRoot, session } = options;
-
- const report = (level, ...args) => {
- if (mcpLog && typeof mcpLog[level] === 'function') {
- mcpLog[level](...args);
- }
- };
-
- if (!projectRoot) {
- throw new Error('Project root is required but not found.');
- }
-
- // Use centralized config path finding instead of hardcoded path
- const configPath = findConfigPath(null, { projectRoot });
- const configExists = isConfigFilePresent(projectRoot);
-
- log(
- 'debug',
- `Checking for config file using findConfigPath, found: ${configPath}`
- );
- log(
- 'debug',
- `Checking config file using isConfigFilePresent(), exists: ${configExists}`
- );
-
- if (!configExists) {
- throw new Error(
- 'The configuration file is missing. Run "task-master models --setup" to create it.'
- );
- }
-
- try {
- // Get current settings - these should use the config from the found path automatically
- const mainProvider = getMainProvider(projectRoot);
- const mainModelId = getMainModelId(projectRoot);
- const researchProvider = getResearchProvider(projectRoot);
- const researchModelId = getResearchModelId(projectRoot);
- const fallbackProvider = getFallbackProvider(projectRoot);
- const fallbackModelId = getFallbackModelId(projectRoot);
-
- // Check API keys
- const mainCliKeyOk = isApiKeySet(mainProvider, session, projectRoot);
- const mainMcpKeyOk = getMcpApiKeyStatus(mainProvider, projectRoot);
- const researchCliKeyOk = isApiKeySet(
- researchProvider,
- session,
- projectRoot
- );
- const researchMcpKeyOk = getMcpApiKeyStatus(researchProvider, projectRoot);
- const fallbackCliKeyOk = fallbackProvider
- ? isApiKeySet(fallbackProvider, session, projectRoot)
- : true;
- const fallbackMcpKeyOk = fallbackProvider
- ? getMcpApiKeyStatus(fallbackProvider, projectRoot)
- : true;
-
- // Get available models to find detailed info
- const availableModels = getAvailableModels(projectRoot);
-
- // Find model details
- const mainModelData = availableModels.find((m) => m.id === mainModelId);
- const researchModelData = availableModels.find(
- (m) => m.id === researchModelId
- );
- const fallbackModelData = fallbackModelId
- ? availableModels.find((m) => m.id === fallbackModelId)
- : null;
-
- // Return structured configuration data
- return {
- success: true,
- data: {
- activeModels: {
- main: {
- provider: mainProvider,
- modelId: mainModelId,
- sweScore: mainModelData?.swe_score || null,
- cost: mainModelData?.cost_per_1m_tokens || null,
- keyStatus: {
- cli: mainCliKeyOk,
- mcp: mainMcpKeyOk
- }
- },
- research: {
- provider: researchProvider,
- modelId: researchModelId,
- sweScore: researchModelData?.swe_score || null,
- cost: researchModelData?.cost_per_1m_tokens || null,
- keyStatus: {
- cli: researchCliKeyOk,
- mcp: researchMcpKeyOk
- }
- },
- fallback: fallbackProvider
- ? {
- provider: fallbackProvider,
- modelId: fallbackModelId,
- sweScore: fallbackModelData?.swe_score || null,
- cost: fallbackModelData?.cost_per_1m_tokens || null,
- keyStatus: {
- cli: fallbackCliKeyOk,
- mcp: fallbackMcpKeyOk
- }
- }
- : null
- },
- message: 'Successfully retrieved current model configuration'
- }
- };
- } catch (error) {
- report('error', `Error getting model configuration: ${error.message}`);
- return {
- success: false,
- error: {
- code: 'CONFIG_ERROR',
- message: error.message
- }
- };
- }
+ const { mcpLog, projectRoot, session } = options;
+
+ const report = (level, ...args) => {
+ if (mcpLog && typeof mcpLog[level] === "function") {
+ mcpLog[level](...args);
+ }
+ };
+
+ if (!projectRoot) {
+ throw new Error("Project root is required but not found.");
+ }
+
+ // Use centralized config path finding instead of hardcoded path
+ const configPath = findConfigPath(null, { projectRoot });
+ const configExists = isConfigFilePresent(projectRoot);
+
+ log(
+ "debug",
+ `Checking for config file using findConfigPath, found: ${configPath}`
+ );
+ log(
+ "debug",
+ `Checking config file using isConfigFilePresent(), exists: ${configExists}`
+ );
+
+ if (!configExists) {
+ throw new Error(
+ 'The configuration file is missing. Run "task-master models --setup" to create it.'
+ );
+ }
+
+ try {
+ // Get current settings - these should use the config from the found path automatically
+ const mainProvider = getMainProvider(projectRoot);
+ const mainModelId = getMainModelId(projectRoot);
+ const researchProvider = getResearchProvider(projectRoot);
+ const researchModelId = getResearchModelId(projectRoot);
+ const fallbackProvider = getFallbackProvider(projectRoot);
+ const fallbackModelId = getFallbackModelId(projectRoot);
+
+ // Check API keys
+ const mainCliKeyOk = isApiKeySet(mainProvider, session, projectRoot);
+ const mainMcpKeyOk = getMcpApiKeyStatus(mainProvider, projectRoot);
+ const researchCliKeyOk = isApiKeySet(
+ researchProvider,
+ session,
+ projectRoot
+ );
+ const researchMcpKeyOk = getMcpApiKeyStatus(researchProvider, projectRoot);
+ const fallbackCliKeyOk = fallbackProvider
+ ? isApiKeySet(fallbackProvider, session, projectRoot)
+ : true;
+ const fallbackMcpKeyOk = fallbackProvider
+ ? getMcpApiKeyStatus(fallbackProvider, projectRoot)
+ : true;
+
+ // Get available models to find detailed info
+ const availableModels = getAvailableModels(projectRoot);
+
+ // Find model details
+ const mainModelData = availableModels.find((m) => m.id === mainModelId);
+ const researchModelData = availableModels.find(
+ (m) => m.id === researchModelId
+ );
+ const fallbackModelData = fallbackModelId
+ ? availableModels.find((m) => m.id === fallbackModelId)
+ : null;
+
+ // Return structured configuration data
+ return {
+ success: true,
+ data: {
+ activeModels: {
+ main: {
+ provider: mainProvider,
+ modelId: mainModelId,
+ sweScore: mainModelData?.swe_score || null,
+ cost: mainModelData?.cost_per_1m_tokens || null,
+ keyStatus: {
+ cli: mainCliKeyOk,
+ mcp: mainMcpKeyOk,
+ },
+ },
+ research: {
+ provider: researchProvider,
+ modelId: researchModelId,
+ sweScore: researchModelData?.swe_score || null,
+ cost: researchModelData?.cost_per_1m_tokens || null,
+ keyStatus: {
+ cli: researchCliKeyOk,
+ mcp: researchMcpKeyOk,
+ },
+ },
+ fallback: fallbackProvider
+ ? {
+ provider: fallbackProvider,
+ modelId: fallbackModelId,
+ sweScore: fallbackModelData?.swe_score || null,
+ cost: fallbackModelData?.cost_per_1m_tokens || null,
+ keyStatus: {
+ cli: fallbackCliKeyOk,
+ mcp: fallbackMcpKeyOk,
+ },
+ }
+ : null,
+ },
+ message: "Successfully retrieved current model configuration",
+ },
+ };
+ } catch (error) {
+ report("error", `Error getting model configuration: ${error.message}`);
+ return {
+ success: false,
+ error: {
+ code: "CONFIG_ERROR",
+ message: error.message,
+ },
+ };
+ }
}
/**
@@ -271,85 +271,85 @@ async function getModelConfiguration(options = {}) {
* @returns {Object} RESTful response with available models
*/
async function getAvailableModelsList(options = {}) {
- const { mcpLog, projectRoot } = options;
-
- const report = (level, ...args) => {
- if (mcpLog && typeof mcpLog[level] === 'function') {
- mcpLog[level](...args);
- }
- };
-
- if (!projectRoot) {
- throw new Error('Project root is required but not found.');
- }
-
- // Use centralized config path finding instead of hardcoded path
- const configPath = findConfigPath(null, { projectRoot });
- const configExists = isConfigFilePresent(projectRoot);
-
- log(
- 'debug',
- `Checking for config file using findConfigPath, found: ${configPath}`
- );
- log(
- 'debug',
- `Checking config file using isConfigFilePresent(), exists: ${configExists}`
- );
-
- if (!configExists) {
- throw new Error(
- 'The configuration file is missing. Run "task-master models --setup" to create it.'
- );
- }
-
- try {
- // Get all available models
- const allAvailableModels = getAvailableModels(projectRoot);
-
- if (!allAvailableModels || allAvailableModels.length === 0) {
- return {
- success: true,
- data: {
- models: [],
- message: 'No available models found'
- }
- };
- }
-
- // Get currently used model IDs
- const mainModelId = getMainModelId(projectRoot);
- const researchModelId = getResearchModelId(projectRoot);
- const fallbackModelId = getFallbackModelId(projectRoot);
-
- // Filter out placeholder models and active models
- const activeIds = [mainModelId, researchModelId, fallbackModelId].filter(
- Boolean
- );
- const otherAvailableModels = allAvailableModels.map((model) => ({
- provider: model.provider || 'N/A',
- modelId: model.id,
- sweScore: model.swe_score || null,
- cost: model.cost_per_1m_tokens || null,
- allowedRoles: model.allowed_roles || []
- }));
-
- return {
- success: true,
- data: {
- models: otherAvailableModels,
- message: `Successfully retrieved ${otherAvailableModels.length} available models`
- }
- };
- } catch (error) {
- report('error', `Error getting available models: ${error.message}`);
- return {
- success: false,
- error: {
- code: 'MODELS_LIST_ERROR',
- message: error.message
- }
- };
- }
+ const { mcpLog, projectRoot } = options;
+
+ const report = (level, ...args) => {
+ if (mcpLog && typeof mcpLog[level] === "function") {
+ mcpLog[level](...args);
+ }
+ };
+
+ if (!projectRoot) {
+ throw new Error("Project root is required but not found.");
+ }
+
+ // Use centralized config path finding instead of hardcoded path
+ const configPath = findConfigPath(null, { projectRoot });
+ const configExists = isConfigFilePresent(projectRoot);
+
+ log(
+ "debug",
+ `Checking for config file using findConfigPath, found: ${configPath}`
+ );
+ log(
+ "debug",
+ `Checking config file using isConfigFilePresent(), exists: ${configExists}`
+ );
+
+ if (!configExists) {
+ throw new Error(
+ 'The configuration file is missing. Run "task-master models --setup" to create it.'
+ );
+ }
+
+ try {
+ // Get all available models
+ const allAvailableModels = getAvailableModels(projectRoot);
+
+ if (!allAvailableModels || allAvailableModels.length === 0) {
+ return {
+ success: true,
+ data: {
+ models: [],
+ message: "No available models found",
+ },
+ };
+ }
+
+ // Get currently used model IDs
+ const mainModelId = getMainModelId(projectRoot);
+ const researchModelId = getResearchModelId(projectRoot);
+ const fallbackModelId = getFallbackModelId(projectRoot);
+
+ // Filter out placeholder models and active models
+ const activeIds = [mainModelId, researchModelId, fallbackModelId].filter(
+ Boolean
+ );
+ const otherAvailableModels = allAvailableModels.map((model) => ({
+ provider: model.provider || "N/A",
+ modelId: model.id,
+ sweScore: model.swe_score || null,
+ cost: model.cost_per_1m_tokens || null,
+ allowedRoles: model.allowed_roles || [],
+ }));
+
+ return {
+ success: true,
+ data: {
+ models: otherAvailableModels,
+ message: `Successfully retrieved ${otherAvailableModels.length} available models`,
+ },
+ };
+ } catch (error) {
+ report("error", `Error getting available models: ${error.message}`);
+ return {
+ success: false,
+ error: {
+ code: "MODELS_LIST_ERROR",
+ message: error.message,
+ },
+ };
+ }
}
/**
@@ -364,211 +364,218 @@ async function getAvailableModelsList(options = {}) {
* @returns {Object} RESTful response with result of update operation
*/
async function setModel(role, modelId, options = {}) {
- const { mcpLog, projectRoot, providerHint } = options;
-
- const report = (level, ...args) => {
- if (mcpLog && typeof mcpLog[level] === 'function') {
- mcpLog[level](...args);
- }
- };
-
- if (!projectRoot) {
- throw new Error('Project root is required but not found.');
- }
-
- // Use centralized config path finding instead of hardcoded path
- const configPath = findConfigPath(null, { projectRoot });
- const configExists = isConfigFilePresent(projectRoot);
-
- log(
- 'debug',
- `Checking for config file using findConfigPath, found: ${configPath}`
- );
- log(
- 'debug',
- `Checking config file using isConfigFilePresent(), exists: ${configExists}`
- );
-
- if (!configExists) {
- throw new Error(
- 'The configuration file is missing. Run "task-master models --setup" to create it.'
- );
- }
-
- // Validate role
- if (!['main', 'research', 'fallback'].includes(role)) {
- return {
- success: false,
- error: {
- code: 'INVALID_ROLE',
- message: `Invalid role: ${role}. Must be one of: main, research, fallback.`
- }
- };
- }
-
- // Validate model ID
- if (typeof modelId !== 'string' || modelId.trim() === '') {
- return {
- success: false,
- error: {
- code: 'INVALID_MODEL_ID',
- message: `Invalid model ID: ${modelId}. Must be a non-empty string.`
- }
- };
- }
-
- try {
- const availableModels = getAvailableModels(projectRoot);
- const currentConfig = getConfig(projectRoot);
- let determinedProvider = null; // Initialize provider
- let warningMessage = null;
-
- // Find the model data in internal list initially to see if it exists at all
- const modelData = availableModels.find((m) => m.id === modelId);
-
- // --- Revised Logic: Prioritize providerHint --- //
-
- if (providerHint) {
- // Hint provided (--ollama or --openrouter flag used)
- if (modelData && modelData.provider === providerHint) {
- // Found internally AND provider matches the hint
- determinedProvider = providerHint;
- report(
- 'info',
- `Model ${modelId} found internally with matching provider hint ${determinedProvider}.`
- );
- } else {
- // Either not found internally, OR found but under a DIFFERENT provider than hinted.
- // Proceed with custom logic based ONLY on the hint.
- if (providerHint === 'openrouter') {
- // Check OpenRouter ONLY because hint was openrouter
- report('info', `Checking OpenRouter for ${modelId} (as hinted)...`);
- const openRouterModels = await fetchOpenRouterModels();
-
- if (
- openRouterModels &&
- openRouterModels.some((m) => m.id === modelId)
- ) {
- determinedProvider = 'openrouter';
- warningMessage = `Warning: Custom OpenRouter model '${modelId}' set. This model is not officially validated by Taskmaster and may not function as expected.`;
- report('warn', warningMessage);
- } else {
- // Hinted as OpenRouter but not found in live check
- throw new Error(
- `Model ID "${modelId}" not found in the live OpenRouter model list. Please verify the ID and ensure it's available on OpenRouter.`
- );
- }
- } else if (providerHint === 'ollama') {
- // Check Ollama ONLY because hint was ollama
- report('info', `Checking Ollama for ${modelId} (as hinted)...`);
-
- // Get the Ollama base URL from config
- const ollamaBaseURL = getBaseUrlForRole(role, projectRoot);
- const ollamaModels = await fetchOllamaModels(ollamaBaseURL);
-
- if (ollamaModels === null) {
- // Connection failed - server probably not running
- throw new Error(
- `Unable to connect to Ollama server at ${ollamaBaseURL}. Please ensure Ollama is running and try again.`
- );
- } else if (ollamaModels.some((m) => m.model === modelId)) {
- determinedProvider = 'ollama';
- warningMessage = `Warning: Custom Ollama model '${modelId}' set. Ensure your Ollama server is running and has pulled this model. Taskmaster cannot guarantee compatibility.`;
- report('warn', warningMessage);
- } else {
- // Server is running but model not found
- const tagsUrl = `${ollamaBaseURL}/tags`;
- throw new Error(
- `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}`);
- }
- }
- } else {
- // No hint provided (flags not used)
- if (modelData) {
- // Found internally, use the provider from the internal list
- determinedProvider = modelData.provider;
- report(
- 'info',
- `Model ${modelId} found internally with provider ${determinedProvider}.`
- );
- } else {
- // Model not found and no provider hint was given
- return {
- success: false,
- error: {
- code: 'MODEL_NOT_FOUND_NO_HINT',
- message: `Model ID "${modelId}" not found in Taskmaster's supported models. If this is a custom model, please specify the provider using --openrouter or --ollama.`
- }
- };
- }
- }
-
- // --- End of Revised Logic --- //
-
- // At this point, we should have a determinedProvider if the model is valid (internally or custom)
- if (!determinedProvider) {
- // This case acts as a safeguard
- return {
- success: false,
- error: {
- code: 'PROVIDER_UNDETERMINED',
- message: `Could not determine the provider for model ID "${modelId}".`
- }
- };
- }
-
- // Update configuration
- currentConfig.models[role] = {
- ...currentConfig.models[role], // Keep existing params like maxTokens
- provider: determinedProvider,
- modelId: modelId
- };
-
- // Write updated configuration
- const writeResult = writeConfig(currentConfig, projectRoot);
- if (!writeResult) {
- return {
- success: false,
- error: {
- code: 'CONFIG_WRITE_ERROR',
- message: 'Error writing updated configuration to configuration file'
- }
- };
- }
-
- const successMessage = `Successfully set ${role} model to ${modelId} (Provider: ${determinedProvider})`;
- report('info', successMessage);
-
- return {
- success: true,
- data: {
- role,
- provider: determinedProvider,
- modelId,
- message: successMessage,
- warning: warningMessage // Include warning in the response data
- }
- };
- } catch (error) {
- report('error', `Error setting ${role} model: ${error.message}`);
- return {
- success: false,
- error: {
- code: 'SET_MODEL_ERROR',
- message: error.message
- }
- };
- }
+ const { mcpLog, projectRoot, providerHint } = options;
+
+ const report = (level, ...args) => {
+ if (mcpLog && typeof mcpLog[level] === "function") {
+ mcpLog[level](...args);
+ }
+ };
+
+ if (!projectRoot) {
+ throw new Error("Project root is required but not found.");
+ }
+
+ // Use centralized config path finding instead of hardcoded path
+ const configPath = findConfigPath(null, { projectRoot });
+ const configExists = isConfigFilePresent(projectRoot);
+
+ log(
+ "debug",
+ `Checking for config file using findConfigPath, found: ${configPath}`
+ );
+ log(
+ "debug",
+ `Checking config file using isConfigFilePresent(), exists: ${configExists}`
+ );
+
+ if (!configExists) {
+ throw new Error(
+ 'The configuration file is missing. Run "task-master models --setup" to create it.'
+ );
+ }
+
+ // Validate role
+ if (!["main", "research", "fallback"].includes(role)) {
+ return {
+ success: false,
+ error: {
+ code: "INVALID_ROLE",
+ message: `Invalid role: ${role}. Must be one of: main, research, fallback.`,
+ },
+ };
+ }
+
+ // Validate model ID
+ if (typeof modelId !== "string" || modelId.trim() === "") {
+ return {
+ success: false,
+ error: {
+ code: "INVALID_MODEL_ID",
+ message: `Invalid model ID: ${modelId}. Must be a non-empty string.`,
+ },
+ };
+ }
+
+ try {
+ const availableModels = getAvailableModels(projectRoot);
+ const currentConfig = getConfig(projectRoot);
+ let determinedProvider = null; // Initialize provider
+ let warningMessage = null;
+
+ // Find the model data in internal list initially to see if it exists at all
+ const modelData = availableModels.find((m) => m.id === modelId);
+
+ // --- Revised Logic: Prioritize providerHint --- //
+
+ if (providerHint) {
+ // Hint provided (--ollama or --openrouter flag used)
+ if (modelData && modelData.provider === providerHint) {
+ // Found internally AND provider matches the hint
+ determinedProvider = providerHint;
+ report(
+ "info",
+ `Model ${modelId} found internally with matching provider hint ${determinedProvider}.`
+ );
+ } else {
+ // Either not found internally, OR found but under a DIFFERENT provider than hinted.
+ // Proceed with custom logic based ONLY on the hint.
+ if (providerHint === "openrouter") {
+ // Check OpenRouter ONLY because hint was openrouter
+ report("info", `Checking OpenRouter for ${modelId} (as hinted)...`);
+ const openRouterModels = await fetchOpenRouterModels();
+
+ if (
+ openRouterModels &&
+ openRouterModels.some((m) => m.id === modelId)
+ ) {
+ determinedProvider = "openrouter";
+
+ // Check if this is a free model (ends with :free)
+ if (modelId.endsWith(":free")) {
+ warningMessage = `Warning: OpenRouter free model '${modelId}' selected. Free models have significant limitations including lower context windows, reduced rate limits, and may not support advanced features like tool_use. Consider using the paid version '${modelId.replace(":free", "")}' for full functionality.`;
+ } else {
+ warningMessage = `Warning: Custom OpenRouter model '${modelId}' set. This model is not officially validated by Taskmaster and may not function as expected.`;
+ }
+
+ report("warn", warningMessage);
+ } else {
+ // Hinted as OpenRouter but not found in live check
+ throw new Error(
+ `Model ID "${modelId}" not found in the live OpenRouter model list. Please verify the ID and ensure it's available on OpenRouter.`
+ );
+ }
+ } else if (providerHint === "ollama") {
+ // Check Ollama ONLY because hint was ollama
+ report("info", `Checking Ollama for ${modelId} (as hinted)...`);
+
+ // Get the Ollama base URL from config
+ const ollamaBaseURL = getBaseUrlForRole(role, projectRoot);
+ const ollamaModels = await fetchOllamaModels(ollamaBaseURL);
+
+ if (ollamaModels === null) {
+ // Connection failed - server probably not running
+ throw new Error(
+ `Unable to connect to Ollama server at ${ollamaBaseURL}. Please ensure Ollama is running and try again.`
+ );
+ } else if (ollamaModels.some((m) => m.model === modelId)) {
+ determinedProvider = "ollama";
+ warningMessage = `Warning: Custom Ollama model '${modelId}' set. Ensure your Ollama server is running and has pulled this model. Taskmaster cannot guarantee compatibility.`;
+ report("warn", warningMessage);
+ } else {
+ // Server is running but model not found
+ const tagsUrl = `${ollamaBaseURL}/tags`;
+ throw new Error(
+ `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}`);
+ }
+ }
+ } else {
+ // No hint provided (flags not used)
+ if (modelData) {
+ // Found internally, use the provider from the internal list
+ determinedProvider = modelData.provider;
+ report(
+ "info",
+ `Model ${modelId} found internally with provider ${determinedProvider}.`
+ );
+ } else {
+ // Model not found and no provider hint was given
+ return {
+ success: false,
+ error: {
+ code: "MODEL_NOT_FOUND_NO_HINT",
+ message: `Model ID "${modelId}" not found in Taskmaster's supported models. If this is a custom model, please specify the provider using --openrouter or --ollama.`,
+ },
+ };
+ }
+ }
+
+ // --- End of Revised Logic --- //
+
+ // At this point, we should have a determinedProvider if the model is valid (internally or custom)
+ if (!determinedProvider) {
+ // This case acts as a safeguard
+ return {
+ success: false,
+ error: {
+ code: "PROVIDER_UNDETERMINED",
+ message: `Could not determine the provider for model ID "${modelId}".`,
+ },
+ };
+ }
+
+ // Update configuration
+ currentConfig.models[role] = {
+ ...currentConfig.models[role], // Keep existing params like maxTokens
+ provider: determinedProvider,
+ modelId: modelId,
+ };
+
+ // Write updated configuration
+ const writeResult = writeConfig(currentConfig, projectRoot);
+ if (!writeResult) {
+ return {
+ success: false,
+ error: {
+ code: "CONFIG_WRITE_ERROR",
+ message: "Error writing updated configuration to configuration file",
+ },
+ };
+ }
+
+ const successMessage = `Successfully set ${role} model to ${modelId} (Provider: ${determinedProvider})`;
+ report("info", successMessage);
+
+ return {
+ success: true,
+ data: {
+ role,
+ provider: determinedProvider,
+ modelId,
+ message: successMessage,
+ warning: warningMessage, // Include warning in the response data
+ },
+ };
+ } catch (error) {
+ report("error", `Error setting ${role} model: ${error.message}`);
+ return {
+ success: false,
+ error: {
+ code: "SET_MODEL_ERROR",
+ message: error.message,
+ },
+ };
+ }
}
/**
@@ -580,52 +587,52 @@ async function setModel(role, modelId, options = {}) {
* @returns {Object} RESTful response with API key status report
*/
async function getApiKeyStatusReport(options = {}) {
- const { mcpLog, projectRoot, session } = options;
- const report = (level, ...args) => {
- if (mcpLog && typeof mcpLog[level] === 'function') {
- mcpLog[level](...args);
- }
- };
-
- try {
- const providers = getAllProviders();
- const providersToCheck = providers.filter(
- (p) => p.toLowerCase() !== 'ollama'
- ); // Ollama is not a provider, it's a service, doesn't need an api key usually
- const statusReport = providersToCheck.map((provider) => {
- // Use provided projectRoot for MCP status check
- const cliOk = isApiKeySet(provider, session, projectRoot); // Pass session and projectRoot for CLI check
- const mcpOk = getMcpApiKeyStatus(provider, projectRoot);
- return {
- provider,
- cli: cliOk,
- mcp: mcpOk
- };
- });
-
- report('info', 'Successfully generated API key status report.');
- return {
- success: true,
- data: {
- report: statusReport,
- message: 'API key status report generated.'
- }
- };
- } catch (error) {
- report('error', `Error generating API key status report: ${error.message}`);
- return {
- success: false,
- error: {
- code: 'API_KEY_STATUS_ERROR',
- message: error.message
- }
- };
- }
+ const { mcpLog, projectRoot, session } = options;
+ const report = (level, ...args) => {
+ if (mcpLog && typeof mcpLog[level] === "function") {
+ mcpLog[level](...args);
+ }
+ };
+
+ try {
+ const providers = getAllProviders();
+ const providersToCheck = providers.filter(
+ (p) => p.toLowerCase() !== "ollama"
+ ); // Ollama is not a provider, it's a service, doesn't need an api key usually
+ const statusReport = providersToCheck.map((provider) => {
+ // Use provided projectRoot for MCP status check
+ const cliOk = isApiKeySet(provider, session, projectRoot); // Pass session and projectRoot for CLI check
+ const mcpOk = getMcpApiKeyStatus(provider, projectRoot);
+ return {
+ provider,
+ cli: cliOk,
+ mcp: mcpOk,
+ };
+ });
+
+ report("info", "Successfully generated API key status report.");
+ return {
+ success: true,
+ data: {
+ report: statusReport,
+ message: "API key status report generated.",
+ },
+ };
+ } catch (error) {
+ report("error", `Error generating API key status report: ${error.message}`);
+ return {
+ success: false,
+ error: {
+ code: "API_KEY_STATUS_ERROR",
+ message: error.message,
+ },
+ };
+ }
}
export {
- getModelConfiguration,
- getAvailableModelsList,
- setModel,
- getApiKeyStatusReport
+ getModelConfiguration,
+ getAvailableModelsList,
+ setModel,
+ getApiKeyStatusReport,
};