@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,736 +0,0 @@
1
- /**
2
- * V3 CLI Status Command
3
- * System status display for Claude Flow
4
- */
5
-
6
- import type { Command, CommandContext, CommandResult } from '../types.js';
7
- import { output } from '../output.js';
8
- import { callMCPTool, MCPClientError } from '../mcp-client.js';
9
- import * as fs from 'fs';
10
- import * as path from 'path';
11
- import * as os from 'os';
12
-
13
- // Status refresh interval (ms)
14
- const DEFAULT_WATCH_INTERVAL = 2000;
15
-
16
- // Track CPU usage over time
17
- let lastCpuUsage: { user: number; system: number } | null = null;
18
- let lastCpuTime = Date.now();
19
-
20
- // Get real process CPU usage percentage
21
- function getProcessCpuUsage(): number {
22
- const cpuUsage = process.cpuUsage(lastCpuUsage ? { user: lastCpuUsage.user, system: lastCpuUsage.system } : undefined);
23
- const now = Date.now();
24
- const elapsed = now - lastCpuTime;
25
-
26
- // Calculate percentage (cpuUsage is in microseconds)
27
- const totalCpu = (cpuUsage.user + cpuUsage.system) / 1000; // Convert to ms
28
- const percentage = elapsed > 0 ? (totalCpu / elapsed) * 100 : 0;
29
-
30
- // Update for next call
31
- lastCpuUsage = cpuUsage;
32
- lastCpuTime = now;
33
-
34
- return Math.min(100, Math.max(0, percentage));
35
- }
36
-
37
- // Get real process memory usage percentage
38
- function getProcessMemoryUsage(): number {
39
- const memoryUsage = process.memoryUsage();
40
- const totalMemory = os.totalmem();
41
- const usedMemory = memoryUsage.heapUsed + memoryUsage.external;
42
-
43
- return (usedMemory / totalMemory) * 100;
44
- }
45
-
46
- // Check if project is initialized
47
- function isInitialized(cwd: string): boolean {
48
- const configPath = path.join(cwd, '.claude-flow', 'config.yaml');
49
- return fs.existsSync(configPath);
50
- }
51
-
52
- // Format uptime
53
- function formatUptime(ms: number): string {
54
- const seconds = Math.floor(ms / 1000);
55
- const minutes = Math.floor(seconds / 60);
56
- const hours = Math.floor(minutes / 60);
57
- const days = Math.floor(hours / 24);
58
-
59
- if (days > 0) {
60
- return `${days}d ${hours % 24}h ${minutes % 60}m`;
61
- } else if (hours > 0) {
62
- return `${hours}h ${minutes % 60}m ${seconds % 60}s`;
63
- } else if (minutes > 0) {
64
- return `${minutes}m ${seconds % 60}s`;
65
- } else {
66
- return `${seconds}s`;
67
- }
68
- }
69
-
70
- // Format bytes
71
- function formatBytes(bytes: number): string {
72
- if (bytes === 0) return '0 B';
73
- const k = 1024;
74
- const sizes = ['B', 'KB', 'MB', 'GB'];
75
- const i = Math.floor(Math.log(bytes) / Math.log(k));
76
- return `${parseFloat((bytes / Math.pow(k, i)).toFixed(1))} ${sizes[i]}`;
77
- }
78
-
79
- // Get system status data
80
- async function getSystemStatus(): Promise<{
81
- initialized: boolean;
82
- running: boolean;
83
- swarm: {
84
- id: string | null;
85
- topology: string;
86
- agents: { total: number; active: number; idle: number };
87
- health: string;
88
- uptime: number;
89
- };
90
- mcp: {
91
- running: boolean;
92
- port: number | null;
93
- transport: string;
94
- };
95
- memory: {
96
- entries: number;
97
- size: string;
98
- backend: string;
99
- performance: { searchTime: number; cacheHitRate: number };
100
- };
101
- tasks: {
102
- total: number;
103
- pending: number;
104
- running: number;
105
- completed: number;
106
- failed: number;
107
- };
108
- performance: {
109
- cpuUsage: number;
110
- memoryUsage: number;
111
- flashAttention: string;
112
- searchSpeed: string;
113
- };
114
- }> {
115
- try {
116
- // Get swarm status
117
- const swarmStatus = await callMCPTool<{
118
- swarmId: string;
119
- topology: string;
120
- agents: { total: number; active: number; idle: number; terminated: number };
121
- health: string;
122
- uptime: number;
123
- }>('swarm/status', { includeMetrics: true });
124
-
125
- // Get MCP status
126
- let mcpStatus = { running: false, port: null as number | null, transport: 'stdio' };
127
- try {
128
- const mcp = await callMCPTool<{
129
- running: boolean;
130
- port: number;
131
- transport: string;
132
- }>('mcp/status', {});
133
- mcpStatus = mcp;
134
- } catch {
135
- // MCP not running
136
- }
137
-
138
- // Get memory status
139
- const memoryStatus = await callMCPTool<{
140
- entries: number;
141
- size: number;
142
- backend: string;
143
- performance: { avgSearchTime: number; cacheHitRate: number };
144
- }>('memory/stats', {});
145
-
146
- // Get task status
147
- const taskStatus = await callMCPTool<{
148
- total: number;
149
- pending: number;
150
- running: number;
151
- completed: number;
152
- failed: number;
153
- }>('task/summary', {});
154
-
155
- return {
156
- initialized: true,
157
- running: true,
158
- swarm: {
159
- id: swarmStatus.swarmId,
160
- topology: swarmStatus.topology,
161
- agents: {
162
- total: swarmStatus.agents.total,
163
- active: swarmStatus.agents.active,
164
- idle: swarmStatus.agents.idle
165
- },
166
- health: swarmStatus.health,
167
- uptime: swarmStatus.uptime
168
- },
169
- mcp: mcpStatus,
170
- memory: {
171
- entries: memoryStatus.entries,
172
- size: formatBytes(memoryStatus.size),
173
- backend: memoryStatus.backend,
174
- performance: {
175
- searchTime: memoryStatus.performance.avgSearchTime,
176
- cacheHitRate: memoryStatus.performance.cacheHitRate
177
- }
178
- },
179
- tasks: taskStatus,
180
- performance: {
181
- cpuUsage: getProcessCpuUsage(),
182
- memoryUsage: getProcessMemoryUsage(),
183
- flashAttention: '2.8x speedup',
184
- searchSpeed: '150x faster'
185
- }
186
- };
187
- } catch (error) {
188
- // System not running
189
- return {
190
- initialized: true,
191
- running: false,
192
- swarm: {
193
- id: null,
194
- topology: 'none',
195
- agents: { total: 0, active: 0, idle: 0 },
196
- health: 'stopped',
197
- uptime: 0
198
- },
199
- mcp: { running: false, port: null, transport: 'stdio' },
200
- memory: {
201
- entries: 0,
202
- size: '0 B',
203
- backend: 'none',
204
- performance: { searchTime: 0, cacheHitRate: 0 }
205
- },
206
- tasks: { total: 0, pending: 0, running: 0, completed: 0, failed: 0 },
207
- performance: {
208
- cpuUsage: 0,
209
- memoryUsage: 0,
210
- flashAttention: 'N/A',
211
- searchSpeed: 'N/A'
212
- }
213
- };
214
- }
215
- }
216
-
217
- // Display status in text format
218
- function displayStatus(status: Awaited<ReturnType<typeof getSystemStatus>>): void {
219
- output.writeln();
220
-
221
- // Header with overall status
222
- const statusIcon = status.running
223
- ? output.success('[RUNNING]')
224
- : output.warning('[STOPPED]');
225
- output.writeln(`${output.bold('Claude Flow V3')} ${statusIcon}`);
226
- output.writeln();
227
-
228
- // Swarm section
229
- output.writeln(output.bold('Swarm'));
230
- if (status.running) {
231
- output.printTable({
232
- columns: [
233
- { key: 'property', header: 'Property', width: 15 },
234
- { key: 'value', header: 'Value', width: 30 }
235
- ],
236
- data: [
237
- { property: 'ID', value: status.swarm.id },
238
- { property: 'Topology', value: status.swarm.topology },
239
- { property: 'Health', value: formatHealth(status.swarm.health) },
240
- { property: 'Uptime', value: formatUptime(status.swarm.uptime) }
241
- ]
242
- });
243
- } else {
244
- output.printInfo(' Swarm not running');
245
- }
246
- output.writeln();
247
-
248
- // Agents section
249
- output.writeln(output.bold('Agents'));
250
- output.printTable({
251
- columns: [
252
- { key: 'status', header: 'Status', width: 12 },
253
- { key: 'count', header: 'Count', width: 10, align: 'right' }
254
- ],
255
- data: [
256
- { status: 'Active', count: status.swarm.agents.active },
257
- { status: 'Idle', count: status.swarm.agents.idle },
258
- { status: output.bold('Total'), count: status.swarm.agents.total }
259
- ]
260
- });
261
- output.writeln();
262
-
263
- // Tasks section
264
- output.writeln(output.bold('Tasks'));
265
- output.printTable({
266
- columns: [
267
- { key: 'status', header: 'Status', width: 12 },
268
- { key: 'count', header: 'Count', width: 10, align: 'right' }
269
- ],
270
- data: [
271
- { status: 'Pending', count: status.tasks.pending },
272
- { status: 'Running', count: status.tasks.running },
273
- { status: 'Completed', count: status.tasks.completed },
274
- { status: 'Failed', count: status.tasks.failed },
275
- { status: output.bold('Total'), count: status.tasks.total }
276
- ]
277
- });
278
- output.writeln();
279
-
280
- // Memory section
281
- output.writeln(output.bold('Memory'));
282
- output.printTable({
283
- columns: [
284
- { key: 'property', header: 'Property', width: 18 },
285
- { key: 'value', header: 'Value', width: 20, align: 'right' }
286
- ],
287
- data: [
288
- { property: 'Backend', value: status.memory.backend },
289
- { property: 'Entries', value: status.memory.entries },
290
- { property: 'Size', value: status.memory.size },
291
- { property: 'Search Time', value: `${status.memory.performance.searchTime.toFixed(2)}ms` },
292
- { property: 'Cache Hit Rate', value: `${(status.memory.performance.cacheHitRate * 100).toFixed(1)}%` }
293
- ]
294
- });
295
- output.writeln();
296
-
297
- // MCP section
298
- output.writeln(output.bold('MCP Server'));
299
- if (status.mcp.running) {
300
- output.printInfo(` Running on port ${status.mcp.port} (${status.mcp.transport})`);
301
- } else {
302
- output.printInfo(' Not running');
303
- }
304
- output.writeln();
305
-
306
- // Performance section
307
- if (status.running) {
308
- output.writeln(output.bold('V3 Performance Gains'));
309
- output.printList([
310
- `Flash Attention: ${output.success(status.performance.flashAttention)}`,
311
- `Vector Search: ${output.success(status.performance.searchSpeed)}`,
312
- `CPU Usage: ${status.performance.cpuUsage.toFixed(1)}%`,
313
- `Memory Usage: ${status.performance.memoryUsage.toFixed(1)}%`
314
- ]);
315
- }
316
- }
317
-
318
- // Format health status with color
319
- function formatHealth(health: string): string {
320
- switch (health) {
321
- case 'healthy':
322
- return output.success(health);
323
- case 'degraded':
324
- return output.warning(health);
325
- case 'unhealthy':
326
- case 'stopped':
327
- return output.error(health);
328
- default:
329
- return health;
330
- }
331
- }
332
-
333
- // Main status action
334
- const statusAction = async (ctx: CommandContext): Promise<CommandResult> => {
335
- const watch = ctx.flags.watch as boolean;
336
- const interval = (ctx.flags.interval as number) || DEFAULT_WATCH_INTERVAL / 1000;
337
- const healthCheck = ctx.flags['health-check'] as boolean;
338
- const cwd = ctx.cwd;
339
-
340
- // Check initialization
341
- if (!isInitialized(cwd)) {
342
- output.printError('Claude Flow is not initialized in this directory');
343
- output.printInfo('Run "claude-flow init" to initialize');
344
- return { success: false, exitCode: 1 };
345
- }
346
-
347
- // Get status
348
- const status = await getSystemStatus();
349
-
350
- // Health check mode
351
- if (healthCheck) {
352
- return performHealthCheck(status);
353
- }
354
-
355
- // JSON output
356
- if (ctx.flags.format === 'json') {
357
- output.printJson(status);
358
- return { success: true, data: status };
359
- }
360
-
361
- // Watch mode
362
- if (watch) {
363
- return watchStatus(interval);
364
- }
365
-
366
- // Single status display
367
- displayStatus(status);
368
-
369
- return { success: true, data: status };
370
- };
371
-
372
- // Perform health checks
373
- async function performHealthCheck(
374
- status: Awaited<ReturnType<typeof getSystemStatus>>
375
- ): Promise<CommandResult> {
376
- output.writeln();
377
- output.writeln(output.bold('Health Check'));
378
- output.writeln();
379
-
380
- const checks: Array<{ name: string; status: 'pass' | 'fail' | 'warn'; message: string }> = [];
381
-
382
- // Check if system is running
383
- checks.push({
384
- name: 'System Running',
385
- status: status.running ? 'pass' : 'fail',
386
- message: status.running ? 'System is running' : 'System is not running'
387
- });
388
-
389
- // Check swarm health
390
- if (status.running) {
391
- checks.push({
392
- name: 'Swarm Health',
393
- status: status.swarm.health === 'healthy' ? 'pass' :
394
- status.swarm.health === 'degraded' ? 'warn' : 'fail',
395
- message: `Swarm is ${status.swarm.health}`
396
- });
397
-
398
- // Check agent count
399
- checks.push({
400
- name: 'Agents Available',
401
- status: status.swarm.agents.active > 0 ? 'pass' :
402
- status.swarm.agents.idle > 0 ? 'warn' : 'fail',
403
- message: `${status.swarm.agents.active} active, ${status.swarm.agents.idle} idle`
404
- });
405
-
406
- // Check MCP
407
- checks.push({
408
- name: 'MCP Server',
409
- status: status.mcp.running ? 'pass' : 'warn',
410
- message: status.mcp.running ? `Running on port ${status.mcp.port}` : 'Not running'
411
- });
412
-
413
- // Check memory backend
414
- checks.push({
415
- name: 'Memory Backend',
416
- status: status.memory.backend !== 'none' ? 'pass' : 'fail',
417
- message: `Using ${status.memory.backend} backend`
418
- });
419
-
420
- // Check for failed tasks
421
- const failRate = status.tasks.total > 0
422
- ? status.tasks.failed / status.tasks.total
423
- : 0;
424
- checks.push({
425
- name: 'Task Success Rate',
426
- status: failRate < 0.05 ? 'pass' : failRate < 0.2 ? 'warn' : 'fail',
427
- message: `${((1 - failRate) * 100).toFixed(1)}% success rate`
428
- });
429
- }
430
-
431
- // Display results
432
- for (const check of checks) {
433
- const icon = check.status === 'pass' ? output.success('[PASS]') :
434
- check.status === 'warn' ? output.warning('[WARN]') :
435
- output.error('[FAIL]');
436
- output.writeln(`${icon} ${check.name}: ${check.message}`);
437
- }
438
-
439
- output.writeln();
440
-
441
- const passed = checks.filter(c => c.status === 'pass').length;
442
- const warned = checks.filter(c => c.status === 'warn').length;
443
- const failed = checks.filter(c => c.status === 'fail').length;
444
-
445
- if (failed === 0) {
446
- output.printSuccess(`All checks passed (${passed} passed, ${warned} warnings)`);
447
- } else {
448
- output.printError(`Health check failed (${passed} passed, ${warned} warnings, ${failed} failed)`);
449
- }
450
-
451
- return {
452
- success: failed === 0,
453
- exitCode: failed > 0 ? 1 : 0,
454
- data: { checks, summary: { passed, warned, failed } }
455
- };
456
- }
457
-
458
- // Watch mode - continuous status updates
459
- async function watchStatus(intervalSeconds: number): Promise<CommandResult> {
460
- output.writeln();
461
- output.writeln(output.bold('Watch Mode'));
462
- output.writeln(output.dim(`Refreshing every ${intervalSeconds}s. Press Ctrl+C to exit.`));
463
- output.writeln();
464
-
465
- const refresh = async () => {
466
- // Clear screen
467
- process.stdout.write('\x1b[2J\x1b[H');
468
-
469
- output.writeln(output.dim(`Last updated: ${new Date().toLocaleTimeString()}`));
470
- output.writeln();
471
-
472
- const status = await getSystemStatus();
473
- displayStatus(status);
474
- };
475
-
476
- // Initial display
477
- await refresh();
478
-
479
- // Set up interval
480
- const intervalId = setInterval(refresh, intervalSeconds * 1000);
481
-
482
- // Handle exit
483
- return new Promise((resolve) => {
484
- process.on('SIGINT', () => {
485
- clearInterval(intervalId);
486
- output.writeln();
487
- output.printInfo('Watch mode stopped');
488
- resolve({ success: true });
489
- });
490
- });
491
- }
492
-
493
- // Agents subcommand
494
- const agentsCommand: Command = {
495
- name: 'agents',
496
- description: 'Show detailed agent status',
497
- action: async (ctx: CommandContext): Promise<CommandResult> => {
498
- try {
499
- const result = await callMCPTool<{
500
- agents: Array<{
501
- id: string;
502
- type: string;
503
- status: string;
504
- task?: string;
505
- uptime: number;
506
- metrics: { tasksCompleted: number; successRate: number };
507
- }>;
508
- }>('agent/list', { includeMetrics: true, status: 'all' });
509
-
510
- if (ctx.flags.format === 'json') {
511
- output.printJson(result);
512
- return { success: true, data: result };
513
- }
514
-
515
- output.writeln();
516
- output.writeln(output.bold('Agent Status'));
517
- output.writeln();
518
-
519
- if (result.agents.length === 0) {
520
- output.printInfo('No agents running');
521
- return { success: true, data: result };
522
- }
523
-
524
- output.printTable({
525
- columns: [
526
- { key: 'id', header: 'ID', width: 20 },
527
- { key: 'type', header: 'Type', width: 12 },
528
- { key: 'status', header: 'Status', width: 10 },
529
- { key: 'task', header: 'Current Task', width: 25 },
530
- { key: 'uptime', header: 'Uptime', width: 12 },
531
- { key: 'success', header: 'Success', width: 8 }
532
- ],
533
- data: result.agents.map(a => ({
534
- id: a.id,
535
- type: a.type,
536
- status: formatHealth(a.status),
537
- task: a.task || '-',
538
- uptime: formatUptime(a.uptime),
539
- success: `${(a.metrics.successRate * 100).toFixed(0)}%`
540
- }))
541
- });
542
-
543
- return { success: true, data: result };
544
- } catch (error) {
545
- if (error instanceof MCPClientError) {
546
- output.printError(`Failed to get agent status: ${error.message}`);
547
- } else {
548
- output.printError(`Unexpected error: ${String(error)}`);
549
- }
550
- return { success: false, exitCode: 1 };
551
- }
552
- }
553
- };
554
-
555
- // Tasks subcommand
556
- const tasksCommand: Command = {
557
- name: 'tasks',
558
- description: 'Show detailed task status',
559
- action: async (ctx: CommandContext): Promise<CommandResult> => {
560
- try {
561
- const result = await callMCPTool<{
562
- tasks: Array<{
563
- id: string;
564
- type: string;
565
- status: string;
566
- priority: string;
567
- agent?: string;
568
- progress: number;
569
- createdAt: string;
570
- }>;
571
- }>('task/list', { status: 'all', limit: 50 });
572
-
573
- if (ctx.flags.format === 'json') {
574
- output.printJson(result);
575
- return { success: true, data: result };
576
- }
577
-
578
- output.writeln();
579
- output.writeln(output.bold('Task Status'));
580
- output.writeln();
581
-
582
- if (result.tasks.length === 0) {
583
- output.printInfo('No tasks');
584
- return { success: true, data: result };
585
- }
586
-
587
- output.printTable({
588
- columns: [
589
- { key: 'id', header: 'ID', width: 15 },
590
- { key: 'type', header: 'Type', width: 15 },
591
- { key: 'status', header: 'Status', width: 12 },
592
- { key: 'priority', header: 'Priority', width: 10 },
593
- { key: 'agent', header: 'Agent', width: 15 },
594
- { key: 'progress', header: 'Progress', width: 10 }
595
- ],
596
- data: result.tasks.map(t => ({
597
- id: t.id,
598
- type: t.type,
599
- status: formatHealth(t.status),
600
- priority: t.priority,
601
- agent: t.agent || '-',
602
- progress: `${t.progress}%`
603
- }))
604
- });
605
-
606
- return { success: true, data: result };
607
- } catch (error) {
608
- if (error instanceof MCPClientError) {
609
- output.printError(`Failed to get task status: ${error.message}`);
610
- } else {
611
- output.printError(`Unexpected error: ${String(error)}`);
612
- }
613
- return { success: false, exitCode: 1 };
614
- }
615
- }
616
- };
617
-
618
- // Memory subcommand
619
- const memoryCommand: Command = {
620
- name: 'memory',
621
- description: 'Show detailed memory status',
622
- action: async (ctx: CommandContext): Promise<CommandResult> => {
623
- try {
624
- const result = await callMCPTool<{
625
- backend: string;
626
- entries: number;
627
- size: number;
628
- namespaces: Array<{ name: string; entries: number }>;
629
- performance: {
630
- avgSearchTime: number;
631
- avgWriteTime: number;
632
- cacheHitRate: number;
633
- hnswEnabled: boolean;
634
- };
635
- v3Gains: {
636
- searchImprovement: string;
637
- memoryReduction: string;
638
- };
639
- }>('memory/detailed-stats', {});
640
-
641
- if (ctx.flags.format === 'json') {
642
- output.printJson(result);
643
- return { success: true, data: result };
644
- }
645
-
646
- output.writeln();
647
- output.writeln(output.bold('Memory Status'));
648
- output.writeln();
649
-
650
- output.printTable({
651
- columns: [
652
- { key: 'property', header: 'Property', width: 20 },
653
- { key: 'value', header: 'Value', width: 25 }
654
- ],
655
- data: [
656
- { property: 'Backend', value: result.backend },
657
- { property: 'Total Entries', value: result.entries.toLocaleString() },
658
- { property: 'Storage Size', value: formatBytes(result.size) },
659
- { property: 'HNSW Index', value: result.performance.hnswEnabled ? 'Enabled' : 'Disabled' }
660
- ]
661
- });
662
-
663
- output.writeln();
664
- output.writeln(output.bold('Performance'));
665
- output.printTable({
666
- columns: [
667
- { key: 'metric', header: 'Metric', width: 20 },
668
- { key: 'value', header: 'Value', width: 20, align: 'right' }
669
- ],
670
- data: [
671
- { metric: 'Avg Search Time', value: `${result.performance.avgSearchTime.toFixed(2)}ms` },
672
- { metric: 'Avg Write Time', value: `${result.performance.avgWriteTime.toFixed(2)}ms` },
673
- { metric: 'Cache Hit Rate', value: `${(result.performance.cacheHitRate * 100).toFixed(1)}%` }
674
- ]
675
- });
676
-
677
- output.writeln();
678
- output.writeln(output.bold('V3 Performance Gains'));
679
- output.printList([
680
- `Search Speed: ${output.success(result.v3Gains.searchImprovement)}`,
681
- `Memory Usage: ${output.success(result.v3Gains.memoryReduction)}`
682
- ]);
683
-
684
- return { success: true, data: result };
685
- } catch (error) {
686
- if (error instanceof MCPClientError) {
687
- output.printError(`Failed to get memory status: ${error.message}`);
688
- } else {
689
- output.printError(`Unexpected error: ${String(error)}`);
690
- }
691
- return { success: false, exitCode: 1 };
692
- }
693
- }
694
- };
695
-
696
- // Main status command
697
- export const statusCommand: Command = {
698
- name: 'status',
699
- description: 'Show system status',
700
- subcommands: [agentsCommand, tasksCommand, memoryCommand],
701
- options: [
702
- {
703
- name: 'watch',
704
- short: 'w',
705
- description: 'Watch mode - continuously update status',
706
- type: 'boolean',
707
- default: false
708
- },
709
- {
710
- name: 'interval',
711
- short: 'i',
712
- description: 'Watch mode update interval in seconds',
713
- type: 'number',
714
- default: 2
715
- },
716
- {
717
- name: 'health-check',
718
- description: 'Perform health checks and exit',
719
- type: 'boolean',
720
- default: false
721
- }
722
- ],
723
- examples: [
724
- { command: 'claude-flow status', description: 'Show current system status' },
725
- { command: 'claude-flow status --watch', description: 'Watch mode with live updates' },
726
- { command: 'claude-flow status --watch -i 5', description: 'Watch mode updating every 5 seconds' },
727
- { command: 'claude-flow status --health-check', description: 'Run health checks' },
728
- { command: 'claude-flow status --json', description: 'Output status as JSON' },
729
- { command: 'claude-flow status agents', description: 'Show detailed agent status' },
730
- { command: 'claude-flow status tasks', description: 'Show detailed task status' },
731
- { command: 'claude-flow status memory', description: 'Show detailed memory status' }
732
- ],
733
- action: statusAction
734
- };
735
-
736
- export default statusCommand;