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,269 +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
- const noAgentsConfigured = !agentStatus.jules.configured && !agentStatus.gemini.configured;
42
- if (noAgentsConfigured && !options.analyzeOnly) {
43
- console.log(chalk.red('\nāŒ No coding agents are available'));
44
- console.log(chalk.cyan('šŸ’” Configure API keys to enable code fixing:'));
45
- console.log(chalk.cyan(' • Run "base config set-keys" to configure API keys'));
46
- console.log(chalk.cyan(' • Get Gemini API key: https://aistudio.google.com'));
47
- console.log(chalk.cyan(' • Get Jules API key: https://jules.google.com/settings#api'));
48
- process.exit(1);
49
- }
50
-
51
- if (noAgentsConfigured && options.analyzeOnly) {
52
- console.log(chalk.yellow('\nāš ļø No AI coding agents configured, running fallback analysis only.'));
53
- }
54
-
55
- // Show agent-specific information
56
- if (agentStatus.primary === 'jules' && agentStatus.jules.repoDetected) {
57
- console.log(chalk.cyan('šŸ”— GitHub repository detected - Jules available for autonomous fixing'));
58
- } else if (agentStatus.primary === 'gemini' || !agentStatus.jules.repoDetected) {
59
- console.log(chalk.cyan('šŸ’Ž Using Gemini 2.5 Pro for local file fixing'));
60
- console.log(chalk.dim(' This works with any local files, no GitHub required'));
61
- }
62
-
63
- // Step 1: Check for violations
64
- console.log(chalk.cyan('šŸ” Scanning for compatibility violations...'));
65
-
66
- // Get files to fix
67
- const filePattern = options.files || '**/*.{js,jsx,ts,tsx,vue,svelte,css,html}';
68
- const files = await glob(filePattern, {
69
- ignore: [
70
- 'node_modules/**',
71
- 'dist/**',
72
- 'build/**',
73
- '.git/**',
74
- '**/*.min.js',
75
- '**/*.min.css'
76
- ]
77
- });
78
-
79
- const violations = await baseGuard.checkViolations(files);
80
-
81
- if (violations.length === 0) {
82
- UIComponents.showSuccessBox('No compatibility violations found!');
83
- return;
84
- }
85
-
86
- console.log(chalk.yellow(`\nāš ļø Found ${violations.length} compatibility violations\n`));
87
- UIComponents.showViolations(violations);
88
-
89
- // Step 2: Analyze violations with Gemini
90
- let analyses;
91
- if (geminiAnalyzer) {
92
- console.log(chalk.cyan('\n🧠 Analyzing violations with AI...'));
93
- analyses = await geminiAnalyzer.analyzeViolations(violations);
94
- } else {
95
- console.log(chalk.yellow('\nāš ļø Gemini API key not configured, using fallback analysis...'));
96
- analyses = await baseGuard.analyzeViolations(violations);
97
- }
98
-
99
- // If analyze-only mode, show analysis and exit
100
- if (options.analyzeOnly) {
101
- console.log(chalk.cyan('\nšŸ“‹ Analysis Results:\n'));
102
- analyses.forEach((analysis, index) => {
103
- console.log(chalk.yellow(`${index + 1}. ${analysis.violation.feature} in ${analysis.violation.file}`));
104
- console.log(` Impact: ${analysis.userImpact}`);
105
- console.log(` Strategy: ${analysis.fixStrategy}`);
106
- console.log(` Confidence: ${Math.round(analysis.confidence * 100)}%\n`);
107
- });
108
- return;
109
- }
110
-
111
- // Step 3: Generate fixes with unified code fixer
112
- console.log(chalk.cyan(`\nšŸ¤– Generating fixes with ${agentStatus.primary}...`));
113
-
114
- const fixes = [];
115
- let successCount = 0;
116
- let failedCount = 0;
117
-
118
- for (let i = 0; i < violations.length; i++) {
119
- const violation = violations[i];
120
- const analysis = analyses[i];
121
-
122
- if (!violation || !analysis) continue;
123
-
124
- try {
125
- console.log(chalk.cyan(`\nšŸ”§ Fixing ${violation.feature} in ${violation.file}...`));
126
-
127
- const fix = await unifiedCodeFixer.generateFix(violation, analysis);
128
- fixes.push(fix);
129
- successCount++;
130
-
131
- console.log(chalk.green(`āœ… Fix generated (confidence: ${Math.round(fix.confidence * 100)}%)`));
132
-
133
- // Show preview if not in auto mode
134
- if (!options.auto) {
135
- console.log(chalk.dim('\nPreview:'));
136
- console.log(chalk.dim(fix.preview.substring(0, 200) + (fix.preview.length > 200 ? '...' : '')));
137
- }
138
-
139
- } catch (error) {
140
- failedCount++;
141
- console.log(chalk.red(`āŒ Failed to generate fix: ${error instanceof Error ? error.message : 'Unknown error'}`));
142
- }
143
- }
144
-
145
- if (fixes.length === 0) {
146
- console.log(chalk.yellow('\nāš ļø No fixes were generated'));
147
- return;
148
- }
149
-
150
- // Show results summary
151
- console.log(chalk.cyan('\nšŸ“Š Fix Generation Results:\n'));
152
- console.log(chalk.green(`āœ… Generated ${successCount} fixes`));
153
- if (failedCount > 0) {
154
- console.log(chalk.red(`āŒ Failed to generate ${failedCount} fixes`));
155
- }
156
-
157
- // Show fixes with previews
158
- if (!options.auto && fixes.length > 0) {
159
- console.log(chalk.cyan('\nšŸ” Generated Fixes:\n'));
160
- fixes.forEach((fix, index) => {
161
- console.log(chalk.white(`${index + 1}. ${fix.violation.feature} in ${fix.filePath}`));
162
- console.log(chalk.dim(` Confidence: ${Math.round(fix.confidence * 100)}%`));
163
- console.log(chalk.dim(` Strategy: ${fix.analysis.fixStrategy}`));
164
-
165
- // Show a snippet of the explanation
166
- const explanation = fix.explanation?.split('\n')[0] || 'No explanation available';
167
- if (explanation.length > 80) {
168
- console.log(chalk.dim(` ${explanation.substring(0, 80)}...`));
169
- } else {
170
- console.log(chalk.dim(` ${explanation}`));
171
- }
172
- console.log();
173
- });
174
- }
175
-
176
- // Step 4: Apply fixes
177
- let appliedCount = 0;
178
- let skippedCount = 0;
179
- let applyFailedCount = 0;
180
-
181
- if (options.auto) {
182
- console.log(chalk.cyan('\n⚔ Applying fixes automatically...'));
183
- for (const fix of fixes) {
184
- try {
185
- await fixManager.applyFix(fix);
186
- appliedCount++;
187
- } catch (error) {
188
- applyFailedCount++;
189
- console.log(chalk.red(`āŒ Failed to apply fix for ${fix.filePath}: ${error instanceof Error ? error.message : 'Unknown error'}`));
190
- }
191
- }
192
- } else {
193
- console.log(chalk.cyan('\n🧩 Review and apply fixes:'));
194
- const results = await fixManager.applyFixes(fixes);
195
- appliedCount = results.applied.length;
196
- skippedCount = results.skipped.length;
197
- applyFailedCount = results.failed.length;
198
- }
199
-
200
- // Show summary
201
- console.log(chalk.cyan(`\nšŸ“ˆ Summary: ${successCount}/${violations.length} fixes generated successfully`));
202
- console.log(chalk.green(`āœ… Applied fixes: ${appliedCount}`));
203
- if (skippedCount > 0) {
204
- console.log(chalk.yellow(`ā­ļø Skipped fixes: ${skippedCount}`));
205
- }
206
- if (applyFailedCount > 0) {
207
- console.log(chalk.red(`āŒ Failed to apply: ${applyFailedCount}`));
208
- }
209
-
210
- if (failedCount > 0) {
211
- console.log(chalk.yellow(`\nāš ļø ${failedCount} fixes failed to generate. This may be due to:`));
212
- console.log(chalk.yellow(' • Complex compatibility issues requiring manual review'));
213
- console.log(chalk.yellow(' • API rate limits or temporary service issues'));
214
- console.log(chalk.yellow(' • Files that couldn\'t be read or analyzed'));
215
- }
216
-
217
- // Show next steps
218
- console.log(chalk.cyan('\nšŸ’” Next Steps:'));
219
- console.log(chalk.cyan(' • Test your application after applying fixes'));
220
- console.log(chalk.cyan(' • Run "base check" to verify fixes resolve violations'));
221
-
222
- UIComponents.showSuccessBox('Fix process completed!');
223
-
224
- } catch (error) {
225
- const apiError = ErrorHandler.handleAPIError(error);
226
- ErrorHandler.displayError(apiError);
227
-
228
- // Provide specific help for fix command issues
229
- console.log('\nšŸ’” Troubleshooting:');
230
- if (apiError.type === 'authentication') {
231
- UIComponents.showList([
232
- 'Check your API keys with "base config show"',
233
- 'Update API keys with "base config set-keys"',
234
- 'Verify API keys are valid and not expired',
235
- 'Ensure you have proper permissions for Jules and Gemini'
236
- ]);
237
- } else if (apiError.type === 'configuration') {
238
- UIComponents.showList([
239
- 'Run "base init" to set up BaseGuard configuration',
240
- 'Configure API keys with "base config set-keys"',
241
- 'Ensure you are in a GitHub repository for Jules fixing'
242
- ]);
243
- } else if (apiError.type === 'network') {
244
- UIComponents.showList([
245
- 'Check your internet connection',
246
- 'Verify firewall allows access to AI services',
247
- 'Try again when network connection is stable'
248
- ]);
249
- } else {
250
- UIComponents.showList([
251
- 'Try running "base check" for basic violation detection',
252
- 'Verify your API keys are configured correctly',
253
- 'Check the documentation for troubleshooting steps'
254
- ]);
255
- }
256
-
257
- // Show fallback suggestions
258
- if (ErrorHandler.shouldUseFallbackMode(apiError)) {
259
- console.log('\nšŸ”„ Alternative options:');
260
- UIComponents.showList([
261
- 'Run "base check" for offline compatibility checking',
262
- 'Review violations manually using browser compatibility tables',
263
- 'Try AI features again when services are available'
264
- ]);
265
- }
266
-
267
- process.exit(1);
268
- }
269
- }
@@ -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
- }