// tools/generate-tests/plan-mode-handler.ts — SPEC-058a Plan mode handler
// Extracted from generate-tests.ts to stay under 400-line limit
import { generateTestPlan } from '../../engine/test-plan-generator.js';
function formatLayerSection(layer) {
    const statusIcon = layer.needed ? '✓' : '–';
    const lines = [
        `### ${statusIcon} ${layer.type.toUpperCase()} tests (${layer.priority})`,
        '',
        `**Needed:** ${layer.needed ? 'Yes' : 'No'}`,
        `**Reason:** ${layer.reason}`,
    ];
    if (layer.needed) {
        lines.push(`**Estimated hours:** ${layer.estimatedHours}h`);
        if (layer.frameworks.length > 0) {
            lines.push(`**Frameworks:** ${layer.frameworks.join(', ')}`);
        }
        if (layer.tools.length > 0) {
            lines.push(`**Tools:** ${layer.tools.join(', ')}`);
        }
    }
    lines.push('');
    return lines;
}
export function handlePlanMode(projectId, knowledge) {
    const plan = generateTestPlan(knowledge);
    const lines = [
        '## Test Plan',
        '',
        `**Project:** \`${projectId}\``,
        `**Generated at:** ${plan.generatedAt}`,
        `**Total estimated hours:** ${plan.totalEstimatedHours}h`,
        `**Starter kit mode:** ${plan.starterKit ? 'Yes (no apps detected)' : 'No'}`,
        '',
        '## Layers',
        '',
    ];
    for (const layer of plan.layers) {
        lines.push(...formatLayerSection(layer));
    }
    if (plan.mcpRecommendations.length > 0) {
        lines.push('## MCP Recommendations', '');
        for (const rec of plan.mcpRecommendations) {
            lines.push(`- ${rec}`);
        }
        lines.push('');
    }
    if (plan.starterKit) {
        lines.push('## Starter Kit', '', 'No apps were detected. Use the starter kit templates to bootstrap your test setup:', '- Add a test runner to your project (vitest, pytest, go test, etc.)', '- Configure coverage thresholds (aim for 80%+ lines, 70%+ branches)', '- Set up CI/CD to run tests on every push', '');
    }
    return {
        content: [{ type: 'text', text: lines.join('\n') }],
    };
}
//# sourceMappingURL=plan-mode-handler.js.map