myaidev-method 0.2.22 → 0.2.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/USER_GUIDE.md +453 -48
  2. package/bin/cli.js +18 -0
  3. package/content-rules.example.md +80 -0
  4. package/dist/mcp/mcp-launcher.js +237 -0
  5. package/dist/server/.tsbuildinfo +1 -1
  6. package/dist/server/auth/layers.d.ts +1 -1
  7. package/dist/server/auth/services/AuthService.d.ts +1 -1
  8. package/dist/server/auth/services/TokenService.js.map +1 -1
  9. package/dist/server/auth/services/example.d.ts +5 -5
  10. package/package.json +16 -16
  11. package/src/index.js +21 -8
  12. package/src/lib/update-manager.js +2 -1
  13. package/src/lib/visual-config-utils.js +321 -295
  14. package/src/lib/visual-generation-utils.js +1000 -811
  15. package/src/scripts/configure-wordpress-mcp.js +8 -3
  16. package/src/scripts/generate-visual-cli.js +365 -235
  17. package/src/scripts/ping.js +250 -0
  18. package/src/scripts/wordpress/publish-to-wordpress.js +165 -0
  19. package/src/server/auth/services/TokenService.ts +1 -1
  20. package/src/templates/claude/agents/content-rules-setup.md +657 -0
  21. package/src/templates/claude/agents/content-writer.md +328 -1
  22. package/src/templates/claude/agents/visual-content-generator.md +182 -4
  23. package/src/templates/claude/commands/myai-configure.md +1 -1
  24. package/src/templates/claude/commands/myai-content-rules-setup.md +204 -0
  25. package/src/templates/codex/commands/myai-content-rules-setup.md +85 -0
  26. package/src/templates/gemini/commands/myai-content-rules-setup.toml +57 -0
  27. package/.claude/mcp/sparc-orchestrator-server.js +0 -607
  28. package/.claude/mcp/wordpress-server.js +0 -1277
  29. package/src/agents/content-writer-prompt.md +0 -164
  30. package/src/agents/content-writer.json +0 -70
  31. package/src/templates/claude/mcp_config.json +0 -74
  32. package/src/templates/claude/slash_commands.json +0 -166
  33. package/src/templates/scripts/configure-wordpress-mcp.js +0 -181
@@ -0,0 +1,237 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * MCP Server Launcher Script
5
+ * Manages MCP server lifecycle with proper error handling and configuration
6
+ */
7
+
8
+ import { spawn } from 'child_process';
9
+ import { promises as fs } from 'fs';
10
+ import path from 'path';
11
+ import { fileURLToPath } from 'url';
12
+
13
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
14
+
15
+ class MCPLauncher {
16
+ constructor() {
17
+ this.serverProcess = null;
18
+ this.serverPath = path.resolve(__dirname, '../../.claude/mcp/wordpress-server.js');
19
+ this.isShuttingDown = false;
20
+ }
21
+
22
+ log(message, level = 'info') {
23
+ const timestamp = new Date().toISOString();
24
+ const prefix = {
25
+ info: '🔧',
26
+ success: '✅',
27
+ error: '❌',
28
+ warn: 'âš ī¸'
29
+ }[level] || 'â„šī¸';
30
+
31
+ console.log(`[${timestamp}] ${prefix} ${message}`);
32
+ }
33
+
34
+ async validateEnvironment() {
35
+ this.log('Validating environment configuration...');
36
+
37
+ const required = ['WORDPRESS_URL', 'WORDPRESS_USERNAME', 'WORDPRESS_APP_PASSWORD'];
38
+ const missing = required.filter(key => !process.env[key]);
39
+
40
+ if (missing.length > 0) {
41
+ throw new Error(`Missing required environment variables: ${missing.join(', ')}`);
42
+ }
43
+
44
+ this.log('Environment validation passed', 'success');
45
+ }
46
+
47
+ async validateServerFile() {
48
+ this.log('Checking MCP server file...');
49
+
50
+ try {
51
+ await fs.access(this.serverPath);
52
+ this.log('MCP server file found', 'success');
53
+ } catch (error) {
54
+ throw new Error(`MCP server file not found: ${this.serverPath}`);
55
+ }
56
+ }
57
+
58
+ async startServer() {
59
+ if (this.serverProcess) {
60
+ this.log('Server is already running', 'warn');
61
+ return;
62
+ }
63
+
64
+ this.log('Starting Enhanced WordPress MCP Server...');
65
+
66
+ this.serverProcess = spawn('node', [this.serverPath], {
67
+ stdio: ['inherit', 'pipe', 'pipe'],
68
+ env: process.env
69
+ });
70
+
71
+ // Handle server output
72
+ this.serverProcess.stdout.on('data', (data) => {
73
+ const output = data.toString().trim();
74
+ if (output) {
75
+ console.log(`[SERVER] ${output}`);
76
+ }
77
+ });
78
+
79
+ this.serverProcess.stderr.on('data', (data) => {
80
+ const output = data.toString().trim();
81
+ if (output) {
82
+ if (output.includes('Enhanced WordPress MCP Server') && output.includes('running')) {
83
+ this.log('MCP Server started successfully', 'success');
84
+ this.log(`Server PID: ${this.serverProcess.pid}`);
85
+ this.log('MCP Server is ready to accept connections');
86
+ } else if (output.includes('ERROR') || output.includes('Error')) {
87
+ this.log(`Server error: ${output}`, 'error');
88
+ } else {
89
+ console.log(`[SERVER] ${output}`);
90
+ }
91
+ }
92
+ });
93
+
94
+ // Handle server exit
95
+ this.serverProcess.on('exit', (code, signal) => {
96
+ if (!this.isShuttingDown) {
97
+ if (code === 0) {
98
+ this.log('Server exited gracefully');
99
+ } else {
100
+ this.log(`Server exited with code ${code} (signal: ${signal})`, 'error');
101
+ }
102
+ }
103
+ this.serverProcess = null;
104
+ });
105
+
106
+ this.serverProcess.on('error', (error) => {
107
+ this.log(`Server startup error: ${error.message}`, 'error');
108
+ this.serverProcess = null;
109
+ });
110
+
111
+ // Setup graceful shutdown
112
+ this.setupShutdownHandlers();
113
+ }
114
+
115
+ setupShutdownHandlers() {
116
+ const shutdown = async (signal) => {
117
+ if (this.isShuttingDown) return;
118
+
119
+ this.isShuttingDown = true;
120
+ this.log(`Received ${signal}, shutting down gracefully...`);
121
+
122
+ if (this.serverProcess) {
123
+ this.log('Stopping MCP server...');
124
+ this.serverProcess.kill('SIGTERM');
125
+
126
+ // Force kill after 10 seconds
127
+ setTimeout(() => {
128
+ if (this.serverProcess) {
129
+ this.log('Force killing server...', 'warn');
130
+ this.serverProcess.kill('SIGKILL');
131
+ }
132
+ }, 10000);
133
+
134
+ // Wait for server to exit
135
+ await new Promise((resolve) => {
136
+ if (!this.serverProcess) {
137
+ resolve();
138
+ return;
139
+ }
140
+
141
+ this.serverProcess.on('exit', () => {
142
+ resolve();
143
+ });
144
+ });
145
+ }
146
+
147
+ this.log('Shutdown complete');
148
+ process.exit(0);
149
+ };
150
+
151
+ process.on('SIGINT', () => shutdown('SIGINT'));
152
+ process.on('SIGTERM', () => shutdown('SIGTERM'));
153
+ process.on('SIGHUP', () => shutdown('SIGHUP'));
154
+ }
155
+
156
+ async launch() {
157
+ try {
158
+ this.log('🚀 MyAIDev Method MCP Server Launcher');
159
+ this.log('=====================================');
160
+
161
+ await this.validateEnvironment();
162
+ await this.validateServerFile();
163
+ await this.startServer();
164
+
165
+ // Keep the launcher running
166
+ this.log('Launcher is monitoring server...');
167
+
168
+ } catch (error) {
169
+ this.log(`Launch failed: ${error.message}`, 'error');
170
+ process.exit(1);
171
+ }
172
+ }
173
+
174
+ async status() {
175
+ this.log('MCP Server Status Check');
176
+ this.log('======================');
177
+
178
+ if (this.serverProcess) {
179
+ this.log(`Server is running (PID: ${this.serverProcess.pid})`, 'success');
180
+ this.log(`Server path: ${this.serverPath}`);
181
+ } else {
182
+ this.log('Server is not running', 'warn');
183
+ }
184
+
185
+ // Environment status
186
+ const envVars = ['WORDPRESS_URL', 'WORDPRESS_USERNAME', 'WORDPRESS_APP_PASSWORD'];
187
+ this.log('\nEnvironment variables:');
188
+ envVars.forEach(key => {
189
+ const status = process.env[key] ? '✅' : '❌';
190
+ const value = process.env[key] ? 'configured' : 'missing';
191
+ console.log(` ${status} ${key}: ${value}`);
192
+ });
193
+
194
+ return {
195
+ running: !!this.serverProcess,
196
+ pid: this.serverProcess?.pid,
197
+ serverPath: this.serverPath
198
+ };
199
+ }
200
+ }
201
+
202
+ // CLI interface
203
+ async function main() {
204
+ const launcher = new MCPLauncher();
205
+ const command = process.argv[2] || 'start';
206
+
207
+ switch (command) {
208
+ case 'start':
209
+ await launcher.launch();
210
+ break;
211
+
212
+ case 'status':
213
+ await launcher.status();
214
+ break;
215
+
216
+ case 'health':
217
+ const { default: healthCheck } = await import('./health-check.js');
218
+ await healthCheck();
219
+ break;
220
+
221
+ default:
222
+ console.log('Usage: node mcp-launcher.js [start|status|health]');
223
+ console.log('');
224
+ console.log('Commands:');
225
+ console.log(' start - Start the MCP server (default)');
226
+ console.log(' status - Show server status');
227
+ console.log(' health - Run health check');
228
+ process.exit(1);
229
+ }
230
+ }
231
+
232
+ export { MCPLauncher };
233
+
234
+ // Run if called directly
235
+ if (import.meta.url === `file://${process.argv[1]}`) {
236
+ main().catch(console.error);
237
+ }