@vibescope/mcp-server 0.2.4 → 0.2.6

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 CHANGED
@@ -45,14 +45,27 @@ Then configure:
45
45
 
46
46
  ## Quick Start
47
47
 
48
- ### Claude Code
48
+ ### Interactive Setup (Recommended)
49
+
50
+ Run the setup wizard to automatically configure Vibescope for your IDE:
51
+
52
+ ```bash
53
+ npx -p @vibescope/mcp-server vibescope-cli setup
54
+ ```
55
+
56
+ This guides you through:
57
+ 1. Selecting your IDE (Claude Code, Claude Desktop, Cursor, or Gemini CLI)
58
+ 2. Getting your API key from the Vibescope dashboard
59
+ 3. Writing the configuration file
60
+
61
+ ### Claude Code (Manual)
49
62
 
50
63
  ```bash
51
64
  claude mcp add vibescope npx @vibescope/mcp-server@latest \
52
65
  --env VIBESCOPE_API_KEY=your_key
53
66
  ```
54
67
 
55
- ### Gemini CLI
68
+ ### Gemini CLI (Manual)
56
69
 
57
70
  Add to your `~/.gemini/settings.json` or project-level `.gemini/settings.json`:
58
71
 
package/dist/cli.d.ts CHANGED
@@ -1,9 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * Vibescope CLI - Enforcement verification tool
3
+ * Vibescope CLI - Setup wizard and enforcement verification tool
4
4
  *
5
- * Used by Claude Code Stop hook to verify agent compliance with Vibescope tracking.
6
- * Exit codes:
5
+ * Commands:
6
+ * setup - Interactive wizard to configure Vibescope for your IDE
7
+ * verify - Check agent compliance with Vibescope tracking (used by hooks)
8
+ *
9
+ * Exit codes (for verify command):
7
10
  * 0 = Compliant (allow exit)
8
11
  * 1 = Non-compliant (block exit, loop back)
9
12
  * 2 = Error (allow exit with warning)
package/dist/cli.js CHANGED
@@ -1,14 +1,18 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * Vibescope CLI - Enforcement verification tool
3
+ * Vibescope CLI - Setup wizard and enforcement verification tool
4
4
  *
5
- * Used by Claude Code Stop hook to verify agent compliance with Vibescope tracking.
6
- * Exit codes:
5
+ * Commands:
6
+ * setup - Interactive wizard to configure Vibescope for your IDE
7
+ * verify - Check agent compliance with Vibescope tracking (used by hooks)
8
+ *
9
+ * Exit codes (for verify command):
7
10
  * 0 = Compliant (allow exit)
8
11
  * 1 = Non-compliant (block exit, loop back)
9
12
  * 2 = Error (allow exit with warning)
10
13
  */
11
14
  import { execSync } from 'child_process';
15
+ import { runSetup } from './setup.js';
12
16
  // ============================================================================
13
17
  // Configuration (read at runtime for testability)
14
18
  // ============================================================================
@@ -89,7 +93,12 @@ export async function verify(gitUrl, projectId) {
89
93
  async function main() {
90
94
  const args = process.argv.slice(2);
91
95
  const command = args[0];
92
- if (command === 'verify') {
96
+ if (command === 'setup') {
97
+ // Run interactive setup wizard
98
+ await runSetup();
99
+ process.exit(0);
100
+ }
101
+ else if (command === 'verify') {
93
102
  // Parse --git-url and --project-id flags
94
103
  let gitUrl;
95
104
  let projectId;
@@ -115,29 +124,38 @@ async function main() {
115
124
  }
116
125
  }
117
126
  else if (command === 'help' || command === '--help' || command === '-h') {
118
- console.log(`
119
- Vibescope CLI - Enforcement verification tool
120
-
121
- Usage:
122
- vibescope-cli verify [options] Check Vibescope compliance before exit
123
-
124
- Options:
125
- --git-url <url> Git repository URL (auto-detected if not provided)
126
- --project-id <id> Vibescope project UUID
127
-
128
- Exit Codes:
129
- 0 Compliant - agent can exit
130
- 1 Non-compliant - agent should continue work
131
- 2 Error - allow exit with warning
132
-
133
- Environment Variables:
134
- VIBESCOPE_API_KEY Required - Your Vibescope API key
135
- VIBESCOPE_API_URL Optional - API URL (default: https://vibescope.dev)
127
+ console.log(`
128
+ Vibescope CLI - Setup wizard and enforcement verification tool
129
+
130
+ Usage:
131
+ vibescope-cli setup Interactive setup wizard for your IDE
132
+ vibescope-cli verify [options] Check Vibescope compliance before exit
133
+
134
+ Setup:
135
+ Configures Vibescope MCP integration for:
136
+ - Claude Code (CLI)
137
+ - Claude Desktop
138
+ - Cursor
139
+ - Gemini CLI
140
+
141
+ Verify Options:
142
+ --git-url <url> Git repository URL (auto-detected if not provided)
143
+ --project-id <id> Vibescope project UUID
144
+
145
+ Exit Codes (verify):
146
+ 0 Compliant - agent can exit
147
+ 1 Non-compliant - agent should continue work
148
+ 2 Error - allow exit with warning
149
+
150
+ Environment Variables:
151
+ VIBESCOPE_API_KEY Required for verify - Your Vibescope API key
152
+ VIBESCOPE_API_URL Optional - API URL (default: https://vibescope.dev)
136
153
  `);
137
154
  process.exit(0);
138
155
  }
139
156
  else {
140
- console.error('Usage: vibescope-cli verify [--git-url <url>] [--project-id <id>]');
157
+ console.error('Usage: vibescope-cli setup');
158
+ console.error(' vibescope-cli verify [--git-url <url>] [--project-id <id>]');
141
159
  console.error(' vibescope-cli --help');
142
160
  process.exit(2);
143
161
  }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Vibescope Setup Wizard
3
+ * Guides users through setting up Vibescope MCP integration
4
+ *
5
+ * Usage: vibescope-cli setup
6
+ */
7
+ export interface IdeConfig {
8
+ name: string;
9
+ displayName: string;
10
+ configPath: string;
11
+ detected: boolean;
12
+ configFormat: 'mcp-json' | 'settings-json';
13
+ }
14
+ export declare function detectIdes(): IdeConfig[];
15
+ export declare function validateApiKey(apiKey: string): Promise<{
16
+ valid: boolean;
17
+ message: string;
18
+ }>;
19
+ export declare function readExistingConfig(configPath: string): Record<string, unknown>;
20
+ export declare function writeConfig(configPath: string, config: Record<string, unknown>): void;
21
+ export declare function generateMcpConfig(apiKey: string, ide: IdeConfig): Record<string, unknown>;
22
+ export declare function runSetup(): Promise<void>;
package/dist/setup.js ADDED
@@ -0,0 +1,313 @@
1
+ /**
2
+ * Vibescope Setup Wizard
3
+ * Guides users through setting up Vibescope MCP integration
4
+ *
5
+ * Usage: vibescope-cli setup
6
+ */
7
+ import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'node:fs';
8
+ import { createInterface } from 'node:readline';
9
+ import { homedir, platform } from 'node:os';
10
+ import { join, dirname } from 'node:path';
11
+ import { exec } from 'node:child_process';
12
+ const VIBESCOPE_SETTINGS_URL = 'https://vibescope.dev/dashboard/settings';
13
+ const DEFAULT_SUPABASE_URL = 'https://uuneucmuubpgswvfijwd.supabase.co';
14
+ // ============================================================================
15
+ // Config Path Helpers
16
+ // ============================================================================
17
+ function getClaudeDesktopConfigPath() {
18
+ const plat = platform();
19
+ const home = homedir();
20
+ if (plat === 'darwin') {
21
+ return join(home, 'Library', 'Application Support', 'Claude', 'claude_desktop_config.json');
22
+ }
23
+ else if (plat === 'win32') {
24
+ return join(home, 'AppData', 'Roaming', 'Claude', 'claude_desktop_config.json');
25
+ }
26
+ else {
27
+ return join(home, '.config', 'Claude', 'claude_desktop_config.json');
28
+ }
29
+ }
30
+ function getCursorConfigPath() {
31
+ const plat = platform();
32
+ const home = homedir();
33
+ if (plat === 'darwin') {
34
+ return join(home, 'Library', 'Application Support', 'Cursor', 'User', 'globalStorage', 'saoudrizwan.claude-dev', 'settings', 'cline_mcp_settings.json');
35
+ }
36
+ else if (plat === 'win32') {
37
+ return join(home, 'AppData', 'Roaming', 'Cursor', 'User', 'globalStorage', 'saoudrizwan.claude-dev', 'settings', 'cline_mcp_settings.json');
38
+ }
39
+ else {
40
+ return join(home, '.config', 'Cursor', 'User', 'globalStorage', 'saoudrizwan.claude-dev', 'settings', 'cline_mcp_settings.json');
41
+ }
42
+ }
43
+ function getGeminiConfigPath() {
44
+ return join(homedir(), '.gemini', 'settings.json');
45
+ }
46
+ // ============================================================================
47
+ // IDE Detection
48
+ // ============================================================================
49
+ export function detectIdes() {
50
+ const ides = [
51
+ {
52
+ name: 'claude-code',
53
+ displayName: 'Claude Code (CLI)',
54
+ configPath: '.mcp.json',
55
+ detected: true,
56
+ configFormat: 'mcp-json',
57
+ },
58
+ {
59
+ name: 'claude-desktop',
60
+ displayName: 'Claude Desktop',
61
+ configPath: getClaudeDesktopConfigPath(),
62
+ detected: existsSync(dirname(getClaudeDesktopConfigPath())),
63
+ configFormat: 'mcp-json',
64
+ },
65
+ {
66
+ name: 'cursor',
67
+ displayName: 'Cursor',
68
+ configPath: getCursorConfigPath(),
69
+ detected: existsSync(dirname(getCursorConfigPath())),
70
+ configFormat: 'mcp-json',
71
+ },
72
+ {
73
+ name: 'gemini',
74
+ displayName: 'Gemini CLI',
75
+ configPath: getGeminiConfigPath(),
76
+ detected: true,
77
+ configFormat: 'settings-json',
78
+ },
79
+ ];
80
+ return ides;
81
+ }
82
+ // ============================================================================
83
+ // User Prompts
84
+ // ============================================================================
85
+ async function prompt(question) {
86
+ const rl = createInterface({
87
+ input: process.stdin,
88
+ output: process.stdout,
89
+ });
90
+ return new Promise((resolve) => {
91
+ rl.question(question, (answer) => {
92
+ rl.close();
93
+ resolve(answer.trim());
94
+ });
95
+ });
96
+ }
97
+ async function promptSelect(question, options) {
98
+ console.log('\n' + question + '\n');
99
+ options.forEach((opt, i) => {
100
+ console.log(' ' + (i + 1) + ') ' + opt.label);
101
+ });
102
+ const answer = await prompt('\nEnter number: ');
103
+ const index = parseInt(answer, 10) - 1;
104
+ if (index >= 0 && index < options.length) {
105
+ return options[index].value;
106
+ }
107
+ console.log('Invalid selection, using first option.');
108
+ return options[0].value;
109
+ }
110
+ // ============================================================================
111
+ // Browser & Validation
112
+ // ============================================================================
113
+ function openBrowser(url) {
114
+ return new Promise((resolve) => {
115
+ const plat = platform();
116
+ let cmd;
117
+ if (plat === 'darwin') {
118
+ cmd = 'open "' + url + '"';
119
+ }
120
+ else if (plat === 'win32') {
121
+ cmd = 'start "" "' + url + '"';
122
+ }
123
+ else {
124
+ cmd = 'xdg-open "' + url + '"';
125
+ }
126
+ exec(cmd, (error) => {
127
+ if (error) {
128
+ console.log('\nCould not open browser automatically.');
129
+ console.log('Please visit: ' + url + '\n');
130
+ }
131
+ resolve();
132
+ });
133
+ });
134
+ }
135
+ export async function validateApiKey(apiKey) {
136
+ try {
137
+ const response = await fetch(DEFAULT_SUPABASE_URL + '/rest/v1/api_keys?key=eq.' + apiKey + '&select=id', {
138
+ headers: {
139
+ 'apikey': apiKey,
140
+ 'Authorization': 'Bearer ' + apiKey,
141
+ },
142
+ });
143
+ if (response.ok) {
144
+ return { valid: true, message: 'API key validated successfully!' };
145
+ }
146
+ else {
147
+ return { valid: false, message: 'API key appears to be invalid.' };
148
+ }
149
+ }
150
+ catch {
151
+ return { valid: true, message: 'Could not validate API key (network issue), but proceeding.' };
152
+ }
153
+ }
154
+ // ============================================================================
155
+ // Config Management
156
+ // ============================================================================
157
+ export function readExistingConfig(configPath) {
158
+ if (existsSync(configPath)) {
159
+ try {
160
+ return JSON.parse(readFileSync(configPath, 'utf-8'));
161
+ }
162
+ catch {
163
+ return {};
164
+ }
165
+ }
166
+ return {};
167
+ }
168
+ export function writeConfig(configPath, config) {
169
+ const dir = dirname(configPath);
170
+ if (!existsSync(dir)) {
171
+ mkdirSync(dir, { recursive: true });
172
+ }
173
+ writeFileSync(configPath, JSON.stringify(config, null, 2) + '\n');
174
+ }
175
+ export function generateMcpConfig(apiKey, ide) {
176
+ const vibescopeServer = {
177
+ command: 'npx',
178
+ args: ['-y', '-p', '@vibescope/mcp-server@latest', 'vibescope-mcp'],
179
+ env: {
180
+ VIBESCOPE_API_KEY: apiKey,
181
+ },
182
+ };
183
+ // Gemini CLI uses a different config format with additional options
184
+ if (ide.configFormat === 'settings-json') {
185
+ return {
186
+ mcpServers: {
187
+ vibescope: {
188
+ ...vibescopeServer,
189
+ timeout: 30000,
190
+ trust: true,
191
+ },
192
+ },
193
+ };
194
+ }
195
+ // Standard MCP config for Claude Code, Claude Desktop, Cursor
196
+ return {
197
+ mcpServers: {
198
+ vibescope: vibescopeServer,
199
+ },
200
+ };
201
+ }
202
+ // ============================================================================
203
+ // Main Setup Flow
204
+ // ============================================================================
205
+ export async function runSetup() {
206
+ console.log('\n=================================');
207
+ console.log(' Vibescope Setup Wizard');
208
+ console.log('=================================\n');
209
+ // Step 1: Detect IDEs
210
+ const ides = detectIdes();
211
+ const detectedIdes = ides.filter(ide => ide.detected);
212
+ console.log('Available development environments:');
213
+ detectedIdes.forEach(ide => {
214
+ console.log(' - ' + ide.displayName);
215
+ });
216
+ // Step 2: Select IDE to configure
217
+ let selectedIde;
218
+ if (detectedIdes.length === 1) {
219
+ selectedIde = detectedIdes[0];
220
+ console.log('\nConfiguring for ' + selectedIde.displayName + '...');
221
+ }
222
+ else {
223
+ const ideChoice = await promptSelect('Which environment do you want to configure?', detectedIdes.map(ide => ({ label: ide.displayName, value: ide.name })));
224
+ selectedIde = ides.find(ide => ide.name === ideChoice) || detectedIdes[0];
225
+ }
226
+ // Step 3: Check if config already exists
227
+ if (existsSync(selectedIde.configPath)) {
228
+ const existingConfig = readExistingConfig(selectedIde.configPath);
229
+ const hasMcpServers = 'mcpServers' in existingConfig;
230
+ const hasVibescope = hasMcpServers &&
231
+ typeof existingConfig.mcpServers === 'object' &&
232
+ existingConfig.mcpServers !== null &&
233
+ 'vibescope' in existingConfig.mcpServers;
234
+ if (hasVibescope) {
235
+ const overwrite = await prompt('\nVibescope is already configured. Reconfigure? (y/N): ');
236
+ if (overwrite.toLowerCase() !== 'y') {
237
+ console.log('\nSetup cancelled. Your existing configuration is preserved.');
238
+ return;
239
+ }
240
+ }
241
+ }
242
+ // Step 4: Get API key
243
+ console.log('\n--- Step 1: Get your API key ---\n');
244
+ console.log('Opening Vibescope settings page in your browser...');
245
+ console.log("Create an API key if you don't have one, then copy it.\n");
246
+ await openBrowser(VIBESCOPE_SETTINGS_URL);
247
+ const apiKey = await prompt('Paste your Vibescope API key: ');
248
+ if (!apiKey) {
249
+ console.error('\nError: API key is required.');
250
+ process.exit(1);
251
+ }
252
+ // Validate API key
253
+ console.log('\nValidating API key...');
254
+ const validation = await validateApiKey(apiKey);
255
+ console.log(validation.message);
256
+ if (!validation.valid) {
257
+ const proceed = await prompt('Proceed anyway? (y/N): ');
258
+ if (proceed.toLowerCase() !== 'y') {
259
+ process.exit(1);
260
+ }
261
+ }
262
+ // Step 5: Write configuration
263
+ console.log('\n--- Step 2: Writing Configuration ---\n');
264
+ const mcpConfig = generateMcpConfig(apiKey, selectedIde);
265
+ // Merge with existing config if present
266
+ const existingConfig = readExistingConfig(selectedIde.configPath);
267
+ const existingMcpServers = typeof existingConfig.mcpServers === 'object' && existingConfig.mcpServers !== null
268
+ ? existingConfig.mcpServers
269
+ : {};
270
+ const newMcpServers = mcpConfig.mcpServers;
271
+ const mergedConfig = {
272
+ ...existingConfig,
273
+ mcpServers: {
274
+ ...existingMcpServers,
275
+ ...newMcpServers,
276
+ },
277
+ };
278
+ writeConfig(selectedIde.configPath, mergedConfig);
279
+ console.log('Configuration written to: ' + selectedIde.configPath);
280
+ // Step 6: IDE-specific next steps
281
+ console.log('\n=================================');
282
+ console.log(' Setup Complete!');
283
+ console.log('=================================\n');
284
+ switch (selectedIde.name) {
285
+ case 'claude-code':
286
+ console.log('Next steps:');
287
+ console.log(' 1. Restart Claude Code (or run: claude mcp reload)');
288
+ console.log(' 2. Verify connection: claude mcp list');
289
+ console.log(' 3. Start using Vibescope in your conversation');
290
+ break;
291
+ case 'claude-desktop':
292
+ console.log('Next steps:');
293
+ console.log(' 1. Restart Claude Desktop');
294
+ console.log(' 2. Vibescope tools will be available in your conversations');
295
+ break;
296
+ case 'cursor':
297
+ console.log('Next steps:');
298
+ console.log(' 1. Restart Cursor');
299
+ console.log(' 2. Open the MCP settings to verify Vibescope is connected');
300
+ break;
301
+ case 'gemini':
302
+ console.log('Next steps:');
303
+ console.log(' 1. Restart Gemini CLI');
304
+ console.log(' 2. Verify connection: gemini mcp list');
305
+ console.log(' 3. Start using Vibescope in your conversation');
306
+ break;
307
+ default:
308
+ console.log('Next steps:');
309
+ console.log(' 1. Restart your IDE/CLI');
310
+ console.log(' 2. Verify Vibescope is connected');
311
+ }
312
+ console.log('\nHappy building!\n');
313
+ }
@@ -19,8 +19,10 @@ export function estimateTokens(obj) {
19
19
  const json = JSON.stringify(obj);
20
20
  return Math.max(1, Math.ceil(json.length / 4));
21
21
  }
22
- catch {
23
- // If JSON serialization fails, return a minimal estimate
22
+ catch (error) {
23
+ // Log warning when serialization fails (e.g., circular references, BigInt)
24
+ const errorMessage = error instanceof Error ? error.message : String(error);
25
+ console.warn(`[Vibescope] Token estimation failed: ${errorMessage}. Returning minimal estimate of 1 token.`);
24
26
  return 1;
25
27
  }
26
28
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibescope/mcp-server",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "description": "MCP server for Vibescope - AI project tracking tools",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",