Skip to content

Commit bc754d6

Browse files
committed
refactor(@angular/cli): enhance example search with structured data
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.
1 parent 0c84e42 commit bc754d6

23 files changed

+238
-52
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@
145145
"verdaccio": "6.1.6",
146146
"verdaccio-auth-memory": "^10.0.0",
147147
"yargs-parser": "22.0.0",
148+
"zod": "4.1.5",
148149
"zone.js": "^0.15.0"
149150
},
150151
"dependenciesMeta": {

packages/angular/cli/lib/examples/signal-forms/01-basic-signal-form.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ export interface UserProfile {
4848

4949
@Component({
5050
selector: 'app-user-profile',
51-
standalone: true,
5251
imports: [JsonPipe],
5352
templateUrl: './user-profile.component.html',
5453
changeDetection: ChangeDetectionStrategy.OnPush,
@@ -125,7 +124,6 @@ import { UserProfileComponent, UserProfile } from './user-profile.component';
125124

126125
@Component({
127126
selector: 'app-root',
128-
standalone: true,
129127
imports: [UserProfileComponent, JsonPipe],
130128
template: `
131129
<h1>User Profile</h1>

packages/angular/cli/lib/examples/signal-forms/02-built-in-validators.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ const settingsSchema = schema<UserSettings>((form) => {
7272

7373
@Component({
7474
selector: 'app-user-settings',
75-
standalone: true,
7675
imports: [JsonPipe],
7776
templateUrl: './user-settings.component.html',
7877
changeDetection: ChangeDetectionStrategy.OnPush,
@@ -183,7 +182,6 @@ import { UserSettingsComponent, UserSettings } from './user-settings.component';
183182

184183
@Component({
185184
selector: 'app-root',
186-
standalone: true,
187185
imports: [UserSettingsComponent, JsonPipe],
188186
template: `
189187
<h1>User Settings</h1>

packages/angular/cli/lib/examples/signal-forms/03-cross-field-validation.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ const passwordSchema = schema<PasswordForm>((passwordForm) => {
7474

7575
@Component({
7676
selector: 'app-password-form',
77-
standalone: true,
7877
imports: [JsonPipe],
7978
templateUrl: './password-form.component.html',
8079
changeDetection: ChangeDetectionStrategy.OnPush,
@@ -154,7 +153,6 @@ import { PasswordFormComponent, PasswordForm } from './password-form.component';
154153

155154
@Component({
156155
selector: 'app-root',
157-
standalone: true,
158156
imports: [PasswordFormComponent, JsonPipe],
159157
template: `
160158
<h1>Change Password</h1>

packages/angular/cli/lib/examples/signal-forms/04-conditional-validation.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ const contactSchema = schema<ContactForm>((contactForm) => {
5757

5858
@Component({
5959
selector: 'app-contact-form',
60-
standalone: true,
6160
imports: [JsonPipe],
6261
templateUrl: './contact-form.component.html',
6362
changeDetection: ChangeDetectionStrategy.OnPush,
@@ -126,7 +125,6 @@ import { ContactFormComponent, ContactForm } from './contact-form.component';
126125

127126
@Component({
128127
selector: 'app-root',
129-
standalone: true,
130128
imports: [ContactFormComponent, JsonPipe],
131129
template: `
132130
<h1>Contact Us</h1>

packages/angular/cli/lib/examples/signal-forms/05-dynamic-field-state-hidden.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ const contactSchema = schema<ContactForm>((form) => {
5555

5656
@Component({
5757
selector: 'app-contact-form',
58-
standalone: true,
5958
imports: [JsonPipe],
6059
templateUrl: './contact-form.component.html',
6160
changeDetection: ChangeDetectionStrategy.OnPush,
@@ -127,7 +126,6 @@ import { ContactFormComponent, ContactForm } from './contact-form.component';
127126

128127
@Component({
129128
selector: 'app-root',
130-
standalone: true,
131129
imports: [ContactFormComponent, JsonPipe],
132130
template: `
133131
<h1>Contact Us</h1>

packages/angular/cli/lib/examples/signal-forms/06-conditionally-disabling-fields.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ const promoSchema = schema<PromoForm>((form) => {
5555

5656
@Component({
5757
selector: 'app-promo-form',
58-
standalone: true,
5958
imports: [JsonPipe],
6059
templateUrl: './promo-form.component.html',
6160
changeDetection: ChangeDetectionStrategy.OnPush,
@@ -127,7 +126,6 @@ import { PromoFormComponent, PromoForm } from './promo-form.component';
127126

128127
@Component({
129128
selector: 'app-root',
130-
standalone: true,
131129
imports: [PromoFormComponent, JsonPipe],
132130
template: `
133131
<h1>Promotional Code</h1>

packages/angular/cli/lib/examples/signal-forms/07-dynamic-arrays.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ const surveySchema = schema<SurveyForm>((survey) => {
6262

6363
@Component({
6464
selector: 'app-survey-form',
65-
standalone: true,
6665
imports: [JsonPipe],
6766
templateUrl: './survey-form.component.html',
6867
changeDetection: ChangeDetectionStrategy.OnPush,
@@ -155,7 +154,6 @@ import { SurveyFormComponent, SurveyForm } from './survey-form.component';
155154

156155
@Component({
157156
selector: 'app-root',
158-
standalone: true,
159157
imports: [SurveyFormComponent, JsonPipe],
160158
template: `
161159
<h1>Create Survey</h1>

packages/angular/cli/lib/examples/signal-forms/08-custom-form-control.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ import { FormValueControl } from '@angular/forms/signals';
4343

4444
@Component({
4545
selector: 'app-numeric-stepper',
46-
standalone: true,
4746
template: `
4847
<button type="button" (click)="decrement()">-</button>
4948
<span>{{ value() }}</span>
@@ -81,7 +80,6 @@ export interface ProductForm {
8180

8281
@Component({
8382
selector: 'app-product-form',
84-
standalone: true,
8583
imports: [JsonPipe, NumericStepperComponent],
8684
templateUrl: './product-form.component.html',
8785
changeDetection: ChangeDetectionStrategy.OnPush,
@@ -145,7 +143,6 @@ import { ProductFormComponent, ProductForm } from './product-form.component';
145143

146144
@Component({
147145
selector: 'app-root',
148-
standalone: true,
149146
imports: [ProductFormComponent, JsonPipe],
150147
template: `
151148
<h1>Product Order</h1>

packages/angular/cli/lib/examples/signal-forms/09-async-validation.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ const registrationSchema = schema<RegistrationForm>((form) => {
5858

5959
@Component({
6060
selector: 'app-registration-form',
61-
standalone: true,
6261
imports: [JsonPipe],
6362
templateUrl: './registration-form.component.html',
6463
changeDetection: ChangeDetectionStrategy.OnPush,
@@ -160,7 +159,6 @@ import { RegistrationFormComponent, RegistrationForm } from './registration-form
160159

161160
@Component({
162161
selector: 'app-root',
163-
standalone: true,
164162
imports: [RegistrationFormComponent, JsonPipe],
165163
template: `
166164
<h1>Register</h1>

0 commit comments

Comments
 (0)