| 1 | import type { ServerProviderSkill } from "@t3tools/contracts"; |
| 2 | |
| 3 | export function matchesSlashSkillQuery(skill: ServerProviderSkill, query: string): boolean { |
| 4 | if (!skill.enabled) return false; |
| 5 | const normalizedQuery = query.toLowerCase(); |
| 6 | const skillQuery = |
| 7 | normalizedQuery === "skill" |
| 8 | ? "" |
| 9 | : normalizedQuery.startsWith("skill:") |
| 10 | ? normalizedQuery.slice("skill:".length) |
| 11 | : normalizedQuery; |
| 12 | if (!skillQuery) return true; |
| 13 | return [skill.name, skill.displayName, skill.shortDescription, skill.description].some((value) => |
| 14 | value?.toLowerCase().includes(skillQuery), |
| 15 | ); |
| 16 | } |