@aiready/cli 0.10.6 → 0.12.0

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.
@@ -1,37 +1,63 @@
1
- import { describe, it, expect, vi } from 'vitest';
1
+ import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
2
2
  import { analyzeUnified } from '../index';
3
-
4
- // Mock the individual tools
5
- vi.mock('@aiready/pattern-detect', () => ({
6
- analyzePatterns: vi.fn().mockResolvedValue({
7
- results: [],
8
- duplicates: [],
9
- files: [],
10
- }),
11
- generateSummary: vi.fn().mockReturnValue({
12
- totalDuplicateLines: 0,
13
- potentialSavings: 0,
14
- }),
15
- }));
16
-
17
- vi.mock('@aiready/context-analyzer', () => ({
18
- analyzeContext: vi.fn().mockResolvedValue([]),
19
- generateSummary: vi.fn().mockReturnValue({
20
- totalFiles: 0,
21
- averageCohesion: 0,
22
- averageFragmentation: 0,
23
- }),
24
- }));
3
+ import { ToolRegistry, ToolName, SpokeOutputSchema } from '@aiready/core';
25
4
 
26
5
  describe('CLI Unified Analysis', () => {
6
+ beforeEach(() => {
7
+ ToolRegistry.clear();
8
+
9
+ // Register mock providers
10
+ ToolRegistry.register({
11
+ id: ToolName.PatternDetect,
12
+ alias: ['patterns'],
13
+ analyze: async () =>
14
+ SpokeOutputSchema.parse({
15
+ results: [],
16
+ summary: {},
17
+ metadata: { toolName: ToolName.PatternDetect, version: '1.0.0' },
18
+ }),
19
+ score: () => ({
20
+ toolName: ToolName.PatternDetect,
21
+ score: 80,
22
+ factors: [],
23
+ recommendations: [],
24
+ rawMetrics: {},
25
+ }),
26
+ defaultWeight: 10,
27
+ });
28
+
29
+ ToolRegistry.register({
30
+ id: ToolName.ContextAnalyzer,
31
+ alias: ['context'],
32
+ analyze: async () =>
33
+ SpokeOutputSchema.parse({
34
+ results: [],
35
+ summary: {},
36
+ metadata: { toolName: ToolName.ContextAnalyzer, version: '1.0.0' },
37
+ }),
38
+ score: () => ({
39
+ toolName: ToolName.ContextAnalyzer,
40
+ score: 70,
41
+ factors: [],
42
+ recommendations: [],
43
+ rawMetrics: {},
44
+ }),
45
+ defaultWeight: 10,
46
+ });
47
+ });
48
+
49
+ afterEach(() => {
50
+ ToolRegistry.clear();
51
+ });
52
+
27
53
  it('should run unified analysis with both tools', async () => {
28
54
  const results = await analyzeUnified({
29
55
  rootDir: '/test',
30
56
  tools: ['patterns', 'context'],
31
57
  });
32
58
 
33
- expect(results).toHaveProperty('patternDetect');
34
- expect(results).toHaveProperty('contextAnalyzer');
59
+ expect(results).toHaveProperty(ToolName.PatternDetect);
60
+ expect(results).toHaveProperty(ToolName.ContextAnalyzer);
35
61
  expect(results).toHaveProperty('summary');
36
62
  });
37
63
 
@@ -41,8 +67,8 @@ describe('CLI Unified Analysis', () => {
41
67
  tools: ['patterns'],
42
68
  });
43
69
 
44
- expect(results).toHaveProperty('patternDetect');
45
- expect(results).not.toHaveProperty('contextAnalyzer');
70
+ expect(results).toHaveProperty(ToolName.PatternDetect);
71
+ expect(results).not.toHaveProperty(ToolName.ContextAnalyzer);
46
72
  expect(results).toHaveProperty('summary');
47
73
  });
48
74
 
@@ -52,8 +78,8 @@ describe('CLI Unified Analysis', () => {
52
78
  tools: ['context'],
53
79
  });
54
80
 
55
- expect(results).not.toHaveProperty('patternDetect');
56
- expect(results).toHaveProperty('contextAnalyzer');
81
+ expect(results).not.toHaveProperty(ToolName.PatternDetect);
82
+ expect(results).toHaveProperty(ToolName.ContextAnalyzer);
57
83
  expect(results).toHaveProperty('summary');
58
84
  });
59
85
  });