/**
 * Technical terms denylist.
 * Descriptions containing any of these words are NOT considered trivial,
 * regardless of word count.
 */
const TECH_TERMS_DENYLIST = [
    'api',
    'database',
    'cache',
    'auth',
    'migration',
    'oauth',
    'graphql',
    'websocket',
    'stream',
    'queue',
];
/**
 * Tokenizes a description string into lowercase words, removing punctuation.
 */
function tokenize(description) {
    return description
        .toLowerCase()
        .replace(/[^a-z0-9\s]/g, '')
        .split(/\s+/)
        .filter((w) => w.length > 0);
}
/**
 * Detects whether a task description is trivial (≤5 words, no tech terms).
 * Trivial tasks should be captured as backlog ideas rather than full specs.
 */
export function detectTrivial(description) {
    const trimmed = description.trim();
    if (trimmed.length === 0) {
        return {
            isTrivial: true,
            reason: 'Empty description — capture as backlog idea.',
            wordCount: 0,
            foundTechTerms: [],
        };
    }
    const words = tokenize(trimmed);
    const wordCount = words.length;
    const foundTechTerms = TECH_TERMS_DENYLIST.filter((term) => words.includes(term));
    if (wordCount > 5) {
        return {
            isTrivial: false,
            reason: `Description has ${wordCount} words (threshold: 5).`,
            wordCount,
            foundTechTerms,
        };
    }
    if (foundTechTerms.length > 0) {
        return {
            isTrivial: false,
            reason: `Description contains technical terms: ${foundTechTerms.join(', ')}.`,
            wordCount,
            foundTechTerms,
        };
    }
    return {
        isTrivial: true,
        reason: `Description is ${wordCount} word${wordCount === 1 ? '' : 's'} with no technical terms — suggest capturing as backlog idea.`,
        wordCount,
        foundTechTerms: [],
    };
}
//# sourceMappingURL=trivial-detector.js.map