claude-flow-novice 1.5.12 → 1.5.13

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 (40) hide show
  1. package/.claude-flow-novice/dist/mcp/auth.js +347 -0
  2. package/.claude-flow-novice/dist/mcp/claude-code-wrapper.js +717 -0
  3. package/.claude-flow-novice/dist/mcp/claude-flow-tools.js +1365 -0
  4. package/.claude-flow-novice/dist/mcp/client.js +201 -0
  5. package/.claude-flow-novice/dist/mcp/index.js +192 -0
  6. package/.claude-flow-novice/dist/mcp/integrate-wrapper.js +85 -0
  7. package/.claude-flow-novice/dist/mcp/lifecycle-manager.js +348 -0
  8. package/.claude-flow-novice/dist/mcp/load-balancer.js +386 -0
  9. package/.claude-flow-novice/dist/mcp/mcp-config-manager.js +1362 -0
  10. package/.claude-flow-novice/dist/mcp/mcp-server-novice-simplified.js +583 -0
  11. package/.claude-flow-novice/dist/mcp/mcp-server-novice.js +723 -0
  12. package/.claude-flow-novice/dist/mcp/mcp-server-sdk.js +649 -0
  13. package/.claude-flow-novice/dist/mcp/mcp-server.js +2256 -0
  14. package/.claude-flow-novice/dist/mcp/orchestration-integration.js +800 -0
  15. package/.claude-flow-novice/dist/mcp/performance-monitor.js +489 -0
  16. package/.claude-flow-novice/dist/mcp/protocol-manager.js +376 -0
  17. package/.claude-flow-novice/dist/mcp/router.js +220 -0
  18. package/.claude-flow-novice/dist/mcp/ruv-swarm-tools.js +671 -0
  19. package/.claude-flow-novice/dist/mcp/ruv-swarm-wrapper.js +254 -0
  20. package/.claude-flow-novice/dist/mcp/server-with-wrapper.js +32 -0
  21. package/.claude-flow-novice/dist/mcp/server-wrapper-mode.js +26 -0
  22. package/.claude-flow-novice/dist/mcp/server.js +539 -0
  23. package/.claude-flow-novice/dist/mcp/session-manager.js +338 -0
  24. package/.claude-flow-novice/dist/mcp/sparc-modes.js +455 -0
  25. package/.claude-flow-novice/dist/mcp/swarm-tools.js +903 -0
  26. package/.claude-flow-novice/dist/mcp/tools.js +426 -0
  27. package/.claude-flow-novice/dist/src/cli/commands/swarm.js +23 -1
  28. package/.claude-flow-novice/dist/src/cli/commands/swarm.js.map +1 -1
  29. package/.claude-flow-novice/dist/src/cli/simple-commands/init/templates/CLAUDE.md +40 -101
  30. package/.claude-flow-novice/dist/src/coordination/swarm-coordinator-factory.js +36 -0
  31. package/.claude-flow-novice/dist/src/coordination/swarm-coordinator-factory.js.map +1 -0
  32. package/.claude-flow-novice/dist/src/validators/index.js +12 -0
  33. package/.claude-flow-novice/dist/src/validators/index.js.map +1 -0
  34. package/.claude-flow-novice/dist/src/validators/swarm-init-validator.js +261 -0
  35. package/.claude-flow-novice/dist/src/validators/swarm-init-validator.js.map +1 -0
  36. package/.claude-flow-novice/dist/src/validators/todowrite-batching-validator.js +204 -0
  37. package/.claude-flow-novice/dist/src/validators/todowrite-batching-validator.js.map +1 -0
  38. package/.claude-flow-novice/dist/src/validators/todowrite-integration.js +189 -0
  39. package/.claude-flow-novice/dist/src/validators/todowrite-integration.js.map +1 -0
  40. package/package.json +2 -2
@@ -0,0 +1,671 @@
1
+ /**
2
+ * ruv-swarm MCP tools wrapper for Claude Code integration
3
+ *
4
+ * This module provides MCP tools that integrate with the external ruv-swarm
5
+ * package to enable advanced swarm coordination and neural capabilities.
6
+ */ import { execAsync } from '../utils/helpers.js';
7
+ // Import error fixes for agent_metrics, swarm_monitor, neural_train
8
+ let errorFixes;
9
+ try {
10
+ errorFixes = require('./fixes/mcp-error-fixes.js');
11
+ } catch (e) {
12
+ // Fallback if module not found
13
+ errorFixes = {
14
+ fixAgentMetrics: (d)=>d,
15
+ fixSwarmMonitor: (d)=>d,
16
+ fixNeuralTrain: (d)=>d,
17
+ wrapRuvSwarmResponse: (n, d)=>d
18
+ };
19
+ }
20
+ /**
21
+ * Execute ruv-swarm command with proper error handling
22
+ */ async function executeRuvSwarmCommand(command, args = [], context, logger) {
23
+ try {
24
+ const workDir = context?.workingDirectory || process.cwd();
25
+ const fullCommand = `npx ruv-swarm ${command} ${args.join(' ')}`;
26
+ logger?.debug('Executing ruv-swarm command', {
27
+ command: fullCommand,
28
+ workDir
29
+ });
30
+ const result = await execAsync(fullCommand, {
31
+ cwd: workDir
32
+ });
33
+ // Parse JSON response if possible
34
+ let data;
35
+ try {
36
+ data = JSON.parse(result.stdout);
37
+ } catch {
38
+ data = {
39
+ output: result.stdout,
40
+ stderr: result.stderr
41
+ };
42
+ }
43
+ logger?.debug('ruv-swarm command completed', {
44
+ command,
45
+ success: true
46
+ });
47
+ return {
48
+ success: true,
49
+ data,
50
+ metadata: {
51
+ timestamp: Date.now(),
52
+ swarmId: context?.swarmId,
53
+ sessionId: context?.sessionId
54
+ }
55
+ };
56
+ } catch (error) {
57
+ logger?.error('ruv-swarm command failed', {
58
+ command,
59
+ error: error instanceof Error ? error.message : String(error)
60
+ });
61
+ return {
62
+ success: false,
63
+ error: error instanceof Error ? error.message : String(error),
64
+ metadata: {
65
+ timestamp: Date.now(),
66
+ swarmId: context?.swarmId,
67
+ sessionId: context?.sessionId
68
+ }
69
+ };
70
+ }
71
+ }
72
+ /**
73
+ * Create ruv-swarm MCP tools for Claude Code integration
74
+ *
75
+ * These tools provide access to the full ruv-swarm functionality including:
76
+ * - Swarm initialization and management
77
+ * - Neural agent coordination
78
+ * - Memory and persistence
79
+ * - Performance monitoring
80
+ * - Task orchestration
81
+ */ export function createRuvSwarmTools(logger) {
82
+ return [
83
+ // === SWARM LIFECYCLE TOOLS ===
84
+ {
85
+ name: 'mcp__ruv-swarm__swarm_init',
86
+ description: 'Initialize a new ruv-swarm with specified topology and configuration',
87
+ inputSchema: {
88
+ type: 'object',
89
+ properties: {
90
+ topology: {
91
+ type: 'string',
92
+ enum: [
93
+ 'mesh',
94
+ 'hierarchical',
95
+ 'ring',
96
+ 'star'
97
+ ],
98
+ description: 'Swarm topology type'
99
+ },
100
+ maxAgents: {
101
+ type: 'number',
102
+ minimum: 1,
103
+ maximum: 100,
104
+ default: 5,
105
+ description: 'Maximum number of agents'
106
+ },
107
+ strategy: {
108
+ type: 'string',
109
+ enum: [
110
+ 'balanced',
111
+ 'specialized',
112
+ 'adaptive'
113
+ ],
114
+ default: 'balanced',
115
+ description: 'Distribution strategy'
116
+ }
117
+ },
118
+ required: [
119
+ 'topology'
120
+ ]
121
+ },
122
+ handler: async (input, context)=>{
123
+ const args = [
124
+ '--topology',
125
+ input.topology,
126
+ '--max-agents',
127
+ String(input.maxAgents || 5),
128
+ '--strategy',
129
+ input.strategy || 'balanced'
130
+ ];
131
+ return await executeRuvSwarmCommand('swarm init', args, context, logger);
132
+ }
133
+ },
134
+ {
135
+ name: 'mcp__ruv-swarm__swarm_status',
136
+ description: 'Get current swarm status and agent information',
137
+ inputSchema: {
138
+ type: 'object',
139
+ properties: {
140
+ verbose: {
141
+ type: 'boolean',
142
+ default: false,
143
+ description: 'Include detailed agent information'
144
+ }
145
+ }
146
+ },
147
+ handler: async (input, context)=>{
148
+ const args = input.verbose ? [
149
+ '--verbose'
150
+ ] : [];
151
+ return await executeRuvSwarmCommand('swarm status', args, context, logger);
152
+ }
153
+ },
154
+ {
155
+ name: 'mcp__ruv-swarm__swarm_monitor',
156
+ description: 'Monitor swarm activity in real-time',
157
+ inputSchema: {
158
+ type: 'object',
159
+ properties: {
160
+ duration: {
161
+ type: 'number',
162
+ default: 10,
163
+ description: 'Monitoring duration in seconds'
164
+ },
165
+ interval: {
166
+ type: 'number',
167
+ default: 1,
168
+ description: 'Update interval in seconds'
169
+ }
170
+ }
171
+ },
172
+ handler: async (input, context)=>{
173
+ const args = [
174
+ '--duration',
175
+ String(input.duration || 10),
176
+ '--interval',
177
+ String(input.interval || 1)
178
+ ];
179
+ const result = await executeRuvSwarmCommand('swarm monitor', args, context, logger);
180
+ // Apply fix to ensure recentEvents is an array
181
+ return errorFixes.fixSwarmMonitor(result);
182
+ }
183
+ },
184
+ // === AGENT MANAGEMENT TOOLS ===
185
+ {
186
+ name: 'mcp__ruv-swarm__agent_spawn',
187
+ description: 'Spawn a new agent in the swarm',
188
+ inputSchema: {
189
+ type: 'object',
190
+ properties: {
191
+ type: {
192
+ type: 'string',
193
+ enum: [
194
+ 'coordinator',
195
+ 'researcher',
196
+ 'coder',
197
+ 'analyst',
198
+ 'architect',
199
+ 'tester',
200
+ 'reviewer',
201
+ 'optimizer',
202
+ 'documenter',
203
+ 'monitor',
204
+ 'specialist'
205
+ ],
206
+ description: 'Agent type'
207
+ },
208
+ name: {
209
+ type: 'string',
210
+ description: 'Custom agent name'
211
+ },
212
+ capabilities: {
213
+ type: 'array',
214
+ items: {
215
+ type: 'string'
216
+ },
217
+ description: 'Agent capabilities'
218
+ }
219
+ },
220
+ required: [
221
+ 'type'
222
+ ]
223
+ },
224
+ handler: async (input, context)=>{
225
+ const args = [
226
+ '--type',
227
+ input.type
228
+ ];
229
+ if (input.name) {
230
+ args.push('--name', input.name);
231
+ }
232
+ if (input.capabilities && input.capabilities.length > 0) {
233
+ args.push('--capabilities', input.capabilities.join(','));
234
+ }
235
+ return await executeRuvSwarmCommand('agent spawn', args, context, logger);
236
+ }
237
+ },
238
+ {
239
+ name: 'mcp__ruv-swarm__agent_list',
240
+ description: 'List all active agents in the swarm',
241
+ inputSchema: {
242
+ type: 'object',
243
+ properties: {
244
+ filter: {
245
+ type: 'string',
246
+ enum: [
247
+ 'all',
248
+ 'active',
249
+ 'idle',
250
+ 'busy'
251
+ ],
252
+ default: 'all',
253
+ description: 'Filter agents by status'
254
+ }
255
+ }
256
+ },
257
+ handler: async (input, context)=>{
258
+ const args = [
259
+ '--filter',
260
+ input.filter || 'all'
261
+ ];
262
+ return await executeRuvSwarmCommand('agent list', args, context, logger);
263
+ }
264
+ },
265
+ {
266
+ name: 'mcp__ruv-swarm__agent_metrics',
267
+ description: 'Get performance metrics for agents',
268
+ inputSchema: {
269
+ type: 'object',
270
+ properties: {
271
+ agentId: {
272
+ type: 'string',
273
+ description: 'Specific agent ID (optional)'
274
+ },
275
+ metric: {
276
+ type: 'string',
277
+ enum: [
278
+ 'all',
279
+ 'cpu',
280
+ 'memory',
281
+ 'tasks',
282
+ 'performance'
283
+ ],
284
+ default: 'all'
285
+ }
286
+ }
287
+ },
288
+ handler: async (input, context)=>{
289
+ const args = [
290
+ '--metric',
291
+ input.metric || 'all'
292
+ ];
293
+ if (input.agentId) {
294
+ args.push('--agent-id', input.agentId);
295
+ }
296
+ const result = await executeRuvSwarmCommand('agent metrics', args, context, logger);
297
+ // Apply fix to ensure neuralNetworks is an array
298
+ return errorFixes.fixAgentMetrics(result);
299
+ }
300
+ },
301
+ // === TASK ORCHESTRATION TOOLS ===
302
+ {
303
+ name: 'mcp__ruv-swarm__task_orchestrate',
304
+ description: 'Orchestrate a task across the swarm',
305
+ inputSchema: {
306
+ type: 'object',
307
+ properties: {
308
+ task: {
309
+ type: 'string',
310
+ description: 'Task description or instructions'
311
+ },
312
+ strategy: {
313
+ type: 'string',
314
+ enum: [
315
+ 'parallel',
316
+ 'sequential',
317
+ 'adaptive'
318
+ ],
319
+ default: 'adaptive',
320
+ description: 'Execution strategy'
321
+ },
322
+ priority: {
323
+ type: 'string',
324
+ enum: [
325
+ 'low',
326
+ 'medium',
327
+ 'high',
328
+ 'critical'
329
+ ],
330
+ default: 'medium',
331
+ description: 'Task priority'
332
+ },
333
+ maxAgents: {
334
+ type: 'number',
335
+ minimum: 1,
336
+ maximum: 10,
337
+ description: 'Maximum agents to use'
338
+ }
339
+ },
340
+ required: [
341
+ 'task'
342
+ ]
343
+ },
344
+ handler: async (input, context)=>{
345
+ const args = [
346
+ '--task',
347
+ JSON.stringify(input.task),
348
+ '--strategy',
349
+ input.strategy || 'adaptive',
350
+ '--priority',
351
+ input.priority || 'medium'
352
+ ];
353
+ if (input.maxAgents) {
354
+ args.push('--max-agents', String(input.maxAgents));
355
+ }
356
+ return await executeRuvSwarmCommand('task orchestrate', args, context, logger);
357
+ }
358
+ },
359
+ {
360
+ name: 'mcp__ruv-swarm__task_status',
361
+ description: 'Check progress of running tasks',
362
+ inputSchema: {
363
+ type: 'object',
364
+ properties: {
365
+ taskId: {
366
+ type: 'string',
367
+ description: 'Specific task ID (optional)'
368
+ },
369
+ detailed: {
370
+ type: 'boolean',
371
+ default: false,
372
+ description: 'Include detailed progress'
373
+ }
374
+ }
375
+ },
376
+ handler: async (input, context)=>{
377
+ const args = [];
378
+ if (input.taskId) {
379
+ args.push('--task-id', input.taskId);
380
+ }
381
+ if (input.detailed) {
382
+ args.push('--detailed');
383
+ }
384
+ return await executeRuvSwarmCommand('task status', args, context, logger);
385
+ }
386
+ },
387
+ {
388
+ name: 'mcp__ruv-swarm__task_results',
389
+ description: 'Retrieve results from completed tasks',
390
+ inputSchema: {
391
+ type: 'object',
392
+ properties: {
393
+ taskId: {
394
+ type: 'string',
395
+ description: 'Task ID to retrieve results for'
396
+ },
397
+ format: {
398
+ type: 'string',
399
+ enum: [
400
+ 'summary',
401
+ 'detailed',
402
+ 'raw'
403
+ ],
404
+ default: 'summary',
405
+ description: 'Result format'
406
+ }
407
+ },
408
+ required: [
409
+ 'taskId'
410
+ ]
411
+ },
412
+ handler: async (input, context)=>{
413
+ const args = [
414
+ '--task-id',
415
+ input.taskId,
416
+ '--format',
417
+ input.format || 'summary'
418
+ ];
419
+ return await executeRuvSwarmCommand('task results', args, context, logger);
420
+ }
421
+ },
422
+ // === MEMORY AND PERSISTENCE TOOLS ===
423
+ {
424
+ name: 'mcp__ruv-swarm__memory_usage',
425
+ description: 'Get current memory usage statistics',
426
+ inputSchema: {
427
+ type: 'object',
428
+ properties: {
429
+ detail: {
430
+ type: 'string',
431
+ enum: [
432
+ 'summary',
433
+ 'detailed',
434
+ 'by-agent'
435
+ ],
436
+ default: 'summary',
437
+ description: 'Detail level'
438
+ }
439
+ }
440
+ },
441
+ handler: async (input, context)=>{
442
+ const args = [
443
+ '--detail',
444
+ input.detail || 'summary'
445
+ ];
446
+ return await executeRuvSwarmCommand('memory usage', args, context, logger);
447
+ }
448
+ },
449
+ // === NEURAL CAPABILITIES TOOLS ===
450
+ {
451
+ name: 'mcp__ruv-swarm__neural_status',
452
+ description: 'Get neural agent status and performance metrics',
453
+ inputSchema: {
454
+ type: 'object',
455
+ properties: {
456
+ agentId: {
457
+ type: 'string',
458
+ description: 'Specific agent ID (optional)'
459
+ }
460
+ }
461
+ },
462
+ handler: async (input, context)=>{
463
+ const args = [];
464
+ if (input.agentId) {
465
+ args.push('--agent-id', input.agentId);
466
+ }
467
+ return await executeRuvSwarmCommand('neural status', args, context, logger);
468
+ }
469
+ },
470
+ {
471
+ name: 'mcp__ruv-swarm__neural_train',
472
+ description: 'Train neural agents with sample tasks',
473
+ inputSchema: {
474
+ type: 'object',
475
+ properties: {
476
+ agentId: {
477
+ type: 'string',
478
+ description: 'Specific agent ID to train (optional)'
479
+ },
480
+ iterations: {
481
+ type: 'number',
482
+ minimum: 1,
483
+ maximum: 100,
484
+ default: 10,
485
+ description: 'Number of training iterations'
486
+ }
487
+ }
488
+ },
489
+ handler: async (input, context)=>{
490
+ // Apply fix to ensure agentId is valid
491
+ const fixedInput = errorFixes.fixNeuralTrain(input);
492
+ const args = [
493
+ '--iterations',
494
+ String(fixedInput.iterations || 10)
495
+ ];
496
+ if (fixedInput.agentId) {
497
+ args.push('--agent-id', fixedInput.agentId);
498
+ }
499
+ return await executeRuvSwarmCommand('neural train', args, context, logger);
500
+ }
501
+ },
502
+ {
503
+ name: 'mcp__ruv-swarm__neural_patterns',
504
+ description: 'Get cognitive pattern information',
505
+ inputSchema: {
506
+ type: 'object',
507
+ properties: {
508
+ pattern: {
509
+ type: 'string',
510
+ enum: [
511
+ 'all',
512
+ 'convergent',
513
+ 'divergent',
514
+ 'lateral',
515
+ 'systems',
516
+ 'critical',
517
+ 'abstract'
518
+ ],
519
+ default: 'all',
520
+ description: 'Cognitive pattern type'
521
+ }
522
+ }
523
+ },
524
+ handler: async (input, context)=>{
525
+ const args = [
526
+ '--pattern',
527
+ input.pattern || 'all'
528
+ ];
529
+ return await executeRuvSwarmCommand('neural patterns', args, context, logger);
530
+ }
531
+ },
532
+ // === PERFORMANCE AND BENCHMARKING TOOLS ===
533
+ {
534
+ name: 'mcp__ruv-swarm__benchmark_run',
535
+ description: 'Execute performance benchmarks',
536
+ inputSchema: {
537
+ type: 'object',
538
+ properties: {
539
+ type: {
540
+ type: 'string',
541
+ enum: [
542
+ 'all',
543
+ 'wasm',
544
+ 'swarm',
545
+ 'agent',
546
+ 'task'
547
+ ],
548
+ default: 'all',
549
+ description: 'Benchmark type'
550
+ },
551
+ iterations: {
552
+ type: 'number',
553
+ minimum: 1,
554
+ maximum: 100,
555
+ default: 10,
556
+ description: 'Number of iterations'
557
+ }
558
+ }
559
+ },
560
+ handler: async (input, context)=>{
561
+ const args = [
562
+ '--type',
563
+ input.type || 'all',
564
+ '--iterations',
565
+ String(input.iterations || 10)
566
+ ];
567
+ return await executeRuvSwarmCommand('benchmark run', args, context, logger);
568
+ }
569
+ },
570
+ {
571
+ name: 'mcp__ruv-swarm__features_detect',
572
+ description: 'Detect runtime features and capabilities',
573
+ inputSchema: {
574
+ type: 'object',
575
+ properties: {
576
+ category: {
577
+ type: 'string',
578
+ enum: [
579
+ 'all',
580
+ 'wasm',
581
+ 'simd',
582
+ 'memory',
583
+ 'platform'
584
+ ],
585
+ default: 'all',
586
+ description: 'Feature category'
587
+ }
588
+ }
589
+ },
590
+ handler: async (input, context)=>{
591
+ const args = [
592
+ '--category',
593
+ input.category || 'all'
594
+ ];
595
+ return await executeRuvSwarmCommand('features detect', args, context, logger);
596
+ }
597
+ }
598
+ ];
599
+ }
600
+ /**
601
+ * Check if ruv-swarm is available in the current environment
602
+ */ export async function isRuvSwarmAvailable(logger) {
603
+ try {
604
+ const result = await executeRuvSwarmCommand('--version', [], undefined, logger);
605
+ return result.success;
606
+ } catch (error) {
607
+ logger?.warn('ruv-swarm not available', {
608
+ error: error instanceof Error ? error instanceof Error ? error.message : String(error) : error
609
+ });
610
+ return false;
611
+ }
612
+ }
613
+ /**
614
+ * Get ruv-swarm configuration and capabilities
615
+ */ export async function getRuvSwarmCapabilities(logger) {
616
+ try {
617
+ const result = await executeRuvSwarmCommand('features detect', [
618
+ '--category',
619
+ 'all'
620
+ ], undefined, logger);
621
+ return result.data;
622
+ } catch (error) {
623
+ logger?.error('Failed to get ruv-swarm capabilities', error);
624
+ return null;
625
+ }
626
+ }
627
+ /**
628
+ * Initialize ruv-swarm with claude-code-flow integration
629
+ */ export async function initializeRuvSwarmIntegration(workingDirectory, logger) {
630
+ const context = {
631
+ workingDirectory,
632
+ sessionId: `claude-flow-${Date.now()}`
633
+ };
634
+ logger?.info('Initializing ruv-swarm integration', {
635
+ workingDirectory
636
+ });
637
+ // Check if ruv-swarm is available
638
+ const available = await isRuvSwarmAvailable(logger);
639
+ if (!available) {
640
+ return {
641
+ success: false,
642
+ error: 'ruv-swarm is not available. Please install it with: npm install -g ruv-swarm'
643
+ };
644
+ }
645
+ // Get capabilities
646
+ const capabilities = await getRuvSwarmCapabilities(logger);
647
+ logger?.info('ruv-swarm integration initialized', {
648
+ capabilities
649
+ });
650
+ return {
651
+ success: true,
652
+ data: {
653
+ available: true,
654
+ capabilities,
655
+ integration: 'claude-code-flow',
656
+ sessionId: context.sessionId
657
+ },
658
+ metadata: {
659
+ timestamp: Date.now(),
660
+ sessionId: context.sessionId
661
+ }
662
+ };
663
+ }
664
+ export default {
665
+ createRuvSwarmTools,
666
+ isRuvSwarmAvailable,
667
+ getRuvSwarmCapabilities,
668
+ initializeRuvSwarmIntegration
669
+ };
670
+
671
+ //# sourceMappingURL=ruv-swarm-tools.js.map