@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/config-adapter.ts
DELETED
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Configuration Adapter
|
|
3
|
-
* Converts between SystemConfig and V3Config types
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import type { SystemConfig } from '@claude-flow/shared';
|
|
7
|
-
import type { V3Config } from './types.js';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Convert SystemConfig to V3Config (CLI-specific format)
|
|
11
|
-
*/
|
|
12
|
-
export function systemConfigToV3Config(systemConfig: SystemConfig): V3Config {
|
|
13
|
-
return {
|
|
14
|
-
version: '3.0.0',
|
|
15
|
-
projectRoot: systemConfig.orchestrator?.session?.dataDir || process.cwd(),
|
|
16
|
-
|
|
17
|
-
// Agent configuration
|
|
18
|
-
agents: {
|
|
19
|
-
defaultType: 'coder',
|
|
20
|
-
autoSpawn: false, // Not in SystemConfig
|
|
21
|
-
maxConcurrent: systemConfig.orchestrator?.lifecycle?.maxConcurrentAgents ?? 15,
|
|
22
|
-
timeout: systemConfig.orchestrator?.lifecycle?.spawnTimeout ?? 300000,
|
|
23
|
-
providers: [],
|
|
24
|
-
},
|
|
25
|
-
|
|
26
|
-
// Swarm configuration
|
|
27
|
-
swarm: {
|
|
28
|
-
topology: normalizeTopology(systemConfig.swarm?.topology),
|
|
29
|
-
maxAgents: systemConfig.swarm?.maxAgents ?? 15,
|
|
30
|
-
autoScale: systemConfig.swarm?.autoScale?.enabled ?? false,
|
|
31
|
-
coordinationStrategy: systemConfig.swarm?.coordination?.consensusRequired ? 'consensus' : 'leader',
|
|
32
|
-
healthCheckInterval: systemConfig.swarm?.coordination?.timeoutMs ?? 10000,
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
// Memory configuration
|
|
36
|
-
memory: {
|
|
37
|
-
backend: normalizeMemoryBackend(systemConfig.memory?.type),
|
|
38
|
-
persistPath: systemConfig.memory?.path || './data/memory',
|
|
39
|
-
cacheSize: systemConfig.memory?.maxSize ?? 1000000,
|
|
40
|
-
enableHNSW: systemConfig.memory?.agentdb?.indexType === 'hnsw',
|
|
41
|
-
vectorDimension: systemConfig.memory?.agentdb?.dimensions ?? 1536,
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
// MCP configuration
|
|
45
|
-
mcp: {
|
|
46
|
-
serverHost: systemConfig.mcp?.transport?.host || 'localhost',
|
|
47
|
-
serverPort: systemConfig.mcp?.transport?.port ?? 3000,
|
|
48
|
-
autoStart: false, // Not in SystemConfig
|
|
49
|
-
transportType: systemConfig.mcp?.transport?.type || 'stdio',
|
|
50
|
-
tools: [], // Not in SystemConfig
|
|
51
|
-
},
|
|
52
|
-
|
|
53
|
-
// CLI preferences
|
|
54
|
-
cli: {
|
|
55
|
-
colorOutput: true,
|
|
56
|
-
interactive: true,
|
|
57
|
-
verbosity: 'normal',
|
|
58
|
-
outputFormat: 'text',
|
|
59
|
-
progressStyle: 'spinner',
|
|
60
|
-
},
|
|
61
|
-
|
|
62
|
-
// Hooks configuration
|
|
63
|
-
hooks: {
|
|
64
|
-
enabled: false,
|
|
65
|
-
autoExecute: false,
|
|
66
|
-
hooks: [],
|
|
67
|
-
},
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Convert V3Config to SystemConfig
|
|
73
|
-
*/
|
|
74
|
-
export function v3ConfigToSystemConfig(v3Config: V3Config): Partial<SystemConfig> {
|
|
75
|
-
return {
|
|
76
|
-
orchestrator: {
|
|
77
|
-
lifecycle: {
|
|
78
|
-
maxConcurrentAgents: v3Config.agents.maxConcurrent,
|
|
79
|
-
spawnTimeout: v3Config.agents.timeout,
|
|
80
|
-
terminateTimeout: 10000,
|
|
81
|
-
maxSpawnRetries: 3,
|
|
82
|
-
},
|
|
83
|
-
session: {
|
|
84
|
-
dataDir: v3Config.projectRoot,
|
|
85
|
-
persistSessions: true,
|
|
86
|
-
sessionRetentionMs: 3600000,
|
|
87
|
-
},
|
|
88
|
-
health: {
|
|
89
|
-
checkInterval: v3Config.swarm.healthCheckInterval,
|
|
90
|
-
historyLimit: 100,
|
|
91
|
-
degradedThreshold: 1,
|
|
92
|
-
unhealthyThreshold: 2,
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
|
|
96
|
-
swarm: {
|
|
97
|
-
topology: denormalizeTopology(v3Config.swarm.topology),
|
|
98
|
-
maxAgents: v3Config.swarm.maxAgents,
|
|
99
|
-
autoScale: {
|
|
100
|
-
enabled: v3Config.swarm.autoScale,
|
|
101
|
-
minAgents: 1,
|
|
102
|
-
maxAgents: v3Config.swarm.maxAgents,
|
|
103
|
-
scaleUpThreshold: 0.8,
|
|
104
|
-
scaleDownThreshold: 0.3,
|
|
105
|
-
},
|
|
106
|
-
coordination: {
|
|
107
|
-
consensusRequired: v3Config.swarm.coordinationStrategy === 'consensus',
|
|
108
|
-
timeoutMs: v3Config.swarm.healthCheckInterval,
|
|
109
|
-
retryPolicy: {
|
|
110
|
-
maxRetries: 3,
|
|
111
|
-
backoffMs: 500,
|
|
112
|
-
},
|
|
113
|
-
},
|
|
114
|
-
communication: {
|
|
115
|
-
protocol: 'events',
|
|
116
|
-
batchSize: 10,
|
|
117
|
-
flushIntervalMs: 100,
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
|
|
121
|
-
memory: {
|
|
122
|
-
type: denormalizeMemoryBackend(v3Config.memory.backend),
|
|
123
|
-
path: v3Config.memory.persistPath,
|
|
124
|
-
maxSize: v3Config.memory.cacheSize,
|
|
125
|
-
agentdb: {
|
|
126
|
-
dimensions: v3Config.memory.vectorDimension,
|
|
127
|
-
indexType: v3Config.memory.enableHNSW ? 'hnsw' : 'flat',
|
|
128
|
-
efConstruction: 200,
|
|
129
|
-
m: 16,
|
|
130
|
-
quantization: 'none',
|
|
131
|
-
},
|
|
132
|
-
},
|
|
133
|
-
|
|
134
|
-
mcp: {
|
|
135
|
-
name: 'claude-flow',
|
|
136
|
-
version: '3.0.0',
|
|
137
|
-
transport: {
|
|
138
|
-
type: v3Config.mcp.transportType as 'stdio' | 'http' | 'websocket',
|
|
139
|
-
host: v3Config.mcp.serverHost,
|
|
140
|
-
port: v3Config.mcp.serverPort,
|
|
141
|
-
},
|
|
142
|
-
capabilities: {
|
|
143
|
-
tools: true,
|
|
144
|
-
resources: true,
|
|
145
|
-
prompts: true,
|
|
146
|
-
logging: true,
|
|
147
|
-
},
|
|
148
|
-
},
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Normalize topology from SystemConfig to V3Config
|
|
154
|
-
*/
|
|
155
|
-
function normalizeTopology(
|
|
156
|
-
topology: string | undefined
|
|
157
|
-
): 'hierarchical' | 'mesh' | 'ring' | 'star' | 'hybrid' {
|
|
158
|
-
switch (topology) {
|
|
159
|
-
case 'hierarchical':
|
|
160
|
-
case 'mesh':
|
|
161
|
-
case 'ring':
|
|
162
|
-
case 'star':
|
|
163
|
-
return topology;
|
|
164
|
-
case 'hierarchical-mesh':
|
|
165
|
-
case 'adaptive':
|
|
166
|
-
return 'hybrid';
|
|
167
|
-
default:
|
|
168
|
-
return 'hierarchical';
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* Denormalize topology from V3Config to SystemConfig
|
|
174
|
-
*/
|
|
175
|
-
function denormalizeTopology(
|
|
176
|
-
topology: 'hierarchical' | 'mesh' | 'ring' | 'star' | 'hybrid'
|
|
177
|
-
): 'hierarchical' | 'mesh' | 'ring' | 'star' | 'adaptive' | 'hierarchical-mesh' {
|
|
178
|
-
if (topology === 'hybrid') {
|
|
179
|
-
return 'hierarchical-mesh';
|
|
180
|
-
}
|
|
181
|
-
return topology;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* Normalize memory backend from SystemConfig to V3Config
|
|
186
|
-
*/
|
|
187
|
-
function normalizeMemoryBackend(
|
|
188
|
-
backend: string | undefined
|
|
189
|
-
): 'memory' | 'sqlite' | 'agentdb' | 'hybrid' {
|
|
190
|
-
switch (backend) {
|
|
191
|
-
case 'memory':
|
|
192
|
-
case 'sqlite':
|
|
193
|
-
case 'agentdb':
|
|
194
|
-
case 'hybrid':
|
|
195
|
-
return backend;
|
|
196
|
-
case 'redis':
|
|
197
|
-
return 'memory'; // Redis maps to memory for CLI purposes
|
|
198
|
-
default:
|
|
199
|
-
return 'hybrid';
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* Denormalize memory backend from V3Config to SystemConfig
|
|
205
|
-
*/
|
|
206
|
-
function denormalizeMemoryBackend(
|
|
207
|
-
backend: 'memory' | 'sqlite' | 'agentdb' | 'hybrid'
|
|
208
|
-
): 'memory' | 'sqlite' | 'agentdb' | 'hybrid' | 'redis' {
|
|
209
|
-
return backend;
|
|
210
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,383 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* V3 CLI Main Entry Point
|
|
3
|
-
* Modernized CLI for Claude Flow V3
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import type { Command, CommandContext, CommandResult, V3Config, CLIError } from './types.js';
|
|
7
|
-
import { CommandParser, commandParser } from './parser.js';
|
|
8
|
-
import { OutputFormatter, output } from './output.js';
|
|
9
|
-
import { commands, commandRegistry, getCommand } from './commands/index.js';
|
|
10
|
-
|
|
11
|
-
export const VERSION = '3.0.0-alpha.1';
|
|
12
|
-
|
|
13
|
-
export interface CLIOptions {
|
|
14
|
-
name?: string;
|
|
15
|
-
description?: string;
|
|
16
|
-
version?: string;
|
|
17
|
-
interactive?: boolean;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* V3 CLI Application
|
|
22
|
-
*/
|
|
23
|
-
export class CLI {
|
|
24
|
-
private name: string;
|
|
25
|
-
private description: string;
|
|
26
|
-
private version: string;
|
|
27
|
-
private parser: CommandParser;
|
|
28
|
-
private output: OutputFormatter;
|
|
29
|
-
private interactive: boolean;
|
|
30
|
-
|
|
31
|
-
constructor(options: CLIOptions = {}) {
|
|
32
|
-
this.name = options.name || 'claude-flow';
|
|
33
|
-
this.description = options.description || 'Claude Flow V3 - AI Agent Orchestration Platform';
|
|
34
|
-
this.version = options.version || VERSION;
|
|
35
|
-
this.parser = commandParser;
|
|
36
|
-
this.output = output;
|
|
37
|
-
this.interactive = options.interactive ?? process.stdin.isTTY ?? false;
|
|
38
|
-
|
|
39
|
-
// Register all commands
|
|
40
|
-
for (const cmd of commands) {
|
|
41
|
-
this.parser.registerCommand(cmd);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Run the CLI with given arguments
|
|
47
|
-
*/
|
|
48
|
-
async run(args: string[] = process.argv.slice(2)): Promise<void> {
|
|
49
|
-
try {
|
|
50
|
-
// Parse arguments
|
|
51
|
-
const parseResult = this.parser.parse(args);
|
|
52
|
-
const { command: commandPath, flags, positional } = parseResult;
|
|
53
|
-
|
|
54
|
-
// Handle global flags
|
|
55
|
-
if (flags.version || flags.V) {
|
|
56
|
-
this.showVersion();
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (flags.noColor) {
|
|
61
|
-
this.output.setColorEnabled(false);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// No command - show help
|
|
65
|
-
if (commandPath.length === 0 || flags.help || flags.h) {
|
|
66
|
-
if (commandPath.length > 0) {
|
|
67
|
-
// Show command-specific help
|
|
68
|
-
this.showCommandHelp(commandPath[0]);
|
|
69
|
-
} else {
|
|
70
|
-
this.showHelp();
|
|
71
|
-
}
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// Find and execute command
|
|
76
|
-
const commandName = commandPath[0];
|
|
77
|
-
// First check the parser's registry (for dynamically registered commands)
|
|
78
|
-
// Then fall back to the static registry
|
|
79
|
-
const command = this.parser.getCommand(commandName) || getCommand(commandName);
|
|
80
|
-
|
|
81
|
-
if (!command) {
|
|
82
|
-
this.output.printError(`Unknown command: ${commandName}`);
|
|
83
|
-
this.output.writeln(`Run "${this.name} --help" for available commands`);
|
|
84
|
-
process.exit(1);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// Handle subcommand (supports nested subcommands)
|
|
88
|
-
let targetCommand = command;
|
|
89
|
-
let subcommandArgs = positional;
|
|
90
|
-
|
|
91
|
-
// Process command path (e.g., ['hooks', 'worker', 'list'])
|
|
92
|
-
if (commandPath.length > 1 && command.subcommands) {
|
|
93
|
-
const subcommandName = commandPath[1];
|
|
94
|
-
const subcommand = command.subcommands.find(
|
|
95
|
-
sc => sc.name === subcommandName || sc.aliases?.includes(subcommandName)
|
|
96
|
-
);
|
|
97
|
-
|
|
98
|
-
if (subcommand) {
|
|
99
|
-
targetCommand = subcommand;
|
|
100
|
-
subcommandArgs = positional.slice(1);
|
|
101
|
-
|
|
102
|
-
// Check for nested subcommand (level 2)
|
|
103
|
-
if (commandPath.length > 2 && subcommand.subcommands) {
|
|
104
|
-
const nestedName = commandPath[2];
|
|
105
|
-
const nestedSubcommand = subcommand.subcommands.find(
|
|
106
|
-
sc => sc.name === nestedName || sc.aliases?.includes(nestedName)
|
|
107
|
-
);
|
|
108
|
-
if (nestedSubcommand) {
|
|
109
|
-
targetCommand = nestedSubcommand;
|
|
110
|
-
subcommandArgs = positional.slice(2);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
} else if (positional.length > 0 && command.subcommands) {
|
|
115
|
-
// Check if first positional is a subcommand
|
|
116
|
-
const subcommandName = positional[0];
|
|
117
|
-
const subcommand = command.subcommands.find(
|
|
118
|
-
sc => sc.name === subcommandName || sc.aliases?.includes(subcommandName)
|
|
119
|
-
);
|
|
120
|
-
|
|
121
|
-
if (subcommand) {
|
|
122
|
-
targetCommand = subcommand;
|
|
123
|
-
subcommandArgs = positional.slice(1);
|
|
124
|
-
|
|
125
|
-
// Check for nested subcommand (level 2 from positional)
|
|
126
|
-
if (subcommandArgs.length > 0 && subcommand.subcommands) {
|
|
127
|
-
const nestedName = subcommandArgs[0];
|
|
128
|
-
const nestedSubcommand = subcommand.subcommands.find(
|
|
129
|
-
sc => sc.name === nestedName || sc.aliases?.includes(nestedName)
|
|
130
|
-
);
|
|
131
|
-
if (nestedSubcommand) {
|
|
132
|
-
targetCommand = nestedSubcommand;
|
|
133
|
-
subcommandArgs = subcommandArgs.slice(1);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// Validate flags
|
|
140
|
-
const validationErrors = this.parser.validateFlags(flags, targetCommand);
|
|
141
|
-
if (validationErrors.length > 0) {
|
|
142
|
-
for (const error of validationErrors) {
|
|
143
|
-
this.output.printError(error);
|
|
144
|
-
}
|
|
145
|
-
process.exit(1);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
// Build context
|
|
149
|
-
const ctx: CommandContext = {
|
|
150
|
-
args: subcommandArgs,
|
|
151
|
-
flags,
|
|
152
|
-
config: await this.loadConfig(flags.config as string),
|
|
153
|
-
cwd: process.cwd(),
|
|
154
|
-
interactive: this.interactive && !flags.quiet
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
// Execute command
|
|
158
|
-
if (targetCommand.action) {
|
|
159
|
-
const result = await targetCommand.action(ctx);
|
|
160
|
-
|
|
161
|
-
if (result && !result.success) {
|
|
162
|
-
process.exit(result.exitCode || 1);
|
|
163
|
-
}
|
|
164
|
-
} else {
|
|
165
|
-
// No action - show command help
|
|
166
|
-
this.showCommandHelp(commandName);
|
|
167
|
-
}
|
|
168
|
-
} catch (error) {
|
|
169
|
-
// Don't re-handle if this is a process.exit error (from mocked tests)
|
|
170
|
-
const errorMessage = (error as Error).message;
|
|
171
|
-
if (errorMessage && errorMessage.startsWith('process.exit:')) {
|
|
172
|
-
throw error; // Re-throw so tests can capture the exit code
|
|
173
|
-
}
|
|
174
|
-
this.handleError(error as Error);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Show main help
|
|
180
|
-
*/
|
|
181
|
-
private showHelp(): void {
|
|
182
|
-
this.output.writeln();
|
|
183
|
-
this.output.writeln(this.output.bold(`${this.name} v${this.version}`));
|
|
184
|
-
this.output.writeln(this.output.dim(this.description));
|
|
185
|
-
this.output.writeln();
|
|
186
|
-
|
|
187
|
-
this.output.writeln(this.output.bold('USAGE:'));
|
|
188
|
-
this.output.writeln(` ${this.name} <command> [subcommand] [options]`);
|
|
189
|
-
this.output.writeln();
|
|
190
|
-
|
|
191
|
-
this.output.writeln(this.output.bold('COMMANDS:'));
|
|
192
|
-
for (const cmd of commands) {
|
|
193
|
-
if (cmd.hidden) continue;
|
|
194
|
-
const name = cmd.name.padEnd(12);
|
|
195
|
-
this.output.writeln(` ${this.output.highlight(name)} ${cmd.description}`);
|
|
196
|
-
}
|
|
197
|
-
this.output.writeln();
|
|
198
|
-
|
|
199
|
-
this.output.writeln(this.output.bold('GLOBAL OPTIONS:'));
|
|
200
|
-
for (const opt of this.parser.getGlobalOptions()) {
|
|
201
|
-
const flags = opt.short ? `-${opt.short}, --${opt.name}` : ` --${opt.name}`;
|
|
202
|
-
this.output.writeln(` ${flags.padEnd(25)} ${opt.description}`);
|
|
203
|
-
}
|
|
204
|
-
this.output.writeln();
|
|
205
|
-
|
|
206
|
-
this.output.writeln(this.output.bold('V3 FEATURES:'));
|
|
207
|
-
this.output.printList([
|
|
208
|
-
'15-agent hierarchical mesh coordination',
|
|
209
|
-
'AgentDB with HNSW indexing (150x-12,500x faster)',
|
|
210
|
-
'Flash Attention (2.49x-7.47x speedup)',
|
|
211
|
-
'Unified SwarmCoordinator engine',
|
|
212
|
-
'Event-sourced state management',
|
|
213
|
-
'Domain-Driven Design architecture'
|
|
214
|
-
]);
|
|
215
|
-
this.output.writeln();
|
|
216
|
-
|
|
217
|
-
this.output.writeln(this.output.bold('EXAMPLES:'));
|
|
218
|
-
this.output.writeln(` ${this.name} agent spawn -t coder # Spawn a coder agent`);
|
|
219
|
-
this.output.writeln(` ${this.name} swarm init --v3-mode # Initialize V3 swarm`);
|
|
220
|
-
this.output.writeln(` ${this.name} memory search -q "auth patterns" # Semantic search`);
|
|
221
|
-
this.output.writeln(` ${this.name} mcp start # Start MCP server`);
|
|
222
|
-
this.output.writeln();
|
|
223
|
-
|
|
224
|
-
this.output.writeln(this.output.dim('Run "claude-flow <command> --help" for command help'));
|
|
225
|
-
this.output.writeln();
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* Show command-specific help
|
|
230
|
-
*/
|
|
231
|
-
private showCommandHelp(commandName: string): void {
|
|
232
|
-
const command = getCommand(commandName);
|
|
233
|
-
|
|
234
|
-
if (!command) {
|
|
235
|
-
this.output.printError(`Unknown command: ${commandName}`);
|
|
236
|
-
return;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
this.output.writeln();
|
|
240
|
-
this.output.writeln(this.output.bold(`${this.name} ${command.name}`));
|
|
241
|
-
this.output.writeln(command.description);
|
|
242
|
-
this.output.writeln();
|
|
243
|
-
|
|
244
|
-
// Subcommands
|
|
245
|
-
if (command.subcommands && command.subcommands.length > 0) {
|
|
246
|
-
this.output.writeln(this.output.bold('SUBCOMMANDS:'));
|
|
247
|
-
for (const sub of command.subcommands) {
|
|
248
|
-
if (sub.hidden) continue;
|
|
249
|
-
const name = sub.name.padEnd(15);
|
|
250
|
-
const aliases = sub.aliases ? this.output.dim(` (${sub.aliases.join(', ')})`) : '';
|
|
251
|
-
this.output.writeln(` ${this.output.highlight(name)} ${sub.description}${aliases}`);
|
|
252
|
-
}
|
|
253
|
-
this.output.writeln();
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
// Options
|
|
257
|
-
if (command.options && command.options.length > 0) {
|
|
258
|
-
this.output.writeln(this.output.bold('OPTIONS:'));
|
|
259
|
-
for (const opt of command.options) {
|
|
260
|
-
const flags = opt.short ? `-${opt.short}, --${opt.name}` : ` --${opt.name}`;
|
|
261
|
-
const required = opt.required ? this.output.error(' (required)') : '';
|
|
262
|
-
const defaultVal = opt.default !== undefined ? this.output.dim(` [default: ${opt.default}]`) : '';
|
|
263
|
-
this.output.writeln(` ${flags.padEnd(25)} ${opt.description}${required}${defaultVal}`);
|
|
264
|
-
}
|
|
265
|
-
this.output.writeln();
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
// Examples
|
|
269
|
-
if (command.examples && command.examples.length > 0) {
|
|
270
|
-
this.output.writeln(this.output.bold('EXAMPLES:'));
|
|
271
|
-
for (const example of command.examples) {
|
|
272
|
-
this.output.writeln(` ${this.output.dim('$')} ${example.command}`);
|
|
273
|
-
this.output.writeln(` ${this.output.dim(example.description)}`);
|
|
274
|
-
}
|
|
275
|
-
this.output.writeln();
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
/**
|
|
280
|
-
* Show version
|
|
281
|
-
*/
|
|
282
|
-
private showVersion(): void {
|
|
283
|
-
this.output.writeln(`${this.name} v${this.version}`);
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
/**
|
|
287
|
-
* Load configuration file
|
|
288
|
-
*/
|
|
289
|
-
private async loadConfig(configPath?: string): Promise<V3Config | undefined> {
|
|
290
|
-
try {
|
|
291
|
-
// Import config utilities
|
|
292
|
-
const { loadConfig: loadSystemConfig } = await import('@claude-flow/shared');
|
|
293
|
-
const { systemConfigToV3Config } = await import('./config-adapter.js');
|
|
294
|
-
|
|
295
|
-
// Load configuration
|
|
296
|
-
const loaded = await loadSystemConfig({
|
|
297
|
-
file: configPath,
|
|
298
|
-
paths: configPath ? undefined : [process.cwd()],
|
|
299
|
-
});
|
|
300
|
-
|
|
301
|
-
// Convert to V3Config format
|
|
302
|
-
const v3Config = systemConfigToV3Config(loaded.config);
|
|
303
|
-
|
|
304
|
-
// Log warnings if any
|
|
305
|
-
if (loaded.warnings && loaded.warnings.length > 0) {
|
|
306
|
-
for (const warning of loaded.warnings) {
|
|
307
|
-
this.output.printWarning(warning);
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
return v3Config;
|
|
312
|
-
} catch (error) {
|
|
313
|
-
// Config loading is optional - don't fail if it doesn't exist
|
|
314
|
-
if (process.env.DEBUG) {
|
|
315
|
-
this.output.writeln(
|
|
316
|
-
this.output.dim(`Config loading failed: ${(error as Error).message}`)
|
|
317
|
-
);
|
|
318
|
-
}
|
|
319
|
-
return undefined;
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
/**
|
|
324
|
-
* Handle errors
|
|
325
|
-
*/
|
|
326
|
-
private handleError(error: Error): void {
|
|
327
|
-
if ('code' in error) {
|
|
328
|
-
// CLIError
|
|
329
|
-
const cliError = error as CLIError;
|
|
330
|
-
this.output.printError(cliError.message);
|
|
331
|
-
|
|
332
|
-
if (cliError.details) {
|
|
333
|
-
this.output.writeln(this.output.dim(JSON.stringify(cliError.details, null, 2)));
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
process.exit(cliError.exitCode);
|
|
337
|
-
} else {
|
|
338
|
-
// Generic error
|
|
339
|
-
this.output.printError(error.message);
|
|
340
|
-
|
|
341
|
-
if (process.env.DEBUG) {
|
|
342
|
-
this.output.writeln();
|
|
343
|
-
this.output.writeln(this.output.dim(error.stack || ''));
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
process.exit(1);
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
// =============================================================================
|
|
352
|
-
// Module Exports
|
|
353
|
-
// =============================================================================
|
|
354
|
-
|
|
355
|
-
// Types
|
|
356
|
-
export * from './types.js';
|
|
357
|
-
|
|
358
|
-
// Parser
|
|
359
|
-
export { CommandParser, commandParser } from './parser.js';
|
|
360
|
-
|
|
361
|
-
// Output
|
|
362
|
-
export { OutputFormatter, output, Progress, Spinner } from './output.js';
|
|
363
|
-
|
|
364
|
-
// Prompt
|
|
365
|
-
export * from './prompt.js';
|
|
366
|
-
|
|
367
|
-
// Commands (internal use)
|
|
368
|
-
export * from './commands/index.js';
|
|
369
|
-
|
|
370
|
-
// MCP Server management
|
|
371
|
-
export {
|
|
372
|
-
MCPServerManager,
|
|
373
|
-
createMCPServerManager,
|
|
374
|
-
getServerManager,
|
|
375
|
-
startMCPServer,
|
|
376
|
-
stopMCPServer,
|
|
377
|
-
getMCPServerStatus,
|
|
378
|
-
type MCPServerOptions,
|
|
379
|
-
type MCPServerStatus,
|
|
380
|
-
} from './mcp-server.js';
|
|
381
|
-
|
|
382
|
-
// Default export
|
|
383
|
-
export default CLI;
|