@claude-flow/cli 3.0.0-alpha.1
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/.agentic-flow/intelligence.json +16 -0
- package/.claude-flow/metrics/agent-metrics.json +1 -0
- package/.claude-flow/metrics/performance.json +87 -0
- package/.claude-flow/metrics/task-metrics.json +10 -0
- package/README.md +1186 -0
- package/__tests__/README.md +140 -0
- package/__tests__/TEST_SUMMARY.md +144 -0
- package/__tests__/cli.test.ts +558 -0
- package/__tests__/commands.test.ts +726 -0
- package/__tests__/config-adapter.test.ts +362 -0
- package/__tests__/config-loading.test.ts +106 -0
- package/__tests__/coverage/.tmp/coverage-0.json +1 -0
- package/__tests__/coverage/.tmp/coverage-1.json +1 -0
- package/__tests__/coverage/.tmp/coverage-2.json +1 -0
- package/__tests__/coverage/.tmp/coverage-3.json +1 -0
- package/__tests__/coverage/.tmp/coverage-4.json +1 -0
- package/__tests__/coverage/.tmp/coverage-5.json +1 -0
- package/__tests__/mcp-client.test.ts +480 -0
- package/__tests__/p1-commands.test.ts +1064 -0
- package/bin/cli.js +14 -0
- package/dist/src/commands/agent.d.ts +8 -0
- package/dist/src/commands/agent.d.ts.map +1 -0
- package/dist/src/commands/agent.js +803 -0
- package/dist/src/commands/agent.js.map +1 -0
- package/dist/src/commands/config.d.ts +8 -0
- package/dist/src/commands/config.d.ts.map +1 -0
- package/dist/src/commands/config.js +406 -0
- package/dist/src/commands/config.js.map +1 -0
- package/dist/src/commands/hive-mind.d.ts +8 -0
- package/dist/src/commands/hive-mind.d.ts.map +1 -0
- package/dist/src/commands/hive-mind.js +627 -0
- package/dist/src/commands/hive-mind.js.map +1 -0
- package/dist/src/commands/hooks.d.ts +8 -0
- package/dist/src/commands/hooks.d.ts.map +1 -0
- package/dist/src/commands/hooks.js +2098 -0
- package/dist/src/commands/hooks.js.map +1 -0
- package/dist/src/commands/index.d.ts +51 -0
- package/dist/src/commands/index.d.ts.map +1 -0
- package/dist/src/commands/index.js +105 -0
- package/dist/src/commands/index.js.map +1 -0
- package/dist/src/commands/init.d.ts +8 -0
- package/dist/src/commands/init.d.ts.map +1 -0
- package/dist/src/commands/init.js +532 -0
- package/dist/src/commands/init.js.map +1 -0
- package/dist/src/commands/mcp.d.ts +11 -0
- package/dist/src/commands/mcp.d.ts.map +1 -0
- package/dist/src/commands/mcp.js +662 -0
- package/dist/src/commands/mcp.js.map +1 -0
- package/dist/src/commands/memory.d.ts +8 -0
- package/dist/src/commands/memory.d.ts.map +1 -0
- package/dist/src/commands/memory.js +911 -0
- package/dist/src/commands/memory.js.map +1 -0
- package/dist/src/commands/migrate.d.ts +8 -0
- package/dist/src/commands/migrate.d.ts.map +1 -0
- package/dist/src/commands/migrate.js +398 -0
- package/dist/src/commands/migrate.js.map +1 -0
- package/dist/src/commands/process.d.ts +10 -0
- package/dist/src/commands/process.d.ts.map +1 -0
- package/dist/src/commands/process.js +566 -0
- package/dist/src/commands/process.js.map +1 -0
- package/dist/src/commands/session.d.ts +8 -0
- package/dist/src/commands/session.d.ts.map +1 -0
- package/dist/src/commands/session.js +750 -0
- package/dist/src/commands/session.js.map +1 -0
- package/dist/src/commands/start.d.ts +8 -0
- package/dist/src/commands/start.d.ts.map +1 -0
- package/dist/src/commands/start.js +398 -0
- package/dist/src/commands/start.js.map +1 -0
- package/dist/src/commands/status.d.ts +8 -0
- package/dist/src/commands/status.d.ts.map +1 -0
- package/dist/src/commands/status.js +560 -0
- package/dist/src/commands/status.js.map +1 -0
- package/dist/src/commands/swarm.d.ts +8 -0
- package/dist/src/commands/swarm.d.ts.map +1 -0
- package/dist/src/commands/swarm.js +573 -0
- package/dist/src/commands/swarm.js.map +1 -0
- package/dist/src/commands/task.d.ts +8 -0
- package/dist/src/commands/task.d.ts.map +1 -0
- package/dist/src/commands/task.js +671 -0
- package/dist/src/commands/task.js.map +1 -0
- package/dist/src/commands/workflow.d.ts +8 -0
- package/dist/src/commands/workflow.d.ts.map +1 -0
- package/dist/src/commands/workflow.js +617 -0
- package/dist/src/commands/workflow.js.map +1 -0
- package/dist/src/config-adapter.d.ts +15 -0
- package/dist/src/config-adapter.d.ts.map +1 -0
- package/dist/src/config-adapter.js +185 -0
- package/dist/src/config-adapter.js.map +1 -0
- package/dist/src/index.d.ts +55 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +312 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/infrastructure/in-memory-repositories.d.ts +68 -0
- package/dist/src/infrastructure/in-memory-repositories.d.ts.map +1 -0
- package/dist/src/infrastructure/in-memory-repositories.js +264 -0
- package/dist/src/infrastructure/in-memory-repositories.js.map +1 -0
- package/dist/src/init/claudemd-generator.d.ts +15 -0
- package/dist/src/init/claudemd-generator.d.ts.map +1 -0
- package/dist/src/init/claudemd-generator.js +626 -0
- package/dist/src/init/claudemd-generator.js.map +1 -0
- package/dist/src/init/executor.d.ts +11 -0
- package/dist/src/init/executor.d.ts.map +1 -0
- package/dist/src/init/executor.js +647 -0
- package/dist/src/init/executor.js.map +1 -0
- package/dist/src/init/helpers-generator.d.ts +42 -0
- package/dist/src/init/helpers-generator.d.ts.map +1 -0
- package/dist/src/init/helpers-generator.js +613 -0
- package/dist/src/init/helpers-generator.js.map +1 -0
- package/dist/src/init/index.d.ts +12 -0
- package/dist/src/init/index.d.ts.map +1 -0
- package/dist/src/init/index.js +15 -0
- package/dist/src/init/index.js.map +1 -0
- package/dist/src/init/mcp-generator.d.ts +18 -0
- package/dist/src/init/mcp-generator.d.ts.map +1 -0
- package/dist/src/init/mcp-generator.js +71 -0
- package/dist/src/init/mcp-generator.js.map +1 -0
- package/dist/src/init/settings-generator.d.ts +14 -0
- package/dist/src/init/settings-generator.d.ts.map +1 -0
- package/dist/src/init/settings-generator.js +257 -0
- package/dist/src/init/settings-generator.js.map +1 -0
- package/dist/src/init/statusline-generator.d.ts +14 -0
- package/dist/src/init/statusline-generator.d.ts.map +1 -0
- package/dist/src/init/statusline-generator.js +206 -0
- package/dist/src/init/statusline-generator.js.map +1 -0
- package/dist/src/init/types.d.ts +240 -0
- package/dist/src/init/types.d.ts.map +1 -0
- package/dist/src/init/types.js +210 -0
- package/dist/src/init/types.js.map +1 -0
- package/dist/src/mcp-client.d.ts +92 -0
- package/dist/src/mcp-client.d.ts.map +1 -0
- package/dist/src/mcp-client.js +189 -0
- package/dist/src/mcp-client.js.map +1 -0
- package/dist/src/mcp-server.d.ts +153 -0
- package/dist/src/mcp-server.d.ts.map +1 -0
- package/dist/src/mcp-server.js +448 -0
- package/dist/src/mcp-server.js.map +1 -0
- package/dist/src/mcp-tools/agent-tools.d.ts +8 -0
- package/dist/src/mcp-tools/agent-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/agent-tools.js +90 -0
- package/dist/src/mcp-tools/agent-tools.js.map +1 -0
- package/dist/src/mcp-tools/config-tools.d.ts +8 -0
- package/dist/src/mcp-tools/config-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/config-tools.js +86 -0
- package/dist/src/mcp-tools/config-tools.js.map +1 -0
- package/dist/src/mcp-tools/hooks-tools.d.ts +41 -0
- package/dist/src/mcp-tools/hooks-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/hooks-tools.js +1646 -0
- package/dist/src/mcp-tools/hooks-tools.js.map +1 -0
- package/dist/src/mcp-tools/index.d.ts +12 -0
- package/dist/src/mcp-tools/index.d.ts.map +1 -0
- package/dist/src/mcp-tools/index.js +11 -0
- package/dist/src/mcp-tools/index.js.map +1 -0
- package/dist/src/mcp-tools/memory-tools.d.ts +8 -0
- package/dist/src/mcp-tools/memory-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/memory-tools.js +87 -0
- package/dist/src/mcp-tools/memory-tools.js.map +1 -0
- package/dist/src/mcp-tools/swarm-tools.d.ts +8 -0
- package/dist/src/mcp-tools/swarm-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/swarm-tools.js +67 -0
- package/dist/src/mcp-tools/swarm-tools.js.map +1 -0
- package/dist/src/mcp-tools/types.d.ts +31 -0
- package/dist/src/mcp-tools/types.d.ts.map +1 -0
- package/dist/src/mcp-tools/types.js +7 -0
- package/dist/src/mcp-tools/types.js.map +1 -0
- package/dist/src/output.d.ts +117 -0
- package/dist/src/output.d.ts.map +1 -0
- package/dist/src/output.js +471 -0
- package/dist/src/output.js.map +1 -0
- package/dist/src/parser.d.ts +41 -0
- package/dist/src/parser.d.ts.map +1 -0
- package/dist/src/parser.js +353 -0
- package/dist/src/parser.js.map +1 -0
- package/dist/src/prompt.d.ts +44 -0
- package/dist/src/prompt.d.ts.map +1 -0
- package/dist/src/prompt.js +501 -0
- package/dist/src/prompt.js.map +1 -0
- package/dist/src/types.d.ts +198 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +38 -0
- package/dist/src/types.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/docs/CONFIG_LOADING.md +236 -0
- package/docs/IMPLEMENTATION_COMPLETE.md +421 -0
- package/docs/MCP_CLIENT_GUIDE.md +620 -0
- package/docs/REFACTORING_SUMMARY.md +247 -0
- package/package.json +29 -0
- package/src/commands/agent.ts +941 -0
- package/src/commands/config.ts +452 -0
- package/src/commands/hive-mind.ts +762 -0
- package/src/commands/hooks.ts +2603 -0
- package/src/commands/index.ts +115 -0
- package/src/commands/init.ts +597 -0
- package/src/commands/mcp.ts +753 -0
- package/src/commands/memory.ts +1063 -0
- package/src/commands/migrate.ts +447 -0
- package/src/commands/process.ts +617 -0
- package/src/commands/session.ts +891 -0
- package/src/commands/start.ts +457 -0
- package/src/commands/status.ts +705 -0
- package/src/commands/swarm.ts +648 -0
- package/src/commands/task.ts +792 -0
- package/src/commands/workflow.ts +742 -0
- package/src/config-adapter.ts +210 -0
- package/src/index.ts +383 -0
- package/src/infrastructure/in-memory-repositories.ts +310 -0
- package/src/init/claudemd-generator.ts +631 -0
- package/src/init/executor.ts +756 -0
- package/src/init/helpers-generator.ts +628 -0
- package/src/init/index.ts +60 -0
- package/src/init/mcp-generator.ts +83 -0
- package/src/init/settings-generator.ts +274 -0
- package/src/init/statusline-generator.ts +211 -0
- package/src/init/types.ts +447 -0
- package/src/mcp-client.ts +227 -0
- package/src/mcp-server.ts +571 -0
- package/src/mcp-tools/agent-tools.ts +92 -0
- package/src/mcp-tools/config-tools.ts +88 -0
- package/src/mcp-tools/hooks-tools.ts +1819 -0
- package/src/mcp-tools/index.ts +12 -0
- package/src/mcp-tools/memory-tools.ts +89 -0
- package/src/mcp-tools/swarm-tools.ts +69 -0
- package/src/mcp-tools/types.ts +33 -0
- package/src/output.ts +593 -0
- package/src/parser.ts +417 -0
- package/src/prompt.ts +619 -0
- package/src/types.ts +287 -0
- package/tsconfig.json +16 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/vitest.config.ts +13 -0
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Config Adapter Tests
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { describe, it, expect } from 'vitest';
|
|
6
|
+
import { systemConfigToV3Config, v3ConfigToSystemConfig } from '../src/config-adapter.js';
|
|
7
|
+
import type { SystemConfig } from '@claude-flow/shared';
|
|
8
|
+
import type { V3Config } from '../src/types.js';
|
|
9
|
+
|
|
10
|
+
describe('ConfigAdapter', () => {
|
|
11
|
+
describe('systemConfigToV3Config', () => {
|
|
12
|
+
it('should convert minimal SystemConfig to V3Config', () => {
|
|
13
|
+
const systemConfig: SystemConfig = {
|
|
14
|
+
orchestrator: {
|
|
15
|
+
lifecycle: {
|
|
16
|
+
autoStart: true,
|
|
17
|
+
maxConcurrentAgents: 10,
|
|
18
|
+
shutdownTimeoutMs: 30000,
|
|
19
|
+
cleanupOrphanedAgents: true,
|
|
20
|
+
},
|
|
21
|
+
session: {
|
|
22
|
+
dataDir: '/test/data',
|
|
23
|
+
persistState: true,
|
|
24
|
+
stateFile: 'session.json',
|
|
25
|
+
},
|
|
26
|
+
monitoring: {
|
|
27
|
+
enabled: true,
|
|
28
|
+
metricsIntervalMs: 5000,
|
|
29
|
+
healthCheckIntervalMs: 10000,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
swarm: {
|
|
33
|
+
topology: 'hierarchical-mesh',
|
|
34
|
+
maxAgents: 15,
|
|
35
|
+
},
|
|
36
|
+
memory: {
|
|
37
|
+
type: 'hybrid',
|
|
38
|
+
},
|
|
39
|
+
mcp: {
|
|
40
|
+
enabled: true,
|
|
41
|
+
transport: {
|
|
42
|
+
type: 'stdio',
|
|
43
|
+
host: 'localhost',
|
|
44
|
+
port: 3000,
|
|
45
|
+
},
|
|
46
|
+
enabledTools: ['agent/*', 'swarm/*'],
|
|
47
|
+
security: {
|
|
48
|
+
requireAuth: false,
|
|
49
|
+
allowedOrigins: ['*'],
|
|
50
|
+
rateLimiting: {
|
|
51
|
+
enabled: true,
|
|
52
|
+
maxRequestsPerMinute: 100,
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
logging: {
|
|
57
|
+
level: 'info',
|
|
58
|
+
pretty: true,
|
|
59
|
+
destination: 'console',
|
|
60
|
+
format: 'text',
|
|
61
|
+
},
|
|
62
|
+
hooks: {
|
|
63
|
+
enabled: true,
|
|
64
|
+
autoExecute: true,
|
|
65
|
+
definitions: [],
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const v3Config = systemConfigToV3Config(systemConfig);
|
|
70
|
+
|
|
71
|
+
expect(v3Config.version).toBe('3.0.0');
|
|
72
|
+
expect(v3Config.projectRoot).toBe('/test/data');
|
|
73
|
+
expect(v3Config.agents.maxConcurrent).toBe(10);
|
|
74
|
+
expect(v3Config.agents.autoSpawn).toBe(false); // Default is false for safety
|
|
75
|
+
expect(v3Config.swarm.topology).toBe('hybrid'); // 'hierarchical-mesh' normalizes to 'hybrid'
|
|
76
|
+
expect(v3Config.swarm.maxAgents).toBe(15);
|
|
77
|
+
expect(v3Config.memory.backend).toBe('hybrid');
|
|
78
|
+
expect(v3Config.mcp.serverHost).toBe('localhost');
|
|
79
|
+
expect(v3Config.mcp.serverPort).toBe(3000);
|
|
80
|
+
expect(v3Config.mcp.autoStart).toBe(false); // Default is false for safety
|
|
81
|
+
expect(v3Config.cli.colorOutput).toBe(true);
|
|
82
|
+
expect(v3Config.cli.verbosity).toBe('normal'); // Default verbosity level
|
|
83
|
+
expect(v3Config.hooks.enabled).toBe(false); // Default is false
|
|
84
|
+
expect(v3Config.hooks.autoExecute).toBe(false); // Default is false
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('should handle missing optional fields', () => {
|
|
88
|
+
const minimalConfig: SystemConfig = {
|
|
89
|
+
orchestrator: {
|
|
90
|
+
lifecycle: {
|
|
91
|
+
autoStart: false,
|
|
92
|
+
maxConcurrentAgents: 5,
|
|
93
|
+
shutdownTimeoutMs: 30000,
|
|
94
|
+
cleanupOrphanedAgents: true,
|
|
95
|
+
},
|
|
96
|
+
session: {
|
|
97
|
+
dataDir: '/data',
|
|
98
|
+
persistState: true,
|
|
99
|
+
stateFile: 'session.json',
|
|
100
|
+
},
|
|
101
|
+
monitoring: {
|
|
102
|
+
enabled: true,
|
|
103
|
+
metricsIntervalMs: 5000,
|
|
104
|
+
healthCheckIntervalMs: 10000,
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
swarm: {
|
|
108
|
+
topology: 'mesh',
|
|
109
|
+
maxAgents: 10,
|
|
110
|
+
},
|
|
111
|
+
memory: {
|
|
112
|
+
type: 'sqlite',
|
|
113
|
+
},
|
|
114
|
+
mcp: {
|
|
115
|
+
enabled: false,
|
|
116
|
+
transport: {
|
|
117
|
+
type: 'http',
|
|
118
|
+
host: '127.0.0.1',
|
|
119
|
+
port: 8080,
|
|
120
|
+
},
|
|
121
|
+
enabledTools: [],
|
|
122
|
+
security: {
|
|
123
|
+
requireAuth: false,
|
|
124
|
+
allowedOrigins: ['*'],
|
|
125
|
+
rateLimiting: {
|
|
126
|
+
enabled: true,
|
|
127
|
+
maxRequestsPerMinute: 100,
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
logging: {
|
|
132
|
+
level: 'debug',
|
|
133
|
+
pretty: false,
|
|
134
|
+
destination: 'file',
|
|
135
|
+
format: 'json',
|
|
136
|
+
},
|
|
137
|
+
hooks: {
|
|
138
|
+
enabled: false,
|
|
139
|
+
autoExecute: false,
|
|
140
|
+
definitions: [],
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
const v3Config = systemConfigToV3Config(minimalConfig);
|
|
145
|
+
|
|
146
|
+
expect(v3Config.agents.maxConcurrent).toBe(5);
|
|
147
|
+
expect(v3Config.agents.autoSpawn).toBe(false);
|
|
148
|
+
expect(v3Config.memory.backend).toBe('sqlite');
|
|
149
|
+
expect(v3Config.mcp.autoStart).toBe(false);
|
|
150
|
+
expect(v3Config.cli.colorOutput).toBe(true); // Default is always true
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
describe('v3ConfigToSystemConfig', () => {
|
|
155
|
+
it('should convert V3Config to SystemConfig', () => {
|
|
156
|
+
const v3Config: V3Config = {
|
|
157
|
+
version: '3.0.0',
|
|
158
|
+
projectRoot: '/test/project',
|
|
159
|
+
agents: {
|
|
160
|
+
defaultType: 'coder',
|
|
161
|
+
autoSpawn: true,
|
|
162
|
+
maxConcurrent: 20,
|
|
163
|
+
timeout: 60000,
|
|
164
|
+
providers: [],
|
|
165
|
+
},
|
|
166
|
+
swarm: {
|
|
167
|
+
topology: 'hierarchical',
|
|
168
|
+
maxAgents: 20,
|
|
169
|
+
autoScale: true,
|
|
170
|
+
coordinationStrategy: 'consensus',
|
|
171
|
+
healthCheckInterval: 15000,
|
|
172
|
+
},
|
|
173
|
+
memory: {
|
|
174
|
+
backend: 'agentdb',
|
|
175
|
+
persistPath: '/test/memory',
|
|
176
|
+
cacheSize: 500000,
|
|
177
|
+
enableHNSW: true,
|
|
178
|
+
vectorDimension: 768,
|
|
179
|
+
},
|
|
180
|
+
mcp: {
|
|
181
|
+
serverHost: '0.0.0.0',
|
|
182
|
+
serverPort: 4000,
|
|
183
|
+
autoStart: true,
|
|
184
|
+
transportType: 'websocket',
|
|
185
|
+
tools: ['memory/*'],
|
|
186
|
+
},
|
|
187
|
+
cli: {
|
|
188
|
+
colorOutput: true,
|
|
189
|
+
interactive: true,
|
|
190
|
+
verbosity: 'verbose',
|
|
191
|
+
outputFormat: 'json',
|
|
192
|
+
progressStyle: 'bar',
|
|
193
|
+
},
|
|
194
|
+
hooks: {
|
|
195
|
+
enabled: true,
|
|
196
|
+
autoExecute: false,
|
|
197
|
+
hooks: [
|
|
198
|
+
{
|
|
199
|
+
name: 'test-hook',
|
|
200
|
+
event: 'pre-task',
|
|
201
|
+
handler: '/path/to/handler.js',
|
|
202
|
+
priority: 10,
|
|
203
|
+
enabled: true,
|
|
204
|
+
},
|
|
205
|
+
],
|
|
206
|
+
},
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
const systemConfig = v3ConfigToSystemConfig(v3Config);
|
|
210
|
+
|
|
211
|
+
// Core orchestrator conversion (autoStart not mapped)
|
|
212
|
+
expect(systemConfig.orchestrator?.lifecycle?.maxConcurrentAgents).toBe(20);
|
|
213
|
+
expect(systemConfig.orchestrator?.session?.dataDir).toBe('/test/project');
|
|
214
|
+
expect(systemConfig.swarm?.topology).toBe('hierarchical');
|
|
215
|
+
expect(systemConfig.swarm?.maxAgents).toBe(20);
|
|
216
|
+
expect(systemConfig.swarm?.autoScale?.enabled).toBe(true);
|
|
217
|
+
expect(systemConfig.swarm?.coordination?.consensusRequired).toBe(true);
|
|
218
|
+
expect(systemConfig.memory?.type).toBe('agentdb');
|
|
219
|
+
expect(systemConfig.memory?.path).toBe('/test/memory');
|
|
220
|
+
expect(systemConfig.memory?.agentdb?.dimensions).toBe(768);
|
|
221
|
+
expect(systemConfig.memory?.agentdb?.indexType).toBe('hnsw');
|
|
222
|
+
// MCP enabled not mapped, just transport
|
|
223
|
+
expect(systemConfig.mcp?.transport?.type).toBe('websocket');
|
|
224
|
+
expect(systemConfig.mcp?.transport?.host).toBe('0.0.0.0');
|
|
225
|
+
expect(systemConfig.mcp?.transport?.port).toBe(4000);
|
|
226
|
+
// logging and hooks not included in v3ConfigToSystemConfig conversion
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
it('should handle different coordination strategies', () => {
|
|
230
|
+
const leaderConfig: V3Config = {
|
|
231
|
+
version: '3.0.0',
|
|
232
|
+
projectRoot: '/test',
|
|
233
|
+
agents: {
|
|
234
|
+
defaultType: 'coder',
|
|
235
|
+
autoSpawn: false,
|
|
236
|
+
maxConcurrent: 10,
|
|
237
|
+
timeout: 30000,
|
|
238
|
+
providers: [],
|
|
239
|
+
},
|
|
240
|
+
swarm: {
|
|
241
|
+
topology: 'star',
|
|
242
|
+
maxAgents: 10,
|
|
243
|
+
autoScale: false,
|
|
244
|
+
coordinationStrategy: 'leader',
|
|
245
|
+
healthCheckInterval: 5000,
|
|
246
|
+
},
|
|
247
|
+
memory: {
|
|
248
|
+
backend: 'memory',
|
|
249
|
+
persistPath: '/data',
|
|
250
|
+
cacheSize: 100000,
|
|
251
|
+
enableHNSW: false,
|
|
252
|
+
vectorDimension: 1536,
|
|
253
|
+
},
|
|
254
|
+
mcp: {
|
|
255
|
+
serverHost: 'localhost',
|
|
256
|
+
serverPort: 3000,
|
|
257
|
+
autoStart: false,
|
|
258
|
+
transportType: 'stdio',
|
|
259
|
+
tools: [],
|
|
260
|
+
},
|
|
261
|
+
cli: {
|
|
262
|
+
colorOutput: true,
|
|
263
|
+
interactive: true,
|
|
264
|
+
verbosity: 'normal',
|
|
265
|
+
outputFormat: 'text',
|
|
266
|
+
progressStyle: 'spinner',
|
|
267
|
+
},
|
|
268
|
+
hooks: {
|
|
269
|
+
enabled: false,
|
|
270
|
+
autoExecute: false,
|
|
271
|
+
hooks: [],
|
|
272
|
+
},
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
const systemConfig = v3ConfigToSystemConfig(leaderConfig);
|
|
276
|
+
|
|
277
|
+
expect(systemConfig.swarm?.coordination?.consensusRequired).toBe(false);
|
|
278
|
+
expect(systemConfig.memory?.agentdb?.indexType).toBe('flat');
|
|
279
|
+
});
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
describe('round-trip conversion', () => {
|
|
283
|
+
it('should preserve key config values through round-trip', () => {
|
|
284
|
+
const originalSystemConfig: SystemConfig = {
|
|
285
|
+
orchestrator: {
|
|
286
|
+
lifecycle: {
|
|
287
|
+
autoStart: true,
|
|
288
|
+
maxConcurrentAgents: 12,
|
|
289
|
+
shutdownTimeoutMs: 30000,
|
|
290
|
+
cleanupOrphanedAgents: true,
|
|
291
|
+
},
|
|
292
|
+
session: {
|
|
293
|
+
dataDir: '/test/roundtrip',
|
|
294
|
+
persistState: true,
|
|
295
|
+
stateFile: 'session.json',
|
|
296
|
+
},
|
|
297
|
+
monitoring: {
|
|
298
|
+
enabled: true,
|
|
299
|
+
metricsIntervalMs: 5000,
|
|
300
|
+
healthCheckIntervalMs: 8000,
|
|
301
|
+
},
|
|
302
|
+
},
|
|
303
|
+
swarm: {
|
|
304
|
+
topology: 'hierarchical-mesh',
|
|
305
|
+
maxAgents: 12,
|
|
306
|
+
},
|
|
307
|
+
memory: {
|
|
308
|
+
type: 'hybrid',
|
|
309
|
+
path: '/test/memory',
|
|
310
|
+
agentdb: {
|
|
311
|
+
dimensions: 1536,
|
|
312
|
+
indexType: 'hnsw',
|
|
313
|
+
efConstruction: 200,
|
|
314
|
+
m: 16,
|
|
315
|
+
quantization: 'none',
|
|
316
|
+
},
|
|
317
|
+
},
|
|
318
|
+
mcp: {
|
|
319
|
+
enabled: true,
|
|
320
|
+
transport: {
|
|
321
|
+
type: 'http',
|
|
322
|
+
host: '127.0.0.1',
|
|
323
|
+
port: 5000,
|
|
324
|
+
},
|
|
325
|
+
enabledTools: ['test/*'],
|
|
326
|
+
security: {
|
|
327
|
+
requireAuth: false,
|
|
328
|
+
allowedOrigins: ['*'],
|
|
329
|
+
rateLimiting: {
|
|
330
|
+
enabled: true,
|
|
331
|
+
maxRequestsPerMinute: 100,
|
|
332
|
+
},
|
|
333
|
+
},
|
|
334
|
+
},
|
|
335
|
+
logging: {
|
|
336
|
+
level: 'warn',
|
|
337
|
+
pretty: true,
|
|
338
|
+
destination: 'console',
|
|
339
|
+
format: 'text',
|
|
340
|
+
},
|
|
341
|
+
hooks: {
|
|
342
|
+
enabled: true,
|
|
343
|
+
autoExecute: true,
|
|
344
|
+
definitions: [],
|
|
345
|
+
},
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
const v3Config = systemConfigToV3Config(originalSystemConfig);
|
|
349
|
+
const roundTripConfig = v3ConfigToSystemConfig(v3Config);
|
|
350
|
+
|
|
351
|
+
// Core values preserved through round-trip
|
|
352
|
+
expect(roundTripConfig.orchestrator?.lifecycle?.maxConcurrentAgents).toBe(12);
|
|
353
|
+
expect(roundTripConfig.swarm?.topology).toBe('hierarchical-mesh');
|
|
354
|
+
expect(roundTripConfig.swarm?.maxAgents).toBe(12);
|
|
355
|
+
expect(roundTripConfig.memory?.type).toBe('hybrid');
|
|
356
|
+
expect(roundTripConfig.memory?.path).toBe('/test/memory');
|
|
357
|
+
expect(roundTripConfig.mcp?.transport?.type).toBe('http');
|
|
358
|
+
expect(roundTripConfig.mcp?.transport?.port).toBe(5000);
|
|
359
|
+
// Note: logging is not included in v3ConfigToSystemConfig
|
|
360
|
+
});
|
|
361
|
+
});
|
|
362
|
+
});
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Config Loading Integration Tests
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
6
|
+
import { mkdtemp, rm, writeFile } from 'fs/promises';
|
|
7
|
+
import { join } from 'path';
|
|
8
|
+
import { tmpdir } from 'os';
|
|
9
|
+
import { CLI } from '../src/index.js';
|
|
10
|
+
|
|
11
|
+
describe('Config Loading', () => {
|
|
12
|
+
let tempDir: string;
|
|
13
|
+
|
|
14
|
+
beforeEach(async () => {
|
|
15
|
+
tempDir = await mkdtemp(join(tmpdir(), 'cli-config-test-'));
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
afterEach(async () => {
|
|
19
|
+
await rm(tempDir, { recursive: true, force: true });
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('should load config from file when specified', async () => {
|
|
23
|
+
const configPath = join(tempDir, 'claude-flow.config.json');
|
|
24
|
+
const config = {
|
|
25
|
+
orchestrator: {
|
|
26
|
+
lifecycle: {
|
|
27
|
+
autoStart: true,
|
|
28
|
+
maxConcurrentAgents: 10,
|
|
29
|
+
shutdownTimeoutMs: 30000,
|
|
30
|
+
cleanupOrphanedAgents: true,
|
|
31
|
+
},
|
|
32
|
+
session: {
|
|
33
|
+
dataDir: tempDir,
|
|
34
|
+
persistState: true,
|
|
35
|
+
stateFile: 'session.json',
|
|
36
|
+
},
|
|
37
|
+
monitoring: {
|
|
38
|
+
enabled: true,
|
|
39
|
+
metricsIntervalMs: 5000,
|
|
40
|
+
healthCheckIntervalMs: 10000,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
swarm: {
|
|
44
|
+
topology: 'hierarchical-mesh',
|
|
45
|
+
maxAgents: 15,
|
|
46
|
+
},
|
|
47
|
+
memory: {
|
|
48
|
+
type: 'hybrid',
|
|
49
|
+
},
|
|
50
|
+
mcp: {
|
|
51
|
+
enabled: true,
|
|
52
|
+
transport: {
|
|
53
|
+
type: 'stdio',
|
|
54
|
+
host: 'localhost',
|
|
55
|
+
port: 3000,
|
|
56
|
+
},
|
|
57
|
+
enabledTools: [],
|
|
58
|
+
security: {
|
|
59
|
+
requireAuth: false,
|
|
60
|
+
allowedOrigins: ['*'],
|
|
61
|
+
rateLimiting: {
|
|
62
|
+
enabled: true,
|
|
63
|
+
maxRequestsPerMinute: 100,
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
logging: {
|
|
68
|
+
level: 'info',
|
|
69
|
+
pretty: true,
|
|
70
|
+
destination: 'console',
|
|
71
|
+
format: 'text',
|
|
72
|
+
},
|
|
73
|
+
hooks: {
|
|
74
|
+
enabled: true,
|
|
75
|
+
autoExecute: false,
|
|
76
|
+
definitions: [],
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
await writeFile(configPath, JSON.stringify(config, null, 2));
|
|
81
|
+
|
|
82
|
+
// Create CLI instance and verify config loading works
|
|
83
|
+
const cli = new CLI();
|
|
84
|
+
|
|
85
|
+
// The config loading is tested indirectly through the CLI's run method
|
|
86
|
+
// but we've already tested the adapter functions in config-adapter.test.ts
|
|
87
|
+
expect(cli).toBeDefined();
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('should handle missing config file gracefully', async () => {
|
|
91
|
+
const cli = new CLI();
|
|
92
|
+
|
|
93
|
+
// Should not throw when config file doesn't exist
|
|
94
|
+
expect(cli).toBeDefined();
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('should handle invalid config file gracefully', async () => {
|
|
98
|
+
const configPath = join(tempDir, 'claude-flow.config.json');
|
|
99
|
+
await writeFile(configPath, '{ invalid json }');
|
|
100
|
+
|
|
101
|
+
const cli = new CLI();
|
|
102
|
+
|
|
103
|
+
// Should not throw when config file is invalid
|
|
104
|
+
expect(cli).toBeDefined();
|
|
105
|
+
});
|
|
106
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"result":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"result":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"result":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"result":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"result":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"result":[]}
|