@codebakers/cli 1.0.6 → 1.0.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.
Files changed (2) hide show
  1. package/dist/index.js +96 -6
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -14,9 +14,10 @@ import chalk2 from "chalk";
14
14
  import inquirer from "inquirer";
15
15
  import chalk from "chalk";
16
16
  import ora from "ora";
17
- import { writeFile, mkdir } from "fs/promises";
17
+ import { writeFile, mkdir, readFile } from "fs/promises";
18
18
  import { existsSync } from "fs";
19
19
  import { join } from "path";
20
+ import { homedir } from "os";
20
21
 
21
22
  // src/utils/api.ts
22
23
  import nodeFetch from "node-fetch";
@@ -115,7 +116,7 @@ var IDE_CONFIGS = {
115
116
  },
116
117
  "claude-code": {
117
118
  file: "CLAUDE.md",
118
- description: "Claude Code CLI"
119
+ description: "Claude Code"
119
120
  }
120
121
  };
121
122
  function setupCommand(program2) {
@@ -184,7 +185,7 @@ Validation failed: ${validation.error || "Unknown error"}`));
184
185
  message: "Which AI coding tool are you using?",
185
186
  choices: [
186
187
  { name: "Cursor", value: "cursor" },
187
- { name: "Claude Code (CLI)", value: "claude-code" },
188
+ { name: "Claude Code (VS Code extension or CLI)", value: "claude-code" },
188
189
  { name: "Windsurf (Codeium)", value: "windsurf" },
189
190
  { name: "Aider", value: "aider" },
190
191
  { name: "Skip for now", value: null }
@@ -198,9 +199,30 @@ Validation failed: ${validation.error || "Unknown error"}`));
198
199
  }
199
200
  console.log(chalk.bold.green("\n\u{1F389} Setup complete!\n"));
200
201
  if (ide === "claude-code") {
201
- console.log(chalk.dim("Next step - add CodeBakers MCP server to Claude Code:"));
202
- console.log(chalk.dim(" (Run this command inside Claude Code chat, NOT in terminal)\n"));
203
- console.log(chalk.cyan(" /mcp add codebakers npx -y @codebakers/cli serve\n"));
202
+ const mcpConfigured = await configureMcpServer();
203
+ if (mcpConfigured) {
204
+ console.log(chalk.green("\u2713 MCP server configured automatically!\n"));
205
+ console.log(chalk.dim("Next steps:"));
206
+ console.log(chalk.dim(" 1. Restart Claude Code (close and reopen VS Code, or restart the CLI)"));
207
+ console.log(chalk.dim(" 2. CodeBakers patterns will be available via the MCP server\n"));
208
+ } else {
209
+ console.log(chalk.yellow("\n\u26A0 Could not auto-configure MCP server.\n"));
210
+ console.log(chalk.dim("Please add CodeBakers manually:"));
211
+ console.log(chalk.dim(""));
212
+ console.log(chalk.dim("Option 1 - In Claude Code chat, type:"));
213
+ console.log(chalk.cyan(" /mcp add codebakers npx -y @codebakers/cli serve"));
214
+ console.log(chalk.dim(""));
215
+ console.log(chalk.dim("Option 2 - Create .mcp.json in your project root:"));
216
+ console.log(chalk.cyan(` {
217
+ "mcpServers": {
218
+ "codebakers": {
219
+ "command": "npx",
220
+ "args": ["-y", "@codebakers/cli", "serve"]
221
+ }
222
+ }
223
+ }`));
224
+ console.log(chalk.dim("\nThen restart Claude Code.\n"));
225
+ }
204
226
  } else if (ide) {
205
227
  console.log(chalk.dim(`Pattern file created. Restart ${IDE_CONFIGS[ide].description} to load it.
206
228
  `));
@@ -306,6 +328,74 @@ message: |
306
328
  ${router.split("\n").map((line) => " " + line).join("\n")}
307
329
  `;
308
330
  }
331
+ async function configureMcpServer() {
332
+ const locations = [
333
+ // Project-level .mcp.json (preferred for portability)
334
+ join(process.cwd(), ".mcp.json"),
335
+ // User-level Claude settings
336
+ join(homedir(), ".claude", "settings.json"),
337
+ // Alternative user-level location
338
+ join(homedir(), ".claude.json")
339
+ ];
340
+ const mcpConfig = {
341
+ codebakers: {
342
+ command: "npx",
343
+ args: ["-y", "@codebakers/cli", "serve"]
344
+ }
345
+ };
346
+ const projectMcpPath = locations[0];
347
+ try {
348
+ let existingConfig = {};
349
+ if (existsSync(projectMcpPath)) {
350
+ try {
351
+ const content = await readFile(projectMcpPath, "utf-8");
352
+ existingConfig = JSON.parse(content);
353
+ } catch {
354
+ existingConfig = {};
355
+ }
356
+ }
357
+ const newConfig = {
358
+ ...existingConfig,
359
+ mcpServers: {
360
+ ...existingConfig.mcpServers || {},
361
+ ...mcpConfig
362
+ }
363
+ };
364
+ await writeFile(projectMcpPath, JSON.stringify(newConfig, null, 2), "utf-8");
365
+ console.log(chalk.dim(` Created/updated ${projectMcpPath}`));
366
+ return true;
367
+ } catch (error) {
368
+ }
369
+ for (const settingsPath of locations.slice(1)) {
370
+ try {
371
+ const dir = join(settingsPath, "..");
372
+ if (!existsSync(dir)) {
373
+ await mkdir(dir, { recursive: true });
374
+ }
375
+ let existingConfig = {};
376
+ if (existsSync(settingsPath)) {
377
+ try {
378
+ const content = await readFile(settingsPath, "utf-8");
379
+ existingConfig = JSON.parse(content);
380
+ } catch {
381
+ existingConfig = {};
382
+ }
383
+ }
384
+ const newConfig = {
385
+ ...existingConfig,
386
+ mcpServers: {
387
+ ...existingConfig.mcpServers || {},
388
+ ...mcpConfig
389
+ }
390
+ };
391
+ await writeFile(settingsPath, JSON.stringify(newConfig, null, 2), "utf-8");
392
+ console.log(chalk.dim(` Created/updated ${settingsPath}`));
393
+ return true;
394
+ } catch {
395
+ }
396
+ }
397
+ return false;
398
+ }
309
399
 
310
400
  // src/commands/serve.ts
311
401
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codebakers/cli",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "CodeBakers CLI - AI prompt patterns for production-ready code",
5
5
  "main": "dist/index.js",
6
6
  "bin": {