@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
|
@@ -1,726 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* V3 CLI Commands Tests
|
|
3
|
-
* Tests for agent, swarm, memory, and config commands
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { describe, it, expect, beforeEach, vi, afterEach } from 'vitest';
|
|
7
|
-
import { agentCommand } from '../src/commands/agent.js';
|
|
8
|
-
import { swarmCommand } from '../src/commands/swarm.js';
|
|
9
|
-
import { memoryCommand } from '../src/commands/memory.js';
|
|
10
|
-
import { configCommand } from '../src/commands/config.js';
|
|
11
|
-
import type { CommandContext } from '../src/types.js';
|
|
12
|
-
|
|
13
|
-
// Mock MCP client
|
|
14
|
-
vi.mock('../src/mcp-client.js', () => ({
|
|
15
|
-
callMCPTool: vi.fn(async (toolName: string, input: Record<string, unknown>) => {
|
|
16
|
-
// Mock responses for different tools
|
|
17
|
-
if (toolName === 'agent/spawn') {
|
|
18
|
-
return {
|
|
19
|
-
agentId: input.id || 'mock-agent-123',
|
|
20
|
-
agentType: input.agentType,
|
|
21
|
-
status: 'active',
|
|
22
|
-
createdAt: new Date().toISOString()
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (toolName === 'agent/list') {
|
|
27
|
-
return {
|
|
28
|
-
agents: [
|
|
29
|
-
{ id: 'agent-1', agentType: 'coder', status: 'active', createdAt: '2024-01-01T00:00:00Z' },
|
|
30
|
-
{ id: 'agent-2', agentType: 'tester', status: 'idle', createdAt: '2024-01-01T00:01:00Z' }
|
|
31
|
-
],
|
|
32
|
-
total: 2
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (toolName === 'agent/status') {
|
|
37
|
-
return {
|
|
38
|
-
id: input.agentId,
|
|
39
|
-
agentType: 'coder',
|
|
40
|
-
status: 'active',
|
|
41
|
-
createdAt: '2024-01-01T00:00:00Z',
|
|
42
|
-
lastActivityAt: new Date().toISOString(),
|
|
43
|
-
metrics: {
|
|
44
|
-
tasksCompleted: 10,
|
|
45
|
-
tasksInProgress: 2,
|
|
46
|
-
tasksFailed: 1,
|
|
47
|
-
averageExecutionTime: 1500,
|
|
48
|
-
uptime: 3600000
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (toolName === 'agent/terminate') {
|
|
54
|
-
return {
|
|
55
|
-
agentId: input.agentId,
|
|
56
|
-
terminated: true,
|
|
57
|
-
terminatedAt: new Date().toISOString()
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (toolName === 'swarm/init') {
|
|
62
|
-
return {
|
|
63
|
-
swarmId: 'swarm-mock-123',
|
|
64
|
-
topology: input.topology,
|
|
65
|
-
initializedAt: new Date().toISOString(),
|
|
66
|
-
config: {
|
|
67
|
-
topology: input.topology,
|
|
68
|
-
maxAgents: input.maxAgents || 15,
|
|
69
|
-
currentAgents: 0,
|
|
70
|
-
autoScaling: true
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return {};
|
|
76
|
-
}),
|
|
77
|
-
MCPClientError: class MCPClientError extends Error {
|
|
78
|
-
constructor(message: string, public toolName: string, public cause?: Error) {
|
|
79
|
-
super(message);
|
|
80
|
-
this.name = 'MCPClientError';
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}));
|
|
84
|
-
|
|
85
|
-
// Mock output
|
|
86
|
-
vi.mock('../src/output.js', () => ({
|
|
87
|
-
output: {
|
|
88
|
-
writeln: vi.fn(),
|
|
89
|
-
printInfo: vi.fn(),
|
|
90
|
-
printSuccess: vi.fn(),
|
|
91
|
-
printError: vi.fn(),
|
|
92
|
-
printWarning: vi.fn(),
|
|
93
|
-
printTable: vi.fn(),
|
|
94
|
-
printJson: vi.fn(),
|
|
95
|
-
printList: vi.fn(),
|
|
96
|
-
printBox: vi.fn(),
|
|
97
|
-
createSpinner: vi.fn(() => ({
|
|
98
|
-
start: vi.fn(),
|
|
99
|
-
succeed: vi.fn(),
|
|
100
|
-
fail: vi.fn(),
|
|
101
|
-
stop: vi.fn()
|
|
102
|
-
})),
|
|
103
|
-
highlight: (str: string) => str,
|
|
104
|
-
bold: (str: string) => str,
|
|
105
|
-
dim: (str: string) => str,
|
|
106
|
-
success: (str: string) => str,
|
|
107
|
-
error: (str: string) => str,
|
|
108
|
-
warning: (str: string) => str,
|
|
109
|
-
info: (str: string) => str,
|
|
110
|
-
progressBar: () => '[=====> ]',
|
|
111
|
-
setColorEnabled: vi.fn()
|
|
112
|
-
}
|
|
113
|
-
}));
|
|
114
|
-
|
|
115
|
-
// Mock prompts (always return default values for non-interactive tests)
|
|
116
|
-
vi.mock('../src/prompt.js', () => ({
|
|
117
|
-
select: vi.fn(async (opts) => opts.default || opts.options[0]?.value),
|
|
118
|
-
confirm: vi.fn(async (opts) => opts.default ?? false),
|
|
119
|
-
input: vi.fn(async (opts) => opts.default || 'test-input'),
|
|
120
|
-
multiSelect: vi.fn(async (opts) => opts.default || [])
|
|
121
|
-
}));
|
|
122
|
-
|
|
123
|
-
describe('Agent Commands', () => {
|
|
124
|
-
let ctx: CommandContext;
|
|
125
|
-
|
|
126
|
-
beforeEach(() => {
|
|
127
|
-
ctx = {
|
|
128
|
-
args: [],
|
|
129
|
-
flags: { _: [] },
|
|
130
|
-
cwd: '/test',
|
|
131
|
-
interactive: false
|
|
132
|
-
};
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
describe('agent spawn', () => {
|
|
136
|
-
it('should spawn agent with type flag', async () => {
|
|
137
|
-
const spawnCmd = agentCommand.subcommands?.find(c => c.name === 'spawn');
|
|
138
|
-
expect(spawnCmd).toBeDefined();
|
|
139
|
-
|
|
140
|
-
ctx.flags = { type: 'coder', _: [] };
|
|
141
|
-
const result = await spawnCmd!.action!(ctx);
|
|
142
|
-
|
|
143
|
-
expect(result.success).toBe(true);
|
|
144
|
-
expect(result.data).toHaveProperty('agentId');
|
|
145
|
-
expect(result.data).toHaveProperty('agentType', 'coder');
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
it('should spawn agent with custom name', async () => {
|
|
149
|
-
const spawnCmd = agentCommand.subcommands?.find(c => c.name === 'spawn');
|
|
150
|
-
|
|
151
|
-
ctx.flags = { type: 'tester', name: 'my-tester', _: [] };
|
|
152
|
-
const result = await spawnCmd!.action!(ctx);
|
|
153
|
-
|
|
154
|
-
expect(result.success).toBe(true);
|
|
155
|
-
expect(result.data).toHaveProperty('agentId', 'my-tester');
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
it('should fail without agent type in non-interactive mode', async () => {
|
|
159
|
-
const spawnCmd = agentCommand.subcommands?.find(c => c.name === 'spawn');
|
|
160
|
-
|
|
161
|
-
ctx.flags = { _: [] };
|
|
162
|
-
const result = await spawnCmd!.action!(ctx);
|
|
163
|
-
|
|
164
|
-
expect(result.success).toBe(false);
|
|
165
|
-
expect(result.exitCode).toBe(1);
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
it('should pass provider and model options', async () => {
|
|
169
|
-
const spawnCmd = agentCommand.subcommands?.find(c => c.name === 'spawn');
|
|
170
|
-
|
|
171
|
-
ctx.flags = {
|
|
172
|
-
type: 'coder',
|
|
173
|
-
provider: 'anthropic',
|
|
174
|
-
model: 'claude-3-5-sonnet',
|
|
175
|
-
_: []
|
|
176
|
-
};
|
|
177
|
-
const result = await spawnCmd!.action!(ctx);
|
|
178
|
-
|
|
179
|
-
expect(result.success).toBe(true);
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
it('should handle task option', async () => {
|
|
183
|
-
const spawnCmd = agentCommand.subcommands?.find(c => c.name === 'spawn');
|
|
184
|
-
|
|
185
|
-
ctx.flags = {
|
|
186
|
-
type: 'researcher',
|
|
187
|
-
task: 'Research React patterns',
|
|
188
|
-
_: []
|
|
189
|
-
};
|
|
190
|
-
const result = await spawnCmd!.action!(ctx);
|
|
191
|
-
|
|
192
|
-
expect(result.success).toBe(true);
|
|
193
|
-
});
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
describe('agent list', () => {
|
|
197
|
-
it('should list all agents', async () => {
|
|
198
|
-
const listCmd = agentCommand.subcommands?.find(c => c.name === 'list');
|
|
199
|
-
expect(listCmd).toBeDefined();
|
|
200
|
-
|
|
201
|
-
const result = await listCmd!.action!(ctx);
|
|
202
|
-
|
|
203
|
-
expect(result.success).toBe(true);
|
|
204
|
-
expect(result.data).toHaveProperty('agents');
|
|
205
|
-
expect(result.data).toHaveProperty('total', 2);
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
it('should filter by agent type', async () => {
|
|
209
|
-
const listCmd = agentCommand.subcommands?.find(c => c.name === 'list');
|
|
210
|
-
|
|
211
|
-
ctx.flags = { type: 'coder', _: [] };
|
|
212
|
-
const result = await listCmd!.action!(ctx);
|
|
213
|
-
|
|
214
|
-
expect(result.success).toBe(true);
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
it('should filter by status', async () => {
|
|
218
|
-
const listCmd = agentCommand.subcommands?.find(c => c.name === 'list');
|
|
219
|
-
|
|
220
|
-
ctx.flags = { status: 'active', _: [] };
|
|
221
|
-
const result = await listCmd!.action!(ctx);
|
|
222
|
-
|
|
223
|
-
expect(result.success).toBe(true);
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
it('should include inactive agents with --all flag', async () => {
|
|
227
|
-
const listCmd = agentCommand.subcommands?.find(c => c.name === 'list');
|
|
228
|
-
|
|
229
|
-
ctx.flags = { all: true, _: [] };
|
|
230
|
-
const result = await listCmd!.action!(ctx);
|
|
231
|
-
|
|
232
|
-
expect(result.success).toBe(true);
|
|
233
|
-
});
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
describe('agent status', () => {
|
|
237
|
-
it('should show agent status', async () => {
|
|
238
|
-
const statusCmd = agentCommand.subcommands?.find(c => c.name === 'status');
|
|
239
|
-
expect(statusCmd).toBeDefined();
|
|
240
|
-
|
|
241
|
-
ctx.args = ['agent-123'];
|
|
242
|
-
const result = await statusCmd!.action!(ctx);
|
|
243
|
-
|
|
244
|
-
expect(result.success).toBe(true);
|
|
245
|
-
expect(result.data).toHaveProperty('id');
|
|
246
|
-
expect(result.data).toHaveProperty('status');
|
|
247
|
-
expect(result.data).toHaveProperty('metrics');
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
it('should fail without agent ID', async () => {
|
|
251
|
-
const statusCmd = agentCommand.subcommands?.find(c => c.name === 'status');
|
|
252
|
-
|
|
253
|
-
ctx.args = [];
|
|
254
|
-
ctx.interactive = false;
|
|
255
|
-
const result = await statusCmd!.action!(ctx);
|
|
256
|
-
|
|
257
|
-
expect(result.success).toBe(false);
|
|
258
|
-
expect(result.exitCode).toBe(1);
|
|
259
|
-
});
|
|
260
|
-
});
|
|
261
|
-
|
|
262
|
-
describe('agent stop', () => {
|
|
263
|
-
it('should stop agent', async () => {
|
|
264
|
-
const stopCmd = agentCommand.subcommands?.find(c => c.name === 'stop');
|
|
265
|
-
expect(stopCmd).toBeDefined();
|
|
266
|
-
|
|
267
|
-
ctx.args = ['agent-123'];
|
|
268
|
-
ctx.flags = { force: true, _: [] };
|
|
269
|
-
const result = await stopCmd!.action!(ctx);
|
|
270
|
-
|
|
271
|
-
expect(result.success).toBe(true);
|
|
272
|
-
expect(result.data).toHaveProperty('agentId', 'agent-123');
|
|
273
|
-
expect(result.data).toHaveProperty('terminated', true);
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
it('should fail without agent ID', async () => {
|
|
277
|
-
const stopCmd = agentCommand.subcommands?.find(c => c.name === 'stop');
|
|
278
|
-
|
|
279
|
-
ctx.args = [];
|
|
280
|
-
const result = await stopCmd!.action!(ctx);
|
|
281
|
-
|
|
282
|
-
expect(result.success).toBe(false);
|
|
283
|
-
});
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
describe('agent metrics', () => {
|
|
287
|
-
it('should show agent metrics', async () => {
|
|
288
|
-
const metricsCmd = agentCommand.subcommands?.find(c => c.name === 'metrics');
|
|
289
|
-
expect(metricsCmd).toBeDefined();
|
|
290
|
-
|
|
291
|
-
const result = await metricsCmd!.action!(ctx);
|
|
292
|
-
|
|
293
|
-
expect(result.success).toBe(true);
|
|
294
|
-
expect(result.data).toHaveProperty('summary');
|
|
295
|
-
expect(result.data).toHaveProperty('performance');
|
|
296
|
-
});
|
|
297
|
-
|
|
298
|
-
it('should accept period option', async () => {
|
|
299
|
-
const metricsCmd = agentCommand.subcommands?.find(c => c.name === 'metrics');
|
|
300
|
-
|
|
301
|
-
ctx.flags = { period: '7d', _: [] };
|
|
302
|
-
const result = await metricsCmd!.action!(ctx);
|
|
303
|
-
|
|
304
|
-
expect(result.success).toBe(true);
|
|
305
|
-
});
|
|
306
|
-
});
|
|
307
|
-
});
|
|
308
|
-
|
|
309
|
-
describe('Swarm Commands', () => {
|
|
310
|
-
let ctx: CommandContext;
|
|
311
|
-
|
|
312
|
-
beforeEach(() => {
|
|
313
|
-
ctx = {
|
|
314
|
-
args: [],
|
|
315
|
-
flags: { _: [] },
|
|
316
|
-
cwd: '/test',
|
|
317
|
-
interactive: false
|
|
318
|
-
};
|
|
319
|
-
});
|
|
320
|
-
|
|
321
|
-
describe('swarm init', () => {
|
|
322
|
-
it('should initialize swarm with default topology', async () => {
|
|
323
|
-
const initCmd = swarmCommand.subcommands?.find(c => c.name === 'init');
|
|
324
|
-
expect(initCmd).toBeDefined();
|
|
325
|
-
|
|
326
|
-
const result = await initCmd!.action!(ctx);
|
|
327
|
-
|
|
328
|
-
expect(result.success).toBe(true);
|
|
329
|
-
expect(result.data).toHaveProperty('swarmId');
|
|
330
|
-
expect(result.data).toHaveProperty('topology');
|
|
331
|
-
});
|
|
332
|
-
|
|
333
|
-
it('should initialize swarm with custom topology', async () => {
|
|
334
|
-
const initCmd = swarmCommand.subcommands?.find(c => c.name === 'init');
|
|
335
|
-
|
|
336
|
-
ctx.flags = { topology: 'mesh', _: [] };
|
|
337
|
-
const result = await initCmd!.action!(ctx);
|
|
338
|
-
|
|
339
|
-
expect(result.success).toBe(true);
|
|
340
|
-
expect(result.data).toHaveProperty('topology', 'mesh');
|
|
341
|
-
});
|
|
342
|
-
|
|
343
|
-
it('should enable V3 mode', async () => {
|
|
344
|
-
const initCmd = swarmCommand.subcommands?.find(c => c.name === 'init');
|
|
345
|
-
|
|
346
|
-
ctx.flags = { v3Mode: true, _: [] };
|
|
347
|
-
const result = await initCmd!.action!(ctx);
|
|
348
|
-
|
|
349
|
-
expect(result.success).toBe(true);
|
|
350
|
-
});
|
|
351
|
-
|
|
352
|
-
it('should set max agents', async () => {
|
|
353
|
-
const initCmd = swarmCommand.subcommands?.find(c => c.name === 'init');
|
|
354
|
-
|
|
355
|
-
ctx.flags = { maxAgents: 20, _: [] };
|
|
356
|
-
const result = await initCmd!.action!(ctx);
|
|
357
|
-
|
|
358
|
-
expect(result.success).toBe(true);
|
|
359
|
-
expect(result.data?.config).toHaveProperty('maxAgents', 20);
|
|
360
|
-
});
|
|
361
|
-
});
|
|
362
|
-
|
|
363
|
-
describe('swarm start', () => {
|
|
364
|
-
it('should start swarm with objective', async () => {
|
|
365
|
-
const startCmd = swarmCommand.subcommands?.find(c => c.name === 'start');
|
|
366
|
-
expect(startCmd).toBeDefined();
|
|
367
|
-
|
|
368
|
-
ctx.flags = { objective: 'Build REST API', _: [] };
|
|
369
|
-
const result = await startCmd!.action!(ctx);
|
|
370
|
-
|
|
371
|
-
expect(result.success).toBe(true);
|
|
372
|
-
expect(result.data).toHaveProperty('objective', 'Build REST API');
|
|
373
|
-
});
|
|
374
|
-
|
|
375
|
-
it('should fail without objective', async () => {
|
|
376
|
-
const startCmd = swarmCommand.subcommands?.find(c => c.name === 'start');
|
|
377
|
-
|
|
378
|
-
const result = await startCmd!.action!(ctx);
|
|
379
|
-
|
|
380
|
-
expect(result.success).toBe(false);
|
|
381
|
-
expect(result.exitCode).toBe(1);
|
|
382
|
-
});
|
|
383
|
-
|
|
384
|
-
it('should accept strategy option', async () => {
|
|
385
|
-
const startCmd = swarmCommand.subcommands?.find(c => c.name === 'start');
|
|
386
|
-
|
|
387
|
-
ctx.flags = { objective: 'Test project', strategy: 'testing', _: [] };
|
|
388
|
-
const result = await startCmd!.action!(ctx);
|
|
389
|
-
|
|
390
|
-
expect(result.success).toBe(true);
|
|
391
|
-
expect(result.data).toHaveProperty('strategy', 'testing');
|
|
392
|
-
});
|
|
393
|
-
});
|
|
394
|
-
|
|
395
|
-
describe('swarm status', () => {
|
|
396
|
-
it('should show swarm status', async () => {
|
|
397
|
-
const statusCmd = swarmCommand.subcommands?.find(c => c.name === 'status');
|
|
398
|
-
expect(statusCmd).toBeDefined();
|
|
399
|
-
|
|
400
|
-
const result = await statusCmd!.action!(ctx);
|
|
401
|
-
|
|
402
|
-
expect(result.success).toBe(true);
|
|
403
|
-
expect(result.data).toHaveProperty('agents');
|
|
404
|
-
expect(result.data).toHaveProperty('tasks');
|
|
405
|
-
expect(result.data).toHaveProperty('metrics');
|
|
406
|
-
});
|
|
407
|
-
});
|
|
408
|
-
|
|
409
|
-
describe('swarm stop', () => {
|
|
410
|
-
it('should stop swarm', async () => {
|
|
411
|
-
const stopCmd = swarmCommand.subcommands?.find(c => c.name === 'stop');
|
|
412
|
-
expect(stopCmd).toBeDefined();
|
|
413
|
-
|
|
414
|
-
ctx.args = ['swarm-123'];
|
|
415
|
-
ctx.flags = { force: true, _: [] };
|
|
416
|
-
const result = await stopCmd!.action!(ctx);
|
|
417
|
-
|
|
418
|
-
expect(result.success).toBe(true);
|
|
419
|
-
expect(result.data).toHaveProperty('swarmId', 'swarm-123');
|
|
420
|
-
expect(result.data).toHaveProperty('stopped', true);
|
|
421
|
-
});
|
|
422
|
-
|
|
423
|
-
it('should fail without swarm ID', async () => {
|
|
424
|
-
const stopCmd = swarmCommand.subcommands?.find(c => c.name === 'stop');
|
|
425
|
-
|
|
426
|
-
const result = await stopCmd!.action!(ctx);
|
|
427
|
-
|
|
428
|
-
expect(result.success).toBe(false);
|
|
429
|
-
});
|
|
430
|
-
});
|
|
431
|
-
|
|
432
|
-
describe('swarm scale', () => {
|
|
433
|
-
it('should scale swarm', async () => {
|
|
434
|
-
const scaleCmd = swarmCommand.subcommands?.find(c => c.name === 'scale');
|
|
435
|
-
expect(scaleCmd).toBeDefined();
|
|
436
|
-
|
|
437
|
-
ctx.args = ['swarm-123'];
|
|
438
|
-
ctx.flags = { agents: 20, _: [] };
|
|
439
|
-
const result = await scaleCmd!.action!(ctx);
|
|
440
|
-
|
|
441
|
-
expect(result.success).toBe(true);
|
|
442
|
-
expect(result.data).toHaveProperty('agents', 20);
|
|
443
|
-
});
|
|
444
|
-
|
|
445
|
-
it('should fail without target agent count', async () => {
|
|
446
|
-
const scaleCmd = swarmCommand.subcommands?.find(c => c.name === 'scale');
|
|
447
|
-
|
|
448
|
-
ctx.args = ['swarm-123'];
|
|
449
|
-
const result = await scaleCmd!.action!(ctx);
|
|
450
|
-
|
|
451
|
-
expect(result.success).toBe(false);
|
|
452
|
-
});
|
|
453
|
-
});
|
|
454
|
-
|
|
455
|
-
describe('swarm coordinate', () => {
|
|
456
|
-
it('should show V3 coordination structure', async () => {
|
|
457
|
-
const coordinateCmd = swarmCommand.subcommands?.find(c => c.name === 'coordinate');
|
|
458
|
-
expect(coordinateCmd).toBeDefined();
|
|
459
|
-
|
|
460
|
-
const result = await coordinateCmd!.action!(ctx);
|
|
461
|
-
|
|
462
|
-
expect(result.success).toBe(true);
|
|
463
|
-
expect(result.data).toHaveProperty('agents');
|
|
464
|
-
expect(result.data?.agents).toHaveLength(15);
|
|
465
|
-
});
|
|
466
|
-
});
|
|
467
|
-
});
|
|
468
|
-
|
|
469
|
-
describe('Memory Commands', () => {
|
|
470
|
-
let ctx: CommandContext;
|
|
471
|
-
|
|
472
|
-
beforeEach(() => {
|
|
473
|
-
ctx = {
|
|
474
|
-
args: [],
|
|
475
|
-
flags: { _: [] },
|
|
476
|
-
cwd: '/test',
|
|
477
|
-
interactive: false
|
|
478
|
-
};
|
|
479
|
-
});
|
|
480
|
-
|
|
481
|
-
describe('memory store', () => {
|
|
482
|
-
it('should store data', async () => {
|
|
483
|
-
const storeCmd = memoryCommand.subcommands?.find(c => c.name === 'store');
|
|
484
|
-
expect(storeCmd).toBeDefined();
|
|
485
|
-
|
|
486
|
-
ctx.flags = { key: 'test-key', value: 'test-value', _: [] };
|
|
487
|
-
const result = await storeCmd!.action!(ctx);
|
|
488
|
-
|
|
489
|
-
expect(result.success).toBe(true);
|
|
490
|
-
expect(result.data).toHaveProperty('key', 'test-key');
|
|
491
|
-
});
|
|
492
|
-
|
|
493
|
-
it('should fail without key', async () => {
|
|
494
|
-
const storeCmd = memoryCommand.subcommands?.find(c => c.name === 'store');
|
|
495
|
-
|
|
496
|
-
ctx.flags = { value: 'test-value', _: [] };
|
|
497
|
-
const result = await storeCmd!.action!(ctx);
|
|
498
|
-
|
|
499
|
-
expect(result.success).toBe(false);
|
|
500
|
-
});
|
|
501
|
-
});
|
|
502
|
-
|
|
503
|
-
describe('memory retrieve', () => {
|
|
504
|
-
it('should retrieve data', async () => {
|
|
505
|
-
const retrieveCmd = memoryCommand.subcommands?.find(c => c.name === 'retrieve');
|
|
506
|
-
expect(retrieveCmd).toBeDefined();
|
|
507
|
-
|
|
508
|
-
ctx.args = ['test-key'];
|
|
509
|
-
const result = await retrieveCmd!.action!(ctx);
|
|
510
|
-
|
|
511
|
-
expect(result.success).toBe(true);
|
|
512
|
-
expect(result.data).toHaveProperty('key', 'test-key');
|
|
513
|
-
});
|
|
514
|
-
});
|
|
515
|
-
|
|
516
|
-
describe('memory search', () => {
|
|
517
|
-
it('should search memory', async () => {
|
|
518
|
-
const searchCmd = memoryCommand.subcommands?.find(c => c.name === 'search');
|
|
519
|
-
expect(searchCmd).toBeDefined();
|
|
520
|
-
|
|
521
|
-
ctx.flags = { query: 'authentication', _: [] };
|
|
522
|
-
const result = await searchCmd!.action!(ctx);
|
|
523
|
-
|
|
524
|
-
expect(result.success).toBe(true);
|
|
525
|
-
expect(Array.isArray(result.data)).toBe(true);
|
|
526
|
-
});
|
|
527
|
-
|
|
528
|
-
it('should fail without query', async () => {
|
|
529
|
-
const searchCmd = memoryCommand.subcommands?.find(c => c.name === 'search');
|
|
530
|
-
|
|
531
|
-
const result = await searchCmd!.action!(ctx);
|
|
532
|
-
|
|
533
|
-
expect(result.success).toBe(false);
|
|
534
|
-
});
|
|
535
|
-
});
|
|
536
|
-
|
|
537
|
-
describe('memory list', () => {
|
|
538
|
-
it('should list memory entries', async () => {
|
|
539
|
-
const listCmd = memoryCommand.subcommands?.find(c => c.name === 'list');
|
|
540
|
-
expect(listCmd).toBeDefined();
|
|
541
|
-
|
|
542
|
-
const result = await listCmd!.action!(ctx);
|
|
543
|
-
|
|
544
|
-
expect(result.success).toBe(true);
|
|
545
|
-
expect(Array.isArray(result.data)).toBe(true);
|
|
546
|
-
});
|
|
547
|
-
});
|
|
548
|
-
|
|
549
|
-
describe('memory delete', () => {
|
|
550
|
-
it('should delete entry', async () => {
|
|
551
|
-
const deleteCmd = memoryCommand.subcommands?.find(c => c.name === 'delete');
|
|
552
|
-
expect(deleteCmd).toBeDefined();
|
|
553
|
-
|
|
554
|
-
ctx.args = ['test-key'];
|
|
555
|
-
ctx.flags = { force: true, _: [] };
|
|
556
|
-
const result = await deleteCmd!.action!(ctx);
|
|
557
|
-
|
|
558
|
-
expect(result.success).toBe(true);
|
|
559
|
-
expect(result.data).toHaveProperty('deleted', true);
|
|
560
|
-
});
|
|
561
|
-
});
|
|
562
|
-
|
|
563
|
-
describe('memory stats', () => {
|
|
564
|
-
it('should show memory statistics', async () => {
|
|
565
|
-
const statsCmd = memoryCommand.subcommands?.find(c => c.name === 'stats');
|
|
566
|
-
expect(statsCmd).toBeDefined();
|
|
567
|
-
|
|
568
|
-
const result = await statsCmd!.action!(ctx);
|
|
569
|
-
|
|
570
|
-
expect(result.success).toBe(true);
|
|
571
|
-
expect(result.data).toHaveProperty('entries');
|
|
572
|
-
expect(result.data).toHaveProperty('storage');
|
|
573
|
-
expect(result.data).toHaveProperty('performance');
|
|
574
|
-
});
|
|
575
|
-
});
|
|
576
|
-
|
|
577
|
-
describe('memory configure', () => {
|
|
578
|
-
it('should configure memory backend', async () => {
|
|
579
|
-
const configureCmd = memoryCommand.subcommands?.find(c => c.name === 'configure');
|
|
580
|
-
expect(configureCmd).toBeDefined();
|
|
581
|
-
|
|
582
|
-
ctx.flags = { backend: 'agentdb', _: [] };
|
|
583
|
-
const result = await configureCmd!.action!(ctx);
|
|
584
|
-
|
|
585
|
-
expect(result.success).toBe(true);
|
|
586
|
-
expect(result.data).toHaveProperty('backend', 'agentdb');
|
|
587
|
-
});
|
|
588
|
-
});
|
|
589
|
-
});
|
|
590
|
-
|
|
591
|
-
describe('Config Commands', () => {
|
|
592
|
-
let ctx: CommandContext;
|
|
593
|
-
|
|
594
|
-
beforeEach(() => {
|
|
595
|
-
ctx = {
|
|
596
|
-
args: [],
|
|
597
|
-
flags: { _: [] },
|
|
598
|
-
cwd: '/test',
|
|
599
|
-
interactive: false
|
|
600
|
-
};
|
|
601
|
-
});
|
|
602
|
-
|
|
603
|
-
describe('config init', () => {
|
|
604
|
-
it('should initialize configuration', async () => {
|
|
605
|
-
const initCmd = configCommand.subcommands?.find(c => c.name === 'init');
|
|
606
|
-
expect(initCmd).toBeDefined();
|
|
607
|
-
|
|
608
|
-
const result = await initCmd!.action!(ctx);
|
|
609
|
-
|
|
610
|
-
expect(result.success).toBe(true);
|
|
611
|
-
expect(result.data).toHaveProperty('version');
|
|
612
|
-
});
|
|
613
|
-
|
|
614
|
-
it('should initialize with V3 mode', async () => {
|
|
615
|
-
const initCmd = configCommand.subcommands?.find(c => c.name === 'init');
|
|
616
|
-
|
|
617
|
-
ctx.flags = { v3: true, _: [] };
|
|
618
|
-
const result = await initCmd!.action!(ctx);
|
|
619
|
-
|
|
620
|
-
expect(result.success).toBe(true);
|
|
621
|
-
expect(result.data).toHaveProperty('v3Mode', true);
|
|
622
|
-
});
|
|
623
|
-
});
|
|
624
|
-
|
|
625
|
-
describe('config get', () => {
|
|
626
|
-
it('should get configuration value', async () => {
|
|
627
|
-
const getCmd = configCommand.subcommands?.find(c => c.name === 'get');
|
|
628
|
-
expect(getCmd).toBeDefined();
|
|
629
|
-
|
|
630
|
-
ctx.args = ['swarm.topology'];
|
|
631
|
-
const result = await getCmd!.action!(ctx);
|
|
632
|
-
|
|
633
|
-
expect(result.success).toBe(true);
|
|
634
|
-
expect(result.data).toHaveProperty('key');
|
|
635
|
-
expect(result.data).toHaveProperty('value');
|
|
636
|
-
});
|
|
637
|
-
|
|
638
|
-
it('should show all config when no key provided', async () => {
|
|
639
|
-
const getCmd = configCommand.subcommands?.find(c => c.name === 'get');
|
|
640
|
-
|
|
641
|
-
const result = await getCmd!.action!(ctx);
|
|
642
|
-
|
|
643
|
-
expect(result.success).toBe(true);
|
|
644
|
-
});
|
|
645
|
-
});
|
|
646
|
-
|
|
647
|
-
describe('config set', () => {
|
|
648
|
-
it('should set configuration value', async () => {
|
|
649
|
-
const setCmd = configCommand.subcommands?.find(c => c.name === 'set');
|
|
650
|
-
expect(setCmd).toBeDefined();
|
|
651
|
-
|
|
652
|
-
ctx.flags = { key: 'swarm.maxAgents', value: '20', _: [] };
|
|
653
|
-
const result = await setCmd!.action!(ctx);
|
|
654
|
-
|
|
655
|
-
expect(result.success).toBe(true);
|
|
656
|
-
expect(result.data).toHaveProperty('key', 'swarm.maxAgents');
|
|
657
|
-
expect(result.data).toHaveProperty('value', '20');
|
|
658
|
-
});
|
|
659
|
-
|
|
660
|
-
it('should fail without key and value', async () => {
|
|
661
|
-
const setCmd = configCommand.subcommands?.find(c => c.name === 'set');
|
|
662
|
-
|
|
663
|
-
const result = await setCmd!.action!(ctx);
|
|
664
|
-
|
|
665
|
-
expect(result.success).toBe(false);
|
|
666
|
-
});
|
|
667
|
-
});
|
|
668
|
-
|
|
669
|
-
describe('config providers', () => {
|
|
670
|
-
it('should list providers', async () => {
|
|
671
|
-
const providersCmd = configCommand.subcommands?.find(c => c.name === 'providers');
|
|
672
|
-
expect(providersCmd).toBeDefined();
|
|
673
|
-
|
|
674
|
-
const result = await providersCmd!.action!(ctx);
|
|
675
|
-
|
|
676
|
-
expect(result.success).toBe(true);
|
|
677
|
-
expect(Array.isArray(result.data)).toBe(true);
|
|
678
|
-
});
|
|
679
|
-
});
|
|
680
|
-
|
|
681
|
-
describe('config reset', () => {
|
|
682
|
-
it('should reset configuration', async () => {
|
|
683
|
-
const resetCmd = configCommand.subcommands?.find(c => c.name === 'reset');
|
|
684
|
-
expect(resetCmd).toBeDefined();
|
|
685
|
-
|
|
686
|
-
ctx.flags = { force: true, _: [] };
|
|
687
|
-
const result = await resetCmd!.action!(ctx);
|
|
688
|
-
|
|
689
|
-
expect(result.success).toBe(true);
|
|
690
|
-
expect(result.data).toHaveProperty('reset', true);
|
|
691
|
-
});
|
|
692
|
-
});
|
|
693
|
-
|
|
694
|
-
describe('config export', () => {
|
|
695
|
-
it('should export configuration', async () => {
|
|
696
|
-
const exportCmd = configCommand.subcommands?.find(c => c.name === 'export');
|
|
697
|
-
expect(exportCmd).toBeDefined();
|
|
698
|
-
|
|
699
|
-
const result = await exportCmd!.action!(ctx);
|
|
700
|
-
|
|
701
|
-
expect(result.success).toBe(true);
|
|
702
|
-
expect(result.data).toHaveProperty('config');
|
|
703
|
-
});
|
|
704
|
-
});
|
|
705
|
-
|
|
706
|
-
describe('config import', () => {
|
|
707
|
-
it('should import configuration', async () => {
|
|
708
|
-
const importCmd = configCommand.subcommands?.find(c => c.name === 'import');
|
|
709
|
-
expect(importCmd).toBeDefined();
|
|
710
|
-
|
|
711
|
-
ctx.flags = { file: './config.json', _: [] };
|
|
712
|
-
const result = await importCmd!.action!(ctx);
|
|
713
|
-
|
|
714
|
-
expect(result.success).toBe(true);
|
|
715
|
-
expect(result.data).toHaveProperty('imported', true);
|
|
716
|
-
});
|
|
717
|
-
|
|
718
|
-
it('should fail without file path', async () => {
|
|
719
|
-
const importCmd = configCommand.subcommands?.find(c => c.name === 'import');
|
|
720
|
-
|
|
721
|
-
const result = await importCmd!.action!(ctx);
|
|
722
|
-
|
|
723
|
-
expect(result.success).toBe(false);
|
|
724
|
-
});
|
|
725
|
-
});
|
|
726
|
-
});
|