smart-routing
Intelligent request routing for /toh command. Analyzes user intent, assesses confidence, surveys the runtime (2-step, per orchestration-protocol), and routes to the appropriate agent(s). Memory-first approach ensures context awareness. Triggers: /toh command, natural language requests, ambiguous inputs.
wasintoh · 已有 AI 审核记录
安装与使用
运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。
npx skills add wasintoh/toh-framework --skill smart-routing技能说明
name: smart-routing description: > Intelligent request routing for /toh command. Analyzes user intent, assesses confidence, surveys the runtime (2-step, per orchestration-protocol), and routes to the appropriate agent(s). Memory-first approach ensures context awareness. Triggers: /toh command, natural language requests, ambiguous inputs.
Smart Routing Skill
Intelligent routing engine for the /toh smart command. Routes any natural language request to the right agent(s).
🧠 Routing Pipeline
┌─────────────────────────────────────────────────────────────────┐
│ USER REQUEST │
├─────────────────────────────────────────────────────────────────┤
│ │
│ STEP 0: MEMORY CHECK (ALWAYS FIRST!) │
│ ├── Read .toh/memory/active.md │
│ ├── Read .toh/memory/summary.md │
│ ├── Read .toh/memory/decisions.md │
│ └── Build context understanding │
│ │
│ STEP 1: INTENT CLASSIFICATION │
│ ├── Pattern matching (keywords, phrases) │
│ ├── Context inference (from memory) │
│ └── Scope detection (simple/complex) │
│ │
│ STEP 2: CONFIDENCE SCORING │
│ ├── HIGH (80%+) → Direct execution │
│ ├── MEDIUM (50-80%) → Plan Agent first │
│ └── LOW (<50%) → Ask for clarification │
│ │
│ STEP 3: RUNTIME SURVEY (2-step — orchestration-protocol A) │
│ ├── Identity: declared by loaded context file + │
│ │ .toh/capabilities.json │
│ └── Probe: teams env flag + version gates only │
│ │
│ STEP 4: AGENT SELECTION & EXECUTION │
│ └── Route to appropriate agent(s) │
│ │
└─────────────────────────────────────────────────────────────────┘
📊 Intent Classification Matrix
Illustrative heuristics only — native agent-description matching makes the actual call (see /toh); do not compute or display confidence scores.
Primary Patterns → Agent Mapping
| Pattern Category | Keywords (EN) | Keywords (TH) | Primary Agent | Confidence |
|---|---|---|---|---|
| Create UI | create, add, make, build + page/component/UI | สร้าง, เพิ่ม, ทำ + หน้า/component | UI Agent | HIGH |
| Add Logic | logic, state, function, hook, validation | logic, state, function, เพิ่ม logic | Dev Agent | HIGH |
| Fix Bug | bug, error, broken, fix, not working | bug, error, พัง, ไม่ทำงาน, แก้ | Fix Agent | HIGH |
| Improve Design | prettier, beautiful, design, polish, style | สวย, design, ปรับ design | Design Agent | HIGH |
| Testing | test, check, verify | test, ทดสอบ, เช็ค | Test Agent | HIGH |
| Connect Backend | connect, database, Supabase, API, backend | เชื่อม, database, Supabase | Connect Agent | HIGH |
| Deploy | deploy, ship, production, publish | deploy, ship, ขึ้น production | Ship Agent | HIGH |
| LINE Platform | LINE, LIFF, LINE MINI App | LINE, LIFF | LINE Agent | HIGH |
| Mobile Platform | mobile, iOS, Android, PWA, Capacitor | mobile, มือถือ | Mobile Agent | HIGH |
| New Project | new project, start, build app, create system | project ใหม่, สร้าง app | Vibe Agent | HIGH |
| Planning | plan, analyze, PRD, architecture | วางแผน, วิเคราะห์ | Plan Agent | HIGH |
| AI/Prompt | prompt, AI, chatbot, system prompt | prompt, AI, chatbot | Dev Agent + prompt-optimizer | HIGH |
| Continue | continue, resume, go on | ทำต่อ, ต่อ | Memory → Last Agent | MEDIUM |
| Complex Request | Multiple features, system, e-commerce, etc. | ระบบ + หลาย features | Plan Agent | MEDIUM |
| Vague Request | help, fix it, make better (without context) | ช่วยด้วย, แก้ที | Ask Clarification | LOW |
🎯 Confidence Scoring Algorithm
Illustrative heuristics only — native agent-description matching makes the actual call (see /toh); do not compute or display confidence scores.
interface ConfidenceFactors {
keywordMatch: number; // 0-40 points
contextClarity: number; // 0-30 points
memorySupport: number; // 0-20 points
scopeDefinition: number; // 0-10 points
}
function calculateConfidence(request: string, memory: Memory): number {
let score = 0;
// Keyword matching (0-40 points)
// Strong match with primary patterns = 40
// Partial match = 20
// No match = 0
score += keywordMatchScore(request);
// Context clarity (0-30 points)
// Specific page/component mentioned = 30
// General area mentioned = 15
// No specifics = 0
score += contextClarityScore(request);
// Memory support (0-20 points)
// Request relates to active task = 20
// Request relates to project = 10
// No memory context = 0
score += memorySupportScore(request, memory);
// Scope definition (0-10 points)
// Single clear task = 10
// Multiple related tasks = 5
// Unclear scope = 0
score += scopeDefinitionScore(request);
return score; // 0-100
}
// Thresholds
const HIGH_CONFIDENCE = 80; // Execute directly
const MEDIUM_CONFIDENCE = 50; // Route to Plan Agent
// Below 50 = Ask for clarification
🖥️ Runtime Survey (2-step — never guess the IDE)
Step 1 — Identity (declared)
Your runtime identity is **declared by the platform conte
阅读完整来源 ↗