@@ -4,12 +4,24 @@ import { BLAZOR_DOTNET_GUIDE, SETUP_DOCS, SETUP_MD } from './constants.js';
44export const MISSING_FRAMEWORK_MESSAGE =
55 'Which framework are you using? Please specify one of: angular, react, blazor, or webcomponents.' ;
66
7+ // Sanitize user input for FTS4 MATCH syntax.
8+ // Strip characters that are FTS4 operators or cause syntax errors:
9+ // " (phrase delimiter), ( ) (grouping), : (column filter), @ (internal)
10+ // Preserve hyphens — the porter tokenizer handles them consistently
11+ // at both index and query time (e.g. "grid-editing" stays as one phrase).
12+ // Preserve trailing * — FTS4 prefix queries (e.g. grid*) rely on it,
13+ // and the DB is built with prefix="2,3" indexes to support this.
714export function sanitizeSearchDocsQuery ( queryText : string ) : string | null {
815 const sanitized = queryText
916 . replace ( / [ " ( ) { } [ \] : @ ] / g, ' ' )
1017 . split ( / \s + / )
1118 . filter ( Boolean )
1219 . map ( ( term ) => {
20+ // Terms ending with * are prefix queries — don't quote them
21+ // because FTS4 treats "grid*" as a literal match for the
22+ // asterisk character, while unquoted grid* does prefix expansion.
23+ // Drop terms that are only asterisks (e.g. *, **) — they have
24+ // no actual prefix and would cause an FTS4 syntax error.
1325 if ( term . endsWith ( '*' ) ) {
1426 return / [ ^ * ] / . test ( term ) ? term : null ;
1527 }
@@ -22,6 +34,11 @@ export function sanitizeSearchDocsQuery(queryText: string): string | null {
2234 return sanitized || null ;
2335}
2436
37+ // Build the setup-guide response for the requested framework.
38+ // For Blazor, combine the base .NET guide with any MCP-fetched docs
39+ // that are available for the configured setup document names.
40+ // For other frameworks, return the static setup markdown when present,
41+ // otherwise fall back to a simple "not available" message.
2542export async function buildProjectSetupGuide (
2643 docsProvider : DocsProvider ,
2744 framework ?: string ,
@@ -48,4 +65,4 @@ export async function buildProjectSetupGuide(
4865 SETUP_MD [ framework ] ??
4966 `No setup guide available for framework: ${ framework } `
5067 ) ;
51- }
68+ }
0 commit comments