@daileyos/mcp-server 1.21.2 → 1.21.9
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/dist/api.d.ts +7 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +23 -2
- package/dist/api.js.map +1 -1
- package/dist/index.js +24 -17
- package/dist/index.js.map +1 -1
- package/dist/tools/accounts.d.ts.map +1 -1
- package/dist/tools/accounts.js +3 -2
- package/dist/tools/accounts.js.map +1 -1
- package/dist/tools/ai.d.ts.map +1 -1
- package/dist/tools/ai.js +7 -1
- package/dist/tools/ai.js.map +1 -1
- package/dist/tools/auth.d.ts.map +1 -1
- package/dist/tools/auth.js +25 -6
- package/dist/tools/auth.js.map +1 -1
- package/dist/tools/backups.d.ts.map +1 -1
- package/dist/tools/backups.js +3 -1
- package/dist/tools/backups.js.map +1 -1
- package/dist/tools/build-logs.d.ts.map +1 -1
- package/dist/tools/build-logs.js +3 -1
- package/dist/tools/build-logs.js.map +1 -1
- package/dist/tools/credentials-reveal.d.ts.map +1 -1
- package/dist/tools/credentials-reveal.js +3 -1
- package/dist/tools/credentials-reveal.js.map +1 -1
- package/dist/tools/dailey-images.js +3 -3
- package/dist/tools/dailey-images.js.map +1 -1
- package/dist/tools/db-migrate.js +5 -5
- package/dist/tools/db-migrate.js.map +1 -1
- package/dist/tools/db.d.ts.map +1 -1
- package/dist/tools/db.js +17 -1
- package/dist/tools/db.js.map +1 -1
- package/dist/tools/deploy-status.d.ts.map +1 -1
- package/dist/tools/deploy-status.js +3 -1
- package/dist/tools/deploy-status.js.map +1 -1
- package/dist/tools/deploy.d.ts.map +1 -1
- package/dist/tools/deploy.js +9 -1
- package/dist/tools/deploy.js.map +1 -1
- package/dist/tools/domains.d.ts.map +1 -1
- package/dist/tools/domains.js +3 -1
- package/dist/tools/domains.js.map +1 -1
- package/dist/tools/email.d.ts.map +1 -1
- package/dist/tools/email.js +8 -2
- package/dist/tools/email.js.map +1 -1
- package/dist/tools/env.d.ts.map +1 -1
- package/dist/tools/env.js +5 -1
- package/dist/tools/env.js.map +1 -1
- package/dist/tools/environments.js +3 -3
- package/dist/tools/environments.js.map +1 -1
- package/dist/tools/exec-run.d.ts.map +1 -1
- package/dist/tools/exec-run.js +7 -1
- package/dist/tools/exec-run.js.map +1 -1
- package/dist/tools/images.d.ts.map +1 -1
- package/dist/tools/images.js +5 -1
- package/dist/tools/images.js.map +1 -1
- package/dist/tools/lifecycle.d.ts.map +1 -1
- package/dist/tools/lifecycle.js +5 -1
- package/dist/tools/lifecycle.js.map +1 -1
- package/dist/tools/links.d.ts.map +1 -1
- package/dist/tools/links.js +3 -1
- package/dist/tools/links.js.map +1 -1
- package/dist/tools/platform.d.ts.map +1 -1
- package/dist/tools/platform.js +5 -3
- package/dist/tools/platform.js.map +1 -1
- package/dist/tools/processes.d.ts.map +1 -1
- package/dist/tools/processes.js +11 -1
- package/dist/tools/processes.js.map +1 -1
- package/dist/tools/projects.d.ts.map +1 -1
- package/dist/tools/projects.js +36 -12
- package/dist/tools/projects.js.map +1 -1
- package/dist/tools/resource-config.d.ts.map +1 -1
- package/dist/tools/resource-config.js +3 -1
- package/dist/tools/resource-config.js.map +1 -1
- package/dist/tools/scale.d.ts.map +1 -1
- package/dist/tools/scale.js +3 -1
- package/dist/tools/scale.js.map +1 -1
- package/dist/tools/storage.d.ts.map +1 -1
- package/dist/tools/storage.js +11 -1
- package/dist/tools/storage.js.map +1 -1
- package/dist/tools/support.d.ts.map +1 -1
- package/dist/tools/support.js +3 -1
- package/dist/tools/support.js.map +1 -1
- package/dist/tools/usage.d.ts.map +1 -1
- package/dist/tools/usage.js +3 -1
- package/dist/tools/usage.js.map +1 -1
- package/dist/tools/wordpress-import.d.ts.map +1 -1
- package/dist/tools/wordpress-import.js +3 -1
- package/dist/tools/wordpress-import.js.map +1 -1
- package/dist/tools/wordpress-migrate.d.ts.map +1 -1
- package/dist/tools/wordpress-migrate.js +3 -1
- package/dist/tools/wordpress-migrate.js.map +1 -1
- package/dist/tools/wordpress-snapshot.d.ts.map +1 -1
- package/dist/tools/wordpress-snapshot.js +9 -1
- package/dist/tools/wordpress-snapshot.js.map +1 -1
- package/package.json +10 -2
- package/.dockerignore +0 -6
- package/.github/workflows/publish.yml +0 -120
- package/Dockerfile +0 -19
- package/claude-config.json +0 -13
- package/docs/superpowers/plans/2026-08-09-remote-mcp-endpoint.md +0 -663
- package/docs/superpowers/specs/2026-08-09-remote-mcp-endpoint-design.md +0 -66
- package/src/api.ts +0 -263
- package/src/context.ts +0 -12
- package/src/http.ts +0 -160
- package/src/index.ts +0 -94
- package/src/server.ts +0 -188
- package/src/tools/accounts.ts +0 -119
- package/src/tools/addons.ts +0 -124
- package/src/tools/admin.ts +0 -42
- package/src/tools/ai.ts +0 -83
- package/src/tools/analyze.ts +0 -108
- package/src/tools/auth.ts +0 -177
- package/src/tools/backups.ts +0 -84
- package/src/tools/billing.ts +0 -34
- package/src/tools/build-logs.ts +0 -65
- package/src/tools/bundle.ts +0 -129
- package/src/tools/cli.ts +0 -76
- package/src/tools/credentials-reveal.ts +0 -64
- package/src/tools/credits.ts +0 -97
- package/src/tools/dailey-images.ts +0 -151
- package/src/tools/db-migrate.ts +0 -211
- package/src/tools/db.ts +0 -391
- package/src/tools/deploy-status.ts +0 -247
- package/src/tools/deploy.ts +0 -101
- package/src/tools/diagnose.ts +0 -567
- package/src/tools/domains.ts +0 -156
- package/src/tools/email.ts +0 -101
- package/src/tools/env.ts +0 -205
- package/src/tools/environments.ts +0 -138
- package/src/tools/exec-run.ts +0 -91
- package/src/tools/images.ts +0 -221
- package/src/tools/lifecycle.ts +0 -75
- package/src/tools/links.ts +0 -69
- package/src/tools/platform.ts +0 -209
- package/src/tools/processes.ts +0 -182
- package/src/tools/project-transfer.ts +0 -129
- package/src/tools/projects.ts +0 -287
- package/src/tools/resource-config.ts +0 -84
- package/src/tools/scale.ts +0 -33
- package/src/tools/storage.ts +0 -281
- package/src/tools/support.ts +0 -42
- package/src/tools/usage.ts +0 -128
- package/src/tools/wordpress-import.ts +0 -174
- package/src/tools/wordpress-live-edit.ts +0 -250
- package/src/tools/wordpress-migrate.ts +0 -104
- package/src/tools/wordpress-snapshot.ts +0 -225
- package/src/tools/wordpress-targeting.ts +0 -188
- package/src/upload.ts +0 -35
- package/src/version.ts +0 -70
- package/test/context.test.ts +0 -36
- package/test/http.test.ts +0 -103
- package/test/server-surface.test.ts +0 -36
- package/test/use-account-sticky.test.ts +0 -28
- package/test/wordpress-import.test.ts +0 -223
- package/test/wordpress-live-edit.test.ts +0 -159
- package/test/wordpress-targeting.test.ts +0 -162
- package/tests/dailey-images.test.mjs +0 -156
- package/tests/environments.test.mjs +0 -230
- package/tests/mcp-protocol-smoke.mjs +0 -149
- package/tests/new-tools-smoke.mjs +0 -217
- package/tests/pack1-mcp-preflight.test.mjs +0 -184
- package/tests/pack6-smoke.mjs +0 -222
- package/tests/wp-snapshot-labels.test.mjs +0 -21
- package/tests/wp-snapshot.test.mjs +0 -261
- package/tsconfig.json +0 -19
|
@@ -1,223 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
import { test } from 'node:test';
|
|
2
|
-
import assert from 'node:assert';
|
|
3
|
-
|
|
4
|
-
// Minimal fake McpServer: registerWordPressLiveEditTools calls
|
|
5
|
-
// server.tool(name, description, schema, handler) three times — capture the
|
|
6
|
-
// handler for each tool by name.
|
|
7
|
-
function makeFakeServer() {
|
|
8
|
-
const handlers = new Map<string, (args: any) => Promise<{ content: Array<{ type: 'text'; text: string }> }>>();
|
|
9
|
-
const server = {
|
|
10
|
-
tool: (name: string, _desc: string, _schema: unknown, h: (args: any) => any) => {
|
|
11
|
-
handlers.set(name, h);
|
|
12
|
-
},
|
|
13
|
-
};
|
|
14
|
-
return { server, getHandler: (name: string) => handlers.get(name)! };
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const IDENTITY = {
|
|
18
|
-
project_id: 'proj_wp1',
|
|
19
|
-
slug: 'my-blog',
|
|
20
|
-
domain: 'my-blog.dailey.cloud',
|
|
21
|
-
env: 'prod',
|
|
22
|
-
db_name: 'wp_myblog',
|
|
23
|
-
namespace: 'cust-abc',
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
// Shared active-account state + a router that mimics the two-phase server:
|
|
27
|
-
// a mutating POST without confirm_token returns a preview envelope; the same
|
|
28
|
-
// POST WITH confirm_token executes.
|
|
29
|
-
function makeApiMock() {
|
|
30
|
-
const calls: Array<{ method: string; path: string; body?: any }> = [];
|
|
31
|
-
let active: string | undefined;
|
|
32
|
-
return {
|
|
33
|
-
calls,
|
|
34
|
-
namedExports: {
|
|
35
|
-
apiRequest: async (method: string, path: string, body?: any) => {
|
|
36
|
-
calls.push({ method, path, body });
|
|
37
|
-
|
|
38
|
-
// read-only routes
|
|
39
|
-
if (path.endsWith('/wp/files/list')) {
|
|
40
|
-
return { ok: true, status: 200, data: { path: body?.path ?? '/', entries: [{ name: 'style.css', type: 'file', size: 12, path: '/style.css' }] } };
|
|
41
|
-
}
|
|
42
|
-
if (path.endsWith('/wp/files/read')) {
|
|
43
|
-
return { ok: true, status: 200, data: { path: body.path, encoding: 'utf8', content: 'body{}', size: 6 } };
|
|
44
|
-
}
|
|
45
|
-
if (path.endsWith('/wp/media/list')) {
|
|
46
|
-
return { ok: true, status: 200, data: { path: body?.path ?? '/', entries: [] } };
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// mutating routes — two-phase
|
|
50
|
-
const mutating = ['/wp/files/write', '/wp/files/delete', '/wp/media/upload', '/wp/cli'];
|
|
51
|
-
if (mutating.some((m) => path.endsWith(m))) {
|
|
52
|
-
const isCliRead = path.endsWith('/wp/cli') && !body?.allow_write;
|
|
53
|
-
if (isCliRead) {
|
|
54
|
-
return { ok: true, status: 200, data: { stdout: 'https://my-blog.dailey.cloud', stderr: '', exit_code: 0, write: false } };
|
|
55
|
-
}
|
|
56
|
-
if (!body?.confirm_token) {
|
|
57
|
-
return { ok: true, status: 200, data: { preview: true, confirm_token: 'tok_abc123', identity: IDENTITY, change: { op: path } } };
|
|
58
|
-
}
|
|
59
|
-
// executed
|
|
60
|
-
return { ok: true, status: 200, data: { ok: true, path: body.path, snapshot_id: 'snap_1', confirm_token_used: body.confirm_token } };
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
throw new Error(`unexpected apiRequest call: ${method} ${path}`);
|
|
64
|
-
},
|
|
65
|
-
formatError: (res: any) => JSON.stringify(res),
|
|
66
|
-
textResult: (text: string) => ({ content: [{ type: 'text' as const, text }] }),
|
|
67
|
-
jsonResult: (data: unknown) => ({ content: [{ type: 'text' as const, text: JSON.stringify(data, null, 2) }] }),
|
|
68
|
-
getActiveAccount: () => active,
|
|
69
|
-
setActiveAccount: (v: string | undefined) => { active = v && v.trim() ? v.trim() : undefined; },
|
|
70
|
-
},
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
test('dailey_wp_files list posts to /wp/files/list and surfaces active_account', async (t) => {
|
|
75
|
-
const mock = makeApiMock();
|
|
76
|
-
t.mock.module('../src/api.js', { namedExports: mock.namedExports });
|
|
77
|
-
|
|
78
|
-
const { registerWordPressLiveEditTools } = await import('../src/tools/wordpress-live-edit.js?t=files-list');
|
|
79
|
-
const { server, getHandler } = makeFakeServer();
|
|
80
|
-
registerWordPressLiveEditTools(server as any);
|
|
81
|
-
|
|
82
|
-
const result = await getHandler('dailey_wp_files')({ project: 'proj_wp1', action: 'list', account: 'acme' });
|
|
83
|
-
const parsed = JSON.parse(result.content[0].text);
|
|
84
|
-
|
|
85
|
-
assert.strictEqual(mock.calls[0].path, '/projects/proj_wp1/wp/files/list');
|
|
86
|
-
assert.strictEqual(mock.calls[0].method, 'POST');
|
|
87
|
-
assert.strictEqual(parsed.active_account, 'acme');
|
|
88
|
-
assert.strictEqual(parsed.entries[0].name, 'style.css');
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
test('dailey_wp_files write is two-phase: preview (no token) then execute (with token)', async (t) => {
|
|
92
|
-
const mock = makeApiMock();
|
|
93
|
-
t.mock.module('../src/api.js', { namedExports: mock.namedExports });
|
|
94
|
-
|
|
95
|
-
const { registerWordPressLiveEditTools } = await import('../src/tools/wordpress-live-edit.js?t=files-write');
|
|
96
|
-
const { server, getHandler } = makeFakeServer();
|
|
97
|
-
registerWordPressLiveEditTools(server as any);
|
|
98
|
-
|
|
99
|
-
// Phase 1 — no confirm_token → preview with identity echo + token, no mutation.
|
|
100
|
-
const preview = await getHandler('dailey_wp_files')({ project: 'proj_wp1', action: 'write', path: '/style.css', content: 'body{color:red}' });
|
|
101
|
-
const text = preview.content[0].text;
|
|
102
|
-
assert.match(text, /PREVIEW ONLY/);
|
|
103
|
-
assert.match(text, /my-blog\.dailey\.cloud/, 'echoes domain');
|
|
104
|
-
assert.match(text, /wp_myblog/, 'echoes db_name');
|
|
105
|
-
assert.match(text, /confirm_token: tok_abc123/);
|
|
106
|
-
const writeCall = mock.calls.find((c) => c.path.endsWith('/wp/files/write'));
|
|
107
|
-
assert.strictEqual(writeCall!.body.confirm_token, undefined, 'phase 1 must NOT send a confirm_token');
|
|
108
|
-
|
|
109
|
-
// Phase 2 — relay the real token → executes.
|
|
110
|
-
const executed = await getHandler('dailey_wp_files')({ project: 'proj_wp1', action: 'write', path: '/style.css', content: 'body{color:red}', confirm_token: 'tok_abc123' });
|
|
111
|
-
const parsed = JSON.parse(executed.content[0].text);
|
|
112
|
-
assert.strictEqual(parsed.ok, true);
|
|
113
|
-
assert.strictEqual(parsed.snapshot_id, 'snap_1');
|
|
114
|
-
assert.strictEqual(parsed.confirm_token_used, 'tok_abc123');
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
test('dailey_wp_media upload is two-phase', async (t) => {
|
|
118
|
-
const mock = makeApiMock();
|
|
119
|
-
t.mock.module('../src/api.js', { namedExports: mock.namedExports });
|
|
120
|
-
|
|
121
|
-
const { registerWordPressLiveEditTools } = await import('../src/tools/wordpress-live-edit.js?t=media');
|
|
122
|
-
const { server, getHandler } = makeFakeServer();
|
|
123
|
-
registerWordPressLiveEditTools(server as any);
|
|
124
|
-
|
|
125
|
-
const preview = await getHandler('dailey_wp_media')({ project: 'proj_wp1', action: 'upload', filename: 'logo.png', content_base64: 'AAAA' });
|
|
126
|
-
assert.match(preview.content[0].text, /PREVIEW ONLY/);
|
|
127
|
-
assert.match(preview.content[0].text, /confirm_token: tok_abc123/);
|
|
128
|
-
|
|
129
|
-
const executed = await getHandler('dailey_wp_media')({ project: 'proj_wp1', action: 'upload', filename: 'logo.png', content_base64: 'AAAA', confirm_token: 'tok_abc123' });
|
|
130
|
-
const parsed = JSON.parse(executed.content[0].text);
|
|
131
|
-
assert.strictEqual(parsed.ok, true);
|
|
132
|
-
assert.strictEqual(parsed.active_account, 'self');
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
test('dailey_wp_cli read-only runs immediately; write is two-phase', async (t) => {
|
|
136
|
-
const mock = makeApiMock();
|
|
137
|
-
t.mock.module('../src/api.js', { namedExports: mock.namedExports });
|
|
138
|
-
|
|
139
|
-
const { registerWordPressLiveEditTools } = await import('../src/tools/wordpress-live-edit.js?t=cli');
|
|
140
|
-
const { server, getHandler } = makeFakeServer();
|
|
141
|
-
registerWordPressLiveEditTools(server as any);
|
|
142
|
-
|
|
143
|
-
// read-only: no allow_write → executes immediately
|
|
144
|
-
const read = await getHandler('dailey_wp_cli')({ project: 'proj_wp1', args: ['option', 'get', 'siteurl'] });
|
|
145
|
-
const readParsed = JSON.parse(read.content[0].text);
|
|
146
|
-
assert.strictEqual(readParsed.exit_code, 0);
|
|
147
|
-
assert.strictEqual(readParsed.write, false);
|
|
148
|
-
assert.strictEqual(mock.calls[0].body.args[0], 'option');
|
|
149
|
-
|
|
150
|
-
// write: allow_write true, no token → preview
|
|
151
|
-
const preview = await getHandler('dailey_wp_cli')({ project: 'proj_wp1', args: ['plugin', 'activate', 'akismet'], allow_write: true });
|
|
152
|
-
assert.match(preview.content[0].text, /PREVIEW ONLY/);
|
|
153
|
-
assert.match(preview.content[0].text, /confirm_token: tok_abc123/);
|
|
154
|
-
|
|
155
|
-
// write with token → executes
|
|
156
|
-
const executed = await getHandler('dailey_wp_cli')({ project: 'proj_wp1', args: ['plugin', 'activate', 'akismet'], allow_write: true, confirm_token: 'tok_abc123' });
|
|
157
|
-
const parsed = JSON.parse(executed.content[0].text);
|
|
158
|
-
assert.strictEqual(parsed.ok, true);
|
|
159
|
-
});
|
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
import { test } from 'node:test';
|
|
2
|
-
import assert from 'node:assert';
|
|
3
|
-
|
|
4
|
-
// Minimal fake McpServer: registerWordPressTargetingTools calls
|
|
5
|
-
// server.tool(name, description, schema, handler) three times — capture the
|
|
6
|
-
// handler for each tool by name.
|
|
7
|
-
function makeFakeServer() {
|
|
8
|
-
const handlers = new Map<string, (args: any) => Promise<{ content: Array<{ type: 'text'; text: string }> }>>();
|
|
9
|
-
const server = {
|
|
10
|
-
tool: (name: string, _desc: string, _schema: unknown, h: (args: any) => any) => {
|
|
11
|
-
handlers.set(name, h);
|
|
12
|
-
},
|
|
13
|
-
};
|
|
14
|
-
return { server, getHandler: (name: string) => handlers.get(name)! };
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// Shared active-account state so setActiveAccount/getActiveAccount behave like
|
|
18
|
-
// the real session-scoped store while under mock.
|
|
19
|
-
function makeApiMock() {
|
|
20
|
-
const calls: Array<{ method: string; path: string; body?: unknown }> = [];
|
|
21
|
-
let active: string | undefined;
|
|
22
|
-
return {
|
|
23
|
-
calls,
|
|
24
|
-
getActive: () => active,
|
|
25
|
-
namedExports: {
|
|
26
|
-
apiRequest: async (method: string, path: string, body?: unknown) => {
|
|
27
|
-
calls.push({ method, path, body });
|
|
28
|
-
if (path === '/projects') {
|
|
29
|
-
return { ok: true, status: 200, data: { id: 'proj_wp1', name: (body as any).name, slug: 'my-blog', status: 'pending', repo_url: (body as any).repo_url, build_id: 'b1' } };
|
|
30
|
-
}
|
|
31
|
-
if (path === '/projects/wp/list') {
|
|
32
|
-
return { ok: true, status: 200, data: { projects: [
|
|
33
|
-
{ project_id: 'proj_wp1', slug: 'my-blog', domain: 'my-blog.dailey.cloud', env: 'prod', db_name: 'wp_myblog', namespace: 'cust-abc', active_account: active ?? null },
|
|
34
|
-
] } };
|
|
35
|
-
}
|
|
36
|
-
if (path === '/projects/wp/resolve?ref=my-blog') {
|
|
37
|
-
return { ok: true, status: 200, data: { project_id: 'proj_wp1', slug: 'my-blog', domain: 'my-blog.dailey.cloud', env: 'prod', db_name: 'wp_myblog', namespace: 'cust-abc', active_account: active ?? null } };
|
|
38
|
-
}
|
|
39
|
-
if (path === '/projects/wp/resolve?ref=ghost') {
|
|
40
|
-
return { ok: false, status: 404, data: { error: 'not found' } };
|
|
41
|
-
}
|
|
42
|
-
throw new Error(`unexpected apiRequest call: ${method} ${path}`);
|
|
43
|
-
},
|
|
44
|
-
formatError: (res: any) => JSON.stringify(res),
|
|
45
|
-
textResult: (text: string) => ({ content: [{ type: 'text' as const, text }] }),
|
|
46
|
-
jsonResult: (data: unknown) => ({ content: [{ type: 'text' as const, text: JSON.stringify(data, null, 2) }] }),
|
|
47
|
-
getActiveAccount: () => active,
|
|
48
|
-
setActiveAccount: (v: string | undefined) => { active = v && v.trim() ? v.trim() : undefined; },
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
test('dailey_create_wordpress POSTs /projects with the hardened WP catalog body and returns admin URL + account', async (t) => {
|
|
54
|
-
const mock = makeApiMock();
|
|
55
|
-
t.mock.module('../src/api.js', { namedExports: mock.namedExports });
|
|
56
|
-
|
|
57
|
-
const { registerWordPressTargetingTools } = await import('../src/tools/wordpress-targeting.js?t=create');
|
|
58
|
-
const { server, getHandler } = makeFakeServer();
|
|
59
|
-
registerWordPressTargetingTools(server as any);
|
|
60
|
-
|
|
61
|
-
const result = await getHandler('dailey_create_wordpress')({ name: 'My Blog', account: 'acme' });
|
|
62
|
-
const text = result.content[0].text;
|
|
63
|
-
|
|
64
|
-
const post = mock.calls.find((c) => c.path === '/projects');
|
|
65
|
-
assert.ok(post, 'must POST /projects');
|
|
66
|
-
assert.deepStrictEqual(post!.body, {
|
|
67
|
-
name: 'My Blog',
|
|
68
|
-
repo_url: 'wordpress',
|
|
69
|
-
needs_database: true,
|
|
70
|
-
needs_storage: true,
|
|
71
|
-
});
|
|
72
|
-
assert.match(text, /https:\/\/my-blog\.dailey\.cloud\/wp-admin/);
|
|
73
|
-
assert.match(text, /WORDPRESS_ADMIN_PASSWORD/);
|
|
74
|
-
assert.match(text, /Account:\s+acme/, 'surfaces the effective account');
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
test('dailey_wp_list calls GET /projects/wp/list and surfaces active_account + projects', async (t) => {
|
|
78
|
-
const mock = makeApiMock();
|
|
79
|
-
t.mock.module('../src/api.js', { namedExports: mock.namedExports });
|
|
80
|
-
|
|
81
|
-
const { registerWordPressTargetingTools } = await import('../src/tools/wordpress-targeting.js?t=list');
|
|
82
|
-
const { server, getHandler } = makeFakeServer();
|
|
83
|
-
registerWordPressTargetingTools(server as any);
|
|
84
|
-
|
|
85
|
-
const result = await getHandler('dailey_wp_list')({ account: 'acme' });
|
|
86
|
-
const parsed = JSON.parse(result.content[0].text);
|
|
87
|
-
|
|
88
|
-
assert.deepStrictEqual(mock.calls.map((c) => `${c.method} ${c.path}`), ['GET /projects/wp/list']);
|
|
89
|
-
assert.strictEqual(parsed.active_account, 'acme');
|
|
90
|
-
assert.strictEqual(parsed.count, 1);
|
|
91
|
-
assert.strictEqual(parsed.projects[0].slug, 'my-blog');
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
test('dailey_wp_target echoes the resolved identity for a valid ref', async (t) => {
|
|
95
|
-
const mock = makeApiMock();
|
|
96
|
-
t.mock.module('../src/api.js', { namedExports: mock.namedExports });
|
|
97
|
-
|
|
98
|
-
const { registerWordPressTargetingTools } = await import('../src/tools/wordpress-targeting.js?t=target-ok');
|
|
99
|
-
const { server, getHandler } = makeFakeServer();
|
|
100
|
-
registerWordPressTargetingTools(server as any);
|
|
101
|
-
|
|
102
|
-
const result = await getHandler('dailey_wp_target')({ project: 'my-blog' });
|
|
103
|
-
const parsed = JSON.parse(result.content[0].text);
|
|
104
|
-
|
|
105
|
-
assert.strictEqual(parsed.resolved, true);
|
|
106
|
-
assert.strictEqual(parsed.target.project_id, 'proj_wp1');
|
|
107
|
-
assert.strictEqual(parsed.target.db_name, 'wp_myblog');
|
|
108
|
-
assert.strictEqual(parsed.target.domain, 'my-blog.dailey.cloud');
|
|
109
|
-
assert.match(parsed.confirm, /db=wp_myblog/);
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
test('dailey_wp_target returns a clear not-found on 404 pointing at dailey_wp_list', async (t) => {
|
|
113
|
-
const mock = makeApiMock();
|
|
114
|
-
t.mock.module('../src/api.js', { namedExports: mock.namedExports });
|
|
115
|
-
|
|
116
|
-
const { registerWordPressTargetingTools } = await import('../src/tools/wordpress-targeting.js?t=target-404');
|
|
117
|
-
const { server, getHandler } = makeFakeServer();
|
|
118
|
-
registerWordPressTargetingTools(server as any);
|
|
119
|
-
|
|
120
|
-
const result = await getHandler('dailey_wp_target')({ project: 'ghost', account: 'acme' });
|
|
121
|
-
const parsed = JSON.parse(result.content[0].text);
|
|
122
|
-
|
|
123
|
-
assert.strictEqual(parsed.resolved, false);
|
|
124
|
-
assert.strictEqual(parsed.active_account, 'acme');
|
|
125
|
-
assert.match(parsed.message, /No WordPress project matching 'ghost'/);
|
|
126
|
-
assert.match(parsed.message, /dailey_wp_list/);
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Regression guard for the 2026-08-07 outage.
|
|
131
|
-
*
|
|
132
|
-
* `repo_url` is what deploy-service resolves the catalog template from on EVERY
|
|
133
|
-
* deploy — the MySQL env, the persistent wp-content volume, the backup sidecar and
|
|
134
|
-
* the Recreate strategy all hang off that lookup. It must be the catalog SLUG.
|
|
135
|
-
*
|
|
136
|
-
* It was previously the image ref `wordpress:6-apache`, matched by comparing image
|
|
137
|
-
* repositories. When the catalog image was repointed to
|
|
138
|
-
* `registry.dailey.cloud/catalog/wordpress:6-apache-wpcli` on 2026-07-13, the
|
|
139
|
-
* repositories stopped matching, the lookup returned null, and every WordPress site
|
|
140
|
-
* created afterwards came up as a generic stateless app — no volume, no
|
|
141
|
-
* WORDPRESS_DB_*, no wp-cli — serving the installer.
|
|
142
|
-
*
|
|
143
|
-
* The assertion above used to pin the image ref, so it stayed green throughout.
|
|
144
|
-
* This test states the actual invariant instead: never send an image ref here.
|
|
145
|
-
*/
|
|
146
|
-
test('dailey_create_wordpress sends the catalog SLUG, never an image ref (repoint-proof)', async (t) => {
|
|
147
|
-
const mock = makeApiMock();
|
|
148
|
-
t.mock.module('../src/api.js', { namedExports: mock.namedExports });
|
|
149
|
-
|
|
150
|
-
const { registerWordPressTargetingTools } = await import('../src/tools/wordpress-targeting.js?t=slug');
|
|
151
|
-
const { server, getHandler } = makeFakeServer();
|
|
152
|
-
registerWordPressTargetingTools(server as any);
|
|
153
|
-
|
|
154
|
-
await getHandler('dailey_create_wordpress')({ name: 'Shop' });
|
|
155
|
-
|
|
156
|
-
const post = mock.calls.find((c) => c.path === '/projects');
|
|
157
|
-
const repoUrl = (post!.body as any).repo_url as string;
|
|
158
|
-
|
|
159
|
-
assert.strictEqual(repoUrl, 'wordpress', 'must be the catalog slug');
|
|
160
|
-
assert.ok(!repoUrl.includes(':'), 'a tag means an image ref was sent, not a slug');
|
|
161
|
-
assert.ok(!repoUrl.includes('/'), 'a registry path means an image ref was sent, not a slug');
|
|
162
|
-
});
|