3.9 KiB
3.9 KiB
Plugin Directory
Automated plugin registry with PR validation and auto-merge capabilities for the Plugin Host system.
Features
- 🤖 Automated PR Processing: Automatically validates and merges plugin submissions
- ✅ Strict Validation: Enforces plugin schema and ownership rules
- 🔒 Ownership Protection: Users can only remove plugins they authored
- 📡 Webhook Integration: Gitea webhook support for real-time PR handling
- 🔍 Schema Validation: Ensures all plugins meet quality standards
- 📦 REST API: List and query available plugins
Setup
1. Install Dependencies
npm install
2. Configure Environment
Copy .env.example to .env and fill in your Gitea details:
cp .env.example .env
Edit .env:
GITEA_URL=http://synbox.ruv.wtf:8418
GITEA_TOKEN=your_gitea_access_token_here
WEBHOOK_SECRET=your_webhook_secret_here
PORT=3000
3. Configure Gitea Webhook
In your Gitea repository settings:
- Go to Settings → Webhooks → Add Webhook → Gitea
- Set Payload URL:
http://your-server:3000/webhook - Set Secret: (same as WEBHOOK_SECRET in .env)
- Select events:
Pull Request - Save webhook
4. Start Server
npm start
For development with auto-reload:
npm run dev
Plugin Submission Rules
Valid PRs Must:
- ✅ Only modify files in the
plugins/directory - ✅ Only add or remove
.jsonfiles - ✅ Have valid JSON matching the plugin schema
- ✅ Have plugin ID matching the filename
- ✅ Have author field matching PR author (for new plugins)
- ✅ Only remove plugins you authored
Plugin Schema
{
"id": "your-plugin-id",
"name": "Your Plugin Name",
"version": "1.0.0",
"description": "What your plugin does",
"author": "your-gitea-username",
"repository": "http://synbox.ruv.wtf:8418/username/plugin-repo.git",
"downloadUrl": "http://synbox.ruv.wtf:8418/username/plugin-repo/archive/main.zip",
"homepage": "http://synbox.ruv.wtf:8418/username/plugin-repo",
"tags": ["tag1", "tag2"],
"addedDate": "2026-04-17T00:00:00.000Z"
}
Required Fields:
id- Unique identifier (must match filename without .json)name- Display nameversion- Semantic version (X.Y.Z)description- What the plugin doesauthor- Your Gitea usernamerepository- Git repository URL
Optional Fields:
downloadUrl- Direct download linkhomepage- Plugin homepage or docstags- Array of category tagsaddedDate- ISO 8601 date stringdependencies- Required plugins or packages
API Endpoints
List All Plugins
GET /plugins
Response:
{
"plugins": [...],
"count": 10
}
Get Specific Plugin
GET /plugins/:pluginId
Health Check
GET /health
Webhook Endpoint
POST /webhook
How It Works
- User creates a PR adding/removing a plugin JSON file
- Gitea sends webhook to the directory server
- Server validates the PR:
- Checks file locations
- Validates JSON schema
- Verifies ownership for removals
- Ensures author matches PR creator
- If valid: Auto-approves and merges
- If invalid: Comments with error details
Undoing Changes
To undo a merged plugin submission:
- Create a new PR that reverses the change
- To remove a plugin you added: delete the JSON file
- To re-add a plugin you removed: add the JSON file back
The same validation rules apply - you can only remove plugins you authored.
Development
The system consists of:
server.js- Express server and endpointsWebhookHandler.js- Processes Gitea webhooksValidatorEnhanced.js- Validates PR changesplugins/- Plugin registry JSON files
Security
- Webhook signatures are verified using HMAC-SHA256
- Only PR authors can modify their own plugins
- All file operations are restricted to the
plugins/directory - JSON parsing errors are caught and reported
License
MIT