@codebakers/cli 3.3.2 → 3.3.3

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.
@@ -960,6 +960,20 @@ class CodeBakersServer {
960
960
  },
961
961
  },
962
962
  },
963
+ {
964
+ name: 'detect_intent',
965
+ description: 'CALL THIS FIRST when user request is ambiguous or could match multiple MCP tools. Analyzes user input and returns which MCP tool(s) would be appropriate, with explanations. Show the result to the user and ask for confirmation before executing. This prevents accidental destructive actions.',
966
+ inputSchema: {
967
+ type: 'object',
968
+ properties: {
969
+ userMessage: {
970
+ type: 'string',
971
+ description: 'The user\'s message or request to analyze',
972
+ },
973
+ },
974
+ required: ['userMessage'],
975
+ },
976
+ },
963
977
  ],
964
978
  }));
965
979
  // Handle tool calls
@@ -1049,6 +1063,8 @@ class CodeBakersServer {
1049
1063
  return this.handleCheckUpdateNotification();
1050
1064
  case 'update_patterns':
1051
1065
  return this.handleUpdatePatterns(args);
1066
+ case 'detect_intent':
1067
+ return this.handleDetectIntent(args);
1052
1068
  default:
1053
1069
  throw new types_js_1.McpError(types_js_1.ErrorCode.MethodNotFound, `Unknown tool: ${name}`);
1054
1070
  }
@@ -4678,6 +4694,143 @@ ${handlers.join('\n')}
4678
4694
  }],
4679
4695
  };
4680
4696
  }
4697
+ /**
4698
+ * Detect intent from user message and suggest appropriate MCP tools
4699
+ * Shows what would happen before executing, for user confirmation
4700
+ */
4701
+ handleDetectIntent(args) {
4702
+ const { userMessage } = args;
4703
+ const msg = userMessage.toLowerCase();
4704
+ // Define intent patterns with their MCP tools
4705
+ const intentPatterns = [
4706
+ {
4707
+ keywords: ['upgrade codebakers', 'update patterns', 'sync patterns', 'download patterns', 'get latest patterns'],
4708
+ tool: 'update_patterns',
4709
+ description: 'Download latest CLAUDE.md and all .claude/ modules from the CodeBakers server',
4710
+ action: 'WRITE - Will overwrite local pattern files with server versions',
4711
+ isDestructive: true,
4712
+ },
4713
+ {
4714
+ keywords: ['upgrade', 'improve code', 'make production ready', 'code quality'],
4715
+ tool: 'upgrade',
4716
+ description: 'Analyze your code for quality improvements (does NOT download patterns)',
4717
+ action: 'READ-ONLY - Analyzes code and suggests improvements',
4718
+ isDestructive: false,
4719
+ },
4720
+ {
4721
+ keywords: ['build', 'create project', 'new project', 'scaffold', 'start fresh'],
4722
+ tool: 'scaffold_project',
4723
+ description: 'Create a new project from scratch with CodeBakers patterns',
4724
+ action: 'WRITE - Will create new files and folders',
4725
+ isDestructive: true,
4726
+ },
4727
+ {
4728
+ keywords: ['add feature', 'implement', 'build feature', 'create feature'],
4729
+ tool: 'optimize_and_build',
4730
+ description: 'Optimize your feature request with AI and fetch relevant patterns',
4731
+ action: 'READ + ASSIST - Fetches patterns and guides implementation',
4732
+ isDestructive: false,
4733
+ },
4734
+ {
4735
+ keywords: ['audit', 'review code', 'check code', 'code review'],
4736
+ tool: 'run_audit',
4737
+ description: 'Run comprehensive code quality audit',
4738
+ action: 'READ-ONLY - Analyzes code and reports issues',
4739
+ isDestructive: false,
4740
+ },
4741
+ {
4742
+ keywords: ['heal', 'fix errors', 'auto-fix', 'fix bugs'],
4743
+ tool: 'heal',
4744
+ description: 'AI-powered error detection and automatic fixing',
4745
+ action: 'WRITE - May modify files to fix errors',
4746
+ isDestructive: true,
4747
+ },
4748
+ {
4749
+ keywords: ['design', 'clone design', 'copy design', 'match design'],
4750
+ tool: 'design',
4751
+ description: 'Clone a design from mockups, screenshots, or websites',
4752
+ action: 'WRITE - Will generate component files',
4753
+ isDestructive: true,
4754
+ },
4755
+ {
4756
+ keywords: ['status', 'progress', "what's built", 'where am i'],
4757
+ tool: 'project_status',
4758
+ description: 'Show current project build progress and stats',
4759
+ action: 'READ-ONLY - Shows project state',
4760
+ isDestructive: false,
4761
+ },
4762
+ {
4763
+ keywords: ['run tests', 'test', 'check tests'],
4764
+ tool: 'run_tests',
4765
+ description: 'Execute the project test suite',
4766
+ action: 'READ-ONLY - Runs tests and reports results',
4767
+ isDestructive: false,
4768
+ },
4769
+ {
4770
+ keywords: ['list patterns', 'show patterns', 'what patterns'],
4771
+ tool: 'list_patterns',
4772
+ description: 'List all available CodeBakers patterns',
4773
+ action: 'READ-ONLY - Shows available patterns',
4774
+ isDestructive: false,
4775
+ },
4776
+ {
4777
+ keywords: ['init', 'initialize', 'add patterns to existing'],
4778
+ tool: 'init_project',
4779
+ description: 'Add CodeBakers patterns to an existing project',
4780
+ action: 'WRITE - Will add CLAUDE.md and .claude/ folder',
4781
+ isDestructive: true,
4782
+ },
4783
+ ];
4784
+ // Find matching intents
4785
+ const matches = intentPatterns.filter(pattern => pattern.keywords.some(keyword => msg.includes(keyword)));
4786
+ let response = `# 🔍 Intent Detection\n\n`;
4787
+ response += `**Your message:** "${userMessage}"\n\n`;
4788
+ if (matches.length === 0) {
4789
+ response += `## No specific MCP tool detected\n\n`;
4790
+ response += `Your request doesn't clearly match any MCP tool. I'll proceed with general assistance.\n\n`;
4791
+ response += `**Available tools you might want:**\n`;
4792
+ response += `- \`update_patterns\` - Download latest patterns from server\n`;
4793
+ response += `- \`optimize_and_build\` - Get AI help building a feature\n`;
4794
+ response += `- \`run_audit\` - Review your code quality\n`;
4795
+ response += `- \`project_status\` - Check build progress\n`;
4796
+ }
4797
+ else if (matches.length === 1) {
4798
+ const match = matches[0];
4799
+ response += `## Detected Intent\n\n`;
4800
+ response += `| Property | Value |\n`;
4801
+ response += `|----------|-------|\n`;
4802
+ response += `| **Tool** | \`${match.tool}\` |\n`;
4803
+ response += `| **Description** | ${match.description} |\n`;
4804
+ response += `| **Action Type** | ${match.action} |\n`;
4805
+ response += `| **Destructive?** | ${match.isDestructive ? '⚠️ YES - modifies files' : '✅ NO - read-only'} |\n\n`;
4806
+ if (match.isDestructive) {
4807
+ response += `### ⚠️ Confirmation Required\n\n`;
4808
+ response += `This action will modify files. Do you want to proceed?\n\n`;
4809
+ response += `**Reply "yes" or "proceed" to execute, or describe what you actually want.**\n`;
4810
+ }
4811
+ else {
4812
+ response += `This is a read-only operation. Safe to proceed.\n\n`;
4813
+ response += `**Reply "yes" to execute, or clarify your request.**\n`;
4814
+ }
4815
+ }
4816
+ else {
4817
+ response += `## Multiple Possible Intents\n\n`;
4818
+ response += `Your request could match several tools:\n\n`;
4819
+ matches.forEach((match, i) => {
4820
+ response += `### Option ${i + 1}: \`${match.tool}\`\n`;
4821
+ response += `- **What it does:** ${match.description}\n`;
4822
+ response += `- **Action:** ${match.action}\n`;
4823
+ response += `- **Destructive:** ${match.isDestructive ? '⚠️ Yes' : '✅ No'}\n\n`;
4824
+ });
4825
+ response += `**Which option do you want?** Reply with the tool name or option number.\n`;
4826
+ }
4827
+ return {
4828
+ content: [{
4829
+ type: 'text',
4830
+ text: response,
4831
+ }],
4832
+ };
4833
+ }
4681
4834
  async run() {
4682
4835
  const transport = new stdio_js_1.StdioServerTransport();
4683
4836
  await this.server.connect(transport);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codebakers/cli",
3
- "version": "3.3.2",
3
+ "version": "3.3.3",
4
4
  "description": "CodeBakers CLI - Production patterns for AI-assisted development",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
package/src/mcp/server.ts CHANGED
@@ -1047,6 +1047,21 @@ class CodeBakersServer {
1047
1047
  },
1048
1048
  },
1049
1049
  },
1050
+ {
1051
+ name: 'detect_intent',
1052
+ description:
1053
+ 'CALL THIS FIRST when user request is ambiguous or could match multiple MCP tools. Analyzes user input and returns which MCP tool(s) would be appropriate, with explanations. Show the result to the user and ask for confirmation before executing. This prevents accidental destructive actions.',
1054
+ inputSchema: {
1055
+ type: 'object' as const,
1056
+ properties: {
1057
+ userMessage: {
1058
+ type: 'string',
1059
+ description: 'The user\'s message or request to analyze',
1060
+ },
1061
+ },
1062
+ required: ['userMessage'],
1063
+ },
1064
+ },
1050
1065
  ],
1051
1066
  }));
1052
1067
 
@@ -1180,6 +1195,9 @@ class CodeBakersServer {
1180
1195
  case 'update_patterns':
1181
1196
  return this.handleUpdatePatterns(args as { force?: boolean });
1182
1197
 
1198
+ case 'detect_intent':
1199
+ return this.handleDetectIntent(args as { userMessage: string });
1200
+
1183
1201
  default:
1184
1202
  throw new McpError(ErrorCode.MethodNotFound, `Unknown tool: ${name}`);
1185
1203
  }
@@ -5303,6 +5321,151 @@ ${handlers.join('\n')}
5303
5321
  };
5304
5322
  }
5305
5323
 
5324
+ /**
5325
+ * Detect intent from user message and suggest appropriate MCP tools
5326
+ * Shows what would happen before executing, for user confirmation
5327
+ */
5328
+ private handleDetectIntent(args: { userMessage: string }) {
5329
+ const { userMessage } = args;
5330
+ const msg = userMessage.toLowerCase();
5331
+
5332
+ // Define intent patterns with their MCP tools
5333
+ const intentPatterns = [
5334
+ {
5335
+ keywords: ['upgrade codebakers', 'update patterns', 'sync patterns', 'download patterns', 'get latest patterns'],
5336
+ tool: 'update_patterns',
5337
+ description: 'Download latest CLAUDE.md and all .claude/ modules from the CodeBakers server',
5338
+ action: 'WRITE - Will overwrite local pattern files with server versions',
5339
+ isDestructive: true,
5340
+ },
5341
+ {
5342
+ keywords: ['upgrade', 'improve code', 'make production ready', 'code quality'],
5343
+ tool: 'upgrade',
5344
+ description: 'Analyze your code for quality improvements (does NOT download patterns)',
5345
+ action: 'READ-ONLY - Analyzes code and suggests improvements',
5346
+ isDestructive: false,
5347
+ },
5348
+ {
5349
+ keywords: ['build', 'create project', 'new project', 'scaffold', 'start fresh'],
5350
+ tool: 'scaffold_project',
5351
+ description: 'Create a new project from scratch with CodeBakers patterns',
5352
+ action: 'WRITE - Will create new files and folders',
5353
+ isDestructive: true,
5354
+ },
5355
+ {
5356
+ keywords: ['add feature', 'implement', 'build feature', 'create feature'],
5357
+ tool: 'optimize_and_build',
5358
+ description: 'Optimize your feature request with AI and fetch relevant patterns',
5359
+ action: 'READ + ASSIST - Fetches patterns and guides implementation',
5360
+ isDestructive: false,
5361
+ },
5362
+ {
5363
+ keywords: ['audit', 'review code', 'check code', 'code review'],
5364
+ tool: 'run_audit',
5365
+ description: 'Run comprehensive code quality audit',
5366
+ action: 'READ-ONLY - Analyzes code and reports issues',
5367
+ isDestructive: false,
5368
+ },
5369
+ {
5370
+ keywords: ['heal', 'fix errors', 'auto-fix', 'fix bugs'],
5371
+ tool: 'heal',
5372
+ description: 'AI-powered error detection and automatic fixing',
5373
+ action: 'WRITE - May modify files to fix errors',
5374
+ isDestructive: true,
5375
+ },
5376
+ {
5377
+ keywords: ['design', 'clone design', 'copy design', 'match design'],
5378
+ tool: 'design',
5379
+ description: 'Clone a design from mockups, screenshots, or websites',
5380
+ action: 'WRITE - Will generate component files',
5381
+ isDestructive: true,
5382
+ },
5383
+ {
5384
+ keywords: ['status', 'progress', "what's built", 'where am i'],
5385
+ tool: 'project_status',
5386
+ description: 'Show current project build progress and stats',
5387
+ action: 'READ-ONLY - Shows project state',
5388
+ isDestructive: false,
5389
+ },
5390
+ {
5391
+ keywords: ['run tests', 'test', 'check tests'],
5392
+ tool: 'run_tests',
5393
+ description: 'Execute the project test suite',
5394
+ action: 'READ-ONLY - Runs tests and reports results',
5395
+ isDestructive: false,
5396
+ },
5397
+ {
5398
+ keywords: ['list patterns', 'show patterns', 'what patterns'],
5399
+ tool: 'list_patterns',
5400
+ description: 'List all available CodeBakers patterns',
5401
+ action: 'READ-ONLY - Shows available patterns',
5402
+ isDestructive: false,
5403
+ },
5404
+ {
5405
+ keywords: ['init', 'initialize', 'add patterns to existing'],
5406
+ tool: 'init_project',
5407
+ description: 'Add CodeBakers patterns to an existing project',
5408
+ action: 'WRITE - Will add CLAUDE.md and .claude/ folder',
5409
+ isDestructive: true,
5410
+ },
5411
+ ];
5412
+
5413
+ // Find matching intents
5414
+ const matches = intentPatterns.filter(pattern =>
5415
+ pattern.keywords.some(keyword => msg.includes(keyword))
5416
+ );
5417
+
5418
+ let response = `# 🔍 Intent Detection\n\n`;
5419
+ response += `**Your message:** "${userMessage}"\n\n`;
5420
+
5421
+ if (matches.length === 0) {
5422
+ response += `## No specific MCP tool detected\n\n`;
5423
+ response += `Your request doesn't clearly match any MCP tool. I'll proceed with general assistance.\n\n`;
5424
+ response += `**Available tools you might want:**\n`;
5425
+ response += `- \`update_patterns\` - Download latest patterns from server\n`;
5426
+ response += `- \`optimize_and_build\` - Get AI help building a feature\n`;
5427
+ response += `- \`run_audit\` - Review your code quality\n`;
5428
+ response += `- \`project_status\` - Check build progress\n`;
5429
+ } else if (matches.length === 1) {
5430
+ const match = matches[0];
5431
+ response += `## Detected Intent\n\n`;
5432
+ response += `| Property | Value |\n`;
5433
+ response += `|----------|-------|\n`;
5434
+ response += `| **Tool** | \`${match.tool}\` |\n`;
5435
+ response += `| **Description** | ${match.description} |\n`;
5436
+ response += `| **Action Type** | ${match.action} |\n`;
5437
+ response += `| **Destructive?** | ${match.isDestructive ? '⚠️ YES - modifies files' : '✅ NO - read-only'} |\n\n`;
5438
+
5439
+ if (match.isDestructive) {
5440
+ response += `### ⚠️ Confirmation Required\n\n`;
5441
+ response += `This action will modify files. Do you want to proceed?\n\n`;
5442
+ response += `**Reply "yes" or "proceed" to execute, or describe what you actually want.**\n`;
5443
+ } else {
5444
+ response += `This is a read-only operation. Safe to proceed.\n\n`;
5445
+ response += `**Reply "yes" to execute, or clarify your request.**\n`;
5446
+ }
5447
+ } else {
5448
+ response += `## Multiple Possible Intents\n\n`;
5449
+ response += `Your request could match several tools:\n\n`;
5450
+
5451
+ matches.forEach((match, i) => {
5452
+ response += `### Option ${i + 1}: \`${match.tool}\`\n`;
5453
+ response += `- **What it does:** ${match.description}\n`;
5454
+ response += `- **Action:** ${match.action}\n`;
5455
+ response += `- **Destructive:** ${match.isDestructive ? '⚠️ Yes' : '✅ No'}\n\n`;
5456
+ });
5457
+
5458
+ response += `**Which option do you want?** Reply with the tool name or option number.\n`;
5459
+ }
5460
+
5461
+ return {
5462
+ content: [{
5463
+ type: 'text' as const,
5464
+ text: response,
5465
+ }],
5466
+ };
5467
+ }
5468
+
5306
5469
  async run(): Promise<void> {
5307
5470
  const transport = new StdioServerTransport();
5308
5471
  await this.server.connect(transport);