Add prefix matching to registry search

Search terms now automatically get a * suffix for prefix matching.
E.g., searching "summ" matches "summarize", "summary", etc.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
rob 2026-01-17 02:42:46 -04:00
parent 85d1212c0d
commit a46add05b7
2 changed files with 7 additions and 1 deletions

View File

@ -55,6 +55,7 @@ All notable changes to CmdForge will be documented in this file.
- Logs when AI review is skipped with reason
### Fixed
- **Registry search partial matching**: Search now supports prefix matching (e.g., "summ" matches "summarize")
- VERSION_EXISTS error showing after successful publish (made endpoint idempotent by checking config_hash)
- My Tools page listing every version separately (now consolidated by tool name)
- GUI not refreshing after publish dialog closes

View File

@ -677,10 +677,15 @@ def create_app() -> Flask:
# Sanitize query for FTS5 - escape special characters that cause syntax errors
# FTS5 special chars: * " ( ) : ^ - NOT AND OR NEAR
# For safety, we'll quote the entire query if it contains special chars
fts5_special = set('*"():^-')
fts5_special = set('"():^-')
if any(c in fts5_special for c in query_text) or query_text.upper() in ('NOT', 'AND', 'OR', 'NEAR'):
# Escape double quotes and wrap in quotes for literal search
query_text = '"' + query_text.replace('"', '""') + '"'
else:
# Add prefix matching - append * to each word for partial matches
# e.g., "summ text" becomes "summ* text*" to match "summarize", "text", "texting"
words = query_text.split()
query_text = " ".join(word + "*" if not word.endswith("*") else word for word in words)
page, per_page, sort, order, error = parse_pagination("/tools/search", "downloads")
if error: