"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ImplPlanCommand = void 0;
const commander_1 = require("commander");
const chalk_1 = __importDefault(require("chalk"));
const FeatureGraphCompiler_1 = require("../services/FeatureGraphCompiler");
const ImplGraphCompiler_1 = require("../services/ImplGraphCompiler");
exports.ImplPlanCommand = new commander_1.Command("implementation:plan")
    .description("Generate an implementation plan for a feature")
    .argument("<feature-id>", "feature ID to plan")
    .action(async (featureId) => {
    const featureCompiler = new FeatureGraphCompiler_1.FeatureGraphCompiler();
    const graph = await featureCompiler.compileFromContext();
    const feature = graph.getFeatureById(featureId);
    if (!feature) {
        console.error(chalk_1.default.red(`Feature "${featureId}" not found`));
        process.exit(1);
    }
    const implCompiler = new ImplGraphCompiler_1.ImplGraphCompiler();
    const implGraph = await implCompiler.compileFromFeature(feature);
    console.log(chalk_1.default.bold(`\n📐 Implementation Plan: ${feature.name}`));
    console.log(chalk_1.default.dim("─".repeat(60)));
    for (const batch of implGraph.batches) {
        const statusIcon = batch.status === "completed"
            ? chalk_1.default.green("✓")
            : batch.status === "failed"
                ? chalk_1.default.red("✗")
                : chalk_1.default.cyan("▸");
        console.log(`\n  ${statusIcon} ${chalk_1.default.bold(batch.label)} ${chalk_1.default.dim(`(${batch.type})`)}`);
        for (const task of batch.tasks) {
            const taskIcon = task.status === "completed"
                ? chalk_1.default.green("✓")
                : task.status === "failed"
                    ? chalk_1.default.red("✗")
                    : task.status === "in-progress"
                        ? chalk_1.default.yellow("●")
                        : chalk_1.default.dim("·");
            const effortIcon = task.estimatedEffort === "small"
                ? chalk_1.default.dim("S")
                : task.estimatedEffort === "medium"
                    ? chalk_1.default.yellow("M")
                    : chalk_1.default.red("L");
            console.log(`    ${taskIcon} ${task.name} ${chalk_1.default.dim(`[${effortIcon}]`)}`);
            if (task.outputPaths.length > 0) {
                console.log(`       ${chalk_1.default.dim("→")} ${task.outputPaths.join(", ")}`);
            }
        }
    }
    const total = implGraph.nodes.size;
    const pending = implGraph.getTasksByStatus("pending").length;
    console.log(chalk_1.default.dim("\n─".repeat(60)));
    console.log(`  ${total} tasks · ${pending} pending · ${implGraph.batches.length} batches`);
    console.log();
});
//# sourceMappingURL=impl-plan.js.map