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,264 +0,0 @@
1
- import chalk from 'chalk';
2
- import { UIComponents } from '../ui/index.js';
3
- import { BaseGuard } from '../core/index.js';
4
- import { ConfigurationManager } from '../core/configuration.js';
5
- import { ErrorHandler } from '../core/error-handler.js';
6
- import { UnifiedCodeFixer } from '../ai/unified-code-fixer.js';
7
- import { GeminiAnalyzer } from '../ai/gemini-analyzer.js';
8
- import { FixManager } from '../ai/fix-manager.js';
9
- import { glob } from 'glob';
10
-
11
- /**
12
- * Fix violations with AI analysis and implementation
13
- */
14
- export async function fix(options: {
15
- auto?: boolean;
16
- analyzeOnly?: boolean;
17
- files?: string;
18
- }): Promise<void> {
19
- try {
20
- console.log(chalk.cyan('šŸ”§ BaseGuard AI Fix\n'));
21
-
22
- // Load configuration
23
- const config = await ConfigurationManager.load();
24
-
25
- // Initialize services
26
- const baseGuard = new BaseGuard(config);
27
- const unifiedCodeFixer = new UnifiedCodeFixer(config);
28
- const fixManager = new FixManager();
29
- const geminiAnalyzer = config.apiKeys.gemini ? new GeminiAnalyzer(config.apiKeys.gemini) : null;
30
-
31
- // Show agent status and recommendations
32
- console.log(chalk.cyan('šŸ¤– Coding Agent Status:'));
33
- const agentStatus = await unifiedCodeFixer.getAgentStatus();
34
-
35
- const primaryAvailable = agentStatus.primary === 'jules' ? agentStatus.jules.available : agentStatus.gemini.available;
36
- const fallbackAvailable = agentStatus.fallback === 'jules' ? agentStatus.jules.available : agentStatus.gemini.available;
37
-
38
- console.log(` Primary: ${agentStatus.primary} ${primaryAvailable ? 'āœ…' : 'āŒ'}`);
39
- console.log(` Fallback: ${agentStatus.fallback} ${fallbackAvailable ? 'āœ…' : 'āŒ'}`);
40
-
41
- if (!agentStatus.jules.configured && !agentStatus.gemini.configured) {
42
- console.log(chalk.red('\nāŒ No coding agents are available'));
43
- console.log(chalk.cyan('šŸ’” Configure API keys to enable code fixing:'));
44
- console.log(chalk.cyan(' • Run "base config set-keys" to configure API keys'));
45
- console.log(chalk.cyan(' • Get Gemini API key: https://aistudio.google.com'));
46
- console.log(chalk.cyan(' • Get Jules API key: https://jules.google.com/settings#api'));
47
- process.exit(1);
48
- }
49
-
50
- // Show agent-specific information
51
- if (agentStatus.primary === 'jules' && agentStatus.jules.repoDetected) {
52
- console.log(chalk.cyan('šŸ”— GitHub repository detected - Jules available for autonomous fixing'));
53
- } else if (agentStatus.primary === 'gemini' || !agentStatus.jules.repoDetected) {
54
- console.log(chalk.cyan('šŸ’Ž Using Gemini 2.5 Pro for local file fixing'));
55
- console.log(chalk.dim(' This works with any local files, no GitHub required'));
56
- }
57
-
58
- // Step 1: Check for violations
59
- console.log(chalk.cyan('šŸ” Scanning for compatibility violations...'));
60
-
61
- // Get files to fix
62
- const filePattern = options.files || '**/*.{js,jsx,ts,tsx,vue,svelte,css,html}';
63
- const files = await glob(filePattern, {
64
- ignore: [
65
- 'node_modules/**',
66
- 'dist/**',
67
- 'build/**',
68
- '.git/**',
69
- '**/*.min.js',
70
- '**/*.min.css'
71
- ]
72
- });
73
-
74
- const violations = await baseGuard.checkViolations(files);
75
-
76
- if (violations.length === 0) {
77
- UIComponents.showSuccessBox('No compatibility violations found!');
78
- return;
79
- }
80
-
81
- console.log(chalk.yellow(`\nāš ļø Found ${violations.length} compatibility violations\n`));
82
- UIComponents.showViolations(violations);
83
-
84
- // Step 2: Analyze violations with Gemini
85
- let analyses;
86
- if (geminiAnalyzer) {
87
- console.log(chalk.cyan('\n🧠 Analyzing violations with AI...'));
88
- analyses = await geminiAnalyzer.analyzeViolations(violations);
89
- } else {
90
- console.log(chalk.yellow('\nāš ļø Gemini API key not configured, using fallback analysis...'));
91
- analyses = await baseGuard.analyzeViolations(violations);
92
- }
93
-
94
- // If analyze-only mode, show analysis and exit
95
- if (options.analyzeOnly) {
96
- console.log(chalk.cyan('\nšŸ“‹ Analysis Results:\n'));
97
- analyses.forEach((analysis, index) => {
98
- console.log(chalk.yellow(`${index + 1}. ${analysis.violation.feature} in ${analysis.violation.file}`));
99
- console.log(` Impact: ${analysis.userImpact}`);
100
- console.log(` Strategy: ${analysis.fixStrategy}`);
101
- console.log(` Confidence: ${Math.round(analysis.confidence * 100)}%\n`);
102
- });
103
- return;
104
- }
105
-
106
- // Step 3: Generate fixes with unified code fixer
107
- console.log(chalk.cyan(`\nšŸ¤– Generating fixes with ${agentStatus.primary}...`));
108
-
109
- const fixes = [];
110
- let successCount = 0;
111
- let failedCount = 0;
112
-
113
- for (let i = 0; i < violations.length; i++) {
114
- const violation = violations[i];
115
- const analysis = analyses[i];
116
-
117
- if (!violation || !analysis) continue;
118
-
119
- try {
120
- console.log(chalk.cyan(`\nšŸ”§ Fixing ${violation.feature} in ${violation.file}...`));
121
-
122
- const fix = await unifiedCodeFixer.generateFix(violation, analysis);
123
- fixes.push(fix);
124
- successCount++;
125
-
126
- console.log(chalk.green(`āœ… Fix generated (confidence: ${Math.round(fix.confidence * 100)}%)`));
127
-
128
- // Show preview if not in auto mode
129
- if (!options.auto) {
130
- console.log(chalk.dim('\nPreview:'));
131
- console.log(chalk.dim(fix.preview.substring(0, 200) + (fix.preview.length > 200 ? '...' : '')));
132
- }
133
-
134
- } catch (error) {
135
- failedCount++;
136
- console.log(chalk.red(`āŒ Failed to generate fix: ${error instanceof Error ? error.message : 'Unknown error'}`));
137
- }
138
- }
139
-
140
- if (fixes.length === 0) {
141
- console.log(chalk.yellow('\nāš ļø No fixes were generated'));
142
- return;
143
- }
144
-
145
- // Show results summary
146
- console.log(chalk.cyan('\nšŸ“Š Fix Generation Results:\n'));
147
- console.log(chalk.green(`āœ… Generated ${successCount} fixes`));
148
- if (failedCount > 0) {
149
- console.log(chalk.red(`āŒ Failed to generate ${failedCount} fixes`));
150
- }
151
-
152
- // Show fixes with previews
153
- if (!options.auto && fixes.length > 0) {
154
- console.log(chalk.cyan('\nšŸ” Generated Fixes:\n'));
155
- fixes.forEach((fix, index) => {
156
- console.log(chalk.white(`${index + 1}. ${fix.violation.feature} in ${fix.filePath}`));
157
- console.log(chalk.dim(` Confidence: ${Math.round(fix.confidence * 100)}%`));
158
- console.log(chalk.dim(` Strategy: ${fix.analysis.fixStrategy}`));
159
-
160
- // Show a snippet of the explanation
161
- const explanation = fix.explanation?.split('\n')[0] || 'No explanation available';
162
- if (explanation.length > 80) {
163
- console.log(chalk.dim(` ${explanation.substring(0, 80)}...`));
164
- } else {
165
- console.log(chalk.dim(` ${explanation}`));
166
- }
167
- console.log();
168
- });
169
- }
170
-
171
- // Step 4: Apply fixes
172
- let appliedCount = 0;
173
- let skippedCount = 0;
174
- let applyFailedCount = 0;
175
-
176
- if (options.auto) {
177
- console.log(chalk.cyan('\n⚔ Applying fixes automatically...'));
178
- for (const fix of fixes) {
179
- try {
180
- await fixManager.applyFix(fix);
181
- appliedCount++;
182
- } catch (error) {
183
- applyFailedCount++;
184
- console.log(chalk.red(`āŒ Failed to apply fix for ${fix.filePath}: ${error instanceof Error ? error.message : 'Unknown error'}`));
185
- }
186
- }
187
- } else {
188
- console.log(chalk.cyan('\n🧩 Review and apply fixes:'));
189
- const results = await fixManager.applyFixes(fixes);
190
- appliedCount = results.applied.length;
191
- skippedCount = results.skipped.length;
192
- applyFailedCount = results.failed.length;
193
- }
194
-
195
- // Show summary
196
- console.log(chalk.cyan(`\nšŸ“ˆ Summary: ${successCount}/${violations.length} fixes generated successfully`));
197
- console.log(chalk.green(`āœ… Applied fixes: ${appliedCount}`));
198
- if (skippedCount > 0) {
199
- console.log(chalk.yellow(`ā­ļø Skipped fixes: ${skippedCount}`));
200
- }
201
- if (applyFailedCount > 0) {
202
- console.log(chalk.red(`āŒ Failed to apply: ${applyFailedCount}`));
203
- }
204
-
205
- if (failedCount > 0) {
206
- console.log(chalk.yellow(`\nāš ļø ${failedCount} fixes failed to generate. This may be due to:`));
207
- console.log(chalk.yellow(' • Complex compatibility issues requiring manual review'));
208
- console.log(chalk.yellow(' • API rate limits or temporary service issues'));
209
- console.log(chalk.yellow(' • Files that couldn\'t be read or analyzed'));
210
- }
211
-
212
- // Show next steps
213
- console.log(chalk.cyan('\nšŸ’” Next Steps:'));
214
- console.log(chalk.cyan(' • Test your application after applying fixes'));
215
- console.log(chalk.cyan(' • Run "base check" to verify fixes resolve violations'));
216
-
217
- UIComponents.showSuccessBox('Fix process completed!');
218
-
219
- } catch (error) {
220
- const apiError = ErrorHandler.handleAPIError(error);
221
- ErrorHandler.displayError(apiError);
222
-
223
- // Provide specific help for fix command issues
224
- console.log('\nšŸ’” Troubleshooting:');
225
- if (apiError.type === 'authentication') {
226
- UIComponents.showList([
227
- 'Check your API keys with "base config show"',
228
- 'Update API keys with "base config set-keys"',
229
- 'Verify API keys are valid and not expired',
230
- 'Ensure you have proper permissions for Jules and Gemini'
231
- ]);
232
- } else if (apiError.type === 'configuration') {
233
- UIComponents.showList([
234
- 'Run "base init" to set up BaseGuard configuration',
235
- 'Configure API keys with "base config set-keys"',
236
- 'Ensure you are in a GitHub repository for Jules fixing'
237
- ]);
238
- } else if (apiError.type === 'network') {
239
- UIComponents.showList([
240
- 'Check your internet connection',
241
- 'Verify firewall allows access to AI services',
242
- 'Try again when network connection is stable'
243
- ]);
244
- } else {
245
- UIComponents.showList([
246
- 'Try running "base check" for basic violation detection',
247
- 'Verify your API keys are configured correctly',
248
- 'Check the documentation for troubleshooting steps'
249
- ]);
250
- }
251
-
252
- // Show fallback suggestions
253
- if (ErrorHandler.shouldUseFallbackMode(apiError)) {
254
- console.log('\nšŸ”„ Alternative options:');
255
- UIComponents.showList([
256
- 'Run "base check" for offline compatibility checking',
257
- 'Review violations manually using browser compatibility tables',
258
- 'Try AI features again when services are available'
259
- ]);
260
- }
261
-
262
- process.exit(1);
263
- }
264
- }
@@ -1,7 +0,0 @@
1
- // CLI command exports
2
- export * from './init.js';
3
- export * from './check.js';
4
- export * from './fix.js';
5
- export * from './config.js';
6
- export * from './automation.js';
7
- export { status, diagnostics } from './status.js';
@@ -1,156 +0,0 @@
1
- import { UIComponents, Prompts } from '../ui/index.js';
2
- import { ConfigurationManager, BROWSER_TARGET_PRESETS, type PresetName } from '../core/index.js';
3
- import { ErrorHandler } from '../core/error-handler.js';
4
-
5
- /**
6
- * Initialize BaseGuard in a project
7
- */
8
- export async function init(options: {
9
- preset?: string;
10
- skipHooks?: boolean;
11
- skipApiKeys?: boolean;
12
- }): Promise<void> {
13
- try {
14
- UIComponents.showHeader();
15
-
16
- // Check if already initialized
17
- const configExists = await ConfigurationManager.exists();
18
- if (configExists) {
19
- const { default: inquirer } = await import('inquirer');
20
- const { overwrite } = await inquirer.prompt([
21
- {
22
- type: 'confirm',
23
- name: 'overwrite',
24
- message: 'BaseGuard is already initialized. Overwrite existing configuration?',
25
- default: false
26
- }
27
- ]);
28
-
29
- if (!overwrite) {
30
- UIComponents.showInfoBox('Initialization cancelled. Use "base config" to modify settings.');
31
- return;
32
- }
33
- }
34
-
35
- const spinner = UIComponents.createSpinner('Setting up BaseGuard configuration...');
36
- spinner.start();
37
-
38
- // Create configuration based on options or run setup wizard
39
- let config;
40
-
41
- if (options.preset && options.preset !== 'custom') {
42
- // Use preset configuration
43
- const presetName = options.preset as PresetName;
44
- if (BROWSER_TARGET_PRESETS[presetName]) {
45
- config = ConfigurationManager.createWithPreset(presetName);
46
- spinner.text = `Using ${presetName} preset...`;
47
- } else {
48
- spinner.fail(`Invalid preset: ${options.preset}`);
49
- UIComponents.showErrorBox(`Available presets: ${Object.keys(BROWSER_TARGET_PRESETS).join(', ')}`);
50
- return;
51
- }
52
- } else {
53
- // Run interactive setup wizard
54
- spinner.stop();
55
- const setupResult = await Prompts.setupWizard();
56
- spinner.start();
57
-
58
- config = ConfigurationManager.createWithCustomTargets(setupResult.targets);
59
-
60
- // Set up automation if requested and not skipped
61
- if (setupResult.installHooks && !options.skipHooks) {
62
- config.automation = {
63
- enabled: true,
64
- trigger: setupResult.hookTrigger,
65
- autoAnalyze: true,
66
- autoFix: false,
67
- blockCommit: true
68
- };
69
- }
70
- }
71
-
72
- // Set up API keys and coding agent if not skipped
73
- if (!options.skipApiKeys) {
74
- spinner.stop();
75
- const apiKeys = await Prompts.setupApiKeys();
76
-
77
- if (apiKeys.julesApiKey) {
78
- config.apiKeys.jules = apiKeys.julesApiKey;
79
- }
80
- if (apiKeys.geminiApiKey) {
81
- config.apiKeys.gemini = apiKeys.geminiApiKey;
82
- }
83
-
84
- // Configure coding agent based on available keys
85
- if (apiKeys.julesApiKey && apiKeys.geminiApiKey) {
86
- const codingAgentChoice = await Prompts.chooseCodingAgent();
87
- config.codingAgent.primary = codingAgentChoice.primary;
88
- config.codingAgent.fallback = codingAgentChoice.fallback;
89
- } else if (apiKeys.julesApiKey) {
90
- config.codingAgent.primary = 'jules';
91
- config.codingAgent.fallback = 'jules';
92
- } else if (apiKeys.geminiApiKey) {
93
- config.codingAgent.primary = 'gemini';
94
- config.codingAgent.fallback = 'gemini';
95
- }
96
-
97
- spinner.start();
98
- }
99
-
100
- await ConfigurationManager.save(config);
101
- spinner.succeed('BaseGuard configuration created');
102
-
103
- UIComponents.showSuccessBox('BaseGuard has been successfully initialized!');
104
-
105
- // Show configuration summary
106
- console.log('\nšŸ“‹ Configuration Summary:');
107
- UIComponents.showList([
108
- `Browser targets: ${config.targets.map(t => `${t.browser} ${t.minVersion}`).join(', ')}`,
109
- `API keys: ${config.apiKeys.jules ? 'āœ…' : 'āŒ'} Jules, ${config.apiKeys.gemini ? 'āœ…' : 'āŒ'} Gemini`,
110
- `Automation: ${config.automation.enabled ? 'āœ… Enabled' : 'āŒ Disabled'}`
111
- ]);
112
-
113
- console.log('\nšŸš€ Next steps:');
114
- const nextSteps = ['Run `base check` to scan for compatibility issues'];
115
-
116
- if (config.apiKeys.jules && config.apiKeys.gemini) {
117
- nextSteps.push('Run `base fix` to automatically fix issues with AI');
118
- } else {
119
- nextSteps.push('Run `base config set-keys` to configure AI services');
120
- }
121
-
122
- if (!config.automation.enabled) {
123
- nextSteps.push('Run `base automation enable` to set up git hooks');
124
- }
125
-
126
- UIComponents.showList(nextSteps);
127
-
128
- } catch (error) {
129
- const apiError = ErrorHandler.handleAPIError(error);
130
- ErrorHandler.displayError(apiError);
131
-
132
- // Provide specific help for common init issues
133
- console.log('\nšŸ’” Common solutions:');
134
- if (apiError.type === 'network') {
135
- UIComponents.showList([
136
- 'Check your internet connection',
137
- 'Try running init again with --skip-api-keys to set up offline',
138
- 'Configure API keys later with "base config set-keys"'
139
- ]);
140
- } else if (apiError.type === 'configuration') {
141
- UIComponents.showList([
142
- 'Delete .baseguardrc.json and try again',
143
- 'Check file permissions in the current directory',
144
- 'Run "base config validate" to check for issues'
145
- ]);
146
- } else {
147
- UIComponents.showList([
148
- 'Try running "base init --skip-api-keys" for offline setup',
149
- 'Check the documentation at https://github.com/baseguard/baseguard#readme',
150
- 'Report this issue if it persists'
151
- ]);
152
- }
153
-
154
- process.exit(1);
155
- }
156
- }