grg-kit-cli 0.2.0 ā 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +97 -167
- package/bin/grg.js +25 -32
- package/commands/add.js +59 -101
- package/commands/init.js +150 -19
- package/commands/list.js +26 -58
- package/commands/llm-prompts.js +706 -0
- package/config/resources.js +15 -11
- package/package.json +6 -7
- package/scripts/README.md +4 -4
- package/scripts/generate-resources.js +14 -14
- package/commands/interactive.js +0 -223
- package/commands/metadata.js +0 -122
|
@@ -0,0 +1,706 @@
|
|
|
1
|
+
const fs = require('fs').promises;
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const chalk = require('chalk');
|
|
4
|
+
const ora = require('ora');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* LLM Prompts command - generates LLM-specific prompts and rules
|
|
8
|
+
* Helps AI assistants understand GRG Kit design system and use MCP server
|
|
9
|
+
*/
|
|
10
|
+
async function llmPrompts(options) {
|
|
11
|
+
const outputDir = options.output || '.windsurf/rules';
|
|
12
|
+
|
|
13
|
+
console.log(chalk.bold.cyan('\nš¤ Generating LLM Prompts and Rules\n'));
|
|
14
|
+
|
|
15
|
+
// Step 1: Create output directory
|
|
16
|
+
const spinner = ora('Creating rules directory...').start();
|
|
17
|
+
try {
|
|
18
|
+
await fs.mkdir(outputDir, { recursive: true });
|
|
19
|
+
spinner.succeed(chalk.green(`ā Created ${outputDir} directory`));
|
|
20
|
+
} catch (error) {
|
|
21
|
+
spinner.fail(chalk.red('Failed to create directory'));
|
|
22
|
+
console.error(chalk.red(error.message));
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Step 2: Generate design-system.md
|
|
27
|
+
spinner.start('Generating design-system.md...');
|
|
28
|
+
try {
|
|
29
|
+
const designSystemContent = generateDesignSystemRules();
|
|
30
|
+
const designSystemPath = path.join(outputDir, 'design-system.md');
|
|
31
|
+
await fs.writeFile(designSystemPath, designSystemContent);
|
|
32
|
+
spinner.succeed(chalk.green('ā Generated design-system.md'));
|
|
33
|
+
} catch (error) {
|
|
34
|
+
spinner.fail(chalk.red('Failed to generate design-system.md'));
|
|
35
|
+
console.error(chalk.red(error.message));
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Step 3: Generate grg-kit-mcp.md
|
|
40
|
+
spinner.start('Generating grg-kit-mcp.md...');
|
|
41
|
+
try {
|
|
42
|
+
const mcpContent = generateMCPRules();
|
|
43
|
+
const mcpPath = path.join(outputDir, 'grg-kit-mcp.md');
|
|
44
|
+
await fs.writeFile(mcpPath, mcpContent);
|
|
45
|
+
spinner.succeed(chalk.green('ā Generated grg-kit-mcp.md'));
|
|
46
|
+
} catch (error) {
|
|
47
|
+
spinner.fail(chalk.red('Failed to generate grg-kit-mcp.md'));
|
|
48
|
+
console.error(chalk.red(error.message));
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Success message
|
|
53
|
+
console.log(chalk.bold.green('\n⨠LLM prompts and rules generated successfully!\n'));
|
|
54
|
+
console.log(chalk.gray('Files created:'));
|
|
55
|
+
console.log(chalk.cyan(` ${outputDir}/design-system.md`));
|
|
56
|
+
console.log(chalk.cyan(` ${outputDir}/grg-kit-mcp.md`));
|
|
57
|
+
|
|
58
|
+
console.log(chalk.yellow('\nNext steps:'));
|
|
59
|
+
console.log(chalk.gray(' 1. These rules will be automatically picked up by Windsurf/Cascade'));
|
|
60
|
+
console.log(chalk.gray(' 2. Make sure the grg-kit MCP server is configured in your IDE'));
|
|
61
|
+
console.log(chalk.gray(' 3. AI will now check GRG Kit resources before writing custom code'));
|
|
62
|
+
console.log();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function generateDesignSystemRules() {
|
|
66
|
+
return `---
|
|
67
|
+
trigger: always_on
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
# GRG Kit Design System Rules
|
|
71
|
+
|
|
72
|
+
## Overview
|
|
73
|
+
|
|
74
|
+
This project uses **GRG Kit**, a comprehensive Angular UI toolkit built on top of **Spartan-NG UI**. The design system is organized into two main layers:
|
|
75
|
+
|
|
76
|
+
- **Brain (\`@spartan-ng/brain\`)**: Provides unstyled, accessible behavioral components
|
|
77
|
+
- **Helm (\`@spartan-ng/helm\`)**: Provides styled visual components built on top of Brain components
|
|
78
|
+
- **GRG Kit (\`@grg-kit/ui\`)**: Custom components with \`grg-\` prefix
|
|
79
|
+
|
|
80
|
+
## Critical Rules
|
|
81
|
+
|
|
82
|
+
### 1. Always Check GRG Kit First
|
|
83
|
+
**BEFORE writing any UI component, layout, or page:**
|
|
84
|
+
1. Use the MCP server to search for existing resources: \`search_ui_resources\`
|
|
85
|
+
2. Check if a component, layout, or example already exists
|
|
86
|
+
3. Only write custom code if no suitable resource exists
|
|
87
|
+
|
|
88
|
+
### 2. Component Organization
|
|
89
|
+
|
|
90
|
+
**Spartan-NG Components** (in \`libs/ui/\`):
|
|
91
|
+
- Use \`hlm\` prefix for directives
|
|
92
|
+
- Import via \`HlmComponentImports\`
|
|
93
|
+
- Example: \`HlmButtonImports\`, \`HlmCardImports\`
|
|
94
|
+
|
|
95
|
+
**GRG Kit Components** (in \`libs/grg-ui/\`):
|
|
96
|
+
- Use \`grg-\` prefix for selectors
|
|
97
|
+
- Import via \`GrgComponentImports\`
|
|
98
|
+
- Example: \`GrgStepperImports\`
|
|
99
|
+
- Path alias: \`@grg-kit/ui/component-name\`
|
|
100
|
+
|
|
101
|
+
### 3. Import Patterns
|
|
102
|
+
|
|
103
|
+
#### Standard Spartan-NG Import
|
|
104
|
+
\`\`\`typescript
|
|
105
|
+
import { HlmButtonImports } from '@spartan-ng/helm/button';
|
|
106
|
+
import { HlmAlertImports } from '@spartan-ng/helm/alert';
|
|
107
|
+
import { HlmCardImports } from '@spartan-ng/helm/card';
|
|
108
|
+
|
|
109
|
+
@Component({
|
|
110
|
+
imports: [HlmButtonImports, HlmAlertImports, HlmCardImports],
|
|
111
|
+
// ...
|
|
112
|
+
})
|
|
113
|
+
\`\`\`
|
|
114
|
+
|
|
115
|
+
#### Complex Components (Brain + Helm)
|
|
116
|
+
\`\`\`typescript
|
|
117
|
+
import { BrnDialogImports } from '@spartan-ng/brain/dialog';
|
|
118
|
+
import { HlmDialogImports } from '@spartan-ng/helm/dialog';
|
|
119
|
+
|
|
120
|
+
@Component({
|
|
121
|
+
imports: [BrnDialogImports, HlmDialogImports],
|
|
122
|
+
// ...
|
|
123
|
+
})
|
|
124
|
+
\`\`\`
|
|
125
|
+
|
|
126
|
+
#### GRG Kit Components
|
|
127
|
+
\`\`\`typescript
|
|
128
|
+
import { GrgStepperImports } from '@grg-kit/ui/stepper';
|
|
129
|
+
|
|
130
|
+
@Component({
|
|
131
|
+
imports: [GrgStepperImports],
|
|
132
|
+
template: \`
|
|
133
|
+
<grg-stepper>
|
|
134
|
+
<grg-step>...</grg-step>
|
|
135
|
+
</grg-stepper>
|
|
136
|
+
\`
|
|
137
|
+
})
|
|
138
|
+
\`\`\`
|
|
139
|
+
|
|
140
|
+
## Component Usage Patterns
|
|
141
|
+
|
|
142
|
+
### Basic Components
|
|
143
|
+
|
|
144
|
+
#### Button
|
|
145
|
+
\`\`\`typescript
|
|
146
|
+
// Basic usage
|
|
147
|
+
<button hlmBtn>Button</button>
|
|
148
|
+
|
|
149
|
+
// With variants
|
|
150
|
+
<button hlmBtn variant="destructive">Destructive</button>
|
|
151
|
+
<button hlmBtn variant="outline">Outline</button>
|
|
152
|
+
<button hlmBtn variant="ghost">Ghost</button>
|
|
153
|
+
<button hlmBtn variant="link">Link</button>
|
|
154
|
+
<button hlmBtn variant="secondary">Secondary</button>
|
|
155
|
+
|
|
156
|
+
// With sizes
|
|
157
|
+
<button hlmBtn size="sm">Small</button>
|
|
158
|
+
<button hlmBtn size="lg">Large</button>
|
|
159
|
+
\`\`\`
|
|
160
|
+
|
|
161
|
+
#### Input
|
|
162
|
+
\`\`\`typescript
|
|
163
|
+
// Basic input
|
|
164
|
+
<input hlmInput type="email" placeholder="Email" />
|
|
165
|
+
|
|
166
|
+
// With sizing
|
|
167
|
+
<input class="w-80" hlmInput type="email" placeholder="Email" />
|
|
168
|
+
\`\`\`
|
|
169
|
+
|
|
170
|
+
### Composite Components
|
|
171
|
+
|
|
172
|
+
#### Alert
|
|
173
|
+
\`\`\`typescript
|
|
174
|
+
<div hlmAlert>
|
|
175
|
+
<ng-icon hlm hlmAlertIcon name="lucideCircleCheck" />
|
|
176
|
+
<h4 hlmAlertTitle>Success! Your changes have been saved</h4>
|
|
177
|
+
<p hlmAlertDescription>This is an alert with icon, title and description.</p>
|
|
178
|
+
</div>
|
|
179
|
+
|
|
180
|
+
// Destructive variant
|
|
181
|
+
<div hlmAlert variant="destructive">
|
|
182
|
+
<ng-icon hlm hlmAlertIcon name="lucideCircleAlert" />
|
|
183
|
+
<h4 hlmAlertTitle>Unable to process your payment.</h4>
|
|
184
|
+
<div hlmAlertDescription>
|
|
185
|
+
<p>Please verify your billing information and try again.</p>
|
|
186
|
+
</div>
|
|
187
|
+
</div>
|
|
188
|
+
\`\`\`
|
|
189
|
+
|
|
190
|
+
#### Card
|
|
191
|
+
\`\`\`typescript
|
|
192
|
+
<section hlmCard>
|
|
193
|
+
<div hlmCardHeader>
|
|
194
|
+
<h3 hlmCardTitle>Card Title</h3>
|
|
195
|
+
<p hlmCardDescription>Card Description</p>
|
|
196
|
+
<div hlmCardAction>
|
|
197
|
+
<button hlmBtn variant="link">Action</button>
|
|
198
|
+
</div>
|
|
199
|
+
</div>
|
|
200
|
+
<div hlmCardContent>
|
|
201
|
+
<!-- Card content -->
|
|
202
|
+
</div>
|
|
203
|
+
<div hlmCardFooter>
|
|
204
|
+
<!-- Card footer -->
|
|
205
|
+
</div>
|
|
206
|
+
</section>
|
|
207
|
+
\`\`\`
|
|
208
|
+
|
|
209
|
+
#### Form Field
|
|
210
|
+
\`\`\`typescript
|
|
211
|
+
<hlm-form-field>
|
|
212
|
+
<input class="w-80" hlmInput [formControl]="control" type="email" placeholder="Email" />
|
|
213
|
+
<hlm-hint>This is your email address.</hlm-hint>
|
|
214
|
+
<hlm-error>The email is required.</hlm-error>
|
|
215
|
+
</hlm-form-field>
|
|
216
|
+
\`\`\`
|
|
217
|
+
|
|
218
|
+
### Interactive Components
|
|
219
|
+
|
|
220
|
+
#### Dialog
|
|
221
|
+
\`\`\`typescript
|
|
222
|
+
<hlm-dialog>
|
|
223
|
+
<button brnDialogTrigger hlmBtn variant="outline">Open Dialog</button>
|
|
224
|
+
<hlm-dialog-content *brnDialogContent="let ctx">
|
|
225
|
+
<hlm-dialog-header>
|
|
226
|
+
<h3 hlmDialogTitle>Edit profile</h3>
|
|
227
|
+
<p hlmDialogDescription>Make changes to your profile here.</p>
|
|
228
|
+
</hlm-dialog-header>
|
|
229
|
+
<div class="grid gap-4">
|
|
230
|
+
<!-- Dialog content -->
|
|
231
|
+
</div>
|
|
232
|
+
<hlm-dialog-footer>
|
|
233
|
+
<button hlmBtn variant="outline" brnDialogClose>Cancel</button>
|
|
234
|
+
<button hlmBtn type="submit">Save changes</button>
|
|
235
|
+
</hlm-dialog-footer>
|
|
236
|
+
</hlm-dialog-content>
|
|
237
|
+
</hlm-dialog>
|
|
238
|
+
\`\`\`
|
|
239
|
+
|
|
240
|
+
## Styling Patterns
|
|
241
|
+
|
|
242
|
+
### TailwindCSS v4 Integration
|
|
243
|
+
The design system uses TailwindCSS v4 syntax for all styling:
|
|
244
|
+
|
|
245
|
+
\`\`\`typescript
|
|
246
|
+
// Layout classes
|
|
247
|
+
class="flex flex-col gap-4"
|
|
248
|
+
class="grid grid-cols-2 gap-2"
|
|
249
|
+
class="w-full max-w-sm"
|
|
250
|
+
|
|
251
|
+
// Responsive design
|
|
252
|
+
class="flex flex-col justify-between gap-4 py-4 sm:flex-row sm:items-center"
|
|
253
|
+
|
|
254
|
+
// State-based styling
|
|
255
|
+
[attr.data-state]="row.getIsSelected() && 'selected'"
|
|
256
|
+
\`\`\`
|
|
257
|
+
|
|
258
|
+
### Component Variants
|
|
259
|
+
Components support multiple variants through the \`variant\` attribute:
|
|
260
|
+
|
|
261
|
+
\`\`\`typescript
|
|
262
|
+
// Button variants
|
|
263
|
+
variant="default" | "destructive" | "outline" | "secondary" | "ghost" | "link"
|
|
264
|
+
|
|
265
|
+
// Alert variants
|
|
266
|
+
variant="default" | "destructive"
|
|
267
|
+
|
|
268
|
+
// Badge variants
|
|
269
|
+
variant="default" | "secondary" | "destructive" | "outline"
|
|
270
|
+
\`\`\`
|
|
271
|
+
|
|
272
|
+
### Size Variants
|
|
273
|
+
Many components support size variants:
|
|
274
|
+
|
|
275
|
+
\`\`\`typescript
|
|
276
|
+
// Button sizes
|
|
277
|
+
size="default" | "sm" | "lg" | "icon"
|
|
278
|
+
|
|
279
|
+
// Icon sizes
|
|
280
|
+
size="sm" | "md" | "lg"
|
|
281
|
+
\`\`\`
|
|
282
|
+
|
|
283
|
+
## Icon Integration
|
|
284
|
+
|
|
285
|
+
### Lucide Icons with ng-icons
|
|
286
|
+
The design system integrates with Lucide icons through the ng-icons library:
|
|
287
|
+
|
|
288
|
+
\`\`\`typescript
|
|
289
|
+
import { NgIcon, provideIcons } from '@ng-icons/core';
|
|
290
|
+
import { lucideCircleCheck, lucideCircleAlert } from '@ng-icons/lucide';
|
|
291
|
+
|
|
292
|
+
@Component({
|
|
293
|
+
imports: [NgIcon, HlmIcon],
|
|
294
|
+
providers: [provideIcons({ lucideCircleCheck, lucideCircleAlert })],
|
|
295
|
+
template: \`
|
|
296
|
+
<ng-icon hlm hlmAlertIcon name="lucideCircleCheck" />
|
|
297
|
+
<ng-icon hlm name="lucideChevronDown" class="ml-2" size="sm" />
|
|
298
|
+
\`
|
|
299
|
+
})
|
|
300
|
+
\`\`\`
|
|
301
|
+
|
|
302
|
+
## Advanced Patterns
|
|
303
|
+
|
|
304
|
+
### Data Tables
|
|
305
|
+
For complex data display, use TanStack Table integration:
|
|
306
|
+
|
|
307
|
+
\`\`\`typescript
|
|
308
|
+
import {
|
|
309
|
+
createAngularTable,
|
|
310
|
+
flexRenderComponent,
|
|
311
|
+
FlexRenderDirective,
|
|
312
|
+
getCoreRowModel,
|
|
313
|
+
getFilteredRowModel,
|
|
314
|
+
getPaginationRowModel,
|
|
315
|
+
getSortedRowModel,
|
|
316
|
+
} from '@tanstack/angular-table';
|
|
317
|
+
|
|
318
|
+
// Define columns with flexRenderComponent for custom cells
|
|
319
|
+
const columns: ColumnDef<DataType>[] = [
|
|
320
|
+
{
|
|
321
|
+
id: 'select',
|
|
322
|
+
header: () => flexRenderComponent(TableHeadSelection),
|
|
323
|
+
cell: () => flexRenderComponent(TableRowSelection),
|
|
324
|
+
},
|
|
325
|
+
// ... other columns
|
|
326
|
+
];
|
|
327
|
+
\`\`\`
|
|
328
|
+
|
|
329
|
+
### Form Integration
|
|
330
|
+
Use Angular Reactive Forms with form field components:
|
|
331
|
+
|
|
332
|
+
\`\`\`typescript
|
|
333
|
+
import { FormControl, ReactiveFormsModule, Validators } from '@angular/forms';
|
|
334
|
+
|
|
335
|
+
@Component({
|
|
336
|
+
imports: [ReactiveFormsModule, HlmFormFieldImports],
|
|
337
|
+
template: \`
|
|
338
|
+
<hlm-form-field>
|
|
339
|
+
<input hlmInput [formControl]="emailControl" type="email" />
|
|
340
|
+
<hlm-error>Email is required.</hlm-error>
|
|
341
|
+
</hlm-form-field>
|
|
342
|
+
\`
|
|
343
|
+
})
|
|
344
|
+
export class FormComponent {
|
|
345
|
+
emailControl = new FormControl('', Validators.required);
|
|
346
|
+
}
|
|
347
|
+
\`\`\`
|
|
348
|
+
|
|
349
|
+
## Best Practices
|
|
350
|
+
|
|
351
|
+
### Component Composition
|
|
352
|
+
1. **Import Consistency**: Always use \`HlmComponentImports\` for importing related components
|
|
353
|
+
2. **Variant Usage**: Leverage built-in variants before creating custom styles
|
|
354
|
+
3. **Accessibility**: Brain components provide accessibility features - don't override them
|
|
355
|
+
4. **Icon Integration**: Use the ng-icons + Lucide pattern for consistent iconography
|
|
356
|
+
|
|
357
|
+
### Styling Guidelines
|
|
358
|
+
1. **TailwindCSS First**: Use Tailwind classes for layout and spacing
|
|
359
|
+
2. **Component Variants**: Use component variants for semantic styling
|
|
360
|
+
3. **Responsive Design**: Apply responsive classes following mobile-first approach
|
|
361
|
+
4. **State Management**: Use Angular signals for reactive state management
|
|
362
|
+
|
|
363
|
+
### Code Organization
|
|
364
|
+
1. **Reusable Components**: Add new reusable components to \`libs/ui/\` (Spartan) or \`libs/grg-ui/\` (GRG Kit)
|
|
365
|
+
2. **Example Components**: Keep examples in \`libs/examples/\` for documentation
|
|
366
|
+
3. **Import Grouping**: Group imports by source (Angular, third-party, internal)
|
|
367
|
+
4. **Type Safety**: Use TypeScript interfaces for component props and data structures
|
|
368
|
+
|
|
369
|
+
## Available Resources
|
|
370
|
+
|
|
371
|
+
### Basic Components
|
|
372
|
+
- **Button**: Interactive buttons with multiple variants and sizes
|
|
373
|
+
- **Input**: Form input fields with consistent styling
|
|
374
|
+
- **Label**: Form labels with proper accessibility
|
|
375
|
+
- **Badge**: Status indicators and tags
|
|
376
|
+
- **Avatar**: User profile images with fallbacks
|
|
377
|
+
|
|
378
|
+
### Layout Components
|
|
379
|
+
- **Card**: Content containers with header, content, and footer sections
|
|
380
|
+
- **Separator**: Visual dividers between content sections
|
|
381
|
+
- **Aspect Ratio**: Responsive containers with fixed aspect ratios
|
|
382
|
+
- **Scroll Area**: Custom scrollable containers
|
|
383
|
+
|
|
384
|
+
### Form Components
|
|
385
|
+
- **Form Field**: Complete form field with validation and hints
|
|
386
|
+
- **Checkbox**: Boolean input controls
|
|
387
|
+
- **Radio Group**: Single-choice selection controls
|
|
388
|
+
- **Select**: Dropdown selection controls
|
|
389
|
+
- **Autocomplete**: Search-enabled selection controls
|
|
390
|
+
|
|
391
|
+
### Navigation Components
|
|
392
|
+
- **Breadcrumb**: Hierarchical navigation indicators
|
|
393
|
+
- **Navigation Menu**: Primary navigation menus
|
|
394
|
+
- **Menubar**: Application menu bars
|
|
395
|
+
- **Pagination**: Data pagination controls
|
|
396
|
+
|
|
397
|
+
### Overlay Components
|
|
398
|
+
- **Dialog**: Modal dialogs and popups
|
|
399
|
+
- **Alert Dialog**: Confirmation and alert dialogs
|
|
400
|
+
- **Popover**: Contextual content overlays
|
|
401
|
+
- **Hover Card**: Content previews on hover
|
|
402
|
+
- **Sheet**: Slide-out panels
|
|
403
|
+
|
|
404
|
+
### Data Display Components
|
|
405
|
+
- **Table**: Data tables with sorting and filtering
|
|
406
|
+
- **Data Table**: Advanced data tables with TanStack integration
|
|
407
|
+
- **Alert**: Status messages and notifications
|
|
408
|
+
- **Progress**: Progress indicators
|
|
409
|
+
- **Skeleton**: Loading state placeholders
|
|
410
|
+
|
|
411
|
+
### Interactive Components
|
|
412
|
+
- **Command**: Command palette and search interfaces
|
|
413
|
+
- **Combobox**: Searchable select controls
|
|
414
|
+
- **Calendar**: Date selection interfaces
|
|
415
|
+
- **Date Picker**: Date input controls
|
|
416
|
+
- **Slider**: Range input controls
|
|
417
|
+
|
|
418
|
+
### GRG Kit Custom Components
|
|
419
|
+
- **Stepper**: Multi-step form wizard component
|
|
420
|
+
|
|
421
|
+
## Package Manager
|
|
422
|
+
|
|
423
|
+
**ALWAYS use pnpm** instead of npm for all package management operations:
|
|
424
|
+
- \`pnpm install\` instead of \`npm install\`
|
|
425
|
+
- \`pnpm add\` instead of \`npm install <package>\`
|
|
426
|
+
- \`pnpm remove\` instead of \`npm uninstall\`
|
|
427
|
+
|
|
428
|
+
This design system provides a comprehensive foundation for building consistent, accessible, and maintainable Angular applications using modern UI patterns and best practices.
|
|
429
|
+
`;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
function generateMCPRules() {
|
|
433
|
+
return `---
|
|
434
|
+
trigger: always_on
|
|
435
|
+
---
|
|
436
|
+
|
|
437
|
+
# GRG Kit MCP Server Integration
|
|
438
|
+
|
|
439
|
+
## Critical Workflow
|
|
440
|
+
|
|
441
|
+
**BEFORE writing ANY UI component, layout, or page, you MUST:**
|
|
442
|
+
|
|
443
|
+
1. **Search for existing resources** using the MCP server
|
|
444
|
+
2. **Install if found** - don't reinvent the wheel
|
|
445
|
+
3. **Only write custom code** if no suitable resource exists
|
|
446
|
+
|
|
447
|
+
## MCP Server Tools
|
|
448
|
+
|
|
449
|
+
The \`grg-kit\` MCP server provides these tools:
|
|
450
|
+
|
|
451
|
+
### 1. search_ui_resources (USE THIS FIRST!)
|
|
452
|
+
|
|
453
|
+
Search for UI resources by keyword. **This should be your FIRST action** when building UI.
|
|
454
|
+
|
|
455
|
+
\`\`\`typescript
|
|
456
|
+
// Example: User asks for a form
|
|
457
|
+
search_ui_resources({
|
|
458
|
+
query: "form",
|
|
459
|
+
category: "all" // or "themes", "components", "layouts", "examples"
|
|
460
|
+
})
|
|
461
|
+
|
|
462
|
+
// Returns: matching resources with install commands
|
|
463
|
+
\`\`\`
|
|
464
|
+
|
|
465
|
+
**When to use:**
|
|
466
|
+
- User asks for any UI component
|
|
467
|
+
- Building a new page or layout
|
|
468
|
+
- Need examples of how to use a component
|
|
469
|
+
- Looking for a theme
|
|
470
|
+
|
|
471
|
+
### 2. suggest_resources
|
|
472
|
+
|
|
473
|
+
Get AI-powered suggestions based on user requirements.
|
|
474
|
+
|
|
475
|
+
\`\`\`typescript
|
|
476
|
+
// Example: User says "build a login page"
|
|
477
|
+
suggest_resources({
|
|
478
|
+
requirement: "I need a login page"
|
|
479
|
+
})
|
|
480
|
+
|
|
481
|
+
// Returns: layout:auth, examples:form-field, examples:input, etc.
|
|
482
|
+
\`\`\`
|
|
483
|
+
|
|
484
|
+
**When to use:**
|
|
485
|
+
- User describes what they want to build
|
|
486
|
+
- Need recommendations for a specific use case
|
|
487
|
+
- Want to see what's available for a feature
|
|
488
|
+
|
|
489
|
+
### 3. get_resource_details
|
|
490
|
+
|
|
491
|
+
Get detailed information about a specific resource.
|
|
492
|
+
|
|
493
|
+
\`\`\`typescript
|
|
494
|
+
get_resource_details({
|
|
495
|
+
resource: "theme:claude"
|
|
496
|
+
})
|
|
497
|
+
|
|
498
|
+
// Returns: full metadata, dependencies, tags, install command
|
|
499
|
+
\`\`\`
|
|
500
|
+
|
|
501
|
+
**When to use:**
|
|
502
|
+
- Need to know dependencies before installing
|
|
503
|
+
- Want to understand what a resource provides
|
|
504
|
+
- Checking compatibility
|
|
505
|
+
|
|
506
|
+
### 4. install_resource
|
|
507
|
+
|
|
508
|
+
Install a resource into the project.
|
|
509
|
+
|
|
510
|
+
\`\`\`typescript
|
|
511
|
+
install_resource({
|
|
512
|
+
resource: "theme:claude",
|
|
513
|
+
output: "src/themes" // optional
|
|
514
|
+
})
|
|
515
|
+
|
|
516
|
+
// Executes: grg add theme:claude
|
|
517
|
+
\`\`\`
|
|
518
|
+
|
|
519
|
+
**When to use:**
|
|
520
|
+
- After finding a suitable resource
|
|
521
|
+
- User explicitly asks to install something
|
|
522
|
+
- Building a feature that needs specific components
|
|
523
|
+
|
|
524
|
+
### 5. list_available_resources
|
|
525
|
+
|
|
526
|
+
List all resources by category.
|
|
527
|
+
|
|
528
|
+
\`\`\`typescript
|
|
529
|
+
list_available_resources({
|
|
530
|
+
category: "all" // or specific category
|
|
531
|
+
})
|
|
532
|
+
|
|
533
|
+
// Returns: complete catalog with counts
|
|
534
|
+
\`\`\`
|
|
535
|
+
|
|
536
|
+
**When to use:**
|
|
537
|
+
- User asks "what's available?"
|
|
538
|
+
- Need to show options
|
|
539
|
+
- Exploring the catalog
|
|
540
|
+
|
|
541
|
+
## Workflow Examples
|
|
542
|
+
|
|
543
|
+
### Example 1: User Wants a Dashboard
|
|
544
|
+
|
|
545
|
+
\`\`\`
|
|
546
|
+
User: "Create a dashboard with a sidebar"
|
|
547
|
+
|
|
548
|
+
AI Workflow:
|
|
549
|
+
1. search_ui_resources({ query: "dashboard" })
|
|
550
|
+
ā Finds: layout:dashboard, examples:navigation-menu, examples:card
|
|
551
|
+
|
|
552
|
+
2. get_resource_details({ resource: "layout:dashboard" })
|
|
553
|
+
ā Check what it includes
|
|
554
|
+
|
|
555
|
+
3. install_resource({ resource: "layout:dashboard" })
|
|
556
|
+
ā Install the layout
|
|
557
|
+
|
|
558
|
+
4. install_resource({ resource: "examples:navigation-menu" })
|
|
559
|
+
ā Install navigation examples
|
|
560
|
+
|
|
561
|
+
5. Use the installed code as a base
|
|
562
|
+
ā Customize as needed
|
|
563
|
+
\`\`\`
|
|
564
|
+
|
|
565
|
+
### Example 2: User Wants Form Components
|
|
566
|
+
|
|
567
|
+
\`\`\`
|
|
568
|
+
User: "I need a form with validation"
|
|
569
|
+
|
|
570
|
+
AI Workflow:
|
|
571
|
+
1. search_ui_resources({ query: "form" })
|
|
572
|
+
ā Finds: component:stepper, examples:form-field, examples:input
|
|
573
|
+
|
|
574
|
+
2. suggest_resources({ requirement: "form with validation" })
|
|
575
|
+
ā Get recommendations
|
|
576
|
+
|
|
577
|
+
3. install_resource({ resource: "examples:form-field" })
|
|
578
|
+
ā Install form field examples
|
|
579
|
+
|
|
580
|
+
4. install_resource({ resource: "examples:input" })
|
|
581
|
+
ā Install input examples
|
|
582
|
+
|
|
583
|
+
5. Build the form using installed examples
|
|
584
|
+
ā Follow the patterns from examples
|
|
585
|
+
\`\`\`
|
|
586
|
+
|
|
587
|
+
### Example 3: User Wants a Theme
|
|
588
|
+
|
|
589
|
+
\`\`\`
|
|
590
|
+
User: "Add a nice theme to my app"
|
|
591
|
+
|
|
592
|
+
AI Workflow:
|
|
593
|
+
1. list_available_resources({ category: "themes" })
|
|
594
|
+
ā Show available themes
|
|
595
|
+
|
|
596
|
+
2. Present options to user
|
|
597
|
+
ā Let them choose
|
|
598
|
+
|
|
599
|
+
3. install_resource({ resource: "theme:claude" })
|
|
600
|
+
ā Install chosen theme
|
|
601
|
+
|
|
602
|
+
4. Verify installation
|
|
603
|
+
ā Check src/styles.css for import
|
|
604
|
+
\`\`\`
|
|
605
|
+
|
|
606
|
+
## Available Resources
|
|
607
|
+
|
|
608
|
+
### Themes (6 available)
|
|
609
|
+
- \`theme:grg-theme\` - Default GRG Kit theme
|
|
610
|
+
- \`theme:claude\` - Claude-inspired theme
|
|
611
|
+
- \`theme:modern-minimal\` - Modern minimal theme
|
|
612
|
+
- \`theme:vibrant\` - Vibrant color theme
|
|
613
|
+
- \`theme:dark-pro\` - Professional dark theme
|
|
614
|
+
- \`theme:nature\` - Nature-inspired theme
|
|
615
|
+
|
|
616
|
+
### Components (2+ available)
|
|
617
|
+
- \`component:stepper\` - Multi-step form wizard
|
|
618
|
+
- More components available via search
|
|
619
|
+
|
|
620
|
+
### Layouts (3+ available)
|
|
621
|
+
- \`layout:dashboard\` - Dashboard with sidebar
|
|
622
|
+
- \`layout:auth\` - Authentication pages
|
|
623
|
+
- \`layout:landing\` - Landing page template
|
|
624
|
+
- More layouts available via search
|
|
625
|
+
|
|
626
|
+
### Examples (56+ available)
|
|
627
|
+
All Spartan-NG components with complete examples:
|
|
628
|
+
- \`examples:button\` - Button examples
|
|
629
|
+
- \`examples:card\` - Card examples
|
|
630
|
+
- \`examples:dialog\` - Dialog examples
|
|
631
|
+
- \`examples:form-field\` - Form field examples
|
|
632
|
+
- \`examples:table\` - Table examples
|
|
633
|
+
- \`examples:all\` - Install ALL examples
|
|
634
|
+
- Many more available via search
|
|
635
|
+
|
|
636
|
+
## Best Practices
|
|
637
|
+
|
|
638
|
+
### 1. Always Search First
|
|
639
|
+
\`\`\`typescript
|
|
640
|
+
// ā DON'T: Immediately write custom code
|
|
641
|
+
// User: "I need a button"
|
|
642
|
+
// AI: "Here's a custom button component..."
|
|
643
|
+
|
|
644
|
+
// ā
DO: Search for existing resources first
|
|
645
|
+
// User: "I need a button"
|
|
646
|
+
// AI: search_ui_resources({ query: "button" })
|
|
647
|
+
// ā Finds examples:button
|
|
648
|
+
// ā install_resource({ resource: "examples:button" })
|
|
649
|
+
// ā "I've installed button examples. Let me show you how to use them..."
|
|
650
|
+
\`\`\`
|
|
651
|
+
|
|
652
|
+
### 2. Use Suggestions for Complex Requests
|
|
653
|
+
\`\`\`typescript
|
|
654
|
+
// User: "Build a user profile page"
|
|
655
|
+
// AI: suggest_resources({ requirement: "user profile page" })
|
|
656
|
+
// ā Get recommendations for layouts, components, examples
|
|
657
|
+
// ā Install relevant resources
|
|
658
|
+
// ā Build using installed code
|
|
659
|
+
\`\`\`
|
|
660
|
+
|
|
661
|
+
### 3. Check Details Before Installing
|
|
662
|
+
\`\`\`typescript
|
|
663
|
+
// Before installing, check what it includes
|
|
664
|
+
get_resource_details({ resource: "layout:dashboard" })
|
|
665
|
+
// ā See dependencies, tags, description
|
|
666
|
+
// ā Make informed decision
|
|
667
|
+
\`\`\`
|
|
668
|
+
|
|
669
|
+
### 4. Install Examples for Learning
|
|
670
|
+
\`\`\`typescript
|
|
671
|
+
// When user asks "how do I use X?"
|
|
672
|
+
// Install the example instead of explaining
|
|
673
|
+
install_resource({ resource: "examples:X" })
|
|
674
|
+
// ā User can see working code
|
|
675
|
+
// ā Better than verbal explanation
|
|
676
|
+
\`\`\`
|
|
677
|
+
|
|
678
|
+
## Error Handling
|
|
679
|
+
|
|
680
|
+
If a resource is not found:
|
|
681
|
+
1. Try broader search terms
|
|
682
|
+
2. Check if it's a Spartan-NG component (use examples)
|
|
683
|
+
3. Only then write custom code
|
|
684
|
+
4. Inform user that no pre-built resource exists
|
|
685
|
+
|
|
686
|
+
## Integration with Design System
|
|
687
|
+
|
|
688
|
+
After installing resources:
|
|
689
|
+
1. Follow the patterns from installed code
|
|
690
|
+
2. Use the same import style
|
|
691
|
+
3. Maintain consistency with design system
|
|
692
|
+
4. Leverage Tailwind CSS v4 for styling
|
|
693
|
+
|
|
694
|
+
## Remember
|
|
695
|
+
|
|
696
|
+
- **Search before you code** - GRG Kit has 60+ resources
|
|
697
|
+
- **Install examples** - They show best practices
|
|
698
|
+
- **Use layouts** - Don't build pages from scratch
|
|
699
|
+
- **Leverage themes** - Consistent styling out of the box
|
|
700
|
+
- **Check MCP first** - It knows what's available
|
|
701
|
+
|
|
702
|
+
This workflow ensures you're using GRG Kit to its full potential and providing users with production-ready, consistent code.
|
|
703
|
+
`;
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
module.exports = { llmPrompts };
|