superdesign-claude
Version:
SuperDesign Claude v2.2 - AI-Powered Design Pattern Recognition Engine with Code Generation - PHASE 1 + CODE GEN
121 lines (98 loc) • 5.8 kB
JavaScript
/**
* SuperDesign Claude v2.0 - Analyze Command
* Focused intent analysis with detailed output
*/
const { Command } = require('commander');
const chalk = require('chalk');
const boxen = require('boxen');
const ora = require('ora');
const { IntentAnalysisEngine } = require('../src/engines/intent/IntentAnalysisEngine');
const { ConfigurationManager } = require('../src/config/ConfigurationManager');
const { LoggingManager } = require('../src/utils/LoggingManager');
const program = new Command();
async function analyzeIntent(prompt, options) {
const spinner = ora('Initializing analysis engine...').start();
try {
// Initialize services
const config = new ConfigurationManager();
const logger = new LoggingManager(config.get('logging'));
const engine = new IntentAnalysisEngine({ logger });
spinner.text = 'Analyzing intent...';
const result = await engine.analyze(prompt);
spinner.succeed(chalk.green('Analysis complete'));
// Display detailed analysis
console.log('\\n' + boxen(
chalk.cyan.bold('🧠 Intent Analysis Report'),
{ padding: 1, borderColor: 'cyan', borderStyle: 'round' }
));
console.log(chalk.yellow.bold('\\n📝 Input Analysis:'));
console.log(chalk.white(` Original Prompt: "${prompt}"`));
console.log(chalk.white(` Tokens Processed: ${result.metadata.tokensProcessed}`));
console.log(chalk.white(` Processing Time: ${result.metadata.analysisTime}ms`));
console.log(chalk.white(` Confidence Score: ${Math.round(result.metadata.confidenceScore * 100)}%`));
console.log(chalk.yellow.bold('\\n🎯 Intent Classification:'));
console.log(chalk.white(` Primary Type: ${result.intent.type}`));
console.log(chalk.white(` Subtype: ${result.intent.subtype}`));
console.log(chalk.white(` Confidence: ${Math.round(result.intent.confidence * 100)}%`));
console.log(chalk.white(` Keywords: ${result.intent.keywords.join(', ')}`));
console.log(chalk.yellow.bold('\\n🎨 Style Analysis:'));
console.log(chalk.white(` Primary Style: ${result.style.primary || 'Not detected'}`));
console.log(chalk.white(` Secondary Styles: ${result.style.secondary.join(', ') || 'None'}`));
console.log(chalk.white(` Style Modifiers: ${result.style.modifiers.join(', ') || 'None'}`));
console.log(chalk.yellow.bold('\\n🧩 Component Analysis:'));
console.log(chalk.white(` Required Components: ${result.components.required.join(', ')}`));
console.log(chalk.white(` Optional Components: ${result.components.optional.join(', ') || 'None'}`));
console.log(chalk.white(` Suggested Components: ${result.components.suggested.join(', ') || 'None'}`));
console.log(chalk.yellow.bold('\\n🔧 Constraints & Preferences:'));
console.log(chalk.white(` Responsive: ${result.constraints.responsive ? 'Yes' : 'No'}`));
console.log(chalk.white(` Accessibility: ${result.constraints.accessibility ? 'Yes' : 'No'}`));
console.log(chalk.white(` Performance Optimized: ${result.constraints.performance ? 'Yes' : 'No'}`));
console.log(chalk.white(` Target Device: ${result.constraints.device || 'Not specified'}`));
console.log(chalk.white(` Browser: ${result.constraints.browser || 'Not specified'}`));
console.log(chalk.yellow.bold('\\n🎭 User Preferences:'));
console.log(chalk.white(` Color Preference: ${result.preferences.colorPreference || 'Not specified'}`));
console.log(chalk.white(` Layout Density: ${result.preferences.layoutDensity}`));
console.log(chalk.white(` Animation Level: ${result.preferences.animationLevel}`));
console.log(chalk.white(` Complexity: ${result.preferences.complexity}`));
if (result.context.hasExistingDesigns) {
console.log(chalk.yellow.bold('\\n📁 Project Context:'));
console.log(chalk.white(` Existing Designs: Yes`));
console.log(chalk.white(` Project Type: ${result.context.projectType}`));
console.log(chalk.white(` Framework: ${result.context.framework || 'Not detected'}`));
}
// Export results if requested
if (options.export) {
const fs = require('fs');
const filename = options.output || `intent-analysis-${Date.now()}.json`;
fs.writeFileSync(filename, JSON.stringify(result, null, 2));
console.log(chalk.green(`\\n✅ Results exported to ${filename}`));
}
// Show raw data if requested
if (options.raw) {
console.log(chalk.gray('\\n🔍 Raw Analysis Data:'));
console.log(JSON.stringify(result, null, 2));
}
} catch (error) {
spinner.fail(chalk.red('Analysis failed'));
console.error(chalk.red('Error:'), error.message);
if (options.verbose) {
console.error(chalk.gray('Stack trace:'), error.stack);
}
process.exit(1);
}
}
program
.name('superdesign-analyze')
.description('Analyze design intent from natural language prompt')
.version('2.0.0')
.argument('<prompt>', 'Design description to analyze')
.option('-e, --export', 'Export results to JSON file')
.option('-o, --output <filename>', 'Output filename for exported results')
.option('-r, --raw', 'Show raw analysis data')
.option('-v, --verbose', 'Show verbose error information')
.action(analyzeIntent);
if (require.main === module) {
program.parse(process.argv);
}
module.exports = { analyzeIntent };