@claude-flow/cli 3.0.0-alpha.13 → 3.0.0-alpha.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/package.json +12 -4
  2. package/.agentic-flow/intelligence.json +0 -17
  3. package/.claude-flow/agents/store.json +0 -16
  4. package/.claude-flow/daemon-state.json +0 -123
  5. package/.claude-flow/daemon-test.log +0 -0
  6. package/.claude-flow/daemon.log +0 -0
  7. package/.claude-flow/daemon2.log +0 -0
  8. package/.claude-flow/daemon3.log +0 -0
  9. package/.claude-flow/hive-mind/state.json +0 -51
  10. package/.claude-flow/metrics/agent-metrics.json +0 -1
  11. package/.claude-flow/metrics/codebase-map.json +0 -11
  12. package/.claude-flow/metrics/consolidation.json +0 -6
  13. package/.claude-flow/metrics/performance.json +0 -87
  14. package/.claude-flow/metrics/security-audit.json +0 -10
  15. package/.claude-flow/metrics/task-metrics.json +0 -10
  16. package/.claude-flow/metrics/test-gaps.json +0 -6
  17. package/__tests__/README.md +0 -140
  18. package/__tests__/TEST_SUMMARY.md +0 -144
  19. package/__tests__/cli.test.ts +0 -558
  20. package/__tests__/commands.test.ts +0 -726
  21. package/__tests__/config-adapter.test.ts +0 -362
  22. package/__tests__/config-loading.test.ts +0 -106
  23. package/__tests__/coverage/.tmp/coverage-0.json +0 -1
  24. package/__tests__/coverage/.tmp/coverage-1.json +0 -1
  25. package/__tests__/coverage/.tmp/coverage-2.json +0 -1
  26. package/__tests__/coverage/.tmp/coverage-3.json +0 -1
  27. package/__tests__/coverage/.tmp/coverage-4.json +0 -1
  28. package/__tests__/coverage/.tmp/coverage-5.json +0 -1
  29. package/__tests__/mcp-client.test.ts +0 -480
  30. package/__tests__/p1-commands.test.ts +0 -1064
  31. package/agents/architect.yaml +0 -11
  32. package/agents/coder.yaml +0 -11
  33. package/agents/reviewer.yaml +0 -10
  34. package/agents/security-architect.yaml +0 -10
  35. package/agents/tester.yaml +0 -10
  36. package/docs/CONFIG_LOADING.md +0 -236
  37. package/docs/IMPLEMENTATION_COMPLETE.md +0 -421
  38. package/docs/MCP_CLIENT_GUIDE.md +0 -620
  39. package/docs/REFACTORING_SUMMARY.md +0 -247
  40. package/scripts/publish.sh +0 -46
  41. package/src/commands/agent.ts +0 -955
  42. package/src/commands/claims.ts +0 -317
  43. package/src/commands/completions.ts +0 -558
  44. package/src/commands/config.ts +0 -452
  45. package/src/commands/daemon.ts +0 -621
  46. package/src/commands/deployment.ts +0 -323
  47. package/src/commands/doctor.ts +0 -382
  48. package/src/commands/embeddings.ts +0 -686
  49. package/src/commands/hive-mind.ts +0 -928
  50. package/src/commands/hooks.ts +0 -2603
  51. package/src/commands/index.ts +0 -154
  52. package/src/commands/init.ts +0 -597
  53. package/src/commands/mcp.ts +0 -753
  54. package/src/commands/memory.ts +0 -1161
  55. package/src/commands/migrate.ts +0 -447
  56. package/src/commands/neural.ts +0 -253
  57. package/src/commands/performance.ts +0 -292
  58. package/src/commands/plugins.ts +0 -316
  59. package/src/commands/process.ts +0 -695
  60. package/src/commands/providers.ts +0 -259
  61. package/src/commands/security.ts +0 -288
  62. package/src/commands/session.ts +0 -891
  63. package/src/commands/start.ts +0 -457
  64. package/src/commands/status.ts +0 -736
  65. package/src/commands/swarm.ts +0 -648
  66. package/src/commands/task.ts +0 -792
  67. package/src/commands/workflow.ts +0 -742
  68. package/src/config-adapter.ts +0 -210
  69. package/src/index.ts +0 -443
  70. package/src/infrastructure/in-memory-repositories.ts +0 -310
  71. package/src/init/claudemd-generator.ts +0 -631
  72. package/src/init/executor.ts +0 -762
  73. package/src/init/helpers-generator.ts +0 -628
  74. package/src/init/index.ts +0 -60
  75. package/src/init/mcp-generator.ts +0 -83
  76. package/src/init/settings-generator.ts +0 -284
  77. package/src/init/statusline-generator.ts +0 -211
  78. package/src/init/types.ts +0 -447
  79. package/src/mcp-client.ts +0 -241
  80. package/src/mcp-server.ts +0 -577
  81. package/src/mcp-tools/agent-tools.ts +0 -466
  82. package/src/mcp-tools/config-tools.ts +0 -370
  83. package/src/mcp-tools/hive-mind-tools.ts +0 -521
  84. package/src/mcp-tools/hooks-tools.ts +0 -1888
  85. package/src/mcp-tools/index.ts +0 -16
  86. package/src/mcp-tools/memory-tools.ts +0 -270
  87. package/src/mcp-tools/session-tools.ts +0 -359
  88. package/src/mcp-tools/swarm-tools.ts +0 -105
  89. package/src/mcp-tools/task-tools.ts +0 -347
  90. package/src/mcp-tools/types.ts +0 -33
  91. package/src/mcp-tools/workflow-tools.ts +0 -573
  92. package/src/output.ts +0 -639
  93. package/src/parser.ts +0 -417
  94. package/src/prompt.ts +0 -619
  95. package/src/services/index.ts +0 -15
  96. package/src/services/worker-daemon.ts +0 -726
  97. package/src/suggest.ts +0 -245
  98. package/src/types.ts +0 -287
  99. package/tmp.json +0 -0
  100. package/tsconfig.json +0 -16
  101. package/tsconfig.tsbuildinfo +0 -1
  102. package/vitest.config.ts +0 -13
@@ -1,457 +0,0 @@
1
- /**
2
- * V3 CLI Start Command
3
- * System startup for Claude Flow orchestration
4
- */
5
-
6
- import type { Command, CommandContext, CommandResult } from '../types.js';
7
- import { output } from '../output.js';
8
- import { confirm, select } from '../prompt.js';
9
- import { callMCPTool, MCPClientError } from '../mcp-client.js';
10
- import * as fs from 'fs';
11
- import * as path from 'path';
12
-
13
- // Default configuration
14
- const DEFAULT_PORT = 3000;
15
- const DEFAULT_TOPOLOGY = 'hierarchical-mesh';
16
- const DEFAULT_MAX_AGENTS = 15;
17
-
18
- // Check if project is initialized
19
- function isInitialized(cwd: string): boolean {
20
- const configPath = path.join(cwd, '.claude-flow', 'config.yaml');
21
- return fs.existsSync(configPath);
22
- }
23
-
24
- // Simple YAML parser for config (basic implementation)
25
- function parseSimpleYaml(content: string): Record<string, unknown> {
26
- const result: Record<string, unknown> = {};
27
- const lines = content.split('\n');
28
- const stack: Array<{ indent: number; obj: Record<string, unknown>; key?: string }> = [
29
- { indent: -1, obj: result }
30
- ];
31
-
32
- for (const line of lines) {
33
- // Skip comments and empty lines
34
- if (line.trim().startsWith('#') || line.trim() === '') continue;
35
-
36
- const match = line.match(/^(\s*)(\w+):\s*(.*)$/);
37
- if (!match) continue;
38
-
39
- const indent = match[1].length;
40
- const key = match[2];
41
- let value: unknown = match[3].trim();
42
-
43
- // Parse value
44
- if (value === '' || value === undefined) {
45
- value = {};
46
- } else if (value === 'true') {
47
- value = true;
48
- } else if (value === 'false') {
49
- value = false;
50
- } else if (value === 'null') {
51
- value = null;
52
- } else if (!isNaN(Number(value as string)) && value !== '') {
53
- value = Number(value);
54
- } else if (typeof value === 'string' && value.startsWith('"') && value.endsWith('"')) {
55
- value = value.slice(1, -1);
56
- }
57
-
58
- // Find parent based on indentation
59
- while (stack.length > 1 && stack[stack.length - 1].indent >= indent) {
60
- stack.pop();
61
- }
62
-
63
- const parent = stack[stack.length - 1].obj;
64
-
65
- if (typeof value === 'object' && value !== null) {
66
- parent[key] = value;
67
- stack.push({ indent, obj: value as Record<string, unknown>, key });
68
- } else {
69
- parent[key] = value;
70
- }
71
- }
72
-
73
- return result;
74
- }
75
-
76
- // Load configuration
77
- function loadConfig(cwd: string): Record<string, unknown> | null {
78
- const configPath = path.join(cwd, '.claude-flow', 'config.yaml');
79
- if (!fs.existsSync(configPath)) return null;
80
-
81
- try {
82
- const content = fs.readFileSync(configPath, 'utf-8');
83
- return parseSimpleYaml(content);
84
- } catch {
85
- return null;
86
- }
87
- }
88
-
89
- // Main start action
90
- const startAction = async (ctx: CommandContext): Promise<CommandResult> => {
91
- const daemon = ctx.flags.daemon as boolean;
92
- const port = (ctx.flags.port as number) || DEFAULT_PORT;
93
- const topology = (ctx.flags.topology as string) || DEFAULT_TOPOLOGY;
94
- const skipMcp = ctx.flags['skip-mcp'] as boolean;
95
- const cwd = ctx.cwd;
96
-
97
- // Check initialization
98
- if (!isInitialized(cwd)) {
99
- output.printError('Claude Flow is not initialized in this directory');
100
- output.printInfo('Run "claude-flow init" first to initialize');
101
- return { success: false, exitCode: 1 };
102
- }
103
-
104
- // Load configuration
105
- const config = loadConfig(cwd);
106
- const swarmConfig = (config?.swarm as Record<string, unknown>) || {};
107
- const mcpConfig = (config?.mcp as Record<string, unknown>) || {};
108
-
109
- const finalTopology = topology || (swarmConfig.topology as string) || DEFAULT_TOPOLOGY;
110
- const maxAgents = (swarmConfig.maxAgents as number) || DEFAULT_MAX_AGENTS;
111
- const autoStartMcp = (mcpConfig.autoStart as boolean) !== false && !skipMcp;
112
- const mcpPort = port || (mcpConfig.serverPort as number) || DEFAULT_PORT;
113
-
114
- output.writeln();
115
- output.writeln(output.bold('Starting Claude Flow V3'));
116
- output.writeln();
117
-
118
- const spinner = output.createSpinner({ text: 'Initializing system...' });
119
-
120
- try {
121
- // Step 1: Initialize swarm
122
- spinner.start();
123
- spinner.setText('Initializing V3 swarm...');
124
-
125
- const swarmResult = await callMCPTool<{
126
- swarmId: string;
127
- topology: string;
128
- initializedAt: string;
129
- config: Record<string, unknown>;
130
- }>('swarm/init', {
131
- topology: finalTopology,
132
- maxAgents,
133
- autoScaling: swarmConfig.autoScale !== false,
134
- v3Mode: true
135
- });
136
-
137
- spinner.succeed(`Swarm initialized (${finalTopology})`);
138
-
139
- // Step 2: Start MCP server if configured
140
- let mcpResult: Record<string, unknown> | null = null;
141
- if (autoStartMcp) {
142
- spinner.setText('Starting MCP server...');
143
- spinner.start();
144
-
145
- try {
146
- mcpResult = await callMCPTool<{
147
- serverId: string;
148
- port: number;
149
- transport: string;
150
- startedAt: string;
151
- }>('mcp/start', {
152
- port: mcpPort,
153
- transport: mcpConfig.transportType || 'stdio',
154
- tools: mcpConfig.tools || ['agent', 'swarm', 'memory', 'task']
155
- });
156
-
157
- spinner.succeed(`MCP server started on port ${mcpPort}`);
158
- } catch (error) {
159
- spinner.fail('MCP server failed to start');
160
- output.printWarning(
161
- error instanceof MCPClientError
162
- ? error.message
163
- : String(error)
164
- );
165
- // Continue without MCP
166
- }
167
- }
168
-
169
- // Step 3: Run health check
170
- spinner.setText('Running health checks...');
171
- spinner.start();
172
-
173
- const healthResult = await callMCPTool<{
174
- status: 'healthy' | 'degraded' | 'unhealthy';
175
- checks: Array<{ name: string; status: string; message?: string }>;
176
- }>('swarm/health', {
177
- swarmId: swarmResult.swarmId
178
- });
179
-
180
- if (healthResult.status === 'healthy') {
181
- spinner.succeed('Health checks passed');
182
- } else {
183
- spinner.fail(`Health check: ${healthResult.status}`);
184
- }
185
-
186
- // Success output
187
- output.writeln();
188
- output.printSuccess('Claude Flow V3 is running!');
189
- output.writeln();
190
-
191
- // Status display
192
- output.printBox(
193
- [
194
- `Swarm ID: ${swarmResult.swarmId}`,
195
- `Topology: ${finalTopology}`,
196
- `Max Agents: ${maxAgents}`,
197
- `MCP Server: ${autoStartMcp ? `localhost:${mcpPort}` : 'disabled'}`,
198
- `Mode: ${daemon ? 'Daemon' : 'Foreground'}`,
199
- `Health: ${healthResult.status}`
200
- ].join('\n'),
201
- 'System Status'
202
- );
203
-
204
- output.writeln();
205
- output.writeln(output.bold('Quick Commands:'));
206
- output.printList([
207
- `${output.highlight('claude-flow status')} - View system status`,
208
- `${output.highlight('claude-flow agent spawn -t coder')} - Spawn an agent`,
209
- `${output.highlight('claude-flow swarm status')} - View swarm details`,
210
- `${output.highlight('claude-flow stop')} - Stop the system`
211
- ]);
212
-
213
- // Daemon mode
214
- if (daemon) {
215
- output.writeln();
216
- output.printInfo('Running in daemon mode. Use "claude-flow stop" to stop.');
217
-
218
- // Store PID for daemon management
219
- // TODO: Implement proper process forking with detached: true
220
- const daemonPidPath = path.join(cwd, '.claude-flow', 'daemon.pid');
221
- fs.writeFileSync(daemonPidPath, String(process.pid));
222
- }
223
-
224
- const result = {
225
- swarmId: swarmResult.swarmId,
226
- topology: finalTopology,
227
- maxAgents,
228
- mcp: mcpResult ? {
229
- port: mcpPort,
230
- transport: mcpConfig.transportType || 'stdio'
231
- } : null,
232
- health: healthResult.status,
233
- daemon,
234
- startedAt: new Date().toISOString()
235
- };
236
-
237
- if (ctx.flags.format === 'json') {
238
- output.printJson(result);
239
- }
240
-
241
- return { success: true, data: result };
242
- } catch (error) {
243
- spinner.fail('Startup failed');
244
- if (error instanceof MCPClientError) {
245
- output.printError(`Failed to start: ${error.message}`);
246
- } else {
247
- output.printError(`Unexpected error: ${String(error)}`);
248
- }
249
- return { success: false, exitCode: 1 };
250
- }
251
- };
252
-
253
- // Stop subcommand
254
- const stopCommand: Command = {
255
- name: 'stop',
256
- description: 'Stop the Claude Flow system',
257
- options: [
258
- {
259
- name: 'force',
260
- short: 'f',
261
- description: 'Force stop without graceful shutdown',
262
- type: 'boolean',
263
- default: false
264
- },
265
- {
266
- name: 'timeout',
267
- description: 'Shutdown timeout in seconds',
268
- type: 'number',
269
- default: 30
270
- }
271
- ],
272
- action: async (ctx: CommandContext): Promise<CommandResult> => {
273
- const force = ctx.flags.force as boolean;
274
- const timeout = ctx.flags.timeout as number;
275
-
276
- output.writeln();
277
- output.writeln(output.bold('Stopping Claude Flow'));
278
- output.writeln();
279
-
280
- if (!force && ctx.interactive) {
281
- const confirmed = await confirm({
282
- message: 'Are you sure you want to stop Claude Flow?',
283
- default: false
284
- });
285
-
286
- if (!confirmed) {
287
- output.printInfo('Operation cancelled');
288
- return { success: true };
289
- }
290
- }
291
-
292
- const spinner = output.createSpinner({ text: 'Stopping system...' });
293
- spinner.start();
294
-
295
- try {
296
- // Stop MCP server
297
- spinner.setText('Stopping MCP server...');
298
- try {
299
- await callMCPTool('mcp/stop', { graceful: !force, timeout });
300
- spinner.succeed('MCP server stopped');
301
- } catch {
302
- spinner.fail('MCP server was not running');
303
- }
304
-
305
- // Stop swarm
306
- spinner.setText('Stopping swarm...');
307
- spinner.start();
308
- try {
309
- await callMCPTool('swarm/stop', {
310
- graceful: !force,
311
- timeout,
312
- saveState: true
313
- });
314
- spinner.succeed('Swarm stopped');
315
- } catch {
316
- spinner.fail('Swarm was not running');
317
- }
318
-
319
- // Clean up daemon PID
320
- const daemonPidPath = path.join(ctx.cwd, '.claude-flow', 'daemon.pid');
321
- if (fs.existsSync(daemonPidPath)) {
322
- fs.unlinkSync(daemonPidPath);
323
- }
324
-
325
- output.writeln();
326
- output.printSuccess('Claude Flow stopped successfully');
327
-
328
- return {
329
- success: true,
330
- data: { stopped: true, force, stoppedAt: new Date().toISOString() }
331
- };
332
- } catch (error) {
333
- spinner.fail('Stop failed');
334
- output.printError(`Failed to stop: ${error instanceof Error ? error.message : String(error)}`);
335
- return { success: false, exitCode: 1 };
336
- }
337
- }
338
- };
339
-
340
- // Restart subcommand
341
- const restartCommand: Command = {
342
- name: 'restart',
343
- description: 'Restart the Claude Flow system',
344
- options: [
345
- {
346
- name: 'force',
347
- short: 'f',
348
- description: 'Force restart',
349
- type: 'boolean',
350
- default: false
351
- }
352
- ],
353
- action: async (ctx: CommandContext): Promise<CommandResult> => {
354
- output.writeln();
355
- output.writeln(output.bold('Restarting Claude Flow'));
356
- output.writeln();
357
-
358
- // Stop first
359
- const stopCtx = { ...ctx, flags: { ...ctx.flags } };
360
- const stopResult = await stopCommand.action!(stopCtx);
361
-
362
- if (stopResult && !stopResult.success) {
363
- output.printWarning('Stop failed, attempting to start anyway...');
364
- }
365
-
366
- // Wait briefly
367
- await new Promise(resolve => setTimeout(resolve, 1000));
368
-
369
- // Start again
370
- const startResult = await startAction(ctx);
371
-
372
- return {
373
- success: startResult.success,
374
- data: {
375
- restarted: startResult.success,
376
- restartedAt: new Date().toISOString()
377
- }
378
- };
379
- }
380
- };
381
-
382
- // Quick start subcommand
383
- const quickCommand: Command = {
384
- name: 'quick',
385
- aliases: ['q'],
386
- description: 'Quick start with default settings',
387
- action: async (ctx: CommandContext): Promise<CommandResult> => {
388
- // Initialize if needed
389
- if (!isInitialized(ctx.cwd)) {
390
- output.printInfo('Project not initialized, running init first...');
391
- output.writeln();
392
-
393
- // Call init with minimal settings
394
- const { initCommand } = await import('./init.js');
395
- const initCtx = {
396
- ...ctx,
397
- flags: { ...ctx.flags, minimal: true }
398
- };
399
- await initCommand.action!(initCtx);
400
- output.writeln();
401
- }
402
-
403
- // Start with defaults
404
- return startAction({
405
- ...ctx,
406
- flags: { ...ctx.flags, topology: 'mesh' }
407
- });
408
- }
409
- };
410
-
411
- // Main start command
412
- export const startCommand: Command = {
413
- name: 'start',
414
- description: 'Start the Claude Flow orchestration system',
415
- subcommands: [stopCommand, restartCommand, quickCommand],
416
- options: [
417
- {
418
- name: 'daemon',
419
- short: 'd',
420
- description: 'Run as daemon in background',
421
- type: 'boolean',
422
- default: false
423
- },
424
- {
425
- name: 'port',
426
- short: 'p',
427
- description: 'MCP server port',
428
- type: 'number',
429
- default: DEFAULT_PORT
430
- },
431
- {
432
- name: 'topology',
433
- short: 't',
434
- description: 'Swarm topology (hierarchical-mesh, mesh, hierarchical, ring, star)',
435
- type: 'string',
436
- choices: ['hierarchical-mesh', 'mesh', 'hierarchical', 'ring', 'star']
437
- },
438
- {
439
- name: 'skip-mcp',
440
- description: 'Skip starting MCP server',
441
- type: 'boolean',
442
- default: false
443
- }
444
- ],
445
- examples: [
446
- { command: 'claude-flow start', description: 'Start with configuration defaults' },
447
- { command: 'claude-flow start --daemon', description: 'Start as background daemon' },
448
- { command: 'claude-flow start --port 3001', description: 'Start MCP on custom port' },
449
- { command: 'claude-flow start --topology mesh', description: 'Start with mesh topology' },
450
- { command: 'claude-flow start --skip-mcp', description: 'Start without MCP server' },
451
- { command: 'claude-flow start quick', description: 'Quick start with defaults' },
452
- { command: 'claude-flow start stop', description: 'Stop the running system' }
453
- ],
454
- action: startAction
455
- };
456
-
457
- export default startCommand;