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,421 +0,0 @@
1
- import { readdir, stat } from 'fs/promises';
2
- import { join, basename, extname } from 'path';
3
- import { glob } from 'glob';
4
-
5
- /**
6
- * Smart directory filtering to skip node_modules and build outputs
7
- */
8
- export class DirectoryFilter {
9
- private readonly defaultExcludePatterns: string[] = [
10
- 'node_modules',
11
- '.git',
12
- '.svn',
13
- '.hg',
14
- 'dist',
15
- 'build',
16
- 'out',
17
- '.next',
18
- '.nuxt',
19
- '.output',
20
- 'coverage',
21
- '.nyc_output',
22
- '.cache',
23
- '.parcel-cache',
24
- '.vscode',
25
- '.idea',
26
- '*.log',
27
- '*.tmp',
28
- '*.temp',
29
- '.DS_Store',
30
- 'Thumbs.db'
31
- ];
32
-
33
- private readonly defaultIncludeExtensions: string[] = [
34
- '.js',
35
- '.jsx',
36
- '.ts',
37
- '.tsx',
38
- '.vue',
39
- '.svelte',
40
- '.css',
41
- '.scss',
42
- '.sass',
43
- '.less',
44
- '.html',
45
- '.htm'
46
- ];
47
-
48
- private readonly excludePatterns: Set<string>;
49
- private readonly includeExtensions: Set<string>;
50
- private readonly maxDepth: number;
51
- private readonly maxFiles: number;
52
-
53
- constructor(options: {
54
- excludePatterns?: string[];
55
- includeExtensions?: string[];
56
- maxDepth?: number;
57
- maxFiles?: number;
58
- } = {}) {
59
- this.excludePatterns = new Set([
60
- ...this.defaultExcludePatterns,
61
- ...(options.excludePatterns || [])
62
- ]);
63
-
64
- this.includeExtensions = new Set(
65
- options.includeExtensions || this.defaultIncludeExtensions
66
- );
67
-
68
- this.maxDepth = options.maxDepth || 10;
69
- this.maxFiles = options.maxFiles || 10000;
70
- }
71
-
72
- /**
73
- * Find files recursively with smart filtering
74
- */
75
- async findFiles(
76
- directories: string[],
77
- options: {
78
- patterns?: string[];
79
- excludePatterns?: string[];
80
- includeHidden?: boolean;
81
- } = {}
82
- ): Promise<string[]> {
83
- const {
84
- patterns = [],
85
- excludePatterns = [],
86
- includeHidden = false
87
- } = options;
88
-
89
- const allExcludePatterns = new Set([
90
- ...this.excludePatterns,
91
- ...excludePatterns
92
- ]);
93
-
94
- const files: string[] = [];
95
- const processedDirs = new Set<string>();
96
-
97
- for (const directory of directories) {
98
- try {
99
- await this.findFilesRecursive(
100
- directory,
101
- files,
102
- allExcludePatterns,
103
- patterns,
104
- includeHidden,
105
- 0,
106
- processedDirs
107
- );
108
- } catch (error) {
109
- console.warn(`Could not scan directory ${directory}: ${error instanceof Error ? error.message : 'Unknown error'}`);
110
- }
111
-
112
- // Stop if we've found too many files
113
- if (files.length >= this.maxFiles) {
114
- console.warn(`Reached maximum file limit (${this.maxFiles}). Some files may be skipped.`);
115
- break;
116
- }
117
- }
118
-
119
- return files.slice(0, this.maxFiles);
120
- }
121
-
122
- /**
123
- * Find files using glob patterns (faster for specific patterns)
124
- */
125
- async findFilesWithGlob(
126
- patterns: string[],
127
- options: {
128
- cwd?: string;
129
- excludePatterns?: string[];
130
- } = {}
131
- ): Promise<string[]> {
132
- const { cwd = process.cwd(), excludePatterns = [] } = options;
133
-
134
- try {
135
- const allFiles = await glob(patterns, {
136
- cwd,
137
- ignore: [
138
- ...Array.from(this.excludePatterns),
139
- ...excludePatterns
140
- ],
141
- absolute: true,
142
- nodir: true
143
- });
144
-
145
- // Filter by supported extensions
146
- return allFiles.filter(file => this.isSupportedFile(file));
147
- } catch (error) {
148
- console.error(`Glob search failed: ${error instanceof Error ? error.message : 'Unknown error'}`);
149
- return [];
150
- }
151
- }
152
-
153
- /**
154
- * Check if a file should be processed
155
- */
156
- isSupportedFile(filePath: string): boolean {
157
- const extension = extname(filePath).toLowerCase();
158
- return this.includeExtensions.has(extension);
159
- }
160
-
161
- /**
162
- * Check if a directory should be excluded
163
- */
164
- isExcludedDirectory(dirPath: string): boolean {
165
- const dirName = basename(dirPath);
166
-
167
- // Check exact matches
168
- if (this.excludePatterns.has(dirName)) {
169
- return true;
170
- }
171
-
172
- // Check pattern matches
173
- for (const pattern of this.excludePatterns) {
174
- if (pattern.includes('*') || pattern.includes('?')) {
175
- // Simple glob pattern matching
176
- const regex = new RegExp(
177
- pattern
178
- .replace(/\*/g, '.*')
179
- .replace(/\?/g, '.')
180
- );
181
- if (regex.test(dirName)) {
182
- return true;
183
- }
184
- }
185
- }
186
-
187
- return false;
188
- }
189
-
190
- /**
191
- * Get file statistics for a directory
192
- */
193
- async getDirectoryStats(directoryPath: string): Promise<{
194
- totalFiles: number;
195
- supportedFiles: number;
196
- directories: number;
197
- excludedDirectories: number;
198
- largestFiles: Array<{ path: string; size: number }>;
199
- }> {
200
- const stats = {
201
- totalFiles: 0,
202
- supportedFiles: 0,
203
- directories: 0,
204
- excludedDirectories: 0,
205
- largestFiles: [] as Array<{ path: string; size: number }>
206
- };
207
-
208
- try {
209
- await this.collectStats(directoryPath, stats, 0);
210
- } catch (error) {
211
- console.warn(`Could not collect stats for ${directoryPath}: ${error instanceof Error ? error.message : 'Unknown error'}`);
212
- }
213
-
214
- // Sort largest files
215
- stats.largestFiles.sort((a, b) => b.size - a.size);
216
- stats.largestFiles = stats.largestFiles.slice(0, 10);
217
-
218
- return stats;
219
- }
220
-
221
- /**
222
- * Recursive file finding with smart filtering
223
- */
224
- private async findFilesRecursive(
225
- currentPath: string,
226
- results: string[],
227
- excludePatterns: Set<string>,
228
- includePatterns: string[],
229
- includeHidden: boolean,
230
- currentDepth: number,
231
- processedDirs: Set<string>
232
- ): Promise<void> {
233
- // Prevent infinite loops with symlinks
234
- if (processedDirs.has(currentPath)) {
235
- return;
236
- }
237
- processedDirs.add(currentPath);
238
-
239
- // Check depth limit
240
- if (currentDepth >= this.maxDepth) {
241
- return;
242
- }
243
-
244
- // Check file limit
245
- if (results.length >= this.maxFiles) {
246
- return;
247
- }
248
-
249
- try {
250
- const entries = await readdir(currentPath);
251
-
252
- for (const entry of entries) {
253
- // Skip hidden files/directories unless explicitly included
254
- if (!includeHidden && entry.startsWith('.')) {
255
- continue;
256
- }
257
-
258
- const fullPath = join(currentPath, entry);
259
-
260
- try {
261
- const stats = await stat(fullPath);
262
-
263
- if (stats.isDirectory()) {
264
- // Check if directory should be excluded
265
- if (this.isExcludedDirectory(fullPath)) {
266
- continue;
267
- }
268
-
269
- // Recurse into directory
270
- await this.findFilesRecursive(
271
- fullPath,
272
- results,
273
- excludePatterns,
274
- includePatterns,
275
- includeHidden,
276
- currentDepth + 1,
277
- processedDirs
278
- );
279
- } else if (stats.isFile()) {
280
- // Check if file matches patterns
281
- if (this.shouldIncludeFile(fullPath, includePatterns)) {
282
- results.push(fullPath);
283
- }
284
- }
285
- } catch (error) {
286
- // Skip files/directories that can't be accessed
287
- continue;
288
- }
289
- }
290
- } catch (error) {
291
- console.warn(`Could not read directory ${currentPath}: ${error instanceof Error ? error.message : 'Unknown error'}`);
292
- }
293
- }
294
-
295
- /**
296
- * Check if file should be included based on patterns
297
- */
298
- private shouldIncludeFile(filePath: string, includePatterns: string[]): boolean {
299
- // If no specific patterns, use extension filtering
300
- if (includePatterns.length === 0) {
301
- return this.isSupportedFile(filePath);
302
- }
303
-
304
- // Check against include patterns
305
- const fileName = basename(filePath);
306
- return includePatterns.some(pattern => {
307
- if (pattern.includes('*') || pattern.includes('?')) {
308
- const regex = new RegExp(
309
- pattern
310
- .replace(/\*/g, '.*')
311
- .replace(/\?/g, '.')
312
- );
313
- return regex.test(fileName);
314
- }
315
- return fileName === pattern;
316
- });
317
- }
318
-
319
- /**
320
- * Collect directory statistics recursively
321
- */
322
- private async collectStats(
323
- currentPath: string,
324
- stats: any,
325
- currentDepth: number
326
- ): Promise<void> {
327
- if (currentDepth >= this.maxDepth) {
328
- return;
329
- }
330
-
331
- try {
332
- const entries = await readdir(currentPath);
333
-
334
- for (const entry of entries) {
335
- const fullPath = join(currentPath, entry);
336
-
337
- try {
338
- const fileStat = await stat(fullPath);
339
-
340
- if (fileStat.isDirectory()) {
341
- stats.directories++;
342
-
343
- if (this.isExcludedDirectory(fullPath)) {
344
- stats.excludedDirectories++;
345
- continue;
346
- }
347
-
348
- await this.collectStats(fullPath, stats, currentDepth + 1);
349
- } else if (fileStat.isFile()) {
350
- stats.totalFiles++;
351
-
352
- if (this.isSupportedFile(fullPath)) {
353
- stats.supportedFiles++;
354
- }
355
-
356
- // Track largest files
357
- if (stats.largestFiles.length < 100) {
358
- stats.largestFiles.push({
359
- path: fullPath,
360
- size: fileStat.size
361
- });
362
- }
363
- }
364
- } catch (error) {
365
- // Skip files/directories that can't be accessed
366
- continue;
367
- }
368
- }
369
- } catch (error) {
370
- // Skip directories that can't be read
371
- }
372
- }
373
-
374
- /**
375
- * Get supported extensions
376
- */
377
- getSupportedExtensions(): string[] {
378
- return Array.from(this.includeExtensions);
379
- }
380
-
381
- /**
382
- * Get exclude patterns
383
- */
384
- getExcludePatterns(): string[] {
385
- return Array.from(this.excludePatterns);
386
- }
387
-
388
- /**
389
- * Add custom exclude pattern
390
- */
391
- addExcludePattern(pattern: string): void {
392
- this.excludePatterns.add(pattern);
393
- }
394
-
395
- /**
396
- * Remove exclude pattern
397
- */
398
- removeExcludePattern(pattern: string): void {
399
- this.excludePatterns.delete(pattern);
400
- }
401
-
402
- /**
403
- * Add supported extension
404
- */
405
- addSupportedExtension(extension: string): void {
406
- if (!extension.startsWith('.')) {
407
- extension = '.' + extension;
408
- }
409
- this.includeExtensions.add(extension.toLowerCase());
410
- }
411
-
412
- /**
413
- * Remove supported extension
414
- */
415
- removeSupportedExtension(extension: string): void {
416
- if (!extension.startsWith('.')) {
417
- extension = '.' + extension;
418
- }
419
- this.includeExtensions.delete(extension.toLowerCase());
420
- }
421
- }