Files
SuperCharged-Claude-Code-Up…/hooks/intelligent-router.sh
uroma 2925224a9a Remove Clawdbot integration
- Deleted clawd command file (commands/clawd.md)
- Deleted clawd hook files (hooks/clawd-*.sh)
- Removed clawd references from supercharge.sh
- Removed clawd checks from health-check.sh
- Removed clawd aliases from aliases.sh
- Removed clawd patterns from intelligent-router.sh
- Updated enhanced-ralph.md to remove clawd agent reference

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-29 12:25:25 +00:00

164 lines
5.0 KiB
Bash
Executable File

#!/bin/bash
# Intelligent Agent Router - Auto-triggers appropriate agents based on task analysis
# This hook analyzes user input and suggests/routes to the best agent for the task
set -euo pipefail
# Read the user's prompt
PROMPT=$(cat)
# Agent detection patterns with confidence scores
detect_agent() {
local prompt="$1"
local best_agent=""
local best_score=0
local confidence=""
# Ralph patterns - architecture/design
if echo "$prompt" | grep -qiE "(architecture|design system|microservices|system design|plan.*implementation|from scratch|build.*complete|end to end|autonomous|automatically)"; then
if [ $best_score -lt 85 ]; then
best_agent="ralph"
best_score=85
confidence="high"
fi
fi
# Prometheus patterns - code analysis/bugs
if echo "$prompt" | grep -qiE "(bug|fix.*issue|reproduce|analyze.*code|code context|implementation plan|patch|regression)"; then
if [ $best_score -lt 80 ]; then
best_agent="prometheus"
best_score=80
confidence="high"
fi
fi
# Dexto patterns - specific tasks
# GitHub
if echo "$prompt" | grep -qiE "(github|pull request|pr|issue|repo|commit|branch)"; then
if [ $best_score -lt 75 ]; then
best_agent="dexto-github"
best_score=75
confidence="medium"
fi
fi
# PDF/Documents
if echo "$prompt" | grep -qiE "(pdf|document|analyze.*file|read.*doc|summarize.*paper)"; then
if [ $best_score -lt 75 ]; then
best_agent="dexto-pdf"
best_score=75
confidence="medium"
fi
fi
# Image generation/editing
if echo "$prompt" | grep -qiE "(generate.*image|create.*picture|ai.*art|nano.*banana|gemini.*image|sora.*video)"; then
if [ $best_score -lt 75 ]; then
best_agent="dexto-nano-banana"
best_score=75
confidence="medium"
fi
fi
# Video generation
if echo "$prompt" | grep -qiE "(video|sora|generate.*clip|create.*video)"; then
if [ $best_score -lt 75 ]; then
best_agent="dexto-sora"
best_score=75
confidence="medium"
fi
fi
# Music/Audio
if echo "$prompt" | grep -qiE "(music|audio|sound|podcast|beat|melody|song)"; then
if [ $best_score -lt 75 ]; then
best_agent="dexto-music"
best_score=75
confidence="medium"
fi
fi
# Database
if echo "$prompt" | grep -qiE "(database|sql|query|optimize.*db|schema)"; then
if [ $best_score -lt 75 ]; then
best_agent="dexto-database"
best_score=75
confidence="medium"
fi
fi
# Coding/Development
if echo "$prompt" | grep -qiE "(code|develop|implement.*feature|write.*function|refactor|review.*code)"; then
if [ $best_score -lt 70 ]; then
best_agent="dexto-code"
best_score=70
confidence="medium"
fi
fi
# Product research
if echo "$prompt" | grep -qiE "(product.*name|branding|research.*name|naming.*idea)"; then
if [ $best_score -lt 70 ]; then
best_agent="dexto-research"
best_score=70
confidence="medium"
fi
fi
# Codebase exploration
if echo "$prompt" | grep -qiE "(explore.*code|analyze.*codebase|understand.*structure|how.*work)"; then
if [ $best_score -lt 70 ]; then
best_agent="dexto-explore"
best_score=70
confidence="medium"
fi
fi
# Support triage
if echo "$prompt" | grep -qiE "(support.*ticket|triage|customer.*issue|route.*request|categorize.*issue)"; then
if [ $best_score -lt 70 ]; then
best_agent="dexto-triage"
best_score=70
confidence="medium"
fi
fi
# Output result
if [ -n "$best_agent" ]; then
echo "AGENT:$best_agent"
echo "SCORE:$best_score"
echo "CONFIDENCE:$confidence"
return 0
else
echo "AGENT:none"
echo "SCORE:0"
echo "CONFIDENCE:none"
return 1
fi
}
# Main routing logic
RESULT=$(detect_agent "$PROMPT")
AGENT=$(echo "$RESULT" | grep "^AGENT:" | cut -d: -f2)
SCORE=$(echo "$RESULT" | grep "^SCORE:" | cut -d: -f2)
CONFIDENCE=$(echo "$RESULT" | grep "^CONFIDENCE:" | cut -d: -f2)
# Only suggest if confidence is high enough
if [ "$AGENT" != "none" ] && [ "$SCORE" -ge 70 ]; then
case "$AGENT" in
ralph)
echo "💡 **Tip:** This is a complex architecture task. Ralph can help: \`/ralph \"$PROMPT\"\`"
;;
prometheus)
echo "💡 **Tip:** This is a code analysis task. Use Prometheus: \`/prometheus \"$PROMPT\"\`"
;;
dexto-*)
# Extract the specific agent name
SPECIFIC=${AGENT#dexto-}
echo "💡 **Tip:** Use Dexto ${SPECIFIC} agent: \`/${AGENT} \"$PROMPT\"\`"
;;
esac
fi
exit 0