refactor(@angular/cli): enhance example search with structured data - #31138
Merged
Conversation
This commit refactors the `find_examples` MCP tool and its associated database generator to leverage the structured YAML front matter present in the example markdown files. Key changes: - The SQLite database schema is now relational, with dedicated columns for `title`, `summary`, and `keywords`. - An FTS5 virtual table indexes these structured fields, improving search relevance by allowing queries to target specific metadata. - The build-time database generator (`tools/example_db_generator.js`) now parses and validates the front matter of each example file using Zod. The build will fail if an example is missing a required field (`title`, `summary`), ensuring data integrity. - The runtime tool (`packages/.../examples.ts`) uses the same parsing logic but will warn and skip invalid files to be more resilient. This change provides a more robust and accurate foundation for the example search feature, enabling more precise results and paving the way for future enhancements like semantic search.
This commit enhances the `find_examples` MCP tool by introducing advanced filtering capabilities, allowing for more precise and powerful queries. The tool's input schema now accepts optional array-based filters for `keywords`, `required_packages`, and `related_concepts`. These filters are combined with the main full-text search query to narrow down results. To support this, the underlying SQLite database schema has been extended with dedicated columns for this metadata. The build-time database generator and the runtime tool have both been updated to parse, validate, and store this structured data from the example file's front matter. The query logic is now fully dynamic, constructing parameterized SQL queries to safely and efficiently filter the examples based on the provided criteria.
This commit improves the relevance of the `find_examples` MCP server tool by implementing weighted search ranking. The FTS5 query now uses the `bm25()` ranking function to assign a higher weight to matches found in more important fields. Specifically, matches in the `title`, `summary`, and `keywords` are now weighted more heavily than matches in the main content. This results in more accurate and intuitive search results, as examples where the query terms are central to the topic are ranked higher.
clydin
marked this pull request as ready for review
September 8, 2025 17:40
alan-agius4
approved these changes
Sep 9, 2025
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit refactors the
find_examplesMCP tool and its associated database generator to leverage the structured YAML front matter present in the example markdown files.Key changes:
title,summary, andkeywords.tools/example_db_generator.js) now parses and validates the front matter of each example file using Zod. The build will fail if an example is missing a required field (title,summary), ensuring data integrity.packages/.../examples.ts) uses the same parsing logic but will warn and skip invalid files to be more resilient.This change provides a more robust and accurate foundation for the example search feature, enabling more precise results and paving the way for future enhancements like semantic search.