grg-kit-cli 0.3.2 → 0.3.3

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.
@@ -2,6 +2,7 @@ const fs = require('fs').promises;
2
2
  const path = require('path');
3
3
  const chalk = require('chalk');
4
4
  const ora = require('ora');
5
+ const { RESOURCES } = require('../config/resources');
5
6
 
6
7
  /**
7
8
  * LLM Prompts command - generates LLM-specific prompts and rules
@@ -49,11 +50,25 @@ async function llmPrompts(options) {
49
50
  process.exit(1);
50
51
  }
51
52
 
53
+ // Step 4: Generate angular-components.md (glob-triggered)
54
+ spinner.start('Generating angular-components.md...');
55
+ try {
56
+ const angularContent = generateAngularComponentRules();
57
+ const angularPath = path.join(outputDir, 'angular-components.md');
58
+ await fs.writeFile(angularPath, angularContent);
59
+ spinner.succeed(chalk.green('✓ Generated angular-components.md'));
60
+ } catch (error) {
61
+ spinner.fail(chalk.red('Failed to generate angular-components.md'));
62
+ console.error(chalk.red(error.message));
63
+ process.exit(1);
64
+ }
65
+
52
66
  // Success message
53
67
  console.log(chalk.bold.green('\n✨ LLM prompts and rules generated successfully!\n'));
54
68
  console.log(chalk.gray('Files created:'));
55
69
  console.log(chalk.cyan(` ${outputDir}/design-system.md`));
56
70
  console.log(chalk.cyan(` ${outputDir}/grg-kit-mcp.md`));
71
+ console.log(chalk.cyan(` ${outputDir}/angular-components.md`));
57
72
 
58
73
  console.log(chalk.yellow('\nNext steps:'));
59
74
  console.log(chalk.gray(' 1. These rules will be automatically picked up by Windsurf/Cascade'));
@@ -430,114 +445,126 @@ This design system provides a comprehensive foundation for building consistent,
430
445
  }
431
446
 
432
447
  function generateMCPRules() {
448
+ // Dynamically build resource lists from resources.js
449
+ // Note: Spartan-NG components are pre-installed, so we only list GRG Kit resources
450
+ const themes = RESOURCES.themes || [];
451
+ const components = RESOURCES.components || [];
452
+ const blocks = RESOURCES.blocks || [];
453
+
454
+ const themesList = themes.map(t => `- \`theme:${t.name}\` - ${t.description}`).join('\n');
455
+ const componentsList = components.map(c => `- \`component:${c.name}\` - ${c.description}`).join('\n');
456
+ const blocksList = blocks.map(b => `- \`block:${b.name}\` - ${b.description}`).join('\n');
457
+
458
+ const totalResources = themes.length + components.length + blocks.length;
459
+
433
460
  return `---
434
461
  trigger: always_on
435
462
  ---
436
463
 
437
464
  # GRG Kit MCP Server Integration
438
465
 
439
- ## Critical Workflow
466
+ ## Setup
467
+
468
+ Add the grg-kit MCP server to your Windsurf configuration:
469
+
470
+ **File:** \`~/.codeium/windsurf/mcp_config.json\`
471
+
472
+ \`\`\`json
473
+ {
474
+ "mcpServers": {
475
+ "grg-kit": {
476
+ "command": "npx",
477
+ "args": ["-y", "@grg-kit/mcp-server"]
478
+ }
479
+ }
480
+ }
481
+ \`\`\`
482
+
483
+ After adding, restart Windsurf for the MCP server to be available.
484
+
485
+ ## Important: Spartan-NG is Pre-installed
486
+
487
+ **Spartan-NG components are already installed** in this project. You do NOT need to use MCP to install them.
440
488
 
441
- **BEFORE writing ANY UI component, layout, or page, you MUST:**
489
+ - For Spartan-NG usage patterns Refer to \`design-system.md\`
490
+ - For themes, blocks, and GRG Kit components → Use MCP tools below
442
491
 
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
492
+ ## When to Use MCP
493
+
494
+ Use the MCP server for:
495
+ 1. **Themes** - Install different color themes
496
+ 2. **Blocks** - Pre-built page layouts (auth, shell, settings)
497
+ 3. **GRG Kit Components** - Custom components like stepper, file-upload
498
+
499
+ **Do NOT use MCP for:**
500
+ - Spartan-NG components (button, card, dialog, etc.) - already installed
501
+ - Basic UI patterns - see \`design-system.md\`
446
502
 
447
503
  ## MCP Server Tools
448
504
 
449
505
  The \`grg-kit\` MCP server provides these tools:
450
506
 
451
- ### 1. search_ui_resources (USE THIS FIRST!)
507
+ ### 1. mcp2_search_ui_resources
452
508
 
453
- Search for UI resources by keyword. **This should be your FIRST action** when building UI.
509
+ Search for GRG Kit resources (themes, blocks, components).
454
510
 
455
511
  \`\`\`typescript
456
- // Example: User asks for a form
457
- search_ui_resources({
458
- query: "form",
459
- category: "all" // or "themes", "components", "layouts", "examples"
512
+ mcp2_search_ui_resources({
513
+ query: "auth",
514
+ category: "all" // or "themes", "components", "layouts"
460
515
  })
461
-
462
- // Returns: matching resources with install commands
463
516
  \`\`\`
464
517
 
465
518
  **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
519
+ - User needs a page layout or block
469
520
  - Looking for a theme
521
+ - Need a GRG Kit component (stepper, file-upload)
470
522
 
471
- ### 2. suggest_resources
523
+ ### 2. mcp2_suggest_resources
472
524
 
473
- Get AI-powered suggestions based on user requirements.
525
+ Get suggestions based on user requirements.
474
526
 
475
527
  \`\`\`typescript
476
- // Example: User says "build a login page"
477
- suggest_resources({
528
+ mcp2_suggest_resources({
478
529
  requirement: "I need a login page"
479
530
  })
480
531
 
481
- // Returns: layout:auth, examples:form-field, examples:input, etc.
532
+ // Returns: block:auth, theme suggestions
482
533
  \`\`\`
483
534
 
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
535
+ ### 3. mcp2_get_resource_details
490
536
 
491
- Get detailed information about a specific resource.
537
+ Get detailed information about a resource.
492
538
 
493
539
  \`\`\`typescript
494
- get_resource_details({
495
- resource: "theme:claude"
540
+ mcp2_get_resource_details({
541
+ resource: "block:auth"
496
542
  })
497
543
 
498
- // Returns: full metadata, dependencies, tags, install command
544
+ // Returns: dependencies, tags, install command
499
545
  \`\`\`
500
546
 
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
547
+ ### 4. mcp2_install_resource
507
548
 
508
549
  Install a resource into the project.
509
550
 
510
551
  \`\`\`typescript
511
- install_resource({
512
- resource: "theme:claude",
513
- output: "src/themes" // optional
552
+ mcp2_install_resource({
553
+ resource: "block:auth",
554
+ output: "src/app/pages/auth" // optional
514
555
  })
515
-
516
- // Executes: grg add theme:claude
517
556
  \`\`\`
518
557
 
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
558
+ ### 5. mcp2_list_available_resources
525
559
 
526
- List all resources by category.
560
+ List all available resources.
527
561
 
528
562
  \`\`\`typescript
529
- list_available_resources({
530
- category: "all" // or specific category
563
+ mcp2_list_available_resources({
564
+ category: "all" // or "themes", "components", "layouts"
531
565
  })
532
-
533
- // Returns: complete catalog with counts
534
566
  \`\`\`
535
567
 
536
- **When to use:**
537
- - User asks "what's available?"
538
- - Need to show options
539
- - Exploring the catalog
540
-
541
568
  ## Workflow Examples
542
569
 
543
570
  ### Example 1: User Wants a Dashboard
@@ -546,160 +573,209 @@ list_available_resources({
546
573
  User: "Create a dashboard with a sidebar"
547
574
 
548
575
  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
576
+ 1. mcp2_search_ui_resources({ query: "shell sidebar" })
577
+ → Finds: block:shell
557
578
 
558
- 4. install_resource({ resource: "examples:navigation-menu" })
559
- → Install navigation examples
579
+ 2. mcp2_install_resource({ resource: "block:shell" })
580
+ → Install the shell layout
560
581
 
561
- 5. Use the installed code as a base
562
- Customize as needed
582
+ 3. Customize using Spartan-NG components (from design-system.md)
583
+ Add cards, tables, etc.
563
584
  \`\`\`
564
585
 
565
- ### Example 2: User Wants Form Components
586
+ ### Example 2: User Wants a Login Page
566
587
 
567
588
  \`\`\`
568
- User: "I need a form with validation"
589
+ User: "I need a login page"
569
590
 
570
591
  AI Workflow:
571
- 1. search_ui_resources({ query: "form" })
572
- → Finds: component:stepper, examples:form-field, examples:input
592
+ 1. mcp2_search_ui_resources({ query: "auth login" })
593
+ → Finds: block:auth
573
594
 
574
- 2. suggest_resources({ requirement: "form with validation" })
575
- Get recommendations
595
+ 2. mcp2_install_resource({ resource: "block:auth" })
596
+ Install auth block (includes login, signup, forgot password)
576
597
 
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
598
+ 3. Customize as needed
585
599
  \`\`\`
586
600
 
587
601
  ### Example 3: User Wants a Theme
588
602
 
589
603
  \`\`\`
590
- User: "Add a nice theme to my app"
604
+ User: "Change the theme to something warmer"
591
605
 
592
606
  AI Workflow:
593
- 1. list_available_resources({ category: "themes" })
594
- → Show available themes
607
+ 1. mcp2_list_available_resources({ category: "themes" })
608
+ → Show: claude, amber-minimal, etc.
595
609
 
596
- 2. Present options to user
597
- Let them choose
610
+ 2. mcp2_install_resource({ resource: "theme:claude" })
611
+ Install theme
598
612
 
599
- 3. install_resource({ resource: "theme:claude" })
600
- → Install chosen theme
613
+ 3. Update src/styles.css import
614
+ \`\`\`
615
+
616
+ ### Example 4: User Wants a Form Component
617
+
618
+ \`\`\`
619
+ User: "I need a multi-step form"
620
+
621
+ AI Workflow:
622
+ 1. mcp2_search_ui_resources({ query: "stepper form" })
623
+ → Finds: component:stepper
624
+
625
+ 2. mcp2_install_resource({ resource: "component:stepper" })
626
+ → Install stepper component
601
627
 
602
- 4. Verify installation
603
- → Check src/styles.css for import
628
+ 3. Use with Spartan-NG form components (from design-system.md)
604
629
  \`\`\`
605
630
 
606
- ## Available Resources
631
+ ## Available Resources (${totalResources} total)
607
632
 
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
633
+ ### Themes (${themes.length} available)
634
+ ${themesList}
635
635
 
636
- ## Best Practices
636
+ ### GRG Kit Components (${components.length} available)
637
+ ${componentsList}
637
638
 
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..."
639
+ ### Blocks/Layouts (${blocks.length} available)
640
+ ${blocksList}
643
641
 
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..."
642
+ ## Decision Tree
643
+
644
+ \`\`\`
645
+ User request:
646
+
647
+ ├─ Need a button, card, dialog, form field, table, etc.?
648
+ │ └─ Use Spartan-NG (see design-system.md) - ALREADY INSTALLED
649
+
650
+ ├─ Need a page layout (dashboard, auth, settings)?
651
+ │ └─ Use MCP: mcp2_search_ui_resources({ query: "..." })
652
+
653
+ ├─ Need a theme?
654
+ │ └─ Use MCP: mcp2_list_available_resources({ category: "themes" })
655
+
656
+ └─ Need stepper, file-upload, or other GRG Kit component?
657
+ └─ Use MCP: mcp2_search_ui_resources({ query: "..." })
650
658
  \`\`\`
651
659
 
652
- ### 2. Use Suggestions for Complex Requests
660
+ ## Remember
661
+
662
+ - **Spartan-NG is pre-installed** - Don't search for button, card, dialog, etc.
663
+ - **Use design-system.md** for Spartan-NG patterns
664
+ - **Use MCP** only for themes, blocks, and GRG Kit components
665
+ - **Check blocks first** when building pages - don't start from scratch
666
+ `;
667
+ }
668
+
669
+ function generateAngularComponentRules() {
670
+ // Spartan-NG components are pre-installed - list the common ones
671
+ const spartanComponents = [
672
+ 'accordion', 'alert', 'alert-dialog', 'avatar', 'badge', 'breadcrumb',
673
+ 'button', 'calendar', 'card', 'checkbox', 'collapsible', 'combobox',
674
+ 'command', 'context-menu', 'data-table', 'date-picker', 'dialog',
675
+ 'dropdown-menu', 'form-field', 'hover-card', 'input', 'label', 'menubar',
676
+ 'navigation-menu', 'pagination', 'popover', 'progress', 'radio-group',
677
+ 'scroll-area', 'select', 'separator', 'sheet', 'sidebar', 'skeleton',
678
+ 'slider', 'sonner', 'spinner', 'switch', 'table', 'tabs', 'textarea',
679
+ 'toggle', 'tooltip'
680
+ ];
681
+ const componentNames = spartanComponents.join(', ');
682
+
683
+ return `---
684
+ trigger: glob
685
+ globs: ["**/*.component.ts", "**/*.component.html"]
686
+ ---
687
+
688
+ # Angular Component Development with GRG Kit
689
+
690
+ You are editing an Angular component. Before writing UI code:
691
+
692
+ ## Quick Reference
693
+
694
+ ### Spartan-NG Components (Pre-installed)
695
+ These components are already available - just import and use them:
696
+ ${componentNames}
697
+
698
+ ### Import Patterns
699
+
700
+ **Spartan-NG (hlm prefix):**
653
701
  \`\`\`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
702
+ import { HlmButtonImports } from '@spartan-ng/helm/button';
703
+ import { HlmCardImports } from '@spartan-ng/helm/card';
704
+ import { BrnDialogImports } from '@spartan-ng/brain/dialog';
705
+ import { HlmDialogImports } from '@spartan-ng/helm/dialog';
659
706
  \`\`\`
660
707
 
661
- ### 3. Check Details Before Installing
708
+ **GRG Kit (grg- prefix):**
662
709
  \`\`\`typescript
663
- // Before installing, check what it includes
664
- get_resource_details({ resource: "layout:dashboard" })
665
- // → See dependencies, tags, description
666
- // → Make informed decision
710
+ import { GrgStepperImports } from '@grg-kit/ui/stepper';
667
711
  \`\`\`
668
712
 
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
713
+ ### Common Patterns
714
+
715
+ **Button:**
716
+ \`\`\`html
717
+ <button hlmBtn>Default</button>
718
+ <button hlmBtn variant="outline">Outline</button>
719
+ <button hlmBtn variant="destructive">Destructive</button>
676
720
  \`\`\`
677
721
 
678
- ## Error Handling
722
+ **Card:**
723
+ \`\`\`html
724
+ <section hlmCard>
725
+ <div hlmCardHeader>
726
+ <h3 hlmCardTitle>Title</h3>
727
+ <p hlmCardDescription>Description</p>
728
+ </div>
729
+ <div hlmCardContent>Content</div>
730
+ </section>
731
+ \`\`\`
679
732
 
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
733
+ **Form Field:**
734
+ \`\`\`html
735
+ <hlm-form-field>
736
+ <input hlmInput [formControl]="control" placeholder="Email" />
737
+ <hlm-error>Required</hlm-error>
738
+ </hlm-form-field>
739
+ \`\`\`
685
740
 
686
- ## Integration with Design System
741
+ **Dialog:**
742
+ \`\`\`html
743
+ <hlm-dialog>
744
+ <button brnDialogTrigger hlmBtn>Open</button>
745
+ <hlm-dialog-content *brnDialogContent="let ctx">
746
+ <hlm-dialog-header>
747
+ <h3 hlmDialogTitle>Title</h3>
748
+ </hlm-dialog-header>
749
+ <!-- content -->
750
+ </hlm-dialog-content>
751
+ </hlm-dialog>
752
+ \`\`\`
687
753
 
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
754
+ ### Icons
755
+ \`\`\`typescript
756
+ import { NgIcon, provideIcons } from '@ng-icons/core';
757
+ import { lucideCheck, lucideX } from '@ng-icons/lucide';
693
758
 
694
- ## Remember
759
+ @Component({
760
+ providers: [provideIcons({ lucideCheck, lucideX })],
761
+ template: \`<ng-icon hlm name="lucideCheck" />\`
762
+ })
763
+ \`\`\`
764
+
765
+ ## When to Use MCP
695
766
 
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
767
+ Use MCP only for:
768
+ - **Blocks** (auth, shell, settings) - \`mcp2_search_ui_resources({ query: "auth" })\`
769
+ - **Themes** - \`mcp2_list_available_resources({ category: "themes" })\`
770
+ - **GRG Kit components** (stepper, file-upload) - \`mcp2_search_ui_resources({ query: "stepper" })\`
701
771
 
702
- This workflow ensures you're using GRG Kit to its full potential and providing users with production-ready, consistent code.
772
+ **Do NOT use MCP for Spartan-NG components** - they are already installed!
773
+
774
+ ## Remember
775
+ - Spartan-NG components are pre-installed - just import and use
776
+ - Follow existing patterns in the codebase
777
+ - Use TailwindCSS v4 for styling
778
+ - Prefer signals for state management
703
779
  `;
704
780
  }
705
781