"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SemanticsValidateCommand = void 0;
const commander_1 = require("commander");
const chalk_1 = __importDefault(require("chalk"));
const LivingDictionary_1 = require("../services/LivingDictionary");
exports.SemanticsValidateCommand = new commander_1.Command("semantics:validate")
    .description("Validate the dictionary: find undefined terms and conflicts")
    .option("--json", "output as JSON")
    .action(async (options) => {
    const dict = new LivingDictionary_1.LivingDictionary();
    await dict.load();
    const allTerms = dict.getAllTerms();
    const conflicts = dict.getConflicts();
    const needsReview = Array.from(dict.getEntries().values()).filter(e => e.status === "needs-review");
    if (options.json) {
        console.log(JSON.stringify({
            totalTerms: allTerms.length,
            conflicts,
            needsReview: needsReview.length,
            healthy: conflicts.length === 0 && needsReview.length === 0,
        }, null, 2));
        return;
    }
    console.log(chalk_1.default.bold("\n🔍 Semantic Dictionary Validation"));
    console.log(chalk_1.default.dim("─".repeat(50)));
    console.log(`  ${chalk_1.default.cyan("Total terms:")} ${allTerms.length}`);
    const healthy = conflicts.length === 0 && needsReview.length === 0;
    if (healthy) {
        console.log(chalk_1.default.green("\n  ✓ Dictionary is healthy — no conflicts or undefined terms\n"));
        return;
    }
    if (conflicts.length > 0) {
        console.log(chalk_1.default.yellow(`\n  ⚠ ${conflicts.length} semantic conflict(s):`));
        for (const conflict of conflicts) {
            console.log(`     · ${chalk_1.default.bold(conflict.term)}`);
            for (const def of conflict.definitions) {
                console.log(`       ${chalk_1.default.dim(`"${def.definition}" (${def.source})`)}`);
            }
        }
    }
    if (needsReview.length > 0) {
        console.log(chalk_1.default.yellow(`\n  ⚠ ${needsReview.length} term(s) need review:`));
        for (const entry of needsReview) {
            console.log(`     · ${chalk_1.default.cyan(entry.term)} — auto-discovered, needs definition`);
        }
    }
    console.log();
});
//# sourceMappingURL=semantics-validate.js.map