@teambit/cli-mcp-server 0.0.0-01a64fc189fd54260378eef7ec9b3e522f9d6315

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.
@@ -0,0 +1,679 @@
1
+ "use strict";
2
+
3
+ function _chai() {
4
+ const data = require("chai");
5
+ _chai = function () {
6
+ return data;
7
+ };
8
+ return data;
9
+ }
10
+ function _index() {
11
+ const data = require("@modelcontextprotocol/sdk/client/index.js");
12
+ _index = function () {
13
+ return data;
14
+ };
15
+ return data;
16
+ }
17
+ function _stdio() {
18
+ const data = require("@modelcontextprotocol/sdk/client/stdio.js");
19
+ _stdio = function () {
20
+ return data;
21
+ };
22
+ return data;
23
+ }
24
+ function _workspaceTesting() {
25
+ const data = require("@teambit/workspace.testing.mock-workspace");
26
+ _workspaceTesting = function () {
27
+ return data;
28
+ };
29
+ return data;
30
+ }
31
+ function _componentTesting() {
32
+ const data = require("@teambit/component.testing.mock-components");
33
+ _componentTesting = function () {
34
+ return data;
35
+ };
36
+ return data;
37
+ }
38
+ function _harmonyTesting() {
39
+ const data = require("@teambit/harmony.testing.load-aspect");
40
+ _harmonyTesting = function () {
41
+ return data;
42
+ };
43
+ return data;
44
+ }
45
+ function _fsExtra() {
46
+ const data = _interopRequireDefault(require("fs-extra"));
47
+ _fsExtra = function () {
48
+ return data;
49
+ };
50
+ return data;
51
+ }
52
+ function _path() {
53
+ const data = _interopRequireDefault(require("path"));
54
+ _path = function () {
55
+ return data;
56
+ };
57
+ return data;
58
+ }
59
+ function _cliMcpServer() {
60
+ const data = require("./cli-mcp-server.aspect");
61
+ _cliMcpServer = function () {
62
+ return data;
63
+ };
64
+ return data;
65
+ }
66
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
67
+ /* eslint-disable import/extensions */
68
+ /* eslint-disable import/no-unresolved */
69
+
70
+ describe('CliMcpServer Integration Tests', function () {
71
+ this.timeout(30000); // Increased timeout for MCP server operations
72
+
73
+ let workspaceData;
74
+ let mcpClient;
75
+ let workspacePath;
76
+ before(async () => {
77
+ // Set up mock workspace with components
78
+ workspaceData = (0, _workspaceTesting().mockWorkspace)();
79
+ workspacePath = workspaceData.workspacePath;
80
+ await (0, _componentTesting().mockComponents)(workspacePath);
81
+ });
82
+ after(async () => {
83
+ await (0, _workspaceTesting().destroyWorkspace)(workspaceData);
84
+ });
85
+ beforeEach(async () => {
86
+ // Create MCP client and connect directly to the MCP server command
87
+ const transport = new (_stdio().StdioClientTransport)({
88
+ command: 'bit',
89
+ args: ['mcp-server', 'start'],
90
+ cwd: workspacePath
91
+ });
92
+ mcpClient = new (_index().Client)({
93
+ name: 'test-client',
94
+ version: '1.0.0'
95
+ }, {
96
+ capabilities: {}
97
+ });
98
+ await mcpClient.connect(transport);
99
+ });
100
+ afterEach(async () => {
101
+ // Clean up MCP client
102
+ if (mcpClient) {
103
+ await mcpClient.close();
104
+ }
105
+ });
106
+ describe('MCP Server Protocol', () => {
107
+ it('should list available tools', async () => {
108
+ const response = await mcpClient.listTools();
109
+ (0, _chai().expect)(response.tools).to.be.an('array');
110
+ (0, _chai().expect)(response.tools.length).to.be.greaterThan(0);
111
+
112
+ // Check for essential MCP tools
113
+ const toolNames = response.tools.map(tool => tool.name);
114
+ (0, _chai().expect)(toolNames).to.include('bit_workspace_info');
115
+ (0, _chai().expect)(toolNames).to.include('bit_component_details');
116
+ (0, _chai().expect)(toolNames).to.include('bit_commands_list');
117
+ (0, _chai().expect)(toolNames).to.include('bit_query');
118
+ (0, _chai().expect)(toolNames).to.include('bit_execute');
119
+ });
120
+ });
121
+ describe('Consumer Project Mode', () => {
122
+ let consumerProjectClient;
123
+ beforeEach(async () => {
124
+ // Create MCP client for consumer project mode
125
+ const transport = new (_stdio().StdioClientTransport)({
126
+ command: 'bit',
127
+ args: ['mcp-server', 'start', '--consumer-project'],
128
+ cwd: workspacePath
129
+ });
130
+ consumerProjectClient = new (_index().Client)({
131
+ name: 'test-consumer-client',
132
+ version: '1.0.0'
133
+ }, {
134
+ capabilities: {}
135
+ });
136
+ await consumerProjectClient.connect(transport);
137
+ });
138
+ afterEach(async () => {
139
+ if (consumerProjectClient) {
140
+ await consumerProjectClient.close();
141
+ }
142
+ });
143
+ it('should only enable bit_remote_search and bit_remote_component_details tools', async () => {
144
+ const response = await consumerProjectClient.listTools();
145
+ (0, _chai().expect)(response.tools).to.be.an('array');
146
+ const toolNames = response.tools.map(tool => tool.name);
147
+
148
+ // Should include only these two tools
149
+ (0, _chai().expect)(toolNames).to.include('bit_remote_search');
150
+ (0, _chai().expect)(toolNames).to.include('bit_remote_component_details');
151
+
152
+ // Should NOT include these tools that are available in regular mode
153
+ (0, _chai().expect)(toolNames).to.not.include('bit_workspace_info');
154
+ (0, _chai().expect)(toolNames).to.not.include('bit_component_details');
155
+ (0, _chai().expect)(toolNames).to.not.include('bit_commands_list');
156
+ (0, _chai().expect)(toolNames).to.not.include('bit_command_help');
157
+ (0, _chai().expect)(toolNames).to.not.include('bit_query');
158
+ (0, _chai().expect)(toolNames).to.not.include('bit_execute');
159
+
160
+ // Should NOT include the old separate tools
161
+ (0, _chai().expect)(toolNames).to.not.include('bit_show');
162
+ (0, _chai().expect)(toolNames).to.not.include('bit_schema');
163
+
164
+ // Should have exactly 2 tools
165
+ (0, _chai().expect)(toolNames).to.have.lengthOf(2);
166
+ });
167
+ it('should work with bit_remote_search tool', async () => {
168
+ const result = await consumerProjectClient.callTool({
169
+ name: 'bit_remote_search',
170
+ arguments: {
171
+ queries: ['button'],
172
+ cwd: workspacePath
173
+ }
174
+ });
175
+ (0, _chai().expect)(result).to.have.property('content');
176
+ (0, _chai().expect)(result.content).to.be.an('array');
177
+ (0, _chai().expect)(result.content[0]).to.have.property('type', 'text');
178
+ });
179
+ });
180
+ describe('bit_workspace_info tool', () => {
181
+ it('should get workspace information', async () => {
182
+ const result = await mcpClient.callTool({
183
+ name: 'bit_workspace_info',
184
+ arguments: {
185
+ cwd: workspacePath,
186
+ includeStatus: true,
187
+ includeList: true
188
+ }
189
+ });
190
+ (0, _chai().expect)(result).to.have.property('content');
191
+ (0, _chai().expect)(result.content).to.be.an('array');
192
+ (0, _chai().expect)(result.content[0]).to.have.property('type', 'text');
193
+ const content = JSON.parse(result.content[0].text);
194
+ (0, _chai().expect)(content).to.have.property('status');
195
+ (0, _chai().expect)(content).to.have.property('list');
196
+ });
197
+ it('should handle workspace info without optional parameters', async () => {
198
+ const result = await mcpClient.callTool({
199
+ name: 'bit_workspace_info',
200
+ arguments: {
201
+ cwd: workspacePath
202
+ }
203
+ });
204
+ (0, _chai().expect)(result).to.have.property('content');
205
+ (0, _chai().expect)(result.content).to.be.an('array');
206
+ (0, _chai().expect)(result.content[0]).to.have.property('type', 'text');
207
+ const content = JSON.parse(result.content[0].text);
208
+ (0, _chai().expect)(content).to.have.property('status');
209
+ });
210
+ });
211
+ describe('bit_component_details tool', () => {
212
+ it('should get component details for an existing component', async () => {
213
+ const firstComponentId = 'comp1';
214
+ const result = await mcpClient.callTool({
215
+ name: 'bit_component_details',
216
+ arguments: {
217
+ cwd: workspacePath,
218
+ componentName: firstComponentId,
219
+ includeSchema: false
220
+ }
221
+ });
222
+ (0, _chai().expect)(result).to.have.property('content');
223
+ (0, _chai().expect)(result.content).to.be.an('array');
224
+ (0, _chai().expect)(result.content[0]).to.have.property('type', 'text');
225
+ const content = JSON.parse(result.content[0].text);
226
+ (0, _chai().expect)(content).to.have.property('id');
227
+ (0, _chai().expect)(content).to.have.property('env');
228
+ });
229
+ it('should get component details with schema', async () => {
230
+ const firstComponentId = 'comp1';
231
+ const result = await mcpClient.callTool({
232
+ name: 'bit_component_details',
233
+ arguments: {
234
+ cwd: workspacePath,
235
+ componentName: firstComponentId,
236
+ includeSchema: true
237
+ }
238
+ });
239
+ (0, _chai().expect)(result).to.have.property('content');
240
+ (0, _chai().expect)(result.content).to.be.an('array');
241
+ (0, _chai().expect)(result.content[0]).to.have.property('type', 'text');
242
+ const content = JSON.parse(result.content[0].text);
243
+ (0, _chai().expect)(content).to.have.property('id');
244
+ (0, _chai().expect)(content).to.have.property('publicAPI');
245
+ });
246
+ it('should handle non-existent component gracefully', async () => {
247
+ const result = await mcpClient.callTool({
248
+ name: 'bit_component_details',
249
+ arguments: {
250
+ cwd: workspacePath,
251
+ componentName: 'non-existent/component'
252
+ }
253
+ });
254
+ (0, _chai().expect)(result).to.have.property('content');
255
+ (0, _chai().expect)(result.content).to.be.an('array');
256
+ (0, _chai().expect)(result.content[0]).to.have.property('type', 'text');
257
+
258
+ // Should return error information or component details
259
+ const content = result.content[0].text;
260
+ (0, _chai().expect)(content).to.be.a('string');
261
+ });
262
+ });
263
+ describe('bit_commands_list tool', () => {
264
+ it('should get basic commands list', async () => {
265
+ const result = await mcpClient.callTool({
266
+ name: 'bit_commands_list',
267
+ arguments: {}
268
+ });
269
+ (0, _chai().expect)(result).to.have.property('content');
270
+ (0, _chai().expect)(result.content).to.be.an('array');
271
+ (0, _chai().expect)(result.content[0]).to.have.property('type', 'text');
272
+ const content = JSON.parse(result.content[0].text);
273
+ (0, _chai().expect)(content).to.have.property('commands');
274
+ (0, _chai().expect)(content.commands).to.be.an('array');
275
+ (0, _chai().expect)(content.commands.length).to.be.greaterThan(0);
276
+
277
+ // Check command structure
278
+ const firstCommand = content.commands[0];
279
+ (0, _chai().expect)(firstCommand).to.have.property('name');
280
+ (0, _chai().expect)(firstCommand).to.have.property('description');
281
+ });
282
+ it('should get commands info with extended description', async () => {
283
+ const result = await mcpClient.callTool({
284
+ name: 'bit_commands_list',
285
+ arguments: {
286
+ extendedDescription: true,
287
+ internal: false
288
+ }
289
+ });
290
+ (0, _chai().expect)(result).to.have.property('content');
291
+ (0, _chai().expect)(result.content).to.be.an('array');
292
+ (0, _chai().expect)(result.content[0]).to.have.property('type', 'text');
293
+ const content = JSON.parse(result.content[0].text);
294
+ (0, _chai().expect)(content).to.have.property('commands');
295
+ (0, _chai().expect)(content.commands).to.be.an('array');
296
+ (0, _chai().expect)(content.commands.length).to.be.greaterThan(0);
297
+ });
298
+ });
299
+ describe('bit_command_help tool', () => {
300
+ it('should get help for a main command', async () => {
301
+ const result = await mcpClient.callTool({
302
+ name: 'bit_command_help',
303
+ arguments: {
304
+ command: 'status'
305
+ }
306
+ });
307
+ (0, _chai().expect)(result).to.have.property('content');
308
+ (0, _chai().expect)(result.content).to.be.an('array');
309
+ (0, _chai().expect)(result.content[0]).to.have.property('type', 'text');
310
+ const content = JSON.parse(result.content[0].text);
311
+ (0, _chai().expect)(content).to.have.property('name', 'status');
312
+ (0, _chai().expect)(content).to.have.property('description');
313
+ (0, _chai().expect)(content).to.have.property('options');
314
+ });
315
+ it('should get help for lane switch subcommand (private command)', async () => {
316
+ const result = await mcpClient.callTool({
317
+ name: 'bit_command_help',
318
+ arguments: {
319
+ command: 'lane',
320
+ subcommand: 'switch'
321
+ }
322
+ });
323
+ (0, _chai().expect)(result).to.have.property('content');
324
+ (0, _chai().expect)(result.content).to.be.an('array');
325
+ (0, _chai().expect)(result.content[0]).to.have.property('type', 'text');
326
+ const content = JSON.parse(result.content[0].text);
327
+ (0, _chai().expect)(content).to.have.property('name', 'lane switch');
328
+ (0, _chai().expect)(content).to.have.property('description');
329
+ (0, _chai().expect)(content.description).to.include('switch to the specified lane');
330
+ (0, _chai().expect)(content).to.have.property('arguments');
331
+ (0, _chai().expect)(content.arguments).to.be.an('array');
332
+ (0, _chai().expect)(content.arguments[0]).to.have.property('name', 'lane');
333
+ (0, _chai().expect)(content.arguments[0]).to.have.property('description');
334
+ });
335
+ it('should get help for a subcommand that exists', async () => {
336
+ const result = await mcpClient.callTool({
337
+ name: 'bit_command_help',
338
+ arguments: {
339
+ command: 'lane',
340
+ subcommand: 'show'
341
+ }
342
+ });
343
+ (0, _chai().expect)(result).to.have.property('content');
344
+ (0, _chai().expect)(result.content).to.be.an('array');
345
+ (0, _chai().expect)(result.content[0]).to.have.property('type', 'text');
346
+ const content = JSON.parse(result.content[0].text);
347
+ (0, _chai().expect)(content).to.have.property('name', 'lane show');
348
+ (0, _chai().expect)(content).to.have.property('description');
349
+ });
350
+ it('should return error for non-existent command', async () => {
351
+ const result = await mcpClient.callTool({
352
+ name: 'bit_command_help',
353
+ arguments: {
354
+ command: 'nonexistent'
355
+ }
356
+ });
357
+ (0, _chai().expect)(result).to.have.property('content');
358
+ (0, _chai().expect)(result.content).to.be.an('array');
359
+ (0, _chai().expect)(result.content[0]).to.have.property('type', 'text');
360
+ const content = result.content[0].text;
361
+ (0, _chai().expect)(content).to.include('Command not found: nonexistent');
362
+ });
363
+ it('should return error for non-existent subcommand', async () => {
364
+ const result = await mcpClient.callTool({
365
+ name: 'bit_command_help',
366
+ arguments: {
367
+ command: 'lane',
368
+ subcommand: 'nonexistent'
369
+ }
370
+ });
371
+ (0, _chai().expect)(result).to.have.property('content');
372
+ (0, _chai().expect)(result.content).to.be.an('array');
373
+ (0, _chai().expect)(result.content[0]).to.have.property('type', 'text');
374
+ const content = result.content[0].text;
375
+ (0, _chai().expect)(content).to.include('Command not found: lane nonexistent');
376
+ });
377
+ });
378
+ describe('bit_query tool', () => {
379
+ it('should execute read-only commands', async () => {
380
+ const result = await mcpClient.callTool({
381
+ name: 'bit_query',
382
+ arguments: {
383
+ cwd: workspacePath,
384
+ command: 'status'
385
+ }
386
+ });
387
+ (0, _chai().expect)(result).to.have.property('content');
388
+ (0, _chai().expect)(result.content).to.be.an('array');
389
+ (0, _chai().expect)(result.content[0]).to.have.property('type', 'text');
390
+
391
+ // Should return command output
392
+ const content = result.content[0].text;
393
+ (0, _chai().expect)(content).to.be.a('string');
394
+ });
395
+ it('should handle commands with arguments and flags', async () => {
396
+ const result = await mcpClient.callTool({
397
+ name: 'bit_query',
398
+ arguments: {
399
+ cwd: workspacePath,
400
+ command: 'list',
401
+ args: [],
402
+ flags: {
403
+ json: true
404
+ }
405
+ }
406
+ });
407
+ (0, _chai().expect)(result).to.have.property('content');
408
+ (0, _chai().expect)(result.content).to.be.an('array');
409
+ (0, _chai().expect)(result.content[0]).to.have.property('type', 'text');
410
+ const content = result.content[0].text;
411
+ (0, _chai().expect)(content).to.be.a('string');
412
+ });
413
+ });
414
+ describe('Error Handling', () => {
415
+ it('should handle invalid tool calls gracefully', async () => {
416
+ try {
417
+ await mcpClient.callTool({
418
+ name: 'non_existent_tool',
419
+ arguments: {}
420
+ });
421
+ _chai().expect.fail('Should have thrown an error for non-existent tool');
422
+ } catch (error) {
423
+ (0, _chai().expect)(error).to.exist;
424
+ }
425
+ });
426
+ it('should handle invalid workspace directory', async () => {
427
+ const result = await mcpClient.callTool({
428
+ name: 'bit_workspace_info',
429
+ arguments: {
430
+ cwd: '/non/existent/path'
431
+ }
432
+ });
433
+ (0, _chai().expect)(result).to.have.property('content');
434
+ (0, _chai().expect)(result.content).to.be.an('array');
435
+ (0, _chai().expect)(result.content[0]).to.have.property('type', 'text');
436
+
437
+ // Should return error information
438
+ const content = result.content[0].text;
439
+ (0, _chai().expect)(content).to.be.a('string');
440
+ });
441
+ });
442
+ });
443
+ describe('CliMcpServer Direct Aspect Tests', function () {
444
+ this.timeout(30000);
445
+ let workspaceData;
446
+ let mcpServer;
447
+ let workspacePath;
448
+ before(async () => {
449
+ // Set up mock workspace with components
450
+ workspaceData = (0, _workspaceTesting().mockWorkspace)();
451
+ workspacePath = workspaceData.workspacePath;
452
+ await (0, _componentTesting().mockComponents)(workspacePath);
453
+
454
+ // Load the aspect directly
455
+ mcpServer = await (0, _harmonyTesting().loadAspect)(_cliMcpServer().CliMcpServerAspect, workspacePath);
456
+ });
457
+ after(async () => {
458
+ await (0, _workspaceTesting().destroyWorkspace)(workspaceData);
459
+ });
460
+ describe('Setup Editor Methods', () => {
461
+ let setupWorkspaceData;
462
+ let setupWorkspacePath;
463
+ let setupMcpServer;
464
+ beforeEach(async () => {
465
+ // Create a separate mock workspace for setup testing
466
+ setupWorkspaceData = (0, _workspaceTesting().mockWorkspace)();
467
+ setupWorkspacePath = setupWorkspaceData.workspacePath;
468
+ await (0, _componentTesting().mockComponents)(setupWorkspacePath);
469
+
470
+ // Load the aspect for this workspace
471
+ setupMcpServer = await (0, _harmonyTesting().loadAspect)(_cliMcpServer().CliMcpServerAspect, setupWorkspacePath);
472
+ });
473
+ afterEach(async () => {
474
+ // Clean up the setup workspace
475
+ if (setupWorkspaceData) {
476
+ await (0, _workspaceTesting().destroyWorkspace)(setupWorkspaceData);
477
+ }
478
+ });
479
+ it('should handle unsupported editor gracefully', async () => {
480
+ try {
481
+ await mcpServer.setupEditor('unsupported-editor', {
482
+ isGlobal: false
483
+ });
484
+ _chai().expect.fail('Should have thrown an error for unsupported editor');
485
+ } catch (error) {
486
+ (0, _chai().expect)(error).to.exist;
487
+ (0, _chai().expect)(error.message).to.include('Editor "unsupported-editor" is not supported yet');
488
+ (0, _chai().expect)(error.message).to.include('Currently supported: vscode, cursor, windsurf, roo, cline');
489
+ }
490
+ });
491
+ it('should setup VS Code integration directly', async () => {
492
+ await setupMcpServer.setupEditor('vscode', {
493
+ isGlobal: false
494
+ }, setupWorkspacePath);
495
+
496
+ // Verify that the mcp.json file was created in the workspace directory
497
+ const vscodeMcpPath = _path().default.join(setupWorkspacePath, '.vscode', 'mcp.json');
498
+ const mcpExists = await _fsExtra().default.pathExists(vscodeMcpPath);
499
+ (0, _chai().expect)(mcpExists).to.be.true;
500
+
501
+ // Verify the content of the mcp.json file
502
+ const mcpConfig = await _fsExtra().default.readJson(vscodeMcpPath);
503
+ (0, _chai().expect)(mcpConfig).to.have.property('servers');
504
+ (0, _chai().expect)(mcpConfig.servers).to.have.property('bit-cli');
505
+ (0, _chai().expect)(mcpConfig.servers['bit-cli']).to.deep.equal({
506
+ type: 'stdio',
507
+ command: 'bit',
508
+ args: ['mcp-server', 'start']
509
+ });
510
+ });
511
+ it('should setup VS Code integration with consumer project options', async () => {
512
+ await setupMcpServer.setupEditor('vscode', {
513
+ consumerProject: true,
514
+ includeAdditional: 'status,list',
515
+ isGlobal: false
516
+ }, setupWorkspacePath);
517
+ const vscodeMcpPath = _path().default.join(setupWorkspacePath, '.vscode', 'mcp.json');
518
+ const mcpConfig = await _fsExtra().default.readJson(vscodeMcpPath);
519
+ (0, _chai().expect)(mcpConfig.servers['bit-cli'].args).to.include('--consumer-project');
520
+ (0, _chai().expect)(mcpConfig.servers['bit-cli'].args).to.include('--include-additional');
521
+ (0, _chai().expect)(mcpConfig.servers['bit-cli'].args).to.include('status,list');
522
+ });
523
+ it('should setup Cursor integration directly', async () => {
524
+ await setupMcpServer.setupEditor('cursor', {
525
+ isGlobal: false
526
+ }, setupWorkspacePath);
527
+
528
+ // Verify that the mcp.json file was created in the workspace directory
529
+ const cursorConfigPath = _path().default.join(setupWorkspacePath, '.cursor', 'mcp.json');
530
+ const configExists = await _fsExtra().default.pathExists(cursorConfigPath);
531
+ (0, _chai().expect)(configExists).to.be.true;
532
+
533
+ // Verify the content of the config file
534
+ const config = await _fsExtra().default.readJson(cursorConfigPath);
535
+ (0, _chai().expect)(config).to.have.property('mcpServers');
536
+ (0, _chai().expect)(config.mcpServers).to.have.property('bit');
537
+ (0, _chai().expect)(config.mcpServers.bit).to.deep.equal({
538
+ type: 'stdio',
539
+ command: 'bit',
540
+ args: ['mcp-server', 'start']
541
+ });
542
+ });
543
+ it('should setup Windsurf integration directly', async () => {
544
+ await setupMcpServer.setupEditor('windsurf', {
545
+ isGlobal: false
546
+ }, setupWorkspacePath);
547
+
548
+ // Verify that the mcp.json file was created in the workspace directory
549
+ const windsurfConfigPath = _path().default.join(setupWorkspacePath, '.windsurf', 'mcp.json');
550
+ const configExists = await _fsExtra().default.pathExists(windsurfConfigPath);
551
+ (0, _chai().expect)(configExists).to.be.true;
552
+
553
+ // Verify the content of the config file
554
+ const config = await _fsExtra().default.readJson(windsurfConfigPath);
555
+ (0, _chai().expect)(config).to.have.property('mcpServers');
556
+ (0, _chai().expect)(config.mcpServers).to.have.property('bit');
557
+ (0, _chai().expect)(config.mcpServers.bit).to.deep.equal({
558
+ type: 'stdio',
559
+ command: 'bit',
560
+ args: ['mcp-server', 'start']
561
+ });
562
+ });
563
+ it('should setup Roo Code integration directly', async () => {
564
+ await setupMcpServer.setupEditor('roo', {
565
+ isGlobal: false
566
+ }, setupWorkspacePath);
567
+
568
+ // Verify that the mcp.json file was created in the workspace directory
569
+ const rooConfigPath = _path().default.join(setupWorkspacePath, '.roo', 'mcp.json');
570
+ const configExists = await _fsExtra().default.pathExists(rooConfigPath);
571
+ (0, _chai().expect)(configExists).to.be.true;
572
+
573
+ // Verify the content of the config file
574
+ const config = await _fsExtra().default.readJson(rooConfigPath);
575
+ (0, _chai().expect)(config).to.have.property('mcpServers');
576
+ (0, _chai().expect)(config.mcpServers).to.have.property('bit');
577
+ (0, _chai().expect)(config.mcpServers.bit).to.deep.equal({
578
+ type: 'stdio',
579
+ command: 'bit',
580
+ args: ['mcp-server', 'start']
581
+ });
582
+ });
583
+ it('should throw error when trying to setup Roo Code globally', async () => {
584
+ try {
585
+ await setupMcpServer.setupEditor('roo', {
586
+ isGlobal: true
587
+ }, setupWorkspacePath);
588
+ _chai().expect.fail('Should have thrown an error for global Roo Code setup');
589
+ } catch (error) {
590
+ (0, _chai().expect)(error).to.exist;
591
+ (0, _chai().expect)(error.message).to.include('Roo Code global configuration is not supported');
592
+ (0, _chai().expect)(error.message).to.include('VS Code internal storage that cannot be accessed');
593
+ }
594
+ });
595
+ it('should merge with existing VS Code mcp.json config', async () => {
596
+ // First, create existing MCP config
597
+ const vscodeMcpPath = _path().default.join(setupWorkspacePath, '.vscode', 'mcp.json');
598
+ await _fsExtra().default.ensureDir(_path().default.dirname(vscodeMcpPath));
599
+ await _fsExtra().default.writeJson(vscodeMcpPath, {
600
+ servers: {
601
+ 'existing-server': {
602
+ type: 'stdio',
603
+ command: 'some-other-command',
604
+ args: ['start']
605
+ }
606
+ }
607
+ });
608
+
609
+ // Run setup
610
+ await setupMcpServer.setupEditor('vscode', {
611
+ isGlobal: false
612
+ }, setupWorkspacePath);
613
+
614
+ // Verify that existing MCP config is preserved and Bit config is added
615
+ const mcpConfig = await _fsExtra().default.readJson(vscodeMcpPath);
616
+ (0, _chai().expect)(mcpConfig.servers).to.have.property('existing-server');
617
+ (0, _chai().expect)(mcpConfig.servers['existing-server']).to.deep.equal({
618
+ type: 'stdio',
619
+ command: 'some-other-command',
620
+ args: ['start']
621
+ });
622
+ (0, _chai().expect)(mcpConfig.servers).to.have.property('bit-cli');
623
+ (0, _chai().expect)(mcpConfig.servers['bit-cli']).to.deep.equal({
624
+ type: 'stdio',
625
+ command: 'bit',
626
+ args: ['mcp-server', 'start']
627
+ });
628
+ });
629
+ });
630
+ describe('Rules Methods', () => {
631
+ it('should get rules content without error', async () => {
632
+ // This test reproduces the bug where bit-rules-template.md was not found
633
+ const rulesContent = await mcpServer.getRulesContent(false);
634
+ (0, _chai().expect)(rulesContent).to.be.a('string');
635
+ (0, _chai().expect)(rulesContent).to.contain('# Bit MCP Agent Instructions');
636
+ (0, _chai().expect)(rulesContent).to.contain('Core Objectives');
637
+ });
638
+ it('should get consumer project rules content without error', async () => {
639
+ const rulesContent = await mcpServer.getRulesContent(true);
640
+ (0, _chai().expect)(rulesContent).to.be.a('string');
641
+ (0, _chai().expect)(rulesContent).to.contain('## How to Install and Use Bit Components');
642
+ (0, _chai().expect)(rulesContent).to.contain('Bit Components are reusable pieces of code');
643
+ });
644
+ it('should write rules file for VS Code without error', async () => {
645
+ await mcpServer.writeRulesFile('vscode', {
646
+ isGlobal: false,
647
+ consumerProject: false
648
+ }, workspacePath);
649
+
650
+ // Check that the rules file was created
651
+ const rulesPath = _path().default.join(workspacePath, '.github', 'instructions', 'bit.instructions.md');
652
+ const rulesExists = await _fsExtra().default.pathExists(rulesPath);
653
+ (0, _chai().expect)(rulesExists).to.be.true;
654
+
655
+ // Check content
656
+ const rulesContent = await _fsExtra().default.readFile(rulesPath, 'utf8');
657
+ (0, _chai().expect)(rulesContent).to.contain('# Bit MCP Agent Instructions');
658
+ (0, _chai().expect)(rulesContent).to.contain('Core Objectives');
659
+ });
660
+ it('should write consumer project rules file without error', async () => {
661
+ await mcpServer.writeRulesFile('vscode', {
662
+ isGlobal: false,
663
+ consumerProject: true
664
+ }, workspacePath);
665
+
666
+ // Check that the rules file was created
667
+ const rulesPath = _path().default.join(workspacePath, '.github', 'instructions', 'bit.instructions.md');
668
+ const rulesExists = await _fsExtra().default.pathExists(rulesPath);
669
+ (0, _chai().expect)(rulesExists).to.be.true;
670
+
671
+ // Check content is different for consumer project
672
+ const rulesContent = await _fsExtra().default.readFile(rulesPath, 'utf8');
673
+ (0, _chai().expect)(rulesContent).to.contain('## How to Install and Use Bit Components');
674
+ (0, _chai().expect)(rulesContent).to.contain('Bit Components are reusable pieces of code');
675
+ });
676
+ });
677
+ });
678
+
679
+ //# sourceMappingURL=cli-mcp-server.spec.js.map