/** Returns true if the topic has fewer than 3 words (extremely vague — meta-questions needed). */
export function isShortTopic(topic) {
    return topic.trim().split(/\s+/).length < 3;
}
/** Generate meta-questions to scope a vague topic. */
export function generateMetaQuestions() {
    return [
        {
            id: 'meta-1',
            question: 'Is this a brand new feature or an improvement to something that already exists?',
            category: 'scope',
            importance: 'critical',
            suggestedAnswers: ['New feature', 'Improvement to existing feature', 'Bug fix', 'Refactor'],
        },
        {
            id: 'meta-2',
            question: 'Who is the primary user that benefits from this? (e.g., end user, admin, developer)',
            category: 'scope',
            importance: 'critical',
            suggestedAnswers: ['End user', 'Admin', 'Developer/internal', 'All users'],
        },
        {
            id: 'meta-3',
            question: 'What is the minimum viable scope — what would make this "done" at a basic level?',
            category: 'scope',
            importance: 'critical',
            suggestedAnswers: [
                'Just the core happy path',
                'Happy path + error handling',
                'Full feature with edge cases',
            ],
        },
    ];
}
/**
 * Detect contradictions in a set of answers.
 * Returns an array of human-readable contradiction descriptions.
 */
export function detectContradictions(answers) {
    const contradictions = [];
    const values = Object.values(answers).map((v) => v.toLowerCase());
    const joined = values.join(' ');
    // Heuristic: "fast" / "no cache"
    if ((joined.includes('fast') || joined.includes('performant') || joined.includes('low latency')) &&
        (joined.includes('no cache') ||
            joined.includes('without cache') ||
            joined.includes('sin cache'))) {
        contradictions.push('Performance requirement ("fast") may conflict with "no cache" — caching is a primary tool for low-latency responses.');
    }
    // Heuristic: "simple" / many features
    const featureKeywords = [
        'real-time',
        'realtime',
        'offline',
        'multi-tenant',
        'i18n',
        'analytics',
        'notifications',
    ];
    const wantsSimple = joined.includes('simple') || joined.includes('minimal') || joined.includes('lightweight');
    const wantsComplex = featureKeywords.some((k) => joined.includes(k));
    if (wantsSimple && wantsComplex) {
        contradictions.push('Scope may be underestimated: "simple/minimal" combined with advanced features (real-time, offline, multi-tenant, etc.) typically results in a complex implementation.');
    }
    // Heuristic: deadline conflicts
    if ((joined.includes('urgent') || joined.includes('asap') || joined.includes('tomorrow')) &&
        (joined.includes('comprehensive') ||
            joined.includes('complete') ||
            joined.includes('all edge cases'))) {
        contradictions.push('Timeline conflict: "urgent/ASAP" deadline with "comprehensive/all edge cases" scope — consider scoping down to an MVP first.');
    }
    return contradictions;
}
/**
 * Build suggested answers for a question using project knowledge.
 */
export function buildSuggestedAnswers(question, knowledge) {
    const lower = question.question.toLowerCase();
    // Database-related: suggest the project's database
    if (lower.includes('database') || lower.includes('table') || lower.includes('schema')) {
        if (knowledge && knowledge.database !== 'unknown') {
            return [
                `Yes, using project's ${knowledge.database} database`,
                'No new tables needed',
                'Needs new tables',
                'Modifies existing tables',
            ];
        }
    }
    // Framework-related: suggest the project's framework
    if (lower.includes('framework') || lower.includes('pattern') || lower.includes('component')) {
        if (knowledge?.framework) {
            return [
                `Yes, reuse ${knowledge.framework} patterns`,
                'New pattern needed',
                'Mix of existing and new',
            ];
        }
    }
    // Performance questions
    if (lower.includes('performance') ||
        lower.includes('response time') ||
        lower.includes('throughput')) {
        return ['< 200ms response', '< 1s response', 'No strict requirement', 'Depends on load'];
    }
    // Auth questions
    if (lower.includes('authentication') || lower.includes('auth')) {
        return ['JWT tokens', 'Session-based', 'OAuth 2.0', 'No authentication needed', 'API key'];
    }
    // Timeline questions
    if (lower.includes('deadline') || lower.includes('timeline')) {
        return ['No strict deadline', 'Within 1 week', 'Within 1 sprint (2 weeks)', 'Specific date'];
    }
    return [];
}
//# sourceMappingURL=questions.js.map