@claude-flow/cli 3.0.0-alpha.2 → 3.0.0-alpha.21

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