baseguard 1.0.3 → 1.0.4
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.
- package/.baseguardrc.example.json +63 -63
- package/.eslintrc.json +24 -24
- package/.prettierrc +7 -7
- package/CHANGELOG.md +195 -195
- package/DEPLOYMENT.md +624 -624
- package/DEPLOYMENT_CHECKLIST.md +239 -239
- package/DEPLOYMENT_SUMMARY_v1.0.2.md +202 -202
- package/QUICK_START.md +134 -134
- package/README.md +488 -488
- package/RELEASE_NOTES_v1.0.2.md +434 -434
- package/bin/base.js +627 -627
- package/dist/ai/fix-manager.d.ts.map +1 -1
- package/dist/ai/fix-manager.js +1 -1
- package/dist/ai/fix-manager.js.map +1 -1
- package/dist/ai/gemini-analyzer.d.ts.map +1 -1
- package/dist/ai/gemini-analyzer.js +29 -35
- package/dist/ai/gemini-analyzer.js.map +1 -1
- package/dist/ai/gemini-code-fixer.d.ts.map +1 -1
- package/dist/ai/gemini-code-fixer.js +58 -58
- package/dist/ai/gemini-code-fixer.js.map +1 -1
- package/dist/ai/jules-implementer.d.ts +3 -0
- package/dist/ai/jules-implementer.d.ts.map +1 -1
- package/dist/ai/jules-implementer.js +63 -32
- package/dist/ai/jules-implementer.js.map +1 -1
- package/dist/ai/unified-code-fixer.js.map +1 -1
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/check.js +1 -1
- package/dist/commands/check.js.map +1 -1
- package/dist/commands/config.js +2 -1
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/fix.d.ts.map +1 -1
- package/dist/commands/fix.js +44 -15
- package/dist/commands/fix.js.map +1 -1
- package/dist/core/api-key-manager.js +2 -2
- package/dist/core/api-key-manager.js.map +1 -1
- package/dist/core/baseguard.d.ts +1 -0
- package/dist/core/baseguard.d.ts.map +1 -1
- package/dist/core/baseguard.js +13 -10
- package/dist/core/baseguard.js.map +1 -1
- package/dist/core/baseline-checker.d.ts.map +1 -1
- package/dist/core/baseline-checker.js +2 -1
- package/dist/core/baseline-checker.js.map +1 -1
- package/dist/core/configuration-recovery.d.ts.map +1 -1
- package/dist/core/configuration-recovery.js +1 -1
- package/dist/core/configuration-recovery.js.map +1 -1
- package/dist/core/debug-logger.d.ts.map +1 -1
- package/dist/core/debug-logger.js +1 -1
- package/dist/core/debug-logger.js.map +1 -1
- package/dist/core/error-handler.d.ts.map +1 -1
- package/dist/core/error-handler.js +2 -1
- package/dist/core/error-handler.js.map +1 -1
- package/dist/core/gitignore-manager.js +5 -5
- package/dist/core/graceful-degradation-manager.d.ts.map +1 -1
- package/dist/core/graceful-degradation-manager.js +16 -16
- package/dist/core/graceful-degradation-manager.js.map +1 -1
- package/dist/core/lazy-loader.d.ts.map +1 -1
- package/dist/core/lazy-loader.js +9 -2
- package/dist/core/lazy-loader.js.map +1 -1
- package/dist/core/memory-manager.d.ts +0 -3
- package/dist/core/memory-manager.d.ts.map +1 -1
- package/dist/core/memory-manager.js.map +1 -1
- package/dist/core/parser-worker.d.ts +2 -0
- package/dist/core/parser-worker.d.ts.map +1 -0
- package/dist/core/parser-worker.js +19 -0
- package/dist/core/parser-worker.js.map +1 -0
- package/dist/core/startup-optimizer.d.ts.map +1 -1
- package/dist/core/startup-optimizer.js +4 -8
- package/dist/core/startup-optimizer.js.map +1 -1
- package/dist/core/system-error-handler.d.ts.map +1 -1
- package/dist/core/system-error-handler.js.map +1 -1
- package/dist/git/automation-engine.d.ts.map +1 -1
- package/dist/git/automation-engine.js +5 -4
- package/dist/git/automation-engine.js.map +1 -1
- package/dist/git/github-manager.d.ts.map +1 -1
- package/dist/git/github-manager.js.map +1 -1
- package/dist/git/hook-manager.js +5 -5
- package/dist/git/hook-manager.js.map +1 -1
- package/dist/parsers/parser-manager.d.ts.map +1 -1
- package/dist/parsers/parser-manager.js +1 -1
- package/dist/parsers/parser-manager.js.map +1 -1
- package/dist/parsers/svelte-parser.js +1 -1
- package/dist/parsers/svelte-parser.js.map +1 -1
- package/dist/parsers/vanilla-parser.d.ts.map +1 -1
- package/dist/parsers/vanilla-parser.js.map +1 -1
- package/dist/parsers/vue-parser.d.ts.map +1 -1
- package/dist/parsers/vue-parser.js.map +1 -1
- package/dist/ui/components.d.ts +1 -1
- package/dist/ui/components.d.ts.map +1 -1
- package/dist/ui/components.js +11 -11
- package/dist/ui/components.js.map +1 -1
- package/dist/ui/terminal-header.js +14 -14
- package/package.json +105 -105
- package/src/ai/__tests__/gemini-analyzer.test.ts +180 -180
- package/src/ai/agentkit-orchestrator.ts +533 -533
- package/src/ai/fix-manager.ts +362 -362
- package/src/ai/gemini-analyzer.ts +665 -671
- package/src/ai/gemini-code-fixer.ts +539 -540
- package/src/ai/index.ts +3 -3
- package/src/ai/jules-implementer.ts +504 -460
- package/src/ai/unified-code-fixer.ts +347 -347
- package/src/commands/automation.ts +343 -343
- package/src/commands/check.ts +298 -299
- package/src/commands/config.ts +584 -583
- package/src/commands/fix.ts +264 -238
- package/src/commands/index.ts +6 -6
- package/src/commands/init.ts +155 -155
- package/src/commands/status.ts +306 -306
- package/src/core/api-key-manager.ts +298 -298
- package/src/core/baseguard.ts +757 -756
- package/src/core/baseline-checker.ts +564 -563
- package/src/core/cache-manager.ts +271 -271
- package/src/core/configuration-recovery.ts +672 -673
- package/src/core/configuration.ts +595 -595
- package/src/core/debug-logger.ts +590 -590
- package/src/core/directory-filter.ts +420 -420
- package/src/core/error-handler.ts +518 -517
- package/src/core/file-processor.ts +337 -337
- package/src/core/gitignore-manager.ts +168 -168
- package/src/core/graceful-degradation-manager.ts +596 -596
- package/src/core/index.ts +16 -16
- package/src/core/lazy-loader.ts +317 -307
- package/src/core/memory-manager.ts +290 -295
- package/src/core/parser-worker.ts +33 -0
- package/src/core/startup-optimizer.ts +246 -255
- package/src/core/system-error-handler.ts +755 -756
- package/src/git/automation-engine.ts +361 -361
- package/src/git/github-manager.ts +190 -192
- package/src/git/hook-manager.ts +210 -210
- package/src/git/index.ts +3 -3
- package/src/index.ts +7 -7
- package/src/parsers/feature-validator.ts +558 -558
- package/src/parsers/index.ts +7 -7
- package/src/parsers/parser-manager.ts +418 -419
- package/src/parsers/parser.ts +25 -25
- package/src/parsers/react-parser-optimized.ts +160 -160
- package/src/parsers/react-parser.ts +358 -358
- package/src/parsers/svelte-parser.ts +510 -510
- package/src/parsers/vanilla-parser.ts +685 -686
- package/src/parsers/vue-parser.ts +476 -478
- package/src/types/index.ts +95 -95
- package/src/ui/components.ts +567 -567
- package/src/ui/help.ts +192 -192
- package/src/ui/index.ts +3 -3
- package/src/ui/prompts.ts +680 -680
- package/src/ui/terminal-header.ts +58 -58
- package/test-build.js +40 -40
- package/test-config-commands.js +55 -55
- package/test-header-simple.js +32 -32
- package/test-terminal-header.js +11 -11
- package/test-ui.js +28 -28
- package/tests/e2e/baseguard.e2e.test.ts +515 -515
- package/tests/e2e/cross-platform.e2e.test.ts +419 -419
- package/tests/e2e/git-integration.e2e.test.ts +486 -486
- package/tests/fixtures/react-project/package.json +13 -13
- package/tests/fixtures/react-project/src/App.css +75 -75
- package/tests/fixtures/react-project/src/App.tsx +76 -76
- package/tests/fixtures/svelte-project/package.json +10 -10
- package/tests/fixtures/svelte-project/src/App.svelte +368 -368
- package/tests/fixtures/vanilla-project/index.html +75 -75
- package/tests/fixtures/vanilla-project/script.js +330 -330
- package/tests/fixtures/vanilla-project/styles.css +358 -358
- package/tests/fixtures/vue-project/package.json +11 -11
- package/tests/fixtures/vue-project/src/App.vue +215 -215
- package/tsconfig.json +34 -34
- package/vitest.config.ts +11 -11
- package/dist/terminal-header.d.ts +0 -12
- package/dist/terminal-header.js +0 -45
package/src/commands/fix.ts
CHANGED
|
@@ -1,238 +1,264 @@
|
|
|
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 {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
console.log(chalk.cyan('
|
|
53
|
-
|
|
54
|
-
console.log(chalk.cyan('
|
|
55
|
-
console.log(chalk.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
console.log(
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
let
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
'
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
}
|
|
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
|
+
}
|
package/src/commands/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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';
|
|
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
7
|
export { status, diagnostics } from './status.js';
|