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,298 +0,0 @@
1
- import { UIComponents } from '../ui/index.js';
2
- import { BaseGuard } from '../core/baseguard.js';
3
- import { ConfigurationManager } from '../core/configuration.js';
4
- import { ConfigurationRecovery } from '../core/configuration-recovery.js';
5
- import { GracefulDegradationManager } from '../core/graceful-degradation-manager.js';
6
- import { SystemErrorHandler } from '../core/system-error-handler.js';
7
- import { ErrorHandler } from '../core/error-handler.js';
8
- import { logger } from '../core/debug-logger.js';
9
- import { glob } from 'glob';
10
- import chalk from 'chalk';
11
-
12
- /**
13
- * Check for compatibility violations with enhanced error recovery
14
- */
15
- export async function check(options: {
16
- strict?: boolean;
17
- files?: string;
18
- format?: 'table' | 'json' | 'junit';
19
- debug?: boolean;
20
- offline?: boolean;
21
- }): Promise<void> {
22
- const categoryLogger = logger.createCategoryLogger('check-command');
23
- logger.startSession('check-command');
24
-
25
- try {
26
- // Enable debug logging if requested
27
- if (options.debug) {
28
- logger.enableDebug();
29
- }
30
-
31
- // Set offline mode if requested
32
- if (options.offline) {
33
- SystemErrorHandler.setOfflineMode(true);
34
- }
35
-
36
- UIComponents.showHeader();
37
- categoryLogger.info('Starting compatibility check', { options });
38
-
39
- // Load configuration with recovery
40
- const config = await SystemErrorHandler.withRetry(
41
- async () => {
42
- try {
43
- return await ConfigurationManager.load();
44
- } catch (error) {
45
- categoryLogger.warn('Configuration load failed, attempting recovery', { error });
46
-
47
- // Attempt configuration recovery
48
- const recoveryResult = await ConfigurationRecovery.recoverConfiguration({
49
- createBackup: true,
50
- validateConfig: true,
51
- migrateVersion: true,
52
- repairCorruption: true,
53
- useDefaults: true
54
- });
55
-
56
- if (recoveryResult.success && recoveryResult.config) {
57
- if (recoveryResult.warnings.length > 0) {
58
- console.log(chalk.yellow('āš ļø Configuration was recovered with warnings:'));
59
- recoveryResult.warnings.forEach(warning => {
60
- console.log(chalk.yellow(` • ${warning}`));
61
- });
62
- }
63
- return recoveryResult.config;
64
- } else {
65
- throw new Error(`Configuration recovery failed: ${recoveryResult.errors.join(', ')}`);
66
- }
67
- }
68
- },
69
- { operation: 'load_configuration' },
70
- 2 // max retries
71
- );
72
-
73
- // Initialize BaseGuard with error handling
74
- const baseGuard = await SystemErrorHandler.handleGracefully(
75
- async () => new BaseGuard(config),
76
- null,
77
- { operation: 'initialize_baseguard' }
78
- );
79
-
80
- if (!baseGuard) {
81
- throw new Error('Failed to initialize BaseGuard');
82
- }
83
-
84
- const spinner = UIComponents.createSpinner('Scanning files for compatibility issues...');
85
- spinner.start();
86
-
87
- // Get files to check with error recovery
88
- const filePattern = options.files || '**/*.{js,jsx,ts,tsx,vue,svelte,css,html}';
89
- const files = await SystemErrorHandler.handleGracefully(
90
- async () => {
91
- return await glob(filePattern, {
92
- ignore: [
93
- 'node_modules/**',
94
- 'dist/**',
95
- 'build/**',
96
- '.git/**',
97
- '**/*.min.js',
98
- '**/*.min.css'
99
- ]
100
- });
101
- },
102
- [], // fallback to empty array
103
- { operation: 'find_files', details: { pattern: filePattern } }
104
- );
105
-
106
- if (files.length === 0) {
107
- spinner.fail('No files found to check');
108
-
109
- // Show degradation status if in limited mode
110
- const mode = GracefulDegradationManager.getCurrentMode();
111
- if (mode && mode.name !== 'Full Functionality') {
112
- console.log(chalk.yellow(`\nāš ļø Currently in ${mode.name} mode`));
113
- if (mode.limitations.length > 0) {
114
- console.log(chalk.yellow('Limitations:'));
115
- mode.limitations.forEach(limitation => {
116
- console.log(chalk.yellow(` • ${limitation}`));
117
- });
118
- }
119
- }
120
-
121
- UIComponents.showWarningBox('No files matched the pattern. Try adjusting the --files option.');
122
- return;
123
- }
124
-
125
- spinner.text = `Analyzing ${files.length} files...`;
126
- categoryLogger.info(`Found ${files.length} files to analyze`);
127
-
128
- // Scan for violations with enhanced error handling
129
- const violations = await SystemErrorHandler.handleGracefully(
130
- async () => {
131
- return await baseGuard.checkViolations(files);
132
- },
133
- [], // fallback to empty violations
134
- { operation: 'check_violations', details: { fileCount: files.length } },
135
- {
136
- logError: true,
137
- showWarning: true,
138
- attemptRecovery: true
139
- }
140
- );
141
-
142
- spinner.stop();
143
- categoryLogger.info(`Scan completed, found ${violations.length} violations`);
144
-
145
- // Display results based on format with error handling
146
- await SystemErrorHandler.handleGracefully(
147
- async () => {
148
- switch (options.format) {
149
- case 'json':
150
- console.log(JSON.stringify(violations, null, 2));
151
- break;
152
- case 'junit':
153
- UIComponents.showJUnitReport(violations);
154
- break;
155
- default:
156
- UIComponents.showViolations(violations);
157
- break;
158
- }
159
- },
160
- undefined,
161
- { operation: 'display_results', details: { format: options.format, violationCount: violations.length } },
162
- { logError: true, showWarning: false }
163
- );
164
-
165
- // Show summary with degradation mode info
166
- if (violations.length === 0) {
167
- UIComponents.showSuccessBox('šŸŽ‰ No compatibility violations found!');
168
-
169
- // Show mode info if not in full functionality
170
- const mode = GracefulDegradationManager.getCurrentMode();
171
- if (mode && mode.name !== 'Full Functionality') {
172
- console.log(chalk.dim(`\nScan completed in ${mode.name} mode`));
173
- }
174
- } else {
175
- const summary = {
176
- total: violations.length,
177
- byBrowser: violations.reduce((acc, v) => {
178
- acc[v.browser] = (acc[v.browser] || 0) + 1;
179
- return acc;
180
- }, {} as Record<string, number>),
181
- byFile: violations.reduce((acc, v) => {
182
- acc[v.file] = (acc[v.file] || 0) + 1;
183
- return acc;
184
- }, {} as Record<string, number>)
185
- };
186
-
187
- console.log(chalk.yellow('\nšŸ“Š Summary:'));
188
- console.log(` Total violations: ${summary.total}`);
189
- console.log(` Files affected: ${Object.keys(summary.byFile).length}`);
190
- console.log(` Browsers affected: ${Object.keys(summary.byBrowser).join(', ')}`);
191
-
192
- // Show appropriate next steps based on current mode
193
- const mode = GracefulDegradationManager.getCurrentMode();
194
- if (mode?.capabilities.autoFix) {
195
- UIComponents.showInfoBox('Run "base fix" to automatically fix these issues with AI assistance.');
196
- } else {
197
- UIComponents.showInfoBox('AI fixing is not available in current mode. Review violations manually or restore full functionality.');
198
- }
199
-
200
- if (mode && mode.name !== 'Full Functionality') {
201
- console.log(chalk.dim(`\nScan completed in ${mode.name} mode`));
202
- if (mode.limitations.length > 0) {
203
- console.log(chalk.yellow('Current limitations:'));
204
- mode.limitations.forEach(limitation => {
205
- console.log(chalk.yellow(` • ${limitation}`));
206
- });
207
- }
208
- }
209
- }
210
-
211
- // Create auto-backup if violations found
212
- if (violations.length > 0) {
213
- await SystemErrorHandler.handleGracefully(
214
- async () => {
215
- const backup = await baseGuard.createConfigBackup();
216
- if (backup) {
217
- categoryLogger.debug('Created configuration backup', { backup });
218
- }
219
- },
220
- undefined,
221
- { operation: 'create_backup' },
222
- { logError: false, showWarning: false }
223
- );
224
- }
225
-
226
- // Exit with error code if violations found and strict mode
227
- if (options.strict && violations.length > 0) {
228
- process.exit(1);
229
- }
230
-
231
- } catch (error) {
232
- categoryLogger.error('Check command failed', { error });
233
-
234
- const apiError = ErrorHandler.handleAPIError(error);
235
- ErrorHandler.displayError(apiError);
236
-
237
- // Handle service failures gracefully
238
- if (ErrorHandler.shouldUseFallbackMode(apiError)) {
239
- await GracefulDegradationManager.handleServiceFailure('check', apiError.type);
240
- }
241
-
242
- // Provide specific help for check command issues
243
- console.log('\nšŸ’” Troubleshooting:');
244
- if (apiError.type === 'configuration') {
245
- UIComponents.showList([
246
- 'Run "base init" to set up BaseGuard configuration',
247
- 'Run "base config recover" to attempt automatic recovery',
248
- 'Check that .baseguardrc.json exists and is valid',
249
- 'Run "base config validate" to check configuration'
250
- ]);
251
- } else if (options.files) {
252
- UIComponents.showList([
253
- `No files found matching pattern: ${options.files}`,
254
- 'Try a different file pattern (e.g., "src/**/*.ts")',
255
- 'Check that files exist in the specified locations',
256
- 'Use --debug flag for detailed logging'
257
- ]);
258
- } else {
259
- UIComponents.showList([
260
- 'Check that you\'re in a project directory',
261
- 'Verify file permissions for reading project files',
262
- 'Try running with a specific file pattern: --files "src/**/*.js"',
263
- 'Use --offline flag if network issues are suspected',
264
- 'Use --debug flag for detailed error information'
265
- ]);
266
- }
267
-
268
- // Show fallback suggestions
269
- if (ErrorHandler.shouldUseFallbackMode(apiError)) {
270
- console.log('\nšŸ”„ Fallback options:');
271
- UIComponents.showList(ErrorHandler.getFallbackSuggestions(apiError.type));
272
- }
273
-
274
- // Show recovery options
275
- console.log('\nšŸ”§ Recovery options:');
276
- UIComponents.showList([
277
- 'Run "base status" to check system health',
278
- 'Run "base config recover" to fix configuration issues',
279
- 'Run with --debug flag to get detailed error information',
280
- 'Check logs in .baseguard/logs/ for more details'
281
- ]);
282
-
283
- // Generate debug report if in debug mode
284
- if (options.debug) {
285
- try {
286
- const reportFile = await logger.generateDebugReport();
287
- console.log(chalk.dim(`\nDebug report saved to: ${reportFile}`));
288
- } catch (reportError) {
289
- // Ignore report generation errors
290
- }
291
- }
292
-
293
- process.exit(1);
294
- } finally {
295
- // End logging session
296
- await logger.endSession();
297
- }
298
- }