import React, { useState, useEffect } from 'react'; import { X, ChevronRight, ChevronLeft, CheckCircle, AlertCircle, Settings, Server, FileText, Sparkles, ExternalLink, Copy } from 'lucide-react'; import { cn } from '../lib/utils'; import { api } from '../utils/api'; import { copyTextToClipboard } from '../utils/clipboard'; const TaskMasterSetupWizard = ({ isOpen = true, onClose, onComplete, currentProject, className = '' }) => { const [currentStep, setCurrentStep] = useState(1); const [loading, setLoading] = useState(false); const [error, setError] = useState(null); const [setupData, setSetupData] = useState({ projectRoot: '', initGit: true, storeTasksInGit: true, addAliases: true, skipInstall: false, rules: ['claude'], mcpConfigured: false, prdContent: '' }); const totalSteps = 4; useEffect(() => { if (currentProject) { setSetupData(prev => ({ ...prev, projectRoot: currentProject.path || '' })); } }, [currentProject]); const steps = [ { id: 1, title: 'Project Configuration', description: 'Configure basic TaskMaster settings for your project' }, { id: 2, title: 'MCP Server Setup', description: 'Ensure TaskMaster MCP server is properly configured' }, { id: 3, title: 'PRD Creation', description: 'Create or import a Product Requirements Document' }, { id: 4, title: 'Complete Setup', description: 'Initialize TaskMaster and generate initial tasks' } ]; const handleNext = async () => { setError(null); try { if (currentStep === 1) { // Validate project configuration if (!setupData.projectRoot) { setError('Project root path is required'); return; } setCurrentStep(2); } else if (currentStep === 2) { // Check MCP server status setLoading(true); try { const mcpStatus = await api.get('/mcp-utils/taskmaster-server'); setSetupData(prev => ({ ...prev, mcpConfigured: mcpStatus.hasMCPServer && mcpStatus.isConfigured })); setCurrentStep(3); } catch (err) { setError('Failed to check MCP server status. You can continue but some features may not work.'); setCurrentStep(3); } } else if (currentStep === 3) { // Validate PRD step if (!setupData.prdContent.trim()) { setError('Please create or import a PRD to continue'); return; } setCurrentStep(4); } else if (currentStep === 4) { // Complete setup await completeSetup(); } } catch (err) { setError(err.message || 'An error occurred'); } finally { setLoading(false); } }; const handlePrevious = () => { if (currentStep > 1) { setCurrentStep(currentStep - 1); setError(null); } }; const completeSetup = async () => { setLoading(true); try { // Initialize TaskMaster project const initResponse = await api.post('/taskmaster/initialize', { projectRoot: setupData.projectRoot, initGit: setupData.initGit, storeTasksInGit: setupData.storeTasksInGit, addAliases: setupData.addAliases, skipInstall: setupData.skipInstall, rules: setupData.rules, yes: true }); if (!initResponse.ok) { throw new Error('Failed to initialize TaskMaster project'); } // Save PRD content if provided if (setupData.prdContent.trim()) { const prdResponse = await api.post('/taskmaster/save-prd', { projectRoot: setupData.projectRoot, content: setupData.prdContent }); if (!prdResponse.ok) { console.warn('Failed to save PRD content'); } } // Parse PRD to generate initial tasks if (setupData.prdContent.trim()) { const parseResponse = await api.post('/taskmaster/parse-prd', { projectRoot: setupData.projectRoot, input: '.taskmaster/docs/prd.txt', numTasks: '10', research: false, force: false }); if (!parseResponse.ok) { console.warn('Failed to parse PRD and generate tasks'); } } onComplete?.(); onClose?.(); } catch (err) { setError(err.message || 'Failed to complete TaskMaster setup'); } finally { setLoading(false); } }; const copyMCPConfig = () => { const mcpConfig = `{ "mcpServers": { "": { "command": "npx", "args": ["-y", "--package=task-master-ai", "task-master-ai"], "env": { "ANTHROPIC_API_KEY": "your_anthropic_key_here", "PERPLEXITY_API_KEY": "your_perplexity_key_here" } } } }`; copyTextToClipboard(mcpConfig); }; const renderStepContent = () => { switch (currentStep) { case 1: return (
Configure TaskMaster settings for your project
TaskMaster works best with the MCP server configured
To enable full TaskMaster integration, add the MCP server configuration to your Claude settings.
{`{
"mcpServers": {
"task-master-ai": {
"command": "npx",
"args": ["-y", "--package=task-master-ai", "task-master-ai"],
"env": {
"ANTHROPIC_API_KEY": "your_anthropic_key_here",
"PERPLEXITY_API_KEY": "your_perplexity_key_here"
}
}
}
}`}
Create or import a PRD to generate initial tasks
TaskMaster will analyze your PRD and automatically generate a structured task list with dependencies, priorities, and implementation details.
Ready to initialize TaskMaster for your project
.taskmaster/docs/prd.txtStep {currentStep} of {totalSteps}: {steps[currentStep - 1]?.description}
{error}