baseguard 1.0.3 ā 1.0.5
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 +48 -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 +8 -5
- 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 +269 -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 +566 -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/tmp-smoke/.baseguard/backups/config-2026-02-19T12-04-11-067Z-auto.json +30 -0
- package/tmp-smoke/src/bad.css +3 -0
- 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/status.ts
CHANGED
|
@@ -1,307 +1,307 @@
|
|
|
1
|
-
import { BaseGuard } from '../core/baseguard.js';
|
|
2
|
-
import { ConfigurationManager } from '../core/configuration.js';
|
|
3
|
-
import { ConfigurationRecovery } from '../core/configuration-recovery.js';
|
|
4
|
-
import { GracefulDegradationManager } from '../core/graceful-degradation-manager.js';
|
|
5
|
-
import { SystemErrorHandler } from '../core/system-error-handler.js';
|
|
6
|
-
import { logger } from '../core/debug-logger.js';
|
|
7
|
-
import { UIComponents } from '../ui/components.js';
|
|
8
|
-
import chalk from 'chalk';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Show BaseGuard system status and health
|
|
12
|
-
*/
|
|
13
|
-
export async function status(options: {
|
|
14
|
-
verbose?: boolean;
|
|
15
|
-
services?: boolean;
|
|
16
|
-
config?: boolean;
|
|
17
|
-
errors?: boolean;
|
|
18
|
-
}): Promise<void> {
|
|
19
|
-
const categoryLogger = logger.createCategoryLogger('status-command');
|
|
20
|
-
|
|
21
|
-
try {
|
|
22
|
-
UIComponents.showHeader();
|
|
23
|
-
console.log(chalk.cyan('š BaseGuard System Status\n'));
|
|
24
|
-
|
|
25
|
-
// Load configuration with recovery if needed
|
|
26
|
-
let config;
|
|
27
|
-
try {
|
|
28
|
-
config = await ConfigurationManager.load();
|
|
29
|
-
} catch (error) {
|
|
30
|
-
console.log(chalk.red('ā Configuration Error'));
|
|
31
|
-
console.log(chalk.dim(` ${error instanceof Error ? error.message : 'Unknown error'}`));
|
|
32
|
-
|
|
33
|
-
if (options.config) {
|
|
34
|
-
console.log(chalk.cyan('\nš§ Configuration Recovery Options:'));
|
|
35
|
-
console.log(chalk.cyan(' ⢠Run "base config recover" to attempt automatic recovery'));
|
|
36
|
-
console.log(chalk.cyan(' ⢠Run "base init" to create a new configuration'));
|
|
37
|
-
console.log(chalk.cyan(' ⢠Check .baseguardrc.json file manually'));
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// Initialize BaseGuard
|
|
44
|
-
const baseGuard = new BaseGuard(config);
|
|
45
|
-
|
|
46
|
-
// Show system health
|
|
47
|
-
const health = await baseGuard.getHealthStatus();
|
|
48
|
-
|
|
49
|
-
// Overall status
|
|
50
|
-
const statusIcon = health.overall === 'healthy' ? 'ā
' : health.overall === 'degraded' ? 'ā ļø' : 'ā';
|
|
51
|
-
const statusColor = health.overall === 'healthy' ? chalk.green : health.overall === 'degraded' ? chalk.yellow : chalk.red;
|
|
52
|
-
|
|
53
|
-
console.log(statusColor(`${statusIcon} Overall Status: ${health.overall.toUpperCase()}`));
|
|
54
|
-
console.log(chalk.dim(` Degradation Mode: ${health.degradationMode}`));
|
|
55
|
-
|
|
56
|
-
// Component status
|
|
57
|
-
console.log(chalk.cyan('\nš Component Status:'));
|
|
58
|
-
for (const [component, status] of Object.entries(health.components)) {
|
|
59
|
-
const componentIcon = status.status === 'healthy' ? 'ā
' : status.status === 'degraded' ? 'ā ļø' : 'ā';
|
|
60
|
-
console.log(` ${componentIcon} ${component}: ${status.status}`);
|
|
61
|
-
|
|
62
|
-
if (options.verbose && status.details) {
|
|
63
|
-
if (status.details.errors?.length > 0) {
|
|
64
|
-
console.log(chalk.dim(` Errors: ${status.details.errors.slice(0, 3).join(', ')}`));
|
|
65
|
-
}
|
|
66
|
-
if (status.details.error) {
|
|
67
|
-
console.log(chalk.dim(` Error: ${status.details.error}`));
|
|
68
|
-
}
|
|
69
|
-
if (status.details.lastCheck) {
|
|
70
|
-
const age = Math.round((Date.now() - status.details.lastCheck) / 1000);
|
|
71
|
-
console.log(chalk.dim(` Last Check: ${age}s ago`));
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// Service status (if requested)
|
|
77
|
-
if (options.services) {
|
|
78
|
-
console.log(chalk.cyan('\nš Service Status:'));
|
|
79
|
-
const serviceStatus = GracefulDegradationManager.getServiceStatus();
|
|
80
|
-
|
|
81
|
-
for (const [service, info] of serviceStatus) {
|
|
82
|
-
const serviceIcon = info.available ? 'ā
' : 'ā';
|
|
83
|
-
const age = Math.round((Date.now() - info.lastCheck) / 1000);
|
|
84
|
-
console.log(` ${serviceIcon} ${service}: ${info.available ? 'Available' : 'Unavailable'} (${age}s ago)`);
|
|
85
|
-
|
|
86
|
-
if (!info.available && info.error && options.verbose) {
|
|
87
|
-
console.log(chalk.dim(` Error: ${info.error}`));
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// Refresh service status
|
|
92
|
-
console.log(chalk.dim('\nš Refreshing service status...'));
|
|
93
|
-
await GracefulDegradationManager.refreshServiceStatus();
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// Configuration status (if requested)
|
|
97
|
-
if (options.config) {
|
|
98
|
-
console.log(chalk.cyan('\nāļø Configuration Status:'));
|
|
99
|
-
|
|
100
|
-
const configIntegrity = await ConfigurationRecovery.validateIntegrity();
|
|
101
|
-
const configIcon = configIntegrity.valid ? 'ā
' : 'ā';
|
|
102
|
-
console.log(` ${configIcon} Configuration File: ${configIntegrity.valid ? 'Valid' : 'Invalid'}`);
|
|
103
|
-
|
|
104
|
-
if (!configIntegrity.valid) {
|
|
105
|
-
console.log(chalk.red(' Errors:'));
|
|
106
|
-
configIntegrity.errors.forEach(error => {
|
|
107
|
-
console.log(chalk.red(` ⢠${error}`));
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
console.log(chalk.cyan(' Suggestions:'));
|
|
111
|
-
configIntegrity.suggestions.forEach(suggestion => {
|
|
112
|
-
console.log(chalk.cyan(` ⢠${suggestion}`));
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// Show configuration details
|
|
117
|
-
if (options.verbose) {
|
|
118
|
-
console.log(chalk.dim('\n Configuration Details:'));
|
|
119
|
-
console.log(chalk.dim(` Version: ${config.version}`));
|
|
120
|
-
console.log(chalk.dim(` Targets: ${config.targets.length} browser(s)`));
|
|
121
|
-
console.log(chalk.dim(` API Keys: Jules ${config.apiKeys.jules ? 'ā' : 'ā'}, Gemini ${config.apiKeys.gemini ? 'ā' : 'ā'}`));
|
|
122
|
-
console.log(chalk.dim(` Automation: ${config.automation.enabled ? 'Enabled' : 'Disabled'}`));
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// Show available backups
|
|
126
|
-
const backups = await ConfigurationRecovery.listBackups();
|
|
127
|
-
if (backups.length > 0) {
|
|
128
|
-
console.log(chalk.dim(`\n Available Backups: ${backups.length}`));
|
|
129
|
-
if (options.verbose) {
|
|
130
|
-
backups.slice(0, 3).forEach(backup => {
|
|
131
|
-
console.log(chalk.dim(` ⢠${backup.timestamp.toLocaleString()} (${backup.source})`));
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// Error summary (if requested)
|
|
138
|
-
if (options.errors) {
|
|
139
|
-
console.log(chalk.cyan('\nšØ Error Summary:'));
|
|
140
|
-
|
|
141
|
-
const errorSummary = logger.getErrorSummary();
|
|
142
|
-
console.log(` Total Errors: ${errorSummary.totalErrors}`);
|
|
143
|
-
console.log(` Total Warnings: ${errorSummary.totalWarnings}`);
|
|
144
|
-
|
|
145
|
-
if (errorSummary.totalErrors > 0) {
|
|
146
|
-
console.log(chalk.red('\n Error Categories:'));
|
|
147
|
-
for (const [category, count] of Object.entries(errorSummary.errorsByCategory)) {
|
|
148
|
-
console.log(chalk.red(` ${category}: ${count}`));
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
if (options.verbose && errorSummary.recentErrors.length > 0) {
|
|
152
|
-
console.log(chalk.red('\n Recent Errors:'));
|
|
153
|
-
errorSummary.recentErrors.slice(0, 3).forEach(error => {
|
|
154
|
-
console.log(chalk.red(` ⢠${error.message} (${error.category})`));
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
// System error handler status
|
|
160
|
-
const systemErrorSummary = SystemErrorHandler.getErrorSummary();
|
|
161
|
-
if (systemErrorSummary.total > 0) {
|
|
162
|
-
console.log(chalk.yellow('\n System Errors:'));
|
|
163
|
-
console.log(` Total: ${systemErrorSummary.total}`);
|
|
164
|
-
console.log(` Critical: ${systemErrorSummary.critical}`);
|
|
165
|
-
console.log(` Recoverable: ${systemErrorSummary.recoverable}`);
|
|
166
|
-
|
|
167
|
-
if (options.verbose) {
|
|
168
|
-
console.log(chalk.yellow('\n By Severity:'));
|
|
169
|
-
for (const [severity, count] of Object.entries(systemErrorSummary.bySeverity)) {
|
|
170
|
-
if (count > 0) {
|
|
171
|
-
console.log(` ${severity}: ${count}`);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
// Recommendations
|
|
179
|
-
if (health.recommendations.length > 0) {
|
|
180
|
-
console.log(chalk.cyan('\nš” Recommendations:'));
|
|
181
|
-
health.recommendations.forEach(rec => {
|
|
182
|
-
console.log(chalk.cyan(` ⢠${rec}`));
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
// Show degradation mode details
|
|
187
|
-
const mode = GracefulDegradationManager.getCurrentMode();
|
|
188
|
-
if (mode && mode.name !== 'Full Functionality') {
|
|
189
|
-
console.log(chalk.yellow(`\nā ļø Currently in ${mode.name} Mode`));
|
|
190
|
-
console.log(chalk.dim(` ${mode.description}`));
|
|
191
|
-
|
|
192
|
-
if (mode.limitations.length > 0) {
|
|
193
|
-
console.log(chalk.yellow('\n Limitations:'));
|
|
194
|
-
mode.limitations.forEach(limitation => {
|
|
195
|
-
console.log(chalk.yellow(` ⢠${limitation}`));
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
console.log(chalk.cyan('\n Available Features:'));
|
|
200
|
-
if (mode.capabilities.baselineChecking) {
|
|
201
|
-
console.log(chalk.green(' ā
Baseline compatibility checking'));
|
|
202
|
-
}
|
|
203
|
-
if (mode.capabilities.caching) {
|
|
204
|
-
console.log(chalk.green(' ā
Result caching'));
|
|
205
|
-
}
|
|
206
|
-
if (!mode.capabilities.aiAnalysis) {
|
|
207
|
-
console.log(chalk.yellow(' ā ļø AI analysis disabled'));
|
|
208
|
-
}
|
|
209
|
-
if (!mode.capabilities.autoFix) {
|
|
210
|
-
console.log(chalk.yellow(' ā ļø Auto-fixing disabled'));
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
// Performance info
|
|
215
|
-
if (options.verbose) {
|
|
216
|
-
const memoryUsage = process.memoryUsage();
|
|
217
|
-
const uptime = process.uptime();
|
|
218
|
-
|
|
219
|
-
console.log(chalk.cyan('\nš Performance Info:'));
|
|
220
|
-
console.log(` Uptime: ${Math.round(uptime)}s`);
|
|
221
|
-
console.log(` Memory: ${Math.round(memoryUsage.heapUsed / 1024 / 1024)}MB used / ${Math.round(memoryUsage.heapTotal / 1024 / 1024)}MB total`);
|
|
222
|
-
console.log(` Platform: ${process.platform} ${process.arch}`);
|
|
223
|
-
console.log(` Node.js: ${process.version}`);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
// Quick actions
|
|
227
|
-
console.log(chalk.cyan('\nš§ Quick Actions:'));
|
|
228
|
-
const actions = [];
|
|
229
|
-
|
|
230
|
-
if (health.overall !== 'healthy') {
|
|
231
|
-
actions.push('Run "base config recover" to attempt automatic recovery');
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
if (!mode?.capabilities.aiAnalysis) {
|
|
235
|
-
actions.push('Check network connectivity to restore AI features');
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
const errorSummary = logger.getErrorSummary();
|
|
239
|
-
if (errorSummary.totalErrors > 5) {
|
|
240
|
-
actions.push('Run with --errors flag to see detailed error information');
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
actions.push('Run "base check" to scan for compatibility issues');
|
|
244
|
-
actions.push('Run "base status --verbose" for detailed information');
|
|
245
|
-
|
|
246
|
-
actions.forEach(action => {
|
|
247
|
-
console.log(chalk.cyan(` ⢠${action}`));
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
} catch (error) {
|
|
251
|
-
categoryLogger.error('Status command failed', { error });
|
|
252
|
-
|
|
253
|
-
console.log(chalk.red('\nā Failed to get system status'));
|
|
254
|
-
console.log(chalk.red(` Error: ${error instanceof Error ? error.message : 'Unknown error'}`));
|
|
255
|
-
|
|
256
|
-
console.log(chalk.cyan('\nš§ Recovery Options:'));
|
|
257
|
-
console.log(chalk.cyan(' ⢠Run "base init" to reinitialize BaseGuard'));
|
|
258
|
-
console.log(chalk.cyan(' ⢠Check file permissions in your project directory'));
|
|
259
|
-
console.log(chalk.cyan(' ⢠Verify BaseGuard installation: npm list baseguard'));
|
|
260
|
-
|
|
261
|
-
process.exit(1);
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
/**
|
|
266
|
-
* Show detailed system diagnostics
|
|
267
|
-
*/
|
|
268
|
-
export async function diagnostics(): Promise<void> {
|
|
269
|
-
const categoryLogger = logger.createCategoryLogger('diagnostics');
|
|
270
|
-
|
|
271
|
-
try {
|
|
272
|
-
console.log(chalk.cyan('š¬ BaseGuard System Diagnostics\n'));
|
|
273
|
-
|
|
274
|
-
// Generate comprehensive debug report
|
|
275
|
-
const reportFile = await logger.generateDebugReport();
|
|
276
|
-
console.log(chalk.green(`ā
Debug report generated: ${reportFile}`));
|
|
277
|
-
|
|
278
|
-
// Show configuration recovery wizard
|
|
279
|
-
console.log(chalk.cyan('\nš§ Running Configuration Recovery Wizard...'));
|
|
280
|
-
await ConfigurationRecovery.runRecoveryWizard();
|
|
281
|
-
|
|
282
|
-
// Show service status
|
|
283
|
-
console.log(chalk.cyan('\nš Checking Service Availability...'));
|
|
284
|
-
await GracefulDegradationManager.refreshServiceStatus();
|
|
285
|
-
|
|
286
|
-
// Show error log summary
|
|
287
|
-
const loggerErrorSummary = logger.getErrorSummary();
|
|
288
|
-
if (loggerErrorSummary.totalErrors > 0) {
|
|
289
|
-
console.log(chalk.yellow(`\nā ļø Found ${loggerErrorSummary.totalErrors} errors in logs`));
|
|
290
|
-
console.log(chalk.cyan('Recent errors:'));
|
|
291
|
-
loggerErrorSummary.recentErrors.slice(0, 5).forEach(error => {
|
|
292
|
-
console.log(chalk.red(` ⢠${error.message} (${error.category})`));
|
|
293
|
-
});
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
// Cleanup old files
|
|
297
|
-
console.log(chalk.cyan('\nš§¹ Cleaning up old files...'));
|
|
298
|
-
await logger.cleanupOldLogs();
|
|
299
|
-
await GracefulDegradationManager.cleanupCache();
|
|
300
|
-
|
|
301
|
-
console.log(chalk.green('\nā
Diagnostics completed'));
|
|
302
|
-
|
|
303
|
-
} catch (error) {
|
|
304
|
-
categoryLogger.error('Diagnostics failed', { error });
|
|
305
|
-
console.log(chalk.red(`\nā Diagnostics failed: ${error instanceof Error ? error.message : 'Unknown error'}`));
|
|
306
|
-
}
|
|
1
|
+
import { BaseGuard } from '../core/baseguard.js';
|
|
2
|
+
import { ConfigurationManager } from '../core/configuration.js';
|
|
3
|
+
import { ConfigurationRecovery } from '../core/configuration-recovery.js';
|
|
4
|
+
import { GracefulDegradationManager } from '../core/graceful-degradation-manager.js';
|
|
5
|
+
import { SystemErrorHandler } from '../core/system-error-handler.js';
|
|
6
|
+
import { logger } from '../core/debug-logger.js';
|
|
7
|
+
import { UIComponents } from '../ui/components.js';
|
|
8
|
+
import chalk from 'chalk';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Show BaseGuard system status and health
|
|
12
|
+
*/
|
|
13
|
+
export async function status(options: {
|
|
14
|
+
verbose?: boolean;
|
|
15
|
+
services?: boolean;
|
|
16
|
+
config?: boolean;
|
|
17
|
+
errors?: boolean;
|
|
18
|
+
}): Promise<void> {
|
|
19
|
+
const categoryLogger = logger.createCategoryLogger('status-command');
|
|
20
|
+
|
|
21
|
+
try {
|
|
22
|
+
UIComponents.showHeader();
|
|
23
|
+
console.log(chalk.cyan('š BaseGuard System Status\n'));
|
|
24
|
+
|
|
25
|
+
// Load configuration with recovery if needed
|
|
26
|
+
let config;
|
|
27
|
+
try {
|
|
28
|
+
config = await ConfigurationManager.load();
|
|
29
|
+
} catch (error) {
|
|
30
|
+
console.log(chalk.red('ā Configuration Error'));
|
|
31
|
+
console.log(chalk.dim(` ${error instanceof Error ? error.message : 'Unknown error'}`));
|
|
32
|
+
|
|
33
|
+
if (options.config) {
|
|
34
|
+
console.log(chalk.cyan('\nš§ Configuration Recovery Options:'));
|
|
35
|
+
console.log(chalk.cyan(' ⢠Run "base config recover" to attempt automatic recovery'));
|
|
36
|
+
console.log(chalk.cyan(' ⢠Run "base init" to create a new configuration'));
|
|
37
|
+
console.log(chalk.cyan(' ⢠Check .baseguardrc.json file manually'));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Initialize BaseGuard
|
|
44
|
+
const baseGuard = new BaseGuard(config);
|
|
45
|
+
|
|
46
|
+
// Show system health
|
|
47
|
+
const health = await baseGuard.getHealthStatus();
|
|
48
|
+
|
|
49
|
+
// Overall status
|
|
50
|
+
const statusIcon = health.overall === 'healthy' ? 'ā
' : health.overall === 'degraded' ? 'ā ļø' : 'ā';
|
|
51
|
+
const statusColor = health.overall === 'healthy' ? chalk.green : health.overall === 'degraded' ? chalk.yellow : chalk.red;
|
|
52
|
+
|
|
53
|
+
console.log(statusColor(`${statusIcon} Overall Status: ${health.overall.toUpperCase()}`));
|
|
54
|
+
console.log(chalk.dim(` Degradation Mode: ${health.degradationMode}`));
|
|
55
|
+
|
|
56
|
+
// Component status
|
|
57
|
+
console.log(chalk.cyan('\nš Component Status:'));
|
|
58
|
+
for (const [component, status] of Object.entries(health.components)) {
|
|
59
|
+
const componentIcon = status.status === 'healthy' ? 'ā
' : status.status === 'degraded' ? 'ā ļø' : 'ā';
|
|
60
|
+
console.log(` ${componentIcon} ${component}: ${status.status}`);
|
|
61
|
+
|
|
62
|
+
if (options.verbose && status.details) {
|
|
63
|
+
if (status.details.errors?.length > 0) {
|
|
64
|
+
console.log(chalk.dim(` Errors: ${status.details.errors.slice(0, 3).join(', ')}`));
|
|
65
|
+
}
|
|
66
|
+
if (status.details.error) {
|
|
67
|
+
console.log(chalk.dim(` Error: ${status.details.error}`));
|
|
68
|
+
}
|
|
69
|
+
if (status.details.lastCheck) {
|
|
70
|
+
const age = Math.round((Date.now() - status.details.lastCheck) / 1000);
|
|
71
|
+
console.log(chalk.dim(` Last Check: ${age}s ago`));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Service status (if requested)
|
|
77
|
+
if (options.services) {
|
|
78
|
+
console.log(chalk.cyan('\nš Service Status:'));
|
|
79
|
+
const serviceStatus = GracefulDegradationManager.getServiceStatus();
|
|
80
|
+
|
|
81
|
+
for (const [service, info] of serviceStatus) {
|
|
82
|
+
const serviceIcon = info.available ? 'ā
' : 'ā';
|
|
83
|
+
const age = Math.round((Date.now() - info.lastCheck) / 1000);
|
|
84
|
+
console.log(` ${serviceIcon} ${service}: ${info.available ? 'Available' : 'Unavailable'} (${age}s ago)`);
|
|
85
|
+
|
|
86
|
+
if (!info.available && info.error && options.verbose) {
|
|
87
|
+
console.log(chalk.dim(` Error: ${info.error}`));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Refresh service status
|
|
92
|
+
console.log(chalk.dim('\nš Refreshing service status...'));
|
|
93
|
+
await GracefulDegradationManager.refreshServiceStatus();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Configuration status (if requested)
|
|
97
|
+
if (options.config) {
|
|
98
|
+
console.log(chalk.cyan('\nāļø Configuration Status:'));
|
|
99
|
+
|
|
100
|
+
const configIntegrity = await ConfigurationRecovery.validateIntegrity();
|
|
101
|
+
const configIcon = configIntegrity.valid ? 'ā
' : 'ā';
|
|
102
|
+
console.log(` ${configIcon} Configuration File: ${configIntegrity.valid ? 'Valid' : 'Invalid'}`);
|
|
103
|
+
|
|
104
|
+
if (!configIntegrity.valid) {
|
|
105
|
+
console.log(chalk.red(' Errors:'));
|
|
106
|
+
configIntegrity.errors.forEach(error => {
|
|
107
|
+
console.log(chalk.red(` ⢠${error}`));
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
console.log(chalk.cyan(' Suggestions:'));
|
|
111
|
+
configIntegrity.suggestions.forEach(suggestion => {
|
|
112
|
+
console.log(chalk.cyan(` ⢠${suggestion}`));
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Show configuration details
|
|
117
|
+
if (options.verbose) {
|
|
118
|
+
console.log(chalk.dim('\n Configuration Details:'));
|
|
119
|
+
console.log(chalk.dim(` Version: ${config.version}`));
|
|
120
|
+
console.log(chalk.dim(` Targets: ${config.targets.length} browser(s)`));
|
|
121
|
+
console.log(chalk.dim(` API Keys: Jules ${config.apiKeys.jules ? 'ā' : 'ā'}, Gemini ${config.apiKeys.gemini ? 'ā' : 'ā'}`));
|
|
122
|
+
console.log(chalk.dim(` Automation: ${config.automation.enabled ? 'Enabled' : 'Disabled'}`));
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Show available backups
|
|
126
|
+
const backups = await ConfigurationRecovery.listBackups();
|
|
127
|
+
if (backups.length > 0) {
|
|
128
|
+
console.log(chalk.dim(`\n Available Backups: ${backups.length}`));
|
|
129
|
+
if (options.verbose) {
|
|
130
|
+
backups.slice(0, 3).forEach(backup => {
|
|
131
|
+
console.log(chalk.dim(` ⢠${backup.timestamp.toLocaleString()} (${backup.source})`));
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// Error summary (if requested)
|
|
138
|
+
if (options.errors) {
|
|
139
|
+
console.log(chalk.cyan('\nšØ Error Summary:'));
|
|
140
|
+
|
|
141
|
+
const errorSummary = logger.getErrorSummary();
|
|
142
|
+
console.log(` Total Errors: ${errorSummary.totalErrors}`);
|
|
143
|
+
console.log(` Total Warnings: ${errorSummary.totalWarnings}`);
|
|
144
|
+
|
|
145
|
+
if (errorSummary.totalErrors > 0) {
|
|
146
|
+
console.log(chalk.red('\n Error Categories:'));
|
|
147
|
+
for (const [category, count] of Object.entries(errorSummary.errorsByCategory)) {
|
|
148
|
+
console.log(chalk.red(` ${category}: ${count}`));
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (options.verbose && errorSummary.recentErrors.length > 0) {
|
|
152
|
+
console.log(chalk.red('\n Recent Errors:'));
|
|
153
|
+
errorSummary.recentErrors.slice(0, 3).forEach(error => {
|
|
154
|
+
console.log(chalk.red(` ⢠${error.message} (${error.category})`));
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// System error handler status
|
|
160
|
+
const systemErrorSummary = SystemErrorHandler.getErrorSummary();
|
|
161
|
+
if (systemErrorSummary.total > 0) {
|
|
162
|
+
console.log(chalk.yellow('\n System Errors:'));
|
|
163
|
+
console.log(` Total: ${systemErrorSummary.total}`);
|
|
164
|
+
console.log(` Critical: ${systemErrorSummary.critical}`);
|
|
165
|
+
console.log(` Recoverable: ${systemErrorSummary.recoverable}`);
|
|
166
|
+
|
|
167
|
+
if (options.verbose) {
|
|
168
|
+
console.log(chalk.yellow('\n By Severity:'));
|
|
169
|
+
for (const [severity, count] of Object.entries(systemErrorSummary.bySeverity)) {
|
|
170
|
+
if (count > 0) {
|
|
171
|
+
console.log(` ${severity}: ${count}`);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// Recommendations
|
|
179
|
+
if (health.recommendations.length > 0) {
|
|
180
|
+
console.log(chalk.cyan('\nš” Recommendations:'));
|
|
181
|
+
health.recommendations.forEach(rec => {
|
|
182
|
+
console.log(chalk.cyan(` ⢠${rec}`));
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// Show degradation mode details
|
|
187
|
+
const mode = GracefulDegradationManager.getCurrentMode();
|
|
188
|
+
if (mode && mode.name !== 'Full Functionality') {
|
|
189
|
+
console.log(chalk.yellow(`\nā ļø Currently in ${mode.name} Mode`));
|
|
190
|
+
console.log(chalk.dim(` ${mode.description}`));
|
|
191
|
+
|
|
192
|
+
if (mode.limitations.length > 0) {
|
|
193
|
+
console.log(chalk.yellow('\n Limitations:'));
|
|
194
|
+
mode.limitations.forEach(limitation => {
|
|
195
|
+
console.log(chalk.yellow(` ⢠${limitation}`));
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
console.log(chalk.cyan('\n Available Features:'));
|
|
200
|
+
if (mode.capabilities.baselineChecking) {
|
|
201
|
+
console.log(chalk.green(' ā
Baseline compatibility checking'));
|
|
202
|
+
}
|
|
203
|
+
if (mode.capabilities.caching) {
|
|
204
|
+
console.log(chalk.green(' ā
Result caching'));
|
|
205
|
+
}
|
|
206
|
+
if (!mode.capabilities.aiAnalysis) {
|
|
207
|
+
console.log(chalk.yellow(' ā ļø AI analysis disabled'));
|
|
208
|
+
}
|
|
209
|
+
if (!mode.capabilities.autoFix) {
|
|
210
|
+
console.log(chalk.yellow(' ā ļø Auto-fixing disabled'));
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// Performance info
|
|
215
|
+
if (options.verbose) {
|
|
216
|
+
const memoryUsage = process.memoryUsage();
|
|
217
|
+
const uptime = process.uptime();
|
|
218
|
+
|
|
219
|
+
console.log(chalk.cyan('\nš Performance Info:'));
|
|
220
|
+
console.log(` Uptime: ${Math.round(uptime)}s`);
|
|
221
|
+
console.log(` Memory: ${Math.round(memoryUsage.heapUsed / 1024 / 1024)}MB used / ${Math.round(memoryUsage.heapTotal / 1024 / 1024)}MB total`);
|
|
222
|
+
console.log(` Platform: ${process.platform} ${process.arch}`);
|
|
223
|
+
console.log(` Node.js: ${process.version}`);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// Quick actions
|
|
227
|
+
console.log(chalk.cyan('\nš§ Quick Actions:'));
|
|
228
|
+
const actions = [];
|
|
229
|
+
|
|
230
|
+
if (health.overall !== 'healthy') {
|
|
231
|
+
actions.push('Run "base config recover" to attempt automatic recovery');
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
if (!mode?.capabilities.aiAnalysis) {
|
|
235
|
+
actions.push('Check network connectivity to restore AI features');
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
const errorSummary = logger.getErrorSummary();
|
|
239
|
+
if (errorSummary.totalErrors > 5) {
|
|
240
|
+
actions.push('Run with --errors flag to see detailed error information');
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
actions.push('Run "base check" to scan for compatibility issues');
|
|
244
|
+
actions.push('Run "base status --verbose" for detailed information');
|
|
245
|
+
|
|
246
|
+
actions.forEach(action => {
|
|
247
|
+
console.log(chalk.cyan(` ⢠${action}`));
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
} catch (error) {
|
|
251
|
+
categoryLogger.error('Status command failed', { error });
|
|
252
|
+
|
|
253
|
+
console.log(chalk.red('\nā Failed to get system status'));
|
|
254
|
+
console.log(chalk.red(` Error: ${error instanceof Error ? error.message : 'Unknown error'}`));
|
|
255
|
+
|
|
256
|
+
console.log(chalk.cyan('\nš§ Recovery Options:'));
|
|
257
|
+
console.log(chalk.cyan(' ⢠Run "base init" to reinitialize BaseGuard'));
|
|
258
|
+
console.log(chalk.cyan(' ⢠Check file permissions in your project directory'));
|
|
259
|
+
console.log(chalk.cyan(' ⢠Verify BaseGuard installation: npm list baseguard'));
|
|
260
|
+
|
|
261
|
+
process.exit(1);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Show detailed system diagnostics
|
|
267
|
+
*/
|
|
268
|
+
export async function diagnostics(): Promise<void> {
|
|
269
|
+
const categoryLogger = logger.createCategoryLogger('diagnostics');
|
|
270
|
+
|
|
271
|
+
try {
|
|
272
|
+
console.log(chalk.cyan('š¬ BaseGuard System Diagnostics\n'));
|
|
273
|
+
|
|
274
|
+
// Generate comprehensive debug report
|
|
275
|
+
const reportFile = await logger.generateDebugReport();
|
|
276
|
+
console.log(chalk.green(`ā
Debug report generated: ${reportFile}`));
|
|
277
|
+
|
|
278
|
+
// Show configuration recovery wizard
|
|
279
|
+
console.log(chalk.cyan('\nš§ Running Configuration Recovery Wizard...'));
|
|
280
|
+
await ConfigurationRecovery.runRecoveryWizard();
|
|
281
|
+
|
|
282
|
+
// Show service status
|
|
283
|
+
console.log(chalk.cyan('\nš Checking Service Availability...'));
|
|
284
|
+
await GracefulDegradationManager.refreshServiceStatus();
|
|
285
|
+
|
|
286
|
+
// Show error log summary
|
|
287
|
+
const loggerErrorSummary = logger.getErrorSummary();
|
|
288
|
+
if (loggerErrorSummary.totalErrors > 0) {
|
|
289
|
+
console.log(chalk.yellow(`\nā ļø Found ${loggerErrorSummary.totalErrors} errors in logs`));
|
|
290
|
+
console.log(chalk.cyan('Recent errors:'));
|
|
291
|
+
loggerErrorSummary.recentErrors.slice(0, 5).forEach(error => {
|
|
292
|
+
console.log(chalk.red(` ⢠${error.message} (${error.category})`));
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// Cleanup old files
|
|
297
|
+
console.log(chalk.cyan('\nš§¹ Cleaning up old files...'));
|
|
298
|
+
await logger.cleanupOldLogs();
|
|
299
|
+
await GracefulDegradationManager.cleanupCache();
|
|
300
|
+
|
|
301
|
+
console.log(chalk.green('\nā
Diagnostics completed'));
|
|
302
|
+
|
|
303
|
+
} catch (error) {
|
|
304
|
+
categoryLogger.error('Diagnostics failed', { error });
|
|
305
|
+
console.log(chalk.red(`\nā Diagnostics failed: ${error instanceof Error ? error.message : 'Unknown error'}`));
|
|
306
|
+
}
|
|
307
307
|
}
|