@claude-flow/cli 3.0.0-alpha.2 → 3.0.0-alpha.20
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.
- package/README.md +172 -6
- package/bin/cli.js +0 -0
- package/dist/src/commands/agent.d.ts.map +1 -1
- package/dist/src/commands/agent.js +43 -27
- package/dist/src/commands/agent.js.map +1 -1
- package/dist/src/commands/analyze.d.ts +19 -0
- package/dist/src/commands/analyze.d.ts.map +1 -0
- package/dist/src/commands/analyze.js +1823 -0
- package/dist/src/commands/analyze.js.map +1 -0
- package/dist/src/commands/claims.d.ts +10 -0
- package/dist/src/commands/claims.d.ts.map +1 -0
- package/dist/src/commands/claims.js +288 -0
- package/dist/src/commands/claims.js.map +1 -0
- package/dist/src/commands/completions.d.ts +10 -0
- package/dist/src/commands/completions.d.ts.map +1 -0
- package/dist/src/commands/completions.js +539 -0
- package/dist/src/commands/completions.js.map +1 -0
- package/dist/src/commands/config.js +2 -2
- package/dist/src/commands/config.js.map +1 -1
- package/dist/src/commands/daemon.d.ts +8 -0
- package/dist/src/commands/daemon.d.ts.map +1 -0
- package/dist/src/commands/daemon.js +545 -0
- package/dist/src/commands/daemon.js.map +1 -0
- package/dist/src/commands/deployment.d.ts +10 -0
- package/dist/src/commands/deployment.d.ts.map +1 -0
- package/dist/src/commands/deployment.js +289 -0
- package/dist/src/commands/deployment.js.map +1 -0
- package/dist/src/commands/doctor.d.ts +10 -0
- package/dist/src/commands/doctor.d.ts.map +1 -0
- package/dist/src/commands/doctor.js +429 -0
- package/dist/src/commands/doctor.js.map +1 -0
- package/dist/src/commands/embeddings.d.ts +18 -0
- package/dist/src/commands/embeddings.d.ts.map +1 -0
- package/dist/src/commands/embeddings.js +616 -0
- package/dist/src/commands/embeddings.js.map +1 -0
- package/dist/src/commands/hive-mind.d.ts.map +1 -1
- package/dist/src/commands/hive-mind.js +252 -35
- package/dist/src/commands/hive-mind.js.map +1 -1
- package/dist/src/commands/hooks.d.ts.map +1 -1
- package/dist/src/commands/hooks.js +326 -2
- package/dist/src/commands/hooks.js.map +1 -1
- package/dist/src/commands/index.d.ts +13 -0
- package/dist/src/commands/index.d.ts.map +1 -1
- package/dist/src/commands/index.js +52 -1
- package/dist/src/commands/index.js.map +1 -1
- package/dist/src/commands/mcp.js +4 -4
- package/dist/src/commands/mcp.js.map +1 -1
- package/dist/src/commands/memory.d.ts.map +1 -1
- package/dist/src/commands/memory.js +236 -170
- package/dist/src/commands/memory.js.map +1 -1
- package/dist/src/commands/migrate.js +1 -1
- package/dist/src/commands/migrate.js.map +1 -1
- package/dist/src/commands/neural.d.ts +10 -0
- package/dist/src/commands/neural.d.ts.map +1 -0
- package/dist/src/commands/neural.js +224 -0
- package/dist/src/commands/neural.js.map +1 -0
- package/dist/src/commands/performance.d.ts +10 -0
- package/dist/src/commands/performance.d.ts.map +1 -0
- package/dist/src/commands/performance.js +262 -0
- package/dist/src/commands/performance.js.map +1 -0
- package/dist/src/commands/plugins.d.ts +10 -0
- package/dist/src/commands/plugins.d.ts.map +1 -0
- package/dist/src/commands/plugins.js +280 -0
- package/dist/src/commands/plugins.js.map +1 -0
- package/dist/src/commands/process.d.ts.map +1 -1
- package/dist/src/commands/process.js +95 -20
- package/dist/src/commands/process.js.map +1 -1
- package/dist/src/commands/providers.d.ts +10 -0
- package/dist/src/commands/providers.d.ts.map +1 -0
- package/dist/src/commands/providers.js +232 -0
- package/dist/src/commands/providers.js.map +1 -0
- package/dist/src/commands/route.d.ts +16 -0
- package/dist/src/commands/route.d.ts.map +1 -0
- package/dist/src/commands/route.js +603 -0
- package/dist/src/commands/route.js.map +1 -0
- package/dist/src/commands/security.d.ts +10 -0
- package/dist/src/commands/security.d.ts.map +1 -0
- package/dist/src/commands/security.js +261 -0
- package/dist/src/commands/security.js.map +1 -0
- package/dist/src/commands/start.js +2 -2
- package/dist/src/commands/start.js.map +1 -1
- package/dist/src/commands/status.d.ts.map +1 -1
- package/dist/src/commands/status.js +26 -2
- package/dist/src/commands/status.js.map +1 -1
- package/dist/src/commands/swarm.js +6 -6
- package/dist/src/commands/swarm.js.map +1 -1
- package/dist/src/index.d.ts +4 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +63 -5
- package/dist/src/index.js.map +1 -1
- package/dist/src/init/claudemd-generator.d.ts.map +1 -1
- package/dist/src/init/claudemd-generator.js +218 -362
- package/dist/src/init/claudemd-generator.js.map +1 -1
- package/dist/src/init/executor.d.ts.map +1 -1
- package/dist/src/init/executor.js +5 -0
- package/dist/src/init/executor.js.map +1 -1
- package/dist/src/init/settings-generator.d.ts.map +1 -1
- package/dist/src/init/settings-generator.js +22 -12
- package/dist/src/init/settings-generator.js.map +1 -1
- package/dist/src/mcp-client.d.ts.map +1 -1
- package/dist/src/mcp-client.js +17 -1
- package/dist/src/mcp-client.js.map +1 -1
- package/dist/src/mcp-server.d.ts.map +1 -1
- package/dist/src/mcp-server.js +5 -0
- package/dist/src/mcp-server.js.map +1 -1
- package/dist/src/mcp-tools/agent-tools.d.ts +1 -1
- package/dist/src/mcp-tools/agent-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/agent-tools.js +350 -14
- package/dist/src/mcp-tools/agent-tools.js.map +1 -1
- package/dist/src/mcp-tools/analyze-tools.d.ts +38 -0
- package/dist/src/mcp-tools/analyze-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/analyze-tools.js +317 -0
- package/dist/src/mcp-tools/analyze-tools.js.map +1 -0
- package/dist/src/mcp-tools/config-tools.d.ts +1 -1
- package/dist/src/mcp-tools/config-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/config-tools.js +262 -15
- package/dist/src/mcp-tools/config-tools.js.map +1 -1
- package/dist/src/mcp-tools/hive-mind-tools.d.ts +8 -0
- package/dist/src/mcp-tools/hive-mind-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/hive-mind-tools.js +447 -0
- package/dist/src/mcp-tools/hive-mind-tools.js.map +1 -0
- package/dist/src/mcp-tools/hooks-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/hooks-tools.js +80 -15
- package/dist/src/mcp-tools/hooks-tools.js.map +1 -1
- package/dist/src/mcp-tools/index.d.ts +6 -0
- package/dist/src/mcp-tools/index.d.ts.map +1 -1
- package/dist/src/mcp-tools/index.js +6 -0
- package/dist/src/mcp-tools/index.js.map +1 -1
- package/dist/src/mcp-tools/memory-tools.d.ts +1 -1
- package/dist/src/mcp-tools/memory-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/memory-tools.js +157 -9
- package/dist/src/mcp-tools/memory-tools.js.map +1 -1
- package/dist/src/mcp-tools/session-tools.d.ts +8 -0
- package/dist/src/mcp-tools/session-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/session-tools.js +315 -0
- package/dist/src/mcp-tools/session-tools.js.map +1 -0
- package/dist/src/mcp-tools/swarm-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/swarm-tools.js +37 -2
- package/dist/src/mcp-tools/swarm-tools.js.map +1 -1
- package/dist/src/mcp-tools/task-tools.d.ts +8 -0
- package/dist/src/mcp-tools/task-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/task-tools.js +302 -0
- package/dist/src/mcp-tools/task-tools.js.map +1 -0
- package/dist/src/mcp-tools/workflow-tools.d.ts +8 -0
- package/dist/src/mcp-tools/workflow-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/workflow-tools.js +481 -0
- package/dist/src/mcp-tools/workflow-tools.js.map +1 -0
- package/dist/src/output.d.ts +16 -0
- package/dist/src/output.d.ts.map +1 -1
- package/dist/src/output.js +42 -0
- package/dist/src/output.js.map +1 -1
- package/dist/src/ruvector/ast-analyzer.d.ts +67 -0
- package/dist/src/ruvector/ast-analyzer.d.ts.map +1 -0
- package/dist/src/ruvector/ast-analyzer.js +277 -0
- package/dist/src/ruvector/ast-analyzer.js.map +1 -0
- package/dist/src/ruvector/coverage-router.d.ts +145 -0
- package/dist/src/ruvector/coverage-router.d.ts.map +1 -0
- package/dist/src/ruvector/coverage-router.js +451 -0
- package/dist/src/ruvector/coverage-router.js.map +1 -0
- package/dist/src/ruvector/coverage-tools.d.ts +33 -0
- package/dist/src/ruvector/coverage-tools.d.ts.map +1 -0
- package/dist/src/ruvector/coverage-tools.js +157 -0
- package/dist/src/ruvector/coverage-tools.js.map +1 -0
- package/dist/src/ruvector/diff-classifier.d.ts +154 -0
- package/dist/src/ruvector/diff-classifier.d.ts.map +1 -0
- package/dist/src/ruvector/diff-classifier.js +508 -0
- package/dist/src/ruvector/diff-classifier.js.map +1 -0
- package/dist/src/ruvector/graph-analyzer.d.ts +174 -0
- package/dist/src/ruvector/graph-analyzer.d.ts.map +1 -0
- package/dist/src/ruvector/graph-analyzer.js +878 -0
- package/dist/src/ruvector/graph-analyzer.js.map +1 -0
- package/dist/src/ruvector/index.d.ts +27 -0
- package/dist/src/ruvector/index.d.ts.map +1 -0
- package/dist/src/ruvector/index.js +47 -0
- package/dist/src/ruvector/index.js.map +1 -0
- package/dist/src/ruvector/q-learning-router.d.ts +211 -0
- package/dist/src/ruvector/q-learning-router.d.ts.map +1 -0
- package/dist/src/ruvector/q-learning-router.js +681 -0
- package/dist/src/ruvector/q-learning-router.js.map +1 -0
- package/dist/src/ruvector/vector-db.d.ts +69 -0
- package/dist/src/ruvector/vector-db.d.ts.map +1 -0
- package/dist/src/ruvector/vector-db.js +243 -0
- package/dist/src/ruvector/vector-db.js.map +1 -0
- package/dist/src/services/index.d.ts +7 -0
- package/dist/src/services/index.d.ts.map +1 -0
- package/dist/src/services/index.js +6 -0
- package/dist/src/services/index.js.map +1 -0
- package/dist/src/services/worker-daemon.d.ts +153 -0
- package/dist/src/services/worker-daemon.d.ts.map +1 -0
- package/dist/src/services/worker-daemon.js +567 -0
- package/dist/src/services/worker-daemon.js.map +1 -0
- package/dist/src/suggest.d.ts +53 -0
- package/dist/src/suggest.d.ts.map +1 -0
- package/dist/src/suggest.js +200 -0
- package/dist/src/suggest.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +28 -6
- package/.agentic-flow/intelligence.json +0 -16
- package/.claude-flow/metrics/agent-metrics.json +0 -1
- package/.claude-flow/metrics/performance.json +0 -87
- package/.claude-flow/metrics/task-metrics.json +0 -10
- package/__tests__/README.md +0 -140
- package/__tests__/TEST_SUMMARY.md +0 -144
- package/__tests__/cli.test.ts +0 -558
- package/__tests__/commands.test.ts +0 -726
- package/__tests__/config-adapter.test.ts +0 -362
- package/__tests__/config-loading.test.ts +0 -106
- package/__tests__/coverage/.tmp/coverage-0.json +0 -1
- package/__tests__/coverage/.tmp/coverage-1.json +0 -1
- package/__tests__/coverage/.tmp/coverage-2.json +0 -1
- package/__tests__/coverage/.tmp/coverage-3.json +0 -1
- package/__tests__/coverage/.tmp/coverage-4.json +0 -1
- package/__tests__/coverage/.tmp/coverage-5.json +0 -1
- package/__tests__/mcp-client.test.ts +0 -480
- package/__tests__/p1-commands.test.ts +0 -1064
- package/docs/CONFIG_LOADING.md +0 -236
- package/docs/IMPLEMENTATION_COMPLETE.md +0 -421
- package/docs/MCP_CLIENT_GUIDE.md +0 -620
- package/docs/REFACTORING_SUMMARY.md +0 -247
- package/src/commands/agent.ts +0 -941
- package/src/commands/config.ts +0 -452
- package/src/commands/hive-mind.ts +0 -762
- package/src/commands/hooks.ts +0 -2603
- package/src/commands/index.ts +0 -115
- package/src/commands/init.ts +0 -597
- package/src/commands/mcp.ts +0 -753
- package/src/commands/memory.ts +0 -1063
- package/src/commands/migrate.ts +0 -447
- package/src/commands/process.ts +0 -617
- package/src/commands/session.ts +0 -891
- package/src/commands/start.ts +0 -457
- package/src/commands/status.ts +0 -705
- package/src/commands/swarm.ts +0 -648
- package/src/commands/task.ts +0 -792
- package/src/commands/workflow.ts +0 -742
- package/src/config-adapter.ts +0 -210
- package/src/index.ts +0 -383
- package/src/infrastructure/in-memory-repositories.ts +0 -310
- package/src/init/claudemd-generator.ts +0 -631
- package/src/init/executor.ts +0 -756
- package/src/init/helpers-generator.ts +0 -628
- package/src/init/index.ts +0 -60
- package/src/init/mcp-generator.ts +0 -83
- package/src/init/settings-generator.ts +0 -274
- package/src/init/statusline-generator.ts +0 -211
- package/src/init/types.ts +0 -447
- package/src/mcp-client.ts +0 -227
- package/src/mcp-server.ts +0 -571
- package/src/mcp-tools/agent-tools.ts +0 -92
- package/src/mcp-tools/config-tools.ts +0 -88
- package/src/mcp-tools/hooks-tools.ts +0 -1819
- package/src/mcp-tools/index.ts +0 -12
- package/src/mcp-tools/memory-tools.ts +0 -89
- package/src/mcp-tools/swarm-tools.ts +0 -69
- package/src/mcp-tools/types.ts +0 -33
- package/src/output.ts +0 -593
- package/src/parser.ts +0 -417
- package/src/prompt.ts +0 -619
- package/src/types.ts +0 -287
- package/tmp.json +0 -0
- package/tsconfig.json +0 -16
- package/tsconfig.tsbuildinfo +0 -1
- package/vitest.config.ts +0 -13
package/src/commands/start.ts
DELETED
|
@@ -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
|
-
// In a real implementation, this would fork a background process
|
|
219
|
-
// For now, we simulate daemon behavior
|
|
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;
|