"use strict";
/**
 * 📝 faf edit - Quick edit helper
 * Opens .faf file in default editor or shows edit instructions
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.editFafFile = editFafFile;
const colors_1 = require("../fix-once/colors");
const child_process_1 = require("child_process");
const file_utils_1 = require("../utils/file-utils");
async function editFafFile(file, options = {}) {
    try {
        const fafPath = file || await (0, file_utils_1.findFafFile)();
        if (!fafPath) {
            console.error(colors_1.chalk.red('❌ No .faf file found'));
            console.log(colors_1.chalk.yellow('💡 Run "faf init" to create one'));
            process.exit(1);
        }
        console.log(colors_1.chalk.blue(`\n📝 Edit your .faf file to improve your score:\n`));
        console.log(colors_1.chalk.white(`   File: ${fafPath}\n`));
        console.log(colors_1.chalk.cyan('   Key fields to fill for higher score:'));
        console.log(colors_1.chalk.gray('   HUMAN Context (most important):'));
        console.log(colors_1.chalk.gray('     • human_context.who - Who is this for?'));
        console.log(colors_1.chalk.gray('     • human_context.what - What problem does it solve?'));
        console.log(colors_1.chalk.gray('     • human_context.why - Why does it matter?'));
        console.log(colors_1.chalk.gray('     • human_context.where - Where will it be used?'));
        console.log(colors_1.chalk.gray('     • human_context.when - When is it needed?'));
        console.log(colors_1.chalk.gray('     • human_context.how - How will it work?'));
        console.log();
        console.log(colors_1.chalk.gray('   Technical Context:'));
        console.log(colors_1.chalk.gray('     • stack.frontend - Frontend framework'));
        console.log(colors_1.chalk.gray('     • stack.backend - Backend technology'));
        console.log(colors_1.chalk.gray('     • stack.database - Database system'));
        console.log(colors_1.chalk.gray('     • project.goal - Project objective'));
        console.log(colors_1.chalk.green('\n   After editing, run: ') + colors_1.chalk.white.bold('faf score') + colors_1.chalk.green(' to see improvements'));
        // Try to open in default editor if requested
        if (options.open) {
            const editor = process.env.EDITOR || 'vi';
            console.log(colors_1.chalk.gray(`\n   Opening in ${editor}...`));
            (0, child_process_1.spawn)(editor, [fafPath], { stdio: 'inherit' });
        }
        else {
            console.log(colors_1.chalk.gray('\n   💡 Tip: Use "faf edit --open" to open in your default editor'));
        }
    }
    catch (error) {
        console.error(colors_1.chalk.red('💥 Edit guidance failed:'));
        console.error(colors_1.chalk.red(error instanceof Error ? error.message : String(error)));
        process.exit(1);
    }
}
//# sourceMappingURL=edit-helper.js.map