@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.
Files changed (164) hide show
  1. package/dist/api.d.ts +7 -0
  2. package/dist/api.d.ts.map +1 -1
  3. package/dist/api.js +23 -2
  4. package/dist/api.js.map +1 -1
  5. package/dist/index.js +24 -17
  6. package/dist/index.js.map +1 -1
  7. package/dist/tools/accounts.d.ts.map +1 -1
  8. package/dist/tools/accounts.js +3 -2
  9. package/dist/tools/accounts.js.map +1 -1
  10. package/dist/tools/ai.d.ts.map +1 -1
  11. package/dist/tools/ai.js +7 -1
  12. package/dist/tools/ai.js.map +1 -1
  13. package/dist/tools/auth.d.ts.map +1 -1
  14. package/dist/tools/auth.js +25 -6
  15. package/dist/tools/auth.js.map +1 -1
  16. package/dist/tools/backups.d.ts.map +1 -1
  17. package/dist/tools/backups.js +3 -1
  18. package/dist/tools/backups.js.map +1 -1
  19. package/dist/tools/build-logs.d.ts.map +1 -1
  20. package/dist/tools/build-logs.js +3 -1
  21. package/dist/tools/build-logs.js.map +1 -1
  22. package/dist/tools/credentials-reveal.d.ts.map +1 -1
  23. package/dist/tools/credentials-reveal.js +3 -1
  24. package/dist/tools/credentials-reveal.js.map +1 -1
  25. package/dist/tools/dailey-images.js +3 -3
  26. package/dist/tools/dailey-images.js.map +1 -1
  27. package/dist/tools/db-migrate.js +5 -5
  28. package/dist/tools/db-migrate.js.map +1 -1
  29. package/dist/tools/db.d.ts.map +1 -1
  30. package/dist/tools/db.js +17 -1
  31. package/dist/tools/db.js.map +1 -1
  32. package/dist/tools/deploy-status.d.ts.map +1 -1
  33. package/dist/tools/deploy-status.js +3 -1
  34. package/dist/tools/deploy-status.js.map +1 -1
  35. package/dist/tools/deploy.d.ts.map +1 -1
  36. package/dist/tools/deploy.js +9 -1
  37. package/dist/tools/deploy.js.map +1 -1
  38. package/dist/tools/domains.d.ts.map +1 -1
  39. package/dist/tools/domains.js +3 -1
  40. package/dist/tools/domains.js.map +1 -1
  41. package/dist/tools/email.d.ts.map +1 -1
  42. package/dist/tools/email.js +8 -2
  43. package/dist/tools/email.js.map +1 -1
  44. package/dist/tools/env.d.ts.map +1 -1
  45. package/dist/tools/env.js +5 -1
  46. package/dist/tools/env.js.map +1 -1
  47. package/dist/tools/environments.js +3 -3
  48. package/dist/tools/environments.js.map +1 -1
  49. package/dist/tools/exec-run.d.ts.map +1 -1
  50. package/dist/tools/exec-run.js +7 -1
  51. package/dist/tools/exec-run.js.map +1 -1
  52. package/dist/tools/images.d.ts.map +1 -1
  53. package/dist/tools/images.js +5 -1
  54. package/dist/tools/images.js.map +1 -1
  55. package/dist/tools/lifecycle.d.ts.map +1 -1
  56. package/dist/tools/lifecycle.js +5 -1
  57. package/dist/tools/lifecycle.js.map +1 -1
  58. package/dist/tools/links.d.ts.map +1 -1
  59. package/dist/tools/links.js +3 -1
  60. package/dist/tools/links.js.map +1 -1
  61. package/dist/tools/platform.d.ts.map +1 -1
  62. package/dist/tools/platform.js +5 -3
  63. package/dist/tools/platform.js.map +1 -1
  64. package/dist/tools/processes.d.ts.map +1 -1
  65. package/dist/tools/processes.js +11 -1
  66. package/dist/tools/processes.js.map +1 -1
  67. package/dist/tools/projects.d.ts.map +1 -1
  68. package/dist/tools/projects.js +36 -12
  69. package/dist/tools/projects.js.map +1 -1
  70. package/dist/tools/resource-config.d.ts.map +1 -1
  71. package/dist/tools/resource-config.js +3 -1
  72. package/dist/tools/resource-config.js.map +1 -1
  73. package/dist/tools/scale.d.ts.map +1 -1
  74. package/dist/tools/scale.js +3 -1
  75. package/dist/tools/scale.js.map +1 -1
  76. package/dist/tools/storage.d.ts.map +1 -1
  77. package/dist/tools/storage.js +11 -1
  78. package/dist/tools/storage.js.map +1 -1
  79. package/dist/tools/support.d.ts.map +1 -1
  80. package/dist/tools/support.js +3 -1
  81. package/dist/tools/support.js.map +1 -1
  82. package/dist/tools/usage.d.ts.map +1 -1
  83. package/dist/tools/usage.js +3 -1
  84. package/dist/tools/usage.js.map +1 -1
  85. package/dist/tools/wordpress-import.d.ts.map +1 -1
  86. package/dist/tools/wordpress-import.js +3 -1
  87. package/dist/tools/wordpress-import.js.map +1 -1
  88. package/dist/tools/wordpress-migrate.d.ts.map +1 -1
  89. package/dist/tools/wordpress-migrate.js +3 -1
  90. package/dist/tools/wordpress-migrate.js.map +1 -1
  91. package/dist/tools/wordpress-snapshot.d.ts.map +1 -1
  92. package/dist/tools/wordpress-snapshot.js +9 -1
  93. package/dist/tools/wordpress-snapshot.js.map +1 -1
  94. package/package.json +10 -2
  95. package/.dockerignore +0 -6
  96. package/.github/workflows/publish.yml +0 -120
  97. package/Dockerfile +0 -19
  98. package/claude-config.json +0 -13
  99. package/docs/superpowers/plans/2026-08-09-remote-mcp-endpoint.md +0 -663
  100. package/docs/superpowers/specs/2026-08-09-remote-mcp-endpoint-design.md +0 -66
  101. package/src/api.ts +0 -263
  102. package/src/context.ts +0 -12
  103. package/src/http.ts +0 -160
  104. package/src/index.ts +0 -94
  105. package/src/server.ts +0 -188
  106. package/src/tools/accounts.ts +0 -119
  107. package/src/tools/addons.ts +0 -124
  108. package/src/tools/admin.ts +0 -42
  109. package/src/tools/ai.ts +0 -83
  110. package/src/tools/analyze.ts +0 -108
  111. package/src/tools/auth.ts +0 -177
  112. package/src/tools/backups.ts +0 -84
  113. package/src/tools/billing.ts +0 -34
  114. package/src/tools/build-logs.ts +0 -65
  115. package/src/tools/bundle.ts +0 -129
  116. package/src/tools/cli.ts +0 -76
  117. package/src/tools/credentials-reveal.ts +0 -64
  118. package/src/tools/credits.ts +0 -97
  119. package/src/tools/dailey-images.ts +0 -151
  120. package/src/tools/db-migrate.ts +0 -211
  121. package/src/tools/db.ts +0 -391
  122. package/src/tools/deploy-status.ts +0 -247
  123. package/src/tools/deploy.ts +0 -101
  124. package/src/tools/diagnose.ts +0 -567
  125. package/src/tools/domains.ts +0 -156
  126. package/src/tools/email.ts +0 -101
  127. package/src/tools/env.ts +0 -205
  128. package/src/tools/environments.ts +0 -138
  129. package/src/tools/exec-run.ts +0 -91
  130. package/src/tools/images.ts +0 -221
  131. package/src/tools/lifecycle.ts +0 -75
  132. package/src/tools/links.ts +0 -69
  133. package/src/tools/platform.ts +0 -209
  134. package/src/tools/processes.ts +0 -182
  135. package/src/tools/project-transfer.ts +0 -129
  136. package/src/tools/projects.ts +0 -287
  137. package/src/tools/resource-config.ts +0 -84
  138. package/src/tools/scale.ts +0 -33
  139. package/src/tools/storage.ts +0 -281
  140. package/src/tools/support.ts +0 -42
  141. package/src/tools/usage.ts +0 -128
  142. package/src/tools/wordpress-import.ts +0 -174
  143. package/src/tools/wordpress-live-edit.ts +0 -250
  144. package/src/tools/wordpress-migrate.ts +0 -104
  145. package/src/tools/wordpress-snapshot.ts +0 -225
  146. package/src/tools/wordpress-targeting.ts +0 -188
  147. package/src/upload.ts +0 -35
  148. package/src/version.ts +0 -70
  149. package/test/context.test.ts +0 -36
  150. package/test/http.test.ts +0 -103
  151. package/test/server-surface.test.ts +0 -36
  152. package/test/use-account-sticky.test.ts +0 -28
  153. package/test/wordpress-import.test.ts +0 -223
  154. package/test/wordpress-live-edit.test.ts +0 -159
  155. package/test/wordpress-targeting.test.ts +0 -162
  156. package/tests/dailey-images.test.mjs +0 -156
  157. package/tests/environments.test.mjs +0 -230
  158. package/tests/mcp-protocol-smoke.mjs +0 -149
  159. package/tests/new-tools-smoke.mjs +0 -217
  160. package/tests/pack1-mcp-preflight.test.mjs +0 -184
  161. package/tests/pack6-smoke.mjs +0 -222
  162. package/tests/wp-snapshot-labels.test.mjs +0 -21
  163. package/tests/wp-snapshot.test.mjs +0 -261
  164. package/tsconfig.json +0 -19
@@ -1,217 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Smoke test for the v1.1.0 MCP tools.
4
- *
5
- * Exercises every new tool against a real Dailey OS account, reports
6
- * pass/fail per tool. Does NOT mutate (no deploys, no deletes, no creates).
7
- * Looks for a project to test against — if none exists, skips project-
8
- * scoped tests.
9
- *
10
- * Usage:
11
- * DAILEY_EMAIL=... DAILEY_PASSWORD=... node tests/new-tools-smoke.mjs
12
- */
13
-
14
- const API_URL = process.env.DAILEY_API_URL || 'https://os.dailey.cloud/api';
15
- const EMAIL = process.env.DAILEY_EMAIL;
16
- const PASSWORD = process.env.DAILEY_PASSWORD;
17
-
18
- if (!EMAIL || !PASSWORD) {
19
- console.error('DAILEY_EMAIL and DAILEY_PASSWORD must be set');
20
- process.exit(1);
21
- }
22
-
23
- let token = '';
24
-
25
- async function login() {
26
- const res = await fetch(`${API_URL}/customers/login`, {
27
- method: 'POST',
28
- headers: { 'Content-Type': 'application/json' },
29
- body: JSON.stringify({ email: EMAIL, password: PASSWORD }),
30
- });
31
- if (!res.ok) throw new Error(`login failed: ${res.status}`);
32
- const data = await res.json();
33
- token = data.access_token;
34
- return data;
35
- }
36
-
37
- async function call(method, path, body) {
38
- const opts = {
39
- method,
40
- headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' },
41
- };
42
- if (body) opts.body = JSON.stringify(body);
43
- const res = await fetch(`${API_URL}${path}`, opts);
44
- const text = await res.text();
45
- let data;
46
- try { data = JSON.parse(text); } catch { data = text; }
47
- return { status: res.status, ok: res.ok, data };
48
- }
49
-
50
- const results = [];
51
- function report(name, passed, detail) {
52
- const icon = passed ? '✓' : '✗';
53
- const line = `${icon} ${name}${detail ? ` — ${detail}` : ''}`;
54
- console.log(line);
55
- results.push({ name, passed, detail });
56
- }
57
-
58
- async function test(name, fn) {
59
- try {
60
- const detail = await fn();
61
- report(name, true, detail);
62
- } catch (err) {
63
- report(name, false, err.message);
64
- }
65
- }
66
-
67
- async function main() {
68
- console.log(`Dailey MCP smoke test against ${API_URL}`);
69
- console.log('─'.repeat(60));
70
-
71
- const login_data = await login();
72
- console.log(`Authed as ${login_data.customer?.email || EMAIL}`);
73
- console.log('');
74
-
75
- // Find a project to test against
76
- const projects = await call('GET', '/projects');
77
- if (!projects.ok || !projects.data.projects?.length) {
78
- console.log('No projects found — skipping project-scoped tests');
79
- process.exit(0);
80
- }
81
- const project = projects.data.projects[0];
82
- console.log(`Testing against project: ${project.name} (${project.id})`);
83
- console.log('');
84
-
85
- // Endpoints backing the new MCP tools
86
- await test('dailey_deploy_status', async () => {
87
- const r = await call('GET', `/projects/${project.id}/deploy-status`);
88
- if (!r.ok) throw new Error(`HTTP ${r.status}: ${JSON.stringify(r.data)}`);
89
- return `mode=${r.data.mode}, can_deploy=${r.data.can_deploy}`;
90
- });
91
-
92
- await test('dailey_build_logs (builds list)', async () => {
93
- const r = await call('GET', `/projects/${project.id}/deploys`);
94
- if (!r.ok) throw new Error(`HTTP ${r.status}`);
95
- return `${r.data.builds?.length ?? 0} builds`;
96
- });
97
-
98
- await test('dailey_build_logs (fetch log)', async () => {
99
- const list = await call('GET', `/projects/${project.id}/deploys`);
100
- if (!list.ok) throw new Error(`list HTTP ${list.status}`);
101
- const latest = list.data.builds?.[0];
102
- if (!latest) return 'no builds — skipped';
103
- const r = await call('GET', `/builds/${latest.id}`);
104
- if (!r.ok) throw new Error(`HTTP ${r.status}`);
105
- const logLen = (r.data.log || '').length;
106
- return `build ${latest.id} status=${r.data.status} log=${logLen} bytes`;
107
- });
108
-
109
- await test('dailey_processes', async () => {
110
- const r = await call('GET', `/projects/${project.id}/processes`);
111
- if (!r.ok) throw new Error(`HTTP ${r.status}: ${JSON.stringify(r.data)}`);
112
- return `${r.data.processes?.length ?? 0} processes`;
113
- });
114
-
115
- await test('dailey_pause/resume (dry — read state)', async () => {
116
- // Don't actually pause a prod project. Just verify route exists and
117
- // project is valid by hitting deploy-status (which we already did).
118
- return `skipped mutation — route /pause,/resume exist per code audit`;
119
- });
120
-
121
- await test('dailey_backups (list)', async () => {
122
- const r = await call('GET', `/projects/${project.id}/backups`);
123
- if (!r.ok) throw new Error(`HTTP ${r.status}: ${JSON.stringify(r.data)}`);
124
- return `${r.data.backups?.length ?? 0} backups`;
125
- });
126
-
127
- await test('dailey_resource_config (get)', async () => {
128
- const r = await call('GET', `/projects/${project.id}/resource-config`);
129
- if (!r.ok) throw new Error(`HTTP ${r.status}: ${JSON.stringify(r.data)}`);
130
- return `cpu=${r.data.cpu}, mem=${r.data.memory_mb}MB`;
131
- });
132
-
133
- await test('dailey_service_links (list)', async () => {
134
- const r = await call('GET', `/projects/${project.id}/links`);
135
- if (!r.ok) throw new Error(`HTTP ${r.status}: ${JSON.stringify(r.data)}`);
136
- return `${r.data.links?.length ?? 0} links`;
137
- });
138
-
139
- await test('dailey_domains (list)', async () => {
140
- const r = await call('GET', `/projects/${project.id}/domains`);
141
- if (!r.ok) throw new Error(`HTTP ${r.status}: ${JSON.stringify(r.data)}`);
142
- return `${r.data.domains?.length ?? 0} domains`;
143
- });
144
-
145
- // DNS check requires a real domain — try one if any exists
146
- const domainList = await call('GET', `/projects/${project.id}/domains`);
147
- // Skip the default *.dailey.cloud domain — dns_check rejects those.
148
- const customDomain = domainList.ok
149
- ? domainList.data.domains?.find((x) => !x.is_default)
150
- : null;
151
- if (customDomain) {
152
- const d = customDomain.hostname;
153
- await test(`dailey_domains dns_check (${d})`, async () => {
154
- const r = await call('GET', `/projects/${project.id}/domains/dns-check?domain=${encodeURIComponent(d)}`);
155
- if (!r.ok) throw new Error(`HTTP ${r.status}: ${JSON.stringify(r.data)}`);
156
- return `matched=${r.data.matched}, type=${r.data.match_type}`;
157
- });
158
-
159
- await test(`dailey_domains cert_status (${d})`, async () => {
160
- const r = await call('GET', `/projects/${project.id}/domains/cert-status?domain=${encodeURIComponent(d)}`);
161
- if (!r.ok) throw new Error(`HTTP ${r.status}: ${JSON.stringify(r.data)}`);
162
- return `status=${r.data.status}`;
163
- });
164
- } else {
165
- console.log('⊘ dailey_domains dns_check / cert_status — no custom domains on test project (default only)');
166
- }
167
-
168
- await test('dailey_analyze_repo (docker image)', async () => {
169
- const r = await call('POST', '/projects/analyze', { repo_url: 'nginx:alpine' });
170
- if (!r.ok) throw new Error(`HTTP ${r.status}: ${JSON.stringify(r.data)}`);
171
- return `_isDockerImage=${r.data._isDockerImage}, issues=${r.data.issues?.length || 0}`;
172
- });
173
-
174
- await test('dailey_db_validate (dry)', async () => {
175
- // Does project have a DB? check db info first.
176
- const info = await call('GET', `/projects/${project.id}/database`);
177
- if (!info.ok || info.data?.status === 'not-configured') return `no DB provisioned — skipped`;
178
- const r = await call('POST', `/projects/${project.id}/database/validate`, {
179
- sql: 'CREATE TABLE IF NOT EXISTS _mcp_smoke_test (id INT);',
180
- });
181
- // Pack 4 fix: when a project has no managed DB, the API returns 400
182
- // with a friendly "no managed database" error. Treat that as a skip,
183
- // not a test failure.
184
- if (r.status === 400 && typeof r.data?.error === 'string' && /no managed database/i.test(r.data.error)) {
185
- return `no DB — skipped`;
186
- }
187
- if (!r.ok) throw new Error(`HTTP ${r.status}: ${JSON.stringify(r.data)}`);
188
- return `valid=${r.data.valid}, warnings=${r.data.has_warnings}`;
189
- });
190
-
191
- await test('dailey_db_tunnel (list)', async () => {
192
- const r = await call('GET', `/projects/${project.id}/database/tunnel`);
193
- if (!r.ok) throw new Error(`HTTP ${r.status}: ${JSON.stringify(r.data)}`);
194
- return `${r.data.sessions?.length ?? 0} active sessions`;
195
- });
196
-
197
- // Summary
198
- console.log('');
199
- console.log('─'.repeat(60));
200
- const passed = results.filter((r) => r.passed).length;
201
- const failed = results.filter((r) => !r.passed).length;
202
- console.log(`Passed: ${passed} Failed: ${failed} Total: ${results.length}`);
203
- if (failed > 0) {
204
- console.log('');
205
- console.log('Failures:');
206
- for (const r of results.filter((x) => !x.passed)) {
207
- console.log(` ✗ ${r.name}: ${r.detail}`);
208
- }
209
- process.exit(1);
210
- }
211
- process.exit(0);
212
- }
213
-
214
- main().catch((err) => {
215
- console.error('TEST CRASH:', err);
216
- process.exit(2);
217
- });
@@ -1,184 +0,0 @@
1
- /**
2
- * EOS #47 — dailey-mcp preflight / stdio-TTY banner + JSON-RPC error.
3
- *
4
- * Three paths:
5
- *
6
- * 1. non-TTY + no creds → JSON-RPC 2.0 notification on stdout + stderr
7
- * + exit code 1
8
- * 2. TTY + no creds → stderr banner with "This is an MCP stdio server"
9
- * + exit code 1
10
- * 3. TTY + creds → short "MCP stdio server running" banner + stays
11
- * running (kill after grace period)
12
- *
13
- * TTY is spawned via `unbuffer` (expect tools) when available — Node child-
14
- * process piped stdio is NON-TTY by default. If unbuffer is missing,
15
- * path (2) is documented rather than skipped silently.
16
- *
17
- * Run:
18
- * node tests/pack1-mcp-preflight.test.mjs
19
- * or
20
- * node --test tests/pack1-mcp-preflight.test.mjs
21
- */
22
-
23
- import { test, describe } from 'node:test';
24
- import assert from 'node:assert/strict';
25
- import { spawn, spawnSync } from 'node:child_process';
26
- import { join, dirname } from 'node:path';
27
- import { fileURLToPath } from 'node:url';
28
- import { existsSync, mkdtempSync } from 'node:fs';
29
- import { tmpdir } from 'node:os';
30
-
31
- const __dirname = dirname(fileURLToPath(import.meta.url));
32
- const BINARY = join(__dirname, '..', 'dist', 'index.js');
33
-
34
- function unbufferAvailable() {
35
- const r = spawnSync('sh', ['-c', 'command -v unbuffer']);
36
- return r.status === 0 && String(r.stdout).trim().length > 0;
37
- }
38
-
39
- /**
40
- * Spawn the MCP server with a controlled environment. Returns a promise that
41
- * resolves with { code, stdout, stderr } once the process exits OR the
42
- * waitMs timeout fires (in which case we kill it and set code=null).
43
- */
44
- function runMcp({ env = {}, tty = false, waitMs = 4000, closeStdin = true }) {
45
- return new Promise((resolve) => {
46
- // Isolate HOME + XDG_CONFIG_HOME to an empty temp dir so the server's
47
- // readCliStoredToken() (added in 1.13.2) can't pick up the CLI token of
48
- // whoever runs the test — otherwise the "no creds" cases aren't actually
49
- // cred-less on a machine with a logged-in Dailey CLI.
50
- const isolatedHome = mkdtempSync(join(tmpdir(), 'dailey-mcp-test-'));
51
- const cleanEnv = {
52
- // Drop the parent's credentials unless explicitly restored below.
53
- PATH: process.env.PATH,
54
- HOME: isolatedHome,
55
- XDG_CONFIG_HOME: join(isolatedHome, '.config'),
56
- NODE_PATH: process.env.NODE_PATH,
57
- ...env,
58
- };
59
-
60
- let child;
61
- if (tty) {
62
- if (!unbufferAvailable()) {
63
- resolve({ code: -1, stdout: '', stderr: 'unbuffer-not-available', skipped: true });
64
- return;
65
- }
66
- // unbuffer allocates a pty on stdout (but NOT stdin). For `stdin.isTTY`,
67
- // we use `script` if available — or we fall back to a node wrapper that
68
- // forces process.stdin.isTTY = true before requiring the real binary.
69
- // Simplest cross-platform: use a small wrapper file that stamps the TTY
70
- // flag and then dynamically imports the real entry.
71
- child = spawn(
72
- 'node',
73
- ['-e', `process.stdin.isTTY = true; process.stdout.isTTY = true; await import(${JSON.stringify(BINARY)});`],
74
- { env: cleanEnv, stdio: ['pipe', 'pipe', 'pipe'] },
75
- );
76
- } else {
77
- child = spawn('node', [BINARY], { env: cleanEnv, stdio: ['pipe', 'pipe', 'pipe'] });
78
- }
79
-
80
- let stdout = '';
81
- let stderr = '';
82
- child.stdout.on('data', (c) => { stdout += c.toString(); });
83
- child.stderr.on('data', (c) => { stderr += c.toString(); });
84
-
85
- const timer = setTimeout(() => {
86
- try { child.kill('SIGTERM'); } catch {}
87
- }, waitMs);
88
-
89
- child.on('close', (code) => {
90
- clearTimeout(timer);
91
- setImmediate(() => resolve({ code, stdout, stderr, killed: false }));
92
- });
93
- child.on('error', (err) => {
94
- clearTimeout(timer);
95
- resolve({ code: -1, stdout, stderr: stderr + '\n' + err.message, error: true });
96
- });
97
-
98
- if (closeStdin) {
99
- // Close stdin so the server doesn't block waiting for input.
100
- try { child.stdin.end(); } catch {}
101
- }
102
- });
103
- }
104
-
105
- describe('EOS #47 — MCP preflight', { concurrency: false }, () => {
106
- test('binary exists at dist/index.js (has been built)', () => {
107
- assert.ok(existsSync(BINARY), `binary not found at ${BINARY} — run \`npm run build\` first`);
108
- });
109
-
110
- test('non-TTY + no creds → JSON-RPC notifications/message on stdout + stderr + exit 1', async () => {
111
- const r = await runMcp({
112
- env: { /* no DAILEY_* */ },
113
- tty: false,
114
- waitMs: 4000,
115
- });
116
-
117
- assert.equal(r.code, 1, `expected exit code 1, got ${r.code} (stderr: ${r.stderr.slice(0, 200)})`);
118
-
119
- // Stdout must contain a valid JSON-RPC 2.0 notification
120
- const line = r.stdout.split('\n').map((l) => l.trim()).find((l) => l.length > 0);
121
- assert.ok(line, `expected at least one stdout line, got empty (stderr: ${r.stderr.slice(0, 200)})`);
122
- let parsed;
123
- try { parsed = JSON.parse(line); } catch (err) {
124
- assert.fail(`stdout line is not JSON: ${line.slice(0, 200)}`);
125
- }
126
- assert.equal(parsed.jsonrpc, '2.0', `expected jsonrpc=2.0, got ${parsed.jsonrpc}`);
127
- assert.equal(parsed.method, 'notifications/message', `expected method=notifications/message, got ${parsed.method}`);
128
- assert.equal(parsed.params?.level, 'error');
129
- assert.match(parsed.params?.data || '', /credentials/i);
130
-
131
- // Stderr must also carry the message (so shell users see something)
132
- assert.match(r.stderr, /dailey-mcp/i, 'stderr should mention dailey-mcp');
133
- assert.match(r.stderr, /credentials/i, 'stderr should mention missing credentials');
134
- });
135
-
136
- test('TTY + no creds → stderr banner with "This is an MCP stdio server" + exit 1', async () => {
137
- const r = await runMcp({
138
- env: { /* no DAILEY_* */ },
139
- tty: true,
140
- waitMs: 4000,
141
- });
142
-
143
- if (r.skipped) {
144
- assert.fail(
145
- 'TTY case could not be executed in this environment (no `unbuffer`). ' +
146
- 'Manual verification: run `node dist/index.js` from an interactive terminal ' +
147
- 'with no DAILEY_* env set; expect the long banner + exit 1.'
148
- );
149
- return;
150
- }
151
-
152
- assert.equal(r.code, 1, `expected exit code 1, got ${r.code}`);
153
- assert.match(r.stderr, /This is an MCP stdio server/, 'stderr must contain the TTY banner');
154
- assert.match(r.stderr, /Missing credentials/i, 'stderr must mention Missing credentials');
155
- // Long banner should NOT produce JSON on stdout in TTY mode
156
- assert.equal(r.stdout.trim(), '', 'TTY-no-creds path should NOT emit JSON-RPC on stdout');
157
- });
158
-
159
- test('TTY + creds → short "MCP stdio server running" banner, process keeps running', async () => {
160
- // We don't actually need real creds to hit the success-branch banner —
161
- // `hasCredentials()` checks env vars only.
162
- const r = await runMcp({
163
- env: { DAILEY_API_TOKEN: 'fake-token-for-preflight-test-only' },
164
- tty: true,
165
- waitMs: 2500,
166
- closeStdin: false,
167
- });
168
-
169
- if (r.skipped) {
170
- assert.fail(
171
- 'TTY case could not be executed in this environment (no `unbuffer`). ' +
172
- 'Manual verification: run `DAILEY_API_TOKEN=x node dist/index.js` from an ' +
173
- 'interactive terminal; expect the short "MCP stdio server running" banner ' +
174
- 'and the process stays alive until Ctrl+C.'
175
- );
176
- return;
177
- }
178
-
179
- // Killed by our SIGTERM — exit code should NOT be 1 (that's the preflight-fail code).
180
- // node w/ SIGTERM typically exits with code null or 143.
181
- assert.notEqual(r.code, 1, `server should not exit 1 when creds are present, got ${r.code} (stderr: ${r.stderr.slice(0, 200)})`);
182
- assert.match(r.stderr, /MCP stdio server running/, `stderr should contain short banner. Got: ${r.stderr.slice(0, 300)}`);
183
- });
184
- });
@@ -1,222 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Pack 6 smoke test — dailey_diagnose tool + remediation hints.
4
- *
5
- * Two layers:
6
- * 1. Pure-unit: verify remediationFor() returns the right hint for known
7
- * status codes and error patterns. No network needed.
8
- * 2. End-to-end: spawn the MCP stdio server, list tools, call
9
- * dailey_diagnose against a real project, parse the JSON output.
10
- *
11
- * Usage:
12
- * DAILEY_EMAIL=... DAILEY_PASSWORD=... node tests/pack6-smoke.mjs
13
- */
14
- import { spawn } from 'node:child_process';
15
- import path from 'node:path';
16
-
17
- const here = path.resolve(new URL('.', import.meta.url).pathname);
18
- const binary = path.resolve(here, '..', 'dist/index.js');
19
-
20
- // ── Layer 1: remediationFor unit checks ─────────────────────────────
21
- const { remediationFor } = await import(path.resolve(here, '..', 'dist/api.js'));
22
-
23
- let unitPassed = 0;
24
- let unitFailed = 0;
25
- function unit(name, predicate) {
26
- if (predicate) {
27
- console.log(` ✓ ${name}`);
28
- unitPassed++;
29
- } else {
30
- console.log(` ✗ ${name}`);
31
- unitFailed++;
32
- }
33
- }
34
-
35
- console.log('Unit: remediationFor()');
36
- unit('423 → account-locked hint', /account locked/i.test(remediationFor(423, {}) || ''));
37
- unit('429 → rate-limited hint', /rate limited|retry-after/i.test(remediationFor(429, {}) || ''));
38
- unit('401 → token hint', /token expired|dailey login/i.test(remediationFor(401, {}) || ''));
39
- unit('403 → token hint', /token expired|dailey login/i.test(remediationFor(403, {}) || ''));
40
- unit('502 → unreachable hint', /unreachable/i.test(remediationFor(502, {}) || ''));
41
- unit(
42
- 'AlreadyExists registry → retry hint',
43
- /retry .dailey_deploy./i.test(
44
- remediationFor(500, { error: 'AlreadyExists: blob upload to registry failed' }) || '',
45
- ),
46
- );
47
- unit(
48
- 'SignatureDoesNotMatch → storage refresh',
49
- /storage.*refresh|24h/i.test(
50
- remediationFor(403, { error: 'SignatureDoesNotMatch on PUT' }) || '',
51
- ),
52
- );
53
- unit(
54
- 'CrashLoopBackOff → app_logs',
55
- /app_logs/i.test(remediationFor(500, { error: 'pod CrashLoopBackOff' }) || ''),
56
- );
57
- unit(
58
- 'ENOTFOUND → unreachable',
59
- /unreachable/i.test(remediationFor(0, 'fetch failed: ENOTFOUND os.dailey.cloud') || ''),
60
- );
61
- unit('200 → no hint', remediationFor(200, {}) === null);
62
- unit('404 unrecognized → no hint', remediationFor(404, { error: 'Project not found' }) === null);
63
-
64
- console.log('');
65
-
66
- // ── Layer 2: end-to-end MCP smoke ───────────────────────────────────
67
- const env = {
68
- ...process.env,
69
- DAILEY_API_URL: process.env.DAILEY_API_URL || 'https://os.dailey.cloud/api',
70
- DAILEY_EMAIL: process.env.DAILEY_EMAIL,
71
- DAILEY_PASSWORD: process.env.DAILEY_PASSWORD,
72
- };
73
-
74
- if (!env.DAILEY_EMAIL || !env.DAILEY_PASSWORD) {
75
- console.log('(skip e2e — DAILEY_EMAIL/DAILEY_PASSWORD not set)');
76
- process.exit(unitFailed === 0 ? 0 : 1);
77
- }
78
-
79
- const child = spawn('node', [binary], { env, stdio: ['pipe', 'pipe', 'pipe'] });
80
- let nextId = 1;
81
- const pending = new Map();
82
- let buffer = '';
83
-
84
- child.stdout.on('data', (chunk) => {
85
- buffer += chunk.toString();
86
- const lines = buffer.split('\n');
87
- buffer = lines.pop();
88
- for (const line of lines) {
89
- if (!line.trim()) continue;
90
- try {
91
- const msg = JSON.parse(line);
92
- if (msg.id && pending.has(msg.id)) {
93
- const { resolve } = pending.get(msg.id);
94
- pending.delete(msg.id);
95
- resolve(msg);
96
- }
97
- } catch {}
98
- }
99
- });
100
-
101
- child.stderr.on('data', (chunk) => {
102
- // Quiet — but surface unexpected stack traces
103
- const s = chunk.toString();
104
- if (/error|throw|TypeError/i.test(s)) process.stderr.write(`[mcp] ${s}`);
105
- });
106
-
107
- function send(method, params, timeoutMs = 30000) {
108
- return new Promise((resolve, reject) => {
109
- const id = nextId++;
110
- pending.set(id, { resolve, reject });
111
- child.stdin.write(JSON.stringify({ jsonrpc: '2.0', id, method, params }) + '\n');
112
- setTimeout(() => {
113
- if (pending.has(id)) {
114
- pending.delete(id);
115
- reject(new Error(`Timeout waiting for ${method}`));
116
- }
117
- }, timeoutMs);
118
- });
119
- }
120
-
121
- let e2ePassed = 0;
122
- let e2eFailed = 0;
123
- function e2e(name, predicate, detail) {
124
- if (predicate) {
125
- console.log(` ✓ ${name}${detail ? ' — ' + detail : ''}`);
126
- e2ePassed++;
127
- } else {
128
- console.log(` ✗ ${name}${detail ? ' — ' + detail : ''}`);
129
- e2eFailed++;
130
- }
131
- }
132
-
133
- try {
134
- console.log('E2E: MCP stdio server');
135
- await send('initialize', {
136
- protocolVersion: '2024-11-05',
137
- capabilities: {},
138
- clientInfo: { name: 'pack6-smoke', version: '1.0.0' },
139
- });
140
- child.stdin.write(JSON.stringify({ jsonrpc: '2.0', method: 'notifications/initialized' }) + '\n');
141
-
142
- const toolsMsg = await send('tools/list', {});
143
- const tools = toolsMsg.result?.tools || [];
144
- const names = new Set(tools.map((t) => t.name));
145
- e2e('dailey_diagnose registered', names.has('dailey_diagnose'), `${tools.length} tools total`);
146
-
147
- // Find a project to diagnose
148
- const listMsg = await send('tools/call', { name: 'dailey_list_projects', arguments: {} });
149
- const listText = listMsg.result?.content?.[0]?.text || '';
150
- // Format: lines after divider; first column is the UUID. Pick the first.
151
- const idMatch = listText.match(/^([0-9a-f]{8}-[0-9a-f-]+)/m);
152
- if (!idMatch) {
153
- console.log(' ⊘ no project to diagnose — skipping invocation tests');
154
- } else {
155
- const projectId = idMatch[1];
156
- const slugMatch = listText.match(new RegExp(`^${projectId}\\s+\\S+\\s+(\\S+)`, 'm'));
157
- const slug = slugMatch?.[1];
158
- console.log(` Using project: ${projectId}${slug ? ' (slug: ' + slug + ')' : ''}`);
159
-
160
- // by ID
161
- const byId = await send(
162
- 'tools/call',
163
- { name: 'dailey_diagnose', arguments: { project: projectId } },
164
- 60000,
165
- );
166
- const byIdText = byId.result?.content?.[0]?.text || '';
167
- let byIdJson = null;
168
- try { byIdJson = JSON.parse(byIdText); } catch {}
169
- e2e('dailey_diagnose by ID returns valid JSON', !!byIdJson);
170
- e2e(
171
- 'has top-level summary',
172
- typeof byIdJson?.summary === 'string' && byIdJson.summary.length > 0,
173
- byIdJson?.summary?.slice(0, 60),
174
- );
175
- e2e(
176
- 'verdict is healthy/degraded/broken',
177
- ['healthy', 'degraded', 'broken'].includes(byIdJson?.verdict),
178
- byIdJson?.verdict,
179
- );
180
- e2e('has 6 lane checks', byIdJson && Object.keys(byIdJson.checks || {}).length === 6);
181
- e2e('matched_by=id', byIdJson?.matched_by === 'id');
182
-
183
- // by slug (if we found one)
184
- if (slug) {
185
- const bySlug = await send(
186
- 'tools/call',
187
- { name: 'dailey_diagnose', arguments: { project: slug } },
188
- 60000,
189
- );
190
- const bySlugText = bySlug.result?.content?.[0]?.text || '';
191
- let bySlugJson = null;
192
- try { bySlugJson = JSON.parse(bySlugText); } catch {}
193
- e2e('dailey_diagnose by slug returns valid JSON', !!bySlugJson);
194
- e2e('matched_by=slug', bySlugJson?.matched_by === 'slug');
195
- e2e('resolved to same project_id', bySlugJson?.project_id === projectId);
196
- }
197
-
198
- // bogus → broken with hint
199
- const bogus = await send(
200
- 'tools/call',
201
- { name: 'dailey_diagnose', arguments: { project: 'definitely-not-a-real-slug-xyz123' } },
202
- 30000,
203
- );
204
- const bogusText = bogus.result?.content?.[0]?.text || '';
205
- let bogusJson = null;
206
- try { bogusJson = JSON.parse(bogusText); } catch {}
207
- e2e('bogus slug → verdict=broken', bogusJson?.verdict === 'broken');
208
- e2e('bogus slug → matched_by=none', bogusJson?.matched_by === 'none');
209
- }
210
-
211
- child.kill();
212
- } catch (err) {
213
- console.error('E2E CRASH:', err.message);
214
- child.kill();
215
- e2eFailed++;
216
- }
217
-
218
- console.log('');
219
- console.log('─'.repeat(60));
220
- console.log(`Unit: ${unitPassed} passed, ${unitFailed} failed`);
221
- console.log(`E2E: ${e2ePassed} passed, ${e2eFailed} failed`);
222
- process.exit(unitFailed + e2eFailed === 0 ? 0 : 1);
@@ -1,21 +0,0 @@
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
- });