#!/usr/bin/env node
"use strict";
/**
 * BIG ORANGE 🍊 - CLI Command
 * Compare AI responses at different .faf scores
 */
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const commander_1 = require("commander");
const compare_1 = require("./compare");
const bigo_push_1 = require("./bigo-push");
const faf_generator_1 = require("./faf-generator");
const open_1 = __importDefault(require("open"));
const program = new commander_1.Command();
program
    .name('big-orange')
    .description('🍊 Compare AI responses at different .faf context levels')
    .version('1.0.0');
program
    .command('compare')
    .description('Run side-by-side comparison')
    .argument('[project-path]', 'Path to project to analyze', process.cwd())
    .option('-l, --left <score>', 'Left window .faf score (0-100)', '0')
    .option('-r, --right <score>', 'Right window .faf score (0-100)', '99')
    .option('-p, --prompt <text>', 'Instruction to give both AI instances', 'Build me a color picker component')
    .option('--no-visualize', 'Skip opening browser to view results')
    .action(async (projectPath, options) => {
    console.log('\n🍊 BIG ORANGE - Context Matters\n');
    console.log('═'.repeat(60));
    try {
        // Parse scores
        const leftScore = parseInt(options.left);
        const rightScore = parseInt(options.right);
        // Validate
        if (isNaN(leftScore) || leftScore < 0 || leftScore > 100) {
            throw new Error('Left score must be 0-100');
        }
        if (isNaN(rightScore) || rightScore < 0 || rightScore > 100) {
            throw new Error('Right score must be 0-100');
        }
        // Analyze project (if path provided)
        if (projectPath && projectPath !== process.cwd()) {
            console.log(`\nAnalyzing project: ${projectPath}`);
            const birthScore = await (0, faf_generator_1.calculateBirthScore)(projectPath);
            console.log(`Birth score: ${birthScore}%`);
        }
        console.log('\n');
        // Run comparison
        const results = await (0, compare_1.compareContexts)({
            projectPath,
            leftScore,
            rightScore,
            prompt: options.prompt
        });
        // Push to Big🍊
        console.log('Pushing to Big🍊...');
        const url = await (0, bigo_push_1.pushToBigO)(results);
        // Display results
        console.log('\n═'.repeat(60));
        console.log('\n✅ COMPARISON COMPLETE\n');
        console.log(`Session ID: ${results.sessionId}`);
        console.log(`\nResults:`);
        console.log(`  Left (${leftScore}%): ${results.leftWindow.emoji} ${results.leftWindow.timeToComplete.toFixed(1)}s`);
        console.log(`  Right (${rightScore}%): ${results.rightWindow.emoji} ${results.rightWindow.timeToComplete.toFixed(1)}s`);
        console.log(`\nDelta: ${results.delta.verdict}`);
        console.log(`\nView at: ${url}\n`);
        // Open browser
        if (options.visualize) {
            console.log('Opening Big🍊 in browser...\n');
            await (0, open_1.default)(url);
        }
    }
    catch (error) {
        console.error('\n❌ Error:', error instanceof Error ? error.message : error);
        process.exit(1);
    }
});
program
    .command('demo')
    .description('Run demo comparison with default settings')
    .action(async () => {
    console.log('\n🍊 Running Big Orange Demo\n');
    const results = await (0, compare_1.compareContexts)({
        leftScore: 0,
        rightScore: 99,
        prompt: 'Build me a color picker component'
    });
    const url = await (0, bigo_push_1.pushToBigO)(results);
    console.log(`\n✅ Demo complete!\n`);
    console.log(`View at: ${url}\n`);
    await (0, open_1.default)(url);
});
program.parse();
//# sourceMappingURL=index.js.map