UNPKG

task-master-marcus-ver

Version:

A task management system for ambitious AI-driven development that doesn't overwhelm and confuse Cursor.

100 lines (94 loc) 3.25 kB
/** * tools/parsePRD.js * Tool to parse PRD document and generate tasks */ import { z } from 'zod'; import path from 'path'; import { handleApiResult, createErrorResponse, withNormalizedProjectRoot } from './utils.js'; import { addPRDFileDirect } from '../core/task-master-core.js'; // replace this /** * Register the add_prd tool * @param {Object} server - FastMCP server instance */ export function registerAddPRDTool(server) { server.addTool({ name: 'add_prd_file', description: "Create a Product Requirements Document (PRD) text file called 'prd.txt' based on the user's requirements. Ask the user about their requirements, such as the functions they want to automate and the apps involved. Reinitializing the project is not necessary to run this tool. It is recommended to run add-prd-file after initializing the project in the project root's scripts/ directory.", parameters: z.object({ userRequirements: z .string() // .optional() // .default('scripts/example_prd.txt') .describe("User's requirements and apps required to be included inside the PRD file."), input: z .string() // .optional() .default('scripts/example_prd.txt') .describe('relative path to the sample PRD document format to follow.'), // 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() .default('scripts/prd.txt') .describe( 'Output path for prd.txt file (default: scripts/prd.txt)' ), force: z .boolean() .optional() .default(true) .describe('Overwrite existing output file without prompting.'), append: z .boolean() .optional() .default(true) .describe('Append updates to the existing PRD file, if provided by the user.'), projectRoot: z .string() .describe('The directory of the project. Must be an relative path.') }), execute: withNormalizedProjectRoot(async (args, { log, session }) => { const toolName = 'add_prd_file'; try { log.info( `Executing ${toolName} tool with args: ${JSON.stringify(args)}` ); // Call Direct Function - Pass relevant args including projectRoot const result = await addPRDFileDirect( { userRequirements: args.userRequirements, input: args.input, output: args.output, // numTasks: args.numTasks, force: args.force, append: args.append, projectRoot: args.projectRoot }, log, { session } ); log.info( `${toolName}: Direct function result: success=${result.success}` ); return handleApiResult(result, log, 'Error parsing PRD'); } catch (error) { log.error( `Critical error in ${toolName} tool execute: ${error.message}` ); return createErrorResponse( `Internal tool error (${toolName}): ${error.message}` ); } }) }); }