
Product
Introducing Webhook Events for Alert Changes
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.
@silexlabs/grapesjs-ai-copilot
Advanced tools
Turn GrapesJS into a vibe coding experience. grapesjs-ai-copilot watches your edits, understands your intent, and suggests smart actions through an embedded AI assistant β from fixing SEO to making your site more accessible, responsive, and efficient.
Turn GrapesJS into a vibe coding experience. @silexlabs/grapesjs-ai-copilot watches your edits, understands your intent, and suggests smart actions through an embedded AI assistant β from fixing SEO to making your site more accessible, responsive, and efficient.
This code is part of a bigger project: about Silex v3
ONLINE DEMO (requires an OpenAI API key)
npm install @silexlabs/grapesjs-ai-copilot
<link href="https://unpkg.com/grapesjs/dist/css/grapes.min.css" rel="stylesheet">
<script src="https://unpkg.com/grapesjs"></script>
<script src="https://unpkg.com/@silexlabs/grapesjs-ai-copilot"></script>
<div id="gjs"></div>
const editor = grapesjs.init({
container: '#gjs',
height: '100vh',
plugins: ['@silexlabs/grapesjs-ai-copilot'],
pluginsOpts: {
'@silexlabs/grapesjs-ai-copilot': {
// OpenAI Configuration
aiProvider: 'openai',
apiKey: 'sk-proj-...', // Your OpenAI API key
model: 'gpt-4o', // Optional
// OR Claude Configuration
// aiProvider: 'claude',
// apiKey: 'sk-ant-api03-...',
// model: 'claude-3-5-sonnet-20241022',
updateInterval: 10000, // 10 seconds
minChangesThreshold: 3
}
}
});
import grapesjs from 'grapesjs';
import aiCopilot from '@silexlabs/grapesjs-ai-copilot';
import 'grapesjs/dist/css/grapes.min.css';
const editor = grapesjs.init({
container: '#gjs',
plugins: [aiCopilot],
pluginsOpts: {
'@silexlabs/grapesjs-ai-copilot': {
aiProvider: 'openai', // or 'claude'
apiKey: process.env.OPENAI_API_KEY, // or ANTHROPIC_API_KEY
model: 'gpt-4o', // Optional
updateInterval: 15000,
minChangesThreshold: 2
}
}
});
| Option | Type | Description | Default |
|---|---|---|---|
aiProvider | string | AI provider: 'claude' or 'openai' | 'claude' |
apiKey | string | API key for chosen provider (required) | null |
model | string | Specific model to use (uses provider default if null) | null |
maxTokens | number | Maximum tokens for AI response | 2000 |
updateInterval | number | Analysis interval in milliseconds | 20000 |
minChangesThreshold | number | Minimum changes before analysis | 5 |
customPrompt | string | Custom prompt template (optional) | null |
promptUrl | string | URL to load prompt from (optional) | null |
containerElement | HTMLElement | HTML element to insert the AI interface | null |
containerSelector | string | CSS selector for container element | null |
You can also set your API key via environment variables:
# For OpenAI
export OPENAI_API_KEY=sk-proj-your-key-here
# For Claude/Anthropic
export ANTHROPIC_API_KEY=sk-ant-api03-your-key-here
The AI Copilot supports custom prompts to tailor the assistant's behavior to your specific needs.
const editor = grapesjs.init({
plugins: ['@silexlabs/grapesjs-ai-copilot'],
pluginsOpts: {
'@silexlabs/grapesjs-ai-copilot': {
// Option 1: Direct custom prompt
customPrompt: `You are a specialized SEO assistant.
Focus only on SEO improvements and suggestions.
Current state: {{html}}
Selected: {{selectedComponent}}
Create an SEO audit interface with window.editor actions.`,
// Option 2: Load prompt from URL
promptUrl: 'https://my-site.com/prompts/seo-focused.txt',
aiProvider: 'openai',
apiKey: 'your-key'
}
}
});
Your custom prompts can use these template variables:
{{html}} - Current page HTML{{css}} - Current page CSS{{componentCount}} - Number of components{{canUndo}} - Whether undo is available{{canRedo}} - Whether redo is available{{selectedComponent}} - Currently selected element details{{consoleMessages}} - Console logs from AI interface{{recentCommands}} - Command history for pattern detectionThe plugin includes several pre-built prompts for different use cases:
// Get the AI Copilot instance
const copilot = editor.plugins.get('@silexlabs/grapesjs-ai-copilot').aiCopilot();
// Update prompt configuration
copilot.updatePromptConfig({
customPrompt: 'New prompt content...'
});
// Or load from URL
copilot.updatePromptConfig({
promptUrl: 'https://example.com/new-prompt.txt'
});
// Reload current prompt
await copilot.reloadPrompt();
The AI Copilot analyzes your website and provides suggestions in these categories:
The AI Copilot appears as a panel in the GrapesJS interface with:
Clone and setup:
git clone https://github.com/silexlabs/grapesjs-ai-copilot.git
cd grapesjs-ai-copilot
npm install
Development server:
npm start
Build for production:
npm run build
Simply type what you want in the input field:
"make the header red"
"add a responsive navigation menu"
"center all the text on mobile"
"add alt text to all images"
"create a hero section with a call-to-action button"
The AI will:
When something doesn't work:
User: "make all text blue"
AI: Executes code... (fails due to selector issue)
User: Clicks "Didn't work"
AI: "I see the selector failed. Let me try a different approach using component iteration instead..."
The AI generates comprehensive console.log statements:
// Generated code includes debugging
console.log('=== Starting device selection ===');
editor.Devices.select('Desktop');
console.log('β
Device selected successfully');
console.log('=== Finding components ===');
const components = editor.getWrapper().find('text');
console.log(`Found ${components.length} text components`);
components.forEach((comp, index) => {
console.log(`Processing component ${index + 1}/${components.length}`);
comp.addStyle({ color: 'blue' });
console.log(`β
Applied blue color to component ${index + 1}`);
});
// User types in the AI interface:
"make the navigation responsive"
// AI automatically:
// 1. Analyzes current navigation structure
// 2. Generates responsive JavaScript code
// 3. Executes the code immediately
// 4. Shows success metrics and debugging logs
// After you edit components, AI suggests:
"I notice you added several images without alt text.
Would you like me to add descriptive alt attributes?"
// Click "Apply" to accept the suggestion
// If AI code fails:
User: Clicks "Didn't work"
AI: "The previous CSS selector failed. Let me try using
component iteration instead of CSS selectors."
// AI tries a completely different approach
Contributions are welcome! Please feel free to submit a Pull Request.
AGPL Β© silexlabs
minChangesThreshold for more frequent suggestionsupdateInterval to reduce API usageHappy vibe coding! π
FAQs
Turn GrapesJS into a vibe coding experience. grapesjs-ai-copilot watches your edits, understands your intent, and suggests smart actions through an embedded AI assistant β from fixing SEO to making your site more accessible, responsive, and efficient.
The npm package @silexlabs/grapesjs-ai-copilot receives a total of 21 weekly downloads. As such, @silexlabs/grapesjs-ai-copilot popularity was classified as not popular.
We found that @silexlabs/grapesjs-ai-copilot demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.Β It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.

Security News
ENISA has become a CVE Program Root, giving the EU a central authority for coordinating vulnerability reporting, disclosure, and cross-border response.

Product
Socket now scans OpenVSX extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.