@claude-flow/cli 3.0.0-alpha.13 → 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 (102) hide show
  1. package/package.json +12 -4
  2. package/.agentic-flow/intelligence.json +0 -17
  3. package/.claude-flow/agents/store.json +0 -16
  4. package/.claude-flow/daemon-state.json +0 -123
  5. package/.claude-flow/daemon-test.log +0 -0
  6. package/.claude-flow/daemon.log +0 -0
  7. package/.claude-flow/daemon2.log +0 -0
  8. package/.claude-flow/daemon3.log +0 -0
  9. package/.claude-flow/hive-mind/state.json +0 -51
  10. package/.claude-flow/metrics/agent-metrics.json +0 -1
  11. package/.claude-flow/metrics/codebase-map.json +0 -11
  12. package/.claude-flow/metrics/consolidation.json +0 -6
  13. package/.claude-flow/metrics/performance.json +0 -87
  14. package/.claude-flow/metrics/security-audit.json +0 -10
  15. package/.claude-flow/metrics/task-metrics.json +0 -10
  16. package/.claude-flow/metrics/test-gaps.json +0 -6
  17. package/__tests__/README.md +0 -140
  18. package/__tests__/TEST_SUMMARY.md +0 -144
  19. package/__tests__/cli.test.ts +0 -558
  20. package/__tests__/commands.test.ts +0 -726
  21. package/__tests__/config-adapter.test.ts +0 -362
  22. package/__tests__/config-loading.test.ts +0 -106
  23. package/__tests__/coverage/.tmp/coverage-0.json +0 -1
  24. package/__tests__/coverage/.tmp/coverage-1.json +0 -1
  25. package/__tests__/coverage/.tmp/coverage-2.json +0 -1
  26. package/__tests__/coverage/.tmp/coverage-3.json +0 -1
  27. package/__tests__/coverage/.tmp/coverage-4.json +0 -1
  28. package/__tests__/coverage/.tmp/coverage-5.json +0 -1
  29. package/__tests__/mcp-client.test.ts +0 -480
  30. package/__tests__/p1-commands.test.ts +0 -1064
  31. package/agents/architect.yaml +0 -11
  32. package/agents/coder.yaml +0 -11
  33. package/agents/reviewer.yaml +0 -10
  34. package/agents/security-architect.yaml +0 -10
  35. package/agents/tester.yaml +0 -10
  36. package/docs/CONFIG_LOADING.md +0 -236
  37. package/docs/IMPLEMENTATION_COMPLETE.md +0 -421
  38. package/docs/MCP_CLIENT_GUIDE.md +0 -620
  39. package/docs/REFACTORING_SUMMARY.md +0 -247
  40. package/scripts/publish.sh +0 -46
  41. package/src/commands/agent.ts +0 -955
  42. package/src/commands/claims.ts +0 -317
  43. package/src/commands/completions.ts +0 -558
  44. package/src/commands/config.ts +0 -452
  45. package/src/commands/daemon.ts +0 -621
  46. package/src/commands/deployment.ts +0 -323
  47. package/src/commands/doctor.ts +0 -382
  48. package/src/commands/embeddings.ts +0 -686
  49. package/src/commands/hive-mind.ts +0 -928
  50. package/src/commands/hooks.ts +0 -2603
  51. package/src/commands/index.ts +0 -154
  52. package/src/commands/init.ts +0 -597
  53. package/src/commands/mcp.ts +0 -753
  54. package/src/commands/memory.ts +0 -1161
  55. package/src/commands/migrate.ts +0 -447
  56. package/src/commands/neural.ts +0 -253
  57. package/src/commands/performance.ts +0 -292
  58. package/src/commands/plugins.ts +0 -316
  59. package/src/commands/process.ts +0 -695
  60. package/src/commands/providers.ts +0 -259
  61. package/src/commands/security.ts +0 -288
  62. package/src/commands/session.ts +0 -891
  63. package/src/commands/start.ts +0 -457
  64. package/src/commands/status.ts +0 -736
  65. package/src/commands/swarm.ts +0 -648
  66. package/src/commands/task.ts +0 -792
  67. package/src/commands/workflow.ts +0 -742
  68. package/src/config-adapter.ts +0 -210
  69. package/src/index.ts +0 -443
  70. package/src/infrastructure/in-memory-repositories.ts +0 -310
  71. package/src/init/claudemd-generator.ts +0 -631
  72. package/src/init/executor.ts +0 -762
  73. package/src/init/helpers-generator.ts +0 -628
  74. package/src/init/index.ts +0 -60
  75. package/src/init/mcp-generator.ts +0 -83
  76. package/src/init/settings-generator.ts +0 -284
  77. package/src/init/statusline-generator.ts +0 -211
  78. package/src/init/types.ts +0 -447
  79. package/src/mcp-client.ts +0 -241
  80. package/src/mcp-server.ts +0 -577
  81. package/src/mcp-tools/agent-tools.ts +0 -466
  82. package/src/mcp-tools/config-tools.ts +0 -370
  83. package/src/mcp-tools/hive-mind-tools.ts +0 -521
  84. package/src/mcp-tools/hooks-tools.ts +0 -1888
  85. package/src/mcp-tools/index.ts +0 -16
  86. package/src/mcp-tools/memory-tools.ts +0 -270
  87. package/src/mcp-tools/session-tools.ts +0 -359
  88. package/src/mcp-tools/swarm-tools.ts +0 -105
  89. package/src/mcp-tools/task-tools.ts +0 -347
  90. package/src/mcp-tools/types.ts +0 -33
  91. package/src/mcp-tools/workflow-tools.ts +0 -573
  92. package/src/output.ts +0 -639
  93. package/src/parser.ts +0 -417
  94. package/src/prompt.ts +0 -619
  95. package/src/services/index.ts +0 -15
  96. package/src/services/worker-daemon.ts +0 -726
  97. package/src/suggest.ts +0 -245
  98. package/src/types.ts +0 -287
  99. package/tmp.json +0 -0
  100. package/tsconfig.json +0 -16
  101. package/tsconfig.tsbuildinfo +0 -1
  102. package/vitest.config.ts +0 -13
@@ -1,466 +0,0 @@
1
- /**
2
- * Agent MCP Tools for CLI
3
- *
4
- * Tool definitions for agent lifecycle management with file persistence.
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 AGENT_DIR = 'agents';
14
- const AGENT_FILE = 'store.json';
15
-
16
- interface AgentRecord {
17
- agentId: string;
18
- agentType: string;
19
- status: 'idle' | 'busy' | 'terminated';
20
- health: number;
21
- taskCount: number;
22
- config: Record<string, unknown>;
23
- createdAt: string;
24
- domain?: string;
25
- }
26
-
27
- interface AgentStore {
28
- agents: Record<string, AgentRecord>;
29
- version: string;
30
- }
31
-
32
- function getAgentDir(): string {
33
- return join(process.cwd(), STORAGE_DIR, AGENT_DIR);
34
- }
35
-
36
- function getAgentPath(): string {
37
- return join(getAgentDir(), AGENT_FILE);
38
- }
39
-
40
- function ensureAgentDir(): void {
41
- const dir = getAgentDir();
42
- if (!existsSync(dir)) {
43
- mkdirSync(dir, { recursive: true });
44
- }
45
- }
46
-
47
- function loadAgentStore(): AgentStore {
48
- try {
49
- const path = getAgentPath();
50
- if (existsSync(path)) {
51
- const data = readFileSync(path, 'utf-8');
52
- return JSON.parse(data);
53
- }
54
- } catch {
55
- // Return empty store on error
56
- }
57
- return { agents: {}, version: '3.0.0' };
58
- }
59
-
60
- function saveAgentStore(store: AgentStore): void {
61
- ensureAgentDir();
62
- writeFileSync(getAgentPath(), JSON.stringify(store, null, 2), 'utf-8');
63
- }
64
-
65
- export const agentTools: MCPTool[] = [
66
- {
67
- name: 'agent/spawn',
68
- description: 'Spawn a new agent',
69
- category: 'agent',
70
- inputSchema: {
71
- type: 'object',
72
- properties: {
73
- agentType: { type: 'string', description: 'Type of agent to spawn' },
74
- agentId: { type: 'string', description: 'Optional custom agent ID' },
75
- config: { type: 'object', description: 'Agent configuration' },
76
- domain: { type: 'string', description: 'Agent domain' },
77
- },
78
- required: ['agentType'],
79
- },
80
- handler: async (input) => {
81
- const store = loadAgentStore();
82
- const agentId = (input.agentId as string) || `agent-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
83
-
84
- const agent: AgentRecord = {
85
- agentId,
86
- agentType: input.agentType as string,
87
- status: 'idle',
88
- health: 1.0,
89
- taskCount: 0,
90
- config: (input.config as Record<string, unknown>) || {},
91
- createdAt: new Date().toISOString(),
92
- domain: input.domain as string,
93
- };
94
-
95
- store.agents[agentId] = agent;
96
- saveAgentStore(store);
97
-
98
- return {
99
- success: true,
100
- agentId,
101
- agentType: agent.agentType,
102
- status: 'spawned',
103
- createdAt: agent.createdAt,
104
- };
105
- },
106
- },
107
- {
108
- name: 'agent/terminate',
109
- description: 'Terminate an agent',
110
- category: 'agent',
111
- inputSchema: {
112
- type: 'object',
113
- properties: {
114
- agentId: { type: 'string', description: 'ID of agent to terminate' },
115
- force: { type: 'boolean', description: 'Force immediate termination' },
116
- },
117
- required: ['agentId'],
118
- },
119
- handler: async (input) => {
120
- const store = loadAgentStore();
121
- const agentId = input.agentId as string;
122
-
123
- if (store.agents[agentId]) {
124
- store.agents[agentId].status = 'terminated';
125
- saveAgentStore(store);
126
- return {
127
- success: true,
128
- agentId,
129
- terminated: true,
130
- terminatedAt: new Date().toISOString(),
131
- };
132
- }
133
-
134
- return {
135
- success: false,
136
- agentId,
137
- error: 'Agent not found',
138
- };
139
- },
140
- },
141
- {
142
- name: 'agent/status',
143
- description: 'Get agent status',
144
- category: 'agent',
145
- inputSchema: {
146
- type: 'object',
147
- properties: {
148
- agentId: { type: 'string', description: 'ID of agent' },
149
- },
150
- required: ['agentId'],
151
- },
152
- handler: async (input) => {
153
- const store = loadAgentStore();
154
- const agentId = input.agentId as string;
155
- const agent = store.agents[agentId];
156
-
157
- if (agent) {
158
- return {
159
- agentId: agent.agentId,
160
- agentType: agent.agentType,
161
- status: agent.status,
162
- health: agent.health,
163
- taskCount: agent.taskCount,
164
- createdAt: agent.createdAt,
165
- domain: agent.domain,
166
- };
167
- }
168
-
169
- return {
170
- agentId,
171
- status: 'not_found',
172
- error: 'Agent not found',
173
- };
174
- },
175
- },
176
- {
177
- name: 'agent/list',
178
- description: 'List all agents',
179
- category: 'agent',
180
- inputSchema: {
181
- type: 'object',
182
- properties: {
183
- status: { type: 'string', description: 'Filter by status' },
184
- domain: { type: 'string', description: 'Filter by domain' },
185
- includeTerminated: { type: 'boolean', description: 'Include terminated agents' },
186
- },
187
- },
188
- handler: async (input) => {
189
- const store = loadAgentStore();
190
- let agents = Object.values(store.agents);
191
-
192
- // Filter by status
193
- if (input.status) {
194
- agents = agents.filter(a => a.status === input.status);
195
- } else if (!input.includeTerminated) {
196
- agents = agents.filter(a => a.status !== 'terminated');
197
- }
198
-
199
- // Filter by domain
200
- if (input.domain) {
201
- agents = agents.filter(a => a.domain === input.domain);
202
- }
203
-
204
- return {
205
- agents: agents.map(a => ({
206
- agentId: a.agentId,
207
- agentType: a.agentType,
208
- status: a.status,
209
- health: a.health,
210
- taskCount: a.taskCount,
211
- createdAt: a.createdAt,
212
- domain: a.domain,
213
- })),
214
- total: agents.length,
215
- filters: {
216
- status: input.status,
217
- domain: input.domain,
218
- includeTerminated: input.includeTerminated,
219
- },
220
- };
221
- },
222
- },
223
- {
224
- name: 'agent/pool',
225
- description: 'Manage agent pool',
226
- category: 'agent',
227
- inputSchema: {
228
- type: 'object',
229
- properties: {
230
- action: { type: 'string', enum: ['status', 'scale', 'drain', 'fill'], description: 'Pool action' },
231
- targetSize: { type: 'number', description: 'Target pool size (for scale action)' },
232
- agentType: { type: 'string', description: 'Agent type filter' },
233
- },
234
- required: ['action'],
235
- },
236
- handler: async (input) => {
237
- const store = loadAgentStore();
238
- const agents = Object.values(store.agents).filter(a => a.status !== 'terminated');
239
- const action = (input.action as string) || 'status'; // Default to status
240
-
241
- if (action === 'status') {
242
- const byType: Record<string, number> = {};
243
- const byStatus: Record<string, number> = {};
244
- for (const agent of agents) {
245
- byType[agent.agentType] = (byType[agent.agentType] || 0) + 1;
246
- byStatus[agent.status] = (byStatus[agent.status] || 0) + 1;
247
- }
248
- const idleAgents = agents.filter(a => a.status === 'idle').length;
249
- const busyAgents = agents.filter(a => a.status === 'busy').length;
250
- const utilization = agents.length > 0 ? busyAgents / agents.length : 0;
251
- return {
252
- action,
253
- // CLI expected fields
254
- poolId: 'agent-pool-default',
255
- currentSize: agents.length,
256
- minSize: (input.min as number) || 0,
257
- maxSize: (input.max as number) || 100,
258
- autoScale: (input.autoScale as boolean) ?? false,
259
- utilization,
260
- agents: agents.map(a => ({
261
- id: a.agentId,
262
- type: a.agentType,
263
- status: a.status,
264
- })),
265
- // Additional fields
266
- id: 'agent-pool-default',
267
- size: agents.length,
268
- totalAgents: agents.length,
269
- byType,
270
- byStatus,
271
- avgHealth: agents.length > 0 ? agents.reduce((sum, a) => sum + a.health, 0) / agents.length : 0,
272
- };
273
- }
274
-
275
- if (action === 'scale') {
276
- const targetSize = (input.targetSize as number) || 5;
277
- const agentType = (input.agentType as string) || 'worker';
278
- const currentSize = agents.filter(a => a.agentType === agentType).length;
279
- const delta = targetSize - currentSize;
280
- const added: string[] = [];
281
- const removed: string[] = [];
282
-
283
- if (delta > 0) {
284
- for (let i = 0; i < delta; i++) {
285
- const agentId = `agent-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
286
- store.agents[agentId] = {
287
- agentId,
288
- agentType,
289
- status: 'idle',
290
- health: 1.0,
291
- taskCount: 0,
292
- config: {},
293
- createdAt: new Date().toISOString(),
294
- };
295
- added.push(agentId);
296
- }
297
- } else if (delta < 0) {
298
- const toRemove = agents.filter(a => a.agentType === agentType && a.status === 'idle').slice(0, -delta);
299
- for (const agent of toRemove) {
300
- store.agents[agent.agentId].status = 'terminated';
301
- removed.push(agent.agentId);
302
- }
303
- }
304
-
305
- saveAgentStore(store);
306
- return {
307
- action,
308
- agentType,
309
- previousSize: currentSize,
310
- targetSize,
311
- newSize: currentSize + delta,
312
- added,
313
- removed,
314
- };
315
- }
316
-
317
- if (action === 'drain') {
318
- const agentType = input.agentType as string;
319
- let drained = 0;
320
- for (const agent of agents) {
321
- if (!agentType || agent.agentType === agentType) {
322
- if (agent.status === 'idle') {
323
- store.agents[agent.agentId].status = 'terminated';
324
- drained++;
325
- }
326
- }
327
- }
328
- saveAgentStore(store);
329
- return {
330
- action,
331
- agentType: agentType || 'all',
332
- drained,
333
- remaining: agents.length - drained,
334
- };
335
- }
336
-
337
- return { action, error: 'Unknown action' };
338
- },
339
- },
340
- {
341
- name: 'agent/health',
342
- description: 'Check agent health',
343
- category: 'agent',
344
- inputSchema: {
345
- type: 'object',
346
- properties: {
347
- agentId: { type: 'string', description: 'Specific agent ID (optional)' },
348
- threshold: { type: 'number', description: 'Health threshold (0-1)' },
349
- },
350
- },
351
- handler: async (input) => {
352
- const store = loadAgentStore();
353
- const agents = Object.values(store.agents).filter(a => a.status !== 'terminated');
354
- const threshold = (input.threshold as number) || 0.5;
355
-
356
- if (input.agentId) {
357
- const agent = store.agents[input.agentId as string];
358
- if (agent) {
359
- return {
360
- agentId: agent.agentId,
361
- health: agent.health,
362
- status: agent.status,
363
- healthy: agent.health >= threshold,
364
- taskCount: agent.taskCount,
365
- uptime: Date.now() - new Date(agent.createdAt).getTime(),
366
- };
367
- }
368
- return { agentId: input.agentId, error: 'Agent not found' };
369
- }
370
-
371
- const healthyAgents = agents.filter(a => a.health >= threshold);
372
- const degradedAgents = agents.filter(a => a.health >= 0.3 && a.health < threshold);
373
- const unhealthyAgents = agents.filter(a => a.health < 0.3);
374
- const avgHealth = agents.length > 0 ? agents.reduce((sum, a) => sum + a.health, 0) / agents.length : 1;
375
- const avgCpu = agents.length > 0 ? 35 + Math.random() * 30 : 0; // Simulated CPU
376
- const avgMemory = avgHealth * 0.6; // Correlated with health
377
-
378
- return {
379
- // CLI expected fields
380
- agents: agents.map(a => {
381
- const uptime = Date.now() - new Date(a.createdAt).getTime();
382
- return {
383
- id: a.agentId,
384
- type: a.agentType,
385
- health: a.health >= threshold ? 'healthy' : (a.health >= 0.3 ? 'degraded' : 'unhealthy'),
386
- uptime,
387
- memory: { used: Math.floor(256 * (1 - a.health * 0.3)), limit: 512 },
388
- cpu: 20 + Math.floor(a.health * 40),
389
- tasks: { active: a.taskCount > 0 ? 1 : 0, queued: 0, completed: a.taskCount, failed: 0 },
390
- latency: { avg: 50 + Math.floor((1 - a.health) * 100), p99: 150 + Math.floor((1 - a.health) * 200) },
391
- errors: { count: a.health < threshold ? 1 : 0 },
392
- };
393
- }),
394
- overall: {
395
- healthy: healthyAgents.length,
396
- degraded: degradedAgents.length,
397
- unhealthy: unhealthyAgents.length,
398
- avgCpu,
399
- avgMemory,
400
- score: Math.round(avgHealth * 100),
401
- issues: unhealthyAgents.length,
402
- },
403
- // Additional fields
404
- total: agents.length,
405
- healthyCount: healthyAgents.length,
406
- unhealthyCount: unhealthyAgents.length,
407
- threshold,
408
- avgHealth,
409
- unhealthyAgents: unhealthyAgents.map(a => ({
410
- agentId: a.agentId,
411
- health: a.health,
412
- status: a.status,
413
- })),
414
- };
415
- },
416
- },
417
- {
418
- name: 'agent/update',
419
- description: 'Update agent status or config',
420
- category: 'agent',
421
- inputSchema: {
422
- type: 'object',
423
- properties: {
424
- agentId: { type: 'string', description: 'ID of agent' },
425
- status: { type: 'string', description: 'New status' },
426
- health: { type: 'number', description: 'Health value (0-1)' },
427
- taskCount: { type: 'number', description: 'Task count' },
428
- config: { type: 'object', description: 'Config updates' },
429
- },
430
- required: ['agentId'],
431
- },
432
- handler: async (input) => {
433
- const store = loadAgentStore();
434
- const agentId = input.agentId as string;
435
- const agent = store.agents[agentId];
436
-
437
- if (agent) {
438
- if (input.status) agent.status = input.status as AgentRecord['status'];
439
- if (typeof input.health === 'number') agent.health = input.health as number;
440
- if (typeof input.taskCount === 'number') agent.taskCount = input.taskCount as number;
441
- if (input.config) {
442
- agent.config = { ...agent.config, ...(input.config as Record<string, unknown>) };
443
- }
444
- saveAgentStore(store);
445
-
446
- return {
447
- success: true,
448
- agentId,
449
- updated: true,
450
- agent: {
451
- agentId: agent.agentId,
452
- status: agent.status,
453
- health: agent.health,
454
- taskCount: agent.taskCount,
455
- },
456
- };
457
- }
458
-
459
- return {
460
- success: false,
461
- agentId,
462
- error: 'Agent not found',
463
- };
464
- },
465
- },
466
- ];