baseguard 1.0.4 → 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 (84) 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/dist/commands/fix.d.ts.map +1 -1
  12. package/dist/commands/fix.js +5 -1
  13. package/dist/commands/fix.js.map +1 -1
  14. package/dist/core/baseline-checker.d.ts.map +1 -1
  15. package/dist/core/baseline-checker.js +6 -4
  16. package/dist/core/baseline-checker.js.map +1 -1
  17. package/package.json +1 -1
  18. package/src/ai/__tests__/gemini-analyzer.test.ts +0 -181
  19. package/src/ai/agentkit-orchestrator.ts +0 -534
  20. package/src/ai/fix-manager.ts +0 -362
  21. package/src/ai/gemini-analyzer.ts +0 -665
  22. package/src/ai/gemini-code-fixer.ts +0 -539
  23. package/src/ai/index.ts +0 -4
  24. package/src/ai/jules-implementer.ts +0 -504
  25. package/src/ai/unified-code-fixer.ts +0 -347
  26. package/src/commands/automation.ts +0 -344
  27. package/src/commands/check.ts +0 -298
  28. package/src/commands/config.ts +0 -584
  29. package/src/commands/fix.ts +0 -264
  30. package/src/commands/index.ts +0 -7
  31. package/src/commands/init.ts +0 -156
  32. package/src/commands/status.ts +0 -307
  33. package/src/core/api-key-manager.ts +0 -298
  34. package/src/core/baseguard.ts +0 -757
  35. package/src/core/baseline-checker.ts +0 -564
  36. package/src/core/cache-manager.ts +0 -272
  37. package/src/core/configuration-recovery.ts +0 -672
  38. package/src/core/configuration.ts +0 -596
  39. package/src/core/debug-logger.ts +0 -590
  40. package/src/core/directory-filter.ts +0 -421
  41. package/src/core/error-handler.ts +0 -518
  42. package/src/core/file-processor.ts +0 -338
  43. package/src/core/gitignore-manager.ts +0 -169
  44. package/src/core/graceful-degradation-manager.ts +0 -596
  45. package/src/core/index.ts +0 -17
  46. package/src/core/lazy-loader.ts +0 -317
  47. package/src/core/logger.ts +0 -0
  48. package/src/core/memory-manager.ts +0 -290
  49. package/src/core/parser-worker.ts +0 -33
  50. package/src/core/startup-optimizer.ts +0 -246
  51. package/src/core/system-error-handler.ts +0 -755
  52. package/src/git/automation-engine.ts +0 -361
  53. package/src/git/github-manager.ts +0 -190
  54. package/src/git/hook-manager.ts +0 -210
  55. package/src/git/index.ts +0 -4
  56. package/src/index.ts +0 -8
  57. package/src/parsers/feature-validator.ts +0 -559
  58. package/src/parsers/index.ts +0 -8
  59. package/src/parsers/parser-manager.ts +0 -418
  60. package/src/parsers/parser.ts +0 -26
  61. package/src/parsers/react-parser-optimized.ts +0 -161
  62. package/src/parsers/react-parser.ts +0 -359
  63. package/src/parsers/svelte-parser.ts +0 -510
  64. package/src/parsers/vanilla-parser.ts +0 -685
  65. package/src/parsers/vue-parser.ts +0 -476
  66. package/src/types/index.ts +0 -96
  67. package/src/ui/components.ts +0 -567
  68. package/src/ui/help.ts +0 -193
  69. package/src/ui/index.ts +0 -4
  70. package/src/ui/prompts.ts +0 -681
  71. package/src/ui/terminal-header.ts +0 -59
  72. package/tests/e2e/baseguard.e2e.test.ts +0 -516
  73. package/tests/e2e/cross-platform.e2e.test.ts +0 -420
  74. package/tests/e2e/git-integration.e2e.test.ts +0 -487
  75. package/tests/fixtures/react-project/package.json +0 -14
  76. package/tests/fixtures/react-project/src/App.css +0 -76
  77. package/tests/fixtures/react-project/src/App.tsx +0 -77
  78. package/tests/fixtures/svelte-project/package.json +0 -11
  79. package/tests/fixtures/svelte-project/src/App.svelte +0 -369
  80. package/tests/fixtures/vanilla-project/index.html +0 -76
  81. package/tests/fixtures/vanilla-project/script.js +0 -331
  82. package/tests/fixtures/vanilla-project/styles.css +0 -359
  83. package/tests/fixtures/vue-project/package.json +0 -12
  84. package/tests/fixtures/vue-project/src/App.vue +0 -216
@@ -1,246 +0,0 @@
1
- /**
2
- * Startup optimization manager to minimize initialization time and memory usage
3
- */
4
- export class StartupOptimizer {
5
- private static startTime = Date.now();
6
- private static initialized = false;
7
- private static gcInterval: NodeJS.Timeout | null = null;
8
- private static memoryInterval: NodeJS.Timeout | null = null;
9
-
10
- /**
11
- * Initialize BaseGuard with optimized startup
12
- */
13
- static async initialize(): Promise<void> {
14
- if (this.initialized) {
15
- return;
16
- }
17
-
18
- const startTime = Date.now();
19
-
20
- try {
21
- // Start critical dependency loading in background
22
- await this.preloadCriticalDependencies();
23
-
24
- // Initialize memory management
25
- this.setupMemoryOptimizations();
26
-
27
- this.initialized = true;
28
-
29
- const initTime = Date.now() - startTime;
30
- if (initTime > 1000) {
31
- console.warn(`Slow startup detected: ${initTime}ms`);
32
- }
33
- } catch (error) {
34
- console.warn('Startup optimization failed:', error);
35
- this.initialized = true; // Continue anyway
36
- }
37
- }
38
-
39
- /**
40
- * Preload critical dependencies without blocking
41
- */
42
- private static async preloadCriticalDependencies(): Promise<void> {
43
- // Start loading critical dependencies in parallel
44
- const criticalLoads = [
45
- LazyLoader.getWebFeatures().catch(() => {}),
46
- LazyLoader.getBabelParser().catch(() => {})
47
- ];
48
-
49
- // Don't wait for all to complete - just start the loading process
50
- Promise.all(criticalLoads);
51
- }
52
-
53
- /**
54
- * Setup memory optimizations
55
- */
56
- private static setupMemoryOptimizations(): void {
57
- // Enable garbage collection hints if available
58
- if (global.gc) {
59
- // Set up periodic GC for long-running processes
60
- this.gcInterval = setInterval(() => {
61
- const memCheck = MemoryManager.checkMemoryUsage();
62
-
63
- if (memCheck.warning) {
64
- MemoryManager.tryGarbageCollect();
65
- }
66
- }, 30000); // Check every 30 seconds
67
- this.gcInterval.unref();
68
- }
69
-
70
- // Setup process memory monitoring
71
- process.on('warning', (warning) => {
72
- if (warning.name === 'MaxListenersExceededWarning') {
73
- console.warn('Memory warning: Too many event listeners');
74
- }
75
- });
76
- }
77
-
78
- /**
79
- * Get startup performance metrics
80
- */
81
- static getStartupMetrics(): {
82
- totalStartupTime: number;
83
- memoryUsage: NodeJS.MemoryUsage;
84
- nodeVersion: string;
85
- platform: string;
86
- } {
87
- return {
88
- totalStartupTime: Date.now() - this.startTime,
89
- memoryUsage: process.memoryUsage(),
90
- nodeVersion: process.version,
91
- platform: process.platform
92
- };
93
- }
94
-
95
- /**
96
- * Optimize for specific use cases
97
- */
98
- static async optimizeForUseCase(useCase: 'check' | 'fix' | 'init'): Promise<void> {
99
- switch (useCase) {
100
- case 'check':
101
- // Preload parsing and baseline checking dependencies
102
- LazyLoader.getWebFeatures().catch(() => {});
103
- LazyLoader.getBabelParser().catch(() => {});
104
- LazyLoader.getPostCSS().catch(() => {});
105
- break;
106
-
107
- case 'fix':
108
- // Preload all dependencies including AI services
109
- LazyLoader.preloadCommon();
110
- break;
111
-
112
- case 'init':
113
- // Minimal loading for initialization
114
- break;
115
- }
116
- }
117
-
118
- /**
119
- * Clean up resources and optimize memory
120
- */
121
- static cleanup(): void {
122
- // Clear intervals
123
- if (this.gcInterval) {
124
- clearInterval(this.gcInterval);
125
- this.gcInterval = null;
126
- }
127
- if (this.memoryInterval) {
128
- clearInterval(this.memoryInterval);
129
- this.memoryInterval = null;
130
- }
131
-
132
- // Clear caches
133
- LazyLoader.clearCache();
134
-
135
- // Force garbage collection if available
136
- MemoryManager.tryGarbageCollect();
137
- }
138
-
139
- /**
140
- * Check if startup optimizations are working
141
- */
142
- static validateOptimizations(): {
143
- isOptimized: boolean;
144
- issues: string[];
145
- recommendations: string[];
146
- } {
147
- const issues: string[] = [];
148
- const recommendations: string[] = [];
149
-
150
- const metrics = this.getStartupMetrics();
151
-
152
- // Check startup time
153
- if (metrics.totalStartupTime > 2000) {
154
- issues.push(`Slow startup: ${metrics.totalStartupTime}ms`);
155
- recommendations.push('Consider reducing dependencies or using lazy loading');
156
- }
157
-
158
- // Check memory usage
159
- const heapUsedMB = metrics.memoryUsage.heapUsed / 1024 / 1024;
160
- if (heapUsedMB > 50) {
161
- issues.push(`High memory usage: ${Math.round(heapUsedMB)}MB`);
162
- recommendations.push('Consider optimizing data structures or clearing caches');
163
- }
164
-
165
- // Check Node.js version
166
- const nodeVersion = parseInt(metrics.nodeVersion.slice(1));
167
- if (nodeVersion < 18) {
168
- issues.push(`Old Node.js version: ${metrics.nodeVersion}`);
169
- recommendations.push('Upgrade to Node.js 18+ for better performance');
170
- }
171
-
172
- return {
173
- isOptimized: issues.length === 0,
174
- issues,
175
- recommendations
176
- };
177
- }
178
-
179
- /**
180
- * Optimize memory usage by reducing object overhead
181
- */
182
- static optimizeMemoryUsage(): void {
183
- // Enable V8 memory optimizations if available
184
- if (process.env.NODE_ENV !== 'development') {
185
- // Set V8 flags for better memory management
186
- process.env.NODE_OPTIONS = (process.env.NODE_OPTIONS || '') + ' --max-old-space-size=512 --optimize-for-size';
187
- }
188
-
189
- // Setup memory monitoring
190
- if (global.gc) {
191
- this.memoryInterval = setInterval(() => {
192
- const usage = process.memoryUsage();
193
- const heapUsedMB = usage.heapUsed / 1024 / 1024;
194
-
195
- // Force GC if memory usage is high
196
- if (heapUsedMB > 100 && global.gc) {
197
- global.gc();
198
- }
199
- }, 30000);
200
- this.memoryInterval.unref();
201
- }
202
- }
203
-
204
- /**
205
- * Reduce startup time by deferring non-critical operations
206
- */
207
- static async deferNonCriticalOperations(): Promise<void> {
208
- // Defer heavy operations until after startup
209
- setTimeout(async () => {
210
- try {
211
- // Preload remaining dependencies
212
- const { LazyLoader } = await import('./lazy-loader.js');
213
- LazyLoader.preloadCommon();
214
-
215
- // Initialize caches
216
- // Cleanup old logs
217
- const { logger } = await import('./debug-logger.js');
218
- logger.cleanupOldLogs().catch(() => {});
219
- } catch (error) {
220
- // Ignore errors in deferred operations
221
- }
222
- }, 100); // Defer by 100ms
223
- }
224
-
225
- /**
226
- * Optimize startup by preloading critical dependencies
227
- */
228
- static async optimizeStartup(): Promise<void> {
229
- // Start loading critical dependencies in background
230
- const criticalLoads = [
231
- LazyLoader.getWebFeatures().catch(() => {}),
232
- LazyLoader.getBabelParser().catch(() => {})
233
- ];
234
-
235
- // Don't wait for all to complete, just start the process
236
- Promise.all(criticalLoads);
237
-
238
- // Setup memory optimizations
239
- this.optimizeMemoryUsage();
240
-
241
- // Defer non-critical operations
242
- this.deferNonCriticalOperations();
243
- }
244
- }
245
- import { LazyLoader } from './lazy-loader.js';
246
- import { MemoryManager } from './memory-manager.js';