"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.QuestionsValidateCommand = void 0;
const commander_1 = require("commander");
const chalk_1 = __importDefault(require("chalk"));
const QuestionGraphEngine_1 = require("../services/QuestionGraphEngine");
exports.QuestionsValidateCommand = new commander_1.Command("questions:validate")
    .description("Check if compilation is blocked by unanswered questions")
    .option("--json", "output as JSON")
    .action(async (options) => {
    const engine = new QuestionGraphEngine_1.QuestionGraphEngine();
    await engine.load();
    const blocked = engine.isCompilationBlocked();
    const blockers = engine.getBlockers();
    const unanswered = engine.getUnanswered();
    const sevCounts = engine.countBySeverity();
    if (options.json) {
        console.log(JSON.stringify({
            blocked,
            blockerCount: blockers.length,
            unansweredCount: unanswered.length,
            bySeverity: sevCounts,
            blockers,
        }, null, 2));
        return;
    }
    console.log();
    if (blocked) {
        console.log(chalk_1.default.red.bold(`  ❌ COMPILATION BLOCKED`));
        console.log(chalk_1.default.yellow(`     ${blockers.length} blocking question(s) unresolved`));
        for (const q of blockers) {
            console.log(`     · ${chalk_1.default.bold(q.text)} ${chalk_1.default.cyan(`(${q.id})`)}`);
        }
        console.log();
        console.log(chalk_1.default.dim(`  Run ${chalk_1.default.cyan("mycontext questions:blockers")} for details`));
        console.log(chalk_1.default.dim(`  Run ${chalk_1.default.cyan("mycontext questions:answer <id> <value>")} to resolve`));
    }
    else {
        console.log(chalk_1.default.green.bold(`  ✓ COMPILATION CLEAR`));
        console.log(chalk_1.default.dim(`     ${sevCounts.blocking} blocking, ${sevCounts.important} important, ${sevCounts.optional} optional`));
        if (unanswered.length > 0) {
            console.log(chalk_1.default.dim(`     ${unanswered.length} unanswered (non-blocking) questions remain`));
        }
    }
    console.log();
});
//# sourceMappingURL=questions-validate.js.map