import { planUpgrade } from '../engine/upgrade-planner/index.js';
// ---------------------------------------------------------------------------
// Formatters
// ---------------------------------------------------------------------------
function formatSummary(plan) {
    const lines = [
        `## Upgrade Plan: ${plan.packageName} ${plan.fromVersion} → ${plan.toVersion}`,
        '',
        `| Field | Value |`,
        `|-------|-------|`,
        `| Risk Level | ${plan.riskLevel} |`,
        `| Estimated Effort | ${plan.estimatedEffortHours}h |`,
        `| Auto-Safe | ${plan.isAutoSafe ? 'Yes' : 'No'} |`,
        '',
        '### Steps',
        ...plan.steps.map((s, i) => `${i + 1}. ${s}`),
    ];
    if (plan.breakingChanges.length > 0) {
        lines.push('', '### Breaking Changes');
        plan.breakingChanges.forEach((bc) => {
            lines.push(`- **${bc.description}**`);
            lines.push(`  - Impact: ${bc.impact}`);
            lines.push(`  - Action: ${bc.migrationAction}`);
        });
    }
    lines.push('', '### Testing Checklist', ...plan.testingChecklist.map((t) => `- [ ] ${t}`), '', '### Rollback', plan.rollbackProcedure);
    return lines.join('\n');
}
// ---------------------------------------------------------------------------
// Handler
// ---------------------------------------------------------------------------
export async function handlePlanUpgrade(args) {
    const plan = await planUpgrade(args.projectPath, args.packageName, args.fromVersion, args.targetVersion, args.changelogText);
    const format = args.format ?? 'summary';
    const text = format === 'json' ? JSON.stringify(plan, null, 2) : formatSummary(plan);
    return { content: [{ type: 'text', text }] };
}
//# sourceMappingURL=plan-upgrade.js.map