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,272 +0,0 @@
1
- import { createHash } from 'crypto';
2
- import { stat } from 'fs/promises';
3
- import type { DetectedFeature } from '../types/index.js';
4
-
5
- /**
6
- * LRU Cache implementation for web-features data and parsing results
7
- */
8
- export class LRUCache<K, V> {
9
- private cache = new Map<K, V>();
10
- private readonly maxSize: number;
11
-
12
- constructor(maxSize: number = 1000) {
13
- this.maxSize = maxSize;
14
- }
15
-
16
- get(key: K): V | undefined {
17
- const value = this.cache.get(key);
18
- if (value !== undefined) {
19
- // Move to end (most recently used)
20
- this.cache.delete(key);
21
- this.cache.set(key, value);
22
- }
23
- return value;
24
- }
25
-
26
- set(key: K, value: V): void {
27
- if (this.cache.has(key)) {
28
- this.cache.delete(key);
29
- } else if (this.cache.size >= this.maxSize) {
30
- // Remove least recently used (first item)
31
- const firstKey = this.cache.keys().next().value as K;
32
- if (firstKey !== undefined) {
33
- this.cache.delete(firstKey);
34
- }
35
- }
36
- this.cache.set(key, value);
37
- }
38
-
39
- has(key: K): boolean {
40
- return this.cache.has(key);
41
- }
42
-
43
- clear(): void {
44
- this.cache.clear();
45
- }
46
-
47
- size(): number {
48
- return this.cache.size;
49
- }
50
- }
51
-
52
- /**
53
- * File metadata for incremental scanning
54
- */
55
- interface FileMetadata {
56
- path: string;
57
- mtime: number;
58
- size: number;
59
- hash: string;
60
- }
61
-
62
- /**
63
- * Cached parsing result
64
- */
65
- interface CachedResult {
66
- features: DetectedFeature[];
67
- metadata: FileMetadata;
68
- timestamp: number;
69
- }
70
-
71
- /**
72
- * Cache manager for efficient file processing and incremental scanning
73
- */
74
- export class CacheManager {
75
- private readonly parseCache: LRUCache<string, CachedResult>;
76
- private readonly webFeaturesCache: LRUCache<string, any>;
77
- private readonly fileMetadataCache: Map<string, FileMetadata>;
78
- private readonly maxCacheSize: number;
79
- private readonly cacheValidityMs: number;
80
-
81
- constructor(options: {
82
- maxCacheSize?: number;
83
- cacheValidityMs?: number;
84
- } = {}) {
85
- this.maxCacheSize = options.maxCacheSize || 1000;
86
- this.cacheValidityMs = options.cacheValidityMs || 5 * 60 * 1000; // 5 minutes
87
- this.parseCache = new LRUCache(this.maxCacheSize);
88
- this.webFeaturesCache = new LRUCache(500);
89
- this.fileMetadataCache = new Map();
90
- }
91
-
92
- /**
93
- * Get cached parsing result if file hasn't changed
94
- */
95
- async getCachedParseResult(filePath: string): Promise<DetectedFeature[] | null> {
96
- try {
97
- const currentMetadata = await this.getFileMetadata(filePath);
98
- const cached = this.parseCache.get(filePath);
99
-
100
- if (!cached) {
101
- return null;
102
- }
103
-
104
- // Check if file has changed
105
- if (this.hasFileChanged(cached.metadata, currentMetadata)) {
106
- this.parseCache.set(filePath, { ...cached, metadata: currentMetadata });
107
- return null;
108
- }
109
-
110
- // Check cache validity
111
- if (Date.now() - cached.timestamp > this.cacheValidityMs) {
112
- return null;
113
- }
114
-
115
- return cached.features;
116
- } catch (error) {
117
- // File doesn't exist or can't be accessed
118
- return null;
119
- }
120
- }
121
-
122
- /**
123
- * Cache parsing result
124
- */
125
- async setCachedParseResult(filePath: string, features: DetectedFeature[]): Promise<void> {
126
- try {
127
- const metadata = await this.getFileMetadata(filePath);
128
- const cached: CachedResult = {
129
- features,
130
- metadata,
131
- timestamp: Date.now()
132
- };
133
-
134
- this.parseCache.set(filePath, cached);
135
- this.fileMetadataCache.set(filePath, metadata);
136
- } catch (error) {
137
- // Ignore caching errors
138
- }
139
- }
140
-
141
- /**
142
- * Get cached web-features data
143
- */
144
- getCachedWebFeature(featureId: string): any | null {
145
- return this.webFeaturesCache.get(featureId) || null;
146
- }
147
-
148
- /**
149
- * Cache web-features data
150
- */
151
- setCachedWebFeature(featureId: string, data: any): void {
152
- this.webFeaturesCache.set(featureId, data);
153
- }
154
-
155
- /**
156
- * Check if files have changed since last scan
157
- */
158
- async getChangedFiles(filePaths: string[]): Promise<{
159
- changed: string[];
160
- unchanged: string[];
161
- }> {
162
- const changed: string[] = [];
163
- const unchanged: string[] = [];
164
-
165
- await Promise.all(
166
- filePaths.map(async (filePath) => {
167
- try {
168
- const currentMetadata = await this.getFileMetadata(filePath);
169
- const cachedMetadata = this.fileMetadataCache.get(filePath);
170
-
171
- if (!cachedMetadata || this.hasFileChanged(cachedMetadata, currentMetadata)) {
172
- changed.push(filePath);
173
- this.fileMetadataCache.set(filePath, currentMetadata);
174
- } else {
175
- unchanged.push(filePath);
176
- }
177
- } catch (error) {
178
- // File doesn't exist or can't be accessed, consider it changed
179
- changed.push(filePath);
180
- }
181
- })
182
- );
183
-
184
- return { changed, unchanged };
185
- }
186
-
187
- /**
188
- * Clear all caches
189
- */
190
- clearAll(): void {
191
- this.parseCache.clear();
192
- this.webFeaturesCache.clear();
193
- this.fileMetadataCache.clear();
194
- }
195
-
196
- /**
197
- * Clear expired cache entries
198
- */
199
- clearExpired(): void {
200
- const now = Date.now();
201
- const expiredKeys: string[] = [];
202
-
203
- // Find expired parse cache entries
204
- for (const [key, value] of this.parseCache['cache']) {
205
- if (now - value.timestamp > this.cacheValidityMs) {
206
- expiredKeys.push(key);
207
- }
208
- }
209
-
210
- // Remove expired entries
211
- expiredKeys.forEach(key => {
212
- this.parseCache['cache'].delete(key);
213
- this.fileMetadataCache.delete(key);
214
- });
215
- }
216
-
217
- /**
218
- * Get cache statistics
219
- */
220
- getStats(): {
221
- parseCache: { size: number; maxSize: number };
222
- webFeaturesCache: { size: number; maxSize: number };
223
- fileMetadataCache: { size: number };
224
- } {
225
- return {
226
- parseCache: {
227
- size: this.parseCache.size(),
228
- maxSize: this.maxCacheSize
229
- },
230
- webFeaturesCache: {
231
- size: this.webFeaturesCache.size(),
232
- maxSize: 500
233
- },
234
- fileMetadataCache: {
235
- size: this.fileMetadataCache.size
236
- }
237
- };
238
- }
239
-
240
- /**
241
- * Get file metadata for change detection
242
- */
243
- private async getFileMetadata(filePath: string): Promise<FileMetadata> {
244
- const stats = await stat(filePath);
245
- const hash = this.generateFileHash(filePath, stats.mtime.getTime(), stats.size);
246
-
247
- return {
248
- path: filePath,
249
- mtime: stats.mtime.getTime(),
250
- size: stats.size,
251
- hash
252
- };
253
- }
254
-
255
- /**
256
- * Check if file has changed based on metadata
257
- */
258
- private hasFileChanged(cached: FileMetadata, current: FileMetadata): boolean {
259
- return cached.mtime !== current.mtime ||
260
- cached.size !== current.size ||
261
- cached.hash !== current.hash;
262
- }
263
-
264
- /**
265
- * Generate hash for file identification
266
- */
267
- private generateFileHash(filePath: string, mtime: number, size: number): string {
268
- return createHash('md5')
269
- .update(`${filePath}:${mtime}:${size}`)
270
- .digest('hex');
271
- }
272
- }