@claude-flow/cli 3.0.0-alpha.13 → 3.0.0-alpha.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.
Files changed (106) hide show
  1. package/dist/src/commands/doctor.d.ts.map +1 -1
  2. package/dist/src/commands/doctor.js +75 -2
  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 -382
  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,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
- ];