feat: Add .taskmaster directory (#619)

This commit is contained in:
Ralph Khreish
2025-05-31 16:21:03 +02:00
committed by GitHub
parent 669b744ced
commit 3f64202c9f
151 changed files with 3432 additions and 7584 deletions

View File

@@ -7,11 +7,10 @@ import { z } from 'zod';
import {
handleApiResult,
createErrorResponse,
getProjectRootFromSession,
withNormalizedProjectRoot
} from './utils.js';
import { addDependencyDirect } from '../core/task-master-core.js';
import { findTasksJsonPath } from '../core/utils/path-utils.js';
import { findTasksPath } from '../core/utils/path-utils.js';
/**
* Register the addDependency tool with the MCP server
@@ -44,7 +43,7 @@ export function registerAddDependencyTool(server) {
let tasksJsonPath;
try {
tasksJsonPath = findTasksJsonPath(
tasksJsonPath = findTasksPath(
{ projectRoot: args.projectRoot, file: args.file },
log
);

View File

@@ -10,7 +10,7 @@ import {
withNormalizedProjectRoot
} from './utils.js';
import { addSubtaskDirect } from '../core/task-master-core.js';
import { findTasksJsonPath } from '../core/utils/path-utils.js';
import { findTasksPath } from '../core/utils/path-utils.js';
/**
* Register the addSubtask tool with the MCP server
@@ -67,7 +67,7 @@ export function registerAddSubtaskTool(server) {
// Use args.projectRoot directly (guaranteed by withNormalizedProjectRoot)
let tasksJsonPath;
try {
tasksJsonPath = findTasksJsonPath(
tasksJsonPath = findTasksPath(
{ projectRoot: args.projectRoot, file: args.file },
log
);

View File

@@ -10,7 +10,7 @@ import {
withNormalizedProjectRoot
} from './utils.js';
import { addTaskDirect } from '../core/task-master-core.js';
import { findTasksJsonPath } from '../core/utils/path-utils.js';
import { findTasksPath } from '../core/utils/path-utils.js';
/**
* Register the addTask tool with the MCP server
@@ -70,7 +70,7 @@ export function registerAddTaskTool(server) {
// Use args.projectRoot directly (guaranteed by withNormalizedProjectRoot)
let tasksJsonPath;
try {
tasksJsonPath = findTasksJsonPath(
tasksJsonPath = findTasksPath(
{ projectRoot: args.projectRoot, file: args.file },
log
);

View File

@@ -12,7 +12,8 @@ import {
withNormalizedProjectRoot
} from './utils.js';
import { analyzeTaskComplexityDirect } from '../core/task-master-core.js'; // Assuming core functions are exported via task-master-core.js
import { findTasksJsonPath } from '../core/utils/path-utils.js';
import { findTasksPath } from '../core/utils/path-utils.js';
import { COMPLEXITY_REPORT_FILE } from '../../../src/constants/paths.js';
/**
* Register the analyze_project_complexity tool
@@ -41,7 +42,7 @@ export function registerAnalyzeProjectComplexityTool(server) {
.string()
.optional()
.describe(
'Output file path relative to project root (default: scripts/task-complexity-report.json).'
`Output file path relative to project root (default: ${COMPLEXITY_REPORT_FILE}).`
),
file: z
.string()
@@ -80,7 +81,7 @@ export function registerAnalyzeProjectComplexityTool(server) {
let tasksJsonPath;
try {
tasksJsonPath = findTasksJsonPath(
tasksJsonPath = findTasksPath(
{ projectRoot: args.projectRoot, file: args.file },
log
);
@@ -94,11 +95,7 @@ export function registerAnalyzeProjectComplexityTool(server) {
const outputPath = args.output
? path.resolve(args.projectRoot, args.output)
: path.resolve(
args.projectRoot,
'scripts',
'task-complexity-report.json'
);
: path.resolve(args.projectRoot, COMPLEXITY_REPORT_FILE);
log.info(`${toolName}: Report output path: ${outputPath}`);

View File

@@ -10,7 +10,7 @@ import {
withNormalizedProjectRoot
} from './utils.js';
import { clearSubtasksDirect } from '../core/task-master-core.js';
import { findTasksJsonPath } from '../core/utils/path-utils.js';
import { findTasksPath } from '../core/utils/path-utils.js';
/**
* Register the clearSubtasks tool with the MCP server
@@ -48,7 +48,7 @@ export function registerClearSubtasksTool(server) {
// Use args.projectRoot directly (guaranteed by withNormalizedProjectRoot)
let tasksJsonPath;
try {
tasksJsonPath = findTasksJsonPath(
tasksJsonPath = findTasksPath(
{ projectRoot: args.projectRoot, file: args.file },
log
);

View File

@@ -10,6 +10,7 @@ import {
withNormalizedProjectRoot
} from './utils.js';
import { complexityReportDirect } from '../core/task-master-core.js';
import { COMPLEXITY_REPORT_FILE } from '../../../src/constants/paths.js';
import path from 'path';
/**
@@ -25,7 +26,7 @@ export function registerComplexityReportTool(server) {
.string()
.optional()
.describe(
'Path to the report file (default: scripts/task-complexity-report.json)'
`Path to the report file (default: ${COMPLEXITY_REPORT_FILE})`
),
projectRoot: z
.string()
@@ -40,11 +41,7 @@ export function registerComplexityReportTool(server) {
// Use args.projectRoot directly (guaranteed by withNormalizedProjectRoot)
const reportPath = args.file
? path.resolve(args.projectRoot, args.file)
: path.resolve(
args.projectRoot,
'scripts',
'task-complexity-report.json'
);
: path.resolve(args.projectRoot, COMPLEXITY_REPORT_FILE);
const result = await complexityReportDirect(
{

View File

@@ -10,7 +10,7 @@ import {
withNormalizedProjectRoot
} from './utils.js';
import { expandAllTasksDirect } from '../core/task-master-core.js';
import { findTasksJsonPath } from '../core/utils/path-utils.js';
import { findTasksPath } from '../core/utils/path-utils.js';
/**
* Register the expandAll tool with the MCP server
@@ -67,7 +67,7 @@ export function registerExpandAllTool(server) {
let tasksJsonPath;
try {
tasksJsonPath = findTasksJsonPath(
tasksJsonPath = findTasksPath(
{ projectRoot: args.projectRoot, file: args.file },
log
);

View File

@@ -10,7 +10,7 @@ import {
withNormalizedProjectRoot
} from './utils.js';
import { expandTaskDirect } from '../core/task-master-core.js';
import { findTasksJsonPath } from '../core/utils/path-utils.js';
import { findTasksPath } from '../core/utils/path-utils.js';
/**
* Register the expand-task tool with the MCP server
@@ -54,7 +54,7 @@ export function registerExpandTaskTool(server) {
// Use args.projectRoot directly (guaranteed by withNormalizedProjectRoot)
let tasksJsonPath;
try {
tasksJsonPath = findTasksJsonPath(
tasksJsonPath = findTasksPath(
{ projectRoot: args.projectRoot, file: args.file },
log
);

View File

@@ -10,7 +10,7 @@ import {
withNormalizedProjectRoot
} from './utils.js';
import { fixDependenciesDirect } from '../core/task-master-core.js';
import { findTasksJsonPath } from '../core/utils/path-utils.js';
import { findTasksPath } from '../core/utils/path-utils.js';
/**
* Register the fixDependencies tool with the MCP server
@@ -33,7 +33,7 @@ export function registerFixDependenciesTool(server) {
// Use args.projectRoot directly (guaranteed by withNormalizedProjectRoot)
let tasksJsonPath;
try {
tasksJsonPath = findTasksJsonPath(
tasksJsonPath = findTasksPath(
{ projectRoot: args.projectRoot, file: args.file },
log
);

View File

@@ -10,7 +10,7 @@ import {
withNormalizedProjectRoot
} from './utils.js';
import { generateTaskFilesDirect } from '../core/task-master-core.js';
import { findTasksJsonPath } from '../core/utils/path-utils.js';
import { findTasksPath } from '../core/utils/path-utils.js';
import path from 'path';
/**
@@ -39,7 +39,7 @@ export function registerGenerateTool(server) {
// Use args.projectRoot directly (guaranteed by withNormalizedProjectRoot)
let tasksJsonPath;
try {
tasksJsonPath = findTasksJsonPath(
tasksJsonPath = findTasksPath(
{ projectRoot: args.projectRoot, file: args.file },
log
);

View File

@@ -11,7 +11,7 @@ import {
} from './utils.js';
import { showTaskDirect } from '../core/task-master-core.js';
import {
findTasksJsonPath,
findTasksPath,
findComplexityReportPath
} from '../core/utils/path-utils.js';
@@ -77,7 +77,7 @@ export function registerShowTaskTool(server) {
// Resolve the path to tasks.json using the NORMALIZED projectRoot from args
let tasksJsonPath;
try {
tasksJsonPath = findTasksJsonPath(
tasksJsonPath = findTasksPath(
{ projectRoot: projectRoot, file: file },
log
);
@@ -94,8 +94,10 @@ export function registerShowTaskTool(server) {
let complexityReportPath;
try {
complexityReportPath = findComplexityReportPath(
projectRoot,
args.complexityReport,
{
projectRoot: projectRoot,
complexityReport: args.complexityReport
},
log
);
} catch (error) {

View File

@@ -11,8 +11,8 @@ import {
} from './utils.js';
import { listTasksDirect } from '../core/task-master-core.js';
import {
findTasksJsonPath,
findComplexityReportPath
resolveTasksPath,
resolveComplexityReportPath
} from '../core/utils/path-utils.js';
/**
@@ -55,13 +55,10 @@ export function registerListTasksTool(server) {
try {
log.info(`Getting tasks with filters: ${JSON.stringify(args)}`);
// Use args.projectRoot directly (guaranteed by withNormalizedProjectRoot)
// Resolve the path to tasks.json using new path utilities
let tasksJsonPath;
try {
tasksJsonPath = findTasksJsonPath(
{ projectRoot: args.projectRoot, file: args.file },
log
);
tasksJsonPath = resolveTasksPath(args, session);
} catch (error) {
log.error(`Error finding tasks.json: ${error.message}`);
return createErrorResponse(
@@ -72,14 +69,13 @@ export function registerListTasksTool(server) {
// Resolve the path to complexity report
let complexityReportPath;
try {
complexityReportPath = findComplexityReportPath(
args.projectRoot,
args.complexityReport,
log
);
complexityReportPath = resolveComplexityReportPath(args, session);
} catch (error) {
log.error(`Error finding complexity report: ${error.message}`);
// This is optional, so we don't fail the operation
complexityReportPath = null;
}
const result = await listTasksDirect(
{
tasksJsonPath: tasksJsonPath,

View File

@@ -10,7 +10,7 @@ import {
withNormalizedProjectRoot
} from './utils.js';
import { moveTaskDirect } from '../core/task-master-core.js';
import { findTasksJsonPath } from '../core/utils/path-utils.js';
import { findTasksPath } from '../core/utils/path-utils.js';
/**
* Register the moveTask tool with the MCP server
@@ -45,7 +45,7 @@ export function registerMoveTaskTool(server) {
let tasksJsonPath = args.file;
if (!tasksJsonPath) {
tasksJsonPath = findTasksJsonPath(args, log);
tasksJsonPath = findTasksPath(args, log);
}
// Parse comma-separated IDs

View File

@@ -1,22 +1,22 @@
/**
* tools/next-task.js
* Tool to find the next task to work on
* Tool to find the next task to work on based on dependencies and status
*/
import { z } from 'zod';
import {
handleApiResult,
createErrorResponse,
handleApiResult,
withNormalizedProjectRoot
} from './utils.js';
import { nextTaskDirect } from '../core/task-master-core.js';
import {
findTasksJsonPath,
findComplexityReportPath
resolveTasksPath,
resolveComplexityReportPath
} from '../core/utils/path-utils.js';
/**
* Register the next-task tool with the MCP server
* Register the nextTask tool with the MCP server
* @param {Object} server - FastMCP server instance
*/
export function registerNextTaskTool(server) {
@@ -40,13 +40,10 @@ export function registerNextTaskTool(server) {
try {
log.info(`Finding next task with args: ${JSON.stringify(args)}`);
// Use args.projectRoot directly (guaranteed by withNormalizedProjectRoot)
// Resolve the path to tasks.json using new path utilities
let tasksJsonPath;
try {
tasksJsonPath = findTasksJsonPath(
{ projectRoot: args.projectRoot, file: args.file },
log
);
tasksJsonPath = resolveTasksPath(args, session);
} catch (error) {
log.error(`Error finding tasks.json: ${error.message}`);
return createErrorResponse(
@@ -54,17 +51,16 @@ export function registerNextTaskTool(server) {
);
}
// Resolve the path to complexity report
// Resolve the path to complexity report (optional)
let complexityReportPath;
try {
complexityReportPath = findComplexityReportPath(
args.projectRoot,
args.complexityReport,
log
);
complexityReportPath = resolveComplexityReportPath(args, session);
} catch (error) {
log.error(`Error finding complexity report: ${error.message}`);
// This is optional, so we don't fail the operation
complexityReportPath = null;
}
const result = await nextTaskDirect(
{
tasksJsonPath: tasksJsonPath,
@@ -73,19 +69,10 @@ export function registerNextTaskTool(server) {
log
);
if (result.success) {
log.info(
`Successfully found next task: ${result.data?.task?.id || 'No available tasks'}`
);
} else {
log.error(
`Failed to find next task: ${result.error?.message || 'Unknown error'}`
);
}
log.info(`Next task result: ${result.success ? 'found' : 'none'}`);
return handleApiResult(result, log, 'Error finding next task');
} catch (error) {
log.error(`Error in nextTask tool: ${error.message}`);
log.error(`Error finding next task: ${error.message}`);
return createErrorResponse(error.message);
}
})

View File

@@ -4,13 +4,17 @@
*/
import { z } from 'zod';
import path from 'path';
import {
handleApiResult,
createErrorResponse,
withNormalizedProjectRoot
withNormalizedProjectRoot,
createErrorResponse
} from './utils.js';
import { parsePRDDirect } from '../core/task-master-core.js';
import {
PRD_FILE,
TASKMASTER_DOCS_DIR,
TASKMASTER_TASKS_FILE
} from '../../../src/constants/paths.js';
/**
* Register the parse_prd tool
@@ -19,80 +23,52 @@ import { parsePRDDirect } from '../core/task-master-core.js';
export function registerParsePRDTool(server) {
server.addTool({
name: 'parse_prd',
description:
"Parse a Product Requirements Document (PRD) text file to automatically generate initial tasks. Reinitializing the project is not necessary to run this tool. It is recommended to run parse-prd after initializing the project and creating/importing a prd.txt file in the project root's scripts/ directory.",
description: `Parse a Product Requirements Document (PRD) text file to automatically generate initial tasks. Reinitializing the project is not necessary to run this tool. It is recommended to run parse-prd after initializing the project and creating/importing a prd.txt file in the project root's ${TASKMASTER_DOCS_DIR} directory.`,
parameters: z.object({
input: z
.string()
.optional()
.default('scripts/prd.txt')
.default(PRD_FILE)
.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()
.optional()
.describe(
`Output path for tasks.json file (default: ${TASKMASTER_TASKS_FILE})`
),
numTasks: z
.string()
.optional()
.describe(
'Approximate number of top-level tasks to generate (default: 10). As the agent, if you have enough information, ensure to enter a number of tasks that would logically scale with project complexity. Avoid entering numbers above 50 due to context window limitations.'
),
output: z
.string()
.optional()
.describe(
'Output path for tasks.json file (default: tasks/tasks.json)'
),
force: z
.boolean()
.optional()
.default(false)
.describe('Overwrite existing output file without prompting.'),
append: z
.boolean()
.optional()
.default(false)
.describe('Append generated tasks to existing file.'),
research: z
.boolean()
.optional()
.default(false)
.describe(
'Use the research model for research-backed task generation, providing more comprehensive, accurate and up-to-date task details.'
'Enable Taskmaster to use the research role for potentially more informed task generation. Requires appropriate API key.'
),
projectRoot: z
.string()
.describe('The directory of the project. Must be an absolute path.')
append: z
.boolean()
.optional()
.describe('Append generated tasks to existing file.')
}),
execute: withNormalizedProjectRoot(async (args, { log, session }) => {
const toolName = 'parse_prd';
try {
log.info(
`Executing ${toolName} tool with args: ${JSON.stringify(args)}`
);
// Call Direct Function - Pass relevant args including projectRoot
const result = await parsePRDDirect(
{
input: args.input,
output: args.output,
numTasks: args.numTasks,
force: args.force,
append: args.append,
research: args.research,
projectRoot: args.projectRoot
},
log,
{ session }
);
log.info(
`${toolName}: Direct function result: success=${result.success}`
);
return handleApiResult(result, log, 'Error parsing PRD');
const result = await parsePRDDirect(args, log, { session });
return handleApiResult(result, log);
} catch (error) {
log.error(
`Critical error in ${toolName} tool execute: ${error.message}`
);
return createErrorResponse(
`Internal tool error (${toolName}): ${error.message}`
);
log.error(`Error in parse_prd: ${error.message}`);
return createErrorResponse(`Failed to parse PRD: ${error.message}`);
}
})
});

View File

@@ -10,7 +10,7 @@ import {
withNormalizedProjectRoot
} from './utils.js';
import { removeDependencyDirect } from '../core/task-master-core.js';
import { findTasksJsonPath } from '../core/utils/path-utils.js';
import { findTasksPath } from '../core/utils/path-utils.js';
/**
* Register the removeDependency tool with the MCP server
@@ -42,7 +42,7 @@ export function registerRemoveDependencyTool(server) {
// Use args.projectRoot directly (guaranteed by withNormalizedProjectRoot)
let tasksJsonPath;
try {
tasksJsonPath = findTasksJsonPath(
tasksJsonPath = findTasksPath(
{ projectRoot: args.projectRoot, file: args.file },
log
);

View File

@@ -10,7 +10,7 @@ import {
withNormalizedProjectRoot
} from './utils.js';
import { removeSubtaskDirect } from '../core/task-master-core.js';
import { findTasksJsonPath } from '../core/utils/path-utils.js';
import { findTasksPath } from '../core/utils/path-utils.js';
/**
* Register the removeSubtask tool with the MCP server
@@ -53,7 +53,7 @@ export function registerRemoveSubtaskTool(server) {
// Use args.projectRoot directly (guaranteed by withNormalizedProjectRoot)
let tasksJsonPath;
try {
tasksJsonPath = findTasksJsonPath(
tasksJsonPath = findTasksPath(
{ projectRoot: args.projectRoot, file: args.file },
log
);

View File

@@ -10,7 +10,7 @@ import {
withNormalizedProjectRoot
} from './utils.js';
import { removeTaskDirect } from '../core/task-master-core.js';
import { findTasksJsonPath } from '../core/utils/path-utils.js';
import { findTasksPath } from '../core/utils/path-utils.js';
/**
* Register the remove-task tool with the MCP server
@@ -42,7 +42,7 @@ export function registerRemoveTaskTool(server) {
// Use args.projectRoot directly (guaranteed by withNormalizedProjectRoot)
let tasksJsonPath;
try {
tasksJsonPath = findTasksJsonPath(
tasksJsonPath = findTasksPath(
{ projectRoot: args.projectRoot, file: args.file },
log
);

View File

@@ -14,7 +14,7 @@ import {
nextTaskDirect
} from '../core/task-master-core.js';
import {
findTasksJsonPath,
findTasksPath,
findComplexityReportPath
} from '../core/utils/path-utils.js';
import { TASK_STATUS_OPTIONS } from '../../../src/constants/task-status.js';
@@ -56,7 +56,7 @@ export function registerSetTaskStatusTool(server) {
// Use args.projectRoot directly (guaranteed by withNormalizedProjectRoot)
let tasksJsonPath;
try {
tasksJsonPath = findTasksJsonPath(
tasksJsonPath = findTasksPath(
{ projectRoot: args.projectRoot, file: args.file },
log
);
@@ -70,8 +70,10 @@ export function registerSetTaskStatusTool(server) {
let complexityReportPath;
try {
complexityReportPath = findComplexityReportPath(
args.projectRoot,
args.complexityReport,
{
projectRoot: args.projectRoot,
complexityReport: args.complexityReport
},
log
);
} catch (error) {

View File

@@ -10,7 +10,7 @@ import {
withNormalizedProjectRoot
} from './utils.js';
import { updateSubtaskByIdDirect } from '../core/task-master-core.js';
import { findTasksJsonPath } from '../core/utils/path-utils.js';
import { findTasksPath } from '../core/utils/path-utils.js';
/**
* Register the update-subtask tool with the MCP server
@@ -20,7 +20,7 @@ export function registerUpdateSubtaskTool(server) {
server.addTool({
name: 'update_subtask',
description:
'Appends timestamped information to a specific subtask without replacing existing content',
'Appends timestamped information to a specific subtask without replacing existing content. If you just want to update the subtask status, use set_task_status instead.',
parameters: z.object({
id: z
.string()
@@ -44,7 +44,7 @@ export function registerUpdateSubtaskTool(server) {
let tasksJsonPath;
try {
tasksJsonPath = findTasksJsonPath(
tasksJsonPath = findTasksPath(
{ projectRoot: args.projectRoot, file: args.file },
log
);

View File

@@ -10,7 +10,7 @@ import {
withNormalizedProjectRoot
} from './utils.js';
import { updateTaskByIdDirect } from '../core/task-master-core.js';
import { findTasksJsonPath } from '../core/utils/path-utils.js';
import { findTasksPath } from '../core/utils/path-utils.js';
/**
* Register the update-task tool with the MCP server
@@ -48,7 +48,7 @@ export function registerUpdateTaskTool(server) {
let tasksJsonPath;
try {
tasksJsonPath = findTasksJsonPath(
tasksJsonPath = findTasksPath(
{ projectRoot: args.projectRoot, file: args.file },
log
);

View File

@@ -10,7 +10,7 @@ import {
withNormalizedProjectRoot
} from './utils.js';
import { updateTasksDirect } from '../core/task-master-core.js';
import { findTasksJsonPath } from '../core/utils/path-utils.js';
import { findTasksPath } from '../core/utils/path-utils.js';
/**
* Register the update tool with the MCP server
@@ -56,7 +56,7 @@ export function registerUpdateTool(server) {
let tasksJsonPath;
try {
tasksJsonPath = findTasksJsonPath({ projectRoot, file }, log);
tasksJsonPath = findTasksPath({ projectRoot, file }, log);
log.info(`${toolName}: Resolved tasks path: ${tasksJsonPath}`);
} catch (error) {
log.error(`${toolName}: Error finding tasks.json: ${error.message}`);

View File

@@ -10,7 +10,7 @@ import {
withNormalizedProjectRoot
} from './utils.js';
import { validateDependenciesDirect } from '../core/task-master-core.js';
import { findTasksJsonPath } from '../core/utils/path-utils.js';
import { findTasksPath } from '../core/utils/path-utils.js';
/**
* Register the validateDependencies tool with the MCP server
@@ -34,7 +34,7 @@ export function registerValidateDependenciesTool(server) {
// Use args.projectRoot directly (guaranteed by withNormalizedProjectRoot)
let tasksJsonPath;
try {
tasksJsonPath = findTasksJsonPath(
tasksJsonPath = findTasksPath(
{ projectRoot: args.projectRoot, file: args.file },
log
);