diff --git a/src/bot/intent-detector.js b/src/bot/intent-detector.js index 07a985ac..90e6b5a5 100644 --- a/src/bot/intent-detector.js +++ b/src/bot/intent-detector.js @@ -20,7 +20,7 @@ import { logger } from '../utils/logger.js'; // These are UNAMBIGUOUS greetings — any other message goes to AI const GREETINGS = [ // Single word - /^(hi|hey|hello|howdy|greetings|sup|yo)$/, + /^(hi|hey|hello|howdy|greetings|sup|yo)$/i, // Short greetings (1-2 words, no punctuation) /^(good morning|good afternoon|good evening|good night)/i, @@ -30,10 +30,10 @@ const GREETINGS = [ /^(yes|yeah|yep|nope|no|ok|okay|alright|sure|yup|sure thing|absolutely|definitely)$/, // Continuations - /^(continue|go ahead|proceed|do it|carry on|keep going|onwards)$/, + /^(thanks|thank you|thx|ty|appreciate it|continue|go ahead|proceed|do it|carry on|keep going|onwards)$/i, // Completions - /^(done|finished|completed|all good|looks good|looks fine|good to go)$/, + /^(done|finished|completed|all good|looks good|looks fine|good to go)$/i, // Farewells /^(bye|goodbye|see you|later|take care|cya|goodbye then)$/, @@ -241,6 +241,19 @@ export function detectIntent(message) { } // ── SHORT ANSWERS (handled inline, no AI needed) ── + // Check if short message is actually a greeting first + for (const pattern of GREETINGS) { + if (pattern.test(trimmed)) { + return { + type: 'greeting', + response: '⚡ Ready! What do you need?', + bypassAI: true, + confidence: 1.0, + reasoning: 'Short greeting detected', + }; + } + } + // Not a greeting, check length if (length < 5) { return { type: 'too_short', @@ -262,6 +275,38 @@ export function detectIntent(message) { }; } + // ── REPOSTED QUESTION DETECTION (Ruflo + Clawd hybrid) ── + // Detect when user reposts a question by referencing previous context + // This prevents AI from "forgetting" and re-reading files + const repostKeywords = [ + 'ignore me', 'you ignore', 'you ignored', + "didn't answer", "didn't respond", + "didn't answer my question", "didn't respond to my", + 'you are ignoring', 'you ignored me', + 'earlier', 'before', 'previous', 'last time', + 'my question', 'your answer', "didn't", + ]; + + // Case 1: Question with context reference (highest confidence) + if (lower.includes('?') && repostKeywords.some(kw => lower.includes(kw))) { + return { + type: 'question', + bypassAI: false, + confidence: 0.85, + reasoning: 'Reposted question with context reference (Ruflo + Clawd)', + }; + } + + // Case 2: Context reference without question marker (lower confidence) + if (!lower.includes('?') && repostKeywords.some(kw => lower.includes(kw))) { + return { + type: 'question', + bypassAI: false, + confidence: 0.75, + reasoning: 'Reposted question implied by context reference', + }; + } + // ── ALL OTHER MESSAGES → Go through AI ── return { type: 'normal',