@codebakers/cli 3.9.14 → 3.9.15

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.
@@ -4185,15 +4185,21 @@ Just describe what you want to build! I'll automatically:
4185
4185
  responseText += `**Follow these established patterns for consistency.**\n\n`;
4186
4186
  }
4187
4187
  responseText += `---\n\n`;
4188
- // Section 1: Patterns from server
4188
+ // Section 1: Patterns from server (CONDENSED - not full content)
4189
4189
  if (result.patterns && result.patterns.length > 0) {
4190
4190
  responseText += `## 📦 MANDATORY PATTERNS\n\n`;
4191
- responseText += `You MUST follow these patterns in your code:\n\n`;
4191
+ responseText += `The following patterns apply to this task. Key rules are shown below:\n\n`;
4192
4192
  for (const pattern of result.patterns) {
4193
- responseText += `### ${pattern.name}\n\n`;
4194
- responseText += `**Relevance:** ${pattern.relevance}\n\n`;
4195
- responseText += `\`\`\`typescript\n${pattern.content || ''}\n\`\`\`\n\n`;
4193
+ responseText += `### ${pattern.name} (${pattern.relevance} relevance)\n\n`;
4194
+ // Extract only KEY RULES (first ~100 lines or critical sections)
4195
+ // This prevents 100K+ character responses
4196
+ const content = pattern.content || '';
4197
+ const condensed = this.extractKeyRules(content, pattern.name);
4198
+ if (condensed) {
4199
+ responseText += condensed + '\n\n';
4200
+ }
4196
4201
  }
4202
+ responseText += `> **Note:** These are condensed key rules. The full patterns are enforced server-side.\n\n`;
4197
4203
  }
4198
4204
  // Section 2: Test Requirements (ALL from server, not local file)
4199
4205
  responseText += `---\n\n`;
@@ -4313,6 +4319,68 @@ Just describe what you want to build! I'll automatically:
4313
4319
  const stopWords = ['the', 'and', 'for', 'add', 'fix', 'create', 'make', 'build', 'implement', 'update', 'modify', 'change', 'new', 'with', 'from', 'this', 'that'];
4314
4320
  return words.filter(w => !stopWords.includes(w));
4315
4321
  }
4322
+ /**
4323
+ * Extract key rules from pattern content (CONDENSED - max ~2000 chars per pattern)
4324
+ * This prevents 100K+ character responses that exceed token limits
4325
+ */
4326
+ extractKeyRules(content, patternName) {
4327
+ if (!content)
4328
+ return '';
4329
+ const MAX_CHARS = 2000; // ~50 lines max per pattern
4330
+ const lines = content.split('\n');
4331
+ // Strategy: Extract headers, key rules, and first code example
4332
+ const keyParts = [];
4333
+ let inCodeBlock = false;
4334
+ let codeBlockCount = 0;
4335
+ let currentSize = 0;
4336
+ for (const line of lines) {
4337
+ // Track code blocks
4338
+ if (line.trim().startsWith('```')) {
4339
+ inCodeBlock = !inCodeBlock;
4340
+ if (!inCodeBlock)
4341
+ codeBlockCount++;
4342
+ }
4343
+ // Skip if we've hit the limit
4344
+ if (currentSize > MAX_CHARS) {
4345
+ keyParts.push('...(truncated - server enforces full pattern)');
4346
+ break;
4347
+ }
4348
+ // Always include headers
4349
+ if (line.startsWith('#')) {
4350
+ keyParts.push(line);
4351
+ currentSize += line.length;
4352
+ continue;
4353
+ }
4354
+ // Include lines with key indicators
4355
+ const isKeyLine = line.includes('MUST') ||
4356
+ line.includes('NEVER') ||
4357
+ line.includes('ALWAYS') ||
4358
+ line.includes('REQUIRED') ||
4359
+ line.includes('MANDATORY') ||
4360
+ line.includes('DO NOT') ||
4361
+ line.includes('✅') ||
4362
+ line.includes('❌') ||
4363
+ line.includes('⚠️') ||
4364
+ line.startsWith('- ') ||
4365
+ line.startsWith('* ') ||
4366
+ line.startsWith('|'); // Tables
4367
+ if (isKeyLine && !inCodeBlock) {
4368
+ keyParts.push(line);
4369
+ currentSize += line.length;
4370
+ continue;
4371
+ }
4372
+ // Include first code example only
4373
+ if (inCodeBlock && codeBlockCount === 0) {
4374
+ keyParts.push(line);
4375
+ currentSize += line.length;
4376
+ }
4377
+ }
4378
+ // If we got nothing useful, return first N characters
4379
+ if (keyParts.length < 5) {
4380
+ return content.substring(0, MAX_CHARS) + '\n...(truncated)';
4381
+ }
4382
+ return keyParts.join('\n');
4383
+ }
4316
4384
  /**
4317
4385
  * Find files recursively with given extensions
4318
4386
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codebakers/cli",
3
- "version": "3.9.14",
3
+ "version": "3.9.15",
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
@@ -4652,15 +4652,25 @@ Just describe what you want to build! I'll automatically:
4652
4652
 
4653
4653
  responseText += `---\n\n`;
4654
4654
 
4655
- // Section 1: Patterns from server
4655
+ // Section 1: Patterns from server (CONDENSED - not full content)
4656
4656
  if (result.patterns && result.patterns.length > 0) {
4657
4657
  responseText += `## 📦 MANDATORY PATTERNS\n\n`;
4658
- responseText += `You MUST follow these patterns in your code:\n\n`;
4658
+ responseText += `The following patterns apply to this task. Key rules are shown below:\n\n`;
4659
+
4659
4660
  for (const pattern of result.patterns) {
4660
- responseText += `### ${pattern.name}\n\n`;
4661
- responseText += `**Relevance:** ${pattern.relevance}\n\n`;
4662
- responseText += `\`\`\`typescript\n${pattern.content || ''}\n\`\`\`\n\n`;
4661
+ responseText += `### ${pattern.name} (${pattern.relevance} relevance)\n\n`;
4662
+
4663
+ // Extract only KEY RULES (first ~100 lines or critical sections)
4664
+ // This prevents 100K+ character responses
4665
+ const content = pattern.content || '';
4666
+ const condensed = this.extractKeyRules(content, pattern.name);
4667
+
4668
+ if (condensed) {
4669
+ responseText += condensed + '\n\n';
4670
+ }
4663
4671
  }
4672
+
4673
+ responseText += `> **Note:** These are condensed key rules. The full patterns are enforced server-side.\n\n`;
4664
4674
  }
4665
4675
 
4666
4676
  // Section 2: Test Requirements (ALL from server, not local file)
@@ -4791,6 +4801,78 @@ Just describe what you want to build! I'll automatically:
4791
4801
  return words.filter(w => !stopWords.includes(w));
4792
4802
  }
4793
4803
 
4804
+ /**
4805
+ * Extract key rules from pattern content (CONDENSED - max ~2000 chars per pattern)
4806
+ * This prevents 100K+ character responses that exceed token limits
4807
+ */
4808
+ private extractKeyRules(content: string, patternName: string): string {
4809
+ if (!content) return '';
4810
+
4811
+ const MAX_CHARS = 2000; // ~50 lines max per pattern
4812
+ const lines = content.split('\n');
4813
+
4814
+ // Strategy: Extract headers, key rules, and first code example
4815
+ const keyParts: string[] = [];
4816
+ let inCodeBlock = false;
4817
+ let codeBlockCount = 0;
4818
+ let currentSize = 0;
4819
+
4820
+ for (const line of lines) {
4821
+ // Track code blocks
4822
+ if (line.trim().startsWith('```')) {
4823
+ inCodeBlock = !inCodeBlock;
4824
+ if (!inCodeBlock) codeBlockCount++;
4825
+ }
4826
+
4827
+ // Skip if we've hit the limit
4828
+ if (currentSize > MAX_CHARS) {
4829
+ keyParts.push('...(truncated - server enforces full pattern)');
4830
+ break;
4831
+ }
4832
+
4833
+ // Always include headers
4834
+ if (line.startsWith('#')) {
4835
+ keyParts.push(line);
4836
+ currentSize += line.length;
4837
+ continue;
4838
+ }
4839
+
4840
+ // Include lines with key indicators
4841
+ const isKeyLine =
4842
+ line.includes('MUST') ||
4843
+ line.includes('NEVER') ||
4844
+ line.includes('ALWAYS') ||
4845
+ line.includes('REQUIRED') ||
4846
+ line.includes('MANDATORY') ||
4847
+ line.includes('DO NOT') ||
4848
+ line.includes('✅') ||
4849
+ line.includes('❌') ||
4850
+ line.includes('⚠️') ||
4851
+ line.startsWith('- ') ||
4852
+ line.startsWith('* ') ||
4853
+ line.startsWith('|'); // Tables
4854
+
4855
+ if (isKeyLine && !inCodeBlock) {
4856
+ keyParts.push(line);
4857
+ currentSize += line.length;
4858
+ continue;
4859
+ }
4860
+
4861
+ // Include first code example only
4862
+ if (inCodeBlock && codeBlockCount === 0) {
4863
+ keyParts.push(line);
4864
+ currentSize += line.length;
4865
+ }
4866
+ }
4867
+
4868
+ // If we got nothing useful, return first N characters
4869
+ if (keyParts.length < 5) {
4870
+ return content.substring(0, MAX_CHARS) + '\n...(truncated)';
4871
+ }
4872
+
4873
+ return keyParts.join('\n');
4874
+ }
4875
+
4794
4876
  /**
4795
4877
  * Find files recursively with given extensions
4796
4878
  */