import { buildSuggestedAnswers } from './questions.js';
/**
 * Generate minimal clarification questions based on the topic.
 * Philosophy: Planu facilitates — only ask what's truly needed.
 * Technical details are inferred from project context, not asked.
 */
export function generateQuestions(topic, _context, knowledge, maxQuestions) {
    const questions = [];
    const lower = topic.toLowerCase();
    let idx = 0;
    const nextId = () => `q-${++idx}`;
    // === Core question: What do you want? (always relevant) ===
    questions.push({
        id: nextId(),
        question: `What is the main goal of "${topic}"? What should the user be able to do?`,
        category: 'scope',
        importance: 'critical',
    });
    // === Scope question: What's the MVP? ===
    questions.push({
        id: nextId(),
        question: `What are the must-have features for a first version?`,
        category: 'requirements',
        importance: 'critical',
    });
    // === Acceptance: What does done look like? ===
    questions.push({
        id: nextId(),
        question: `What does "done" look like? Describe the ideal user flow.`,
        category: 'acceptance',
        importance: 'critical',
    });
    // === Context-specific (only if topic mentions specific domains) ===
    // Auth related — only ask which method, nothing else
    if (lower.includes('auth') ||
        lower.includes('login') ||
        lower.includes('register') ||
        lower.includes('password')) {
        questions.push({
            id: nextId(),
            question: `What login methods? (email/password, Google, Apple, magic link, etc.)`,
            category: 'requirements',
            importance: 'helpful',
        });
    }
    // UI related — only ask if there are mockups
    if (lower.includes('ui') ||
        lower.includes('page') ||
        lower.includes('screen') ||
        lower.includes('dashboard')) {
        questions.push({
            id: nextId(),
            question: `Are there mockups or a reference design to follow?`,
            category: 'requirements',
            importance: 'helpful',
        });
    }
    // Trim to maxQuestions, prioritizing by importance
    const priorityOrder = [
        'critical',
        'helpful',
        'nice-to-have',
    ];
    const sorted = questions.sort((a, b) => {
        return priorityOrder.indexOf(a.importance) - priorityOrder.indexOf(b.importance);
    });
    const sliced = sorted.slice(0, maxQuestions);
    // Add context-aware suggestedAnswers to each question
    return sliced.map((q) => ({
        ...q,
        suggestedAnswers: buildSuggestedAnswers(q, knowledge),
    }));
}
//# sourceMappingURL=questions-context.js.map