Spaces:
Running
Running
| /** | |
| * Setup Script - Initialisiert ein neues Plugin | |
| * Nutzung: node scripts/create-plugin.js my-awesome-plugin | |
| */ | |
| const fs = require('fs') | |
| const path = require('path') | |
| const pluginName = process.argv[2] | |
| if (!pluginName) { | |
| console.error('❌ Fehler: Plugin-Name erforderlich') | |
| console.log('Nutzung: node scripts/create-plugin.js my-plugin-name') | |
| process.exit(1) | |
| } | |
| const pluginDir = path.join(__dirname, '..', 'plugins') | |
| const pluginFile = path.join(pluginDir, `${pluginName}.js`) | |
| if (fs.existsSync(pluginFile)) { | |
| console.error(`❌ Plugin ${pluginName} existiert bereits!`) | |
| process.exit(1) | |
| } | |
| const template = `/** | |
| * Plugin: ${pluginName} | |
| * | |
| * Automatisch generiert am: ${new Date().toISOString()} | |
| * | |
| * Hooks: | |
| * - onPluginInit(context): Beim Plugin-Start | |
| * - onMessageSent(context, data): Wenn Benutzer Nachricht sendet | |
| * - onResponseReceived(context, data): Wenn Response kommt | |
| */ | |
| export function onPluginInit(context) { | |
| context.log('🎉 ${pluginName} plugin initialized!') | |
| // TODO: Plugin-Setup hier | |
| } | |
| export function onMessageSent(context, { message, systemPrompt }) { | |
| context.log(\`📤 Message: \${message.substring(0, 50)}...\`) | |
| // TODO: Message-Handler | |
| } | |
| export function onResponseReceived(context, { content, stats }) { | |
| context.log(\`📥 Response: \${content.substring(0, 50)}...\`) | |
| context.log(\`⏱️ Time: \${stats.time}s\`) | |
| // TODO: Response-Handler | |
| } | |
| ` | |
| fs.writeFileSync(pluginFile, template) | |
| console.log(`✅ Plugin erstellt: ${pluginFile}`) | |
| console.log(`\n🚀 Das Plugin wird automatisch geladen wenn die App startet!`) | |
| console.log(`\n📝 Template-Datei: ${pluginFile}`) | |
| console.log(`\n💡 Tipp: Öffne die Datei und füge deine Logik hinzu!`) | |