matchPredicate builds the WHERE clause (without the leading "WHERE") for a search, optionally narrowed by kind. Pass the raw kind string ("" = any kind).
(kind string)
| 172 | // matchPredicate builds the WHERE clause (without the leading "WHERE") for a |
| 173 | // search, optionally narrowed by kind. Pass the raw kind string ("" = any kind). |
| 174 | func matchPredicate(kind string) string { |
| 175 | pred := "(name LIKE ? OR description LIKE ? OR repo_owner LIKE ? OR repo_name LIKE ? OR install_key LIKE ?)" |
| 176 | lead := "" |
| 177 | if kind != "" { |
| 178 | lead = "kind = ? AND " |
| 179 | } |
| 180 | // A subagent is a markdown file beneath an `agents/` folder. Rows whose |
| 181 | // in-repo path has no `agents` segment (commands/, docs/, README, …) are |
| 182 | // not subagents and must never appear on the SubAgents page. This mirrors |
| 183 | // DiscoverResources' underAgentsFolder at query time, so index entries left |
| 184 | // by an older binary (before that filter existed) can't leak through. |
| 185 | if kind == "agent" { |
| 186 | lead += "(item_path LIKE 'agents/%' OR item_path LIKE '%/agents/%') AND " |
| 187 | } |
| 188 | return lead + pred |
| 189 | } |
| 190 | |
| 191 | // Search queries the metadata_items table with LIKE matching. Results are |
| 192 | // deduplicated by name (case-insensitive): when the same name exists in |