Merge branch 'next' of https://github.com/eyaltoledano/claude-task-master into joedanz/flexible-brand-rules
# Conflicts: # scripts/modules/commands.js
This commit is contained in:
@@ -577,7 +577,8 @@ async function _unifiedServiceRunner(serviceType, params) {
|
||||
lowerCaseMessage.includes('does not support tool_use') ||
|
||||
lowerCaseMessage.includes('tool use is not supported') ||
|
||||
lowerCaseMessage.includes('tools are not supported') ||
|
||||
lowerCaseMessage.includes('function calling is not supported')
|
||||
lowerCaseMessage.includes('function calling is not supported') ||
|
||||
lowerCaseMessage.includes('tool use is not supported')
|
||||
) {
|
||||
const specificErrorMsg = `Model '${modelId || 'unknown'}' via provider '${providerName || 'unknown'}' does not support the 'tool use' required by generateObjectService. Please configure a model that supports tool/function calling for the '${currentRole}' role, or use generateTextService if structured output is not strictly required.`;
|
||||
log('error', `[Tool Support Error] ${specificErrorMsg}`);
|
||||
|
||||
@@ -100,6 +100,7 @@ import {
|
||||
RULES_SETUP_ACTION
|
||||
} from '../../src/constants/rules-actions.js';
|
||||
import { getTaskMasterVersion } from '../../src/utils/getVersion.js';
|
||||
import { syncTasksToReadme } from './sync-readme.js';
|
||||
import { RULE_PROFILES } from '../../src/constants/profiles.js';
|
||||
import {
|
||||
convertAllRulesToProfileRules,
|
||||
@@ -3032,6 +3033,54 @@ Examples:
|
||||
}
|
||||
});
|
||||
|
||||
// sync-readme command
|
||||
programInstance
|
||||
.command('sync-readme')
|
||||
.description('Sync the current task list to README.md in the project root')
|
||||
.option(
|
||||
'-f, --file <file>',
|
||||
'Path to the tasks file',
|
||||
TASKMASTER_TASKS_FILE
|
||||
)
|
||||
.option('--with-subtasks', 'Include subtasks in the README output')
|
||||
.option(
|
||||
'-s, --status <status>',
|
||||
'Show only tasks matching this status (e.g., pending, done)'
|
||||
)
|
||||
.action(async (options) => {
|
||||
const tasksPath = options.file || TASKMASTER_TASKS_FILE;
|
||||
const withSubtasks = options.withSubtasks || false;
|
||||
const status = options.status || null;
|
||||
|
||||
// Find project root
|
||||
const projectRoot = findProjectRoot();
|
||||
if (!projectRoot) {
|
||||
console.error(
|
||||
chalk.red(
|
||||
'Error: Could not find project root. Make sure you are in a Task Master project directory.'
|
||||
)
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log(
|
||||
chalk.blue(
|
||||
`📝 Syncing tasks to README.md${withSubtasks ? ' (with subtasks)' : ''}${status ? ` (status: ${status})` : ''}...`
|
||||
)
|
||||
);
|
||||
|
||||
const success = await syncTasksToReadme(projectRoot, {
|
||||
withSubtasks,
|
||||
status,
|
||||
tasksPath
|
||||
});
|
||||
|
||||
if (!success) {
|
||||
console.error(chalk.red('❌ Failed to sync tasks to README.md'));
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
|
||||
return programInstance;
|
||||
}
|
||||
|
||||
|
||||
@@ -563,11 +563,6 @@ function cleanupSubtaskDependencies(tasksData) {
|
||||
* @param {string} tasksPath - Path to tasks.json
|
||||
*/
|
||||
async function validateDependenciesCommand(tasksPath, options = {}) {
|
||||
// Only display banner if not in silent mode
|
||||
if (!isSilentMode()) {
|
||||
displayBanner();
|
||||
}
|
||||
|
||||
log('info', 'Checking for invalid dependencies in task files...');
|
||||
|
||||
// Read tasks data
|
||||
@@ -691,11 +686,6 @@ function countAllDependencies(tasks) {
|
||||
* @param {Object} options - Options object
|
||||
*/
|
||||
async function fixDependenciesCommand(tasksPath, options = {}) {
|
||||
// Only display banner if not in silent mode
|
||||
if (!isSilentMode()) {
|
||||
displayBanner();
|
||||
}
|
||||
|
||||
log('info', 'Checking for and fixing invalid dependencies in tasks.json...');
|
||||
|
||||
try {
|
||||
|
||||
@@ -153,7 +153,7 @@
|
||||
"id": "sonar-pro",
|
||||
"swe_score": 0,
|
||||
"cost_per_1m_tokens": { "input": 3, "output": 15 },
|
||||
"allowed_roles": ["research"],
|
||||
"allowed_roles": ["main", "research"],
|
||||
"max_tokens": 8700
|
||||
},
|
||||
{
|
||||
@@ -174,14 +174,14 @@
|
||||
"id": "sonar-reasoning-pro",
|
||||
"swe_score": 0.211,
|
||||
"cost_per_1m_tokens": { "input": 2, "output": 8 },
|
||||
"allowed_roles": ["main", "fallback"],
|
||||
"allowed_roles": ["main", "research", "fallback"],
|
||||
"max_tokens": 8700
|
||||
},
|
||||
{
|
||||
"id": "sonar-reasoning",
|
||||
"swe_score": 0.211,
|
||||
"cost_per_1m_tokens": { "input": 1, "output": 5 },
|
||||
"allowed_roles": ["main", "fallback"],
|
||||
"allowed_roles": ["main", "research", "fallback"],
|
||||
"max_tokens": 8700
|
||||
}
|
||||
],
|
||||
|
||||
184
scripts/modules/sync-readme.js
Normal file
184
scripts/modules/sync-readme.js
Normal file
@@ -0,0 +1,184 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import chalk from 'chalk';
|
||||
import { log, findProjectRoot } from './utils.js';
|
||||
import { getProjectName } from './config-manager.js';
|
||||
import listTasks from './task-manager/list-tasks.js';
|
||||
|
||||
/**
|
||||
* Creates a basic README structure if one doesn't exist
|
||||
* @param {string} projectName - Name of the project
|
||||
* @returns {string} - Basic README content
|
||||
*/
|
||||
function createBasicReadme(projectName) {
|
||||
return `# ${projectName}
|
||||
|
||||
This project is managed using Task Master.
|
||||
|
||||
`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create UTM tracking URL for task-master.dev
|
||||
* @param {string} projectRoot - The project root path
|
||||
* @returns {string} - UTM tracked URL
|
||||
*/
|
||||
function createTaskMasterUrl(projectRoot) {
|
||||
// Get the actual folder name from the project root path
|
||||
const folderName = path.basename(projectRoot);
|
||||
|
||||
// Clean folder name for UTM (replace spaces/special chars with hyphens)
|
||||
const cleanFolderName = folderName
|
||||
.toLowerCase()
|
||||
.replace(/[^a-z0-9]/g, '-')
|
||||
.replace(/-+/g, '-')
|
||||
.replace(/^-|-$/g, '');
|
||||
|
||||
const utmParams = new URLSearchParams({
|
||||
utm_source: 'github-readme',
|
||||
utm_medium: 'readme-export',
|
||||
utm_campaign: cleanFolderName || 'task-sync',
|
||||
utm_content: 'task-export-link'
|
||||
});
|
||||
|
||||
return `https://task-master.dev?${utmParams.toString()}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the start marker with metadata
|
||||
* @param {Object} options - Export options
|
||||
* @returns {string} - Formatted start marker
|
||||
*/
|
||||
function createStartMarker(options) {
|
||||
const { timestamp, withSubtasks, status, projectRoot } = options;
|
||||
|
||||
// Format status filter text
|
||||
const statusText = status
|
||||
? `Status filter: ${status}`
|
||||
: 'Status filter: none';
|
||||
const subtasksText = withSubtasks ? 'with subtasks' : 'without subtasks';
|
||||
|
||||
// Create the export info content
|
||||
const exportInfo =
|
||||
`🎯 **Taskmaster Export** - ${timestamp}\n` +
|
||||
`📋 Export: ${subtasksText} • ${statusText}\n` +
|
||||
`🔗 Powered by [Task Master](${createTaskMasterUrl(projectRoot)})`;
|
||||
|
||||
// Create a markdown box using code blocks and emojis to mimic our UI style
|
||||
const boxContent =
|
||||
`<!-- TASKMASTER_EXPORT_START -->\n` +
|
||||
`> ${exportInfo.split('\n').join('\n> ')}\n\n`;
|
||||
|
||||
return boxContent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the end marker
|
||||
* @returns {string} - Formatted end marker
|
||||
*/
|
||||
function createEndMarker() {
|
||||
return (
|
||||
`\n> 📋 **End of Taskmaster Export** - Tasks are synced from your project using the \`sync-readme\` command.\n` +
|
||||
`<!-- TASKMASTER_EXPORT_END -->\n`
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Syncs the current task list to README.md at the project root
|
||||
* @param {string} projectRoot - Path to the project root directory
|
||||
* @param {Object} options - Options for syncing
|
||||
* @param {boolean} options.withSubtasks - Include subtasks in the output (default: false)
|
||||
* @param {string} options.status - Filter by status (e.g., 'pending', 'done')
|
||||
* @param {string} options.tasksPath - Custom path to tasks.json
|
||||
* @returns {boolean} - True if sync was successful, false otherwise
|
||||
*/
|
||||
export async function syncTasksToReadme(projectRoot = null, options = {}) {
|
||||
try {
|
||||
const actualProjectRoot = projectRoot || findProjectRoot() || '.';
|
||||
const { withSubtasks = false, status, tasksPath } = options;
|
||||
|
||||
// Get current tasks using the list-tasks functionality with markdown-readme format
|
||||
const tasksOutput = await listTasks(
|
||||
tasksPath ||
|
||||
path.join(actualProjectRoot, '.taskmaster', 'tasks', 'tasks.json'),
|
||||
status,
|
||||
null,
|
||||
withSubtasks,
|
||||
'markdown-readme'
|
||||
);
|
||||
|
||||
if (!tasksOutput) {
|
||||
console.log(chalk.red('❌ Failed to generate task output'));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Generate timestamp and metadata
|
||||
const timestamp =
|
||||
new Date().toISOString().replace('T', ' ').substring(0, 19) + ' UTC';
|
||||
const projectName = getProjectName(actualProjectRoot);
|
||||
|
||||
// Create the export markers with metadata
|
||||
const startMarker = createStartMarker({
|
||||
timestamp,
|
||||
withSubtasks,
|
||||
status,
|
||||
projectRoot: actualProjectRoot
|
||||
});
|
||||
|
||||
const endMarker = createEndMarker();
|
||||
|
||||
// Create the complete task section
|
||||
const taskSection = startMarker + tasksOutput + endMarker;
|
||||
|
||||
// Read current README content
|
||||
const readmePath = path.join(actualProjectRoot, 'README.md');
|
||||
let readmeContent = '';
|
||||
try {
|
||||
readmeContent = fs.readFileSync(readmePath, 'utf8');
|
||||
} catch (err) {
|
||||
if (err.code === 'ENOENT') {
|
||||
// Create basic README if it doesn't exist
|
||||
readmeContent = createBasicReadme(projectName);
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if export markers exist and replace content between them
|
||||
const startComment = '<!-- TASKMASTER_EXPORT_START -->';
|
||||
const endComment = '<!-- TASKMASTER_EXPORT_END -->';
|
||||
|
||||
let updatedContent;
|
||||
const startIndex = readmeContent.indexOf(startComment);
|
||||
const endIndex = readmeContent.indexOf(endComment);
|
||||
|
||||
if (startIndex !== -1 && endIndex !== -1) {
|
||||
// Replace existing task section
|
||||
const beforeTasks = readmeContent.substring(0, startIndex);
|
||||
const afterTasks = readmeContent.substring(endIndex + endComment.length);
|
||||
updatedContent = beforeTasks + taskSection + afterTasks;
|
||||
} else {
|
||||
// Append to end of README
|
||||
updatedContent = readmeContent + '\n' + taskSection;
|
||||
}
|
||||
|
||||
// Write updated content to README
|
||||
fs.writeFileSync(readmePath, updatedContent, 'utf8');
|
||||
|
||||
console.log(chalk.green('✅ Successfully synced tasks to README.md'));
|
||||
console.log(
|
||||
chalk.cyan(
|
||||
`📋 Export details: ${withSubtasks ? 'with' : 'without'} subtasks${status ? `, status: ${status}` : ''}`
|
||||
)
|
||||
);
|
||||
console.log(chalk.gray(`📍 Location: ${readmePath}`));
|
||||
|
||||
return true;
|
||||
} catch (error) {
|
||||
console.log(chalk.red('❌ Failed to sync tasks to README:'), error.message);
|
||||
log('error', `README sync error: ${error.message}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export default syncTasksToReadme;
|
||||
@@ -10,6 +10,8 @@ import {
|
||||
getStatusWithColor,
|
||||
startLoadingIndicator,
|
||||
stopLoadingIndicator,
|
||||
succeedLoadingIndicator,
|
||||
failLoadingIndicator,
|
||||
displayAiUsageSummary
|
||||
} from '../ui.js';
|
||||
import { readJSON, writeJSON, log as consoleLog, truncate } from '../utils.js';
|
||||
@@ -279,7 +281,7 @@ async function addTask(
|
||||
// CLI-only feedback for the dependency analysis
|
||||
if (outputFormat === 'text') {
|
||||
console.log(
|
||||
boxen(chalk.cyan.bold('Task Context Analysis') + '\n', {
|
||||
boxen(chalk.cyan.bold('Task Context Analysis'), {
|
||||
padding: { top: 0, bottom: 0, left: 1, right: 1 },
|
||||
margin: { top: 0, bottom: 0 },
|
||||
borderColor: 'cyan',
|
||||
@@ -492,9 +494,9 @@ async function addTask(
|
||||
includeScore: true, // Return match scores
|
||||
threshold: 0.4, // Lower threshold = stricter matching (range 0-1)
|
||||
keys: [
|
||||
{ name: 'title', weight: 2 }, // Title is most important
|
||||
{ name: 'description', weight: 1.5 }, // Description is next
|
||||
{ name: 'details', weight: 0.8 }, // Details is less important
|
||||
{ name: 'title', weight: 1.5 }, // Title is most important
|
||||
{ name: 'description', weight: 2 }, // Description is very important
|
||||
{ name: 'details', weight: 3 }, // Details is most important
|
||||
// Search dependencies to find tasks that depend on similar things
|
||||
{ name: 'dependencyTitles', weight: 0.5 }
|
||||
],
|
||||
@@ -502,8 +504,8 @@ async function addTask(
|
||||
shouldSort: true,
|
||||
// Allow searching in nested properties
|
||||
useExtendedSearch: true,
|
||||
// Return up to 15 matches
|
||||
limit: 15
|
||||
// Return up to 50 matches
|
||||
limit: 50
|
||||
};
|
||||
|
||||
// Prepare task data with dependencies expanded as titles for better semantic search
|
||||
@@ -596,32 +598,6 @@ async function addTask(
|
||||
// Get top N results for context
|
||||
const relatedTasks = allRelevantTasks.slice(0, 8);
|
||||
|
||||
// Also look for tasks with similar purposes or categories
|
||||
const purposeCategories = [
|
||||
{ pattern: /(command|cli|flag)/i, label: 'CLI commands' },
|
||||
{ pattern: /(task|subtask|add)/i, label: 'Task management' },
|
||||
{ pattern: /(dependency|depend)/i, label: 'Dependency handling' },
|
||||
{ pattern: /(AI|model|prompt)/i, label: 'AI integration' },
|
||||
{ pattern: /(UI|display|show)/i, label: 'User interface' },
|
||||
{ pattern: /(schedule|time|cron)/i, label: 'Scheduling' }, // Added scheduling category
|
||||
{ pattern: /(config|setting|option)/i, label: 'Configuration' } // Added configuration category
|
||||
];
|
||||
|
||||
promptCategory = purposeCategories.find((cat) =>
|
||||
cat.pattern.test(prompt)
|
||||
);
|
||||
const categoryTasks = promptCategory
|
||||
? data.tasks
|
||||
.filter(
|
||||
(t) =>
|
||||
promptCategory.pattern.test(t.title) ||
|
||||
promptCategory.pattern.test(t.description) ||
|
||||
(t.details && promptCategory.pattern.test(t.details))
|
||||
)
|
||||
.filter((t) => !relatedTasks.some((rt) => rt.id === t.id))
|
||||
.slice(0, 3)
|
||||
: [];
|
||||
|
||||
// Format basic task overviews
|
||||
if (relatedTasks.length > 0) {
|
||||
contextTasks = `\nRelevant tasks identified by semantic similarity:\n${relatedTasks
|
||||
@@ -632,12 +608,6 @@ async function addTask(
|
||||
.join('\n')}`;
|
||||
}
|
||||
|
||||
if (categoryTasks.length > 0) {
|
||||
contextTasks += `\n\nTasks related to ${promptCategory.label}:\n${categoryTasks
|
||||
.map((t) => `- Task ${t.id}: ${t.title} - ${t.description}`)
|
||||
.join('\n')}`;
|
||||
}
|
||||
|
||||
if (
|
||||
recentTasks.length > 0 &&
|
||||
!contextTasks.includes('Recently created tasks')
|
||||
@@ -650,13 +620,10 @@ async function addTask(
|
||||
}
|
||||
|
||||
// Add detailed information about the most relevant tasks
|
||||
const allDetailedTasks = [
|
||||
...relatedTasks.slice(0, 5),
|
||||
...categoryTasks.slice(0, 2)
|
||||
];
|
||||
const allDetailedTasks = [...relatedTasks.slice(0, 25)];
|
||||
uniqueDetailedTasks = Array.from(
|
||||
new Map(allDetailedTasks.map((t) => [t.id, t])).values()
|
||||
).slice(0, 8);
|
||||
).slice(0, 20);
|
||||
|
||||
if (uniqueDetailedTasks.length > 0) {
|
||||
contextTasks += `\n\nDetailed information about relevant tasks:`;
|
||||
@@ -715,18 +682,14 @@ async function addTask(
|
||||
}
|
||||
|
||||
// Additional analysis of common patterns
|
||||
const similarPurposeTasks = promptCategory
|
||||
? data.tasks.filter(
|
||||
(t) =>
|
||||
promptCategory.pattern.test(t.title) ||
|
||||
promptCategory.pattern.test(t.description)
|
||||
)
|
||||
: [];
|
||||
const similarPurposeTasks = data.tasks.filter((t) =>
|
||||
prompt.toLowerCase().includes(t.title.toLowerCase())
|
||||
);
|
||||
|
||||
let commonDeps = []; // Initialize commonDeps
|
||||
|
||||
if (similarPurposeTasks.length > 0) {
|
||||
contextTasks += `\n\nCommon patterns for ${promptCategory ? promptCategory.label : 'similar'} tasks:`;
|
||||
contextTasks += `\n\nCommon patterns for similar tasks:`;
|
||||
|
||||
// Collect dependencies from similar purpose tasks
|
||||
const similarDeps = similarPurposeTasks
|
||||
@@ -743,7 +706,7 @@ async function addTask(
|
||||
// Get most common dependencies for similar tasks
|
||||
commonDeps = Object.entries(depCounts)
|
||||
.sort((a, b) => b[1] - a[1])
|
||||
.slice(0, 5);
|
||||
.slice(0, 10);
|
||||
|
||||
if (commonDeps.length > 0) {
|
||||
contextTasks += '\nMost common dependencies for similar tasks:';
|
||||
@@ -760,7 +723,7 @@ async function addTask(
|
||||
if (outputFormat === 'text') {
|
||||
console.log(
|
||||
chalk.gray(
|
||||
` Fuzzy search across ${data.tasks.length} tasks using full prompt and ${promptWords.length} keywords`
|
||||
` Context search across ${data.tasks.length} tasks using full prompt and ${promptWords.length} keywords`
|
||||
)
|
||||
);
|
||||
|
||||
@@ -768,7 +731,7 @@ async function addTask(
|
||||
console.log(
|
||||
chalk.gray(`\n High relevance matches (score < 0.25):`)
|
||||
);
|
||||
highRelevance.slice(0, 5).forEach((t) => {
|
||||
highRelevance.slice(0, 25).forEach((t) => {
|
||||
console.log(
|
||||
chalk.yellow(` • ⭐ Task ${t.id}: ${truncate(t.title, 50)}`)
|
||||
);
|
||||
@@ -779,24 +742,13 @@ async function addTask(
|
||||
console.log(
|
||||
chalk.gray(`\n Medium relevance matches (score < 0.4):`)
|
||||
);
|
||||
mediumRelevance.slice(0, 3).forEach((t) => {
|
||||
mediumRelevance.slice(0, 10).forEach((t) => {
|
||||
console.log(
|
||||
chalk.green(` • Task ${t.id}: ${truncate(t.title, 50)}`)
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
if (promptCategory && categoryTasks.length > 0) {
|
||||
console.log(
|
||||
chalk.gray(`\n Tasks related to ${promptCategory.label}:`)
|
||||
);
|
||||
categoryTasks.forEach((t) => {
|
||||
console.log(
|
||||
chalk.magenta(` • Task ${t.id}: ${truncate(t.title, 50)}`)
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
// Show dependency patterns
|
||||
if (commonDeps && commonDeps.length > 0) {
|
||||
console.log(
|
||||
@@ -864,10 +816,7 @@ async function addTask(
|
||||
numericDependencies.length > 0
|
||||
? dependentTasks.length // Use length of tasks from explicit dependency path
|
||||
: uniqueDetailedTasks.length // Use length of tasks from fuzzy search path
|
||||
)}` +
|
||||
(promptCategory
|
||||
? `\n${chalk.cyan('Category detected: ')}${chalk.yellow(promptCategory.label)}`
|
||||
: ''),
|
||||
)}`,
|
||||
{
|
||||
padding: { top: 0, bottom: 1, left: 1, right: 1 },
|
||||
margin: { top: 1, bottom: 0 },
|
||||
@@ -931,7 +880,7 @@ async function addTask(
|
||||
// Start the loading indicator - only for text mode
|
||||
if (outputFormat === 'text') {
|
||||
loadingIndicator = startLoadingIndicator(
|
||||
`Generating new task with ${useResearch ? 'Research' : 'Main'} AI...\n`
|
||||
`Generating new task with ${useResearch ? 'Research' : 'Main'} AI... \n`
|
||||
);
|
||||
}
|
||||
|
||||
@@ -976,17 +925,33 @@ async function addTask(
|
||||
}
|
||||
|
||||
report('Successfully generated task data from AI.', 'success');
|
||||
|
||||
// Success! Show checkmark
|
||||
if (loadingIndicator) {
|
||||
succeedLoadingIndicator(
|
||||
loadingIndicator,
|
||||
'Task generated successfully'
|
||||
);
|
||||
loadingIndicator = null; // Clear it
|
||||
}
|
||||
} catch (error) {
|
||||
// Failure! Show X
|
||||
if (loadingIndicator) {
|
||||
failLoadingIndicator(loadingIndicator, 'AI generation failed');
|
||||
loadingIndicator = null;
|
||||
}
|
||||
report(
|
||||
`DEBUG: generateObjectService caught error: ${error.message}`,
|
||||
'debug'
|
||||
);
|
||||
report(`Error generating task with AI: ${error.message}`, 'error');
|
||||
if (loadingIndicator) stopLoadingIndicator(loadingIndicator);
|
||||
throw error; // Re-throw error after logging
|
||||
} finally {
|
||||
report('DEBUG: generateObjectService finally block reached.', 'debug');
|
||||
if (loadingIndicator) stopLoadingIndicator(loadingIndicator); // Ensure indicator stops
|
||||
// Clean up if somehow still running
|
||||
if (loadingIndicator) {
|
||||
stopLoadingIndicator(loadingIndicator);
|
||||
}
|
||||
}
|
||||
// --- End Refactored AI Interaction ---
|
||||
}
|
||||
@@ -1057,7 +1022,7 @@ async function addTask(
|
||||
truncate(newTask.description, 47)
|
||||
]);
|
||||
|
||||
console.log(chalk.green('✅ New task created successfully:'));
|
||||
console.log(chalk.green('✓ New task created successfully:'));
|
||||
console.log(table.toString());
|
||||
|
||||
// Helper to get priority color
|
||||
|
||||
@@ -13,8 +13,6 @@ import generateTaskFiles from './generate-task-files.js';
|
||||
* @param {string} taskIds - Task IDs to clear subtasks from
|
||||
*/
|
||||
function clearSubtasks(tasksPath, taskIds) {
|
||||
displayBanner();
|
||||
|
||||
log('info', `Reading tasks from ${tasksPath}...`);
|
||||
const data = readJSON(tasksPath);
|
||||
if (!data || !data.tasks) {
|
||||
|
||||
@@ -36,11 +36,6 @@ function listTasks(
|
||||
outputFormat = 'text'
|
||||
) {
|
||||
try {
|
||||
// Only display banner for text output
|
||||
if (outputFormat === 'text') {
|
||||
displayBanner();
|
||||
}
|
||||
|
||||
const data = readJSON(tasksPath); // Reads the whole tasks.json
|
||||
if (!data || !data.tasks) {
|
||||
throw new Error(`No valid tasks found in ${tasksPath}`);
|
||||
@@ -125,86 +120,7 @@ function listTasks(
|
||||
const subtaskCompletionPercentage =
|
||||
totalSubtasks > 0 ? (completedSubtasks / totalSubtasks) * 100 : 0;
|
||||
|
||||
// For JSON output, return structured data
|
||||
if (outputFormat === 'json') {
|
||||
// *** Modification: Remove 'details' field for JSON output ***
|
||||
const tasksWithoutDetails = filteredTasks.map((task) => {
|
||||
// <-- USES filteredTasks!
|
||||
// Omit 'details' from the parent task
|
||||
const { details, ...taskRest } = task;
|
||||
|
||||
// If subtasks exist, omit 'details' from them too
|
||||
if (taskRest.subtasks && Array.isArray(taskRest.subtasks)) {
|
||||
taskRest.subtasks = taskRest.subtasks.map((subtask) => {
|
||||
const { details: subtaskDetails, ...subtaskRest } = subtask;
|
||||
return subtaskRest;
|
||||
});
|
||||
}
|
||||
return taskRest;
|
||||
});
|
||||
// *** End of Modification ***
|
||||
|
||||
return {
|
||||
tasks: tasksWithoutDetails, // <--- THIS IS THE ARRAY BEING RETURNED
|
||||
filter: statusFilter || 'all', // Return the actual filter used
|
||||
stats: {
|
||||
total: totalTasks,
|
||||
completed: doneCount,
|
||||
inProgress: inProgressCount,
|
||||
pending: pendingCount,
|
||||
blocked: blockedCount,
|
||||
deferred: deferredCount,
|
||||
cancelled: cancelledCount,
|
||||
completionPercentage,
|
||||
subtasks: {
|
||||
total: totalSubtasks,
|
||||
completed: completedSubtasks,
|
||||
inProgress: inProgressSubtasks,
|
||||
pending: pendingSubtasks,
|
||||
blocked: blockedSubtasks,
|
||||
deferred: deferredSubtasks,
|
||||
cancelled: cancelledSubtasks,
|
||||
completionPercentage: subtaskCompletionPercentage
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// ... existing code for text output ...
|
||||
|
||||
// Calculate status breakdowns as percentages of total
|
||||
const taskStatusBreakdown = {
|
||||
'in-progress': totalTasks > 0 ? (inProgressCount / totalTasks) * 100 : 0,
|
||||
pending: totalTasks > 0 ? (pendingCount / totalTasks) * 100 : 0,
|
||||
blocked: totalTasks > 0 ? (blockedCount / totalTasks) * 100 : 0,
|
||||
deferred: totalTasks > 0 ? (deferredCount / totalTasks) * 100 : 0,
|
||||
cancelled: totalTasks > 0 ? (cancelledCount / totalTasks) * 100 : 0
|
||||
};
|
||||
|
||||
const subtaskStatusBreakdown = {
|
||||
'in-progress':
|
||||
totalSubtasks > 0 ? (inProgressSubtasks / totalSubtasks) * 100 : 0,
|
||||
pending: totalSubtasks > 0 ? (pendingSubtasks / totalSubtasks) * 100 : 0,
|
||||
blocked: totalSubtasks > 0 ? (blockedSubtasks / totalSubtasks) * 100 : 0,
|
||||
deferred:
|
||||
totalSubtasks > 0 ? (deferredSubtasks / totalSubtasks) * 100 : 0,
|
||||
cancelled:
|
||||
totalSubtasks > 0 ? (cancelledSubtasks / totalSubtasks) * 100 : 0
|
||||
};
|
||||
|
||||
// Create progress bars with status breakdowns
|
||||
const taskProgressBar = createProgressBar(
|
||||
completionPercentage,
|
||||
30,
|
||||
taskStatusBreakdown
|
||||
);
|
||||
const subtaskProgressBar = createProgressBar(
|
||||
subtaskCompletionPercentage,
|
||||
30,
|
||||
subtaskStatusBreakdown
|
||||
);
|
||||
|
||||
// Calculate dependency statistics
|
||||
// Calculate dependency statistics (moved up to be available for all output formats)
|
||||
const completedTaskIds = new Set(
|
||||
data.tasks
|
||||
.filter((t) => t.status === 'done' || t.status === 'completed')
|
||||
@@ -276,6 +192,118 @@ function listTasks(
|
||||
// Find next task to work on, passing the complexity report
|
||||
const nextItem = findNextTask(data.tasks, complexityReport);
|
||||
|
||||
// For JSON output, return structured data
|
||||
if (outputFormat === 'json') {
|
||||
// *** Modification: Remove 'details' field for JSON output ***
|
||||
const tasksWithoutDetails = filteredTasks.map((task) => {
|
||||
// <-- USES filteredTasks!
|
||||
// Omit 'details' from the parent task
|
||||
const { details, ...taskRest } = task;
|
||||
|
||||
// If subtasks exist, omit 'details' from them too
|
||||
if (taskRest.subtasks && Array.isArray(taskRest.subtasks)) {
|
||||
taskRest.subtasks = taskRest.subtasks.map((subtask) => {
|
||||
const { details: subtaskDetails, ...subtaskRest } = subtask;
|
||||
return subtaskRest;
|
||||
});
|
||||
}
|
||||
return taskRest;
|
||||
});
|
||||
// *** End of Modification ***
|
||||
|
||||
return {
|
||||
tasks: tasksWithoutDetails, // <--- THIS IS THE ARRAY BEING RETURNED
|
||||
filter: statusFilter || 'all', // Return the actual filter used
|
||||
stats: {
|
||||
total: totalTasks,
|
||||
completed: doneCount,
|
||||
inProgress: inProgressCount,
|
||||
pending: pendingCount,
|
||||
blocked: blockedCount,
|
||||
deferred: deferredCount,
|
||||
cancelled: cancelledCount,
|
||||
completionPercentage,
|
||||
subtasks: {
|
||||
total: totalSubtasks,
|
||||
completed: completedSubtasks,
|
||||
inProgress: inProgressSubtasks,
|
||||
pending: pendingSubtasks,
|
||||
blocked: blockedSubtasks,
|
||||
deferred: deferredSubtasks,
|
||||
cancelled: cancelledSubtasks,
|
||||
completionPercentage: subtaskCompletionPercentage
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// For markdown-readme output, return formatted markdown
|
||||
if (outputFormat === 'markdown-readme') {
|
||||
return generateMarkdownOutput(data, filteredTasks, {
|
||||
totalTasks,
|
||||
completedTasks,
|
||||
completionPercentage,
|
||||
doneCount,
|
||||
inProgressCount,
|
||||
pendingCount,
|
||||
blockedCount,
|
||||
deferredCount,
|
||||
cancelledCount,
|
||||
totalSubtasks,
|
||||
completedSubtasks,
|
||||
subtaskCompletionPercentage,
|
||||
inProgressSubtasks,
|
||||
pendingSubtasks,
|
||||
blockedSubtasks,
|
||||
deferredSubtasks,
|
||||
cancelledSubtasks,
|
||||
tasksWithNoDeps,
|
||||
tasksReadyToWork,
|
||||
tasksWithUnsatisfiedDeps,
|
||||
mostDependedOnTask,
|
||||
mostDependedOnTaskId,
|
||||
maxDependents,
|
||||
avgDependenciesPerTask,
|
||||
complexityReport,
|
||||
withSubtasks,
|
||||
nextItem
|
||||
});
|
||||
}
|
||||
|
||||
// ... existing code for text output ...
|
||||
|
||||
// Calculate status breakdowns as percentages of total
|
||||
const taskStatusBreakdown = {
|
||||
'in-progress': totalTasks > 0 ? (inProgressCount / totalTasks) * 100 : 0,
|
||||
pending: totalTasks > 0 ? (pendingCount / totalTasks) * 100 : 0,
|
||||
blocked: totalTasks > 0 ? (blockedCount / totalTasks) * 100 : 0,
|
||||
deferred: totalTasks > 0 ? (deferredCount / totalTasks) * 100 : 0,
|
||||
cancelled: totalTasks > 0 ? (cancelledCount / totalTasks) * 100 : 0
|
||||
};
|
||||
|
||||
const subtaskStatusBreakdown = {
|
||||
'in-progress':
|
||||
totalSubtasks > 0 ? (inProgressSubtasks / totalSubtasks) * 100 : 0,
|
||||
pending: totalSubtasks > 0 ? (pendingSubtasks / totalSubtasks) * 100 : 0,
|
||||
blocked: totalSubtasks > 0 ? (blockedSubtasks / totalSubtasks) * 100 : 0,
|
||||
deferred:
|
||||
totalSubtasks > 0 ? (deferredSubtasks / totalSubtasks) * 100 : 0,
|
||||
cancelled:
|
||||
totalSubtasks > 0 ? (cancelledSubtasks / totalSubtasks) * 100 : 0
|
||||
};
|
||||
|
||||
// Create progress bars with status breakdowns
|
||||
const taskProgressBar = createProgressBar(
|
||||
completionPercentage,
|
||||
30,
|
||||
taskStatusBreakdown
|
||||
);
|
||||
const subtaskProgressBar = createProgressBar(
|
||||
subtaskCompletionPercentage,
|
||||
30,
|
||||
subtaskStatusBreakdown
|
||||
);
|
||||
|
||||
// Get terminal width - more reliable method
|
||||
let terminalWidth;
|
||||
try {
|
||||
@@ -764,4 +792,232 @@ function getWorkItemDescription(item, allTasks) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate markdown-formatted output for README files
|
||||
* @param {Object} data - Full tasks data
|
||||
* @param {Array} filteredTasks - Filtered tasks array
|
||||
* @param {Object} stats - Statistics object
|
||||
* @returns {string} - Formatted markdown string
|
||||
*/
|
||||
function generateMarkdownOutput(data, filteredTasks, stats) {
|
||||
const {
|
||||
totalTasks,
|
||||
completedTasks,
|
||||
completionPercentage,
|
||||
doneCount,
|
||||
inProgressCount,
|
||||
pendingCount,
|
||||
blockedCount,
|
||||
deferredCount,
|
||||
cancelledCount,
|
||||
totalSubtasks,
|
||||
completedSubtasks,
|
||||
subtaskCompletionPercentage,
|
||||
inProgressSubtasks,
|
||||
pendingSubtasks,
|
||||
blockedSubtasks,
|
||||
deferredSubtasks,
|
||||
cancelledSubtasks,
|
||||
tasksWithNoDeps,
|
||||
tasksReadyToWork,
|
||||
tasksWithUnsatisfiedDeps,
|
||||
mostDependedOnTask,
|
||||
mostDependedOnTaskId,
|
||||
maxDependents,
|
||||
avgDependenciesPerTask,
|
||||
complexityReport,
|
||||
withSubtasks,
|
||||
nextItem
|
||||
} = stats;
|
||||
|
||||
let markdown = '';
|
||||
|
||||
// Create progress bars for markdown (using Unicode block characters)
|
||||
const createMarkdownProgressBar = (percentage, width = 20) => {
|
||||
const filled = Math.round((percentage / 100) * width);
|
||||
const empty = width - filled;
|
||||
return '█'.repeat(filled) + '░'.repeat(empty);
|
||||
};
|
||||
|
||||
// Dashboard section
|
||||
markdown += '```\n';
|
||||
markdown +=
|
||||
'╭─────────────────────────────────────────────────────────╮╭─────────────────────────────────────────────────────────╮\n';
|
||||
markdown +=
|
||||
'│ ││ │\n';
|
||||
markdown +=
|
||||
'│ Project Dashboard ││ Dependency Status & Next Task │\n';
|
||||
markdown += `│ Tasks Progress: ${createMarkdownProgressBar(completionPercentage, 20)} ${Math.round(completionPercentage)}% ││ Dependency Metrics: │\n`;
|
||||
markdown += `│ ${Math.round(completionPercentage)}% ││ • Tasks with no dependencies: ${tasksWithNoDeps} │\n`;
|
||||
markdown += `│ Done: ${doneCount} In Progress: ${inProgressCount} Pending: ${pendingCount} Blocked: ${blockedCount} ││ • Tasks ready to work on: ${tasksReadyToWork} │\n`;
|
||||
markdown += `│ Deferred: ${deferredCount} Cancelled: ${cancelledCount} ││ • Tasks blocked by dependencies: ${tasksWithUnsatisfiedDeps} │\n`;
|
||||
markdown += `│ ││ • Most depended-on task: #${mostDependedOnTaskId} (${maxDependents} dependents) │\n`;
|
||||
markdown += `│ Subtasks Progress: ${createMarkdownProgressBar(subtaskCompletionPercentage, 20)} ││ • Avg dependencies per task: ${avgDependenciesPerTask.toFixed(1)} │\n`;
|
||||
markdown += `│ ${Math.round(subtaskCompletionPercentage)}% ${Math.round(subtaskCompletionPercentage)}% ││ │\n`;
|
||||
markdown += `│ Completed: ${completedSubtasks}/${totalSubtasks} In Progress: ${inProgressSubtasks} Pending: ${pendingSubtasks} ││ Next Task to Work On: │\n`;
|
||||
|
||||
const nextTaskTitle = nextItem
|
||||
? nextItem.title.length > 40
|
||||
? nextItem.title.substring(0, 37) + '...'
|
||||
: nextItem.title
|
||||
: 'No task available';
|
||||
|
||||
markdown += `│ Blocked: ${blockedSubtasks} Deferred: ${deferredSubtasks} Cancelled: ${cancelledSubtasks} ││ ID: ${nextItem ? nextItem.id : 'N/A'} - ${nextTaskTitle} │\n`;
|
||||
markdown += `│ ││ Priority: ${nextItem ? nextItem.priority || 'medium' : ''} Dependencies: ${nextItem && nextItem.dependencies && nextItem.dependencies.length > 0 ? 'Some' : 'None'} │\n`;
|
||||
markdown += `│ Priority Breakdown: ││ Complexity: ${nextItem && nextItem.complexityScore ? '● ' + nextItem.complexityScore : 'N/A'} │\n`;
|
||||
markdown += `│ • High priority: ${data.tasks.filter((t) => t.priority === 'high').length} │╰─────────────────────────────────────────────────────────╯\n`;
|
||||
markdown += `│ • Medium priority: ${data.tasks.filter((t) => t.priority === 'medium').length} │\n`;
|
||||
markdown += `│ • Low priority: ${data.tasks.filter((t) => t.priority === 'low').length} │\n`;
|
||||
markdown += '│ │\n';
|
||||
markdown += '╰─────────────────────────────────────────────────────────╯\n';
|
||||
|
||||
// Tasks table
|
||||
markdown +=
|
||||
'┌───────────┬──────────────────────────────────────┬─────────────────┬──────────────┬───────────────────────┬───────────┐\n';
|
||||
markdown +=
|
||||
'│ ID │ Title │ Status │ Priority │ Dependencies │ Complexi… │\n';
|
||||
markdown +=
|
||||
'├───────────┼──────────────────────────────────────┼─────────────────┼──────────────┼───────────────────────┼───────────┤\n';
|
||||
|
||||
// Helper function to format status with symbols
|
||||
const getStatusSymbol = (status) => {
|
||||
switch (status) {
|
||||
case 'done':
|
||||
case 'completed':
|
||||
return '✓ done';
|
||||
case 'in-progress':
|
||||
return '► in-progress';
|
||||
case 'pending':
|
||||
return '○ pending';
|
||||
case 'blocked':
|
||||
return '⭕ blocked';
|
||||
case 'deferred':
|
||||
return 'x deferred';
|
||||
case 'cancelled':
|
||||
return 'x cancelled';
|
||||
case 'review':
|
||||
return '? review';
|
||||
default:
|
||||
return status || 'pending';
|
||||
}
|
||||
};
|
||||
|
||||
// Helper function to format dependencies without color codes
|
||||
const formatDependenciesForMarkdown = (deps, allTasks) => {
|
||||
if (!deps || deps.length === 0) return 'None';
|
||||
return deps
|
||||
.map((depId) => {
|
||||
const depTask = allTasks.find((t) => t.id === depId);
|
||||
return depTask ? depId.toString() : depId.toString();
|
||||
})
|
||||
.join(', ');
|
||||
};
|
||||
|
||||
// Process all tasks
|
||||
filteredTasks.forEach((task) => {
|
||||
const taskTitle = task.title; // No truncation for README
|
||||
const statusSymbol = getStatusSymbol(task.status);
|
||||
const priority = task.priority || 'medium';
|
||||
const deps = formatDependenciesForMarkdown(task.dependencies, data.tasks);
|
||||
const complexity = task.complexityScore
|
||||
? `● ${task.complexityScore}`
|
||||
: 'N/A';
|
||||
|
||||
markdown += `│ ${task.id.toString().padEnd(9)} │ ${taskTitle.substring(0, 36).padEnd(36)} │ ${statusSymbol.padEnd(15)} │ ${priority.padEnd(12)} │ ${deps.substring(0, 21).padEnd(21)} │ ${complexity.padEnd(9)} │\n`;
|
||||
|
||||
// Add subtasks if requested
|
||||
if (withSubtasks && task.subtasks && task.subtasks.length > 0) {
|
||||
task.subtasks.forEach((subtask) => {
|
||||
const subtaskTitle = `└─ ${subtask.title}`; // No truncation
|
||||
const subtaskStatus = getStatusSymbol(subtask.status);
|
||||
const subtaskDeps = formatDependenciesForMarkdown(
|
||||
subtask.dependencies,
|
||||
data.tasks
|
||||
);
|
||||
const subtaskComplexity = subtask.complexityScore
|
||||
? subtask.complexityScore.toString()
|
||||
: 'N/A';
|
||||
|
||||
markdown +=
|
||||
'├───────────┼──────────────────────────────────────┼─────────────────┼──────────────┼───────────────────────┼───────────┤\n';
|
||||
markdown += `│ ${task.id}.${subtask.id}${' '.padEnd(6)} │ ${subtaskTitle.substring(0, 36).padEnd(36)} │ ${subtaskStatus.padEnd(15)} │ - │ ${subtaskDeps.substring(0, 21).padEnd(21)} │ ${subtaskComplexity.padEnd(9)} │\n`;
|
||||
});
|
||||
}
|
||||
|
||||
markdown +=
|
||||
'├───────────┼──────────────────────────────────────┼─────────────────┼──────────────┼───────────────────────┼───────────┤\n';
|
||||
});
|
||||
|
||||
// Close the table
|
||||
markdown = markdown.slice(
|
||||
0,
|
||||
-1 *
|
||||
'├───────────┼──────────────────────────────────────┼─────────────────┼──────────────┼───────────────────────┼───────────┤\n'
|
||||
.length
|
||||
);
|
||||
markdown +=
|
||||
'└───────────┴──────────────────────────────────────┴─────────────────┴──────────────┴───────────────────────┴───────────┘\n';
|
||||
markdown += '```\n\n';
|
||||
|
||||
// Next task recommendation
|
||||
if (nextItem) {
|
||||
markdown +=
|
||||
'╭────────────────────────────────────────────── ⚡ RECOMMENDED NEXT TASK ⚡ ──────────────────────────────────────────────╮\n';
|
||||
markdown +=
|
||||
'│ │\n';
|
||||
markdown += `│ 🔥 Next Task to Work On: #${nextItem.id} - ${nextItem.title} │\n`;
|
||||
markdown +=
|
||||
'│ │\n';
|
||||
markdown += `│ Priority: ${nextItem.priority || 'medium'} Status: ${getStatusSymbol(nextItem.status)} │\n`;
|
||||
markdown += `│ Dependencies: ${nextItem.dependencies && nextItem.dependencies.length > 0 ? formatDependenciesForMarkdown(nextItem.dependencies, data.tasks) : 'None'} │\n`;
|
||||
markdown +=
|
||||
'│ │\n';
|
||||
markdown += `│ Description: ${getWorkItemDescription(nextItem, data.tasks)} │\n`;
|
||||
markdown +=
|
||||
'│ │\n';
|
||||
|
||||
// Add subtasks if they exist
|
||||
const parentTask = data.tasks.find((t) => t.id === nextItem.id);
|
||||
if (parentTask && parentTask.subtasks && parentTask.subtasks.length > 0) {
|
||||
markdown +=
|
||||
'│ Subtasks: │\n';
|
||||
parentTask.subtasks.forEach((subtask) => {
|
||||
markdown += `│ ${nextItem.id}.${subtask.id} [${subtask.status || 'pending'}] ${subtask.title} │\n`;
|
||||
});
|
||||
markdown +=
|
||||
'│ │\n';
|
||||
}
|
||||
|
||||
markdown += `│ Start working: task-master set-status --id=${nextItem.id} --status=in-progress │\n`;
|
||||
markdown += `│ View details: task-master show ${nextItem.id} │\n`;
|
||||
markdown +=
|
||||
'│ │\n';
|
||||
markdown +=
|
||||
'╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n\n';
|
||||
}
|
||||
|
||||
// Suggested next steps
|
||||
markdown += '\n';
|
||||
markdown +=
|
||||
'╭──────────────────────────────────────────────────────────────────────────────────────╮\n';
|
||||
markdown +=
|
||||
'│ │\n';
|
||||
markdown +=
|
||||
'│ Suggested Next Steps: │\n';
|
||||
markdown +=
|
||||
'│ │\n';
|
||||
markdown +=
|
||||
'│ 1. Run task-master next to see what to work on next │\n';
|
||||
markdown +=
|
||||
'│ 2. Run task-master expand --id=<id> to break down a task into subtasks │\n';
|
||||
markdown +=
|
||||
'│ 3. Run task-master set-status --id=<id> --status=done to mark a task as complete │\n';
|
||||
markdown +=
|
||||
'│ │\n';
|
||||
markdown +=
|
||||
'╰──────────────────────────────────────────────────────────────────────────────────────╯\n';
|
||||
|
||||
return markdown;
|
||||
}
|
||||
|
||||
export default listTasks;
|
||||
|
||||
@@ -450,7 +450,14 @@ async function setModel(role, modelId, options = {}) {
|
||||
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.`;
|
||||
|
||||
// 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
|
||||
|
||||
@@ -33,8 +33,6 @@ async function setTaskStatus(tasksPath, taskIdInput, newStatus, options = {}) {
|
||||
|
||||
// Only display UI elements if not in MCP mode
|
||||
if (!isMcpMode) {
|
||||
displayBanner();
|
||||
|
||||
console.log(
|
||||
boxen(chalk.white.bold(`Updating Task Status to: ${newStatus}`), {
|
||||
padding: 1,
|
||||
|
||||
@@ -40,7 +40,7 @@ const warmGradient = gradient(['#fb8b24', '#e36414', '#9a031e']);
|
||||
function displayBanner() {
|
||||
if (isSilentMode()) return;
|
||||
|
||||
console.clear();
|
||||
// console.clear(); // Removing this to avoid clearing the terminal per command
|
||||
const bannerText = figlet.textSync('Task Master', {
|
||||
font: 'Standard',
|
||||
horizontalLayout: 'default',
|
||||
@@ -78,6 +78,8 @@ function displayBanner() {
|
||||
* @returns {Object} Spinner object
|
||||
*/
|
||||
function startLoadingIndicator(message) {
|
||||
if (isSilentMode()) return null;
|
||||
|
||||
const spinner = ora({
|
||||
text: message,
|
||||
color: 'cyan'
|
||||
@@ -87,15 +89,75 @@ function startLoadingIndicator(message) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop a loading indicator
|
||||
* Stop a loading indicator (basic stop, no success/fail indicator)
|
||||
* @param {Object} spinner - Spinner object to stop
|
||||
*/
|
||||
function stopLoadingIndicator(spinner) {
|
||||
if (spinner && spinner.stop) {
|
||||
if (spinner && typeof spinner.stop === 'function') {
|
||||
spinner.stop();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Complete a loading indicator with success (shows checkmark)
|
||||
* @param {Object} spinner - Spinner object to complete
|
||||
* @param {string} message - Optional success message (defaults to current text)
|
||||
*/
|
||||
function succeedLoadingIndicator(spinner, message = null) {
|
||||
if (spinner && typeof spinner.succeed === 'function') {
|
||||
if (message) {
|
||||
spinner.succeed(message);
|
||||
} else {
|
||||
spinner.succeed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Complete a loading indicator with failure (shows X)
|
||||
* @param {Object} spinner - Spinner object to fail
|
||||
* @param {string} message - Optional failure message (defaults to current text)
|
||||
*/
|
||||
function failLoadingIndicator(spinner, message = null) {
|
||||
if (spinner && typeof spinner.fail === 'function') {
|
||||
if (message) {
|
||||
spinner.fail(message);
|
||||
} else {
|
||||
spinner.fail();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Complete a loading indicator with warning (shows warning symbol)
|
||||
* @param {Object} spinner - Spinner object to warn
|
||||
* @param {string} message - Optional warning message (defaults to current text)
|
||||
*/
|
||||
function warnLoadingIndicator(spinner, message = null) {
|
||||
if (spinner && typeof spinner.warn === 'function') {
|
||||
if (message) {
|
||||
spinner.warn(message);
|
||||
} else {
|
||||
spinner.warn();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Complete a loading indicator with info (shows info symbol)
|
||||
* @param {Object} spinner - Spinner object to complete with info
|
||||
* @param {string} message - Optional info message (defaults to current text)
|
||||
*/
|
||||
function infoLoadingIndicator(spinner, message = null) {
|
||||
if (spinner && typeof spinner.info === 'function') {
|
||||
if (message) {
|
||||
spinner.info(message);
|
||||
} else {
|
||||
spinner.info();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a colored progress bar
|
||||
* @param {number} percent - The completion percentage
|
||||
@@ -232,14 +294,14 @@ function getStatusWithColor(status, forTable = false) {
|
||||
}
|
||||
|
||||
const statusConfig = {
|
||||
done: { color: chalk.green, icon: '✅', tableIcon: '✓' },
|
||||
completed: { color: chalk.green, icon: '✅', tableIcon: '✓' },
|
||||
pending: { color: chalk.yellow, icon: '⏱️', tableIcon: '⏱' },
|
||||
done: { color: chalk.green, icon: '✓', tableIcon: '✓' },
|
||||
completed: { color: chalk.green, icon: '✓', tableIcon: '✓' },
|
||||
pending: { color: chalk.yellow, icon: '○', tableIcon: '⏱' },
|
||||
'in-progress': { color: chalk.hex('#FFA500'), icon: '🔄', tableIcon: '►' },
|
||||
deferred: { color: chalk.gray, icon: '⏱️', tableIcon: '⏱' },
|
||||
blocked: { color: chalk.red, icon: '❌', tableIcon: '✗' },
|
||||
review: { color: chalk.magenta, icon: '👀', tableIcon: '👁' },
|
||||
cancelled: { color: chalk.gray, icon: '❌', tableIcon: '✗' }
|
||||
deferred: { color: chalk.gray, icon: 'x', tableIcon: '⏱' },
|
||||
blocked: { color: chalk.red, icon: '!', tableIcon: '✗' },
|
||||
review: { color: chalk.magenta, icon: '?', tableIcon: '?' },
|
||||
cancelled: { color: chalk.gray, icon: '❌', tableIcon: 'x' }
|
||||
};
|
||||
|
||||
const config = statusConfig[status.toLowerCase()] || {
|
||||
@@ -383,8 +445,6 @@ function formatDependenciesWithStatus(
|
||||
* Display a comprehensive help guide
|
||||
*/
|
||||
function displayHelp() {
|
||||
displayBanner();
|
||||
|
||||
// Get terminal width - moved to top of function to make it available throughout
|
||||
const terminalWidth = process.stdout.columns || 100; // Default to 100 if can't detect
|
||||
|
||||
@@ -465,6 +525,11 @@ function displayHelp() {
|
||||
args: '--id=<id> --status=<status>',
|
||||
desc: `Update task status (${TASK_STATUS_OPTIONS.join(', ')})`
|
||||
},
|
||||
{
|
||||
name: 'sync-readme',
|
||||
args: '[--with-subtasks] [--status=<status>]',
|
||||
desc: 'Export tasks to README.md with professional formatting'
|
||||
},
|
||||
{
|
||||
name: 'update',
|
||||
args: '--from=<id> --prompt="<context>"',
|
||||
@@ -745,9 +810,9 @@ function displayHelp() {
|
||||
* @returns {string} Colored complexity score
|
||||
*/
|
||||
function getComplexityWithColor(score) {
|
||||
if (score <= 3) return chalk.green(`🟢 ${score}`);
|
||||
if (score <= 6) return chalk.yellow(`🟡 ${score}`);
|
||||
return chalk.red(`🔴 ${score}`);
|
||||
if (score <= 3) return chalk.green(`● ${score}`);
|
||||
if (score <= 6) return chalk.yellow(`● ${score}`);
|
||||
return chalk.red(`● ${score}`);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -767,8 +832,6 @@ function truncateString(str, maxLength) {
|
||||
* @param {string} tasksPath - Path to the tasks.json file
|
||||
*/
|
||||
async function displayNextTask(tasksPath, complexityReportPath = null) {
|
||||
displayBanner();
|
||||
|
||||
// Read the tasks file
|
||||
const data = readJSON(tasksPath);
|
||||
if (!data || !data.tasks) {
|
||||
@@ -1039,8 +1102,6 @@ async function displayTaskById(
|
||||
complexityReportPath = null,
|
||||
statusFilter = null
|
||||
) {
|
||||
displayBanner();
|
||||
|
||||
// Read the tasks file
|
||||
const data = readJSON(tasksPath);
|
||||
if (!data || !data.tasks) {
|
||||
@@ -1495,8 +1556,6 @@ async function displayTaskById(
|
||||
* @param {string} reportPath - Path to the complexity report file
|
||||
*/
|
||||
async function displayComplexityReport(reportPath) {
|
||||
displayBanner();
|
||||
|
||||
// Check if the report exists
|
||||
if (!fs.existsSync(reportPath)) {
|
||||
console.log(
|
||||
@@ -2093,5 +2152,9 @@ export {
|
||||
displayApiKeyStatus,
|
||||
displayModelConfiguration,
|
||||
displayAvailableModels,
|
||||
displayAiUsageSummary
|
||||
displayAiUsageSummary,
|
||||
succeedLoadingIndicator,
|
||||
failLoadingIndicator,
|
||||
warnLoadingIndicator,
|
||||
infoLoadingIndicator
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user