claude-flow 3.0.0-alpha.10 → 3.0.0-alpha.11

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 (239) hide show
  1. package/package.json +10 -23
  2. package/README.md +0 -1186
  3. package/bin/cli.js +0 -14
  4. package/dist/src/commands/agent.d.ts +0 -8
  5. package/dist/src/commands/agent.d.ts.map +0 -1
  6. package/dist/src/commands/agent.js +0 -819
  7. package/dist/src/commands/agent.js.map +0 -1
  8. package/dist/src/commands/config.d.ts +0 -8
  9. package/dist/src/commands/config.d.ts.map +0 -1
  10. package/dist/src/commands/config.js +0 -406
  11. package/dist/src/commands/config.js.map +0 -1
  12. package/dist/src/commands/daemon.d.ts +0 -8
  13. package/dist/src/commands/daemon.d.ts.map +0 -1
  14. package/dist/src/commands/daemon.js +0 -545
  15. package/dist/src/commands/daemon.js.map +0 -1
  16. package/dist/src/commands/hive-mind.d.ts +0 -8
  17. package/dist/src/commands/hive-mind.d.ts.map +0 -1
  18. package/dist/src/commands/hive-mind.js +0 -844
  19. package/dist/src/commands/hive-mind.js.map +0 -1
  20. package/dist/src/commands/hooks.d.ts +0 -8
  21. package/dist/src/commands/hooks.d.ts.map +0 -1
  22. package/dist/src/commands/hooks.js +0 -2098
  23. package/dist/src/commands/hooks.js.map +0 -1
  24. package/dist/src/commands/index.d.ts +0 -52
  25. package/dist/src/commands/index.d.ts.map +0 -1
  26. package/dist/src/commands/index.js +0 -108
  27. package/dist/src/commands/index.js.map +0 -1
  28. package/dist/src/commands/init.d.ts +0 -8
  29. package/dist/src/commands/init.d.ts.map +0 -1
  30. package/dist/src/commands/init.js +0 -532
  31. package/dist/src/commands/init.js.map +0 -1
  32. package/dist/src/commands/mcp.d.ts +0 -11
  33. package/dist/src/commands/mcp.d.ts.map +0 -1
  34. package/dist/src/commands/mcp.js +0 -662
  35. package/dist/src/commands/mcp.js.map +0 -1
  36. package/dist/src/commands/memory.d.ts +0 -8
  37. package/dist/src/commands/memory.d.ts.map +0 -1
  38. package/dist/src/commands/memory.js +0 -977
  39. package/dist/src/commands/memory.js.map +0 -1
  40. package/dist/src/commands/migrate.d.ts +0 -8
  41. package/dist/src/commands/migrate.d.ts.map +0 -1
  42. package/dist/src/commands/migrate.js +0 -398
  43. package/dist/src/commands/migrate.js.map +0 -1
  44. package/dist/src/commands/process.d.ts +0 -10
  45. package/dist/src/commands/process.d.ts.map +0 -1
  46. package/dist/src/commands/process.js +0 -641
  47. package/dist/src/commands/process.js.map +0 -1
  48. package/dist/src/commands/session.d.ts +0 -8
  49. package/dist/src/commands/session.d.ts.map +0 -1
  50. package/dist/src/commands/session.js +0 -750
  51. package/dist/src/commands/session.js.map +0 -1
  52. package/dist/src/commands/start.d.ts +0 -8
  53. package/dist/src/commands/start.d.ts.map +0 -1
  54. package/dist/src/commands/start.js +0 -398
  55. package/dist/src/commands/start.js.map +0 -1
  56. package/dist/src/commands/status.d.ts +0 -8
  57. package/dist/src/commands/status.d.ts.map +0 -1
  58. package/dist/src/commands/status.js +0 -584
  59. package/dist/src/commands/status.js.map +0 -1
  60. package/dist/src/commands/swarm.d.ts +0 -8
  61. package/dist/src/commands/swarm.d.ts.map +0 -1
  62. package/dist/src/commands/swarm.js +0 -573
  63. package/dist/src/commands/swarm.js.map +0 -1
  64. package/dist/src/commands/task.d.ts +0 -8
  65. package/dist/src/commands/task.d.ts.map +0 -1
  66. package/dist/src/commands/task.js +0 -671
  67. package/dist/src/commands/task.js.map +0 -1
  68. package/dist/src/commands/workflow.d.ts +0 -8
  69. package/dist/src/commands/workflow.d.ts.map +0 -1
  70. package/dist/src/commands/workflow.js +0 -617
  71. package/dist/src/commands/workflow.js.map +0 -1
  72. package/dist/src/config-adapter.d.ts +0 -15
  73. package/dist/src/config-adapter.d.ts.map +0 -1
  74. package/dist/src/config-adapter.js +0 -185
  75. package/dist/src/config-adapter.js.map +0 -1
  76. package/dist/src/index.d.ts +0 -55
  77. package/dist/src/index.d.ts.map +0 -1
  78. package/dist/src/index.js +0 -353
  79. package/dist/src/index.js.map +0 -1
  80. package/dist/src/infrastructure/in-memory-repositories.d.ts +0 -68
  81. package/dist/src/infrastructure/in-memory-repositories.d.ts.map +0 -1
  82. package/dist/src/infrastructure/in-memory-repositories.js +0 -264
  83. package/dist/src/infrastructure/in-memory-repositories.js.map +0 -1
  84. package/dist/src/init/claudemd-generator.d.ts +0 -15
  85. package/dist/src/init/claudemd-generator.d.ts.map +0 -1
  86. package/dist/src/init/claudemd-generator.js +0 -626
  87. package/dist/src/init/claudemd-generator.js.map +0 -1
  88. package/dist/src/init/executor.d.ts +0 -11
  89. package/dist/src/init/executor.d.ts.map +0 -1
  90. package/dist/src/init/executor.js +0 -652
  91. package/dist/src/init/executor.js.map +0 -1
  92. package/dist/src/init/helpers-generator.d.ts +0 -42
  93. package/dist/src/init/helpers-generator.d.ts.map +0 -1
  94. package/dist/src/init/helpers-generator.js +0 -613
  95. package/dist/src/init/helpers-generator.js.map +0 -1
  96. package/dist/src/init/index.d.ts +0 -12
  97. package/dist/src/init/index.d.ts.map +0 -1
  98. package/dist/src/init/index.js +0 -15
  99. package/dist/src/init/index.js.map +0 -1
  100. package/dist/src/init/mcp-generator.d.ts +0 -18
  101. package/dist/src/init/mcp-generator.d.ts.map +0 -1
  102. package/dist/src/init/mcp-generator.js +0 -71
  103. package/dist/src/init/mcp-generator.js.map +0 -1
  104. package/dist/src/init/settings-generator.d.ts +0 -14
  105. package/dist/src/init/settings-generator.d.ts.map +0 -1
  106. package/dist/src/init/settings-generator.js +0 -267
  107. package/dist/src/init/settings-generator.js.map +0 -1
  108. package/dist/src/init/statusline-generator.d.ts +0 -14
  109. package/dist/src/init/statusline-generator.d.ts.map +0 -1
  110. package/dist/src/init/statusline-generator.js +0 -206
  111. package/dist/src/init/statusline-generator.js.map +0 -1
  112. package/dist/src/init/types.d.ts +0 -240
  113. package/dist/src/init/types.d.ts.map +0 -1
  114. package/dist/src/init/types.js +0 -210
  115. package/dist/src/init/types.js.map +0 -1
  116. package/dist/src/mcp-client.d.ts +0 -92
  117. package/dist/src/mcp-client.d.ts.map +0 -1
  118. package/dist/src/mcp-client.js +0 -203
  119. package/dist/src/mcp-client.js.map +0 -1
  120. package/dist/src/mcp-server.d.ts +0 -153
  121. package/dist/src/mcp-server.d.ts.map +0 -1
  122. package/dist/src/mcp-server.js +0 -453
  123. package/dist/src/mcp-server.js.map +0 -1
  124. package/dist/src/mcp-tools/agent-tools.d.ts +0 -8
  125. package/dist/src/mcp-tools/agent-tools.d.ts.map +0 -1
  126. package/dist/src/mcp-tools/agent-tools.js +0 -426
  127. package/dist/src/mcp-tools/agent-tools.js.map +0 -1
  128. package/dist/src/mcp-tools/config-tools.d.ts +0 -8
  129. package/dist/src/mcp-tools/config-tools.d.ts.map +0 -1
  130. package/dist/src/mcp-tools/config-tools.js +0 -333
  131. package/dist/src/mcp-tools/config-tools.js.map +0 -1
  132. package/dist/src/mcp-tools/hive-mind-tools.d.ts +0 -8
  133. package/dist/src/mcp-tools/hive-mind-tools.d.ts.map +0 -1
  134. package/dist/src/mcp-tools/hive-mind-tools.js +0 -447
  135. package/dist/src/mcp-tools/hive-mind-tools.js.map +0 -1
  136. package/dist/src/mcp-tools/hooks-tools.d.ts +0 -41
  137. package/dist/src/mcp-tools/hooks-tools.d.ts.map +0 -1
  138. package/dist/src/mcp-tools/hooks-tools.js +0 -1711
  139. package/dist/src/mcp-tools/hooks-tools.js.map +0 -1
  140. package/dist/src/mcp-tools/index.d.ts +0 -16
  141. package/dist/src/mcp-tools/index.d.ts.map +0 -1
  142. package/dist/src/mcp-tools/index.js +0 -15
  143. package/dist/src/mcp-tools/index.js.map +0 -1
  144. package/dist/src/mcp-tools/memory-tools.d.ts +0 -8
  145. package/dist/src/mcp-tools/memory-tools.d.ts.map +0 -1
  146. package/dist/src/mcp-tools/memory-tools.js +0 -235
  147. package/dist/src/mcp-tools/memory-tools.js.map +0 -1
  148. package/dist/src/mcp-tools/session-tools.d.ts +0 -8
  149. package/dist/src/mcp-tools/session-tools.d.ts.map +0 -1
  150. package/dist/src/mcp-tools/session-tools.js +0 -315
  151. package/dist/src/mcp-tools/session-tools.js.map +0 -1
  152. package/dist/src/mcp-tools/swarm-tools.d.ts +0 -8
  153. package/dist/src/mcp-tools/swarm-tools.d.ts.map +0 -1
  154. package/dist/src/mcp-tools/swarm-tools.js +0 -102
  155. package/dist/src/mcp-tools/swarm-tools.js.map +0 -1
  156. package/dist/src/mcp-tools/task-tools.d.ts +0 -8
  157. package/dist/src/mcp-tools/task-tools.d.ts.map +0 -1
  158. package/dist/src/mcp-tools/task-tools.js +0 -302
  159. package/dist/src/mcp-tools/task-tools.js.map +0 -1
  160. package/dist/src/mcp-tools/types.d.ts +0 -31
  161. package/dist/src/mcp-tools/types.d.ts.map +0 -1
  162. package/dist/src/mcp-tools/types.js +0 -7
  163. package/dist/src/mcp-tools/types.js.map +0 -1
  164. package/dist/src/mcp-tools/workflow-tools.d.ts +0 -8
  165. package/dist/src/mcp-tools/workflow-tools.d.ts.map +0 -1
  166. package/dist/src/mcp-tools/workflow-tools.js +0 -481
  167. package/dist/src/mcp-tools/workflow-tools.js.map +0 -1
  168. package/dist/src/output.d.ts +0 -133
  169. package/dist/src/output.d.ts.map +0 -1
  170. package/dist/src/output.js +0 -513
  171. package/dist/src/output.js.map +0 -1
  172. package/dist/src/parser.d.ts +0 -41
  173. package/dist/src/parser.d.ts.map +0 -1
  174. package/dist/src/parser.js +0 -353
  175. package/dist/src/parser.js.map +0 -1
  176. package/dist/src/prompt.d.ts +0 -44
  177. package/dist/src/prompt.d.ts.map +0 -1
  178. package/dist/src/prompt.js +0 -501
  179. package/dist/src/prompt.js.map +0 -1
  180. package/dist/src/services/index.d.ts +0 -7
  181. package/dist/src/services/index.d.ts.map +0 -1
  182. package/dist/src/services/index.js +0 -6
  183. package/dist/src/services/index.js.map +0 -1
  184. package/dist/src/services/worker-daemon.d.ts +0 -153
  185. package/dist/src/services/worker-daemon.d.ts.map +0 -1
  186. package/dist/src/services/worker-daemon.js +0 -567
  187. package/dist/src/services/worker-daemon.js.map +0 -1
  188. package/dist/src/types.d.ts +0 -198
  189. package/dist/src/types.d.ts.map +0 -1
  190. package/dist/src/types.js +0 -38
  191. package/dist/src/types.js.map +0 -1
  192. package/dist/tsconfig.tsbuildinfo +0 -1
  193. package/src/commands/agent.ts +0 -955
  194. package/src/commands/config.ts +0 -452
  195. package/src/commands/daemon.ts +0 -621
  196. package/src/commands/hive-mind.ts +0 -928
  197. package/src/commands/hooks.ts +0 -2603
  198. package/src/commands/index.ts +0 -118
  199. package/src/commands/init.ts +0 -597
  200. package/src/commands/mcp.ts +0 -753
  201. package/src/commands/memory.ts +0 -1161
  202. package/src/commands/migrate.ts +0 -447
  203. package/src/commands/process.ts +0 -695
  204. package/src/commands/session.ts +0 -891
  205. package/src/commands/start.ts +0 -457
  206. package/src/commands/status.ts +0 -736
  207. package/src/commands/swarm.ts +0 -648
  208. package/src/commands/task.ts +0 -792
  209. package/src/commands/workflow.ts +0 -742
  210. package/src/config-adapter.ts +0 -210
  211. package/src/index.ts +0 -427
  212. package/src/infrastructure/in-memory-repositories.ts +0 -310
  213. package/src/init/claudemd-generator.ts +0 -631
  214. package/src/init/executor.ts +0 -762
  215. package/src/init/helpers-generator.ts +0 -628
  216. package/src/init/index.ts +0 -60
  217. package/src/init/mcp-generator.ts +0 -83
  218. package/src/init/settings-generator.ts +0 -284
  219. package/src/init/statusline-generator.ts +0 -211
  220. package/src/init/types.ts +0 -447
  221. package/src/mcp-client.ts +0 -241
  222. package/src/mcp-server.ts +0 -577
  223. package/src/mcp-tools/agent-tools.ts +0 -466
  224. package/src/mcp-tools/config-tools.ts +0 -370
  225. package/src/mcp-tools/hive-mind-tools.ts +0 -521
  226. package/src/mcp-tools/hooks-tools.ts +0 -1888
  227. package/src/mcp-tools/index.ts +0 -16
  228. package/src/mcp-tools/memory-tools.ts +0 -270
  229. package/src/mcp-tools/session-tools.ts +0 -359
  230. package/src/mcp-tools/swarm-tools.ts +0 -105
  231. package/src/mcp-tools/task-tools.ts +0 -347
  232. package/src/mcp-tools/types.ts +0 -33
  233. package/src/mcp-tools/workflow-tools.ts +0 -573
  234. package/src/output.ts +0 -639
  235. package/src/parser.ts +0 -417
  236. package/src/prompt.ts +0 -619
  237. package/src/services/index.ts +0 -15
  238. package/src/services/worker-daemon.ts +0 -726
  239. package/src/types.ts +0 -287
@@ -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;