@claude-flow/cli 3.0.0-alpha.13 → 3.0.0-alpha.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/package.json +12 -4
  2. package/.agentic-flow/intelligence.json +0 -17
  3. package/.claude-flow/agents/store.json +0 -16
  4. package/.claude-flow/daemon-state.json +0 -123
  5. package/.claude-flow/daemon-test.log +0 -0
  6. package/.claude-flow/daemon.log +0 -0
  7. package/.claude-flow/daemon2.log +0 -0
  8. package/.claude-flow/daemon3.log +0 -0
  9. package/.claude-flow/hive-mind/state.json +0 -51
  10. package/.claude-flow/metrics/agent-metrics.json +0 -1
  11. package/.claude-flow/metrics/codebase-map.json +0 -11
  12. package/.claude-flow/metrics/consolidation.json +0 -6
  13. package/.claude-flow/metrics/performance.json +0 -87
  14. package/.claude-flow/metrics/security-audit.json +0 -10
  15. package/.claude-flow/metrics/task-metrics.json +0 -10
  16. package/.claude-flow/metrics/test-gaps.json +0 -6
  17. package/__tests__/README.md +0 -140
  18. package/__tests__/TEST_SUMMARY.md +0 -144
  19. package/__tests__/cli.test.ts +0 -558
  20. package/__tests__/commands.test.ts +0 -726
  21. package/__tests__/config-adapter.test.ts +0 -362
  22. package/__tests__/config-loading.test.ts +0 -106
  23. package/__tests__/coverage/.tmp/coverage-0.json +0 -1
  24. package/__tests__/coverage/.tmp/coverage-1.json +0 -1
  25. package/__tests__/coverage/.tmp/coverage-2.json +0 -1
  26. package/__tests__/coverage/.tmp/coverage-3.json +0 -1
  27. package/__tests__/coverage/.tmp/coverage-4.json +0 -1
  28. package/__tests__/coverage/.tmp/coverage-5.json +0 -1
  29. package/__tests__/mcp-client.test.ts +0 -480
  30. package/__tests__/p1-commands.test.ts +0 -1064
  31. package/agents/architect.yaml +0 -11
  32. package/agents/coder.yaml +0 -11
  33. package/agents/reviewer.yaml +0 -10
  34. package/agents/security-architect.yaml +0 -10
  35. package/agents/tester.yaml +0 -10
  36. package/docs/CONFIG_LOADING.md +0 -236
  37. package/docs/IMPLEMENTATION_COMPLETE.md +0 -421
  38. package/docs/MCP_CLIENT_GUIDE.md +0 -620
  39. package/docs/REFACTORING_SUMMARY.md +0 -247
  40. package/scripts/publish.sh +0 -46
  41. package/src/commands/agent.ts +0 -955
  42. package/src/commands/claims.ts +0 -317
  43. package/src/commands/completions.ts +0 -558
  44. package/src/commands/config.ts +0 -452
  45. package/src/commands/daemon.ts +0 -621
  46. package/src/commands/deployment.ts +0 -323
  47. package/src/commands/doctor.ts +0 -382
  48. package/src/commands/embeddings.ts +0 -686
  49. package/src/commands/hive-mind.ts +0 -928
  50. package/src/commands/hooks.ts +0 -2603
  51. package/src/commands/index.ts +0 -154
  52. package/src/commands/init.ts +0 -597
  53. package/src/commands/mcp.ts +0 -753
  54. package/src/commands/memory.ts +0 -1161
  55. package/src/commands/migrate.ts +0 -447
  56. package/src/commands/neural.ts +0 -253
  57. package/src/commands/performance.ts +0 -292
  58. package/src/commands/plugins.ts +0 -316
  59. package/src/commands/process.ts +0 -695
  60. package/src/commands/providers.ts +0 -259
  61. package/src/commands/security.ts +0 -288
  62. package/src/commands/session.ts +0 -891
  63. package/src/commands/start.ts +0 -457
  64. package/src/commands/status.ts +0 -736
  65. package/src/commands/swarm.ts +0 -648
  66. package/src/commands/task.ts +0 -792
  67. package/src/commands/workflow.ts +0 -742
  68. package/src/config-adapter.ts +0 -210
  69. package/src/index.ts +0 -443
  70. package/src/infrastructure/in-memory-repositories.ts +0 -310
  71. package/src/init/claudemd-generator.ts +0 -631
  72. package/src/init/executor.ts +0 -762
  73. package/src/init/helpers-generator.ts +0 -628
  74. package/src/init/index.ts +0 -60
  75. package/src/init/mcp-generator.ts +0 -83
  76. package/src/init/settings-generator.ts +0 -284
  77. package/src/init/statusline-generator.ts +0 -211
  78. package/src/init/types.ts +0 -447
  79. package/src/mcp-client.ts +0 -241
  80. package/src/mcp-server.ts +0 -577
  81. package/src/mcp-tools/agent-tools.ts +0 -466
  82. package/src/mcp-tools/config-tools.ts +0 -370
  83. package/src/mcp-tools/hive-mind-tools.ts +0 -521
  84. package/src/mcp-tools/hooks-tools.ts +0 -1888
  85. package/src/mcp-tools/index.ts +0 -16
  86. package/src/mcp-tools/memory-tools.ts +0 -270
  87. package/src/mcp-tools/session-tools.ts +0 -359
  88. package/src/mcp-tools/swarm-tools.ts +0 -105
  89. package/src/mcp-tools/task-tools.ts +0 -347
  90. package/src/mcp-tools/types.ts +0 -33
  91. package/src/mcp-tools/workflow-tools.ts +0 -573
  92. package/src/output.ts +0 -639
  93. package/src/parser.ts +0 -417
  94. package/src/prompt.ts +0 -619
  95. package/src/services/index.ts +0 -15
  96. package/src/services/worker-daemon.ts +0 -726
  97. package/src/suggest.ts +0 -245
  98. package/src/types.ts +0 -287
  99. package/tmp.json +0 -0
  100. package/tsconfig.json +0 -16
  101. package/tsconfig.tsbuildinfo +0 -1
  102. 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
- });