| name | plugin-dev |
| description | Comprehensive plugin development toolkit for creating, testing, and managing plugins across multiple platforms with scaffolding, validation, and deployment utilities. |
| license | MIT |
Plugin Development Toolkit
Overview
Complete development environment for creating plugins across different platforms including OpenCode, VS Code, Chrome, WordPress, and more. Provides scaffolding, testing, validation, and deployment utilities.
Quick Start
Installation
npm install -g @plugin-dev/cli
npx @plugin-dev/cli create my-plugin
Create New Plugin
plugin-dev create
plugin-dev create --type=opencode --name=my-awesome-plugin
plugin-dev create --type=vscode --name=my-extension
plugin-dev create --type=chrome --name=my-browser-extension
Plugin Types
OpenCode Plugins
plugin-dev create opencode my-plugin --template=skill
my-plugin/
├── package.json
├── README.md
├── index.js
├── tests/
│ └── plugin.test.js
└── docs/
└── api.md
OpenCode Plugin Template
module.exports = {
name: 'my-plugin',
version: '1.0.0',
description: 'My awesome OpenCode plugin',
type: 'skill',
async initialize() {
console.log('Plugin initialized');
},
async execute(input) {
return {
success: true,
result: 'Plugin executed successfully'
};
}
};
VS Code Extensions
plugin-dev create vscode my-extension --template=language-support
my-extension/
├── package.json
├── extension.js
├── syntaxes/
├── snippets/
└── resources/
VS Code Extension Template
const vscode = require('vscode');
function activate(context) {
let disposable = vscode.commands.registerCommand(
'extension.helloWorld',
function () {
vscode.window.showInformationMessage('Hello World!');
}
);
context.subscriptions.push(disposable);
}
function deactivate() {}
module.exports = { activate, deactivate };
Chrome Extensions
plugin-dev create chrome my-extension --template=action
my-extension/
├── manifest.json
├── popup.html
├── content.js
├── background.js
└── icons/
Chrome Extension Template
chrome.runtime.onInstalled.addListener(() => {
chrome.contextMenus.create({
id: 'myExtension',
title: 'My Extension Action',
contexts: ['selection']
});
});
chrome.contextMenus.onClicked.addListener((info, tab) => {
if (info.menuItemId === 'myExtension') {
}
});
Development Tools
Local Development Server
plugin-dev dev --port=3000 --watch
plugin-dev dev --platform=opencode
plugin-dev dev --platform=vscode --debug
Testing Framework
plugin-dev test
plugin-dev test --unit
plugin-dev test --integration
plugin-dev test --e2e
plugin-dev test --coverage --threshold=80
Test Examples
const { PluginTester } = require('@plugin-dev/testing');
describe('MyPlugin', () => {
let tester;
beforeEach(() => {
tester = new PluginTester('./index.js');
});
test('should initialize correctly', async () => {
const plugin = await tester.load();
expect(plugin.name).toBe('my-plugin');
});
test('should execute successfully', async () => {
const result = await tester.execute({ input: 'test' });
expect(result.success).toBe(true);
});
});
Validation & Linting
plugin-dev validate
plugin-dev lint --fix
plugin-dev type-check
plugin-dev audit --security
Plugin Configuration
package.json Configuration
{
"name": "my-plugin",
"version": "1.0.0",
"description": "My awesome plugin",
"main": "index.js",
"type": "opencode-skill",
"opencode": {
"category": "utility",
"tags": ["automation", "productivity"],
"permissions": ["file-read", "network"],
"dependencies": ["node-fetch", "lodash"]
},
"scripts": {
"dev": "plugin-dev dev",
"test": "plugin-dev test",
"build": "plugin-dev build",
"publish": "plugin-dev publish"
},
"devDependencies": {
"@plugin-dev/testing": "^1.0.0",
"@plugin-dev/linter": "^1.0.0"
}
}
Plugin Configuration File
module.exports = {
name: 'my-plugin',
type: 'opencode-skill',
metadata: {
author: 'Your Name',
license: 'MIT',
repository: 'https://github.com/username/my-plugin',
keywords: ['plugin', 'automation', 'utility']
},
runtime: {
timeout: 30000,
memory: '512MB',
permissions: ['file-read', 'network']
},
development: {
port: 3000,
hotReload: true,
debugMode: true
},
build: {
target: 'node',
minify: true,
bundle: true,
output: './dist'
}
};
Advanced Features
Plugin Hooks
module.exports = {
name: 'my-plugin',
async beforeInitialize() {
console.log('About to initialize...');
},
async initialize() {
},
async beforeExecute(input) {
console.log('About to execute with:', input);
return input;
},
async execute(input) {
return { success: true, result: 'done' };
},
async afterExecute(result) {
console.log('Execution result:', result);
return result;
},
async beforeDestroy() {
console.log('About to destroy plugin...');
},
async destroy() {
}
};
Plugin Communication
const { PluginBus } = require('@plugin-dev/communication');
PluginBus.on('user:login', (user) => {
console.log('User logged in:', user.id);
});
PluginBus.emit('plugin:ready', {
plugin: 'my-plugin',
version: '1.0.0'
});
const otherPlugin = PluginBus.getPlugin('other-plugin');
const response = await otherPlugin.sendMessage('process', { data: 'test' });
Plugin Storage
const { PluginStorage } = require('@plugin-dev/storage');
const localStore = new PluginStorage('local');
await localStore.set('config', { theme: 'dark' });
const config = await localStore.get('config');
const cloudStore = new PluginStorage('cloud', {
provider: 'aws',
bucket: 'my-plugin-storage'
});
await cloudStore.set('user-data', userData);
Platform Integration
OpenCode Integration
const { OpenCodeAPI } = require('@plugin-dev/platforms');
const opencode = new OpenCodeAPI();
opencode.registerCommand('my-plugin.action', () => {
console.log('Action executed');
});
const fileSystem = opencode.getService('filesystem');
const editor = opencode.getService('editor');
const terminal = opencode.getService('terminal');
VS Code Integration
const vscode = require('vscode');
vscode.commands.registerCommand('my-plugin.hello', () => {
vscode.window.showInformationMessage('Hello from my plugin!');
});
const provider = vscode.languages.registerCompletionItemProvider(
'javascript',
{
provideCompletionItems(document, position) {
}
}
);
Chrome Integration
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
if (request.action === 'getData') {
sendResponse({ data: 'result' });
}
});
chrome.storage.local.set({ key: 'value' });
chrome.storage.local.get(['key'], (result) => {
console.log(result.key);
});
Build & Deployment
Build Process
plugin-dev build --target=production
plugin-dev build --platform=opencode
plugin-dev build --platform=vscode --minify
plugin-dev build --config=custom.build.js
Build Configuration
module.exports = {
entry: './index.js',
output: {
path: './dist',
filename: 'bundle.js'
},
plugins: [
new MinifyPlugin(),
new BundleAnalyzerPlugin()
],
optimization: {
minimize: true,
splitChunks: true
},
platform: {
opencode: {
target: 'node',
externals: ['fs', 'path']
},
vscode: {
target: 'node',
includeVSCodeAPI: true
},
chrome: {
target: 'browser',
polyfills: ['Promise', 'Object.assign']
}
}
};
Deployment
plugin-dev publish --registry=opencode
plugin-dev publish --registry=vscode-marketplace
plugin-dev publish --registry=chrome-webstore
plugin-dev deploy --config=deploy.config.js --env=production
Deployment Configuration
module.exports = {
environments: {
development: {
registry: 'opencode-staging',
version: '1.0.0-dev'
},
production: {
registry: 'opencode',
version: '1.0.0',
changelog: './CHANGELOG.md'
}
},
beforeDeploy: async () => {
console.log('Running pre-deployment checks...');
await runTests();
await validatePlugin();
},
afterDeploy: async (result) => {
console.log('Deployment completed:', result.url);
await notifyTeam(result);
}
};
Testing
Unit Testing
const { expect } = require('chai');
const plugin = require('../../index.js');
describe('Plugin Unit Tests', () => {
test('should have correct name', () => {
expect(plugin.name).toBe('my-plugin');
});
test('should initialize correctly', async () => {
await plugin.initialize();
expect(plugin.initialized).toBe(true);
});
});
Integration Testing
const { PluginTester } = require('@plugin-dev/testing');
describe('Plugin Integration Tests', () => {
let tester;
beforeEach(async () => {
tester = new PluginTester();
await tester.start();
});
afterEach(async () => {
await tester.stop();
});
test('should handle API requests', async () => {
const response = await tester.request('/api/process', {
method: 'POST',
body: { data: 'test' }
});
expect(response.status).toBe(200);
expect(response.body.success).toBe(true);
});
});
E2E Testing
const { E2ETester } = require('@plugin-dev/testing');
describe('Plugin E2E Tests', () => {
let tester;
beforeAll(async () => {
tester = new E2ETester({
browser: 'chrome',
headless: true
});
await tester.setup();
});
afterAll(async () => {
await tester.cleanup();
});
test('should complete full workflow', async () => {
await tester.navigateTo('/plugin');
await tester.click('#start-button');
await tester.waitFor('#result');
const result = await tester.getText('#result');
expect(result).toContain('success');
});
});
Debugging
Debug Mode
plugin-dev dev --debug --port=9229
plugin-dev dev --debugger=vscode
plugin-dev dev --debugger=chrome
Logging
const { PluginLogger } = require('@plugin-dev/logger');
const logger = new PluginLogger({
level: 'debug',
format: 'json',
outputs: ['console', 'file']
});
logger.debug('Debug message');
logger.info('Info message');
logger.warn('Warning message');
logger.error('Error message');
Performance Monitoring
Metrics Collection
const { PluginMonitor } = require('@plugin-dev/monitoring');
const monitor = new PluginMonitor({
interval: 60000,
metrics: ['cpu', 'memory', 'latency', 'throughput']
});
monitor.addMetric('custom-metric', () => {
return calculateCustomMetric();
});
Performance Optimization
plugin-dev analyze --performance
plugin-dev optimize --bundle
plugin-dev profile --memory --duration=300000
Security
Security Scanning
plugin-dev audit --security
plugin-dev audit --dependencies
plugin-dev audit --code --rules=owasp-top-ten
Secure Development Practices
const { SecurityUtils } = require('@plugin-dev/security');
function sanitizeInput(input) {
return SecurityUtils.sanitize(input, {
allowedTags: ['b', 'i', 'em'],
allowedAttributes: ['class'],
maxLength: 1000
});
}
const secureApi = SecurityUtils.createSecureApi({
timeout: 30000,
retries: 3,
validateSSL: true
});
Contributing
- Fork the repository
- Create feature branch
- Add tests
- Ensure all checks pass
- Submit pull request
License
MIT License - see LICENSE file for details.