@vespermcp/mcp-server 1.2.21 → 1.2.24
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/README.md +49 -0
- package/build/cache/service.js +7 -0
- package/build/cloud/adapters/supabase.js +49 -0
- package/build/cloud/storage-manager.js +6 -0
- package/build/export/exporter.js +22 -9
- package/build/gateway/unified-dataset-gateway.js +441 -0
- package/build/index.js +1815 -839
- package/build/ingestion/ingestor.js +7 -4
- package/build/install/install-service.js +11 -6
- package/build/lib/supabase.js +3 -0
- package/build/metadata/arxiv-source.js +229 -0
- package/build/metadata/circuit-breaker.js +62 -0
- package/build/metadata/github-source.js +203 -0
- package/build/metadata/hackernews-source.js +123 -0
- package/build/metadata/quality.js +27 -0
- package/build/metadata/scraper.js +85 -14
- package/build/metadata/semantic-scholar-source.js +138 -0
- package/build/python/asset_downloader_engine.py +2 -0
- package/build/python/convert_engine.py +92 -0
- package/build/python/export_engine.py +45 -0
- package/build/python/kaggle_engine.py +77 -5
- package/build/python/normalize_engine.py +83 -0
- package/build/python/vesper/core/asset_downloader.py +5 -1
- package/build/scripts/test-phase1-webcore-quality.js +104 -0
- package/build/search/engine.js +45 -6
- package/build/search/jit-orchestrator.js +18 -14
- package/build/search/query-intent.js +509 -0
- package/build/tools/formatter.js +6 -3
- package/build/utils/python-runtime.js +130 -0
- package/build/web/extract-web.js +297 -0
- package/build/web/fusion-engine.js +457 -0
- package/build/web/types.js +1 -0
- package/build/web/web-core.js +242 -0
- package/package.json +12 -5
- package/scripts/postinstall.cjs +87 -31
- package/scripts/wizard.cjs +652 -0
- package/scripts/wizard.js +338 -12
- package/src/python/__pycache__/config.cpython-312.pyc +0 -0
- package/src/python/__pycache__/kaggle_engine.cpython-312.pyc +0 -0
- package/src/python/asset_downloader_engine.py +2 -0
- package/src/python/convert_engine.py +92 -0
- package/src/python/export_engine.py +45 -0
- package/src/python/kaggle_engine.py +77 -5
- package/src/python/normalize_engine.py +83 -0
- package/src/python/requirements.txt +12 -0
- package/src/python/vesper/core/asset_downloader.py +5 -1
- package/wizard.cjs +3 -0
|
@@ -0,0 +1,652 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// ─────────────────────────────────────────────────────────────
|
|
4
|
+
// vesper-wizard — Zero-friction local setup for Vesper MCP
|
|
5
|
+
// Run: npx vesper-wizard@latest
|
|
6
|
+
// ─────────────────────────────────────────────────────────────
|
|
7
|
+
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
const path = require('path');
|
|
10
|
+
const os = require('os');
|
|
11
|
+
const crypto = require('crypto');
|
|
12
|
+
const { execSync, spawnSync } = require('child_process');
|
|
13
|
+
const http = require('http');
|
|
14
|
+
const https = require('https');
|
|
15
|
+
const readline = require('readline');
|
|
16
|
+
|
|
17
|
+
// ── Paths ────────────────────────────────────────────────────
|
|
18
|
+
const HOME = os.homedir();
|
|
19
|
+
const VESPER_DIR = path.join(HOME, '.vesper');
|
|
20
|
+
const CONFIG_TOML = path.join(VESPER_DIR, 'config.toml');
|
|
21
|
+
const CONFIG_JSON = path.join(VESPER_DIR, 'config.json');
|
|
22
|
+
const DATA_DIR = path.join(VESPER_DIR, 'data');
|
|
23
|
+
const IS_WIN = process.platform === 'win32';
|
|
24
|
+
const APPDATA = process.env.APPDATA || path.join(HOME, 'AppData', 'Roaming');
|
|
25
|
+
|
|
26
|
+
// ── Helpers ──────────────────────────────────────────────────
|
|
27
|
+
function ensureDir(dir) {
|
|
28
|
+
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function generateLocalKey() {
|
|
32
|
+
const random = crypto.randomBytes(24).toString('hex');
|
|
33
|
+
return `vesper_sk_local_${random}`;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function readToml(filePath) {
|
|
37
|
+
if (!fs.existsSync(filePath)) return {};
|
|
38
|
+
const content = fs.readFileSync(filePath, 'utf8');
|
|
39
|
+
const obj = {};
|
|
40
|
+
for (const line of content.split('\n')) {
|
|
41
|
+
const m = line.match(/^\s*(\w+)\s*=\s*"(.*)"\s*$/);
|
|
42
|
+
if (m) obj[m[1]] = m[2];
|
|
43
|
+
}
|
|
44
|
+
return obj;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function writeToml(filePath, data) {
|
|
48
|
+
ensureDir(path.dirname(filePath));
|
|
49
|
+
const lines = Object.entries(data).map(([k, v]) => `${k} = "${v}"`);
|
|
50
|
+
fs.writeFileSync(filePath, lines.join('\n') + '\n', 'utf8');
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function readWizardState() {
|
|
54
|
+
if (!fs.existsSync(CONFIG_JSON)) return {};
|
|
55
|
+
try {
|
|
56
|
+
const content = fs.readFileSync(CONFIG_JSON, 'utf8').trim();
|
|
57
|
+
return content ? JSON.parse(content) : {};
|
|
58
|
+
} catch {
|
|
59
|
+
return {};
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function writeWizardState(state) {
|
|
64
|
+
ensureDir(path.dirname(CONFIG_JSON));
|
|
65
|
+
fs.writeFileSync(CONFIG_JSON, JSON.stringify(state, null, 2), 'utf8');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function hasCompletedOnboarding() {
|
|
69
|
+
const state = readWizardState();
|
|
70
|
+
return state.onboardingCompleted === true;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function markOnboardingCompleted() {
|
|
74
|
+
const state = readWizardState();
|
|
75
|
+
state.onboardingCompleted = true;
|
|
76
|
+
writeWizardState(state);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function dim(text) { return `\x1b[2m${text}\x1b[0m`; }
|
|
80
|
+
function bold(text) { return `\x1b[1m${text}\x1b[0m`; }
|
|
81
|
+
function green(text) { return `\x1b[32m${text}\x1b[0m`; }
|
|
82
|
+
function cyan(text) { return `\x1b[36m${text}\x1b[0m`; }
|
|
83
|
+
function yellow(text) { return `\x1b[33m${text}\x1b[0m`; }
|
|
84
|
+
function red(text) { return `\x1b[31m${text}\x1b[0m`; }
|
|
85
|
+
function magenta(text) { return `\x1b[35m${text}\x1b[0m`; }
|
|
86
|
+
|
|
87
|
+
// ── Vesper API URL resolution ────────────────────────────────
|
|
88
|
+
const VESPER_API_URL = process.env.VESPER_API_URL || '';
|
|
89
|
+
const DEFAULT_VESPER_API_CANDIDATES = [
|
|
90
|
+
'https://getvesper.dev',
|
|
91
|
+
'http://localhost:3000',
|
|
92
|
+
'http://127.0.0.1:3000',
|
|
93
|
+
];
|
|
94
|
+
|
|
95
|
+
// ── Device Auth Helpers ──────────────────────────────────────
|
|
96
|
+
function httpJson(method, url, body) {
|
|
97
|
+
return new Promise((resolve, reject) => {
|
|
98
|
+
const parsed = new URL(url);
|
|
99
|
+
const lib = parsed.protocol === 'https:' ? https : http;
|
|
100
|
+
const opts = {
|
|
101
|
+
method,
|
|
102
|
+
hostname: parsed.hostname,
|
|
103
|
+
port: parsed.port || (parsed.protocol === 'https:' ? 443 : 80),
|
|
104
|
+
path: parsed.pathname + parsed.search,
|
|
105
|
+
headers: { 'Content-Type': 'application/json' },
|
|
106
|
+
};
|
|
107
|
+
const req = lib.request(opts, (res) => {
|
|
108
|
+
let data = '';
|
|
109
|
+
res.on('data', (chunk) => (data += chunk));
|
|
110
|
+
res.on('end', () => {
|
|
111
|
+
try { resolve({ status: res.statusCode, body: JSON.parse(data) }); }
|
|
112
|
+
catch { resolve({ status: res.statusCode, body: data }); }
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
req.on('error', reject);
|
|
116
|
+
if (body) req.write(JSON.stringify(body));
|
|
117
|
+
req.end();
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
async function probeDeviceAuth(baseUrl) {
|
|
122
|
+
try {
|
|
123
|
+
const res = await httpJson('POST', `${baseUrl}/api/auth/device/start`);
|
|
124
|
+
if (res.status === 201 && !!res.body && !!res.body.code) {
|
|
125
|
+
return { baseUrl, status: 'ready', response: res.body };
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (res.status === 503 && res.body && res.body.requiresSetup) {
|
|
129
|
+
return {
|
|
130
|
+
baseUrl,
|
|
131
|
+
status: 'setup-required',
|
|
132
|
+
response: res.body,
|
|
133
|
+
message: res.body.error || 'Auth storage is not initialized.',
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return {
|
|
138
|
+
baseUrl,
|
|
139
|
+
status: 'unreachable',
|
|
140
|
+
response: res.body,
|
|
141
|
+
message: typeof res.body === 'string' ? res.body : JSON.stringify(res.body),
|
|
142
|
+
};
|
|
143
|
+
} catch (error) {
|
|
144
|
+
return {
|
|
145
|
+
baseUrl,
|
|
146
|
+
status: 'unreachable',
|
|
147
|
+
message: error && error.message ? error.message : 'Request failed',
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
async function resolveVesperApiBaseUrl() {
|
|
153
|
+
const candidates = VESPER_API_URL
|
|
154
|
+
? [VESPER_API_URL]
|
|
155
|
+
: DEFAULT_VESPER_API_CANDIDATES;
|
|
156
|
+
|
|
157
|
+
let setupRequiredProbe = null;
|
|
158
|
+
|
|
159
|
+
for (const candidate of candidates) {
|
|
160
|
+
const probe = await probeDeviceAuth(candidate);
|
|
161
|
+
if (probe.status === 'ready') {
|
|
162
|
+
return probe;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (!setupRequiredProbe && probe.status === 'setup-required') {
|
|
166
|
+
setupRequiredProbe = probe;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return setupRequiredProbe;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function openBrowser(url) {
|
|
174
|
+
try {
|
|
175
|
+
if (process.platform === 'win32') {
|
|
176
|
+
spawnSync('cmd', ['/c', 'start', '', url], { stdio: 'ignore' });
|
|
177
|
+
} else if (process.platform === 'darwin') {
|
|
178
|
+
spawnSync('open', [url], { stdio: 'ignore' });
|
|
179
|
+
} else {
|
|
180
|
+
spawnSync('xdg-open', [url], { stdio: 'ignore' });
|
|
181
|
+
}
|
|
182
|
+
} catch { /* browser open is best-effort */ }
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function isInteractiveTerminal() {
|
|
186
|
+
return Boolean(process.stdin && process.stdin.isTTY && process.stdout && process.stdout.isTTY);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function askYesNo(question) {
|
|
190
|
+
return new Promise((resolve) => {
|
|
191
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
192
|
+
rl.question(` ${question} ${dim('[Y/n]')} `, (answer) => {
|
|
193
|
+
rl.close();
|
|
194
|
+
resolve(!answer || answer.toLowerCase().startsWith('y'));
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function askInput(question) {
|
|
200
|
+
return new Promise((resolve) => {
|
|
201
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
202
|
+
rl.question(` ${question} `, (answer) => {
|
|
203
|
+
rl.close();
|
|
204
|
+
resolve(String(answer || '').trim());
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
async function askChoice(question, choices, defaultValue) {
|
|
210
|
+
console.log(` ${question}`);
|
|
211
|
+
choices.forEach((choice, index) => {
|
|
212
|
+
console.log(` ${dim(String(index + 1) + ')')} ${choice.label}`);
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
const prompt = defaultValue ? `${dim('[default: ' + defaultValue + ']')}` : '';
|
|
216
|
+
const answer = await askInput(`${prompt} ${cyan('→')} Choose an option:`);
|
|
217
|
+
if (!answer && defaultValue) {
|
|
218
|
+
return defaultValue;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
const numeric = Number(answer);
|
|
222
|
+
if (Number.isFinite(numeric) && numeric >= 1 && numeric <= choices.length) {
|
|
223
|
+
return choices[numeric - 1].value;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const matched = choices.find((choice) => choice.value === answer);
|
|
227
|
+
return matched ? matched.value : defaultValue;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function isCloudApiKey(value) {
|
|
231
|
+
return !!value && value.startsWith('vesper_sk_') && !value.startsWith('vesper_sk_local_');
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
async function promptForManualApiKey() {
|
|
235
|
+
console.log(`\n ${cyan('■')} ${bold('Manual API Key')}`);
|
|
236
|
+
console.log(` ${dim('Paste a Vesper cloud API key. It will be stored locally in config.toml.\n')}`);
|
|
237
|
+
|
|
238
|
+
while (true) {
|
|
239
|
+
const value = await askInput(`${cyan('→')} Vesper API key:`);
|
|
240
|
+
if (isCloudApiKey(value)) {
|
|
241
|
+
return value;
|
|
242
|
+
}
|
|
243
|
+
console.log(` ${yellow('!')} ${yellow('Expected a Vesper key starting with vesper_sk_')}`);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
async function chooseAuthMode(existingKey, existingAuthMode) {
|
|
248
|
+
const hasExistingKey = !!existingKey;
|
|
249
|
+
if (hasExistingKey) {
|
|
250
|
+
console.log(` ${dim('Current key:')} ${dim(existingKey.slice(0, 24) + '...')}`);
|
|
251
|
+
console.log(` ${dim('Current mode:')} ${dim(existingAuthMode || (isCloudApiKey(existingKey) ? 'cloud' : 'local_unified'))}`);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
const choices = [];
|
|
255
|
+
choices.push({ value: 'browser', label: 'Sign in through the browser' });
|
|
256
|
+
choices.push({ value: 'manual', label: 'Provide Vesper API key manually' });
|
|
257
|
+
|
|
258
|
+
return await askChoice(`${cyan('→')} How do you want to authenticate Vesper?`, choices, 'browser');
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
async function deviceAuthFlow() {
|
|
262
|
+
console.log(`\n ${cyan('■')} ${bold('Device Authentication')}`);
|
|
263
|
+
console.log(` ${dim('Link your CLI to a Vesper account for cloud features\n')}`);
|
|
264
|
+
|
|
265
|
+
const resolvedApiBaseUrl = await resolveVesperApiBaseUrl();
|
|
266
|
+
if (!resolvedApiBaseUrl) {
|
|
267
|
+
console.log(` ${red('✗')} ${red('Could not reach any Vesper auth endpoint.')}`);
|
|
268
|
+
console.log(` ${dim('Tried:')} ${dim((VESPER_API_URL ? [VESPER_API_URL] : DEFAULT_VESPER_API_CANDIDATES).join(', '))}`);
|
|
269
|
+
console.log(` ${dim('If your landing app is running locally, start it on http://localhost:3000 or set VESPER_API_URL.')}`);
|
|
270
|
+
console.log(` ${dim('Falling back to manual key entry.\n')}`);
|
|
271
|
+
return null;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
if (resolvedApiBaseUrl.status === 'setup-required') {
|
|
275
|
+
console.log(` ${yellow('!')} ${yellow('Reached Vesper auth endpoint, but local auth storage is not initialized.')}`);
|
|
276
|
+
console.log(` ${dim('Endpoint:')} ${dim(resolvedApiBaseUrl.baseUrl)}`);
|
|
277
|
+
console.log(` ${dim('Reason:')} ${dim(resolvedApiBaseUrl.message || 'Apply Supabase migrations first.')}`);
|
|
278
|
+
console.log(` ${dim('Run the SQL in supabase/migrations/001_device_auth.sql and 002_rate_limits.sql, then retry.')}`);
|
|
279
|
+
console.log(` ${dim('Falling back to manual key entry.\n')}`);
|
|
280
|
+
return null;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
console.log(` ${dim('Auth endpoint:')} ${dim(resolvedApiBaseUrl.baseUrl)}\n`);
|
|
284
|
+
|
|
285
|
+
// Step 1: Call /api/auth/device/start
|
|
286
|
+
process.stdout.write(` ${dim('Requesting device code...')}`);
|
|
287
|
+
let startRes;
|
|
288
|
+
try {
|
|
289
|
+
startRes = await httpJson('POST', `${resolvedApiBaseUrl.baseUrl}/api/auth/device/start`);
|
|
290
|
+
} catch (err) {
|
|
291
|
+
console.log(` ${red('✗')}`);
|
|
292
|
+
console.log(` ${red('Could not reach Vesper API at')} ${dim(resolvedApiBaseUrl.baseUrl)}`);
|
|
293
|
+
console.log(` ${dim('Falling back to manual key entry.\n')}`);
|
|
294
|
+
return null;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
if (startRes.status !== 201 || !startRes.body.code) {
|
|
298
|
+
console.log(` ${red('✗')}`);
|
|
299
|
+
console.log(` ${red('Unexpected response:')} ${dim(JSON.stringify(startRes.body))}`);
|
|
300
|
+
return null;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
const { code, loginUrl } = startRes.body;
|
|
304
|
+
console.log(` ${green('✓')}\n`);
|
|
305
|
+
|
|
306
|
+
// Step 2: Display code and open browser
|
|
307
|
+
console.log(` ┌───────────────────────────────────────────────┐`);
|
|
308
|
+
console.log(` │ │`);
|
|
309
|
+
console.log(` │ ${bold('Your device code:')} ${cyan(bold(code))} │`);
|
|
310
|
+
console.log(` │ │`);
|
|
311
|
+
console.log(` │ ${dim('Open this URL to sign in:')} │`);
|
|
312
|
+
console.log(` │ ${cyan(loginUrl.padEnd(41))}│`);
|
|
313
|
+
console.log(` │ │`);
|
|
314
|
+
console.log(` └───────────────────────────────────────────────┘\n`);
|
|
315
|
+
|
|
316
|
+
const shouldAutoOpenBrowser = process.env.VESPER_WIZARD_AUTO_OPEN !== '0';
|
|
317
|
+
if (shouldAutoOpenBrowser) {
|
|
318
|
+
openBrowser(loginUrl);
|
|
319
|
+
if (!hasCompletedOnboarding()) {
|
|
320
|
+
markOnboardingCompleted();
|
|
321
|
+
}
|
|
322
|
+
console.log(` ${dim('Browser opened automatically for device auth.')}`);
|
|
323
|
+
} else {
|
|
324
|
+
console.log(` ${dim('Browser auto-open disabled via VESPER_WIZARD_AUTO_OPEN=0. Open the URL manually to continue.')}`);
|
|
325
|
+
}
|
|
326
|
+
console.log(` ${dim('Waiting for you to sign in...')}\n`);
|
|
327
|
+
|
|
328
|
+
// Step 3: Poll until confirmed or expired
|
|
329
|
+
const POLL_INTERVAL = 3000; // 3 seconds
|
|
330
|
+
const MAX_POLLS = 200; // 10 min max (200 × 3s)
|
|
331
|
+
let polls = 0;
|
|
332
|
+
const spinner = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
|
333
|
+
|
|
334
|
+
while (polls < MAX_POLLS) {
|
|
335
|
+
polls++;
|
|
336
|
+
const frame = spinner[polls % spinner.length];
|
|
337
|
+
process.stdout.write(`\r ${cyan(frame)} Polling... (${polls})`);
|
|
338
|
+
|
|
339
|
+
try {
|
|
340
|
+
const pollRes = await httpJson('GET', `${resolvedApiBaseUrl.baseUrl}/api/auth/device/poll?code=${code}`);
|
|
341
|
+
|
|
342
|
+
if (pollRes.body.status === 'confirmed' && pollRes.body.apiKey) {
|
|
343
|
+
process.stdout.write(`\r ${green('✓')} Device authenticated! \n`);
|
|
344
|
+
console.log(` ${dim('Email:')} ${pollRes.body.email || 'linked'}`);
|
|
345
|
+
return pollRes.body.apiKey;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
if (pollRes.body.status === 'expired') {
|
|
349
|
+
process.stdout.write(`\r ${red('✗')} Device code expired. \n`);
|
|
350
|
+
console.log(` ${dim('Run the wizard again to get a new code.')}`);
|
|
351
|
+
return null;
|
|
352
|
+
}
|
|
353
|
+
} catch {
|
|
354
|
+
// Network hiccup — keep polling
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
await new Promise((r) => setTimeout(r, POLL_INTERVAL));
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
process.stdout.write(`\r ${red('✗')} Timed out waiting for authentication.\n`);
|
|
361
|
+
return null;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
function printBanner() {
|
|
365
|
+
console.log(`
|
|
366
|
+
${dim('─────────────────────────────────────────────────')}
|
|
367
|
+
|
|
368
|
+
${bold('██ ██ ███████ ███████ ██████ ███████ ██████')}
|
|
369
|
+
${bold('██ ██ ██ ██ ██ ██ ██ ██ ██')}
|
|
370
|
+
${bold('██ ██ █████ ███████ ██████ █████ ██████')}
|
|
371
|
+
${bold(' ██ ██ ██ ██ ██ ██ ██ ██')}
|
|
372
|
+
${bold(' ████ ███████ ███████ ██ ███████ ██ ██')}
|
|
373
|
+
|
|
374
|
+
${cyan('dataset intelligence layer')}
|
|
375
|
+
${dim('local-first • zero-config • agent-native')}
|
|
376
|
+
|
|
377
|
+
${dim('─────────────────────────────────────────────────')}
|
|
378
|
+
`);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
// ── MCP Auto-Config ──────────────────────────────────────────
|
|
382
|
+
function getAllAgentConfigs() {
|
|
383
|
+
const isMac = process.platform === 'darwin';
|
|
384
|
+
return [
|
|
385
|
+
{
|
|
386
|
+
name: 'Claude Code',
|
|
387
|
+
path: path.join(HOME, '.claude.json'),
|
|
388
|
+
format: 'mcpServers',
|
|
389
|
+
},
|
|
390
|
+
{
|
|
391
|
+
name: 'Claude Desktop',
|
|
392
|
+
path: IS_WIN
|
|
393
|
+
? path.join(APPDATA, 'Claude', 'claude_desktop_config.json')
|
|
394
|
+
: isMac
|
|
395
|
+
? path.join(HOME, 'Library', 'Application Support', 'Claude', 'claude_desktop_config.json')
|
|
396
|
+
: path.join(HOME, '.config', 'claude', 'claude_desktop_config.json'),
|
|
397
|
+
format: 'mcpServers',
|
|
398
|
+
},
|
|
399
|
+
{
|
|
400
|
+
name: 'Cursor',
|
|
401
|
+
path: path.join(HOME, '.cursor', 'mcp.json'),
|
|
402
|
+
format: 'mcpServers',
|
|
403
|
+
},
|
|
404
|
+
{
|
|
405
|
+
name: 'VS Code',
|
|
406
|
+
path: IS_WIN
|
|
407
|
+
? path.join(APPDATA, 'Code', 'User', 'mcp.json')
|
|
408
|
+
: isMac
|
|
409
|
+
? path.join(HOME, 'Library', 'Application Support', 'Code', 'User', 'mcp.json')
|
|
410
|
+
: path.join(HOME, '.config', 'Code', 'User', 'mcp.json'),
|
|
411
|
+
format: 'servers',
|
|
412
|
+
},
|
|
413
|
+
{
|
|
414
|
+
name: 'Codex',
|
|
415
|
+
path: path.join(HOME, '.codex', 'config.toml'),
|
|
416
|
+
format: 'toml',
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
name: 'Gemini CLI',
|
|
420
|
+
path: path.join(HOME, '.gemini', 'settings.json'),
|
|
421
|
+
format: 'mcpServers',
|
|
422
|
+
},
|
|
423
|
+
];
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
function installMcpToAgent(agent) {
|
|
427
|
+
const npxCmd = IS_WIN ? 'npx.cmd' : 'npx';
|
|
428
|
+
const serverEntry = { command: npxCmd, args: ['-y', '-p', '@vespermcp/mcp-server@latest', 'vespermcp'] };
|
|
429
|
+
|
|
430
|
+
try {
|
|
431
|
+
if (agent.format === 'toml') {
|
|
432
|
+
let content = fs.existsSync(agent.path) ? fs.readFileSync(agent.path, 'utf8') : '';
|
|
433
|
+
if (content.includes('[mcp_servers.vesper]')) return true;
|
|
434
|
+
ensureDir(path.dirname(agent.path));
|
|
435
|
+
content += `\n[mcp_servers.vesper]\ncommand = "${serverEntry.command}"\nargs = [${serverEntry.args.map(a => `"${a}"`).join(', ')}]\n`;
|
|
436
|
+
fs.writeFileSync(agent.path, content, 'utf8');
|
|
437
|
+
return true;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
let config = {};
|
|
441
|
+
if (fs.existsSync(agent.path)) {
|
|
442
|
+
try { config = JSON.parse(fs.readFileSync(agent.path, 'utf8').trim() || '{}'); } catch { config = {}; }
|
|
443
|
+
} else {
|
|
444
|
+
ensureDir(path.dirname(agent.path));
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
const key = agent.format === 'servers' ? 'servers' : 'mcpServers';
|
|
448
|
+
if (!config[key]) config[key] = {};
|
|
449
|
+
|
|
450
|
+
const entry = agent.format === 'servers'
|
|
451
|
+
? { type: 'stdio', ...serverEntry }
|
|
452
|
+
: serverEntry;
|
|
453
|
+
|
|
454
|
+
config[key].vesper = entry;
|
|
455
|
+
fs.writeFileSync(agent.path, JSON.stringify(config, null, 2), 'utf8');
|
|
456
|
+
return true;
|
|
457
|
+
} catch {
|
|
458
|
+
return false;
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
// ── Server Health Check ──────────────────────────────────────
|
|
463
|
+
async function checkServerHealth() {
|
|
464
|
+
try {
|
|
465
|
+
// Quick stdio check — spawn server and see if it responds
|
|
466
|
+
const result = spawnSync(IS_WIN ? 'npx.cmd' : 'npx', ['-y', '@vespermcp/mcp-server@latest', '--version'], {
|
|
467
|
+
timeout: 10000,
|
|
468
|
+
encoding: 'utf8',
|
|
469
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
470
|
+
});
|
|
471
|
+
return result.status === 0 || (result.stderr && result.stderr.includes('Vesper'));
|
|
472
|
+
} catch {
|
|
473
|
+
return false;
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
// ── Main Wizard ──────────────────────────────────────────────
|
|
478
|
+
async function main() {
|
|
479
|
+
if (!isInteractiveTerminal()) {
|
|
480
|
+
console.error(red('vesper-wizard is interactive and cannot run in MCP stdio mode.'));
|
|
481
|
+
console.error(dim('Use this command for MCP server runtime instead:'));
|
|
482
|
+
console.error(cyan('npx -y -p @vespermcp/mcp-server@latest vespermcp'));
|
|
483
|
+
process.exit(2);
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
printBanner();
|
|
487
|
+
|
|
488
|
+
console.log(` ${green('→')} Setting up Vesper on ${bold(os.hostname())}\n`);
|
|
489
|
+
|
|
490
|
+
// ─── Step 1: Create directories ────────────────────────────
|
|
491
|
+
process.stdout.write(` ${dim('[')}${cyan('1/6')}${dim(']')} Creating local directories...`);
|
|
492
|
+
ensureDir(VESPER_DIR);
|
|
493
|
+
ensureDir(DATA_DIR);
|
|
494
|
+
ensureDir(path.join(DATA_DIR, 'raw'));
|
|
495
|
+
ensureDir(path.join(DATA_DIR, 'processed'));
|
|
496
|
+
ensureDir(path.join(VESPER_DIR, 'datasets'));
|
|
497
|
+
console.log(` ${green('✓')}`);
|
|
498
|
+
|
|
499
|
+
// ─── Step 2: Authenticate (device flow or local key) ──────
|
|
500
|
+
console.log(`\n ${dim('[')}${cyan('2/6')}${dim(']')} Authentication`);
|
|
501
|
+
|
|
502
|
+
const existing = readToml(CONFIG_TOML);
|
|
503
|
+
let localKey = existing.api_key || '';
|
|
504
|
+
let authMode = existing.auth_mode || '';
|
|
505
|
+
|
|
506
|
+
const authChoice = await chooseAuthMode(localKey, authMode);
|
|
507
|
+
|
|
508
|
+
if (authChoice === 'manual') {
|
|
509
|
+
localKey = await promptForManualApiKey();
|
|
510
|
+
authMode = 'cloud';
|
|
511
|
+
console.log(` ${green('✓')} Cloud API key saved from manual input`);
|
|
512
|
+
} else if (authChoice === 'browser') {
|
|
513
|
+
const cloudKey = await deviceAuthFlow();
|
|
514
|
+
if (cloudKey) {
|
|
515
|
+
localKey = cloudKey;
|
|
516
|
+
authMode = 'cloud';
|
|
517
|
+
} else {
|
|
518
|
+
console.log(`\n ${yellow('!')} Browser sign-in did not complete. Falling back to manual key entry.`);
|
|
519
|
+
localKey = await promptForManualApiKey();
|
|
520
|
+
authMode = 'cloud';
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
const configData = { ...existing, api_key: localKey, auth_mode: authMode };
|
|
525
|
+
writeToml(CONFIG_TOML, configData);
|
|
526
|
+
console.log(` ${dim('Key:')} ${dim(localKey.slice(0, 24) + '...')} ${dim('→')} ${dim(CONFIG_TOML)}`);
|
|
527
|
+
|
|
528
|
+
// ─── Step 3: Local vault initialization ────────────────────
|
|
529
|
+
process.stdout.write(`\n ${dim('[')}${cyan('3/6')}${dim(']')} Initializing local credentials vault...`);
|
|
530
|
+
const vaultData = readToml(CONFIG_TOML);
|
|
531
|
+
if (!vaultData.auth_mode) vaultData.auth_mode = 'local_unified';
|
|
532
|
+
writeToml(CONFIG_TOML, vaultData);
|
|
533
|
+
console.log(` ${green('✓')}`);
|
|
534
|
+
console.log(` ${dim('Mode:')} ${dim(vaultData.auth_mode === 'cloud' ? 'cloud (linked to Vesper account)' : 'single local Vesper key (no external keys required)')}`);
|
|
535
|
+
|
|
536
|
+
// ─── Step 4: Verify @vespermcp/mcp-server command ───────────
|
|
537
|
+
console.log(`\n ${dim('[')}${cyan('4/6')}${dim(']')} Verifying Vesper MCP server command...`);
|
|
538
|
+
try {
|
|
539
|
+
const npmCmd = IS_WIN ? 'npx.cmd' : 'npx';
|
|
540
|
+
const verify = spawnSync(npmCmd, ['-y', '-p', '@vespermcp/mcp-server@latest', 'vespermcp', '--version'], {
|
|
541
|
+
stdio: 'pipe',
|
|
542
|
+
timeout: 30000,
|
|
543
|
+
encoding: 'utf8',
|
|
544
|
+
});
|
|
545
|
+
if (verify.status === 0) {
|
|
546
|
+
console.log(` ${green('✓')} @vespermcp/mcp-server command is available`);
|
|
547
|
+
} else {
|
|
548
|
+
console.log(` ${yellow('⚠')} Could not verify vespermcp binary. MCP clients will still install it on first run.`);
|
|
549
|
+
}
|
|
550
|
+
} catch {
|
|
551
|
+
console.log(` ${yellow('⚠')} Could not verify vespermcp binary. MCP clients will still install it on first run.`);
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
// ─── Step 5: Auto-configure all detected IDEs ──────────────
|
|
555
|
+
process.stdout.write(`\n ${dim('[')}${cyan('5/6')}${dim(']')} Configuring coding agents...`);
|
|
556
|
+
const agents = getAllAgentConfigs();
|
|
557
|
+
const configuredAgents = [];
|
|
558
|
+
const skippedAgents = [];
|
|
559
|
+
|
|
560
|
+
for (const agent of agents) {
|
|
561
|
+
const dirExists = fs.existsSync(path.dirname(agent.path));
|
|
562
|
+
const fileExists = fs.existsSync(agent.path);
|
|
563
|
+
if (fileExists || dirExists) {
|
|
564
|
+
const ok = installMcpToAgent(agent);
|
|
565
|
+
if (ok) configuredAgents.push(agent.name);
|
|
566
|
+
else skippedAgents.push(agent.name);
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
console.log(` ${green('✓')}`);
|
|
570
|
+
|
|
571
|
+
if (configuredAgents.length > 0) {
|
|
572
|
+
console.log(`\n ┌───────────────────────────────────────────────┐`);
|
|
573
|
+
console.log(` │ ${bold('MCP Auto-Configured')} │`);
|
|
574
|
+
console.log(` ├───────────────────────────────────────────────┤`);
|
|
575
|
+
for (const name of configuredAgents) {
|
|
576
|
+
console.log(` │ ${green('✓')} ${name.padEnd(42)}│`);
|
|
577
|
+
}
|
|
578
|
+
console.log(` └───────────────────────────────────────────────┘`);
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
// ─── Step 6: Verify ────────────────────────────────────────
|
|
582
|
+
console.log(`\n ${dim('[')}${cyan('6/6')}${dim(']')} Verifying installation...`);
|
|
583
|
+
|
|
584
|
+
const dbExists = fs.existsSync(path.join(DATA_DIR, 'metadata.db'));
|
|
585
|
+
const vecExists = fs.existsSync(path.join(DATA_DIR, 'vectors.json')) || fs.existsSync(path.join(DATA_DIR, 'vectors.bin'));
|
|
586
|
+
const keyStored = fs.existsSync(CONFIG_TOML);
|
|
587
|
+
|
|
588
|
+
console.log(` ${keyStored ? green('✓') : red('✗')} Local API key ${dim(CONFIG_TOML)}`);
|
|
589
|
+
console.log(` ${dbExists ? green('✓') : yellow('⚠')} Dataset index ${dim(dbExists ? 'ready' : 'will build on first search')}`);
|
|
590
|
+
console.log(` ${vecExists ? green('✓') : yellow('⚠')} Vector store ${dim(vecExists ? 'ready' : 'will build on first search')}`);
|
|
591
|
+
console.log(` ${configuredAgents.length > 0 ? green('✓') : yellow('⚠')} MCP agents ${dim(configuredAgents.length + ' configured')}`);
|
|
592
|
+
|
|
593
|
+
// ─── Final Summary ─────────────────────────────────────────
|
|
594
|
+
const finalConfig = readToml(CONFIG_TOML);
|
|
595
|
+
const isCloud = finalConfig.auth_mode === 'cloud';
|
|
596
|
+
console.log(`
|
|
597
|
+
${dim('═════════════════════════════════════════════════')}
|
|
598
|
+
|
|
599
|
+
${green(bold('✓ Vesper is ready!'))}
|
|
600
|
+
|
|
601
|
+
${bold(isCloud ? 'Your cloud API key:' : 'Your local API key:')}
|
|
602
|
+
${cyan(finalConfig.api_key || localKey)}
|
|
603
|
+
|
|
604
|
+
${bold('Auth mode:')}
|
|
605
|
+
${dim(isCloud ? '☁ Cloud (linked to Vesper account)' : '🔑 Local-only (key never leaves your machine)')}
|
|
606
|
+
|
|
607
|
+
${bold('Config file:')}
|
|
608
|
+
${dim(CONFIG_TOML)}
|
|
609
|
+
|
|
610
|
+
${bold('What just happened:')}
|
|
611
|
+
${dim('1.')} ${isCloud ? 'Linked to your Vesper cloud account' : 'Generated a local API key (never leaves your machine)'}
|
|
612
|
+
${dim('2.')} Initialized local credentials vault
|
|
613
|
+
${dim('3.')} Auto-configured MCP for ${configuredAgents.length > 0 ? configuredAgents.join(', ') : 'detected agents'}
|
|
614
|
+
${dim('4.')} Vesper server ready on stdio transport
|
|
615
|
+
|
|
616
|
+
${dim('─────────────────────────────────────────────────')}
|
|
617
|
+
|
|
618
|
+
${bold('Quick start — try in your AI assistant:')}
|
|
619
|
+
|
|
620
|
+
${cyan('Search datasets')}
|
|
621
|
+
${dim('>')} vesper_search(query="sentiment analysis")
|
|
622
|
+
|
|
623
|
+
${cyan('Download & prepare')}
|
|
624
|
+
${dim('>')} prepare_dataset(query="image classification cats dogs")
|
|
625
|
+
|
|
626
|
+
${cyan('Quality analysis')}
|
|
627
|
+
${dim('>')} analyze_quality(dataset_id="imdb")
|
|
628
|
+
|
|
629
|
+
${cyan('Export to your project')}
|
|
630
|
+
${dim('>')} export_dataset(dataset_id="imdb", format="parquet")
|
|
631
|
+
|
|
632
|
+
${dim('─────────────────────────────────────────────────')}
|
|
633
|
+
|
|
634
|
+
${bold('Unified API — one interface, every source:')}
|
|
635
|
+
HuggingFace · Kaggle · OpenML · data.world
|
|
636
|
+
|
|
637
|
+
${dim('Agents call localhost Vesper APIs with one local key.')}
|
|
638
|
+
${dim('Vesper adapters handle provider routing internally.')}
|
|
639
|
+
|
|
640
|
+
${dim('─────────────────────────────────────────────────')}
|
|
641
|
+
|
|
642
|
+
${yellow('→')} Restart your IDE to activate MCP
|
|
643
|
+
${dim('Docs:')} https://github.com/vesper/mcp-server
|
|
644
|
+
|
|
645
|
+
${dim('═════════════════════════════════════════════════')}
|
|
646
|
+
`);
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
main().catch((err) => {
|
|
650
|
+
console.error(`\n${red('Error:')} ${err.message || err}`);
|
|
651
|
+
process.exit(1);
|
|
652
|
+
});
|