UNPKG

task-engine-ai-core

Version:

Revolutionary AI-driven task management system with complete transformation trilogy: Frontend v0.1.0, Backend v0.2.0, CLI v0.3.0 - Enterprise-grade performance with 95% improvements

113 lines (92 loc) โ€ข 3.95 kB
#!/usr/bin/env node /** * Test script for automatic MCP setup * * This script tests the auto-setup functionality in a new project context. * * @version 0.3.5 * @author Task Engine AI Team */ import { mkdirSync, rmSync, existsSync } from 'fs'; import { join, resolve } from 'path'; import { execSync } from 'child_process'; async function testAutoSetup() { console.log('๐Ÿงช Testing Automatic MCP Setup'); console.log('==============================\n'); // Create a temporary test project const testProjectPath = resolve(process.cwd(), 'test-project-temp'); try { // Clean up any existing test project if (existsSync(testProjectPath)) { rmSync(testProjectPath, { recursive: true, force: true }); } // Create test project mkdirSync(testProjectPath, { recursive: true }); console.log(`๐Ÿ“ Created test project: ${testProjectPath}`); // Create a basic package.json to make it look like a real project const packageJson = { name: 'test-project', version: '1.0.0', description: 'Test project for Task Engine AI auto-setup' }; const { writeFileSync } = await import('fs'); writeFileSync( join(testProjectPath, 'package.json'), JSON.stringify(packageJson, null, 2) ); // Create .cursor directory to simulate Cursor IDE mkdirSync(join(testProjectPath, '.cursor'), { recursive: true }); console.log('๐Ÿ“ฑ Created .cursor directory (simulating Cursor IDE)'); // Change to test project directory process.chdir(testProjectPath); console.log(`๐Ÿ“‚ Changed to test project directory: ${process.cwd()}`); // Import and run auto-setup console.log('\n๐Ÿ”ง Running auto-setup...\n'); // Set environment variable to point to test project process.env.TASK_MASTER_PROJECT_ROOT = testProjectPath; const AutoMCPSetup = (await import('./auto-setup-mcp.js')).default; const autoSetup = new AutoMCPSetup(); await autoSetup.autoSetup(); console.log('\nโœ… Auto-setup completed successfully!'); // Verify the configuration was created const mcpConfigPath = join(testProjectPath, '.cursor', 'mcp.json'); if (existsSync(mcpConfigPath)) { console.log('โœ… MCP configuration file created'); const { readFileSync } = await import('fs'); const config = JSON.parse(readFileSync(mcpConfigPath, 'utf8')); console.log('๐Ÿ“‹ Configuration preview:'); console.log(JSON.stringify(config, null, 2)); } else { console.log('โŒ MCP configuration file not found'); } // Verify Task Engine structure was created const taskMasterDir = join(testProjectPath, '.taskmaster'); if (existsSync(taskMasterDir)) { console.log('โœ… Task Engine project structure created'); } else { console.log('โŒ Task Engine project structure not found'); } } catch (error) { console.error('\nโŒ Test failed:', error.message); console.error(error.stack); } finally { // Clean up test project try { process.chdir(resolve(testProjectPath, '..')); if (existsSync(testProjectPath)) { rmSync(testProjectPath, { recursive: true, force: true }); console.log('\n๐Ÿงน Cleaned up test project'); } } catch (cleanupError) { console.error('โš ๏ธ Failed to clean up test project:', cleanupError.message); } } } // Run test if called directly if (import.meta.url === `file://${process.argv[1]}`) { testAutoSetup().catch(error => { console.error('Test failed:', error); process.exit(1); }); } export default testAutoSetup;