#!/usr/bin/env node
"use strict";
/**
 * FAF UPDATE - Save your current version
 *
 * Simple command: "faf update"
 * Just saves your current version as a checkpoint
 */
Object.defineProperty(exports, "__esModule", { value: true });
const commander_1 = require("../fix-once/commander");
const faf_dna_1 = require("../engines/faf-dna");
const colors_1 = require("../fix-once/colors");
const program = new commander_1.Command();
program
    .name('faf update')
    .description('Save your current FAF version (checkpoint your progress)')
    .action(async () => {
    try {
        const projectPath = process.cwd();
        const dnaManager = new faf_dna_1.FafDNAManager(projectPath);
        // Load DNA
        const dna = await dnaManager.load();
        if (!dna) {
            console.log(colors_1.colors.error('❌ No FAF DNA found'));
            console.log(colors_1.colors.secondary('Run "faf init" to create your project DNA'));
            process.exit(1);
        }
        // Approve current version
        await dnaManager.approve();
        console.log();
        console.log(colors_1.colors.success('✅ VERSION SAVED'));
        console.log();
        // Show update details
        console.log(colors_1.colors.info(`Version: ${dna.current.version}`));
        console.log(colors_1.colors.info(`Score: ${dna.current.score}%`));
        console.log(colors_1.colors.info(`Growth from birth: +${dna.current.score - dna.birthCertificate.birthDNA}%`));
        console.log();
        // Show journey
        const journey = dnaManager.getJourney('compact');
        console.log(colors_1.colors.highlight(`Journey: ${journey}`));
        console.log();
        // Check for milestones
        const milestones = dna.growth.milestones;
        const firstSave = milestones.find(m => m.type === 'first_save');
        if (firstSave && firstSave.version === dna.current.version) {
            console.log(colors_1.colors.success(`🎆 MILESTONE: First Save achieved!`));
            console.log();
        }
        if (dna.current.score >= 85 && !milestones.find(m => m.type === 'elite')) {
            console.log(colors_1.colors.success(`⭐ ACHIEVEMENT: Elite status unlocked!`));
            console.log();
        }
        console.log(colors_1.colors.info('Your progress has been saved! 💾'));
        console.log(colors_1.colors.secondary('You can always return to this version if needed'));
        console.log();
        console.log(colors_1.colors.info('Keep improving:'));
        console.log(colors_1.colors.secondary('  • faf auto - Continue growing your context'));
        console.log(colors_1.colors.secondary('  • faf log  - See your complete journey'));
        console.log(colors_1.colors.secondary('  • faf score - Check current status'));
        console.log();
    }
    catch (error) {
        console.error(colors_1.colors.error(`❌ Error: ${error.message}`));
        process.exit(1);
    }
});
program.parse(process.argv);
//# sourceMappingURL=faf-update.js.map