@codebakers/cli 3.3.5 → 3.3.7

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.
@@ -656,6 +656,36 @@ async function init() {
656
656
  (0, fs_1.writeFileSync)((0, path_1.join)(cwd, '.cursorrules'), CURSORRULES_TEMPLATE);
657
657
  // Write .cursorignore
658
658
  (0, fs_1.writeFileSync)((0, path_1.join)(cwd, '.cursorignore'), CURSORIGNORE_TEMPLATE);
659
+ // Create GLOBAL ~/.cursor/mcp.json for MCP server configuration
660
+ // Cursor reads MCP config from global location, not project-local
661
+ const homeDir = process.env.USERPROFILE || process.env.HOME || '';
662
+ const globalCursorDir = (0, path_1.join)(homeDir, '.cursor');
663
+ if (!(0, fs_1.existsSync)(globalCursorDir)) {
664
+ (0, fs_1.mkdirSync)(globalCursorDir, { recursive: true });
665
+ }
666
+ const mcpConfigPath = (0, path_1.join)(globalCursorDir, 'mcp.json');
667
+ const isWindows = process.platform === 'win32';
668
+ const mcpConfig = {
669
+ mcpServers: {
670
+ codebakers: isWindows
671
+ ? { command: 'cmd', args: ['/c', 'npx', '-y', '@codebakers/cli', 'serve'] }
672
+ : { command: 'npx', args: ['-y', '@codebakers/cli', 'serve'] }
673
+ }
674
+ };
675
+ // Merge with existing MCP config if present
676
+ if ((0, fs_1.existsSync)(mcpConfigPath)) {
677
+ try {
678
+ const existing = JSON.parse((0, fs_1.readFileSync)(mcpConfigPath, 'utf-8'));
679
+ existing.mcpServers = { ...existing.mcpServers, ...mcpConfig.mcpServers };
680
+ (0, fs_1.writeFileSync)(mcpConfigPath, JSON.stringify(existing, null, 2));
681
+ }
682
+ catch {
683
+ (0, fs_1.writeFileSync)(mcpConfigPath, JSON.stringify(mcpConfig, null, 2));
684
+ }
685
+ }
686
+ else {
687
+ (0, fs_1.writeFileSync)(mcpConfigPath, JSON.stringify(mcpConfig, null, 2));
688
+ }
659
689
  // Create/merge .vscode/settings.json
660
690
  const vscodeDir = (0, path_1.join)(cwd, '.vscode');
661
691
  if (!(0, fs_1.existsSync)(vscodeDir)) {
@@ -671,6 +701,7 @@ async function init() {
671
701
  (0, fs_1.writeFileSync)(existingSettingsPath, JSON.stringify(VSCODE_SETTINGS_TEMPLATE, null, 2));
672
702
  }
673
703
  cursorSpinner.succeed('Cursor configuration installed!');
704
+ console.log(chalk_1.default.green(' ✓ MCP server configured (~/.cursor/mcp.json)'));
674
705
  }
675
706
  catch (error) {
676
707
  cursorSpinner.warn('Could not install Cursor files (continuing anyway)');
@@ -8,6 +8,8 @@ const chalk_1 = __importDefault(require("chalk"));
8
8
  const ora_1 = __importDefault(require("ora"));
9
9
  const readline_1 = require("readline");
10
10
  const child_process_1 = require("child_process");
11
+ const fs_1 = require("fs");
12
+ const path_1 = require("path");
11
13
  const config_js_1 = require("../config.js");
12
14
  const api_js_1 = require("../lib/api.js");
13
15
  const progress_js_1 = require("../lib/progress.js");
@@ -127,47 +129,80 @@ async function setup() {
127
129
  }
128
130
  function showFinalInstructions() {
129
131
  const isWindows = process.platform === 'win32';
132
+ const cwd = process.cwd();
130
133
  console.log(chalk_1.default.blue(' ══════════════════════════════════════════════════════════'));
131
- console.log(chalk_1.default.white.bold('\n STEP 3: Connecting CodeBakers to Claude...\n'));
134
+ console.log(chalk_1.default.white.bold('\n STEP 3: Connecting CodeBakers to your IDE...\n'));
132
135
  console.log(chalk_1.default.blue(' ══════════════════════════════════════════════════════════\n'));
133
- // Auto-install MCP server
136
+ // Install MCP for Claude Code CLI
134
137
  const mcpCmd = isWindows
135
138
  ? 'claude mcp add --transport stdio codebakers -- cmd /c npx -y @codebakers/cli serve'
136
139
  : 'claude mcp add --transport stdio codebakers -- npx -y @codebakers/cli serve';
140
+ let claudeCodeInstalled = false;
137
141
  try {
138
142
  (0, child_process_1.execSync)(mcpCmd, { stdio: 'pipe' });
139
- console.log(chalk_1.default.green(' ✅ CodeBakers MCP server installed!\n'));
143
+ console.log(chalk_1.default.green(' ✅ Claude Code MCP server installed!\n'));
144
+ claudeCodeInstalled = true;
140
145
  }
141
146
  catch (error) {
142
- // Check if it's already installed (command might fail if already exists)
143
147
  const errorMessage = error instanceof Error ? error.message : String(error);
144
148
  if (errorMessage.includes('already exists') || errorMessage.includes('already registered')) {
145
- console.log(chalk_1.default.green(' ✅ CodeBakers MCP server already installed!\n'));
149
+ console.log(chalk_1.default.green(' ✅ Claude Code MCP server already installed!\n'));
150
+ claudeCodeInstalled = true;
146
151
  }
147
152
  else {
148
- console.log(chalk_1.default.yellow(' ⚠️ Could not auto-install MCP server.\n'));
149
- console.log(chalk_1.default.white(' Run this command manually in your terminal:\n'));
150
- console.log(chalk_1.default.bgBlue.white('\n ' + mcpCmd + ' \n'));
151
- console.log(chalk_1.default.yellow('\n ⚠️ Then close this terminal and open a new one in your project.\n'));
152
- return;
153
+ console.log(chalk_1.default.yellow(' ⚠️ Claude Code not detected (that\'s OK if using Cursor)\n'));
153
154
  }
154
155
  }
156
+ // Install MCP for Cursor IDE (create GLOBAL ~/.cursor/mcp.json)
157
+ // Cursor reads MCP config from global location, not project-local
158
+ const homeDir = process.env.USERPROFILE || process.env.HOME || '';
159
+ const cursorDir = (0, path_1.join)(homeDir, '.cursor');
160
+ const mcpConfigPath = (0, path_1.join)(cursorDir, 'mcp.json');
161
+ const mcpConfig = {
162
+ mcpServers: {
163
+ codebakers: isWindows
164
+ ? { command: 'cmd', args: ['/c', 'npx', '-y', '@codebakers/cli', 'serve'] }
165
+ : { command: 'npx', args: ['-y', '@codebakers/cli', 'serve'] }
166
+ }
167
+ };
168
+ try {
169
+ if (!(0, fs_1.existsSync)(cursorDir)) {
170
+ (0, fs_1.mkdirSync)(cursorDir, { recursive: true });
171
+ }
172
+ // Merge with existing MCP config if present
173
+ if ((0, fs_1.existsSync)(mcpConfigPath)) {
174
+ const existing = JSON.parse((0, fs_1.readFileSync)(mcpConfigPath, 'utf-8'));
175
+ existing.mcpServers = { ...existing.mcpServers, ...mcpConfig.mcpServers };
176
+ (0, fs_1.writeFileSync)(mcpConfigPath, JSON.stringify(existing, null, 2));
177
+ }
178
+ else {
179
+ (0, fs_1.writeFileSync)(mcpConfigPath, JSON.stringify(mcpConfig, null, 2));
180
+ }
181
+ console.log(chalk_1.default.green(' ✅ Cursor MCP server configured! (~/.cursor/mcp.json)\n'));
182
+ }
183
+ catch (error) {
184
+ console.log(chalk_1.default.yellow(' ⚠️ Could not create Cursor MCP config\n'));
185
+ }
155
186
  console.log(chalk_1.default.blue(' ══════════════════════════════════════════════════════════'));
156
187
  console.log(chalk_1.default.white.bold('\n 🎉 Setup Complete!\n'));
157
188
  console.log(chalk_1.default.blue(' ══════════════════════════════════════════════════════════\n'));
158
- console.log(chalk_1.default.yellow.bold(' ⚠️ RESTART REQUIRED - Follow these steps:\n'));
159
- console.log(chalk_1.default.white(' For Claude Code:\n'));
160
- console.log(chalk_1.default.gray(' 1. Close this terminal completely (type ') + chalk_1.default.cyan('exit') + chalk_1.default.gray(')'));
161
- console.log(chalk_1.default.gray(' 2. Open a NEW terminal window'));
162
- console.log(chalk_1.default.gray(' 3. Navigate to your project folder'));
163
- console.log(chalk_1.default.gray(' 4. Run ') + chalk_1.default.cyan('claude') + chalk_1.default.gray(' to start Claude Code\n'));
189
+ console.log(chalk_1.default.yellow.bold(' ⚠️ RESTART REQUIRED:\n'));
164
190
  console.log(chalk_1.default.white(' For Cursor:\n'));
165
191
  console.log(chalk_1.default.gray(' 1. Close Cursor completely (Cmd+Q / Alt+F4)'));
166
192
  console.log(chalk_1.default.gray(' 2. Reopen Cursor'));
167
193
  console.log(chalk_1.default.gray(' 3. Open Composer (Cmd+I / Ctrl+I)\n'));
194
+ if (claudeCodeInstalled) {
195
+ console.log(chalk_1.default.white(' For Claude Code:\n'));
196
+ console.log(chalk_1.default.gray(' 1. Close this terminal completely (type ') + chalk_1.default.cyan('exit') + chalk_1.default.gray(')'));
197
+ console.log(chalk_1.default.gray(' 2. Open a NEW terminal window'));
198
+ console.log(chalk_1.default.gray(' 3. Navigate to your project folder'));
199
+ console.log(chalk_1.default.gray(' 4. Run ') + chalk_1.default.cyan('claude') + chalk_1.default.gray(' to start Claude Code\n'));
200
+ }
168
201
  console.log(chalk_1.default.blue(' ──────────────────────────────────────────────────────────\n'));
169
- console.log(chalk_1.default.white(' To verify CodeBakers is working, ask the AI:\n'));
170
- console.log(chalk_1.default.green(' "Are you using CodeBakers?"\n'));
171
- console.log(chalk_1.default.gray(' The AI should respond with its CodeBakers status.'));
202
+ console.log(chalk_1.default.white(' Next step: Initialize patterns in your project:\n'));
203
+ console.log(chalk_1.default.cyan(' codebakers init\n'));
204
+ console.log(chalk_1.default.white(' To verify CodeBakers is working, ask the AI:\n'));
205
+ console.log(chalk_1.default.green(' "update codebakers patterns"\n'));
206
+ console.log(chalk_1.default.gray(' The AI should call the update_patterns MCP tool.'));
172
207
  console.log(chalk_1.default.gray(' Need help? https://codebakers.ai/docs\n'));
173
208
  }
package/dist/index.js CHANGED
@@ -34,7 +34,7 @@ const path_1 = require("path");
34
34
  // ============================================
35
35
  // Automatic Update Notification
36
36
  // ============================================
37
- const CURRENT_VERSION = '3.3.5';
37
+ const CURRENT_VERSION = '3.3.7';
38
38
  async function checkForUpdatesInBackground() {
39
39
  // Check if we have a valid cached result first (fast path)
40
40
  const cached = (0, config_js_2.getCachedUpdateInfo)();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codebakers/cli",
3
- "version": "3.3.5",
3
+ "version": "3.3.7",
4
4
  "description": "CodeBakers CLI - Production patterns for AI-assisted development",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -700,6 +700,37 @@ export async function init(): Promise<void> {
700
700
  // Write .cursorignore
701
701
  writeFileSync(join(cwd, '.cursorignore'), CURSORIGNORE_TEMPLATE);
702
702
 
703
+ // Create GLOBAL ~/.cursor/mcp.json for MCP server configuration
704
+ // Cursor reads MCP config from global location, not project-local
705
+ const homeDir = process.env.USERPROFILE || process.env.HOME || '';
706
+ const globalCursorDir = join(homeDir, '.cursor');
707
+ if (!existsSync(globalCursorDir)) {
708
+ mkdirSync(globalCursorDir, { recursive: true });
709
+ }
710
+
711
+ const mcpConfigPath = join(globalCursorDir, 'mcp.json');
712
+ const isWindows = process.platform === 'win32';
713
+ const mcpConfig = {
714
+ mcpServers: {
715
+ codebakers: isWindows
716
+ ? { command: 'cmd', args: ['/c', 'npx', '-y', '@codebakers/cli', 'serve'] }
717
+ : { command: 'npx', args: ['-y', '@codebakers/cli', 'serve'] }
718
+ }
719
+ };
720
+
721
+ // Merge with existing MCP config if present
722
+ if (existsSync(mcpConfigPath)) {
723
+ try {
724
+ const existing = JSON.parse(readFileSync(mcpConfigPath, 'utf-8'));
725
+ existing.mcpServers = { ...existing.mcpServers, ...mcpConfig.mcpServers };
726
+ writeFileSync(mcpConfigPath, JSON.stringify(existing, null, 2));
727
+ } catch {
728
+ writeFileSync(mcpConfigPath, JSON.stringify(mcpConfig, null, 2));
729
+ }
730
+ } else {
731
+ writeFileSync(mcpConfigPath, JSON.stringify(mcpConfig, null, 2));
732
+ }
733
+
703
734
  // Create/merge .vscode/settings.json
704
735
  const vscodeDir = join(cwd, '.vscode');
705
736
  if (!existsSync(vscodeDir)) {
@@ -717,6 +748,7 @@ export async function init(): Promise<void> {
717
748
  }
718
749
 
719
750
  cursorSpinner.succeed('Cursor configuration installed!');
751
+ console.log(chalk.green(' ✓ MCP server configured (~/.cursor/mcp.json)'));
720
752
  } catch (error) {
721
753
  cursorSpinner.warn('Could not install Cursor files (continuing anyway)');
722
754
  }
@@ -2,6 +2,8 @@ import chalk from 'chalk';
2
2
  import ora from 'ora';
3
3
  import { createInterface } from 'readline';
4
4
  import { execSync } from 'child_process';
5
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
6
+ import { join } from 'path';
5
7
  import { setApiKey, getApiKey, getApiUrl, syncServiceKeys, SERVICE_KEY_LABELS, type ServiceName } from '../config.js';
6
8
  import { validateApiKey, formatApiError, checkForUpdates, getCliVersion, type ApiError } from '../lib/api.js';
7
9
  import { showQuickStartGuide, formatFriendlyError, getNetworkError, getAuthError } from '../lib/progress.js';
@@ -136,55 +138,90 @@ export async function setup(): Promise<void> {
136
138
 
137
139
  function showFinalInstructions(): void {
138
140
  const isWindows = process.platform === 'win32';
141
+ const cwd = process.cwd();
139
142
 
140
143
  console.log(chalk.blue(' ══════════════════════════════════════════════════════════'));
141
- console.log(chalk.white.bold('\n STEP 3: Connecting CodeBakers to Claude...\n'));
144
+ console.log(chalk.white.bold('\n STEP 3: Connecting CodeBakers to your IDE...\n'));
142
145
  console.log(chalk.blue(' ══════════════════════════════════════════════════════════\n'));
143
146
 
144
- // Auto-install MCP server
147
+ // Install MCP for Claude Code CLI
145
148
  const mcpCmd = isWindows
146
149
  ? 'claude mcp add --transport stdio codebakers -- cmd /c npx -y @codebakers/cli serve'
147
150
  : 'claude mcp add --transport stdio codebakers -- npx -y @codebakers/cli serve';
148
151
 
152
+ let claudeCodeInstalled = false;
149
153
  try {
150
154
  execSync(mcpCmd, { stdio: 'pipe' });
151
- console.log(chalk.green(' ✅ CodeBakers MCP server installed!\n'));
155
+ console.log(chalk.green(' ✅ Claude Code MCP server installed!\n'));
156
+ claudeCodeInstalled = true;
152
157
  } catch (error) {
153
- // Check if it's already installed (command might fail if already exists)
154
158
  const errorMessage = error instanceof Error ? error.message : String(error);
155
159
  if (errorMessage.includes('already exists') || errorMessage.includes('already registered')) {
156
- console.log(chalk.green(' ✅ CodeBakers MCP server already installed!\n'));
160
+ console.log(chalk.green(' ✅ Claude Code MCP server already installed!\n'));
161
+ claudeCodeInstalled = true;
157
162
  } else {
158
- console.log(chalk.yellow(' ⚠️ Could not auto-install MCP server.\n'));
159
- console.log(chalk.white(' Run this command manually in your terminal:\n'));
160
- console.log(chalk.bgBlue.white('\n ' + mcpCmd + ' \n'));
161
- console.log(chalk.yellow('\n ⚠️ Then close this terminal and open a new one in your project.\n'));
162
- return;
163
+ console.log(chalk.yellow(' ⚠️ Claude Code not detected (that\'s OK if using Cursor)\n'));
163
164
  }
164
165
  }
165
166
 
167
+ // Install MCP for Cursor IDE (create GLOBAL ~/.cursor/mcp.json)
168
+ // Cursor reads MCP config from global location, not project-local
169
+ const homeDir = process.env.USERPROFILE || process.env.HOME || '';
170
+ const cursorDir = join(homeDir, '.cursor');
171
+ const mcpConfigPath = join(cursorDir, 'mcp.json');
172
+ const mcpConfig = {
173
+ mcpServers: {
174
+ codebakers: isWindows
175
+ ? { command: 'cmd', args: ['/c', 'npx', '-y', '@codebakers/cli', 'serve'] }
176
+ : { command: 'npx', args: ['-y', '@codebakers/cli', 'serve'] }
177
+ }
178
+ };
179
+
180
+ try {
181
+ if (!existsSync(cursorDir)) {
182
+ mkdirSync(cursorDir, { recursive: true });
183
+ }
184
+
185
+ // Merge with existing MCP config if present
186
+ if (existsSync(mcpConfigPath)) {
187
+ const existing = JSON.parse(readFileSync(mcpConfigPath, 'utf-8'));
188
+ existing.mcpServers = { ...existing.mcpServers, ...mcpConfig.mcpServers };
189
+ writeFileSync(mcpConfigPath, JSON.stringify(existing, null, 2));
190
+ } else {
191
+ writeFileSync(mcpConfigPath, JSON.stringify(mcpConfig, null, 2));
192
+ }
193
+ console.log(chalk.green(' ✅ Cursor MCP server configured! (~/.cursor/mcp.json)\n'));
194
+ } catch (error) {
195
+ console.log(chalk.yellow(' ⚠️ Could not create Cursor MCP config\n'));
196
+ }
197
+
166
198
  console.log(chalk.blue(' ══════════════════════════════════════════════════════════'));
167
199
  console.log(chalk.white.bold('\n 🎉 Setup Complete!\n'));
168
200
  console.log(chalk.blue(' ══════════════════════════════════════════════════════════\n'));
169
201
 
170
- console.log(chalk.yellow.bold(' ⚠️ RESTART REQUIRED - Follow these steps:\n'));
171
-
172
- console.log(chalk.white(' For Claude Code:\n'));
173
- console.log(chalk.gray(' 1. Close this terminal completely (type ') + chalk.cyan('exit') + chalk.gray(')'));
174
- console.log(chalk.gray(' 2. Open a NEW terminal window'));
175
- console.log(chalk.gray(' 3. Navigate to your project folder'));
176
- console.log(chalk.gray(' 4. Run ') + chalk.cyan('claude') + chalk.gray(' to start Claude Code\n'));
202
+ console.log(chalk.yellow.bold(' ⚠️ RESTART REQUIRED:\n'));
177
203
 
178
204
  console.log(chalk.white(' For Cursor:\n'));
179
205
  console.log(chalk.gray(' 1. Close Cursor completely (Cmd+Q / Alt+F4)'));
180
206
  console.log(chalk.gray(' 2. Reopen Cursor'));
181
207
  console.log(chalk.gray(' 3. Open Composer (Cmd+I / Ctrl+I)\n'));
182
208
 
209
+ if (claudeCodeInstalled) {
210
+ console.log(chalk.white(' For Claude Code:\n'));
211
+ console.log(chalk.gray(' 1. Close this terminal completely (type ') + chalk.cyan('exit') + chalk.gray(')'));
212
+ console.log(chalk.gray(' 2. Open a NEW terminal window'));
213
+ console.log(chalk.gray(' 3. Navigate to your project folder'));
214
+ console.log(chalk.gray(' 4. Run ') + chalk.cyan('claude') + chalk.gray(' to start Claude Code\n'));
215
+ }
216
+
183
217
  console.log(chalk.blue(' ──────────────────────────────────────────────────────────\n'));
184
218
 
185
- console.log(chalk.white(' To verify CodeBakers is working, ask the AI:\n'));
186
- console.log(chalk.green(' "Are you using CodeBakers?"\n'));
219
+ console.log(chalk.white(' Next step: Initialize patterns in your project:\n'));
220
+ console.log(chalk.cyan(' codebakers init\n'));
221
+
222
+ console.log(chalk.white(' To verify CodeBakers is working, ask the AI:\n'));
223
+ console.log(chalk.green(' "update codebakers patterns"\n'));
187
224
 
188
- console.log(chalk.gray(' The AI should respond with its CodeBakers status.'));
225
+ console.log(chalk.gray(' The AI should call the update_patterns MCP tool.'));
189
226
  console.log(chalk.gray(' Need help? https://codebakers.ai/docs\n'));
190
227
  }
package/src/index.ts CHANGED
@@ -32,7 +32,7 @@ import { join } from 'path';
32
32
  // Automatic Update Notification
33
33
  // ============================================
34
34
 
35
- const CURRENT_VERSION = '3.3.5';
35
+ const CURRENT_VERSION = '3.3.7';
36
36
 
37
37
  async function checkForUpdatesInBackground(): Promise<void> {
38
38
  // Check if we have a valid cached result first (fast path)