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
JavaScript
/**
* 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;