"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.PlanFeatureCommand = void 0;
const commander_1 = require("commander");
const inquirer_1 = __importDefault(require("inquirer"));
const llmClarifier_1 = require("../services/llmClarifier");
const FeaturePlannerAgent_1 = require("../agents/implementations/FeaturePlannerAgent");
const contextManager_1 = require("../utils/contextManager");
exports.PlanFeatureCommand = new commander_1.Command("plan-feature")
    .description("Describe a new feature/enhancement, clarify with LLM, and let the planner agent review, plan, and update the brain/todos.")
    .action(async () => {
    // 1. Prompt user for feature/enhancement description
    const { featureDescription } = await inquirer_1.default.prompt([
        {
            type: "input",
            name: "featureDescription",
            message: "Describe the new feature or enhancement:",
        },
    ]);
    // 2. Load current context
    const contextManager = new contextManager_1.ContextManager();
    const context = await contextManager.loadContext();
    // 3. Clarify/clean request with LLM
    const clarifiedRequest = await (0, llmClarifier_1.clarifyFeatureRequestWithLLM)(featureDescription, context);
    // 4. Planner agent reviews and proposes plan/todos
    const planner = new FeaturePlannerAgent_1.FeaturePlannerAgent();
    const plan = await planner.planFeature(clarifiedRequest, context);
    // 5. Present plan/todos for approval
    console.log("\nProposed Plan:");
    console.log(plan.summary);
    if (plan.todos && plan.todos.length > 0) {
        console.log("\nTodos:");
        plan.todos.forEach((todo, idx) => {
            console.log(`  [ ] ${todo}`);
        });
    }
    const { approve } = await inquirer_1.default.prompt([
        {
            type: "confirm",
            name: "approve",
            message: "Approve and update context.json/roadmap?",
            default: true,
        },
    ]);
    if (approve) {
        const updatedContext = await contextManager.mergeContext(context, plan.contextUpdates);
        await contextManager.saveContext(updatedContext);
        console.log("\n✅ Feature/plan added to context.json and roadmap.");
    }
    else {
        console.log("\n❌ Plan not applied.");
    }
});
//# sourceMappingURL=plan-feature.js.map