// Planu — Estimator Helper Functions
// Internal helpers extracted from estimator.ts to keep file under 400 lines.
/**
 * Round a number to a given number of decimal places.
 */
export function roundTo(value, decimals) {
    const factor = Math.pow(10, decimals);
    return Math.round(value * factor) / factor;
}
/**
 * Determine confidence level based on difficulty, scope, and historical data.
 */
export function determineConfidence(difficulty, scope, historyCount) {
    let score = 0;
    // History helps confidence
    if (historyCount >= 5) {
        score += 2;
    }
    else if (historyCount >= 2) {
        score += 1;
    }
    // Lower difficulty = higher confidence in estimates
    if (difficulty <= 2) {
        score += 2;
    }
    else if (difficulty <= 3) {
        score += 1;
    }
    // Smaller scope = more predictable
    if (scope === 'trivial' || scope === 'feature') {
        score += 1;
    }
    if (score >= 4) {
        return 'high';
    }
    if (score >= 2) {
        return 'medium';
    }
    return 'low';
}
/**
 * Build human-readable reasoning text for an estimation result.
 */
export function buildReasoning(spec, estimation, confidence, historyCount) {
    const parts = [];
    parts.push(`${spec.type} spec with ${spec.scope} scope at difficulty ${spec.difficulty}/5.`);
    parts.push(`Estimated ${estimation.devHours}h dev + ${estimation.reviewHours}h review = ${roundTo(estimation.devHours + estimation.reviewHours, 1)}h total.`);
    parts.push(`Recommended model: ${estimation.recommendedModel} (${estimation.tokenOptimization.mode} mode).`);
    if (historyCount > 0) {
        parts.push(`Based on ${historyCount} similar spec(s) from project history.`);
    }
    parts.push(`Confidence: ${confidence}.`);
    if (confidence === 'low') {
        parts.push('Consider breaking this into smaller specs for more accurate estimation.');
    }
    return parts.join(' ');
}
//# sourceMappingURL=estimator-helpers.js.map