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/bin/base.js
CHANGED
|
@@ -1,628 +1,628 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { Command } from 'commander';
|
|
4
|
-
import chalk from 'chalk';
|
|
5
|
-
import { init, check, fix, config, automation, status, diagnostics } from '../dist/commands/index.js';
|
|
6
|
-
import { showTerminalHeader, showVersionInfo, showGlobalHelp } from '../dist/ui/index.js';
|
|
7
|
-
import { StartupOptimizer } from '../dist/core/startup-optimizer.js';
|
|
8
|
-
|
|
9
|
-
// Initialize startup optimizations with timeout
|
|
10
|
-
const startupPromise = Promise.race([
|
|
11
|
-
StartupOptimizer.initialize().then(() => {
|
|
12
|
-
// Run additional startup optimizations
|
|
13
|
-
return StartupOptimizer.optimizeStartup();
|
|
14
|
-
}),
|
|
15
|
-
new Promise(resolve => setTimeout(resolve, 1000)) // Max 1 second for startup
|
|
16
|
-
]).catch(() => {
|
|
17
|
-
// Ignore startup errors, continue with CLI
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
const program = new Command();
|
|
21
|
-
|
|
22
|
-
program
|
|
23
|
-
.name('base')
|
|
24
|
-
.description(chalk.cyan('🛡️ BaseGuard - Never ship incompatible code again\n') +
|
|
25
|
-
chalk.dim('Intelligent browser compatibility enforcement with AI-powered analysis and autonomous fixing'))
|
|
26
|
-
.version('1.0.3')
|
|
27
|
-
.configureOutput({
|
|
28
|
-
outputError: (str, write) => write(chalk.red(str))
|
|
29
|
-
})
|
|
30
|
-
.configureHelp({
|
|
31
|
-
helpWidth: 100,
|
|
32
|
-
sortSubcommands: true
|
|
33
|
-
})
|
|
34
|
-
.addHelpText('after', `
|
|
35
|
-
${chalk.cyan('Examples:')}
|
|
36
|
-
${chalk.dim('$')} base init ${chalk.gray('# Initialize BaseGuard in your project')}
|
|
37
|
-
${chalk.dim('$')} base check ${chalk.gray('# Check for compatibility violations')}
|
|
38
|
-
${chalk.dim('$')} base fix ${chalk.gray('# Fix violations with AI assistance')}
|
|
39
|
-
${chalk.dim('$')} base config set-keys ${chalk.gray('# Configure API keys for AI services')}
|
|
40
|
-
${chalk.dim('$')} base automation enable ${chalk.gray('# Enable git hooks for automatic checking')}
|
|
41
|
-
|
|
42
|
-
${chalk.cyan('Getting Started:')}
|
|
43
|
-
1. Run ${chalk.white('base init')} to set up BaseGuard in your project
|
|
44
|
-
2. Configure API keys with ${chalk.white('base config set-keys')} for AI features
|
|
45
|
-
3. Enable automation with ${chalk.white('base automation enable')}
|
|
46
|
-
4. Check compatibility with ${chalk.white('base check')}
|
|
47
|
-
|
|
48
|
-
${chalk.cyan('Documentation:')}
|
|
49
|
-
${chalk.blue('https://github.com/baseguard/baseguard#readme')}
|
|
50
|
-
|
|
51
|
-
${chalk.cyan('Support:')}
|
|
52
|
-
${chalk.blue('https://github.com/baseguard/baseguard/issues')}
|
|
53
|
-
`);
|
|
54
|
-
|
|
55
|
-
// Initialize BaseGuard in project
|
|
56
|
-
program
|
|
57
|
-
.command('init')
|
|
58
|
-
.description('Initialize BaseGuard in your project with guided setup')
|
|
59
|
-
.option('--preset <preset>', 'Browser target preset (baseline-widely, baseline-newly, last-2-years, custom)', 'baseline-widely')
|
|
60
|
-
.option('--skip-hooks', 'Skip git hook installation during setup')
|
|
61
|
-
.option('--skip-api-keys', 'Skip API key configuration during setup')
|
|
62
|
-
.addHelpText('after', `
|
|
63
|
-
${chalk.cyan('Browser Target Presets:')}
|
|
64
|
-
${chalk.white('baseline-widely')} Support features available in Baseline for 30+ months
|
|
65
|
-
${chalk.white('baseline-newly')} Support newly available Baseline features
|
|
66
|
-
${chalk.white('last-2-years')} Support browsers from the last 2 years
|
|
67
|
-
${chalk.white('custom')} Configure custom browser targets interactively
|
|
68
|
-
|
|
69
|
-
${chalk.cyan('Examples:')}
|
|
70
|
-
${chalk.dim('$')} base init ${chalk.gray('# Interactive setup with baseline-widely preset')}
|
|
71
|
-
${chalk.dim('$')} base init --preset baseline-newly ${chalk.gray('# Use baseline-newly preset')}
|
|
72
|
-
${chalk.dim('$')} base init --skip-hooks ${chalk.gray('# Skip git hook installation')}
|
|
73
|
-
${chalk.dim('$')} base init --preset custom ${chalk.gray('# Configure custom browser targets')}
|
|
74
|
-
|
|
75
|
-
${chalk.cyan('What this does:')}
|
|
76
|
-
• Creates .baseguardrc.json configuration file
|
|
77
|
-
• Sets up browser compatibility targets
|
|
78
|
-
• Configures API keys for AI services (optional)
|
|
79
|
-
• Installs git hooks for automation (optional)
|
|
80
|
-
• Adds .baseguardrc.json to .gitignore for security
|
|
81
|
-
`)
|
|
82
|
-
.action(async (options) => {
|
|
83
|
-
await startupPromise;
|
|
84
|
-
await StartupOptimizer.optimizeForUseCase('init');
|
|
85
|
-
return init(options);
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
// Check for compatibility violations
|
|
89
|
-
program
|
|
90
|
-
.command('check')
|
|
91
|
-
.description('Scan code for browser compatibility violations using Baseline data')
|
|
92
|
-
.option('--strict', 'Exit with error code if violations are found (useful for CI/CD)')
|
|
93
|
-
.option('--files <pattern>', 'File pattern to check using glob syntax', '**/*.{js,jsx,ts,tsx,vue,svelte,css,html}')
|
|
94
|
-
.option('--format <format>', 'Output format for results', 'table')
|
|
95
|
-
.option('--debug', 'Enable debug logging for troubleshooting')
|
|
96
|
-
.option('--offline', 'Run in offline mode (no network requests)')
|
|
97
|
-
.addHelpText('after', `
|
|
98
|
-
${chalk.cyan('Output Formats:')}
|
|
99
|
-
${chalk.white('table')} Human-readable table format (default)
|
|
100
|
-
${chalk.white('json')} JSON format for programmatic use
|
|
101
|
-
${chalk.white('junit')} JUnit XML format for CI/CD integration
|
|
102
|
-
|
|
103
|
-
${chalk.cyan('Examples:')}
|
|
104
|
-
${chalk.dim('$')} base check ${chalk.gray('# Check all supported files')}
|
|
105
|
-
${chalk.dim('$')} base check --strict ${chalk.gray('# Exit with error if violations found')}
|
|
106
|
-
${chalk.dim('$')} base check --files "src/**/*.ts" ${chalk.gray('# Check only TypeScript files in src/')}
|
|
107
|
-
${chalk.dim('$')} base check --format json ${chalk.gray('# Output results as JSON')}
|
|
108
|
-
${chalk.dim('$')} base check --files "*.css" --strict ${chalk.gray('# Check CSS files with strict mode')}
|
|
109
|
-
|
|
110
|
-
${chalk.cyan('File Patterns:')}
|
|
111
|
-
Supports glob patterns like:
|
|
112
|
-
• ${chalk.white('"src/**/*.{js,ts}"')} - All JS/TS files in src/ and subdirectories
|
|
113
|
-
• ${chalk.white('"components/*.vue"')} - All Vue files in components/
|
|
114
|
-
• ${chalk.white('"**/*.css"')} - All CSS files in project
|
|
115
|
-
|
|
116
|
-
${chalk.cyan('What this checks:')}
|
|
117
|
-
• CSS properties, selectors, and at-rules
|
|
118
|
-
• JavaScript APIs and ECMAScript features
|
|
119
|
-
• HTML elements and attributes
|
|
120
|
-
• Framework-specific files (React, Vue, Svelte)
|
|
121
|
-
• Web platform APIs (Canvas, WebGL, WebRTC, WebAssembly, etc.)
|
|
122
|
-
`)
|
|
123
|
-
.action(async (options) => {
|
|
124
|
-
await startupPromise;
|
|
125
|
-
await StartupOptimizer.optimizeForUseCase('check');
|
|
126
|
-
return check(options);
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
// Fix violations with AI
|
|
130
|
-
program
|
|
131
|
-
.command('fix')
|
|
132
|
-
.description('Analyze and fix compatibility violations using AI (requires API keys)')
|
|
133
|
-
.option('--auto', 'Apply fixes automatically without interactive confirmation')
|
|
134
|
-
.option('--analyze-only', 'Only run AI analysis without generating code fixes')
|
|
135
|
-
.option('--files <pattern>', 'File pattern to fix using glob syntax', '**/*.{js,jsx,ts,tsx,vue,svelte,css,html}')
|
|
136
|
-
.addHelpText('after', `
|
|
137
|
-
${chalk.cyan('Prerequisites:')}
|
|
138
|
-
• Gemini API key (for analysis and fixing) - Get from ${chalk.blue('https://aistudio.google.com')}
|
|
139
|
-
• Jules API key (optional, for GitHub repos) - Get from ${chalk.blue('https://jules.google.com')}
|
|
140
|
-
• Choose your coding agent: "base config coding-agent"
|
|
141
|
-
|
|
142
|
-
${chalk.cyan('Examples:')}
|
|
143
|
-
${chalk.dim('$')} base fix ${chalk.gray('# Interactive fix with confirmation prompts')}
|
|
144
|
-
${chalk.dim('$')} base fix --auto ${chalk.gray('# Apply all fixes automatically')}
|
|
145
|
-
${chalk.dim('$')} base fix --analyze-only ${chalk.gray('# Only analyze, don\'t generate fixes')}
|
|
146
|
-
${chalk.dim('$')} base fix --files "src/**/*.css" ${chalk.gray('# Fix only CSS files in src/')}
|
|
147
|
-
|
|
148
|
-
${chalk.cyan('How it works:')}
|
|
149
|
-
1. ${chalk.white('Scan')} - Detects compatibility violations using Baseline data
|
|
150
|
-
2. ${chalk.white('Analyze')} - Gemini AI researches impact and fix strategies
|
|
151
|
-
3. ${chalk.white('Fix')} - AI generates progressive enhancement code (Jules or Gemini)
|
|
152
|
-
4. ${chalk.white('Review')} - Shows preview of changes before applying
|
|
153
|
-
5. ${chalk.white('Apply')} - Updates files with compatibility fixes
|
|
154
|
-
|
|
155
|
-
${chalk.cyan('Coding Agents:')}
|
|
156
|
-
• ${chalk.white('Gemini 2.5 Pro')} - Works with any files, immediate processing
|
|
157
|
-
• ${chalk.white('Jules')} - GitHub repos only, autonomous cloud processing
|
|
158
|
-
|
|
159
|
-
${chalk.cyan('Fix Strategies:')}
|
|
160
|
-
• Progressive enhancement with @supports for CSS
|
|
161
|
-
• Feature detection for JavaScript APIs
|
|
162
|
-
• Polyfills and fallbacks for older browsers
|
|
163
|
-
• Graceful degradation patterns
|
|
164
|
-
|
|
165
|
-
${chalk.cyan('Setup:')}
|
|
166
|
-
Run ${chalk.white('base config set-keys')} to configure API keys
|
|
167
|
-
Run ${chalk.white('base config coding-agent')} to choose your preferred agent
|
|
168
|
-
`)
|
|
169
|
-
.action(async (options) => {
|
|
170
|
-
await startupPromise;
|
|
171
|
-
await StartupOptimizer.optimizeForUseCase('fix');
|
|
172
|
-
return fix(options);
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
// Configuration management
|
|
176
|
-
const configCmd = program
|
|
177
|
-
.command('config')
|
|
178
|
-
.description('Manage BaseGuard configuration and settings')
|
|
179
|
-
.addHelpText('after', `
|
|
180
|
-
${chalk.cyan('Configuration Commands:')}
|
|
181
|
-
${chalk.white('show')} Display detailed configuration with security status
|
|
182
|
-
${chalk.white('list')} Show configuration summary (supports --format json)
|
|
183
|
-
${chalk.white('set-keys')} Interactive API key setup with browser integration
|
|
184
|
-
${chalk.white('targets')} Manage browser compatibility targets
|
|
185
|
-
${chalk.white('validate')} Check configuration file for errors
|
|
186
|
-
${chalk.white('automation')} Configure git automation settings
|
|
187
|
-
|
|
188
|
-
${chalk.cyan('Examples:')}
|
|
189
|
-
${chalk.dim('$')} base config show ${chalk.gray('# Show detailed configuration')}
|
|
190
|
-
${chalk.dim('$')} base config set-keys ${chalk.gray('# Set up API keys interactively')}
|
|
191
|
-
${chalk.dim('$')} base config list --format json ${chalk.gray('# Export configuration as JSON')}
|
|
192
|
-
${chalk.dim('$')} base config targets --preset baseline-widely ${chalk.gray('# Set browser targets')}
|
|
193
|
-
`);
|
|
194
|
-
|
|
195
|
-
configCmd
|
|
196
|
-
.command('show')
|
|
197
|
-
.description('Display detailed configuration with security and validation status')
|
|
198
|
-
.addHelpText('after', `
|
|
199
|
-
${chalk.cyan('What this shows:')}
|
|
200
|
-
• Current browser targets and presets
|
|
201
|
-
• API key configuration status (without exposing keys)
|
|
202
|
-
• Automation and git hook settings
|
|
203
|
-
• Security status (.gitignore configuration)
|
|
204
|
-
• Configuration validation results
|
|
205
|
-
• Recommendations for improvements
|
|
206
|
-
`)
|
|
207
|
-
.action(() => config('show'));
|
|
208
|
-
|
|
209
|
-
configCmd
|
|
210
|
-
.command('set-keys')
|
|
211
|
-
.description('Interactive setup of API keys for AI services')
|
|
212
|
-
.addHelpText('after', `
|
|
213
|
-
${chalk.cyan('API Services:')}
|
|
214
|
-
${chalk.white('Gemini')} - For AI analysis of compatibility issues
|
|
215
|
-
Get your key: ${chalk.blue('https://aistudio.google.com')}
|
|
216
|
-
|
|
217
|
-
${chalk.white('Jules')} - For autonomous code fixing
|
|
218
|
-
Get your key: ${chalk.blue('https://jules.google.com')}
|
|
219
|
-
|
|
220
|
-
${chalk.cyan('Security:')}
|
|
221
|
-
• Keys are stored in .baseguardrc.json
|
|
222
|
-
• File is automatically added to .gitignore
|
|
223
|
-
• Keys are validated before saving
|
|
224
|
-
`)
|
|
225
|
-
.action(() => config('set-keys'));
|
|
226
|
-
|
|
227
|
-
configCmd
|
|
228
|
-
.command('targets')
|
|
229
|
-
.description('Manage browser compatibility targets')
|
|
230
|
-
.option('--add <target>', 'Add browser target (format: "browser version")')
|
|
231
|
-
.option('--remove <target>', 'Remove browser target by name')
|
|
232
|
-
.option('--preset <preset>', 'Set predefined browser targets')
|
|
233
|
-
.addHelpText('after', `
|
|
234
|
-
${chalk.cyan('Target Formats:')}
|
|
235
|
-
${chalk.white('"chrome 100"')} Minimum Chrome version 100
|
|
236
|
-
${chalk.white('"safari baseline"')} Safari with Baseline support only
|
|
237
|
-
${chalk.white('"firefox 90"')} Minimum Firefox version 90
|
|
238
|
-
|
|
239
|
-
${chalk.cyan('Available Presets:')}
|
|
240
|
-
${chalk.white('baseline-widely')} Features available for 30+ months
|
|
241
|
-
${chalk.white('baseline-newly')} Newly available Baseline features
|
|
242
|
-
${chalk.white('last-2-years')} Browsers from last 2 years
|
|
243
|
-
|
|
244
|
-
${chalk.cyan('Examples:')}
|
|
245
|
-
${chalk.dim('$')} base config targets --add "chrome 100"
|
|
246
|
-
${chalk.dim('$')} base config targets --remove chrome
|
|
247
|
-
${chalk.dim('$')} base config targets --preset baseline-widely
|
|
248
|
-
`)
|
|
249
|
-
.action((options) => config('targets', options));
|
|
250
|
-
|
|
251
|
-
configCmd
|
|
252
|
-
.command('list')
|
|
253
|
-
.description('Show configuration summary with status information')
|
|
254
|
-
.option('--format <format>', 'Output format (table or json)', 'table')
|
|
255
|
-
.addHelpText('after', `
|
|
256
|
-
${chalk.cyan('Output Formats:')}
|
|
257
|
-
${chalk.white('table')} Human-readable summary (default)
|
|
258
|
-
${chalk.white('json')} Machine-readable JSON for scripts
|
|
259
|
-
|
|
260
|
-
${chalk.cyan('Includes:')}
|
|
261
|
-
• Browser targets and count
|
|
262
|
-
• API key configuration status
|
|
263
|
-
• Automation settings
|
|
264
|
-
• Security and validation status
|
|
265
|
-
`)
|
|
266
|
-
.action((options) => config('list', options));
|
|
267
|
-
|
|
268
|
-
configCmd
|
|
269
|
-
.command('validate')
|
|
270
|
-
.description('Validate configuration file for errors and inconsistencies')
|
|
271
|
-
.addHelpText('after', `
|
|
272
|
-
${chalk.cyan('Validation Checks:')}
|
|
273
|
-
• Configuration file syntax and structure
|
|
274
|
-
• Browser target format and validity
|
|
275
|
-
• API key format validation
|
|
276
|
-
• Automation setting consistency
|
|
277
|
-
• Required field presence
|
|
278
|
-
|
|
279
|
-
${chalk.cyan('Exit Codes:')}
|
|
280
|
-
0 - Configuration is valid
|
|
281
|
-
1 - Validation errors found
|
|
282
|
-
`)
|
|
283
|
-
.action(() => config('validate'));
|
|
284
|
-
|
|
285
|
-
configCmd
|
|
286
|
-
.command('automation')
|
|
287
|
-
.description('Configure git automation settings interactively')
|
|
288
|
-
.addHelpText('after', `
|
|
289
|
-
${chalk.cyan('Automation Settings:')}
|
|
290
|
-
• Enable/disable git hooks
|
|
291
|
-
• Choose trigger (pre-commit or pre-push)
|
|
292
|
-
• Configure auto-analysis with Gemini
|
|
293
|
-
• Configure auto-fixing with Jules
|
|
294
|
-
• Set commit blocking behavior
|
|
295
|
-
`)
|
|
296
|
-
.action(() => config('automation'));
|
|
297
|
-
|
|
298
|
-
configCmd
|
|
299
|
-
.command('recover')
|
|
300
|
-
.description('Attempt automatic recovery of corrupted configuration')
|
|
301
|
-
.option('--backup', 'Create backup before recovery')
|
|
302
|
-
.option('--interactive', 'Run interactive recovery wizard')
|
|
303
|
-
.addHelpText('after', `
|
|
304
|
-
${chalk.cyan('Recovery Features:')}
|
|
305
|
-
• Automatic detection of configuration issues
|
|
306
|
-
• Repair of corrupted JSON syntax
|
|
307
|
-
• Migration from older configuration versions
|
|
308
|
-
• Validation and structure repair
|
|
309
|
-
• Backup creation before changes
|
|
310
|
-
|
|
311
|
-
${chalk.cyan('Recovery Process:')}
|
|
312
|
-
1. Validates current configuration
|
|
313
|
-
2. Creates backup if requested
|
|
314
|
-
3. Attempts automatic repair
|
|
315
|
-
4. Migrates to current version
|
|
316
|
-
5. Validates final result
|
|
317
|
-
|
|
318
|
-
${chalk.cyan('Examples:')}
|
|
319
|
-
${chalk.dim('$')} base config recover ${chalk.gray('# Automatic recovery')}
|
|
320
|
-
${chalk.dim('$')} base config recover --backup ${chalk.gray('# Create backup first')}
|
|
321
|
-
${chalk.dim('$')} base config recover --interactive ${chalk.gray('# Interactive wizard')}
|
|
322
|
-
`)
|
|
323
|
-
.action((options) => config('recover', options));
|
|
324
|
-
|
|
325
|
-
configCmd
|
|
326
|
-
.command('coding-agent')
|
|
327
|
-
.description('Manage coding agent selection (Jules vs Gemini)')
|
|
328
|
-
.option('--agent <agent>', 'Set primary agent (jules or gemini)')
|
|
329
|
-
.option('--show', 'Show current agent configuration and status')
|
|
330
|
-
.addHelpText('after', `
|
|
331
|
-
${chalk.cyan('Coding Agents:')}
|
|
332
|
-
${chalk.white('Jules')} - Google's autonomous coding agent (GitHub repos only)
|
|
333
|
-
${chalk.white('Gemini')} - Gemini 2.5 Pro direct API (works with any files)
|
|
334
|
-
|
|
335
|
-
${chalk.cyan('Agent Comparison:')}
|
|
336
|
-
Jules:
|
|
337
|
-
✅ Autonomous operation in cloud VMs
|
|
338
|
-
✅ Full repository context understanding
|
|
339
|
-
✅ Asynchronous processing
|
|
340
|
-
❌ Requires GitHub repository
|
|
341
|
-
❌ Cannot work with local/uncommitted files
|
|
342
|
-
|
|
343
|
-
Gemini:
|
|
344
|
-
✅ Works with any files (GitHub or not)
|
|
345
|
-
✅ Immediate processing
|
|
346
|
-
✅ Works with uncommitted/local files
|
|
347
|
-
✅ Grounded with real-time web search
|
|
348
|
-
⚠️ Requires manual code application
|
|
349
|
-
|
|
350
|
-
${chalk.cyan('Examples:')}
|
|
351
|
-
${chalk.dim('$')} base config coding-agent --show ${chalk.gray('# Show current configuration')}
|
|
352
|
-
${chalk.dim('$')} base config coding-agent --agent gemini ${chalk.gray('# Set Gemini as primary')}
|
|
353
|
-
${chalk.dim('$')} base config coding-agent --agent jules ${chalk.gray('# Set Jules as primary')}
|
|
354
|
-
${chalk.dim('$')} base config coding-agent ${chalk.gray('# Interactive selection')}
|
|
355
|
-
`)
|
|
356
|
-
.action((options) => config('coding-agent', options));
|
|
357
|
-
|
|
358
|
-
// Automation and git hooks
|
|
359
|
-
const autoCmd = program
|
|
360
|
-
.command('automation')
|
|
361
|
-
.alias('auto')
|
|
362
|
-
.description('Manage git automation and hooks for continuous compatibility checking')
|
|
363
|
-
.addHelpText('after', `
|
|
364
|
-
${chalk.cyan('Automation Features:')}
|
|
365
|
-
• Automatic compatibility checking on git operations
|
|
366
|
-
• AI-powered analysis and fixing integration
|
|
367
|
-
• Commit blocking when violations are found
|
|
368
|
-
• Configurable triggers (pre-commit or pre-push)
|
|
369
|
-
|
|
370
|
-
${chalk.cyan('Examples:')}
|
|
371
|
-
${chalk.dim('$')} base automation enable ${chalk.gray('# Enable with interactive setup')}
|
|
372
|
-
${chalk.dim('$')} base automation enable --trigger pre-push ${chalk.gray('# Enable with pre-push trigger')}
|
|
373
|
-
${chalk.dim('$')} base automation status ${chalk.gray('# Show current automation status')}
|
|
374
|
-
${chalk.dim('$')} base automation disable ${chalk.gray('# Disable automation and remove hooks')}
|
|
375
|
-
`);
|
|
376
|
-
|
|
377
|
-
autoCmd
|
|
378
|
-
.command('enable')
|
|
379
|
-
.description('Enable git automation with hook installation')
|
|
380
|
-
.option('--trigger <trigger>', 'When to run checks (pre-commit or pre-push)', 'pre-commit')
|
|
381
|
-
.option('--auto-fix', 'Enable automatic fixing of violations')
|
|
382
|
-
.addHelpText('after', `
|
|
383
|
-
${chalk.cyan('Trigger Options:')}
|
|
384
|
-
${chalk.white('pre-commit')} Check before each commit (faster feedback)
|
|
385
|
-
${chalk.white('pre-push')} Check before each push (less frequent)
|
|
386
|
-
|
|
387
|
-
${chalk.cyan('What this does:')}
|
|
388
|
-
• Installs git hooks using Husky
|
|
389
|
-
• Configures BaseGuard to run automatically
|
|
390
|
-
• Sets up automation preferences
|
|
391
|
-
• Updates .baseguardrc.json configuration
|
|
392
|
-
|
|
393
|
-
${chalk.cyan('Requirements:')}
|
|
394
|
-
• Git repository (run ${chalk.white('git init')} first)
|
|
395
|
-
• Node.js project with package.json
|
|
396
|
-
`)
|
|
397
|
-
.action((options) => automation('enable', options));
|
|
398
|
-
|
|
399
|
-
autoCmd
|
|
400
|
-
.command('disable')
|
|
401
|
-
.description('Disable git automation and remove hooks')
|
|
402
|
-
.addHelpText('after', `
|
|
403
|
-
${chalk.cyan('What this does:')}
|
|
404
|
-
• Removes git hooks from .husky/ directory
|
|
405
|
-
• Disables automation in configuration
|
|
406
|
-
• Preserves other BaseGuard settings
|
|
407
|
-
|
|
408
|
-
${chalk.cyan('Note:')}
|
|
409
|
-
You can re-enable automation anytime with ${chalk.white('base automation enable')}
|
|
410
|
-
`)
|
|
411
|
-
.action(() => automation('disable'));
|
|
412
|
-
|
|
413
|
-
autoCmd
|
|
414
|
-
.command('run')
|
|
415
|
-
.description('Run automation manually (used internally by git hooks)')
|
|
416
|
-
.option('--trigger <trigger>', 'Trigger context (pre-commit or pre-push)')
|
|
417
|
-
.addHelpText('after', `
|
|
418
|
-
${chalk.cyan('Usage:')}
|
|
419
|
-
This command is typically called by git hooks automatically.
|
|
420
|
-
You can run it manually for testing automation behavior.
|
|
421
|
-
|
|
422
|
-
${chalk.cyan('Examples:')}
|
|
423
|
-
${chalk.dim('$')} base automation run --trigger pre-commit
|
|
424
|
-
${chalk.dim('$')} base automation run --trigger pre-push
|
|
425
|
-
`)
|
|
426
|
-
.action((options) => automation('run', options));
|
|
427
|
-
|
|
428
|
-
autoCmd
|
|
429
|
-
.command('status')
|
|
430
|
-
.description('Show detailed automation status and configuration')
|
|
431
|
-
.addHelpText('after', `
|
|
432
|
-
${chalk.cyan('Status Information:')}
|
|
433
|
-
• Automation enabled/disabled state
|
|
434
|
-
• Git hook installation status
|
|
435
|
-
• Trigger configuration (pre-commit/pre-push)
|
|
436
|
-
• Auto-analysis and auto-fix settings
|
|
437
|
-
• API key configuration status
|
|
438
|
-
• Recommendations for setup improvements
|
|
439
|
-
`)
|
|
440
|
-
.action(() => automation('status'));
|
|
441
|
-
|
|
442
|
-
autoCmd
|
|
443
|
-
.command('configure')
|
|
444
|
-
.description('Interactive configuration of all automation settings')
|
|
445
|
-
.addHelpText('after', `
|
|
446
|
-
${chalk.cyan('Configuration Options:')}
|
|
447
|
-
• Enable/disable automation
|
|
448
|
-
• Choose trigger timing
|
|
449
|
-
• Configure AI analysis settings
|
|
450
|
-
• Configure AI fixing settings
|
|
451
|
-
• Set commit blocking behavior
|
|
452
|
-
|
|
453
|
-
${chalk.cyan('Interactive Setup:')}
|
|
454
|
-
Guides you through all automation options with explanations
|
|
455
|
-
and recommendations based on your current configuration.
|
|
456
|
-
`)
|
|
457
|
-
.action(() => automation('configure'));
|
|
458
|
-
|
|
459
|
-
// Browser target management commands (shortcuts)
|
|
460
|
-
program
|
|
461
|
-
.command('add <target>')
|
|
462
|
-
.description('Add browser target (shortcut for config targets --add)')
|
|
463
|
-
.addHelpText('after', `
|
|
464
|
-
${chalk.cyan('Target Format:')}
|
|
465
|
-
"browser version" - e.g., "chrome 100", "safari 15", "firefox baseline"
|
|
466
|
-
|
|
467
|
-
${chalk.cyan('Examples:')}
|
|
468
|
-
${chalk.dim('$')} base add "chrome 100" ${chalk.gray('# Add Chrome 100+ support')}
|
|
469
|
-
${chalk.dim('$')} base add "safari baseline" ${chalk.gray('# Add Safari with Baseline support')}
|
|
470
|
-
${chalk.dim('$')} base add "firefox 90" ${chalk.gray('# Add Firefox 90+ support')}
|
|
471
|
-
`)
|
|
472
|
-
.action((target) => config('targets', { add: target }));
|
|
473
|
-
|
|
474
|
-
program
|
|
475
|
-
.command('remove <target>')
|
|
476
|
-
.description('Remove browser target (shortcut for config targets --remove)')
|
|
477
|
-
.addHelpText('after', `
|
|
478
|
-
${chalk.cyan('Examples:')}
|
|
479
|
-
${chalk.dim('$')} base remove chrome ${chalk.gray('# Remove all Chrome targets')}
|
|
480
|
-
${chalk.dim('$')} base remove safari ${chalk.gray('# Remove all Safari targets')}
|
|
481
|
-
${chalk.dim('$')} base remove firefox ${chalk.gray('# Remove all Firefox targets')}
|
|
482
|
-
`)
|
|
483
|
-
.action((target) => config('targets', { remove: target }));
|
|
484
|
-
|
|
485
|
-
program
|
|
486
|
-
.command('list')
|
|
487
|
-
.description('List configuration summary (shortcut for config list)')
|
|
488
|
-
.option('--format <format>', 'Output format (table or json)', 'table')
|
|
489
|
-
.addHelpText('after', `
|
|
490
|
-
${chalk.cyan('Quick Status:')}
|
|
491
|
-
Shows browser targets, API keys, automation status, and security info.
|
|
492
|
-
|
|
493
|
-
${chalk.cyan('Examples:')}
|
|
494
|
-
${chalk.dim('$')} base list ${chalk.gray('# Show configuration summary')}
|
|
495
|
-
${chalk.dim('$')} base list --format json ${chalk.gray('# Export as JSON')}
|
|
496
|
-
`)
|
|
497
|
-
.action((options) => config('list', options));
|
|
498
|
-
|
|
499
|
-
// System status and health
|
|
500
|
-
program
|
|
501
|
-
.command('status')
|
|
502
|
-
.description('Show BaseGuard system status and health information')
|
|
503
|
-
.option('--verbose', 'Show detailed status information')
|
|
504
|
-
.option('--services', 'Check external service availability')
|
|
505
|
-
.option('--config', 'Show configuration status and validation')
|
|
506
|
-
.option('--errors', 'Show error summary and recent issues')
|
|
507
|
-
.addHelpText('after', `
|
|
508
|
-
${chalk.cyan('Status Information:')}
|
|
509
|
-
• Overall system health (healthy/degraded/critical)
|
|
510
|
-
• Component status (configuration, services, errors)
|
|
511
|
-
• Current degradation mode and limitations
|
|
512
|
-
• Service availability (network, APIs)
|
|
513
|
-
• Configuration validation results
|
|
514
|
-
• Error summary and recent issues
|
|
515
|
-
• Performance information
|
|
516
|
-
• Recovery recommendations
|
|
517
|
-
|
|
518
|
-
${chalk.cyan('Examples:')}
|
|
519
|
-
${chalk.dim('$')} base status ${chalk.gray('# Show basic system status')}
|
|
520
|
-
${chalk.dim('$')} base status --verbose ${chalk.gray('# Show detailed information')}
|
|
521
|
-
${chalk.dim('$')} base status --services ${chalk.gray('# Check service availability')}
|
|
522
|
-
${chalk.dim('$')} base status --config ${chalk.gray('# Show configuration status')}
|
|
523
|
-
${chalk.dim('$')} base status --errors ${chalk.gray('# Show error information')}
|
|
524
|
-
|
|
525
|
-
${chalk.cyan('Health Levels:')}
|
|
526
|
-
${chalk.green('✅ Healthy')} All systems operational
|
|
527
|
-
${chalk.yellow('⚠️ Degraded')} Some features limited
|
|
528
|
-
${chalk.red('❌ Critical')} Major issues detected
|
|
529
|
-
`)
|
|
530
|
-
.action(async (options) => {
|
|
531
|
-
await startupPromise;
|
|
532
|
-
return status(options);
|
|
533
|
-
});
|
|
534
|
-
|
|
535
|
-
// System diagnostics
|
|
536
|
-
program
|
|
537
|
-
.command('diagnostics')
|
|
538
|
-
.alias('diag')
|
|
539
|
-
.description('Run comprehensive system diagnostics and recovery')
|
|
540
|
-
.addHelpText('after', `
|
|
541
|
-
${chalk.cyan('Diagnostic Features:')}
|
|
542
|
-
• Generate detailed debug report
|
|
543
|
-
• Run configuration recovery wizard
|
|
544
|
-
• Check service availability
|
|
545
|
-
• Show error log summary
|
|
546
|
-
• Clean up old files and caches
|
|
547
|
-
• Provide recovery recommendations
|
|
548
|
-
|
|
549
|
-
${chalk.cyan('What this does:')}
|
|
550
|
-
1. Creates comprehensive debug report
|
|
551
|
-
2. Attempts automatic configuration recovery
|
|
552
|
-
3. Checks all external services
|
|
553
|
-
4. Analyzes error logs for patterns
|
|
554
|
-
5. Cleans up temporary files
|
|
555
|
-
6. Provides actionable recommendations
|
|
556
|
-
|
|
557
|
-
${chalk.cyan('Use when:')}
|
|
558
|
-
• BaseGuard is not working correctly
|
|
559
|
-
• You're experiencing frequent errors
|
|
560
|
-
• Need to troubleshoot issues
|
|
561
|
-
• Want to optimize performance
|
|
562
|
-
`)
|
|
563
|
-
.action(async () => {
|
|
564
|
-
await startupPromise;
|
|
565
|
-
return diagnostics();
|
|
566
|
-
});
|
|
567
|
-
|
|
568
|
-
// Add version command with detailed info
|
|
569
|
-
program
|
|
570
|
-
.command('version')
|
|
571
|
-
.description('Show version information and system details')
|
|
572
|
-
.option('--check-updates', 'Check for available updates')
|
|
573
|
-
.addHelpText('after', `
|
|
574
|
-
${chalk.cyan('Version Information:')}
|
|
575
|
-
Shows BaseGuard version, Node.js version, and system information.
|
|
576
|
-
|
|
577
|
-
${chalk.cyan('Examples:')}
|
|
578
|
-
${chalk.dim('$')} base version ${chalk.gray('# Show version info')}
|
|
579
|
-
${chalk.dim('$')} base version --check-updates ${chalk.gray('# Check for updates')}
|
|
580
|
-
`)
|
|
581
|
-
.action((options) => showVersionInfo(options));
|
|
582
|
-
|
|
583
|
-
// Add help command
|
|
584
|
-
program
|
|
585
|
-
.command('help [command]')
|
|
586
|
-
.description('Display help information for BaseGuard or specific commands')
|
|
587
|
-
.addHelpText('after', `
|
|
588
|
-
${chalk.cyan('Examples:')}
|
|
589
|
-
${chalk.dim('$')} base help ${chalk.gray('# Show general help')}
|
|
590
|
-
${chalk.dim('$')} base help init ${chalk.gray('# Show help for init command')}
|
|
591
|
-
${chalk.dim('$')} base help config ${chalk.gray('# Show help for config commands')}
|
|
592
|
-
`)
|
|
593
|
-
.action((command) => {
|
|
594
|
-
if (command) {
|
|
595
|
-
program.commands.find(cmd => cmd.name() === command)?.help();
|
|
596
|
-
} else {
|
|
597
|
-
showGlobalHelp();
|
|
598
|
-
}
|
|
599
|
-
});
|
|
600
|
-
|
|
601
|
-
// Handle unknown commands
|
|
602
|
-
program.on('command:*', function (operands) {
|
|
603
|
-
console.error(chalk.red('❌ Unknown command:'), chalk.white(operands[0]));
|
|
604
|
-
console.log(chalk.yellow('\n💡 Suggestions:'));
|
|
605
|
-
console.log(` • Run ${chalk.white('base help')} to see all available commands`);
|
|
606
|
-
console.log(` • Run ${chalk.white('base init')} if you haven't set up BaseGuard yet`);
|
|
607
|
-
console.log(` • Check for typos in the command name`);
|
|
608
|
-
process.exit(1);
|
|
609
|
-
});
|
|
610
|
-
|
|
611
|
-
// Show help if no command provided
|
|
612
|
-
if (process.argv.length <= 2) {
|
|
613
|
-
showTerminalHeader();
|
|
614
|
-
showGlobalHelp();
|
|
615
|
-
process.exit(0);
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
// For help commands, don't wait for startup
|
|
619
|
-
const isHelpCommand = process.argv.includes('--help') || process.argv.includes('-h') || process.argv.includes('help');
|
|
620
|
-
if (isHelpCommand) {
|
|
621
|
-
// Parse immediately without waiting for startup
|
|
622
|
-
program.parse();
|
|
623
|
-
} else {
|
|
624
|
-
// Wait for startup for other commands
|
|
625
|
-
startupPromise.finally(() => {
|
|
626
|
-
program.parse();
|
|
627
|
-
});
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { Command } from 'commander';
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
import { init, check, fix, config, automation, status, diagnostics } from '../dist/commands/index.js';
|
|
6
|
+
import { showTerminalHeader, showVersionInfo, showGlobalHelp } from '../dist/ui/index.js';
|
|
7
|
+
import { StartupOptimizer } from '../dist/core/startup-optimizer.js';
|
|
8
|
+
|
|
9
|
+
// Initialize startup optimizations with timeout
|
|
10
|
+
const startupPromise = Promise.race([
|
|
11
|
+
StartupOptimizer.initialize().then(() => {
|
|
12
|
+
// Run additional startup optimizations
|
|
13
|
+
return StartupOptimizer.optimizeStartup();
|
|
14
|
+
}),
|
|
15
|
+
new Promise(resolve => setTimeout(resolve, 1000)) // Max 1 second for startup
|
|
16
|
+
]).catch(() => {
|
|
17
|
+
// Ignore startup errors, continue with CLI
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const program = new Command();
|
|
21
|
+
|
|
22
|
+
program
|
|
23
|
+
.name('base')
|
|
24
|
+
.description(chalk.cyan('🛡️ BaseGuard - Never ship incompatible code again\n') +
|
|
25
|
+
chalk.dim('Intelligent browser compatibility enforcement with AI-powered analysis and autonomous fixing'))
|
|
26
|
+
.version('1.0.3')
|
|
27
|
+
.configureOutput({
|
|
28
|
+
outputError: (str, write) => write(chalk.red(str))
|
|
29
|
+
})
|
|
30
|
+
.configureHelp({
|
|
31
|
+
helpWidth: 100,
|
|
32
|
+
sortSubcommands: true
|
|
33
|
+
})
|
|
34
|
+
.addHelpText('after', `
|
|
35
|
+
${chalk.cyan('Examples:')}
|
|
36
|
+
${chalk.dim('$')} base init ${chalk.gray('# Initialize BaseGuard in your project')}
|
|
37
|
+
${chalk.dim('$')} base check ${chalk.gray('# Check for compatibility violations')}
|
|
38
|
+
${chalk.dim('$')} base fix ${chalk.gray('# Fix violations with AI assistance')}
|
|
39
|
+
${chalk.dim('$')} base config set-keys ${chalk.gray('# Configure API keys for AI services')}
|
|
40
|
+
${chalk.dim('$')} base automation enable ${chalk.gray('# Enable git hooks for automatic checking')}
|
|
41
|
+
|
|
42
|
+
${chalk.cyan('Getting Started:')}
|
|
43
|
+
1. Run ${chalk.white('base init')} to set up BaseGuard in your project
|
|
44
|
+
2. Configure API keys with ${chalk.white('base config set-keys')} for AI features
|
|
45
|
+
3. Enable automation with ${chalk.white('base automation enable')}
|
|
46
|
+
4. Check compatibility with ${chalk.white('base check')}
|
|
47
|
+
|
|
48
|
+
${chalk.cyan('Documentation:')}
|
|
49
|
+
${chalk.blue('https://github.com/baseguard/baseguard#readme')}
|
|
50
|
+
|
|
51
|
+
${chalk.cyan('Support:')}
|
|
52
|
+
${chalk.blue('https://github.com/baseguard/baseguard/issues')}
|
|
53
|
+
`);
|
|
54
|
+
|
|
55
|
+
// Initialize BaseGuard in project
|
|
56
|
+
program
|
|
57
|
+
.command('init')
|
|
58
|
+
.description('Initialize BaseGuard in your project with guided setup')
|
|
59
|
+
.option('--preset <preset>', 'Browser target preset (baseline-widely, baseline-newly, last-2-years, custom)', 'baseline-widely')
|
|
60
|
+
.option('--skip-hooks', 'Skip git hook installation during setup')
|
|
61
|
+
.option('--skip-api-keys', 'Skip API key configuration during setup')
|
|
62
|
+
.addHelpText('after', `
|
|
63
|
+
${chalk.cyan('Browser Target Presets:')}
|
|
64
|
+
${chalk.white('baseline-widely')} Support features available in Baseline for 30+ months
|
|
65
|
+
${chalk.white('baseline-newly')} Support newly available Baseline features
|
|
66
|
+
${chalk.white('last-2-years')} Support browsers from the last 2 years
|
|
67
|
+
${chalk.white('custom')} Configure custom browser targets interactively
|
|
68
|
+
|
|
69
|
+
${chalk.cyan('Examples:')}
|
|
70
|
+
${chalk.dim('$')} base init ${chalk.gray('# Interactive setup with baseline-widely preset')}
|
|
71
|
+
${chalk.dim('$')} base init --preset baseline-newly ${chalk.gray('# Use baseline-newly preset')}
|
|
72
|
+
${chalk.dim('$')} base init --skip-hooks ${chalk.gray('# Skip git hook installation')}
|
|
73
|
+
${chalk.dim('$')} base init --preset custom ${chalk.gray('# Configure custom browser targets')}
|
|
74
|
+
|
|
75
|
+
${chalk.cyan('What this does:')}
|
|
76
|
+
• Creates .baseguardrc.json configuration file
|
|
77
|
+
• Sets up browser compatibility targets
|
|
78
|
+
• Configures API keys for AI services (optional)
|
|
79
|
+
• Installs git hooks for automation (optional)
|
|
80
|
+
• Adds .baseguardrc.json to .gitignore for security
|
|
81
|
+
`)
|
|
82
|
+
.action(async (options) => {
|
|
83
|
+
await startupPromise;
|
|
84
|
+
await StartupOptimizer.optimizeForUseCase('init');
|
|
85
|
+
return init(options);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// Check for compatibility violations
|
|
89
|
+
program
|
|
90
|
+
.command('check')
|
|
91
|
+
.description('Scan code for browser compatibility violations using Baseline data')
|
|
92
|
+
.option('--strict', 'Exit with error code if violations are found (useful for CI/CD)')
|
|
93
|
+
.option('--files <pattern>', 'File pattern to check using glob syntax', '**/*.{js,jsx,ts,tsx,vue,svelte,css,html}')
|
|
94
|
+
.option('--format <format>', 'Output format for results', 'table')
|
|
95
|
+
.option('--debug', 'Enable debug logging for troubleshooting')
|
|
96
|
+
.option('--offline', 'Run in offline mode (no network requests)')
|
|
97
|
+
.addHelpText('after', `
|
|
98
|
+
${chalk.cyan('Output Formats:')}
|
|
99
|
+
${chalk.white('table')} Human-readable table format (default)
|
|
100
|
+
${chalk.white('json')} JSON format for programmatic use
|
|
101
|
+
${chalk.white('junit')} JUnit XML format for CI/CD integration
|
|
102
|
+
|
|
103
|
+
${chalk.cyan('Examples:')}
|
|
104
|
+
${chalk.dim('$')} base check ${chalk.gray('# Check all supported files')}
|
|
105
|
+
${chalk.dim('$')} base check --strict ${chalk.gray('# Exit with error if violations found')}
|
|
106
|
+
${chalk.dim('$')} base check --files "src/**/*.ts" ${chalk.gray('# Check only TypeScript files in src/')}
|
|
107
|
+
${chalk.dim('$')} base check --format json ${chalk.gray('# Output results as JSON')}
|
|
108
|
+
${chalk.dim('$')} base check --files "*.css" --strict ${chalk.gray('# Check CSS files with strict mode')}
|
|
109
|
+
|
|
110
|
+
${chalk.cyan('File Patterns:')}
|
|
111
|
+
Supports glob patterns like:
|
|
112
|
+
• ${chalk.white('"src/**/*.{js,ts}"')} - All JS/TS files in src/ and subdirectories
|
|
113
|
+
• ${chalk.white('"components/*.vue"')} - All Vue files in components/
|
|
114
|
+
• ${chalk.white('"**/*.css"')} - All CSS files in project
|
|
115
|
+
|
|
116
|
+
${chalk.cyan('What this checks:')}
|
|
117
|
+
• CSS properties, selectors, and at-rules
|
|
118
|
+
• JavaScript APIs and ECMAScript features
|
|
119
|
+
• HTML elements and attributes
|
|
120
|
+
• Framework-specific files (React, Vue, Svelte)
|
|
121
|
+
• Web platform APIs (Canvas, WebGL, WebRTC, WebAssembly, etc.)
|
|
122
|
+
`)
|
|
123
|
+
.action(async (options) => {
|
|
124
|
+
await startupPromise;
|
|
125
|
+
await StartupOptimizer.optimizeForUseCase('check');
|
|
126
|
+
return check(options);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
// Fix violations with AI
|
|
130
|
+
program
|
|
131
|
+
.command('fix')
|
|
132
|
+
.description('Analyze and fix compatibility violations using AI (requires API keys)')
|
|
133
|
+
.option('--auto', 'Apply fixes automatically without interactive confirmation')
|
|
134
|
+
.option('--analyze-only', 'Only run AI analysis without generating code fixes')
|
|
135
|
+
.option('--files <pattern>', 'File pattern to fix using glob syntax', '**/*.{js,jsx,ts,tsx,vue,svelte,css,html}')
|
|
136
|
+
.addHelpText('after', `
|
|
137
|
+
${chalk.cyan('Prerequisites:')}
|
|
138
|
+
• Gemini API key (for analysis and fixing) - Get from ${chalk.blue('https://aistudio.google.com')}
|
|
139
|
+
• Jules API key (optional, for GitHub repos) - Get from ${chalk.blue('https://jules.google.com')}
|
|
140
|
+
• Choose your coding agent: "base config coding-agent"
|
|
141
|
+
|
|
142
|
+
${chalk.cyan('Examples:')}
|
|
143
|
+
${chalk.dim('$')} base fix ${chalk.gray('# Interactive fix with confirmation prompts')}
|
|
144
|
+
${chalk.dim('$')} base fix --auto ${chalk.gray('# Apply all fixes automatically')}
|
|
145
|
+
${chalk.dim('$')} base fix --analyze-only ${chalk.gray('# Only analyze, don\'t generate fixes')}
|
|
146
|
+
${chalk.dim('$')} base fix --files "src/**/*.css" ${chalk.gray('# Fix only CSS files in src/')}
|
|
147
|
+
|
|
148
|
+
${chalk.cyan('How it works:')}
|
|
149
|
+
1. ${chalk.white('Scan')} - Detects compatibility violations using Baseline data
|
|
150
|
+
2. ${chalk.white('Analyze')} - Gemini AI researches impact and fix strategies
|
|
151
|
+
3. ${chalk.white('Fix')} - AI generates progressive enhancement code (Jules or Gemini)
|
|
152
|
+
4. ${chalk.white('Review')} - Shows preview of changes before applying
|
|
153
|
+
5. ${chalk.white('Apply')} - Updates files with compatibility fixes
|
|
154
|
+
|
|
155
|
+
${chalk.cyan('Coding Agents:')}
|
|
156
|
+
• ${chalk.white('Gemini 2.5 Pro')} - Works with any files, immediate processing
|
|
157
|
+
• ${chalk.white('Jules')} - GitHub repos only, autonomous cloud processing
|
|
158
|
+
|
|
159
|
+
${chalk.cyan('Fix Strategies:')}
|
|
160
|
+
• Progressive enhancement with @supports for CSS
|
|
161
|
+
• Feature detection for JavaScript APIs
|
|
162
|
+
• Polyfills and fallbacks for older browsers
|
|
163
|
+
• Graceful degradation patterns
|
|
164
|
+
|
|
165
|
+
${chalk.cyan('Setup:')}
|
|
166
|
+
Run ${chalk.white('base config set-keys')} to configure API keys
|
|
167
|
+
Run ${chalk.white('base config coding-agent')} to choose your preferred agent
|
|
168
|
+
`)
|
|
169
|
+
.action(async (options) => {
|
|
170
|
+
await startupPromise;
|
|
171
|
+
await StartupOptimizer.optimizeForUseCase('fix');
|
|
172
|
+
return fix(options);
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
// Configuration management
|
|
176
|
+
const configCmd = program
|
|
177
|
+
.command('config')
|
|
178
|
+
.description('Manage BaseGuard configuration and settings')
|
|
179
|
+
.addHelpText('after', `
|
|
180
|
+
${chalk.cyan('Configuration Commands:')}
|
|
181
|
+
${chalk.white('show')} Display detailed configuration with security status
|
|
182
|
+
${chalk.white('list')} Show configuration summary (supports --format json)
|
|
183
|
+
${chalk.white('set-keys')} Interactive API key setup with browser integration
|
|
184
|
+
${chalk.white('targets')} Manage browser compatibility targets
|
|
185
|
+
${chalk.white('validate')} Check configuration file for errors
|
|
186
|
+
${chalk.white('automation')} Configure git automation settings
|
|
187
|
+
|
|
188
|
+
${chalk.cyan('Examples:')}
|
|
189
|
+
${chalk.dim('$')} base config show ${chalk.gray('# Show detailed configuration')}
|
|
190
|
+
${chalk.dim('$')} base config set-keys ${chalk.gray('# Set up API keys interactively')}
|
|
191
|
+
${chalk.dim('$')} base config list --format json ${chalk.gray('# Export configuration as JSON')}
|
|
192
|
+
${chalk.dim('$')} base config targets --preset baseline-widely ${chalk.gray('# Set browser targets')}
|
|
193
|
+
`);
|
|
194
|
+
|
|
195
|
+
configCmd
|
|
196
|
+
.command('show')
|
|
197
|
+
.description('Display detailed configuration with security and validation status')
|
|
198
|
+
.addHelpText('after', `
|
|
199
|
+
${chalk.cyan('What this shows:')}
|
|
200
|
+
• Current browser targets and presets
|
|
201
|
+
• API key configuration status (without exposing keys)
|
|
202
|
+
• Automation and git hook settings
|
|
203
|
+
• Security status (.gitignore configuration)
|
|
204
|
+
• Configuration validation results
|
|
205
|
+
• Recommendations for improvements
|
|
206
|
+
`)
|
|
207
|
+
.action(() => config('show'));
|
|
208
|
+
|
|
209
|
+
configCmd
|
|
210
|
+
.command('set-keys')
|
|
211
|
+
.description('Interactive setup of API keys for AI services')
|
|
212
|
+
.addHelpText('after', `
|
|
213
|
+
${chalk.cyan('API Services:')}
|
|
214
|
+
${chalk.white('Gemini')} - For AI analysis of compatibility issues
|
|
215
|
+
Get your key: ${chalk.blue('https://aistudio.google.com')}
|
|
216
|
+
|
|
217
|
+
${chalk.white('Jules')} - For autonomous code fixing
|
|
218
|
+
Get your key: ${chalk.blue('https://jules.google.com')}
|
|
219
|
+
|
|
220
|
+
${chalk.cyan('Security:')}
|
|
221
|
+
• Keys are stored in .baseguardrc.json
|
|
222
|
+
• File is automatically added to .gitignore
|
|
223
|
+
• Keys are validated before saving
|
|
224
|
+
`)
|
|
225
|
+
.action(() => config('set-keys'));
|
|
226
|
+
|
|
227
|
+
configCmd
|
|
228
|
+
.command('targets')
|
|
229
|
+
.description('Manage browser compatibility targets')
|
|
230
|
+
.option('--add <target>', 'Add browser target (format: "browser version")')
|
|
231
|
+
.option('--remove <target>', 'Remove browser target by name')
|
|
232
|
+
.option('--preset <preset>', 'Set predefined browser targets')
|
|
233
|
+
.addHelpText('after', `
|
|
234
|
+
${chalk.cyan('Target Formats:')}
|
|
235
|
+
${chalk.white('"chrome 100"')} Minimum Chrome version 100
|
|
236
|
+
${chalk.white('"safari baseline"')} Safari with Baseline support only
|
|
237
|
+
${chalk.white('"firefox 90"')} Minimum Firefox version 90
|
|
238
|
+
|
|
239
|
+
${chalk.cyan('Available Presets:')}
|
|
240
|
+
${chalk.white('baseline-widely')} Features available for 30+ months
|
|
241
|
+
${chalk.white('baseline-newly')} Newly available Baseline features
|
|
242
|
+
${chalk.white('last-2-years')} Browsers from last 2 years
|
|
243
|
+
|
|
244
|
+
${chalk.cyan('Examples:')}
|
|
245
|
+
${chalk.dim('$')} base config targets --add "chrome 100"
|
|
246
|
+
${chalk.dim('$')} base config targets --remove chrome
|
|
247
|
+
${chalk.dim('$')} base config targets --preset baseline-widely
|
|
248
|
+
`)
|
|
249
|
+
.action((options) => config('targets', options));
|
|
250
|
+
|
|
251
|
+
configCmd
|
|
252
|
+
.command('list')
|
|
253
|
+
.description('Show configuration summary with status information')
|
|
254
|
+
.option('--format <format>', 'Output format (table or json)', 'table')
|
|
255
|
+
.addHelpText('after', `
|
|
256
|
+
${chalk.cyan('Output Formats:')}
|
|
257
|
+
${chalk.white('table')} Human-readable summary (default)
|
|
258
|
+
${chalk.white('json')} Machine-readable JSON for scripts
|
|
259
|
+
|
|
260
|
+
${chalk.cyan('Includes:')}
|
|
261
|
+
• Browser targets and count
|
|
262
|
+
• API key configuration status
|
|
263
|
+
• Automation settings
|
|
264
|
+
• Security and validation status
|
|
265
|
+
`)
|
|
266
|
+
.action((options) => config('list', options));
|
|
267
|
+
|
|
268
|
+
configCmd
|
|
269
|
+
.command('validate')
|
|
270
|
+
.description('Validate configuration file for errors and inconsistencies')
|
|
271
|
+
.addHelpText('after', `
|
|
272
|
+
${chalk.cyan('Validation Checks:')}
|
|
273
|
+
• Configuration file syntax and structure
|
|
274
|
+
• Browser target format and validity
|
|
275
|
+
• API key format validation
|
|
276
|
+
• Automation setting consistency
|
|
277
|
+
• Required field presence
|
|
278
|
+
|
|
279
|
+
${chalk.cyan('Exit Codes:')}
|
|
280
|
+
0 - Configuration is valid
|
|
281
|
+
1 - Validation errors found
|
|
282
|
+
`)
|
|
283
|
+
.action(() => config('validate'));
|
|
284
|
+
|
|
285
|
+
configCmd
|
|
286
|
+
.command('automation')
|
|
287
|
+
.description('Configure git automation settings interactively')
|
|
288
|
+
.addHelpText('after', `
|
|
289
|
+
${chalk.cyan('Automation Settings:')}
|
|
290
|
+
• Enable/disable git hooks
|
|
291
|
+
• Choose trigger (pre-commit or pre-push)
|
|
292
|
+
• Configure auto-analysis with Gemini
|
|
293
|
+
• Configure auto-fixing with Jules
|
|
294
|
+
• Set commit blocking behavior
|
|
295
|
+
`)
|
|
296
|
+
.action(() => config('automation'));
|
|
297
|
+
|
|
298
|
+
configCmd
|
|
299
|
+
.command('recover')
|
|
300
|
+
.description('Attempt automatic recovery of corrupted configuration')
|
|
301
|
+
.option('--backup', 'Create backup before recovery')
|
|
302
|
+
.option('--interactive', 'Run interactive recovery wizard')
|
|
303
|
+
.addHelpText('after', `
|
|
304
|
+
${chalk.cyan('Recovery Features:')}
|
|
305
|
+
• Automatic detection of configuration issues
|
|
306
|
+
• Repair of corrupted JSON syntax
|
|
307
|
+
• Migration from older configuration versions
|
|
308
|
+
• Validation and structure repair
|
|
309
|
+
• Backup creation before changes
|
|
310
|
+
|
|
311
|
+
${chalk.cyan('Recovery Process:')}
|
|
312
|
+
1. Validates current configuration
|
|
313
|
+
2. Creates backup if requested
|
|
314
|
+
3. Attempts automatic repair
|
|
315
|
+
4. Migrates to current version
|
|
316
|
+
5. Validates final result
|
|
317
|
+
|
|
318
|
+
${chalk.cyan('Examples:')}
|
|
319
|
+
${chalk.dim('$')} base config recover ${chalk.gray('# Automatic recovery')}
|
|
320
|
+
${chalk.dim('$')} base config recover --backup ${chalk.gray('# Create backup first')}
|
|
321
|
+
${chalk.dim('$')} base config recover --interactive ${chalk.gray('# Interactive wizard')}
|
|
322
|
+
`)
|
|
323
|
+
.action((options) => config('recover', options));
|
|
324
|
+
|
|
325
|
+
configCmd
|
|
326
|
+
.command('coding-agent')
|
|
327
|
+
.description('Manage coding agent selection (Jules vs Gemini)')
|
|
328
|
+
.option('--agent <agent>', 'Set primary agent (jules or gemini)')
|
|
329
|
+
.option('--show', 'Show current agent configuration and status')
|
|
330
|
+
.addHelpText('after', `
|
|
331
|
+
${chalk.cyan('Coding Agents:')}
|
|
332
|
+
${chalk.white('Jules')} - Google's autonomous coding agent (GitHub repos only)
|
|
333
|
+
${chalk.white('Gemini')} - Gemini 2.5 Pro direct API (works with any files)
|
|
334
|
+
|
|
335
|
+
${chalk.cyan('Agent Comparison:')}
|
|
336
|
+
Jules:
|
|
337
|
+
✅ Autonomous operation in cloud VMs
|
|
338
|
+
✅ Full repository context understanding
|
|
339
|
+
✅ Asynchronous processing
|
|
340
|
+
❌ Requires GitHub repository
|
|
341
|
+
❌ Cannot work with local/uncommitted files
|
|
342
|
+
|
|
343
|
+
Gemini:
|
|
344
|
+
✅ Works with any files (GitHub or not)
|
|
345
|
+
✅ Immediate processing
|
|
346
|
+
✅ Works with uncommitted/local files
|
|
347
|
+
✅ Grounded with real-time web search
|
|
348
|
+
⚠️ Requires manual code application
|
|
349
|
+
|
|
350
|
+
${chalk.cyan('Examples:')}
|
|
351
|
+
${chalk.dim('$')} base config coding-agent --show ${chalk.gray('# Show current configuration')}
|
|
352
|
+
${chalk.dim('$')} base config coding-agent --agent gemini ${chalk.gray('# Set Gemini as primary')}
|
|
353
|
+
${chalk.dim('$')} base config coding-agent --agent jules ${chalk.gray('# Set Jules as primary')}
|
|
354
|
+
${chalk.dim('$')} base config coding-agent ${chalk.gray('# Interactive selection')}
|
|
355
|
+
`)
|
|
356
|
+
.action((options) => config('coding-agent', options));
|
|
357
|
+
|
|
358
|
+
// Automation and git hooks
|
|
359
|
+
const autoCmd = program
|
|
360
|
+
.command('automation')
|
|
361
|
+
.alias('auto')
|
|
362
|
+
.description('Manage git automation and hooks for continuous compatibility checking')
|
|
363
|
+
.addHelpText('after', `
|
|
364
|
+
${chalk.cyan('Automation Features:')}
|
|
365
|
+
• Automatic compatibility checking on git operations
|
|
366
|
+
• AI-powered analysis and fixing integration
|
|
367
|
+
• Commit blocking when violations are found
|
|
368
|
+
• Configurable triggers (pre-commit or pre-push)
|
|
369
|
+
|
|
370
|
+
${chalk.cyan('Examples:')}
|
|
371
|
+
${chalk.dim('$')} base automation enable ${chalk.gray('# Enable with interactive setup')}
|
|
372
|
+
${chalk.dim('$')} base automation enable --trigger pre-push ${chalk.gray('# Enable with pre-push trigger')}
|
|
373
|
+
${chalk.dim('$')} base automation status ${chalk.gray('# Show current automation status')}
|
|
374
|
+
${chalk.dim('$')} base automation disable ${chalk.gray('# Disable automation and remove hooks')}
|
|
375
|
+
`);
|
|
376
|
+
|
|
377
|
+
autoCmd
|
|
378
|
+
.command('enable')
|
|
379
|
+
.description('Enable git automation with hook installation')
|
|
380
|
+
.option('--trigger <trigger>', 'When to run checks (pre-commit or pre-push)', 'pre-commit')
|
|
381
|
+
.option('--auto-fix', 'Enable automatic fixing of violations')
|
|
382
|
+
.addHelpText('after', `
|
|
383
|
+
${chalk.cyan('Trigger Options:')}
|
|
384
|
+
${chalk.white('pre-commit')} Check before each commit (faster feedback)
|
|
385
|
+
${chalk.white('pre-push')} Check before each push (less frequent)
|
|
386
|
+
|
|
387
|
+
${chalk.cyan('What this does:')}
|
|
388
|
+
• Installs git hooks using Husky
|
|
389
|
+
• Configures BaseGuard to run automatically
|
|
390
|
+
• Sets up automation preferences
|
|
391
|
+
• Updates .baseguardrc.json configuration
|
|
392
|
+
|
|
393
|
+
${chalk.cyan('Requirements:')}
|
|
394
|
+
• Git repository (run ${chalk.white('git init')} first)
|
|
395
|
+
• Node.js project with package.json
|
|
396
|
+
`)
|
|
397
|
+
.action((options) => automation('enable', options));
|
|
398
|
+
|
|
399
|
+
autoCmd
|
|
400
|
+
.command('disable')
|
|
401
|
+
.description('Disable git automation and remove hooks')
|
|
402
|
+
.addHelpText('after', `
|
|
403
|
+
${chalk.cyan('What this does:')}
|
|
404
|
+
• Removes git hooks from .husky/ directory
|
|
405
|
+
• Disables automation in configuration
|
|
406
|
+
• Preserves other BaseGuard settings
|
|
407
|
+
|
|
408
|
+
${chalk.cyan('Note:')}
|
|
409
|
+
You can re-enable automation anytime with ${chalk.white('base automation enable')}
|
|
410
|
+
`)
|
|
411
|
+
.action(() => automation('disable'));
|
|
412
|
+
|
|
413
|
+
autoCmd
|
|
414
|
+
.command('run')
|
|
415
|
+
.description('Run automation manually (used internally by git hooks)')
|
|
416
|
+
.option('--trigger <trigger>', 'Trigger context (pre-commit or pre-push)')
|
|
417
|
+
.addHelpText('after', `
|
|
418
|
+
${chalk.cyan('Usage:')}
|
|
419
|
+
This command is typically called by git hooks automatically.
|
|
420
|
+
You can run it manually for testing automation behavior.
|
|
421
|
+
|
|
422
|
+
${chalk.cyan('Examples:')}
|
|
423
|
+
${chalk.dim('$')} base automation run --trigger pre-commit
|
|
424
|
+
${chalk.dim('$')} base automation run --trigger pre-push
|
|
425
|
+
`)
|
|
426
|
+
.action((options) => automation('run', options));
|
|
427
|
+
|
|
428
|
+
autoCmd
|
|
429
|
+
.command('status')
|
|
430
|
+
.description('Show detailed automation status and configuration')
|
|
431
|
+
.addHelpText('after', `
|
|
432
|
+
${chalk.cyan('Status Information:')}
|
|
433
|
+
• Automation enabled/disabled state
|
|
434
|
+
• Git hook installation status
|
|
435
|
+
• Trigger configuration (pre-commit/pre-push)
|
|
436
|
+
• Auto-analysis and auto-fix settings
|
|
437
|
+
• API key configuration status
|
|
438
|
+
• Recommendations for setup improvements
|
|
439
|
+
`)
|
|
440
|
+
.action(() => automation('status'));
|
|
441
|
+
|
|
442
|
+
autoCmd
|
|
443
|
+
.command('configure')
|
|
444
|
+
.description('Interactive configuration of all automation settings')
|
|
445
|
+
.addHelpText('after', `
|
|
446
|
+
${chalk.cyan('Configuration Options:')}
|
|
447
|
+
• Enable/disable automation
|
|
448
|
+
• Choose trigger timing
|
|
449
|
+
• Configure AI analysis settings
|
|
450
|
+
• Configure AI fixing settings
|
|
451
|
+
• Set commit blocking behavior
|
|
452
|
+
|
|
453
|
+
${chalk.cyan('Interactive Setup:')}
|
|
454
|
+
Guides you through all automation options with explanations
|
|
455
|
+
and recommendations based on your current configuration.
|
|
456
|
+
`)
|
|
457
|
+
.action(() => automation('configure'));
|
|
458
|
+
|
|
459
|
+
// Browser target management commands (shortcuts)
|
|
460
|
+
program
|
|
461
|
+
.command('add <target>')
|
|
462
|
+
.description('Add browser target (shortcut for config targets --add)')
|
|
463
|
+
.addHelpText('after', `
|
|
464
|
+
${chalk.cyan('Target Format:')}
|
|
465
|
+
"browser version" - e.g., "chrome 100", "safari 15", "firefox baseline"
|
|
466
|
+
|
|
467
|
+
${chalk.cyan('Examples:')}
|
|
468
|
+
${chalk.dim('$')} base add "chrome 100" ${chalk.gray('# Add Chrome 100+ support')}
|
|
469
|
+
${chalk.dim('$')} base add "safari baseline" ${chalk.gray('# Add Safari with Baseline support')}
|
|
470
|
+
${chalk.dim('$')} base add "firefox 90" ${chalk.gray('# Add Firefox 90+ support')}
|
|
471
|
+
`)
|
|
472
|
+
.action((target) => config('targets', { add: target }));
|
|
473
|
+
|
|
474
|
+
program
|
|
475
|
+
.command('remove <target>')
|
|
476
|
+
.description('Remove browser target (shortcut for config targets --remove)')
|
|
477
|
+
.addHelpText('after', `
|
|
478
|
+
${chalk.cyan('Examples:')}
|
|
479
|
+
${chalk.dim('$')} base remove chrome ${chalk.gray('# Remove all Chrome targets')}
|
|
480
|
+
${chalk.dim('$')} base remove safari ${chalk.gray('# Remove all Safari targets')}
|
|
481
|
+
${chalk.dim('$')} base remove firefox ${chalk.gray('# Remove all Firefox targets')}
|
|
482
|
+
`)
|
|
483
|
+
.action((target) => config('targets', { remove: target }));
|
|
484
|
+
|
|
485
|
+
program
|
|
486
|
+
.command('list')
|
|
487
|
+
.description('List configuration summary (shortcut for config list)')
|
|
488
|
+
.option('--format <format>', 'Output format (table or json)', 'table')
|
|
489
|
+
.addHelpText('after', `
|
|
490
|
+
${chalk.cyan('Quick Status:')}
|
|
491
|
+
Shows browser targets, API keys, automation status, and security info.
|
|
492
|
+
|
|
493
|
+
${chalk.cyan('Examples:')}
|
|
494
|
+
${chalk.dim('$')} base list ${chalk.gray('# Show configuration summary')}
|
|
495
|
+
${chalk.dim('$')} base list --format json ${chalk.gray('# Export as JSON')}
|
|
496
|
+
`)
|
|
497
|
+
.action((options) => config('list', options));
|
|
498
|
+
|
|
499
|
+
// System status and health
|
|
500
|
+
program
|
|
501
|
+
.command('status')
|
|
502
|
+
.description('Show BaseGuard system status and health information')
|
|
503
|
+
.option('--verbose', 'Show detailed status information')
|
|
504
|
+
.option('--services', 'Check external service availability')
|
|
505
|
+
.option('--config', 'Show configuration status and validation')
|
|
506
|
+
.option('--errors', 'Show error summary and recent issues')
|
|
507
|
+
.addHelpText('after', `
|
|
508
|
+
${chalk.cyan('Status Information:')}
|
|
509
|
+
• Overall system health (healthy/degraded/critical)
|
|
510
|
+
• Component status (configuration, services, errors)
|
|
511
|
+
• Current degradation mode and limitations
|
|
512
|
+
• Service availability (network, APIs)
|
|
513
|
+
• Configuration validation results
|
|
514
|
+
• Error summary and recent issues
|
|
515
|
+
• Performance information
|
|
516
|
+
• Recovery recommendations
|
|
517
|
+
|
|
518
|
+
${chalk.cyan('Examples:')}
|
|
519
|
+
${chalk.dim('$')} base status ${chalk.gray('# Show basic system status')}
|
|
520
|
+
${chalk.dim('$')} base status --verbose ${chalk.gray('# Show detailed information')}
|
|
521
|
+
${chalk.dim('$')} base status --services ${chalk.gray('# Check service availability')}
|
|
522
|
+
${chalk.dim('$')} base status --config ${chalk.gray('# Show configuration status')}
|
|
523
|
+
${chalk.dim('$')} base status --errors ${chalk.gray('# Show error information')}
|
|
524
|
+
|
|
525
|
+
${chalk.cyan('Health Levels:')}
|
|
526
|
+
${chalk.green('✅ Healthy')} All systems operational
|
|
527
|
+
${chalk.yellow('⚠️ Degraded')} Some features limited
|
|
528
|
+
${chalk.red('❌ Critical')} Major issues detected
|
|
529
|
+
`)
|
|
530
|
+
.action(async (options) => {
|
|
531
|
+
await startupPromise;
|
|
532
|
+
return status(options);
|
|
533
|
+
});
|
|
534
|
+
|
|
535
|
+
// System diagnostics
|
|
536
|
+
program
|
|
537
|
+
.command('diagnostics')
|
|
538
|
+
.alias('diag')
|
|
539
|
+
.description('Run comprehensive system diagnostics and recovery')
|
|
540
|
+
.addHelpText('after', `
|
|
541
|
+
${chalk.cyan('Diagnostic Features:')}
|
|
542
|
+
• Generate detailed debug report
|
|
543
|
+
• Run configuration recovery wizard
|
|
544
|
+
• Check service availability
|
|
545
|
+
• Show error log summary
|
|
546
|
+
• Clean up old files and caches
|
|
547
|
+
• Provide recovery recommendations
|
|
548
|
+
|
|
549
|
+
${chalk.cyan('What this does:')}
|
|
550
|
+
1. Creates comprehensive debug report
|
|
551
|
+
2. Attempts automatic configuration recovery
|
|
552
|
+
3. Checks all external services
|
|
553
|
+
4. Analyzes error logs for patterns
|
|
554
|
+
5. Cleans up temporary files
|
|
555
|
+
6. Provides actionable recommendations
|
|
556
|
+
|
|
557
|
+
${chalk.cyan('Use when:')}
|
|
558
|
+
• BaseGuard is not working correctly
|
|
559
|
+
• You're experiencing frequent errors
|
|
560
|
+
• Need to troubleshoot issues
|
|
561
|
+
• Want to optimize performance
|
|
562
|
+
`)
|
|
563
|
+
.action(async () => {
|
|
564
|
+
await startupPromise;
|
|
565
|
+
return diagnostics();
|
|
566
|
+
});
|
|
567
|
+
|
|
568
|
+
// Add version command with detailed info
|
|
569
|
+
program
|
|
570
|
+
.command('version')
|
|
571
|
+
.description('Show version information and system details')
|
|
572
|
+
.option('--check-updates', 'Check for available updates')
|
|
573
|
+
.addHelpText('after', `
|
|
574
|
+
${chalk.cyan('Version Information:')}
|
|
575
|
+
Shows BaseGuard version, Node.js version, and system information.
|
|
576
|
+
|
|
577
|
+
${chalk.cyan('Examples:')}
|
|
578
|
+
${chalk.dim('$')} base version ${chalk.gray('# Show version info')}
|
|
579
|
+
${chalk.dim('$')} base version --check-updates ${chalk.gray('# Check for updates')}
|
|
580
|
+
`)
|
|
581
|
+
.action((options) => showVersionInfo(options));
|
|
582
|
+
|
|
583
|
+
// Add help command
|
|
584
|
+
program
|
|
585
|
+
.command('help [command]')
|
|
586
|
+
.description('Display help information for BaseGuard or specific commands')
|
|
587
|
+
.addHelpText('after', `
|
|
588
|
+
${chalk.cyan('Examples:')}
|
|
589
|
+
${chalk.dim('$')} base help ${chalk.gray('# Show general help')}
|
|
590
|
+
${chalk.dim('$')} base help init ${chalk.gray('# Show help for init command')}
|
|
591
|
+
${chalk.dim('$')} base help config ${chalk.gray('# Show help for config commands')}
|
|
592
|
+
`)
|
|
593
|
+
.action((command) => {
|
|
594
|
+
if (command) {
|
|
595
|
+
program.commands.find(cmd => cmd.name() === command)?.help();
|
|
596
|
+
} else {
|
|
597
|
+
showGlobalHelp();
|
|
598
|
+
}
|
|
599
|
+
});
|
|
600
|
+
|
|
601
|
+
// Handle unknown commands
|
|
602
|
+
program.on('command:*', function (operands) {
|
|
603
|
+
console.error(chalk.red('❌ Unknown command:'), chalk.white(operands[0]));
|
|
604
|
+
console.log(chalk.yellow('\n💡 Suggestions:'));
|
|
605
|
+
console.log(` • Run ${chalk.white('base help')} to see all available commands`);
|
|
606
|
+
console.log(` • Run ${chalk.white('base init')} if you haven't set up BaseGuard yet`);
|
|
607
|
+
console.log(` • Check for typos in the command name`);
|
|
608
|
+
process.exit(1);
|
|
609
|
+
});
|
|
610
|
+
|
|
611
|
+
// Show help if no command provided
|
|
612
|
+
if (process.argv.length <= 2) {
|
|
613
|
+
showTerminalHeader();
|
|
614
|
+
showGlobalHelp();
|
|
615
|
+
process.exit(0);
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
// For help commands, don't wait for startup
|
|
619
|
+
const isHelpCommand = process.argv.includes('--help') || process.argv.includes('-h') || process.argv.includes('help');
|
|
620
|
+
if (isHelpCommand) {
|
|
621
|
+
// Parse immediately without waiting for startup
|
|
622
|
+
program.parse();
|
|
623
|
+
} else {
|
|
624
|
+
// Wait for startup for other commands
|
|
625
|
+
startupPromise.finally(() => {
|
|
626
|
+
program.parse();
|
|
627
|
+
});
|
|
628
628
|
}
|