myaidev-method 0.0.7 → 0.1.0
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.
- package/.claude/CLAUDE.md +52 -0
- package/.claude/agents/content-writer.md +155 -0
- package/.claude/commands/myai-configure.md +44 -0
- package/.claude/commands/myai-content-writer.md +78 -0
- package/.claude/commands/myai-wordpress-publish.md +120 -0
- package/.claude/mcp/gutenberg-converter.js +447 -0
- package/.claude/mcp/mcp-config.json +101 -0
- package/.claude/mcp/wordpress-server-simple.js +182 -0
- package/.claude/mcp/wordpress-server.js +1277 -0
- package/.claude/settings.local.json +12 -0
- package/COOLIFY_DEPLOYMENT.md +750 -0
- package/README.md +6 -6
- package/WORDPRESS_ADMIN_SCRIPTS.md +474 -0
- package/bin/cli.js +17 -22
- package/dist/mcp/gutenberg-converter.js +447 -0
- package/dist/mcp/mcp-config.json +101 -0
- package/dist/mcp/wordpress-server-simple.js +182 -0
- package/dist/mcp/wordpress-server.js +1277 -0
- package/package.json +29 -5
- package/src/lib/coolify-utils.js +380 -0
- package/src/lib/report-synthesizer.js +504 -0
- package/src/lib/wordpress-admin-utils.js +703 -0
- package/src/mcp/health-check.js +190 -0
- package/src/mcp/mcp-launcher.js +237 -0
- package/src/scripts/coolify-deploy-app.js +287 -0
- package/src/scripts/coolify-list-resources.js +199 -0
- package/src/scripts/coolify-status.js +97 -0
- package/src/scripts/test-coolify-deploy.js +47 -0
- package/src/scripts/wordpress-comprehensive-report.js +325 -0
- package/src/scripts/wordpress-health-check.js +175 -0
- package/src/scripts/wordpress-performance-check.js +461 -0
- package/src/scripts/wordpress-security-scan.js +221 -0
- package/src/templates/claude/agents/coolify-deploy.md +563 -0
- package/src/templates/claude/agents/wordpress-admin.md +228 -271
- package/src/templates/claude/commands/myai-configure.md +10 -74
- package/src/templates/claude/commands/myai-coolify-deploy.md +172 -0
- package/src/templates/claude/commands/myai-wordpress-publish.md +16 -8
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Coolify Resource Listing Script
|
|
5
|
+
* List servers, projects, applications, databases, or services
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { CoolifyUtils } from '../lib/coolify-utils.js';
|
|
9
|
+
|
|
10
|
+
const args = process.argv.slice(2);
|
|
11
|
+
|
|
12
|
+
const options = {
|
|
13
|
+
type: null,
|
|
14
|
+
json: args.includes('--json'),
|
|
15
|
+
detailed: args.includes('--detailed') || args.includes('-d')
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// Parse type argument
|
|
19
|
+
for (let i = 0; i < args.length; i++) {
|
|
20
|
+
if (args[i] === '--type' && args[i + 1]) {
|
|
21
|
+
options.type = args[i + 1];
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (!options.type || args.includes('--help') || args.includes('-h')) {
|
|
26
|
+
console.log(`
|
|
27
|
+
Usage: coolify-list-resources --type <resource-type> [options]
|
|
28
|
+
|
|
29
|
+
Resource Types:
|
|
30
|
+
servers List all servers
|
|
31
|
+
projects List all projects
|
|
32
|
+
applications List all applications
|
|
33
|
+
databases List all databases
|
|
34
|
+
services List all services
|
|
35
|
+
all List all resources
|
|
36
|
+
|
|
37
|
+
Options:
|
|
38
|
+
--json Output in JSON format
|
|
39
|
+
--detailed Show detailed information
|
|
40
|
+
-d Alias for --detailed
|
|
41
|
+
--help Show this help
|
|
42
|
+
-h Alias for --help
|
|
43
|
+
|
|
44
|
+
Examples:
|
|
45
|
+
node src/scripts/coolify-list-resources.js --type servers
|
|
46
|
+
node src/scripts/coolify-list-resources.js --type applications --detailed
|
|
47
|
+
node src/scripts/coolify-list-resources.js --type all --json
|
|
48
|
+
`);
|
|
49
|
+
process.exit(0);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async function listResources() {
|
|
53
|
+
try {
|
|
54
|
+
const coolify = new CoolifyUtils();
|
|
55
|
+
let data = {};
|
|
56
|
+
|
|
57
|
+
switch (options.type) {
|
|
58
|
+
case 'servers':
|
|
59
|
+
data.servers = await coolify.listServers();
|
|
60
|
+
break;
|
|
61
|
+
case 'projects':
|
|
62
|
+
data.projects = await coolify.listProjects();
|
|
63
|
+
break;
|
|
64
|
+
case 'applications':
|
|
65
|
+
data.applications = await coolify.listApplications();
|
|
66
|
+
break;
|
|
67
|
+
case 'databases':
|
|
68
|
+
data.databases = await coolify.listDatabases();
|
|
69
|
+
break;
|
|
70
|
+
case 'services':
|
|
71
|
+
data.services = await coolify.listServices();
|
|
72
|
+
break;
|
|
73
|
+
case 'all':
|
|
74
|
+
[data.servers, data.projects, data.applications, data.databases, data.services] = await Promise.all([
|
|
75
|
+
coolify.listServers(),
|
|
76
|
+
coolify.listProjects(),
|
|
77
|
+
coolify.listApplications(),
|
|
78
|
+
coolify.listDatabases(),
|
|
79
|
+
coolify.listServices()
|
|
80
|
+
]);
|
|
81
|
+
break;
|
|
82
|
+
default:
|
|
83
|
+
console.error(`Unknown resource type: ${options.type}`);
|
|
84
|
+
process.exit(1);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (options.json) {
|
|
88
|
+
console.log(JSON.stringify(data, null, 2));
|
|
89
|
+
process.exit(0);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Format output
|
|
93
|
+
console.log('Coolify Resources');
|
|
94
|
+
console.log('='.repeat(60));
|
|
95
|
+
|
|
96
|
+
if (data.servers) {
|
|
97
|
+
console.log('\nServers:');
|
|
98
|
+
console.log('-'.repeat(60));
|
|
99
|
+
if (data.servers.length === 0) {
|
|
100
|
+
console.log(' No servers found');
|
|
101
|
+
} else {
|
|
102
|
+
coolify.formatServerList(data.servers).forEach(s => {
|
|
103
|
+
console.log(` ${s.name}`);
|
|
104
|
+
if (options.detailed) {
|
|
105
|
+
console.log(` UUID: ${s.uuid}`);
|
|
106
|
+
console.log(` IP: ${s.ip}`);
|
|
107
|
+
console.log(` Status: ${s.status}`);
|
|
108
|
+
console.log(` Usable: ${s.usable}`);
|
|
109
|
+
console.log(` Description: ${s.description}`);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (data.projects) {
|
|
116
|
+
console.log('\nProjects:');
|
|
117
|
+
console.log('-'.repeat(60));
|
|
118
|
+
if (data.projects.length === 0) {
|
|
119
|
+
console.log(' No projects found');
|
|
120
|
+
} else {
|
|
121
|
+
data.projects.forEach(p => {
|
|
122
|
+
console.log(` ${p.name}`);
|
|
123
|
+
if (options.detailed) {
|
|
124
|
+
console.log(` UUID: ${p.uuid}`);
|
|
125
|
+
console.log(` ID: ${p.id}`);
|
|
126
|
+
console.log(` Description: ${p.description || 'No description'}`);
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (data.applications) {
|
|
133
|
+
console.log('\nApplications:');
|
|
134
|
+
console.log('-'.repeat(60));
|
|
135
|
+
if (data.applications.length === 0) {
|
|
136
|
+
console.log(' No applications found');
|
|
137
|
+
} else {
|
|
138
|
+
coolify.formatApplicationList(data.applications).forEach(a => {
|
|
139
|
+
console.log(` ${a.name}`);
|
|
140
|
+
if (options.detailed) {
|
|
141
|
+
console.log(` UUID: ${a.uuid}`);
|
|
142
|
+
console.log(` Status: ${a.status}`);
|
|
143
|
+
console.log(` URL: ${a.url}`);
|
|
144
|
+
console.log(` Project: ${a.project}`);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (data.databases) {
|
|
151
|
+
console.log('\nDatabases:');
|
|
152
|
+
console.log('-'.repeat(60));
|
|
153
|
+
if (data.databases.length === 0) {
|
|
154
|
+
console.log(' No databases found');
|
|
155
|
+
} else {
|
|
156
|
+
data.databases.forEach(db => {
|
|
157
|
+
console.log(` ${db.name}`);
|
|
158
|
+
if (options.detailed) {
|
|
159
|
+
console.log(` UUID: ${db.uuid}`);
|
|
160
|
+
console.log(` Type: ${db.type}`);
|
|
161
|
+
console.log(` Status: ${db.status || 'Unknown'}`);
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (data.services) {
|
|
168
|
+
console.log('\nServices:');
|
|
169
|
+
console.log('-'.repeat(60));
|
|
170
|
+
if (data.services.length === 0) {
|
|
171
|
+
console.log(' No services found');
|
|
172
|
+
} else {
|
|
173
|
+
data.services.forEach(svc => {
|
|
174
|
+
console.log(` ${svc.name}`);
|
|
175
|
+
if (options.detailed) {
|
|
176
|
+
console.log(` UUID: ${svc.uuid}`);
|
|
177
|
+
console.log(` Status: ${svc.status || 'Unknown'}`);
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
console.log('\n' + '='.repeat(60));
|
|
184
|
+
process.exit(0);
|
|
185
|
+
} catch (error) {
|
|
186
|
+
if (options.json) {
|
|
187
|
+
console.log(JSON.stringify({ success: false, error: error.message }, null, 2));
|
|
188
|
+
} else {
|
|
189
|
+
console.error(`Error: ${error.message}`);
|
|
190
|
+
}
|
|
191
|
+
process.exit(1);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
196
|
+
listResources();
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export { listResources };
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Coolify Status Check Script
|
|
5
|
+
* Verify Coolify API connectivity and system status
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { CoolifyUtils } from '../lib/coolify-utils.js';
|
|
9
|
+
|
|
10
|
+
const args = process.argv.slice(2);
|
|
11
|
+
const options = {
|
|
12
|
+
comprehensive: args.includes('--comprehensive') || args.includes('-c'),
|
|
13
|
+
json: args.includes('--json'),
|
|
14
|
+
verbose: args.includes('--verbose') || args.includes('-v')
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
async function checkStatus() {
|
|
18
|
+
try {
|
|
19
|
+
if (options.verbose) {
|
|
20
|
+
console.error('Connecting to Coolify...');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const coolify = new CoolifyUtils();
|
|
24
|
+
const status = await coolify.getSystemStatus();
|
|
25
|
+
|
|
26
|
+
if (options.json) {
|
|
27
|
+
console.log(JSON.stringify(status, null, 2));
|
|
28
|
+
process.exit(0);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
console.log('Coolify Status Report');
|
|
32
|
+
console.log('='.repeat(60));
|
|
33
|
+
console.log(`Health: ${status.healthy ? '✓ Healthy' : '✗ Unhealthy'}`);
|
|
34
|
+
console.log('');
|
|
35
|
+
console.log('Servers:');
|
|
36
|
+
console.log(` Total: ${status.servers.total}`);
|
|
37
|
+
console.log(` Reachable: ${status.servers.reachable}`);
|
|
38
|
+
console.log(` Usable: ${status.servers.usable}`);
|
|
39
|
+
console.log('');
|
|
40
|
+
console.log(`Projects: ${status.projects.total}`);
|
|
41
|
+
console.log(`Applications: ${status.applications.total}`);
|
|
42
|
+
console.log('');
|
|
43
|
+
|
|
44
|
+
if (options.comprehensive) {
|
|
45
|
+
const [servers, projects, apps] = await Promise.all([
|
|
46
|
+
coolify.listServers(),
|
|
47
|
+
coolify.listProjects(),
|
|
48
|
+
coolify.listApplications()
|
|
49
|
+
]);
|
|
50
|
+
|
|
51
|
+
console.log('Detailed Server Information:');
|
|
52
|
+
console.log('-'.repeat(60));
|
|
53
|
+
servers.forEach(server => {
|
|
54
|
+
console.log(` ${server.name} (${server.ip})`);
|
|
55
|
+
console.log(` UUID: ${server.uuid}`);
|
|
56
|
+
console.log(` Status: ${server.is_reachable ? '✓' : '✗'} Reachable, ${server.is_usable ? '✓' : '✗'} Usable`);
|
|
57
|
+
});
|
|
58
|
+
console.log('');
|
|
59
|
+
|
|
60
|
+
if (projects.length > 0) {
|
|
61
|
+
console.log('Projects:');
|
|
62
|
+
console.log('-'.repeat(60));
|
|
63
|
+
projects.forEach(project => {
|
|
64
|
+
console.log(` ${project.name} (${project.uuid})`);
|
|
65
|
+
});
|
|
66
|
+
console.log('');
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (apps.length > 0) {
|
|
70
|
+
console.log('Applications:');
|
|
71
|
+
console.log('-'.repeat(60));
|
|
72
|
+
apps.forEach(app => {
|
|
73
|
+
console.log(` ${app.name}`);
|
|
74
|
+
console.log(` UUID: ${app.uuid}`);
|
|
75
|
+
console.log(` Status: ${app.status || 'Unknown'}`);
|
|
76
|
+
console.log(` URL: ${app.fqdn || 'Not configured'}`);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
console.log('='.repeat(60));
|
|
82
|
+
process.exit(status.healthy ? 0 : 1);
|
|
83
|
+
} catch (error) {
|
|
84
|
+
if (options.json) {
|
|
85
|
+
console.log(JSON.stringify({ success: false, error: error.message }, null, 2));
|
|
86
|
+
} else {
|
|
87
|
+
console.error(`Error: ${error.message}`);
|
|
88
|
+
}
|
|
89
|
+
process.exit(1);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
94
|
+
checkStatus();
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export { checkStatus };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import fetch from 'node-fetch';
|
|
2
|
+
import { readFileSync } from 'fs';
|
|
3
|
+
import { parse } from 'dotenv';
|
|
4
|
+
|
|
5
|
+
const envContent = readFileSync('.env', 'utf8');
|
|
6
|
+
const env = parse(envContent);
|
|
7
|
+
|
|
8
|
+
const apiKey = env.COOLIFY_API_KEY;
|
|
9
|
+
const url = env.COOLIFY_URL;
|
|
10
|
+
|
|
11
|
+
const payload = {
|
|
12
|
+
project_uuid: 'zg44coscocg0sko8k0wgcgkw',
|
|
13
|
+
server_uuid: 'vcscogc44gko4k880ww880kk',
|
|
14
|
+
environment_name: 'production',
|
|
15
|
+
git_repository: 'https://github.com/vercel/micro',
|
|
16
|
+
git_branch: 'main',
|
|
17
|
+
name: 'test-micro-app',
|
|
18
|
+
build_pack: 'nixpacks',
|
|
19
|
+
ports_exposes: '3000'
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
console.log('Testing Coolify deployment...');
|
|
23
|
+
console.log('Payload:', JSON.stringify(payload, null, 2));
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
|
+
const response = await fetch(`${url}/api/v1/applications/public`, {
|
|
27
|
+
method: 'POST',
|
|
28
|
+
headers: {
|
|
29
|
+
'Authorization': `Bearer ${apiKey}`,
|
|
30
|
+
'Content-Type': 'application/json',
|
|
31
|
+
'Accept': 'application/json'
|
|
32
|
+
},
|
|
33
|
+
body: JSON.stringify(payload)
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
console.log('Status:', response.status);
|
|
37
|
+
console.log('Status Text:', response.statusText);
|
|
38
|
+
|
|
39
|
+
const data = await response.json().catch(() => ({}));
|
|
40
|
+
console.log('Response:', JSON.stringify(data, null, 2));
|
|
41
|
+
|
|
42
|
+
if (!response.ok) {
|
|
43
|
+
console.error('Error details:', data);
|
|
44
|
+
}
|
|
45
|
+
} catch (error) {
|
|
46
|
+
console.error('Error:', error.message);
|
|
47
|
+
}
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WordPress Comprehensive Report Script
|
|
5
|
+
* Runs all checks and synthesizes into a comprehensive report
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* npx myaidev-method wordpress:comprehensive-report [options]
|
|
9
|
+
* node src/scripts/wordpress-comprehensive-report.js [options]
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { WordPressAdminUtils } from '../lib/wordpress-admin-utils.js';
|
|
13
|
+
import { ReportSynthesizer } from '../lib/report-synthesizer.js';
|
|
14
|
+
import { writeFileSync } from 'fs';
|
|
15
|
+
import { resolve } from 'path';
|
|
16
|
+
|
|
17
|
+
const args = process.argv.slice(2);
|
|
18
|
+
|
|
19
|
+
const options = {
|
|
20
|
+
format: 'markdown', // markdown or json
|
|
21
|
+
output: null, // file path for output
|
|
22
|
+
verbose: false,
|
|
23
|
+
includeHealth: true,
|
|
24
|
+
includeSecurity: true,
|
|
25
|
+
includePerformance: true,
|
|
26
|
+
saveIndividual: false // Save individual reports as well
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
// Parse arguments
|
|
30
|
+
for (let i = 0; i < args.length; i++) {
|
|
31
|
+
switch (args[i]) {
|
|
32
|
+
case '--format':
|
|
33
|
+
options.format = args[++i] || 'markdown';
|
|
34
|
+
break;
|
|
35
|
+
case '--output':
|
|
36
|
+
case '-o':
|
|
37
|
+
options.output = args[++i];
|
|
38
|
+
break;
|
|
39
|
+
case '--verbose':
|
|
40
|
+
case '-v':
|
|
41
|
+
options.verbose = true;
|
|
42
|
+
break;
|
|
43
|
+
case '--save-individual':
|
|
44
|
+
options.saveIndividual = true;
|
|
45
|
+
break;
|
|
46
|
+
case '--health-only':
|
|
47
|
+
options.includeSecurity = false;
|
|
48
|
+
options.includePerformance = false;
|
|
49
|
+
break;
|
|
50
|
+
case '--security-only':
|
|
51
|
+
options.includeHealth = false;
|
|
52
|
+
options.includePerformance = false;
|
|
53
|
+
break;
|
|
54
|
+
case '--performance-only':
|
|
55
|
+
options.includeHealth = false;
|
|
56
|
+
options.includeSecurity = false;
|
|
57
|
+
break;
|
|
58
|
+
case '--help':
|
|
59
|
+
case '-h':
|
|
60
|
+
printHelp();
|
|
61
|
+
process.exit(0);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function printHelp() {
|
|
66
|
+
console.log(`
|
|
67
|
+
WordPress Comprehensive Report Script
|
|
68
|
+
|
|
69
|
+
Runs all WordPress admin checks and synthesizes them into a comprehensive report.
|
|
70
|
+
Perfect for regular site maintenance and agent-driven analysis.
|
|
71
|
+
|
|
72
|
+
Usage:
|
|
73
|
+
npx myaidev-method wordpress:comprehensive-report [options]
|
|
74
|
+
|
|
75
|
+
Options:
|
|
76
|
+
--format <type> Output format: markdown or json (default: markdown)
|
|
77
|
+
--output <file> Write output to file (default: stdout)
|
|
78
|
+
-o <file> Alias for --output
|
|
79
|
+
--verbose Show detailed progress information
|
|
80
|
+
-v Alias for --verbose
|
|
81
|
+
--save-individual Save individual report files as well
|
|
82
|
+
--health-only Only run health check
|
|
83
|
+
--security-only Only run security scan
|
|
84
|
+
--performance-only Only run performance check
|
|
85
|
+
--help Show this help message
|
|
86
|
+
-h Alias for --help
|
|
87
|
+
|
|
88
|
+
Environment Variables (from .env):
|
|
89
|
+
WORDPRESS_URL WordPress site URL
|
|
90
|
+
WORDPRESS_USERNAME Admin username
|
|
91
|
+
WORDPRESS_APP_PASSWORD Application password
|
|
92
|
+
|
|
93
|
+
This script runs:
|
|
94
|
+
✓ Health Check - Site health assessment
|
|
95
|
+
✓ Security Scan - Security vulnerability detection
|
|
96
|
+
✓ Performance Analysis - Performance metrics collection
|
|
97
|
+
|
|
98
|
+
Then synthesizes all results into a comprehensive report with:
|
|
99
|
+
✓ Executive summary with scores
|
|
100
|
+
✓ Critical issues requiring immediate attention
|
|
101
|
+
✓ Warnings and recommendations
|
|
102
|
+
✓ Prioritized action items
|
|
103
|
+
✓ Key metrics and statistics
|
|
104
|
+
|
|
105
|
+
Examples:
|
|
106
|
+
# Generate comprehensive markdown report
|
|
107
|
+
npx myaidev-method wordpress:comprehensive-report
|
|
108
|
+
|
|
109
|
+
# Save comprehensive report to file
|
|
110
|
+
npx myaidev-method wordpress:comprehensive-report --output wp-report.md
|
|
111
|
+
|
|
112
|
+
# Generate JSON report for agent processing
|
|
113
|
+
npx myaidev-method wordpress:comprehensive-report --format json
|
|
114
|
+
|
|
115
|
+
# Save all reports (comprehensive + individual)
|
|
116
|
+
npx myaidev-method wordpress:comprehensive-report --save-individual --output report.md
|
|
117
|
+
|
|
118
|
+
# Verbose mode with progress information
|
|
119
|
+
npx myaidev-method wordpress:comprehensive-report --verbose
|
|
120
|
+
|
|
121
|
+
Agent Integration:
|
|
122
|
+
This script is designed to work with the wordpress-admin agent. The agent can:
|
|
123
|
+
1. Run this script to get structured data
|
|
124
|
+
2. Process the JSON or markdown output
|
|
125
|
+
3. Generate natural language analysis
|
|
126
|
+
4. Provide actionable recommendations
|
|
127
|
+
|
|
128
|
+
Exit Codes:
|
|
129
|
+
0 - Report generated successfully, no critical issues
|
|
130
|
+
1 - Error occurred during analysis
|
|
131
|
+
2 - Report generated with warnings
|
|
132
|
+
3 - Report generated with critical issues
|
|
133
|
+
`);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
async function runComprehensiveReport() {
|
|
137
|
+
const timestamp = new Date().toISOString();
|
|
138
|
+
const reports = [];
|
|
139
|
+
|
|
140
|
+
try {
|
|
141
|
+
if (options.verbose) {
|
|
142
|
+
console.error('WordPress Comprehensive Report');
|
|
143
|
+
console.error('='.repeat(60));
|
|
144
|
+
console.error('Initializing WordPress connection...');
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const wpUtils = new WordPressAdminUtils();
|
|
148
|
+
const synthesizer = new ReportSynthesizer();
|
|
149
|
+
|
|
150
|
+
// Run health check
|
|
151
|
+
if (options.includeHealth) {
|
|
152
|
+
if (options.verbose) {
|
|
153
|
+
console.error('\n[1/3] Running health check...');
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const healthData = await wpUtils.runHealthCheck();
|
|
157
|
+
synthesizer.addReport(healthData, 'health');
|
|
158
|
+
reports.push({ type: 'health', data: healthData });
|
|
159
|
+
|
|
160
|
+
if (options.saveIndividual && options.output) {
|
|
161
|
+
const healthFile = options.output.replace(/\.(md|json)$/, '-health.json');
|
|
162
|
+
writeFileSync(healthFile, JSON.stringify(healthData, null, 2), 'utf8');
|
|
163
|
+
if (options.verbose) {
|
|
164
|
+
console.error(` Saved: ${healthFile}`);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// Run security scan
|
|
170
|
+
if (options.includeSecurity) {
|
|
171
|
+
if (options.verbose) {
|
|
172
|
+
console.error('\n[2/3] Running security scan...');
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const securityData = await wpUtils.runSecurityScan();
|
|
176
|
+
synthesizer.addReport(securityData, 'security');
|
|
177
|
+
reports.push({ type: 'security', data: securityData });
|
|
178
|
+
|
|
179
|
+
if (options.saveIndividual && options.output) {
|
|
180
|
+
const securityFile = options.output.replace(/\.(md|json)$/, '-security.json');
|
|
181
|
+
writeFileSync(securityFile, JSON.stringify(securityData, null, 2), 'utf8');
|
|
182
|
+
if (options.verbose) {
|
|
183
|
+
console.error(` Saved: ${securityFile}`);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// Run performance check
|
|
189
|
+
if (options.includePerformance) {
|
|
190
|
+
if (options.verbose) {
|
|
191
|
+
console.error('\n[3/3] Running performance analysis...');
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const perfData = await wpUtils.getPerformanceMetrics();
|
|
195
|
+
const timing = await measureResponseTime(wpUtils, 3);
|
|
196
|
+
|
|
197
|
+
const performanceData = {
|
|
198
|
+
success: true,
|
|
199
|
+
timestamp,
|
|
200
|
+
site: await wpUtils.getSiteInfo().catch(() => ({ url: wpUtils.url })),
|
|
201
|
+
performance_score: 85, // Calculate based on metrics
|
|
202
|
+
timing,
|
|
203
|
+
metrics: perfData,
|
|
204
|
+
recommendations: []
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
synthesizer.addReport(performanceData, 'performance');
|
|
208
|
+
reports.push({ type: 'performance', data: performanceData });
|
|
209
|
+
|
|
210
|
+
if (options.saveIndividual && options.output) {
|
|
211
|
+
const perfFile = options.output.replace(/\.(md|json)$/, '-performance.json');
|
|
212
|
+
writeFileSync(perfFile, JSON.stringify(performanceData, null, 2), 'utf8');
|
|
213
|
+
if (options.verbose) {
|
|
214
|
+
console.error(` Saved: ${perfFile}`);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
if (options.verbose) {
|
|
220
|
+
console.error('\nSynthesizing comprehensive report...');
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// Generate comprehensive report
|
|
224
|
+
let output;
|
|
225
|
+
if (options.format === 'json') {
|
|
226
|
+
output = synthesizer.generateJSONReport();
|
|
227
|
+
} else {
|
|
228
|
+
output = synthesizer.generateMarkdownReport();
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
if (options.verbose) {
|
|
232
|
+
console.error('Report generation completed.');
|
|
233
|
+
console.error('='.repeat(60));
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// Write output
|
|
237
|
+
if (options.output) {
|
|
238
|
+
const outputPath = resolve(options.output);
|
|
239
|
+
writeFileSync(outputPath, output, 'utf8');
|
|
240
|
+
|
|
241
|
+
if (options.verbose) {
|
|
242
|
+
console.error(`\nComprehensive report written to: ${outputPath}`);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// Output summary for piping
|
|
246
|
+
const synthesis = synthesizer.synthesize();
|
|
247
|
+
console.log(JSON.stringify({
|
|
248
|
+
success: true,
|
|
249
|
+
output_file: outputPath,
|
|
250
|
+
overall_status: synthesis.executive_summary.overall_status,
|
|
251
|
+
critical_issues: synthesis.critical_issues.length,
|
|
252
|
+
warnings: synthesis.warnings.length,
|
|
253
|
+
reports_generated: reports.length
|
|
254
|
+
}));
|
|
255
|
+
} else {
|
|
256
|
+
console.log(output);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// Determine exit code
|
|
260
|
+
const synthesis = synthesizer.synthesize();
|
|
261
|
+
const criticalCount = synthesis.critical_issues.length;
|
|
262
|
+
const warningCount = synthesis.warnings.length;
|
|
263
|
+
|
|
264
|
+
if (criticalCount > 0) {
|
|
265
|
+
process.exit(3); // Critical issues
|
|
266
|
+
} else if (warningCount > 0) {
|
|
267
|
+
process.exit(2); // Warnings
|
|
268
|
+
} else {
|
|
269
|
+
process.exit(0); // All clear
|
|
270
|
+
}
|
|
271
|
+
} catch (error) {
|
|
272
|
+
const errorOutput = {
|
|
273
|
+
success: false,
|
|
274
|
+
error: error.message,
|
|
275
|
+
timestamp,
|
|
276
|
+
reports_completed: reports.length
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
if (options.format === 'json') {
|
|
280
|
+
console.log(JSON.stringify(errorOutput, null, 2));
|
|
281
|
+
} else {
|
|
282
|
+
console.error(`\nERROR: ${error.message}`);
|
|
283
|
+
console.error(`Stack: ${error.stack}`);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
process.exit(1);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
async function measureResponseTime(wpUtils, iterations) {
|
|
291
|
+
const measurements = [];
|
|
292
|
+
|
|
293
|
+
for (let i = 0; i < iterations; i++) {
|
|
294
|
+
const start = Date.now();
|
|
295
|
+
try {
|
|
296
|
+
await wpUtils.request('/');
|
|
297
|
+
measurements.push(Date.now() - start);
|
|
298
|
+
} catch (error) {
|
|
299
|
+
// Skip failed measurements
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
if (i < iterations - 1) {
|
|
303
|
+
await new Promise(resolve => setTimeout(resolve, 100));
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
if (measurements.length === 0) return null;
|
|
308
|
+
|
|
309
|
+
const avg = measurements.reduce((a, b) => a + b, 0) / measurements.length;
|
|
310
|
+
const sorted = measurements.sort((a, b) => a - b);
|
|
311
|
+
|
|
312
|
+
return {
|
|
313
|
+
average: Math.round(avg),
|
|
314
|
+
median: Math.round(sorted[Math.floor(sorted.length / 2)]),
|
|
315
|
+
min: sorted[0],
|
|
316
|
+
max: sorted[sorted.length - 1]
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
// Run if called directly
|
|
321
|
+
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
322
|
+
runComprehensiveReport();
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
export { runComprehensiveReport };
|