baseguard 1.0.5 → 1.0.6

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 (80) hide show
  1. package/dist/ai/gemini-analyzer.d.ts.map +1 -1
  2. package/dist/ai/gemini-analyzer.js +1 -1
  3. package/dist/ai/gemini-analyzer.js.map +1 -1
  4. package/dist/ai/gemini-code-fixer.d.ts.map +1 -1
  5. package/dist/ai/gemini-code-fixer.js +2 -7
  6. package/dist/ai/gemini-code-fixer.js.map +1 -1
  7. package/dist/ai/jules-implementer.d.ts +8 -0
  8. package/dist/ai/jules-implementer.d.ts.map +1 -1
  9. package/dist/ai/jules-implementer.js +115 -17
  10. package/dist/ai/jules-implementer.js.map +1 -1
  11. package/package.json +1 -1
  12. package/src/ai/__tests__/gemini-analyzer.test.ts +0 -181
  13. package/src/ai/agentkit-orchestrator.ts +0 -534
  14. package/src/ai/fix-manager.ts +0 -362
  15. package/src/ai/gemini-analyzer.ts +0 -665
  16. package/src/ai/gemini-code-fixer.ts +0 -539
  17. package/src/ai/index.ts +0 -4
  18. package/src/ai/jules-implementer.ts +0 -504
  19. package/src/ai/unified-code-fixer.ts +0 -347
  20. package/src/commands/automation.ts +0 -344
  21. package/src/commands/check.ts +0 -298
  22. package/src/commands/config.ts +0 -584
  23. package/src/commands/fix.ts +0 -269
  24. package/src/commands/index.ts +0 -7
  25. package/src/commands/init.ts +0 -156
  26. package/src/commands/status.ts +0 -307
  27. package/src/core/api-key-manager.ts +0 -298
  28. package/src/core/baseguard.ts +0 -757
  29. package/src/core/baseline-checker.ts +0 -566
  30. package/src/core/cache-manager.ts +0 -272
  31. package/src/core/configuration-recovery.ts +0 -672
  32. package/src/core/configuration.ts +0 -596
  33. package/src/core/debug-logger.ts +0 -590
  34. package/src/core/directory-filter.ts +0 -421
  35. package/src/core/error-handler.ts +0 -518
  36. package/src/core/file-processor.ts +0 -338
  37. package/src/core/gitignore-manager.ts +0 -169
  38. package/src/core/graceful-degradation-manager.ts +0 -596
  39. package/src/core/index.ts +0 -17
  40. package/src/core/lazy-loader.ts +0 -317
  41. package/src/core/logger.ts +0 -0
  42. package/src/core/memory-manager.ts +0 -290
  43. package/src/core/parser-worker.ts +0 -33
  44. package/src/core/startup-optimizer.ts +0 -246
  45. package/src/core/system-error-handler.ts +0 -755
  46. package/src/git/automation-engine.ts +0 -361
  47. package/src/git/github-manager.ts +0 -190
  48. package/src/git/hook-manager.ts +0 -210
  49. package/src/git/index.ts +0 -4
  50. package/src/index.ts +0 -8
  51. package/src/parsers/feature-validator.ts +0 -559
  52. package/src/parsers/index.ts +0 -8
  53. package/src/parsers/parser-manager.ts +0 -418
  54. package/src/parsers/parser.ts +0 -26
  55. package/src/parsers/react-parser-optimized.ts +0 -161
  56. package/src/parsers/react-parser.ts +0 -359
  57. package/src/parsers/svelte-parser.ts +0 -510
  58. package/src/parsers/vanilla-parser.ts +0 -685
  59. package/src/parsers/vue-parser.ts +0 -476
  60. package/src/types/index.ts +0 -96
  61. package/src/ui/components.ts +0 -567
  62. package/src/ui/help.ts +0 -193
  63. package/src/ui/index.ts +0 -4
  64. package/src/ui/prompts.ts +0 -681
  65. package/src/ui/terminal-header.ts +0 -59
  66. package/tests/e2e/baseguard.e2e.test.ts +0 -516
  67. package/tests/e2e/cross-platform.e2e.test.ts +0 -420
  68. package/tests/e2e/git-integration.e2e.test.ts +0 -487
  69. package/tests/fixtures/react-project/package.json +0 -14
  70. package/tests/fixtures/react-project/src/App.css +0 -76
  71. package/tests/fixtures/react-project/src/App.tsx +0 -77
  72. package/tests/fixtures/svelte-project/package.json +0 -11
  73. package/tests/fixtures/svelte-project/src/App.svelte +0 -369
  74. package/tests/fixtures/vanilla-project/index.html +0 -76
  75. package/tests/fixtures/vanilla-project/script.js +0 -331
  76. package/tests/fixtures/vanilla-project/styles.css +0 -359
  77. package/tests/fixtures/vue-project/package.json +0 -12
  78. package/tests/fixtures/vue-project/src/App.vue +0 -216
  79. package/tmp-smoke/.baseguard/backups/config-2026-02-19T12-04-11-067Z-auto.json +0 -30
  80. package/tmp-smoke/src/bad.css +0 -3
@@ -1,181 +0,0 @@
1
- import { describe, it, expect, vi, beforeEach } from 'vitest';
2
- import { GeminiAnalyzer } from '../gemini-analyzer.js';
3
- import type { Violation } from '../../types/index.js';
4
-
5
- // Mock fetch globally
6
- global.fetch = vi.fn();
7
-
8
- describe('GeminiAnalyzer', () => {
9
- let analyzer: GeminiAnalyzer;
10
- const mockApiKey = 'AIzaSyDummyKeyForTesting1234567890123456789';
11
-
12
- beforeEach(() => {
13
- analyzer = new GeminiAnalyzer(mockApiKey);
14
- vi.clearAllMocks();
15
- });
16
-
17
- const mockViolation: Violation = {
18
- feature: 'container-type',
19
- featureId: 'container-queries',
20
- file: 'src/Card.css',
21
- line: 15,
22
- column: 5,
23
- context: ' container-type: inline-size;',
24
- browser: 'safari',
25
- required: '15',
26
- actual: false,
27
- baselineStatus: 'newly',
28
- reason: 'Not supported in Safari 15'
29
- };
30
-
31
- describe('API Key Validation', () => {
32
- it('should validate correct API key format', () => {
33
- expect(GeminiAnalyzer.validateApiKey(mockApiKey)).toBe(true);
34
- });
35
-
36
- it('should reject invalid API key format', () => {
37
- expect(GeminiAnalyzer.validateApiKey('invalid-key')).toBe(false);
38
- expect(GeminiAnalyzer.validateApiKey('AIza123')).toBe(false); // too short
39
- });
40
- });
41
-
42
- describe('Cache Management', () => {
43
- it('should cache analysis results', async () => {
44
- const mockResponse = {
45
- ok: true,
46
- json: () => Promise.resolve({
47
- candidates: [{
48
- content: {
49
- parts: [{ text: 'Test analysis response with 5% market share impact.' }]
50
- },
51
- groundingMetadata: {
52
- groundingChunks: [
53
- { web: { uri: 'https://web.dev/container-queries' } }
54
- ]
55
- }
56
- }]
57
- })
58
- };
59
-
60
- (global.fetch as any).mockResolvedValue(mockResponse);
61
-
62
- // First call should hit the API
63
- const analysis1 = await analyzer.analyzeViolation(mockViolation);
64
- expect(fetch).toHaveBeenCalledTimes(1);
65
-
66
- // Second call should use cache
67
- const analysis2 = await analyzer.analyzeViolation(mockViolation);
68
- expect(fetch).toHaveBeenCalledTimes(1); // Still only 1 call
69
-
70
- expect(analysis1.violation.feature).toBe(analysis2.violation.feature);
71
- });
72
-
73
- it('should clear cache when requested', async () => {
74
- analyzer.clearCache();
75
- const stats = analyzer.getCacheStats();
76
- expect(stats.size).toBe(0);
77
- });
78
- });
79
-
80
- describe('Error Handling', () => {
81
- it('should handle API errors gracefully', async () => {
82
- (global.fetch as any).mockRejectedValue(new Error('Network error'));
83
-
84
- const analysis = await analyzer.analyzeViolation(mockViolation);
85
-
86
- expect(analysis.confidence).toBe(0.3); // Fallback confidence
87
- expect(analysis.plainEnglish).toContain('Analysis unavailable');
88
- expect(analysis.fixStrategy).toBe('progressive enhancement');
89
- });
90
-
91
- it('should handle invalid API responses', async () => {
92
- const mockResponse = {
93
- ok: true,
94
- json: () => Promise.resolve({ candidates: [] })
95
- };
96
-
97
- (global.fetch as any).mockResolvedValue(mockResponse);
98
-
99
- const analysis = await analyzer.analyzeViolation(mockViolation);
100
-
101
- expect(analysis.confidence).toBe(0.3);
102
- expect(analysis.plainEnglish).toContain('Analysis unavailable');
103
- });
104
- });
105
-
106
- describe('Response Parsing', () => {
107
- it('should extract market share from response', async () => {
108
- const mockResponse = {
109
- ok: true,
110
- json: () => Promise.resolve({
111
- candidates: [{
112
- content: {
113
- parts: [{ text: 'This affects approximately 8.5% of users on Safari 15.' }]
114
- },
115
- groundingMetadata: {
116
- groundingChunks: [
117
- { web: { uri: 'https://caniuse.com/css-container-queries' } }
118
- ]
119
- }
120
- }]
121
- })
122
- };
123
-
124
- (global.fetch as any).mockResolvedValue(mockResponse);
125
-
126
- const analysis = await analyzer.analyzeViolation(mockViolation);
127
-
128
- expect(analysis.marketShare).toBe(0.085);
129
- expect(analysis.sources).toContain('https://caniuse.com/css-container-queries');
130
- });
131
-
132
- it('should extract best practices from response', async () => {
133
- const mockResponse = {
134
- ok: true,
135
- json: () => Promise.resolve({
136
- candidates: [{
137
- content: {
138
- parts: [{
139
- text: 'Use @supports for feature detection. Consider using polyfills. Test across target browsers.'
140
- }]
141
- },
142
- groundingMetadata: { groundingChunks: [] }
143
- }]
144
- })
145
- };
146
-
147
- (global.fetch as any).mockResolvedValue(mockResponse);
148
-
149
- const analysis = await analyzer.analyzeViolation(mockViolation);
150
-
151
- expect(analysis.bestPractices).toContain('Use @supports for feature detection');
152
- expect(analysis.bestPractices).toContain('Consider using polyfills');
153
- expect(analysis.bestPractices).toContain('Test across target browsers');
154
- });
155
- });
156
-
157
- describe('Batch Processing', () => {
158
- it('should process multiple violations with concurrency control', async () => {
159
- const mockResponse = {
160
- ok: true,
161
- json: () => Promise.resolve({
162
- candidates: [{
163
- content: {
164
- parts: [{ text: 'Test analysis response.' }]
165
- },
166
- groundingMetadata: { groundingChunks: [] }
167
- }]
168
- })
169
- };
170
-
171
- (global.fetch as any).mockResolvedValue(mockResponse);
172
-
173
- const violations = [mockViolation, { ...mockViolation, feature: 'dialog' }];
174
- const analyses = await analyzer.analyzeViolations(violations, 2);
175
-
176
- expect(analyses).toHaveLength(2);
177
- expect(analyses[0].violation.feature).toBe('container-type');
178
- expect(analyses[1].violation.feature).toBe('dialog');
179
- });
180
- });
181
- });