@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,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;