@daileyos/mcp-server 1.20.1 → 1.20.2
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/.github/workflows/publish.yml +10 -3
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/tools/redis.d.ts +3 -0
- package/dist/tools/redis.d.ts.map +1 -0
- package/dist/tools/redis.js +72 -0
- package/dist/tools/redis.js.map +1 -0
- package/dist/tools/wordpress-import.d.ts +3 -0
- package/dist/tools/wordpress-import.d.ts.map +1 -0
- package/dist/tools/wordpress-import.js +151 -0
- package/dist/tools/wordpress-import.js.map +1 -0
- package/dist/tools/wordpress-snapshot.d.ts.map +1 -1
- package/dist/tools/wordpress-snapshot.js +5 -4
- package/dist/tools/wordpress-snapshot.js.map +1 -1
- package/package.json +5 -2
- package/src/index.ts +2 -0
- package/src/tools/wordpress-import.ts +174 -0
- package/src/tools/wordpress-snapshot.ts +8 -4
- package/test/wordpress-import.test.ts +223 -0
- package/tests/wp-snapshot-labels.test.mjs +21 -0
|
@@ -96,11 +96,18 @@ jobs:
|
|
|
96
96
|
if: always()
|
|
97
97
|
env:
|
|
98
98
|
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
|
|
99
|
+
COMMIT_MSG: ${{ github.event.head_commit.message }}
|
|
100
|
+
FALLBACK_REF: ${{ github.event.inputs.branch || github.ref_name }}
|
|
99
101
|
run: |
|
|
100
102
|
STATUS="${{ job.status }}"
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
103
|
+
# Untrusted commit message arrives via env (never interpolated into the
|
|
104
|
+
# script — prevents shell injection), then first line only, truncated,
|
|
105
|
+
# and JSON-escaped so it can't break the shell or the Slack payload.
|
|
106
|
+
COMMIT="${COMMIT_MSG:-$FALLBACK_REF}"
|
|
107
|
+
COMMIT="${COMMIT%%$'\n'*}"
|
|
108
|
+
COMMIT="${COMMIT:0:72}"
|
|
109
|
+
COMMIT="${COMMIT//\\/\\\\}"
|
|
110
|
+
COMMIT="${COMMIT//\"/\\\"}"
|
|
104
111
|
RUN_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
|
|
105
112
|
REPO=$(echo "${{ github.repository }}" | cut -d/ -f2)
|
|
106
113
|
if [ "$STATUS" = "success" ]; then
|
package/dist/index.js
CHANGED
|
@@ -30,6 +30,7 @@ import { registerProcessTools } from './tools/processes.js';
|
|
|
30
30
|
import { registerLifecycleTools } from './tools/lifecycle.js';
|
|
31
31
|
import { registerBackupTools } from './tools/backups.js';
|
|
32
32
|
import { registerWordPressMigrateTools } from './tools/wordpress-migrate.js';
|
|
33
|
+
import { registerWordPressImportTools } from './tools/wordpress-import.js';
|
|
33
34
|
import { registerWordPressSnapshotTools } from './tools/wordpress-snapshot.js';
|
|
34
35
|
import { registerEnvironmentTools } from './tools/environments.js';
|
|
35
36
|
import { registerResourceConfigTools } from './tools/resource-config.js';
|
|
@@ -135,6 +136,7 @@ registerEmailTools(server);
|
|
|
135
136
|
registerDaileyImagesTools(server);
|
|
136
137
|
registerBackupTools(server);
|
|
137
138
|
registerWordPressMigrateTools(server);
|
|
139
|
+
registerWordPressImportTools(server);
|
|
138
140
|
registerWordPressSnapshotTools(server);
|
|
139
141
|
registerEnvironmentTools(server);
|
|
140
142
|
// Runtime operations — exec into a pod, run one-off jobs
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAEjF,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,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":"","sources":["../../src/tools/redis.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AA4CpE,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,QAiFnD"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { apiRequest, formatError, textResult } from '../api.js';
|
|
3
|
+
export function registerRedisTools(server) {
|
|
4
|
+
server.tool('dailey_redis_enable', 'Enable Managed Redis ($10/mo, per namespace) so the app gets an authenticated in-cluster Redis (cache / sessions / queue) at redis.<namespace>.svc.cluster.local:6379. This is PAY-AT-PURCHASE and billing-owner-only: the normal response is a Stripe Checkout URL the user MUST open to pay $10/mo before Redis is provisioned — do NOT treat Redis as enabled until payment completes. If the account already has an active managed_redis add-on, or on the operator/internal path, it provisions immediately (redis_enabled:true). After it turns on, redeploy so REDIS_URL / REDIS_HOST / REDIS_PORT / REDIS_PASSWORD / CACHE_URL env is injected.', { project_id: z.string().describe('The project ID') }, async ({ project_id }) => {
|
|
5
|
+
const res = await apiRequest('POST', `/projects/${project_id}/redis/enable`, {});
|
|
6
|
+
if (!res.ok)
|
|
7
|
+
return textResult(formatError(res));
|
|
8
|
+
const d = res.data;
|
|
9
|
+
// Pay-at-purchase: a checkout_url means Redis is NOT provisioned yet.
|
|
10
|
+
if (d.pending && d.checkout_url) {
|
|
11
|
+
return textResult([
|
|
12
|
+
'Managed Redis is $10/mo and requires payment to enable.',
|
|
13
|
+
'',
|
|
14
|
+
'➜ Open this URL to finish enabling Redis (pay $10/mo):',
|
|
15
|
+
d.checkout_url,
|
|
16
|
+
'',
|
|
17
|
+
'Redis is provisioned automatically once the Stripe Checkout is paid. It is NOT active yet.',
|
|
18
|
+
'After it turns on, redeploy the project (dailey_deploy) to pick up REDIS_* env.',
|
|
19
|
+
].join('\n'));
|
|
20
|
+
}
|
|
21
|
+
// Operator / already-active-add-on path — provisioned immediately.
|
|
22
|
+
const lines = ['Managed Redis enabled (cache tier).'];
|
|
23
|
+
if (d.host)
|
|
24
|
+
lines.push(`Host: ${d.host}:${d.port ?? 6379}`);
|
|
25
|
+
lines.push('');
|
|
26
|
+
lines.push('Redeploy the project (dailey_deploy) to pick up REDIS_URL / REDIS_HOST / REDIS_PORT / REDIS_PASSWORD / CACHE_URL.');
|
|
27
|
+
return textResult(lines.join('\n'));
|
|
28
|
+
});
|
|
29
|
+
server.tool('dailey_redis_disable', 'Disable Managed Redis for a project: removes the REDIS_* / CACHE_URL env vars from this project. If this was the LAST project in the namespace using Redis, it also deprovisions the Redis pod and cancels the $10/mo managed_redis add-on. Billing-owner-only (a manager acting-as a managed account is denied).', { project_id: z.string().describe('The project ID') }, async ({ project_id }) => {
|
|
30
|
+
const res = await apiRequest('DELETE', `/projects/${project_id}/redis/enable`);
|
|
31
|
+
if (!res.ok)
|
|
32
|
+
return textResult(formatError(res));
|
|
33
|
+
const d = res.data;
|
|
34
|
+
return textResult(d.deprovisioned
|
|
35
|
+
? 'Managed Redis disabled. This was the last consumer, so the Redis pod was deprovisioned and the $10/mo add-on cancelled. The REDIS_* env vars were removed.'
|
|
36
|
+
: 'Managed Redis disabled for this project (REDIS_* env vars removed). Other projects in the namespace still use the Redis, so it stays provisioned and billed.');
|
|
37
|
+
});
|
|
38
|
+
server.tool('dailey_redis_status', 'Show Managed Redis status for a project: whether the managed_redis add-on is active, whether the namespace Redis is provisioned, whether REDIS_* is injected into this project, the tier/memory, host/port, and live metrics (used memory, connected clients, uptime) when reachable.', { project_id: z.string().describe('The project ID') }, async ({ project_id }) => {
|
|
39
|
+
const res = await apiRequest('GET', `/projects/${project_id}/redis`);
|
|
40
|
+
if (!res.ok)
|
|
41
|
+
return textResult(formatError(res));
|
|
42
|
+
const d = res.data;
|
|
43
|
+
const lines = [
|
|
44
|
+
`Managed Redis — ${d.project_id}`,
|
|
45
|
+
`Enabled: ${d.redis_enabled ? 'yes' : 'no'}`,
|
|
46
|
+
`Add-on: ${d.addon_active ? 'active' : 'inactive'}`,
|
|
47
|
+
`Provisioned: ${d.provisioned ? 'yes' : 'no'}`,
|
|
48
|
+
`Env injected: ${d.env_injected ? 'yes' : 'no'}`,
|
|
49
|
+
`Tier: ${d.tier} (maxmemory ${d.maxmemory}, ${d.maxmemory_policy})`,
|
|
50
|
+
`Host: ${d.host ? `${d.host}:${d.port}` : '(not provisioned)'}`,
|
|
51
|
+
];
|
|
52
|
+
if (d.metrics) {
|
|
53
|
+
lines.push('');
|
|
54
|
+
lines.push('Metrics:');
|
|
55
|
+
lines.push(` up: ${d.metrics.up ? 'yes' : 'no'}`);
|
|
56
|
+
if (d.metrics.redis_version)
|
|
57
|
+
lines.push(` redis_version: ${d.metrics.redis_version}`);
|
|
58
|
+
if (d.metrics.used_memory_bytes != null)
|
|
59
|
+
lines.push(` used_memory: ${d.metrics.used_memory_bytes} bytes`);
|
|
60
|
+
if (d.metrics.connected_clients != null)
|
|
61
|
+
lines.push(` connected_clients: ${d.metrics.connected_clients}`);
|
|
62
|
+
if (d.metrics.uptime_seconds != null)
|
|
63
|
+
lines.push(` uptime_seconds: ${d.metrics.uptime_seconds}`);
|
|
64
|
+
}
|
|
65
|
+
if (!d.redis_enabled) {
|
|
66
|
+
lines.push('');
|
|
67
|
+
lines.push('Redis is off. Enable with dailey_redis_enable (opens a $10/mo Stripe Checkout unless the add-on is already active).');
|
|
68
|
+
}
|
|
69
|
+
return textResult(lines.join('\n'));
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=redis.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redis.js","sourceRoot":"","sources":["../../src/tools/redis.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AA0ChE,MAAM,UAAU,kBAAkB,CAAC,MAAiB;IAClD,MAAM,CAAC,I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ACpI,CAAC;QACD,OAAO,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACtC,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wordpress-import.d.ts","sourceRoot":"","sources":["../../src/tools/wordpress-import.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAiDpE,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,SAAS,QA4H7D"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { existsSync, mkdtempSync, rmSync } from 'node:fs';
|
|
3
|
+
import { tmpdir } from 'node:os';
|
|
4
|
+
import { join, basename } from 'node:path';
|
|
5
|
+
import { analyze, stage } from '@daileyos/wp-bundle';
|
|
6
|
+
import { apiRequest, formatError, textResult } from '../api.js';
|
|
7
|
+
import { putFileToPresignedUrl } from '../upload.js';
|
|
8
|
+
// Client-side preflight cap for `analyze`, before any project/plan is known.
|
|
9
|
+
// The server enforces the customer's real plan limit once a target project
|
|
10
|
+
// exists (customer-api upload-staging.ts: ABSOLUTE_MAX_UPLOAD_BYTES = 2 GiB) —
|
|
11
|
+
// this mirrors that ceiling so an oversized bundle is flagged early rather
|
|
12
|
+
// than only after staging + upload.
|
|
13
|
+
const PLAN_UPLOAD_CAP_BYTES = 2 * 1024 * 1024 * 1024; // 2 GiB
|
|
14
|
+
function formatReport(report) {
|
|
15
|
+
const findings = report.findings.length
|
|
16
|
+
? report.findings.map((f) => ` [${f.level}] ${f.code}: ${f.message}${f.detail ? ` (${f.detail})` : ''}`).join('\n')
|
|
17
|
+
: ' (none)';
|
|
18
|
+
return [
|
|
19
|
+
`Bundle format: ${report.format}`,
|
|
20
|
+
`Source URL: ${report.source.old_url}`,
|
|
21
|
+
`DB size: ${report.sizes.db_bytes} bytes, wp-content: ${report.sizes.wp_content_bytes} bytes (${report.sizes.file_count} files)`,
|
|
22
|
+
`Verdict: ${report.verdict}`,
|
|
23
|
+
'Findings:',
|
|
24
|
+
findings,
|
|
25
|
+
].join('\n');
|
|
26
|
+
}
|
|
27
|
+
export function registerWordPressImportTools(server) {
|
|
28
|
+
server.tool('dailey_wordpress_import', 'Analyze and migrate a WordPress bundle export (Local by Flywheel .zip, All-in-One WP Migration .wpress, or Duplicator archive) onto Dailey OS. action=analyze reads the bundle locally (no upload) and returns a BundleReport — format, detected source config, sizes, findings, verdict. action=migrate auto-provisions a hardened+quarantined WordPress target when project_id is omitted, stages the bundle, uploads the DB + wp-content, runs the pre-migrate scan gate (refuses on a blocked verdict unless allow_unsafe=true — logged), then runs the import and polls to completion. WARNING: migrate replaces the target project\'s database and wp-content; requires confirm=true. action=status checks a previous migration.', {
|
|
29
|
+
action: z.enum(['analyze', 'migrate', 'status']).describe('analyze = read-only bundle report | migrate = full flow (provision/stage/upload/scan/run/poll) | status = check a migration'),
|
|
30
|
+
bundle_file: z.string().optional().describe('Local path to the bundle (.zip/.wpress) — required for analyze and migrate'),
|
|
31
|
+
project_id: z.string().optional().describe('Existing WordPress project to migrate into — omit to auto-provision a new target; required for action=status'),
|
|
32
|
+
confirm: z.boolean().optional().describe('Must be true to run action=migrate (destructive: replaces DB + wp-content)'),
|
|
33
|
+
allow_unsafe: z.boolean().optional().describe('Proceed despite a blocked verdict, whether found client-side (analyze) or by the server-side scan gate — the override is logged'),
|
|
34
|
+
migration_id: z.string().optional().describe('Migration ID — required for action=status'),
|
|
35
|
+
}, async ({ action, bundle_file, project_id, confirm, allow_unsafe, migration_id }) => {
|
|
36
|
+
if (action === 'status') {
|
|
37
|
+
if (!project_id || !migration_id)
|
|
38
|
+
return textResult('project_id and migration_id are required for action=status');
|
|
39
|
+
const res = await apiRequest('GET', `/projects/${project_id}/migrate/wordpress/${migration_id}`);
|
|
40
|
+
if (!res.ok)
|
|
41
|
+
return textResult(formatError(res));
|
|
42
|
+
const s = res.data;
|
|
43
|
+
return textResult(`Migration ${migration_id}: ${s.status}${s.step ? ` (step: ${s.step})` : ''}${s.error ? `\nError: ${s.error}` : ''}${s.log_tail ? `\n--- log ---\n${s.log_tail}` : ''}`);
|
|
44
|
+
}
|
|
45
|
+
if (!bundle_file)
|
|
46
|
+
return textResult(`bundle_file is required for action=${action}`);
|
|
47
|
+
if (!existsSync(bundle_file))
|
|
48
|
+
return textResult(`File not found: ${bundle_file}`);
|
|
49
|
+
let report;
|
|
50
|
+
try {
|
|
51
|
+
report = await analyze(bundle_file, { planUploadCapBytes: PLAN_UPLOAD_CAP_BYTES });
|
|
52
|
+
}
|
|
53
|
+
catch (e) {
|
|
54
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
55
|
+
return textResult(`Failed to analyze bundle: ${message}`);
|
|
56
|
+
}
|
|
57
|
+
if (action === 'analyze') {
|
|
58
|
+
return textResult(formatReport(report));
|
|
59
|
+
}
|
|
60
|
+
// action === 'migrate'
|
|
61
|
+
if (!confirm) {
|
|
62
|
+
return textResult(`Refusing to migrate without confirm=true (this replaces the target's database and wp-content).\n\n${formatReport(report)}`);
|
|
63
|
+
}
|
|
64
|
+
if (report.verdict === 'blocked' && !allow_unsafe) {
|
|
65
|
+
return textResult(`Refusing to migrate: bundle analysis verdict is BLOCKED. Pass allow_unsafe=true to override (logged) if you understand the risk.\n\n${formatReport(report)}`);
|
|
66
|
+
}
|
|
67
|
+
if (report.verdict === 'blocked' && allow_unsafe) {
|
|
68
|
+
console.error(`[dailey_wordpress_import] proceeding past a BLOCKED analyze() verdict for ${bundle_file} (allow_unsafe=true)`);
|
|
69
|
+
}
|
|
70
|
+
let targetProjectId = project_id;
|
|
71
|
+
if (!targetProjectId) {
|
|
72
|
+
const provision = await apiRequest('POST', '/projects/wordpress/provision-target', {
|
|
73
|
+
old_url: report.source.old_url,
|
|
74
|
+
});
|
|
75
|
+
if (!provision.ok)
|
|
76
|
+
return textResult(formatError(provision));
|
|
77
|
+
targetProjectId = provision.data.project_id;
|
|
78
|
+
}
|
|
79
|
+
const tmpDir = mkdtempSync(join(tmpdir(), 'dailey-wp-import-'));
|
|
80
|
+
let staged;
|
|
81
|
+
try {
|
|
82
|
+
try {
|
|
83
|
+
staged = await stage(bundle_file, tmpDir, { gzipDb: true });
|
|
84
|
+
}
|
|
85
|
+
catch (e) {
|
|
86
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
87
|
+
return textResult(`Failed to stage bundle: ${message}`);
|
|
88
|
+
}
|
|
89
|
+
const start = await apiRequest('POST', `/projects/${targetProjectId}/migrate/wordpress`, {
|
|
90
|
+
db_filename: basename(staged.dbFile),
|
|
91
|
+
content_filename: basename(staged.contentFile),
|
|
92
|
+
});
|
|
93
|
+
if (!start.ok)
|
|
94
|
+
return textResult(formatError(start));
|
|
95
|
+
const { migration_id: mid, db_upload, content_upload } = start.data;
|
|
96
|
+
try {
|
|
97
|
+
await putFileToPresignedUrl(db_upload.url, staged.dbFile, db_upload.headers);
|
|
98
|
+
await putFileToPresignedUrl(content_upload.url, staged.contentFile, content_upload.headers);
|
|
99
|
+
}
|
|
100
|
+
catch (e) {
|
|
101
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
102
|
+
return textResult(`Upload failed: ${message}\nMigration ${mid} is still pending on project ${targetProjectId} — fix the file and call migrate again (a new migration will be started).`);
|
|
103
|
+
}
|
|
104
|
+
const scan = await apiRequest('POST', `/projects/${targetProjectId}/migrate/wordpress/${mid}/scan`, {
|
|
105
|
+
allow_unsafe: Boolean(allow_unsafe),
|
|
106
|
+
});
|
|
107
|
+
if (scan.status === 409) {
|
|
108
|
+
const findings = scan.data?.findings ?? [];
|
|
109
|
+
const list = findings.length ? findings.map((f) => ` [${f.level}] ${f.code}: ${f.message}`).join('\n') : ' (no findings detail returned)';
|
|
110
|
+
return textResult(`Refusing to run: server-side scan gate is BLOCKED.\n${list}\nMigration ${mid} is still pending on project ${targetProjectId} — pass allow_unsafe=true to override (logged) and call migrate again.`);
|
|
111
|
+
}
|
|
112
|
+
if (!scan.ok)
|
|
113
|
+
return textResult(formatError(scan));
|
|
114
|
+
const run = await apiRequest('POST', `/projects/${targetProjectId}/migrate/wordpress/${mid}/run`, {
|
|
115
|
+
old_url: report.source.old_url,
|
|
116
|
+
...(report.source.table_prefix && report.source.table_prefix !== 'wp_' ? { table_prefix: report.source.table_prefix } : {}),
|
|
117
|
+
});
|
|
118
|
+
if (!run.ok)
|
|
119
|
+
return textResult(formatError(run));
|
|
120
|
+
// Poll to terminal state (up to ~10 min; migrations are usually 1-3 min).
|
|
121
|
+
// Check immediately (a migration can finish before the first poll tick)
|
|
122
|
+
// and only sleep between checks, not before the first one.
|
|
123
|
+
const started = Date.now();
|
|
124
|
+
let last = null;
|
|
125
|
+
while (Date.now() - started < 10 * 60 * 1000) {
|
|
126
|
+
const st = await apiRequest('GET', `/projects/${targetProjectId}/migrate/wordpress/${mid}`);
|
|
127
|
+
if (st.ok) {
|
|
128
|
+
last = st.data;
|
|
129
|
+
if (last.status === 'succeeded' || last.status === 'failed')
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
await new Promise((r) => setTimeout(r, 5000));
|
|
133
|
+
}
|
|
134
|
+
if (!last)
|
|
135
|
+
return textResult(`Migration ${mid} launched but status could not be read. Check later with action=status project_id=${targetProjectId} migration_id=${mid}.`);
|
|
136
|
+
if (last.status === 'succeeded') {
|
|
137
|
+
return textResult(`Migration succeeded. Site is live at ${run.data.new_url} with the imported content.\nNote: hard-refresh and re-save permalinks (Settings > Permalinks) if pretty URLs 404.`);
|
|
138
|
+
}
|
|
139
|
+
if (last.status === 'failed') {
|
|
140
|
+
return textResult(`Migration FAILED at step: ${last.step ?? 'unknown'}\n${last.error ?? ''}\n--- log ---\n${last.log_tail ?? ''}\nYour staged files were kept — fix the issue and run migrate again.`);
|
|
141
|
+
}
|
|
142
|
+
return textResult(`Migration ${mid} still ${last.status} (step: ${last.step ?? '-'}) after 10 min — check again with action=status project_id=${targetProjectId} migration_id=${mid}.`);
|
|
143
|
+
}
|
|
144
|
+
finally {
|
|
145
|
+
if (staged)
|
|
146
|
+
await staged.cleanup().catch(() => { });
|
|
147
|
+
rmSync(tmpDir, { recursive: true, force: true });
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=wordpress-import.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wordpress-import.js","sourceRoot":"","sources":["../../src/tools/wordpress-import.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,KAAK,EAAqB,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAErD,6EAA6E;AAC7E,2EAA2E;AAC3E,+EAA+E;AAC/E,2EAA2E;AAC3E,oCAAoC;AACpC,MAAM,qBAAqB,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,QAAQ;AAqB9D,SAAS,YAAY,CAAC,MAAoB;IACxC,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM;QACrC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,E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,IAAI,MAAM;gBAAE,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;YACnD,MAAM,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACnD,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wordpress-snapshot.d.ts","sourceRoot":"","sources":["../../src/tools/wordpress-snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"wordpress-snapshot.d.ts","sourceRoot":"","sources":["../../src/tools/wordpress-snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAiEpE,wBAAgB,8BAA8B,CAAC,MAAM,EAAE,SAAS,QA+J/D"}
|
|
@@ -24,18 +24,19 @@ export function registerWordPressSnapshotTools(server) {
|
|
|
24
24
|
}
|
|
25
25
|
const lines = [
|
|
26
26
|
`Snapshots for project ${project_id}`,
|
|
27
|
-
`${'ID'.padEnd(38)} ${'Created'.padEnd(26)} ${'
|
|
27
|
+
`${'ID'.padEnd(38)} ${'Created'.padEnd(26)} ${'Reason'.padEnd(10)} ${'Label'.padEnd(24)} ${'Status'.padEnd(12)} ${'DB'.padEnd(10)} Content`,
|
|
28
28
|
'─'.repeat(115),
|
|
29
29
|
];
|
|
30
30
|
for (const s of snapshots) {
|
|
31
|
-
lines.push(`${(s.id || '').padEnd(38)} ${(s.created_at || '-').padEnd(26)} ${(s.
|
|
31
|
+
lines.push(`${(s.id || '').padEnd(38)} ${(s.created_at || '-').padEnd(26)} ${(s.reason || 'manual').padEnd(10)} ${((s.label ?? '').slice(0, 24) || '—').padEnd(24)} ${(s.status || '-').padEnd(12)} ${fmtBytes(s.db_bytes).padEnd(10)} ${fmtBytes(s.content_bytes ?? s.uploads_bytes)}`);
|
|
32
32
|
}
|
|
33
33
|
return textResult(lines.join('\n'));
|
|
34
34
|
});
|
|
35
35
|
server.tool('dailey_wp_snapshot', 'Create a snapshot (DB + uploads) of a WordPress project', {
|
|
36
36
|
project_id: z.string().describe('The project ID'),
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
label: z.string().optional().describe('Optional human label; labeled points are kept until deleted (never auto-expire)'),
|
|
38
|
+
}, async ({ project_id, label }) => {
|
|
39
|
+
const res = await apiRequest('POST', `/projects/${project_id}/wp/snapshot`, label ? { label } : undefined);
|
|
39
40
|
if (!res.ok)
|
|
40
41
|
return textResult(formatError(res));
|
|
41
42
|
const { operation_id } = res.data;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wordpress-snapshot.js","sourceRoot":"","sources":["../../src/tools/wordpress-snapshot.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,UAAU,EAAc,WAAW,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"wordpress-snapshot.js","sourceRoot":"","sources":["../../src/tools/wordpress-snapshot.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,UAAU,EAAc,WAAW,EAAE,MAAM,WAAW,CAAC;AAuD5E,SAAS,QAAQ,CAAC,KAAc;IAC9B,IAAI,KAAK,IAAI,IAAI;QAAE,OAAO,GAAG,CAAC;IAC9B,IAAI,KAAK,GAAG,IAAI;QAAE,OAAO,GAAG,KAAK,GAAG,CAAC;IACrC,IAAI,KAAK,GAAG,IAAI,GAAG,IAAI;QAAE,OAAO,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;IACjE,IAAI,KAAK,GAAG,IAAI,GAAG,I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AK;YAAE,KAAK,CAAC,IAAI,CAAC,wBAAwB,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC;QAC7D,IAAI,EAAE,CAAC,kBAAkB;YAAE,KAAK,CAAC,IAAI,CAAC,wBAAwB,EAAE,CAAC,kBAAkB,EAAE,CAAC,CAAC;QAEvF,IAAI,EAAE,CAAC,QAAQ,IAAI,EAAE,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC1C,MAAM,IAAI,GAAG,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;YACpC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACf,KAAK,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;YAClC,KAAK,MAAM,KAAK,IAAI,IAAI,EAAE,CAAC;gBACzB,KAAK,CAAC,IAAI,CAAC,KAAK,KAAK,EAAE,CAAC,CAAC;YAC3B,CAAC;QACH,CAAC;QAED,OAAO,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACtC,CAAC,CACF,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@daileyos/mcp-server",
|
|
3
|
-
"version": "1.20.
|
|
3
|
+
"version": "1.20.2",
|
|
4
4
|
"description": "Dailey OS MCP server for Claude Code and AI assistants",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -9,17 +9,20 @@
|
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
11
|
"build": "tsc",
|
|
12
|
-
"start": "node dist/index.js"
|
|
12
|
+
"start": "node dist/index.js",
|
|
13
|
+
"test": "tsx --test --experimental-test-module-mocks test/*.test.ts"
|
|
13
14
|
},
|
|
14
15
|
"publishConfig": {
|
|
15
16
|
"access": "public"
|
|
16
17
|
},
|
|
17
18
|
"dependencies": {
|
|
19
|
+
"@daileyos/wp-bundle": "^0.1.0",
|
|
18
20
|
"@modelcontextprotocol/sdk": "^1.12.1",
|
|
19
21
|
"zod": "^3.24.4"
|
|
20
22
|
},
|
|
21
23
|
"devDependencies": {
|
|
22
24
|
"@types/node": "^22.15.3",
|
|
25
|
+
"tsx": "^4.23.0",
|
|
23
26
|
"typescript": "^5.8.3"
|
|
24
27
|
}
|
|
25
28
|
}
|
package/src/index.ts
CHANGED
|
@@ -32,6 +32,7 @@ import { registerProcessTools } from './tools/processes.js';
|
|
|
32
32
|
import { registerLifecycleTools } from './tools/lifecycle.js';
|
|
33
33
|
import { registerBackupTools } from './tools/backups.js';
|
|
34
34
|
import { registerWordPressMigrateTools } from './tools/wordpress-migrate.js';
|
|
35
|
+
import { registerWordPressImportTools } from './tools/wordpress-import.js';
|
|
35
36
|
import { registerWordPressSnapshotTools } from './tools/wordpress-snapshot.js';
|
|
36
37
|
import { registerEnvironmentTools } from './tools/environments.js';
|
|
37
38
|
import { registerResourceConfigTools } from './tools/resource-config.js';
|
|
@@ -155,6 +156,7 @@ registerEmailTools(server);
|
|
|
155
156
|
registerDaileyImagesTools(server);
|
|
156
157
|
registerBackupTools(server);
|
|
157
158
|
registerWordPressMigrateTools(server);
|
|
159
|
+
registerWordPressImportTools(server);
|
|
158
160
|
registerWordPressSnapshotTools(server);
|
|
159
161
|
registerEnvironmentTools(server);
|
|
160
162
|
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { existsSync, mkdtempSync, rmSync } from 'node:fs';
|
|
4
|
+
import { tmpdir } from 'node:os';
|
|
5
|
+
import { join, basename } from 'node:path';
|
|
6
|
+
import { analyze, stage, type BundleReport } from '@daileyos/wp-bundle';
|
|
7
|
+
import { apiRequest, formatError, textResult } from '../api.js';
|
|
8
|
+
import { putFileToPresignedUrl } from '../upload.js';
|
|
9
|
+
|
|
10
|
+
// Client-side preflight cap for `analyze`, before any project/plan is known.
|
|
11
|
+
// The server enforces the customer's real plan limit once a target project
|
|
12
|
+
// exists (customer-api upload-staging.ts: ABSOLUTE_MAX_UPLOAD_BYTES = 2 GiB) —
|
|
13
|
+
// this mirrors that ceiling so an oversized bundle is flagged early rather
|
|
14
|
+
// than only after staging + upload.
|
|
15
|
+
const PLAN_UPLOAD_CAP_BYTES = 2 * 1024 * 1024 * 1024; // 2 GiB
|
|
16
|
+
|
|
17
|
+
interface ProvisionResponse {
|
|
18
|
+
ok: boolean;
|
|
19
|
+
project_id: string;
|
|
20
|
+
slug: string;
|
|
21
|
+
new_url: string;
|
|
22
|
+
ready: boolean;
|
|
23
|
+
note: string;
|
|
24
|
+
}
|
|
25
|
+
interface StartResponse {
|
|
26
|
+
migration_id: string;
|
|
27
|
+
db_upload: { url: string; key: string; headers: Record<string, string>; max_bytes: number };
|
|
28
|
+
content_upload: { url: string; key: string; headers: Record<string, string>; max_bytes: number };
|
|
29
|
+
warning?: string;
|
|
30
|
+
}
|
|
31
|
+
interface ScanFinding { level: string; code: string; message: string }
|
|
32
|
+
interface ScanResponse { ok: boolean; verdict: 'clean' | 'warn' | 'blocked'; findings: ScanFinding[] }
|
|
33
|
+
interface RunResponse { ok: boolean; migration_id: string; new_url: string }
|
|
34
|
+
interface StatusResponse { status: string; step?: string; error?: string; log_tail?: string; finished_at?: string }
|
|
35
|
+
|
|
36
|
+
function formatReport(report: BundleReport): string {
|
|
37
|
+
const findings = report.findings.length
|
|
38
|
+
? report.findings.map((f) => ` [${f.level}] ${f.code}: ${f.message}${f.detail ? ` (${f.detail})` : ''}`).join('\n')
|
|
39
|
+
: ' (none)';
|
|
40
|
+
return [
|
|
41
|
+
`Bundle format: ${report.format}`,
|
|
42
|
+
`Source URL: ${report.source.old_url}`,
|
|
43
|
+
`DB size: ${report.sizes.db_bytes} bytes, wp-content: ${report.sizes.wp_content_bytes} bytes (${report.sizes.file_count} files)`,
|
|
44
|
+
`Verdict: ${report.verdict}`,
|
|
45
|
+
'Findings:',
|
|
46
|
+
findings,
|
|
47
|
+
].join('\n');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function registerWordPressImportTools(server: McpServer) {
|
|
51
|
+
server.tool(
|
|
52
|
+
'dailey_wordpress_import',
|
|
53
|
+
'Analyze and migrate a WordPress bundle export (Local by Flywheel .zip, All-in-One WP Migration .wpress, or Duplicator archive) onto Dailey OS. action=analyze reads the bundle locally (no upload) and returns a BundleReport — format, detected source config, sizes, findings, verdict. action=migrate auto-provisions a hardened+quarantined WordPress target when project_id is omitted, stages the bundle, uploads the DB + wp-content, runs the pre-migrate scan gate (refuses on a blocked verdict unless allow_unsafe=true — logged), then runs the import and polls to completion. WARNING: migrate replaces the target project\'s database and wp-content; requires confirm=true. action=status checks a previous migration.',
|
|
54
|
+
{
|
|
55
|
+
action: z.enum(['analyze', 'migrate', 'status']).describe('analyze = read-only bundle report | migrate = full flow (provision/stage/upload/scan/run/poll) | status = check a migration'),
|
|
56
|
+
bundle_file: z.string().optional().describe('Local path to the bundle (.zip/.wpress) — required for analyze and migrate'),
|
|
57
|
+
project_id: z.string().optional().describe('Existing WordPress project to migrate into — omit to auto-provision a new target; required for action=status'),
|
|
58
|
+
confirm: z.boolean().optional().describe('Must be true to run action=migrate (destructive: replaces DB + wp-content)'),
|
|
59
|
+
allow_unsafe: z.boolean().optional().describe('Proceed despite a blocked verdict, whether found client-side (analyze) or by the server-side scan gate — the override is logged'),
|
|
60
|
+
migration_id: z.string().optional().describe('Migration ID — required for action=status'),
|
|
61
|
+
},
|
|
62
|
+
async ({ action, bundle_file, project_id, confirm, allow_unsafe, migration_id }) => {
|
|
63
|
+
if (action === 'status') {
|
|
64
|
+
if (!project_id || !migration_id) return textResult('project_id and migration_id are required for action=status');
|
|
65
|
+
const res = await apiRequest<StatusResponse>('GET', `/projects/${project_id}/migrate/wordpress/${migration_id}`);
|
|
66
|
+
if (!res.ok) return textResult(formatError(res));
|
|
67
|
+
const s = res.data;
|
|
68
|
+
return textResult(`Migration ${migration_id}: ${s.status}${s.step ? ` (step: ${s.step})` : ''}${s.error ? `\nError: ${s.error}` : ''}${s.log_tail ? `\n--- log ---\n${s.log_tail}` : ''}`);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (!bundle_file) return textResult(`bundle_file is required for action=${action}`);
|
|
72
|
+
if (!existsSync(bundle_file)) return textResult(`File not found: ${bundle_file}`);
|
|
73
|
+
|
|
74
|
+
let report: BundleReport;
|
|
75
|
+
try {
|
|
76
|
+
report = await analyze(bundle_file, { planUploadCapBytes: PLAN_UPLOAD_CAP_BYTES });
|
|
77
|
+
} catch (e: unknown) {
|
|
78
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
79
|
+
return textResult(`Failed to analyze bundle: ${message}`);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (action === 'analyze') {
|
|
83
|
+
return textResult(formatReport(report));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// action === 'migrate'
|
|
87
|
+
if (!confirm) {
|
|
88
|
+
return textResult(`Refusing to migrate without confirm=true (this replaces the target's database and wp-content).\n\n${formatReport(report)}`);
|
|
89
|
+
}
|
|
90
|
+
if (report.verdict === 'blocked' && !allow_unsafe) {
|
|
91
|
+
return textResult(`Refusing to migrate: bundle analysis verdict is BLOCKED. Pass allow_unsafe=true to override (logged) if you understand the risk.\n\n${formatReport(report)}`);
|
|
92
|
+
}
|
|
93
|
+
if (report.verdict === 'blocked' && allow_unsafe) {
|
|
94
|
+
console.error(`[dailey_wordpress_import] proceeding past a BLOCKED analyze() verdict for ${bundle_file} (allow_unsafe=true)`);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
let targetProjectId = project_id;
|
|
98
|
+
if (!targetProjectId) {
|
|
99
|
+
const provision = await apiRequest<ProvisionResponse>('POST', '/projects/wordpress/provision-target', {
|
|
100
|
+
old_url: report.source.old_url,
|
|
101
|
+
});
|
|
102
|
+
if (!provision.ok) return textResult(formatError(provision));
|
|
103
|
+
targetProjectId = provision.data.project_id;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const tmpDir = mkdtempSync(join(tmpdir(), 'dailey-wp-import-'));
|
|
107
|
+
let staged: Awaited<ReturnType<typeof stage>> | undefined;
|
|
108
|
+
try {
|
|
109
|
+
try {
|
|
110
|
+
staged = await stage(bundle_file, tmpDir, { gzipDb: true });
|
|
111
|
+
} catch (e: unknown) {
|
|
112
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
113
|
+
return textResult(`Failed to stage bundle: ${message}`);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const start = await apiRequest<StartResponse>('POST', `/projects/${targetProjectId}/migrate/wordpress`, {
|
|
117
|
+
db_filename: basename(staged.dbFile),
|
|
118
|
+
content_filename: basename(staged.contentFile),
|
|
119
|
+
});
|
|
120
|
+
if (!start.ok) return textResult(formatError(start));
|
|
121
|
+
const { migration_id: mid, db_upload, content_upload } = start.data;
|
|
122
|
+
|
|
123
|
+
try {
|
|
124
|
+
await putFileToPresignedUrl(db_upload.url, staged.dbFile, db_upload.headers);
|
|
125
|
+
await putFileToPresignedUrl(content_upload.url, staged.contentFile, content_upload.headers);
|
|
126
|
+
} catch (e: unknown) {
|
|
127
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
128
|
+
return textResult(`Upload failed: ${message}\nMigration ${mid} is still pending on project ${targetProjectId} — fix the file and call migrate again (a new migration will be started).`);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const scan = await apiRequest<ScanResponse>('POST', `/projects/${targetProjectId}/migrate/wordpress/${mid}/scan`, {
|
|
132
|
+
allow_unsafe: Boolean(allow_unsafe),
|
|
133
|
+
});
|
|
134
|
+
if (scan.status === 409) {
|
|
135
|
+
const findings = (scan.data as ScanResponse | undefined)?.findings ?? [];
|
|
136
|
+
const list = findings.length ? findings.map((f) => ` [${f.level}] ${f.code}: ${f.message}`).join('\n') : ' (no findings detail returned)';
|
|
137
|
+
return textResult(`Refusing to run: server-side scan gate is BLOCKED.\n${list}\nMigration ${mid} is still pending on project ${targetProjectId} — pass allow_unsafe=true to override (logged) and call migrate again.`);
|
|
138
|
+
}
|
|
139
|
+
if (!scan.ok) return textResult(formatError(scan));
|
|
140
|
+
|
|
141
|
+
const run = await apiRequest<RunResponse>('POST', `/projects/${targetProjectId}/migrate/wordpress/${mid}/run`, {
|
|
142
|
+
old_url: report.source.old_url,
|
|
143
|
+
...(report.source.table_prefix && report.source.table_prefix !== 'wp_' ? { table_prefix: report.source.table_prefix } : {}),
|
|
144
|
+
});
|
|
145
|
+
if (!run.ok) return textResult(formatError(run));
|
|
146
|
+
|
|
147
|
+
// Poll to terminal state (up to ~10 min; migrations are usually 1-3 min).
|
|
148
|
+
// Check immediately (a migration can finish before the first poll tick)
|
|
149
|
+
// and only sleep between checks, not before the first one.
|
|
150
|
+
const started = Date.now();
|
|
151
|
+
let last: StatusResponse | null = null;
|
|
152
|
+
while (Date.now() - started < 10 * 60 * 1000) {
|
|
153
|
+
const st = await apiRequest<StatusResponse>('GET', `/projects/${targetProjectId}/migrate/wordpress/${mid}`);
|
|
154
|
+
if (st.ok) {
|
|
155
|
+
last = st.data;
|
|
156
|
+
if (last.status === 'succeeded' || last.status === 'failed') break;
|
|
157
|
+
}
|
|
158
|
+
await new Promise((r) => setTimeout(r, 5000));
|
|
159
|
+
}
|
|
160
|
+
if (!last) return textResult(`Migration ${mid} launched but status could not be read. Check later with action=status project_id=${targetProjectId} migration_id=${mid}.`);
|
|
161
|
+
if (last.status === 'succeeded') {
|
|
162
|
+
return textResult(`Migration succeeded. Site is live at ${run.data.new_url} with the imported content.\nNote: hard-refresh and re-save permalinks (Settings > Permalinks) if pretty URLs 404.`);
|
|
163
|
+
}
|
|
164
|
+
if (last.status === 'failed') {
|
|
165
|
+
return textResult(`Migration FAILED at step: ${last.step ?? 'unknown'}\n${last.error ?? ''}\n--- log ---\n${last.log_tail ?? ''}\nYour staged files were kept — fix the issue and run migrate again.`);
|
|
166
|
+
}
|
|
167
|
+
return textResult(`Migration ${mid} still ${last.status} (step: ${last.step ?? '-'}) after 10 min — check again with action=status project_id=${targetProjectId} migration_id=${mid}.`);
|
|
168
|
+
} finally {
|
|
169
|
+
if (staged) await staged.cleanup().catch(() => {});
|
|
170
|
+
rmSync(tmpDir, { recursive: true, force: true });
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
);
|
|
174
|
+
}
|
|
@@ -8,8 +8,11 @@ interface Snapshot {
|
|
|
8
8
|
kind: string;
|
|
9
9
|
status: string;
|
|
10
10
|
env?: string;
|
|
11
|
+
reason?: string;
|
|
12
|
+
label?: string | null;
|
|
11
13
|
db_bytes?: number;
|
|
12
14
|
uploads_bytes?: number;
|
|
15
|
+
content_bytes?: number;
|
|
13
16
|
}
|
|
14
17
|
|
|
15
18
|
interface SnapshotsResponse {
|
|
@@ -78,13 +81,13 @@ export function registerWordPressSnapshotTools(server: McpServer) {
|
|
|
78
81
|
|
|
79
82
|
const lines = [
|
|
80
83
|
`Snapshots for project ${project_id}`,
|
|
81
|
-
`${'ID'.padEnd(38)} ${'Created'.padEnd(26)} ${'
|
|
84
|
+
`${'ID'.padEnd(38)} ${'Created'.padEnd(26)} ${'Reason'.padEnd(10)} ${'Label'.padEnd(24)} ${'Status'.padEnd(12)} ${'DB'.padEnd(10)} Content`,
|
|
82
85
|
'─'.repeat(115),
|
|
83
86
|
];
|
|
84
87
|
|
|
85
88
|
for (const s of snapshots) {
|
|
86
89
|
lines.push(
|
|
87
|
-
`${(s.id || '').padEnd(38)} ${(s.created_at || '-').padEnd(26)} ${(s.
|
|
90
|
+
`${(s.id || '').padEnd(38)} ${(s.created_at || '-').padEnd(26)} ${(s.reason || 'manual').padEnd(10)} ${((s.label ?? '').slice(0, 24) || '—').padEnd(24)} ${(s.status || '-').padEnd(12)} ${fmtBytes(s.db_bytes).padEnd(10)} ${fmtBytes(s.content_bytes ?? s.uploads_bytes)}`,
|
|
88
91
|
);
|
|
89
92
|
}
|
|
90
93
|
|
|
@@ -97,9 +100,10 @@ export function registerWordPressSnapshotTools(server: McpServer) {
|
|
|
97
100
|
'Create a snapshot (DB + uploads) of a WordPress project',
|
|
98
101
|
{
|
|
99
102
|
project_id: z.string().describe('The project ID'),
|
|
103
|
+
label: z.string().optional().describe('Optional human label; labeled points are kept until deleted (never auto-expire)'),
|
|
100
104
|
},
|
|
101
|
-
async ({ project_id }) => {
|
|
102
|
-
const res = await apiRequest<SnapshotStartResponse>('POST', `/projects/${project_id}/wp/snapshot
|
|
105
|
+
async ({ project_id, label }) => {
|
|
106
|
+
const res = await apiRequest<SnapshotStartResponse>('POST', `/projects/${project_id}/wp/snapshot`, label ? { label } : undefined);
|
|
103
107
|
if (!res.ok) return textResult(formatError(res));
|
|
104
108
|
|
|
105
109
|
const { operation_id } = res.data;
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { test } from 'node:test';
|
|
2
|
+
import assert from 'node:assert';
|
|
3
|
+
import { mkdtempSync, writeFileSync, rmSync } from 'node:fs';
|
|
4
|
+
import { tmpdir } from 'node:os';
|
|
5
|
+
import { join } from 'node:path';
|
|
6
|
+
|
|
7
|
+
// A minimal fake McpServer: registerWordPressImportTools only calls
|
|
8
|
+
// server.tool(name, description, schema, handler) — capture the handler.
|
|
9
|
+
function makeFakeServer() {
|
|
10
|
+
let handler: ((args: any) => Promise<{ content: Array<{ type: 'text'; text: string }> }>) | undefined;
|
|
11
|
+
const server = {
|
|
12
|
+
tool: (_name: string, _desc: string, _schema: unknown, h: typeof handler) => {
|
|
13
|
+
handler = h;
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
return { server, getHandler: () => handler! };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function blockedReport() {
|
|
20
|
+
return {
|
|
21
|
+
format: 'local-zip' as const,
|
|
22
|
+
source: { old_url: 'https://oldsite.example', table_prefix: 'wp_', wp_version: null, php_version: null, db_charset: null, multisite: false },
|
|
23
|
+
sizes: { db_bytes: 100, wp_content_bytes: 200, file_count: 5 },
|
|
24
|
+
target: { mode: 'auto-provision' as const, new_url: '' },
|
|
25
|
+
findings: [{ level: 'block' as const, code: 'exec-bit', message: 'executable file found' }],
|
|
26
|
+
verdict: 'blocked' as const,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function readyReport() {
|
|
31
|
+
return {
|
|
32
|
+
format: 'local-zip' as const,
|
|
33
|
+
source: { old_url: 'https://oldsite.example', table_prefix: 'wp_', wp_version: null, php_version: null, db_charset: null, multisite: false },
|
|
34
|
+
sizes: { db_bytes: 100, wp_content_bytes: 200, file_count: 5 },
|
|
35
|
+
target: { mode: 'auto-provision' as const, new_url: '' },
|
|
36
|
+
findings: [],
|
|
37
|
+
verdict: 'ready' as const,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function fakeStageResult(dbFile: string, contentFile: string) {
|
|
42
|
+
return {
|
|
43
|
+
dbFile,
|
|
44
|
+
contentFile,
|
|
45
|
+
params: { old_url: 'https://oldsite.example', table_prefix: 'wp_', wp_version: null, php_version: null, db_charset: null, multisite: false },
|
|
46
|
+
cleanup: async () => {},
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
test('action=analyze returns the BundleReport and issues no upload/run calls', async (t) => {
|
|
51
|
+
const calls: string[] = [];
|
|
52
|
+
|
|
53
|
+
t.mock.module('@daileyos/wp-bundle', {
|
|
54
|
+
namedExports: {
|
|
55
|
+
analyze: async () => blockedReport(),
|
|
56
|
+
stage: async () => { throw new Error('stage should not be called for analyze'); },
|
|
57
|
+
detect: async () => 'local-zip',
|
|
58
|
+
adapterFor: () => { throw new Error('not used'); },
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
t.mock.module('../src/api.js', {
|
|
62
|
+
namedExports: {
|
|
63
|
+
apiRequest: async (method: string, path: string) => {
|
|
64
|
+
calls.push(`${method} ${path}`);
|
|
65
|
+
throw new Error('apiRequest should not be called for action=analyze');
|
|
66
|
+
},
|
|
67
|
+
formatError: (res: any) => JSON.stringify(res),
|
|
68
|
+
textResult: (text: string) => ({ content: [{ type: 'text' as const, text }] }),
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
t.mock.module('../src/upload.js', {
|
|
72
|
+
namedExports: {
|
|
73
|
+
putFileToPresignedUrl: async () => { throw new Error('upload should not be called for action=analyze'); },
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
// Cache-bust: each test mocks the same specifiers differently, and Node's
|
|
78
|
+
// ESM loader caches by resolved specifier — a bare re-import would reuse
|
|
79
|
+
// the module instance (and its already-bound imports) from whichever test
|
|
80
|
+
// imported it first. A unique query string forces a fresh instantiation
|
|
81
|
+
// that picks up THIS test's mocks.
|
|
82
|
+
const { registerWordPressImportTools } = await import(`../src/tools/wordpress-import.js?t=analyze`);
|
|
83
|
+
const { server, getHandler } = makeFakeServer();
|
|
84
|
+
registerWordPressImportTools(server as any);
|
|
85
|
+
|
|
86
|
+
const dir = mkdtempSync(join(tmpdir(), 'wp-import-test-'));
|
|
87
|
+
const bundleFile = join(dir, 'bundle.zip');
|
|
88
|
+
writeFileSync(bundleFile, 'fake bundle bytes');
|
|
89
|
+
|
|
90
|
+
try {
|
|
91
|
+
const result = await getHandler()({ action: 'analyze', bundle_file: bundleFile });
|
|
92
|
+
const text = result.content[0].text;
|
|
93
|
+
assert.match(text, /Verdict: blocked/);
|
|
94
|
+
assert.match(text, /exec-bit/);
|
|
95
|
+
assert.strictEqual(calls.length, 0, 'analyze must not call apiRequest');
|
|
96
|
+
} finally {
|
|
97
|
+
rmSync(dir, { recursive: true, force: true });
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
test('action=migrate refuses on a blocked verdict without allow_unsafe, before any /run call', async (t) => {
|
|
102
|
+
const calls: string[] = [];
|
|
103
|
+
|
|
104
|
+
t.mock.module('@daileyos/wp-bundle', {
|
|
105
|
+
namedExports: {
|
|
106
|
+
analyze: async () => blockedReport(),
|
|
107
|
+
stage: async () => { throw new Error('stage should not be called when refused pre-flight'); },
|
|
108
|
+
detect: async () => 'local-zip',
|
|
109
|
+
adapterFor: () => { throw new Error('not used'); },
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
t.mock.module('../src/api.js', {
|
|
113
|
+
namedExports: {
|
|
114
|
+
apiRequest: async (method: string, path: string) => {
|
|
115
|
+
calls.push(`${method} ${path}`);
|
|
116
|
+
throw new Error('apiRequest should not be called when the verdict is blocked and allow_unsafe is not set');
|
|
117
|
+
},
|
|
118
|
+
formatError: (res: any) => JSON.stringify(res),
|
|
119
|
+
textResult: (text: string) => ({ content: [{ type: 'text' as const, text }] }),
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
t.mock.module('../src/upload.js', {
|
|
123
|
+
namedExports: {
|
|
124
|
+
putFileToPresignedUrl: async () => { throw new Error('upload should not be called'); },
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
const { registerWordPressImportTools } = await import(`../src/tools/wordpress-import.js?t=blocked`);
|
|
129
|
+
const { server, getHandler } = makeFakeServer();
|
|
130
|
+
registerWordPressImportTools(server as any);
|
|
131
|
+
|
|
132
|
+
const dir = mkdtempSync(join(tmpdir(), 'wp-import-test-'));
|
|
133
|
+
const bundleFile = join(dir, 'bundle.zip');
|
|
134
|
+
writeFileSync(bundleFile, 'fake bundle bytes');
|
|
135
|
+
|
|
136
|
+
try {
|
|
137
|
+
const result = await getHandler()({ action: 'migrate', bundle_file: bundleFile, confirm: true });
|
|
138
|
+
const text = result.content[0].text;
|
|
139
|
+
assert.match(text, /BLOCKED/);
|
|
140
|
+
assert.match(text, /allow_unsafe/);
|
|
141
|
+
assert.strictEqual(calls.length, 0, 'a blocked verdict must refuse before any customer-api call, including /run');
|
|
142
|
+
} finally {
|
|
143
|
+
rmSync(dir, { recursive: true, force: true });
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
test('action=migrate happy path calls provision-target -> start -> PUT x2 -> scan -> run -> status, in order', async (t) => {
|
|
148
|
+
const calls: string[] = [];
|
|
149
|
+
const puts: string[] = [];
|
|
150
|
+
const dir = mkdtempSync(join(tmpdir(), 'wp-import-test-'));
|
|
151
|
+
const bundleFile = join(dir, 'bundle.zip');
|
|
152
|
+
const dbFile = join(dir, 'db.sql');
|
|
153
|
+
const contentFile = join(dir, 'wp-content.tar.gz');
|
|
154
|
+
writeFileSync(bundleFile, 'fake bundle bytes');
|
|
155
|
+
writeFileSync(dbFile, 'fake db');
|
|
156
|
+
writeFileSync(contentFile, 'fake content');
|
|
157
|
+
|
|
158
|
+
t.mock.module('@daileyos/wp-bundle', {
|
|
159
|
+
namedExports: {
|
|
160
|
+
analyze: async () => readyReport(),
|
|
161
|
+
stage: async () => fakeStageResult(dbFile, contentFile),
|
|
162
|
+
detect: async () => 'local-zip',
|
|
163
|
+
adapterFor: () => { throw new Error('not used'); },
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
t.mock.module('../src/api.js', {
|
|
167
|
+
namedExports: {
|
|
168
|
+
apiRequest: async (method: string, path: string) => {
|
|
169
|
+
calls.push(`${method} ${path}`);
|
|
170
|
+
if (path === '/projects/wordpress/provision-target') {
|
|
171
|
+
return { ok: true, status: 200, data: { ok: true, project_id: 'proj_new', slug: 'x', new_url: 'https://x.dailey.cloud', ready: true, note: '' } };
|
|
172
|
+
}
|
|
173
|
+
if (path === '/projects/proj_new/migrate/wordpress') {
|
|
174
|
+
return {
|
|
175
|
+
ok: true, status: 200, data: {
|
|
176
|
+
migration_id: 'mig1',
|
|
177
|
+
db_upload: { url: 'https://upload.example/db', key: 'k1', headers: {}, max_bytes: 999 },
|
|
178
|
+
content_upload: { url: 'https://upload.example/content', key: 'k2', headers: {}, max_bytes: 999 },
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
if (path === '/projects/proj_new/migrate/wordpress/mig1/scan') {
|
|
183
|
+
return { ok: true, status: 200, data: { ok: true, verdict: 'clean', findings: [] } };
|
|
184
|
+
}
|
|
185
|
+
if (path === '/projects/proj_new/migrate/wordpress/mig1/run') {
|
|
186
|
+
return { ok: true, status: 202, data: { ok: true, migration_id: 'mig1', new_url: 'https://x.dailey.cloud' } };
|
|
187
|
+
}
|
|
188
|
+
if (path === '/projects/proj_new/migrate/wordpress/mig1') {
|
|
189
|
+
return { ok: true, status: 200, data: { status: 'succeeded' } };
|
|
190
|
+
}
|
|
191
|
+
throw new Error(`unexpected apiRequest call: ${method} ${path}`);
|
|
192
|
+
},
|
|
193
|
+
formatError: (res: any) => JSON.stringify(res),
|
|
194
|
+
textResult: (text: string) => ({ content: [{ type: 'text' as const, text }] }),
|
|
195
|
+
},
|
|
196
|
+
});
|
|
197
|
+
t.mock.module('../src/upload.js', {
|
|
198
|
+
namedExports: {
|
|
199
|
+
putFileToPresignedUrl: async (url: string) => { puts.push(url); },
|
|
200
|
+
},
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
const { registerWordPressImportTools } = await import(`../src/tools/wordpress-import.js?t=happy`);
|
|
204
|
+
const { server, getHandler } = makeFakeServer();
|
|
205
|
+
registerWordPressImportTools(server as any);
|
|
206
|
+
|
|
207
|
+
try {
|
|
208
|
+
const result = await getHandler()({ action: 'migrate', bundle_file: bundleFile, confirm: true });
|
|
209
|
+
const text = result.content[0].text;
|
|
210
|
+
assert.match(text, /succeeded/i);
|
|
211
|
+
|
|
212
|
+
assert.deepStrictEqual(calls, [
|
|
213
|
+
'POST /projects/wordpress/provision-target',
|
|
214
|
+
'POST /projects/proj_new/migrate/wordpress',
|
|
215
|
+
'POST /projects/proj_new/migrate/wordpress/mig1/scan',
|
|
216
|
+
'POST /projects/proj_new/migrate/wordpress/mig1/run',
|
|
217
|
+
'GET /projects/proj_new/migrate/wordpress/mig1',
|
|
218
|
+
]);
|
|
219
|
+
assert.deepStrictEqual(puts, ['https://upload.example/db', 'https://upload.example/content']);
|
|
220
|
+
} finally {
|
|
221
|
+
rmSync(dir, { recursive: true, force: true });
|
|
222
|
+
}
|
|
223
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { test } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { registerWordPressSnapshotTools } from '../dist/tools/wordpress-snapshot.js';
|
|
4
|
+
|
|
5
|
+
function collect() {
|
|
6
|
+
const regs = [];
|
|
7
|
+
registerWordPressSnapshotTools({ tool: (name, description, schema, handler) => regs.push({ name, description, schema, handler }) });
|
|
8
|
+
return regs;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
test('dailey_wp_snapshot exposes an optional label param', () => {
|
|
12
|
+
const reg = collect().find((r) => r.name === 'dailey_wp_snapshot');
|
|
13
|
+
assert.ok(reg, 'tool must be registered');
|
|
14
|
+
assert.ok('label' in reg.schema, 'schema must include a label field');
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test('dailey_wp_snapshots source references reason + label columns', async () => {
|
|
18
|
+
const src = await import('node:fs').then((fs) => fs.readFileSync(new URL('../dist/tools/wordpress-snapshot.js', import.meta.url), 'utf8'));
|
|
19
|
+
assert.ok(/reason/i.test(src), 'list output should surface provenance (reason)');
|
|
20
|
+
assert.ok(/label/i.test(src), 'list output should surface label');
|
|
21
|
+
});
|