"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.FeaturePlanCommand = void 0;
const commander_1 = require("commander");
const chalk_1 = __importDefault(require("chalk"));
const FeatureGraphCompiler_1 = require("../services/FeatureGraphCompiler");
exports.FeaturePlanCommand = new commander_1.Command("feature:plan")
    .description("Plan a specific feature and show its implementation tasks")
    .argument("<feature-id>", "feature ID to plan")
    .action(async (featureId) => {
    const compiler = new FeatureGraphCompiler_1.FeatureGraphCompiler();
    const graph = await compiler.compileFromContext();
    const feature = graph.getFeatureById(featureId);
    if (!feature) {
        console.error(chalk_1.default.red(`Feature "${featureId}" not found in the graph`));
        process.exit(1);
    }
    console.log(chalk_1.default.bold(`\n📐 Planning: ${feature.name} ${chalk_1.default.dim(`(${feature.id})`)}`));
    console.log(chalk_1.default.dim(`  ${feature.description}`));
    console.log();
    // Show completeness breakdown
    console.log(chalk_1.default.bold("Completeness Breakdown:"));
    console.log(chalk_1.default.dim("─".repeat(40)));
    const dims = [
        { key: "routes", label: "Routes" },
        { key: "components", label: "Components" },
        { key: "actions", label: "Actions" },
        { key: "models", label: "Models" },
        { key: "permissions", label: "Permissions" },
        { key: "i18n", label: "i18n" },
        { key: "tests", label: "Tests" },
    ];
    for (const dim of dims) {
        const done = feature.completeness[dim.key];
        const icon = done ? chalk_1.default.green("✓") : chalk_1.default.red("✗");
        const count = (feature.ownership[dim.key] || []).length;
        console.log(`  ${icon} ${dim.label}${chalk_1.default.dim(` (${count} items)`)}`);
    }
    console.log();
    // Show dependencies
    const deps = graph.edges
        .filter((e) => e.source === feature.id && e.type === "depends_on")
        .map((e) => {
        const dep = graph.nodes.get(e.target);
        return dep?.name || e.target;
    });
    if (deps.length > 0) {
        console.log(chalk_1.default.bold("Depends on:"));
        deps.forEach((d) => console.log(`  · ${d}`));
        console.log();
    }
    // Show gaps
    const gaps = await compiler.detectGaps(feature);
    if (gaps.length > 0) {
        console.log(chalk_1.default.bold(chalk_1.default.yellow("Gaps detected:")));
        for (const gap of gaps) {
            console.log(`  ${chalk_1.default.yellow("⚠")} ${gap.message}`);
        }
        console.log();
    }
    // Show suggested implementation batches
    console.log(chalk_1.default.bold("Suggested Implementation Order:"));
    console.log(chalk_1.default.dim("─".repeat(40)));
    const batches = [
        { name: "Batch 1 — Models & Data", items: feature.ownership.models },
        { name: "Batch 2 — Routes & Pages", items: feature.ownership.routes },
        { name: "Batch 3 — Components", items: feature.ownership.components },
        { name: "Batch 4 — Actions", items: feature.ownership.actions },
        { name: "Batch 5 — Permissions", items: feature.ownership.permissions },
        { name: "Batch 6 — i18n", items: feature.ownership.i18n },
        { name: "Batch 7 — Tests", items: feature.ownership.tests },
    ];
    for (const batch of batches) {
        const status = batch.items.length > 0 ? chalk_1.default.dim("(defined)") : chalk_1.default.dim(chalk_1.default.red("(not defined)"));
        console.log(`  ${chalk_1.default.cyan("▸")} ${batch.name} ${status}`);
        if (batch.items.length > 0) {
            batch.items.forEach((item) => {
                console.log(`    · ${item}`);
            });
        }
    }
    console.log();
});
//# sourceMappingURL=feature-plan.js.map