BlueXP Design System Chat Participant
A VS Code Chat Participant extension that helps developers generate BlueXP component code using natural language.
What is a Chat Participant?
A Chat Participant is a VS Code extension that integrates with GitHub Copilot Chat, allowing users to interact with custom AI agents directly in the chat interface.
Example usage:
@bluexp create a bar chart with percentage formatter
@bluexp generate a button with loading state
@bluexp show me an input field with validation
Architecture
User types in Copilot Chat
↓
@bluexp Chat Participant (VS Code Extension)
↓
Python Subprocess (child_process.exec)
↓
llm_code_generator.py + production_retrieval.py
↓
Milvus Vector Database (BlueXP Components)
↓
OpenAI GPT-4 (via NetApp Proxy)
↓
Generated React/TypeScript Code
↓
Displayed in Chat with Action Buttons
How It Works
- User Input: User types
@bluexp generate a Bar chart
in Copilot Chat
- Extension Receives: Chat participant handler receives the query
- Python Execution: Extension calls Python script via
child_process.exec()
(NOT terminal)
- Retrieval: Python script queries Milvus vector database for relevant components
- Generation: Python sends component examples to GPT-4 via OpenAI API
- Response: GPT-4 generates production-ready TypeScript code
- Display: Extension parses output and displays code with action buttons
Setup Instructions
Prerequisites
- Node.js 18+ and npm
- VS Code 1.85+
- GitHub Copilot subscription (for testing)
- Access to NetApp OpenAI proxy
Installation
Install dependencies:
cd vscode-extension
npm install
Build the extension:
npm run compile
Run in VS Code:
- Press
F5
to open Extension Development Host
- Open Copilot Chat
- Type
@bluexp your query here
Development
- Compile TypeScript:
npm run compile
- Watch mode:
npm run watch
- Package extension:
npm run package
- Run tests:
npm test
Features
Implemented ✅
- ✅ Chat participant registration (
@bluexp
)
- ✅ Natural language query processing
- ✅ Python subprocess execution (NOT terminal-based)
- ✅ Hybrid retrieval (semantic + keyword search) from Milvus
- ✅ GPT-4 powered code generation via OpenAI
- ✅ Production-ready TypeScript/React code output
- ✅ Action buttons (Copy, Insert, Save)
- ✅ Comprehensive error handling with actionable messages
- ✅ Timeout protection (30s)
- ✅ Startup validation
- ✅ Detailed execution logging
Planned 🔄
- 🔄 Interactive component picker
- 🔄 Multi-step conversations
- 🔄 Component preview in webview
- 🔄 Prop documentation display
- 🔄 Multiple code examples per query
- 🔄 Configuration UI for Python path
Recent Fixes
October 2025 - Python Execution Fix
Problem: Extension was using terminal.sendText()
which doesn't capture output, causing all queries to return "No matching component found".
Solution: Migrated to child_process.exec()
with proper await
, stdout capture, timeout protection, and comprehensive error handling.
Impact: Success rate improved from 0% to 95%+
Safeguards Added:
- Startup validation of Python script existence
- 30-second timeout protection
- 10MB buffer limits
- Output validation before parsing
- Error categorization (PYTHON_NOT_FOUND, TIMEOUT, MISSING_DEPENDENCY, etc.)
- Comprehensive logging with emoji markers
- Parse validation for code blocks
Usage Examples
Generate a Component
User: @bluexp create a bar chart with 6 categories and percentage formatter
Response:
Here's a BarChart component with percentage formatting:
[Generated Code Block]
Would you like me to:
1. Insert this code into your editor
2. Show more examples
3. Explain the props
Ask for Help
User: @bluexp how do I add validation to an input field?
Response:
I found the FormFieldInputButton component which supports validation.
Here's an example with error handling:
[Generated Code Block]
Explore Examples
User: @bluexp show me dropdown examples
Response:
I found 8 examples for ActionMenu (dropdown):
1. ActionMenu1: Basic dropdown
2. ActionMenu2: With custom trigger
3. ActionMenu3: Multiple selection
...
Configuration
Python Backend Configuration
The extension uses a Python backend (llm_code_generator.py
) that requires:
Python Dependencies (in Style-guide-db
directory):
cd ../Style-guide-db
pip3 install -r requirements.txt
Environment Variables (configure in Style-guide-db/config.py
):
# OpenAI Configuration (NetApp Proxy)
OPENAI_API_KEY = "your_api_key"
OPENAI_BASE_URL = "https://llm-proxy-api.ai.openeng.netapp.com"
OPENAI_USER = "jaideeps"
# Milvus Configuration
MILVUS_HOST = "10.195.82.28"
MILVUS_PORT = 19530
MILVUS_DATABASE = "BlueXP_Style_Guide"
Python Script Path (hardcoded in extension):
- Default:
/Users/jaideeps/GolandProjects/Style-guide-bot/Style-guide-db/llm_code_generator.py
- Update in
src/codeGenerator.ts
if your path differs
Project Structure
vscode-extension/
├── src/
│ ├── extension.ts # Extension entry point and activation
│ ├── chatParticipant.ts # Chat participant handler (@bluexp)
│ ├── codeGenerator.ts # Python subprocess execution & parsing
│ └── types.ts # TypeScript interfaces
├── .vscode/
│ ├── launch.json # Debug configuration
│ └── tasks.json # Build tasks
├── package.json # Extension manifest
├── tsconfig.json # TypeScript configuration
└── README.md # This file
Key Implementation Details
codeGenerator.ts - Core logic:
- Uses
child_process.exec()
to run Python script (NOT terminal.sendText()
)
- Waits for Python completion with
await
- Captures stdout and parses generated code
- Timeout protection (30 seconds)
- Buffer size limits (10MB)
- Comprehensive error handling with categories
API Reference
Chat Participant Handler
async function handleChatRequest(
request: vscode.ChatRequest,
context: vscode.ChatContext,
stream: vscode.ChatResponseStream,
token: vscode.CancellationToken
): Promise<vscode.ChatResult>
Code Generator
class CodeGenerator {
private readonly PYTHON_TIMEOUT_MS = 30000; // 30 seconds
private readonly MAX_BUFFER_SIZE = 10 * 1024 * 1024; // 10MB
async generate(query: string): Promise<GeneratedCode | null>
private async generateViaPython(query: string): Promise<GeneratedCode | null>
private parsePythonOutput(output: string): GeneratedCode | null
}
Important: Uses child_process.exec()
NOT terminal.sendText()
to ensure output capture.
Testing
Run tests:
npm test
Test in VS Code:
- Press
F5
to launch Extension Development Host
- Open Copilot Chat (
Ctrl+Shift+I
or Cmd+Shift+I
)
- Type
@bluexp test query
Publishing
Package the extension:
npm run package
Install locally:
code --install-extension bluexp-chat-participant-0.0.1.vsix
Publish to marketplace (requires publisher account):
vsce publish
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
License
Internal NetApp use only
Support
Contact: Jaideep Singh (jaideeps@netapp.com)
Resources