@claude-flow/cli 3.0.0-alpha.12 → 3.0.0-alpha.14

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 (106) hide show
  1. package/dist/src/commands/doctor.d.ts.map +1 -1
  2. package/dist/src/commands/doctor.js +7 -3
  3. package/dist/src/commands/doctor.js.map +1 -1
  4. package/dist/tsconfig.tsbuildinfo +1 -1
  5. package/package.json +12 -4
  6. package/.agentic-flow/intelligence.json +0 -17
  7. package/.claude-flow/agents/store.json +0 -16
  8. package/.claude-flow/daemon-state.json +0 -123
  9. package/.claude-flow/daemon-test.log +0 -0
  10. package/.claude-flow/daemon.log +0 -0
  11. package/.claude-flow/daemon2.log +0 -0
  12. package/.claude-flow/daemon3.log +0 -0
  13. package/.claude-flow/hive-mind/state.json +0 -51
  14. package/.claude-flow/metrics/agent-metrics.json +0 -1
  15. package/.claude-flow/metrics/codebase-map.json +0 -11
  16. package/.claude-flow/metrics/consolidation.json +0 -6
  17. package/.claude-flow/metrics/performance.json +0 -87
  18. package/.claude-flow/metrics/security-audit.json +0 -10
  19. package/.claude-flow/metrics/task-metrics.json +0 -10
  20. package/.claude-flow/metrics/test-gaps.json +0 -6
  21. package/__tests__/README.md +0 -140
  22. package/__tests__/TEST_SUMMARY.md +0 -144
  23. package/__tests__/cli.test.ts +0 -558
  24. package/__tests__/commands.test.ts +0 -726
  25. package/__tests__/config-adapter.test.ts +0 -362
  26. package/__tests__/config-loading.test.ts +0 -106
  27. package/__tests__/coverage/.tmp/coverage-0.json +0 -1
  28. package/__tests__/coverage/.tmp/coverage-1.json +0 -1
  29. package/__tests__/coverage/.tmp/coverage-2.json +0 -1
  30. package/__tests__/coverage/.tmp/coverage-3.json +0 -1
  31. package/__tests__/coverage/.tmp/coverage-4.json +0 -1
  32. package/__tests__/coverage/.tmp/coverage-5.json +0 -1
  33. package/__tests__/mcp-client.test.ts +0 -480
  34. package/__tests__/p1-commands.test.ts +0 -1064
  35. package/agents/architect.yaml +0 -11
  36. package/agents/coder.yaml +0 -11
  37. package/agents/reviewer.yaml +0 -10
  38. package/agents/security-architect.yaml +0 -10
  39. package/agents/tester.yaml +0 -10
  40. package/docs/CONFIG_LOADING.md +0 -236
  41. package/docs/IMPLEMENTATION_COMPLETE.md +0 -421
  42. package/docs/MCP_CLIENT_GUIDE.md +0 -620
  43. package/docs/REFACTORING_SUMMARY.md +0 -247
  44. package/scripts/publish.sh +0 -46
  45. package/src/commands/agent.ts +0 -955
  46. package/src/commands/claims.ts +0 -317
  47. package/src/commands/completions.ts +0 -558
  48. package/src/commands/config.ts +0 -452
  49. package/src/commands/daemon.ts +0 -621
  50. package/src/commands/deployment.ts +0 -323
  51. package/src/commands/doctor.ts +0 -378
  52. package/src/commands/embeddings.ts +0 -686
  53. package/src/commands/hive-mind.ts +0 -928
  54. package/src/commands/hooks.ts +0 -2603
  55. package/src/commands/index.ts +0 -154
  56. package/src/commands/init.ts +0 -597
  57. package/src/commands/mcp.ts +0 -753
  58. package/src/commands/memory.ts +0 -1161
  59. package/src/commands/migrate.ts +0 -447
  60. package/src/commands/neural.ts +0 -253
  61. package/src/commands/performance.ts +0 -292
  62. package/src/commands/plugins.ts +0 -316
  63. package/src/commands/process.ts +0 -695
  64. package/src/commands/providers.ts +0 -259
  65. package/src/commands/security.ts +0 -288
  66. package/src/commands/session.ts +0 -891
  67. package/src/commands/start.ts +0 -457
  68. package/src/commands/status.ts +0 -736
  69. package/src/commands/swarm.ts +0 -648
  70. package/src/commands/task.ts +0 -792
  71. package/src/commands/workflow.ts +0 -742
  72. package/src/config-adapter.ts +0 -210
  73. package/src/index.ts +0 -443
  74. package/src/infrastructure/in-memory-repositories.ts +0 -310
  75. package/src/init/claudemd-generator.ts +0 -631
  76. package/src/init/executor.ts +0 -762
  77. package/src/init/helpers-generator.ts +0 -628
  78. package/src/init/index.ts +0 -60
  79. package/src/init/mcp-generator.ts +0 -83
  80. package/src/init/settings-generator.ts +0 -284
  81. package/src/init/statusline-generator.ts +0 -211
  82. package/src/init/types.ts +0 -447
  83. package/src/mcp-client.ts +0 -241
  84. package/src/mcp-server.ts +0 -577
  85. package/src/mcp-tools/agent-tools.ts +0 -466
  86. package/src/mcp-tools/config-tools.ts +0 -370
  87. package/src/mcp-tools/hive-mind-tools.ts +0 -521
  88. package/src/mcp-tools/hooks-tools.ts +0 -1888
  89. package/src/mcp-tools/index.ts +0 -16
  90. package/src/mcp-tools/memory-tools.ts +0 -270
  91. package/src/mcp-tools/session-tools.ts +0 -359
  92. package/src/mcp-tools/swarm-tools.ts +0 -105
  93. package/src/mcp-tools/task-tools.ts +0 -347
  94. package/src/mcp-tools/types.ts +0 -33
  95. package/src/mcp-tools/workflow-tools.ts +0 -573
  96. package/src/output.ts +0 -639
  97. package/src/parser.ts +0 -417
  98. package/src/prompt.ts +0 -619
  99. package/src/services/index.ts +0 -15
  100. package/src/services/worker-daemon.ts +0 -726
  101. package/src/suggest.ts +0 -245
  102. package/src/types.ts +0 -287
  103. package/tmp.json +0 -0
  104. package/tsconfig.json +0 -16
  105. package/tsconfig.tsbuildinfo +0 -1
  106. package/vitest.config.ts +0 -13
@@ -1,521 +0,0 @@
1
- /**
2
- * Hive-Mind MCP Tools for CLI
3
- *
4
- * Tool definitions for collective intelligence and swarm coordination.
5
- */
6
-
7
- import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'node:fs';
8
- import { join } from 'node:path';
9
- import type { MCPTool } from './types.js';
10
-
11
- // Storage paths
12
- const STORAGE_DIR = '.claude-flow';
13
- const HIVE_DIR = 'hive-mind';
14
- const HIVE_FILE = 'state.json';
15
-
16
- interface HiveState {
17
- initialized: boolean;
18
- topology: 'mesh' | 'hierarchical' | 'ring' | 'star';
19
- queen?: {
20
- agentId: string;
21
- electedAt: string;
22
- term: number;
23
- };
24
- workers: string[];
25
- consensus: {
26
- pending: ConsensusProposal[];
27
- history: ConsensusResult[];
28
- };
29
- sharedMemory: Record<string, unknown>;
30
- createdAt: string;
31
- updatedAt: string;
32
- }
33
-
34
- interface ConsensusProposal {
35
- proposalId: string;
36
- type: string;
37
- value: unknown;
38
- proposedBy: string;
39
- proposedAt: string;
40
- votes: Record<string, boolean>;
41
- status: 'pending' | 'approved' | 'rejected';
42
- }
43
-
44
- interface ConsensusResult {
45
- proposalId: string;
46
- type: string;
47
- result: 'approved' | 'rejected';
48
- votes: { for: number; against: number };
49
- decidedAt: string;
50
- }
51
-
52
- function getHiveDir(): string {
53
- return join(process.cwd(), STORAGE_DIR, HIVE_DIR);
54
- }
55
-
56
- function getHivePath(): string {
57
- return join(getHiveDir(), HIVE_FILE);
58
- }
59
-
60
- function ensureHiveDir(): void {
61
- const dir = getHiveDir();
62
- if (!existsSync(dir)) {
63
- mkdirSync(dir, { recursive: true });
64
- }
65
- }
66
-
67
- function loadHiveState(): HiveState {
68
- try {
69
- const path = getHivePath();
70
- if (existsSync(path)) {
71
- const data = readFileSync(path, 'utf-8');
72
- return JSON.parse(data);
73
- }
74
- } catch {
75
- // Return default state on error
76
- }
77
- return {
78
- initialized: false,
79
- topology: 'mesh',
80
- workers: [],
81
- consensus: { pending: [], history: [] },
82
- sharedMemory: {},
83
- createdAt: new Date().toISOString(),
84
- updatedAt: new Date().toISOString(),
85
- };
86
- }
87
-
88
- function saveHiveState(state: HiveState): void {
89
- ensureHiveDir();
90
- state.updatedAt = new Date().toISOString();
91
- writeFileSync(getHivePath(), JSON.stringify(state, null, 2), 'utf-8');
92
- }
93
-
94
- export const hiveMindTools: MCPTool[] = [
95
- {
96
- name: 'hive-mind/init',
97
- description: 'Initialize the hive-mind collective',
98
- category: 'hive-mind',
99
- inputSchema: {
100
- type: 'object',
101
- properties: {
102
- topology: { type: 'string', enum: ['mesh', 'hierarchical', 'ring', 'star'], description: 'Network topology' },
103
- queenId: { type: 'string', description: 'Initial queen agent ID' },
104
- },
105
- },
106
- handler: async (input) => {
107
- const state = loadHiveState();
108
- const hiveId = `hive-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
109
- const queenId = (input.queenId as string) || `queen-${Date.now()}`;
110
-
111
- state.initialized = true;
112
- state.topology = (input.topology as HiveState['topology']) || 'mesh';
113
- state.createdAt = new Date().toISOString();
114
- state.queen = {
115
- agentId: queenId,
116
- electedAt: new Date().toISOString(),
117
- term: 1,
118
- };
119
-
120
- saveHiveState(state);
121
-
122
- return {
123
- success: true,
124
- hiveId,
125
- topology: state.topology,
126
- consensus: (input.consensus as string) || 'byzantine',
127
- queenId,
128
- status: 'initialized',
129
- config: {
130
- topology: state.topology,
131
- consensus: input.consensus || 'byzantine',
132
- maxAgents: input.maxAgents || 15,
133
- persist: input.persist !== false,
134
- memoryBackend: input.memoryBackend || 'hybrid',
135
- },
136
- createdAt: state.createdAt,
137
- };
138
- },
139
- },
140
- {
141
- name: 'hive-mind/status',
142
- description: 'Get hive-mind status',
143
- category: 'hive-mind',
144
- inputSchema: {
145
- type: 'object',
146
- properties: {
147
- verbose: { type: 'boolean', description: 'Include detailed information' },
148
- },
149
- },
150
- handler: async (input) => {
151
- const state = loadHiveState();
152
-
153
- const uptime = state.createdAt ? Date.now() - new Date(state.createdAt).getTime() : 0;
154
- const status = {
155
- // CLI expected fields
156
- hiveId: `hive-${state.createdAt ? new Date(state.createdAt).getTime() : Date.now()}`,
157
- status: state.initialized ? 'active' : 'offline',
158
- topology: state.topology,
159
- consensus: 'byzantine', // Default consensus type
160
- queen: state.queen ? {
161
- id: state.queen.agentId,
162
- agentId: state.queen.agentId,
163
- status: 'active',
164
- load: 0.3 + Math.random() * 0.4, // Simulated load
165
- tasksQueued: state.consensus.pending.length,
166
- electedAt: state.queen.electedAt,
167
- term: state.queen.term,
168
- } : { id: 'N/A', status: 'offline', load: 0, tasksQueued: 0 },
169
- workers: state.workers.map(w => ({
170
- id: w,
171
- type: 'worker',
172
- status: 'idle',
173
- currentTask: null,
174
- tasksCompleted: 0,
175
- })),
176
- metrics: {
177
- totalTasks: state.consensus.history.length + state.consensus.pending.length,
178
- completedTasks: state.consensus.history.length,
179
- failedTasks: 0,
180
- avgTaskTime: 150,
181
- consensusRounds: state.consensus.history.length,
182
- memoryUsage: `${Object.keys(state.sharedMemory).length * 2} KB`,
183
- },
184
- health: {
185
- overall: 'healthy',
186
- queen: state.queen ? 'healthy' : 'unhealthy',
187
- workers: state.workers.length > 0 ? 'healthy' : 'degraded',
188
- consensus: 'healthy',
189
- memory: 'healthy',
190
- },
191
- // Additional fields
192
- id: `hive-${state.createdAt ? new Date(state.createdAt).getTime() : Date.now()}`,
193
- initialized: state.initialized,
194
- workerCount: state.workers.length,
195
- pendingConsensus: state.consensus.pending.length,
196
- sharedMemoryKeys: Object.keys(state.sharedMemory).length,
197
- uptime,
198
- createdAt: state.createdAt,
199
- updatedAt: state.updatedAt,
200
- };
201
-
202
- if (input.verbose) {
203
- return {
204
- ...status,
205
- workerDetails: state.workers,
206
- consensusHistory: state.consensus.history.slice(-10),
207
- sharedMemory: state.sharedMemory,
208
- };
209
- }
210
-
211
- return status;
212
- },
213
- },
214
- {
215
- name: 'hive-mind/join',
216
- description: 'Join an agent to the hive-mind',
217
- category: 'hive-mind',
218
- inputSchema: {
219
- type: 'object',
220
- properties: {
221
- agentId: { type: 'string', description: 'Agent ID to join' },
222
- role: { type: 'string', enum: ['worker', 'specialist', 'scout'], description: 'Agent role in hive' },
223
- },
224
- required: ['agentId'],
225
- },
226
- handler: async (input) => {
227
- const state = loadHiveState();
228
- const agentId = input.agentId as string;
229
-
230
- if (!state.initialized) {
231
- return { success: false, error: 'Hive-mind not initialized' };
232
- }
233
-
234
- if (!state.workers.includes(agentId)) {
235
- state.workers.push(agentId);
236
- saveHiveState(state);
237
- }
238
-
239
- return {
240
- success: true,
241
- agentId,
242
- role: input.role || 'worker',
243
- totalWorkers: state.workers.length,
244
- joinedAt: new Date().toISOString(),
245
- };
246
- },
247
- },
248
- {
249
- name: 'hive-mind/leave',
250
- description: 'Remove an agent from the hive-mind',
251
- category: 'hive-mind',
252
- inputSchema: {
253
- type: 'object',
254
- properties: {
255
- agentId: { type: 'string', description: 'Agent ID to remove' },
256
- },
257
- required: ['agentId'],
258
- },
259
- handler: async (input) => {
260
- const state = loadHiveState();
261
- const agentId = input.agentId as string;
262
-
263
- const index = state.workers.indexOf(agentId);
264
- if (index > -1) {
265
- state.workers.splice(index, 1);
266
- saveHiveState(state);
267
- return {
268
- success: true,
269
- agentId,
270
- leftAt: new Date().toISOString(),
271
- remainingWorkers: state.workers.length,
272
- };
273
- }
274
-
275
- return { success: false, agentId, error: 'Agent not in hive' };
276
- },
277
- },
278
- {
279
- name: 'hive-mind/consensus',
280
- description: 'Propose or vote on consensus',
281
- category: 'hive-mind',
282
- inputSchema: {
283
- type: 'object',
284
- properties: {
285
- action: { type: 'string', enum: ['propose', 'vote', 'status', 'list'], description: 'Consensus action' },
286
- proposalId: { type: 'string', description: 'Proposal ID (for vote/status)' },
287
- type: { type: 'string', description: 'Proposal type (for propose)' },
288
- value: { description: 'Proposal value (for propose)' },
289
- vote: { type: 'boolean', description: 'Vote (true=for, false=against)' },
290
- voterId: { type: 'string', description: 'Voter agent ID' },
291
- },
292
- required: ['action'],
293
- },
294
- handler: async (input) => {
295
- const state = loadHiveState();
296
- const action = input.action as string;
297
-
298
- if (action === 'propose') {
299
- const proposalId = `proposal-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
300
- const proposal: ConsensusProposal = {
301
- proposalId,
302
- type: (input.type as string) || 'general',
303
- value: input.value,
304
- proposedBy: (input.voterId as string) || 'system',
305
- proposedAt: new Date().toISOString(),
306
- votes: {},
307
- status: 'pending',
308
- };
309
-
310
- state.consensus.pending.push(proposal);
311
- saveHiveState(state);
312
-
313
- return {
314
- action,
315
- proposalId,
316
- type: proposal.type,
317
- status: 'pending',
318
- requiredVotes: Math.ceil(state.workers.length / 2) + 1,
319
- };
320
- }
321
-
322
- if (action === 'vote') {
323
- const proposal = state.consensus.pending.find(p => p.proposalId === input.proposalId);
324
- if (!proposal) {
325
- return { action, error: 'Proposal not found' };
326
- }
327
-
328
- const voterId = input.voterId as string;
329
- proposal.votes[voterId] = input.vote as boolean;
330
-
331
- // Check if we have majority
332
- const votesFor = Object.values(proposal.votes).filter(v => v).length;
333
- const votesAgainst = Object.values(proposal.votes).filter(v => !v).length;
334
- const majority = Math.ceil(state.workers.length / 2) + 1;
335
-
336
- if (votesFor >= majority) {
337
- proposal.status = 'approved';
338
- state.consensus.history.push({
339
- proposalId: proposal.proposalId,
340
- type: proposal.type,
341
- result: 'approved',
342
- votes: { for: votesFor, against: votesAgainst },
343
- decidedAt: new Date().toISOString(),
344
- });
345
- state.consensus.pending = state.consensus.pending.filter(p => p.proposalId !== proposal.proposalId);
346
- } else if (votesAgainst >= majority) {
347
- proposal.status = 'rejected';
348
- state.consensus.history.push({
349
- proposalId: proposal.proposalId,
350
- type: proposal.type,
351
- result: 'rejected',
352
- votes: { for: votesFor, against: votesAgainst },
353
- decidedAt: new Date().toISOString(),
354
- });
355
- state.consensus.pending = state.consensus.pending.filter(p => p.proposalId !== proposal.proposalId);
356
- }
357
-
358
- saveHiveState(state);
359
-
360
- return {
361
- action,
362
- proposalId: proposal.proposalId,
363
- voterId,
364
- vote: input.vote,
365
- votesFor,
366
- votesAgainst,
367
- status: proposal.status,
368
- };
369
- }
370
-
371
- if (action === 'status') {
372
- const proposal = state.consensus.pending.find(p => p.proposalId === input.proposalId);
373
- if (!proposal) {
374
- // Check history
375
- const historical = state.consensus.history.find(h => h.proposalId === input.proposalId);
376
- if (historical) {
377
- return { action, ...historical, historical: true };
378
- }
379
- return { action, error: 'Proposal not found' };
380
- }
381
-
382
- const votesFor = Object.values(proposal.votes).filter(v => v).length;
383
- const votesAgainst = Object.values(proposal.votes).filter(v => !v).length;
384
-
385
- return {
386
- action,
387
- proposalId: proposal.proposalId,
388
- type: proposal.type,
389
- status: proposal.status,
390
- votesFor,
391
- votesAgainst,
392
- totalVotes: Object.keys(proposal.votes).length,
393
- requiredMajority: Math.ceil(state.workers.length / 2) + 1,
394
- };
395
- }
396
-
397
- if (action === 'list') {
398
- return {
399
- action,
400
- pending: state.consensus.pending.map(p => ({
401
- proposalId: p.proposalId,
402
- type: p.type,
403
- proposedAt: p.proposedAt,
404
- totalVotes: Object.keys(p.votes).length,
405
- })),
406
- recentHistory: state.consensus.history.slice(-5),
407
- };
408
- }
409
-
410
- return { action, error: 'Unknown action' };
411
- },
412
- },
413
- {
414
- name: 'hive-mind/broadcast',
415
- description: 'Broadcast message to all workers',
416
- category: 'hive-mind',
417
- inputSchema: {
418
- type: 'object',
419
- properties: {
420
- message: { type: 'string', description: 'Message to broadcast' },
421
- priority: { type: 'string', enum: ['low', 'normal', 'high', 'critical'], description: 'Message priority' },
422
- fromId: { type: 'string', description: 'Sender agent ID' },
423
- },
424
- required: ['message'],
425
- },
426
- handler: async (input) => {
427
- const state = loadHiveState();
428
-
429
- if (!state.initialized) {
430
- return { success: false, error: 'Hive-mind not initialized' };
431
- }
432
-
433
- const messageId = `msg-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
434
-
435
- // Store in shared memory
436
- const messages = (state.sharedMemory.broadcasts as Array<unknown>) || [];
437
- messages.push({
438
- messageId,
439
- message: input.message,
440
- priority: input.priority || 'normal',
441
- fromId: input.fromId || 'system',
442
- timestamp: new Date().toISOString(),
443
- });
444
-
445
- // Keep only last 100 broadcasts
446
- state.sharedMemory.broadcasts = messages.slice(-100);
447
- saveHiveState(state);
448
-
449
- return {
450
- success: true,
451
- messageId,
452
- recipients: state.workers.length,
453
- priority: input.priority || 'normal',
454
- broadcastAt: new Date().toISOString(),
455
- };
456
- },
457
- },
458
- {
459
- name: 'hive-mind/memory',
460
- description: 'Access hive shared memory',
461
- category: 'hive-mind',
462
- inputSchema: {
463
- type: 'object',
464
- properties: {
465
- action: { type: 'string', enum: ['get', 'set', 'delete', 'list'], description: 'Memory action' },
466
- key: { type: 'string', description: 'Memory key' },
467
- value: { description: 'Value to store (for set)' },
468
- },
469
- required: ['action'],
470
- },
471
- handler: async (input) => {
472
- const state = loadHiveState();
473
- const action = input.action as string;
474
- const key = input.key as string;
475
-
476
- if (action === 'get') {
477
- if (!key) return { action, error: 'Key required' };
478
- return {
479
- action,
480
- key,
481
- value: state.sharedMemory[key],
482
- exists: key in state.sharedMemory,
483
- };
484
- }
485
-
486
- if (action === 'set') {
487
- if (!key) return { action, error: 'Key required' };
488
- state.sharedMemory[key] = input.value;
489
- saveHiveState(state);
490
- return {
491
- action,
492
- key,
493
- success: true,
494
- updatedAt: new Date().toISOString(),
495
- };
496
- }
497
-
498
- if (action === 'delete') {
499
- if (!key) return { action, error: 'Key required' };
500
- const existed = key in state.sharedMemory;
501
- delete state.sharedMemory[key];
502
- saveHiveState(state);
503
- return {
504
- action,
505
- key,
506
- deleted: existed,
507
- };
508
- }
509
-
510
- if (action === 'list') {
511
- return {
512
- action,
513
- keys: Object.keys(state.sharedMemory),
514
- count: Object.keys(state.sharedMemory).length,
515
- };
516
- }
517
-
518
- return { action, error: 'Unknown action' };
519
- },
520
- },
521
- ];