/** Pure matcher for the command palette — every query term must appear. */ export interface PaletteItem { id: string label: string group: string hint?: string } export function matchItems(items: PaletteItem[], q: string, limit = 12): PaletteItem[] { const terms = q.trim().toLowerCase().split(/\s+/).filter((t) => t !== '') if (terms.length === 0) return items.slice(0, limit) const out: PaletteItem[] = [] for (const item of items) { const hay = `${item.label} ${item.hint ?? ''}`.toLowerCase() if (terms.every((t) => hay.includes(t))) { out.push(item) if (out.length >= limit) break } } return out }