/**
 * Generate a PLAN.md markdown string from an ExecutionPlan.
 * Includes RED/GREEN/VERIFY cycles, [P] markers for parallelizable steps,
 * and checkboxes for tracking progress.
 */
export function generatePlanMarkdown(plan, spec) {
    const totalMinutes = plan.phases.reduce((sum, ph) => sum + ph.steps.reduce((s, st) => s + st.estimatedMinutes, 0), 0);
    const estimatedHours = Math.round((totalMinutes / 60) * 10) / 10;
    const lines = [
        `# PLAN.md — ${spec.title}`,
        '',
        `> **Spec**: ${spec.id} | **Status**: ${spec.status} | **Generated**: ${new Date().toISOString()}`,
        '',
        '## Summary',
        '',
        `| Field | Value |`,
        `|-------|-------|`,
        `| Phases | ${plan.phases.length} |`,
        `| Total steps | ${plan.totalSteps} |`,
        `| Estimated time | ${estimatedHours}h (${totalMinutes} min) |`,
        `| Critical path | ${plan.criticalPath.join(' → ') || 'N/A'} |`,
        `| Parallelizable groups | ${plan.parallelizable.length} |`,
        '',
        '> **Legend**: `[P]` = parallelizable with other steps | RED = failing test | GREEN = implementation | VERIFY = check',
        '',
    ];
    for (const phase of plan.phases) {
        lines.push(`## ${phase.name}`, '');
        for (const step of phase.steps) {
            const pTag = step.parallelizable ? ' `[P]`' : '';
            lines.push(`### Step ${step.order}: ${step.title}${pTag}`, '');
            if (step.files.length > 0) {
                lines.push(`**Files**: \`${step.files.join('`, `')}\``, '');
            }
            if (step.dependsOn.length > 0) {
                lines.push(`**Depends on**: Steps ${step.dependsOn.join(', ')}`, '');
            }
            lines.push(`**Estimate**: ${step.estimatedMinutes} min`, '');
            lines.push('**Cycle**:', '');
            lines.push(`- [ ] 🔴 **RED** — ${step.description} (write failing test first)`);
            lines.push(`- [ ] 🟢 **GREEN** — Implement: ${step.description}`);
            lines.push(`- [ ] ✅ **VERIFY** — ${step.verification}`);
            lines.push('');
        }
    }
    return lines.join('\n');
}
//# sourceMappingURL=plan.js.map