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.
Files changed (169) hide show
  1. package/.baseguardrc.example.json +63 -63
  2. package/.eslintrc.json +24 -24
  3. package/.prettierrc +7 -7
  4. package/CHANGELOG.md +195 -195
  5. package/DEPLOYMENT.md +624 -624
  6. package/DEPLOYMENT_CHECKLIST.md +239 -239
  7. package/DEPLOYMENT_SUMMARY_v1.0.2.md +202 -202
  8. package/QUICK_START.md +134 -134
  9. package/README.md +488 -488
  10. package/RELEASE_NOTES_v1.0.2.md +434 -434
  11. package/bin/base.js +627 -627
  12. package/dist/ai/fix-manager.d.ts.map +1 -1
  13. package/dist/ai/fix-manager.js +1 -1
  14. package/dist/ai/fix-manager.js.map +1 -1
  15. package/dist/ai/gemini-analyzer.d.ts.map +1 -1
  16. package/dist/ai/gemini-analyzer.js +29 -35
  17. package/dist/ai/gemini-analyzer.js.map +1 -1
  18. package/dist/ai/gemini-code-fixer.d.ts.map +1 -1
  19. package/dist/ai/gemini-code-fixer.js +58 -58
  20. package/dist/ai/gemini-code-fixer.js.map +1 -1
  21. package/dist/ai/jules-implementer.d.ts +3 -0
  22. package/dist/ai/jules-implementer.d.ts.map +1 -1
  23. package/dist/ai/jules-implementer.js +63 -32
  24. package/dist/ai/jules-implementer.js.map +1 -1
  25. package/dist/ai/unified-code-fixer.js.map +1 -1
  26. package/dist/commands/check.d.ts.map +1 -1
  27. package/dist/commands/check.js +1 -1
  28. package/dist/commands/check.js.map +1 -1
  29. package/dist/commands/config.js +2 -1
  30. package/dist/commands/config.js.map +1 -1
  31. package/dist/commands/fix.d.ts.map +1 -1
  32. package/dist/commands/fix.js +48 -15
  33. package/dist/commands/fix.js.map +1 -1
  34. package/dist/core/api-key-manager.js +2 -2
  35. package/dist/core/api-key-manager.js.map +1 -1
  36. package/dist/core/baseguard.d.ts +1 -0
  37. package/dist/core/baseguard.d.ts.map +1 -1
  38. package/dist/core/baseguard.js +13 -10
  39. package/dist/core/baseguard.js.map +1 -1
  40. package/dist/core/baseline-checker.d.ts.map +1 -1
  41. package/dist/core/baseline-checker.js +8 -5
  42. package/dist/core/baseline-checker.js.map +1 -1
  43. package/dist/core/configuration-recovery.d.ts.map +1 -1
  44. package/dist/core/configuration-recovery.js +1 -1
  45. package/dist/core/configuration-recovery.js.map +1 -1
  46. package/dist/core/debug-logger.d.ts.map +1 -1
  47. package/dist/core/debug-logger.js +1 -1
  48. package/dist/core/debug-logger.js.map +1 -1
  49. package/dist/core/error-handler.d.ts.map +1 -1
  50. package/dist/core/error-handler.js +2 -1
  51. package/dist/core/error-handler.js.map +1 -1
  52. package/dist/core/gitignore-manager.js +5 -5
  53. package/dist/core/graceful-degradation-manager.d.ts.map +1 -1
  54. package/dist/core/graceful-degradation-manager.js +16 -16
  55. package/dist/core/graceful-degradation-manager.js.map +1 -1
  56. package/dist/core/lazy-loader.d.ts.map +1 -1
  57. package/dist/core/lazy-loader.js +9 -2
  58. package/dist/core/lazy-loader.js.map +1 -1
  59. package/dist/core/memory-manager.d.ts +0 -3
  60. package/dist/core/memory-manager.d.ts.map +1 -1
  61. package/dist/core/memory-manager.js.map +1 -1
  62. package/dist/core/parser-worker.d.ts +2 -0
  63. package/dist/core/parser-worker.d.ts.map +1 -0
  64. package/dist/core/parser-worker.js +19 -0
  65. package/dist/core/parser-worker.js.map +1 -0
  66. package/dist/core/startup-optimizer.d.ts.map +1 -1
  67. package/dist/core/startup-optimizer.js +4 -8
  68. package/dist/core/startup-optimizer.js.map +1 -1
  69. package/dist/core/system-error-handler.d.ts.map +1 -1
  70. package/dist/core/system-error-handler.js.map +1 -1
  71. package/dist/git/automation-engine.d.ts.map +1 -1
  72. package/dist/git/automation-engine.js +5 -4
  73. package/dist/git/automation-engine.js.map +1 -1
  74. package/dist/git/github-manager.d.ts.map +1 -1
  75. package/dist/git/github-manager.js.map +1 -1
  76. package/dist/git/hook-manager.js +5 -5
  77. package/dist/git/hook-manager.js.map +1 -1
  78. package/dist/parsers/parser-manager.d.ts.map +1 -1
  79. package/dist/parsers/parser-manager.js +1 -1
  80. package/dist/parsers/parser-manager.js.map +1 -1
  81. package/dist/parsers/svelte-parser.js +1 -1
  82. package/dist/parsers/svelte-parser.js.map +1 -1
  83. package/dist/parsers/vanilla-parser.d.ts.map +1 -1
  84. package/dist/parsers/vanilla-parser.js.map +1 -1
  85. package/dist/parsers/vue-parser.d.ts.map +1 -1
  86. package/dist/parsers/vue-parser.js.map +1 -1
  87. package/dist/ui/components.d.ts +1 -1
  88. package/dist/ui/components.d.ts.map +1 -1
  89. package/dist/ui/components.js +11 -11
  90. package/dist/ui/components.js.map +1 -1
  91. package/dist/ui/terminal-header.js +14 -14
  92. package/package.json +105 -105
  93. package/src/ai/__tests__/gemini-analyzer.test.ts +180 -180
  94. package/src/ai/agentkit-orchestrator.ts +533 -533
  95. package/src/ai/fix-manager.ts +362 -362
  96. package/src/ai/gemini-analyzer.ts +665 -671
  97. package/src/ai/gemini-code-fixer.ts +539 -540
  98. package/src/ai/index.ts +3 -3
  99. package/src/ai/jules-implementer.ts +504 -460
  100. package/src/ai/unified-code-fixer.ts +347 -347
  101. package/src/commands/automation.ts +343 -343
  102. package/src/commands/check.ts +298 -299
  103. package/src/commands/config.ts +584 -583
  104. package/src/commands/fix.ts +269 -238
  105. package/src/commands/index.ts +6 -6
  106. package/src/commands/init.ts +155 -155
  107. package/src/commands/status.ts +306 -306
  108. package/src/core/api-key-manager.ts +298 -298
  109. package/src/core/baseguard.ts +757 -756
  110. package/src/core/baseline-checker.ts +566 -563
  111. package/src/core/cache-manager.ts +271 -271
  112. package/src/core/configuration-recovery.ts +672 -673
  113. package/src/core/configuration.ts +595 -595
  114. package/src/core/debug-logger.ts +590 -590
  115. package/src/core/directory-filter.ts +420 -420
  116. package/src/core/error-handler.ts +518 -517
  117. package/src/core/file-processor.ts +337 -337
  118. package/src/core/gitignore-manager.ts +168 -168
  119. package/src/core/graceful-degradation-manager.ts +596 -596
  120. package/src/core/index.ts +16 -16
  121. package/src/core/lazy-loader.ts +317 -307
  122. package/src/core/memory-manager.ts +290 -295
  123. package/src/core/parser-worker.ts +33 -0
  124. package/src/core/startup-optimizer.ts +246 -255
  125. package/src/core/system-error-handler.ts +755 -756
  126. package/src/git/automation-engine.ts +361 -361
  127. package/src/git/github-manager.ts +190 -192
  128. package/src/git/hook-manager.ts +210 -210
  129. package/src/git/index.ts +3 -3
  130. package/src/index.ts +7 -7
  131. package/src/parsers/feature-validator.ts +558 -558
  132. package/src/parsers/index.ts +7 -7
  133. package/src/parsers/parser-manager.ts +418 -419
  134. package/src/parsers/parser.ts +25 -25
  135. package/src/parsers/react-parser-optimized.ts +160 -160
  136. package/src/parsers/react-parser.ts +358 -358
  137. package/src/parsers/svelte-parser.ts +510 -510
  138. package/src/parsers/vanilla-parser.ts +685 -686
  139. package/src/parsers/vue-parser.ts +476 -478
  140. package/src/types/index.ts +95 -95
  141. package/src/ui/components.ts +567 -567
  142. package/src/ui/help.ts +192 -192
  143. package/src/ui/index.ts +3 -3
  144. package/src/ui/prompts.ts +680 -680
  145. package/src/ui/terminal-header.ts +58 -58
  146. package/test-build.js +40 -40
  147. package/test-config-commands.js +55 -55
  148. package/test-header-simple.js +32 -32
  149. package/test-terminal-header.js +11 -11
  150. package/test-ui.js +28 -28
  151. package/tests/e2e/baseguard.e2e.test.ts +515 -515
  152. package/tests/e2e/cross-platform.e2e.test.ts +419 -419
  153. package/tests/e2e/git-integration.e2e.test.ts +486 -486
  154. package/tests/fixtures/react-project/package.json +13 -13
  155. package/tests/fixtures/react-project/src/App.css +75 -75
  156. package/tests/fixtures/react-project/src/App.tsx +76 -76
  157. package/tests/fixtures/svelte-project/package.json +10 -10
  158. package/tests/fixtures/svelte-project/src/App.svelte +368 -368
  159. package/tests/fixtures/vanilla-project/index.html +75 -75
  160. package/tests/fixtures/vanilla-project/script.js +330 -330
  161. package/tests/fixtures/vanilla-project/styles.css +358 -358
  162. package/tests/fixtures/vue-project/package.json +11 -11
  163. package/tests/fixtures/vue-project/src/App.vue +215 -215
  164. package/tmp-smoke/.baseguard/backups/config-2026-02-19T12-04-11-067Z-auto.json +30 -0
  165. package/tmp-smoke/src/bad.css +3 -0
  166. package/tsconfig.json +34 -34
  167. package/vitest.config.ts +11 -11
  168. package/dist/terminal-header.d.ts +0 -12
  169. package/dist/terminal-header.js +0 -45
package/README.md CHANGED
@@ -1,489 +1,489 @@
1
- # BaseGuard 🛡️
2
-
3
- **Never ship incompatible code again** - Intelligent browser compatibility enforcement with AI-powered analysis and autonomous fixing.
4
-
5
- ## What is BaseGuard?
6
-
7
- BaseGuard is a comprehensive browser compatibility tool that prevents incompatible code from reaching production. It combines official Baseline data with AI-powered analysis and code fixing to ensure your web applications work across all target browsers.
8
-
9
- ### Key Features
10
-
11
- - 🔍 **Universal Framework Support** - Works with React, Vue, Svelte, vanilla JS/CSS, and more
12
- - 🤖 **Dual AI Coding Agents** - Choose between Jules (GitHub repos) or Gemini 2.5 Pro (any files)
13
- - 📊 **Official Baseline Data** - Uses web-features package for accurate compatibility checking
14
- - 🔧 **Intelligent Code Fixing** - AI generates progressive enhancement and polyfill solutions
15
- - 🪝 **Git Integration** - Automated pre-commit/pre-push hooks with violation blocking
16
- - 📈 **Graceful Degradation** - Works offline and handles service failures intelligently
17
- - 🎨 **Beautiful CLI** - Colorful terminal output with progress indicators and detailed reports
18
-
19
- ## Installation
20
-
21
- ```bash
22
- npm install -g baseguard
23
- ```
24
-
25
- **Requirements:**
26
- - Node.js 18 or higher
27
- - Git (for automation features)
28
- - API keys for AI services (setup guide below)
29
-
30
- ## Quick Start
31
-
32
- ### 1. Initialize BaseGuard in Your Project
33
-
34
- ```bash
35
- cd your-project
36
- base init
37
- ```
38
-
39
- This will:
40
- - Create `.baseguardrc.json` configuration file
41
- - Set up browser compatibility targets
42
- - Guide you through API key setup
43
- - Optionally install git hooks for automation
44
-
45
- ### 2. Check for Compatibility Issues
46
-
47
- ```bash
48
- # Check all supported files
49
- base check
50
-
51
- # Check specific files or patterns
52
- base check --files "src/**/*.ts"
53
-
54
- # Strict mode (exit with error if violations found)
55
- base check --strict
56
- ```
57
-
58
- ### 3. Fix Issues with AI
59
-
60
- ```bash
61
- # Interactive fixing with preview
62
- base fix
63
-
64
- # Automatic fixing (no prompts)
65
- base fix --auto
66
-
67
- # Analysis only (no code changes)
68
- base fix --analyze-only
69
- ```
70
-
71
- ## 🚀 Getting Started with AI Services
72
-
73
- BaseGuard offers two AI coding agents for fixing compatibility issues. You can choose the one that best fits your workflow:
74
-
75
- ### Option 1: Gemini 2.5 Pro (Recommended for Most Users)
76
-
77
- **Best for:** Any codebase, local development, uncommitted files
78
-
79
- **Setup Steps:**
80
-
81
- 1. **Get your Gemini API key:**
82
- - Go to [Google AI Studio](https://aistudio.google.com)
83
- - Sign in with your Google account
84
- - Click "Get API key" in the left sidebar
85
- - Click "Create API key" → "Create API key in new project"
86
- - Copy your API key
87
-
88
- 2. **Configure BaseGuard:**
89
- ```bash
90
- base config set-keys
91
- # Follow the prompts to enter your Gemini API key
92
-
93
- # Set Gemini as your primary coding agent
94
- base config coding-agent --agent gemini
95
- ```
96
-
97
- **Advantages:**
98
- - ✅ Works with any files (GitHub, local, uncommitted)
99
- - ✅ Immediate processing and results
100
- - ✅ No repository requirements
101
- - ✅ Grounded with real-time web search
102
- - ✅ Perfect for local development
103
-
104
- ### Option 2: Jules (Google's Autonomous Coding Agent)
105
-
106
- **Best for:** GitHub repositories, autonomous cloud-based fixing
107
-
108
- **Setup Steps:**
109
-
110
- 1. **Get your Jules API key:**
111
- - Go to [Jules Dashboard](https://jules.google.com)
112
- - Sign in with your Google account
113
- - Connect your GitHub account and authorize repositories
114
- - Get your API key from the dashboard
115
-
116
- 2. **Configure BaseGuard:**
117
- ```bash
118
- base config set-keys
119
- # Follow the prompts to enter your Jules API key
120
-
121
- # Set Jules as your primary coding agent
122
- base config coding-agent --agent jules
123
- ```
124
-
125
- **Advantages:**
126
- - ✅ Autonomous operation in cloud VMs
127
- - ✅ Full repository context understanding
128
- - ✅ Asynchronous processing
129
- - ❌ Requires GitHub repository
130
- - ❌ Cannot work with local/uncommitted files
131
-
132
- ### Dual Agent Setup (Recommended)
133
-
134
- You can configure both agents and BaseGuard will automatically choose the best one:
135
-
136
- ```bash
137
- base config set-keys
138
- # Enter both Gemini and Jules API keys
139
-
140
- base config coding-agent
141
- # Choose your preferred primary agent
142
- # BaseGuard will fallback to the other when needed
143
- ```
144
-
145
- ## 📋 Complete Command Reference
146
-
147
- ### Core Commands
148
-
149
- ```bash
150
- # Project initialization
151
- base init # Interactive setup
152
- base init --preset baseline-widely # Use specific browser preset
153
- base init --skip-hooks # Skip git hook installation
154
-
155
- # Compatibility checking
156
- base check # Check all supported files
157
- base check --strict # Exit with error if violations found
158
- base check --files "src/**/*.ts" # Check specific file patterns
159
- base check --format json # Output results as JSON
160
- base check --offline # Run without network requests
161
-
162
- # AI-powered fixing
163
- base fix # Interactive fixing with previews
164
- base fix --auto # Apply all fixes automatically
165
- base fix --analyze-only # Only analyze, don't generate fixes
166
- base fix --files "src/**/*.css" # Fix specific file patterns
167
- ```
168
-
169
- ### Configuration Management
170
-
171
- ```bash
172
- # View configuration
173
- base config show # Detailed configuration display
174
- base config list # Quick configuration summary
175
- base config list --format json # Export configuration as JSON
176
-
177
- # API key management
178
- base config set-keys # Interactive API key setup
179
- base config coding-agent # Manage coding agent selection
180
- base config coding-agent --show # Show current agent configuration
181
- base config coding-agent --agent gemini # Set specific agent
182
-
183
- # Browser targets
184
- base config targets --add "chrome 100" # Add browser target
185
- base config targets --remove chrome # Remove browser targets
186
- base config targets --preset baseline-widely # Set browser preset
187
-
188
- # Configuration maintenance
189
- base config validate # Check configuration for errors
190
- base config recover # Attempt automatic recovery
191
- base config recover --backup # Create backup before recovery
192
- ```
193
-
194
- ### Git Automation
195
-
196
- ```bash
197
- # Automation control
198
- base automation enable # Enable git hooks with setup wizard
199
- base automation enable --trigger pre-push # Enable with specific trigger
200
- base automation disable # Disable automation and remove hooks
201
- base automation status # Show detailed automation status
202
- base automation configure # Interactive automation setup
203
-
204
- # Manual automation testing
205
- base automation run --trigger pre-commit # Test pre-commit behavior
206
- base automation run --trigger pre-push # Test pre-push behavior
207
- ```
208
-
209
- ### System Management
210
-
211
- ```bash
212
- # System health and diagnostics
213
- base status # Show system health overview
214
- base status --verbose # Detailed system information
215
- base status --services # Check external service availability
216
- base diagnostics # Run comprehensive system diagnostics
217
-
218
- # Quick shortcuts
219
- base add "firefox 90" # Quick browser target addition
220
- base remove safari # Quick browser target removal
221
- base list # Quick configuration summary
222
- base version # Show version information
223
- base help [command] # Get help for specific commands
224
- ```
225
-
226
- ## 🎯 Browser Compatibility Targets
227
-
228
- BaseGuard supports flexible browser targeting strategies:
229
-
230
- ### Preset Configurations
231
-
232
- ```bash
233
- # Baseline Widely (Recommended)
234
- # Features supported across browsers for 30+ months
235
- base config targets --preset baseline-widely
236
-
237
- # Baseline Newly
238
- # Recently available Baseline features (cutting-edge)
239
- base config targets --preset baseline-newly
240
-
241
- # Last 2 Years
242
- # Browsers released in the last 2 years
243
- base config targets --preset last-2-years
244
- ```
245
-
246
- ### Custom Browser Targets
247
-
248
- ```bash
249
- # Specific browser versions
250
- base add "chrome 100" # Chrome 100 and above
251
- base add "firefox 90" # Firefox 90 and above
252
- base add "safari 15" # Safari 15 and above
253
-
254
- # Baseline keyword support
255
- base add "chrome baseline" # Chrome with Baseline support
256
- base add "safari baseline" # Safari with Baseline support
257
- ```
258
-
259
- ### Example Configurations
260
-
261
- **Conservative (Maximum Compatibility):**
262
- ```json
263
- {
264
- "targets": [
265
- "chrome 88",
266
- "firefox 78",
267
- "safari 14",
268
- "edge 88"
269
- ]
270
- }
271
- ```
272
-
273
- **Modern (Baseline Widely):**
274
- ```json
275
- {
276
- "targets": [
277
- "chrome baseline",
278
- "firefox baseline",
279
- "safari baseline"
280
- ]
281
- }
282
- ```
283
-
284
- **Cutting-edge (Latest Features):**
285
- ```json
286
- {
287
- "targets": [
288
- "chrome 120",
289
- "firefox 120",
290
- "safari 17"
291
- ]
292
- }
293
- ```
294
-
295
- ## 🔧 Git Integration & Automation
296
-
297
- BaseGuard can automatically check your code before commits or pushes:
298
-
299
- ### Setup Git Hooks
300
-
301
- ```bash
302
- # Enable automation with interactive setup
303
- base automation enable
304
-
305
- # Choose your trigger:
306
- # - pre-commit: Check before each commit (faster feedback)
307
- # - pre-push: Check before each push (less frequent)
308
-
309
- # Enable with specific settings
310
- base automation enable --trigger pre-commit --auto-fix
311
- ```
312
-
313
- ### Automation Features
314
-
315
- - **Violation Detection:** Automatically scans staged files (pre-commit) or all files (pre-push)
316
- - **Commit Blocking:** Prevents commits/pushes when violations are found
317
- - **Auto-fixing:** Optionally applies AI fixes automatically
318
- - **Manual Override:** Use `git commit --no-verify` to bypass when needed
319
-
320
- ### Automation Workflow
321
-
322
- 1. **Developer makes changes** and runs `git commit`
323
- 2. **BaseGuard hook triggers** and scans the staged files
324
- 3. **If violations found:**
325
- - Shows detailed violation report
326
- - Blocks the commit
327
- - Suggests running `base fix` to resolve issues
328
- 4. **If no violations:** Commit proceeds normally
329
-
330
- ## 🛠️ Advanced Usage
331
-
332
- ### Environment Variables
333
-
334
- ```bash
335
- # Performance tuning
336
- export BASEGUARD_MAX_WORKERS=4 # Limit concurrent file processing
337
- export BASEGUARD_MAX_FILES=1000 # Limit total files processed
338
- export BASEGUARD_CACHE_SIZE=500 # Limit cache size
339
-
340
- # Memory optimization
341
- export NODE_OPTIONS="--max-old-space-size=512" # Limit Node.js memory
342
- ```
343
-
344
- ### CI/CD Integration
345
-
346
- ```bash
347
- # In your CI pipeline
348
- base check --strict --format junit > baseguard-results.xml
349
-
350
- # Exit codes:
351
- # 0 = No violations found
352
- # 1 = Violations found (in strict mode)
353
- ```
354
-
355
- ### Offline Development
356
-
357
- BaseGuard works offline for baseline checking:
358
-
359
- ```bash
360
- # Run in offline mode (no AI analysis)
361
- base check --offline
362
-
363
- # Baseline checking works without network
364
- # AI features require internet connection
365
- ```
366
-
367
- ## 🔍 What BaseGuard Checks
368
-
369
- BaseGuard analyzes your code for browser compatibility issues across:
370
-
371
- ### Web Platform Features
372
- - **CSS Properties & Selectors:** Grid, Flexbox, custom properties, modern selectors
373
- - **JavaScript APIs:** Fetch, Promises, async/await, ES6+ features
374
- - **HTML Elements & Attributes:** Modern form inputs, semantic elements
375
- - **Web APIs:** Canvas, WebGL, WebRTC, WebAssembly, Service Workers
376
-
377
- ### Framework Support
378
- - **React/JSX:** Ignores React-specific syntax, focuses on web platform usage
379
- - **Vue:** Analyzes `<script>` and `<style>` blocks for web platform features
380
- - **Svelte:** Extracts web platform usage from component files
381
- - **Vanilla:** Direct analysis of JS, CSS, and HTML files
382
-
383
- ### Example Violations
384
-
385
- ```javascript
386
- // ❌ Will be flagged for older browsers
387
- const data = await fetch('/api/data');
388
- const result = data.json();
389
-
390
- // ✅ BaseGuard can suggest fixes like:
391
- const data = window.fetch ?
392
- await fetch('/api/data') :
393
- await fetchPolyfill('/api/data');
394
- ```
395
-
396
- ```css
397
- /* ❌ Will be flagged for older browsers */
398
- .container {
399
- display: grid;
400
- grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
401
- }
402
-
403
- /* ✅ BaseGuard can suggest progressive enhancement */
404
- .container {
405
- display: flex; /* Fallback */
406
- flex-wrap: wrap;
407
- }
408
-
409
- @supports (display: grid) {
410
- .container {
411
- display: grid;
412
- grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
413
- }
414
- }
415
- ```
416
-
417
- ## 🚨 Troubleshooting
418
-
419
- ### Common Issues
420
-
421
- **"No files found to check"**
422
- ```bash
423
- # Check your file pattern
424
- base check --files "**/*.{js,ts,jsx,tsx}"
425
-
426
- # Verify you're in the right directory
427
- ls -la # Should see your source files
428
- ```
429
-
430
- **"Configuration not found"**
431
- ```bash
432
- # Initialize BaseGuard in your project
433
- base init
434
-
435
- # Or recover corrupted configuration
436
- base config recover
437
- ```
438
-
439
- **"API key invalid"**
440
- ```bash
441
- # Reconfigure your API keys
442
- base config set-keys
443
-
444
- # Verify your keys are correct:
445
- # - Gemini: Should start with "AIza"
446
- # - Jules: Get from jules.google.com dashboard
447
- ```
448
-
449
- **"Git hooks not working"**
450
- ```bash
451
- # Check automation status
452
- base automation status
453
-
454
- # Reinstall hooks
455
- base automation disable
456
- base automation enable
457
- ```
458
-
459
- ### Getting Help
460
-
461
- ```bash
462
- # System health check
463
- base status --verbose
464
-
465
- # Comprehensive diagnostics
466
- base diagnostics
467
-
468
- # Debug mode for detailed logging
469
- base check --debug
470
- base fix --debug
471
- ```
472
-
473
- ### Support Resources
474
-
475
- - **Documentation:** [GitHub Repository](https://github.com/ebuka1017/baseguard)
476
- - **Issues:** [Report bugs and request features](https://github.com/ebuka1017/baseguard/issues)
477
- - **API Documentation:**
478
- - [Gemini API](https://ai.google.dev/docs)
479
- - [Jules Documentation](https://jules.google.com/docs)
480
-
481
- ## 📄 License
482
-
483
- MIT License - see [LICENSE](LICENSE) file for details.
484
-
485
- ---
486
-
487
- **Made with ❤️ by the BaseGuard Team**
488
-
1
+ # BaseGuard 🛡️
2
+
3
+ **Never ship incompatible code again** - Intelligent browser compatibility enforcement with AI-powered analysis and autonomous fixing.
4
+
5
+ ## What is BaseGuard?
6
+
7
+ BaseGuard is a comprehensive browser compatibility tool that prevents incompatible code from reaching production. It combines official Baseline data with AI-powered analysis and code fixing to ensure your web applications work across all target browsers.
8
+
9
+ ### Key Features
10
+
11
+ - 🔍 **Universal Framework Support** - Works with React, Vue, Svelte, vanilla JS/CSS, and more
12
+ - 🤖 **Dual AI Coding Agents** - Choose between Jules (GitHub repos) or Gemini 2.5 Pro (any files)
13
+ - 📊 **Official Baseline Data** - Uses web-features package for accurate compatibility checking
14
+ - 🔧 **Intelligent Code Fixing** - AI generates progressive enhancement and polyfill solutions
15
+ - 🪝 **Git Integration** - Automated pre-commit/pre-push hooks with violation blocking
16
+ - 📈 **Graceful Degradation** - Works offline and handles service failures intelligently
17
+ - 🎨 **Beautiful CLI** - Colorful terminal output with progress indicators and detailed reports
18
+
19
+ ## Installation
20
+
21
+ ```bash
22
+ npm install -g baseguard
23
+ ```
24
+
25
+ **Requirements:**
26
+ - Node.js 18 or higher
27
+ - Git (for automation features)
28
+ - API keys for AI services (setup guide below)
29
+
30
+ ## Quick Start
31
+
32
+ ### 1. Initialize BaseGuard in Your Project
33
+
34
+ ```bash
35
+ cd your-project
36
+ base init
37
+ ```
38
+
39
+ This will:
40
+ - Create `.baseguardrc.json` configuration file
41
+ - Set up browser compatibility targets
42
+ - Guide you through API key setup
43
+ - Optionally install git hooks for automation
44
+
45
+ ### 2. Check for Compatibility Issues
46
+
47
+ ```bash
48
+ # Check all supported files
49
+ base check
50
+
51
+ # Check specific files or patterns
52
+ base check --files "src/**/*.ts"
53
+
54
+ # Strict mode (exit with error if violations found)
55
+ base check --strict
56
+ ```
57
+
58
+ ### 3. Fix Issues with AI
59
+
60
+ ```bash
61
+ # Interactive fixing with preview
62
+ base fix
63
+
64
+ # Automatic fixing (no prompts)
65
+ base fix --auto
66
+
67
+ # Analysis only (no code changes)
68
+ base fix --analyze-only
69
+ ```
70
+
71
+ ## 🚀 Getting Started with AI Services
72
+
73
+ BaseGuard offers two AI coding agents for fixing compatibility issues. You can choose the one that best fits your workflow:
74
+
75
+ ### Option 1: Gemini 2.5 Pro (Recommended for Most Users)
76
+
77
+ **Best for:** Any codebase, local development, uncommitted files
78
+
79
+ **Setup Steps:**
80
+
81
+ 1. **Get your Gemini API key:**
82
+ - Go to [Google AI Studio](https://aistudio.google.com)
83
+ - Sign in with your Google account
84
+ - Click "Get API key" in the left sidebar
85
+ - Click "Create API key" → "Create API key in new project"
86
+ - Copy your API key
87
+
88
+ 2. **Configure BaseGuard:**
89
+ ```bash
90
+ base config set-keys
91
+ # Follow the prompts to enter your Gemini API key
92
+
93
+ # Set Gemini as your primary coding agent
94
+ base config coding-agent --agent gemini
95
+ ```
96
+
97
+ **Advantages:**
98
+ - ✅ Works with any files (GitHub, local, uncommitted)
99
+ - ✅ Immediate processing and results
100
+ - ✅ No repository requirements
101
+ - ✅ Grounded with real-time web search
102
+ - ✅ Perfect for local development
103
+
104
+ ### Option 2: Jules (Google's Autonomous Coding Agent)
105
+
106
+ **Best for:** GitHub repositories, autonomous cloud-based fixing
107
+
108
+ **Setup Steps:**
109
+
110
+ 1. **Get your Jules API key:**
111
+ - Go to [Jules Dashboard](https://jules.google.com)
112
+ - Sign in with your Google account
113
+ - Connect your GitHub account and authorize repositories
114
+ - Get your API key from the dashboard
115
+
116
+ 2. **Configure BaseGuard:**
117
+ ```bash
118
+ base config set-keys
119
+ # Follow the prompts to enter your Jules API key
120
+
121
+ # Set Jules as your primary coding agent
122
+ base config coding-agent --agent jules
123
+ ```
124
+
125
+ **Advantages:**
126
+ - ✅ Autonomous operation in cloud VMs
127
+ - ✅ Full repository context understanding
128
+ - ✅ Asynchronous processing
129
+ - ❌ Requires GitHub repository
130
+ - ❌ Cannot work with local/uncommitted files
131
+
132
+ ### Dual Agent Setup (Recommended)
133
+
134
+ You can configure both agents and BaseGuard will automatically choose the best one:
135
+
136
+ ```bash
137
+ base config set-keys
138
+ # Enter both Gemini and Jules API keys
139
+
140
+ base config coding-agent
141
+ # Choose your preferred primary agent
142
+ # BaseGuard will fallback to the other when needed
143
+ ```
144
+
145
+ ## 📋 Complete Command Reference
146
+
147
+ ### Core Commands
148
+
149
+ ```bash
150
+ # Project initialization
151
+ base init # Interactive setup
152
+ base init --preset baseline-widely # Use specific browser preset
153
+ base init --skip-hooks # Skip git hook installation
154
+
155
+ # Compatibility checking
156
+ base check # Check all supported files
157
+ base check --strict # Exit with error if violations found
158
+ base check --files "src/**/*.ts" # Check specific file patterns
159
+ base check --format json # Output results as JSON
160
+ base check --offline # Run without network requests
161
+
162
+ # AI-powered fixing
163
+ base fix # Interactive fixing with previews
164
+ base fix --auto # Apply all fixes automatically
165
+ base fix --analyze-only # Only analyze, don't generate fixes
166
+ base fix --files "src/**/*.css" # Fix specific file patterns
167
+ ```
168
+
169
+ ### Configuration Management
170
+
171
+ ```bash
172
+ # View configuration
173
+ base config show # Detailed configuration display
174
+ base config list # Quick configuration summary
175
+ base config list --format json # Export configuration as JSON
176
+
177
+ # API key management
178
+ base config set-keys # Interactive API key setup
179
+ base config coding-agent # Manage coding agent selection
180
+ base config coding-agent --show # Show current agent configuration
181
+ base config coding-agent --agent gemini # Set specific agent
182
+
183
+ # Browser targets
184
+ base config targets --add "chrome 100" # Add browser target
185
+ base config targets --remove chrome # Remove browser targets
186
+ base config targets --preset baseline-widely # Set browser preset
187
+
188
+ # Configuration maintenance
189
+ base config validate # Check configuration for errors
190
+ base config recover # Attempt automatic recovery
191
+ base config recover --backup # Create backup before recovery
192
+ ```
193
+
194
+ ### Git Automation
195
+
196
+ ```bash
197
+ # Automation control
198
+ base automation enable # Enable git hooks with setup wizard
199
+ base automation enable --trigger pre-push # Enable with specific trigger
200
+ base automation disable # Disable automation and remove hooks
201
+ base automation status # Show detailed automation status
202
+ base automation configure # Interactive automation setup
203
+
204
+ # Manual automation testing
205
+ base automation run --trigger pre-commit # Test pre-commit behavior
206
+ base automation run --trigger pre-push # Test pre-push behavior
207
+ ```
208
+
209
+ ### System Management
210
+
211
+ ```bash
212
+ # System health and diagnostics
213
+ base status # Show system health overview
214
+ base status --verbose # Detailed system information
215
+ base status --services # Check external service availability
216
+ base diagnostics # Run comprehensive system diagnostics
217
+
218
+ # Quick shortcuts
219
+ base add "firefox 90" # Quick browser target addition
220
+ base remove safari # Quick browser target removal
221
+ base list # Quick configuration summary
222
+ base version # Show version information
223
+ base help [command] # Get help for specific commands
224
+ ```
225
+
226
+ ## 🎯 Browser Compatibility Targets
227
+
228
+ BaseGuard supports flexible browser targeting strategies:
229
+
230
+ ### Preset Configurations
231
+
232
+ ```bash
233
+ # Baseline Widely (Recommended)
234
+ # Features supported across browsers for 30+ months
235
+ base config targets --preset baseline-widely
236
+
237
+ # Baseline Newly
238
+ # Recently available Baseline features (cutting-edge)
239
+ base config targets --preset baseline-newly
240
+
241
+ # Last 2 Years
242
+ # Browsers released in the last 2 years
243
+ base config targets --preset last-2-years
244
+ ```
245
+
246
+ ### Custom Browser Targets
247
+
248
+ ```bash
249
+ # Specific browser versions
250
+ base add "chrome 100" # Chrome 100 and above
251
+ base add "firefox 90" # Firefox 90 and above
252
+ base add "safari 15" # Safari 15 and above
253
+
254
+ # Baseline keyword support
255
+ base add "chrome baseline" # Chrome with Baseline support
256
+ base add "safari baseline" # Safari with Baseline support
257
+ ```
258
+
259
+ ### Example Configurations
260
+
261
+ **Conservative (Maximum Compatibility):**
262
+ ```json
263
+ {
264
+ "targets": [
265
+ "chrome 88",
266
+ "firefox 78",
267
+ "safari 14",
268
+ "edge 88"
269
+ ]
270
+ }
271
+ ```
272
+
273
+ **Modern (Baseline Widely):**
274
+ ```json
275
+ {
276
+ "targets": [
277
+ "chrome baseline",
278
+ "firefox baseline",
279
+ "safari baseline"
280
+ ]
281
+ }
282
+ ```
283
+
284
+ **Cutting-edge (Latest Features):**
285
+ ```json
286
+ {
287
+ "targets": [
288
+ "chrome 120",
289
+ "firefox 120",
290
+ "safari 17"
291
+ ]
292
+ }
293
+ ```
294
+
295
+ ## 🔧 Git Integration & Automation
296
+
297
+ BaseGuard can automatically check your code before commits or pushes:
298
+
299
+ ### Setup Git Hooks
300
+
301
+ ```bash
302
+ # Enable automation with interactive setup
303
+ base automation enable
304
+
305
+ # Choose your trigger:
306
+ # - pre-commit: Check before each commit (faster feedback)
307
+ # - pre-push: Check before each push (less frequent)
308
+
309
+ # Enable with specific settings
310
+ base automation enable --trigger pre-commit --auto-fix
311
+ ```
312
+
313
+ ### Automation Features
314
+
315
+ - **Violation Detection:** Automatically scans staged files (pre-commit) or all files (pre-push)
316
+ - **Commit Blocking:** Prevents commits/pushes when violations are found
317
+ - **Auto-fixing:** Optionally applies AI fixes automatically
318
+ - **Manual Override:** Use `git commit --no-verify` to bypass when needed
319
+
320
+ ### Automation Workflow
321
+
322
+ 1. **Developer makes changes** and runs `git commit`
323
+ 2. **BaseGuard hook triggers** and scans the staged files
324
+ 3. **If violations found:**
325
+ - Shows detailed violation report
326
+ - Blocks the commit
327
+ - Suggests running `base fix` to resolve issues
328
+ 4. **If no violations:** Commit proceeds normally
329
+
330
+ ## 🛠️ Advanced Usage
331
+
332
+ ### Environment Variables
333
+
334
+ ```bash
335
+ # Performance tuning
336
+ export BASEGUARD_MAX_WORKERS=4 # Limit concurrent file processing
337
+ export BASEGUARD_MAX_FILES=1000 # Limit total files processed
338
+ export BASEGUARD_CACHE_SIZE=500 # Limit cache size
339
+
340
+ # Memory optimization
341
+ export NODE_OPTIONS="--max-old-space-size=512" # Limit Node.js memory
342
+ ```
343
+
344
+ ### CI/CD Integration
345
+
346
+ ```bash
347
+ # In your CI pipeline
348
+ base check --strict --format junit > baseguard-results.xml
349
+
350
+ # Exit codes:
351
+ # 0 = No violations found
352
+ # 1 = Violations found (in strict mode)
353
+ ```
354
+
355
+ ### Offline Development
356
+
357
+ BaseGuard works offline for baseline checking:
358
+
359
+ ```bash
360
+ # Run in offline mode (no AI analysis)
361
+ base check --offline
362
+
363
+ # Baseline checking works without network
364
+ # AI features require internet connection
365
+ ```
366
+
367
+ ## 🔍 What BaseGuard Checks
368
+
369
+ BaseGuard analyzes your code for browser compatibility issues across:
370
+
371
+ ### Web Platform Features
372
+ - **CSS Properties & Selectors:** Grid, Flexbox, custom properties, modern selectors
373
+ - **JavaScript APIs:** Fetch, Promises, async/await, ES6+ features
374
+ - **HTML Elements & Attributes:** Modern form inputs, semantic elements
375
+ - **Web APIs:** Canvas, WebGL, WebRTC, WebAssembly, Service Workers
376
+
377
+ ### Framework Support
378
+ - **React/JSX:** Ignores React-specific syntax, focuses on web platform usage
379
+ - **Vue:** Analyzes `<script>` and `<style>` blocks for web platform features
380
+ - **Svelte:** Extracts web platform usage from component files
381
+ - **Vanilla:** Direct analysis of JS, CSS, and HTML files
382
+
383
+ ### Example Violations
384
+
385
+ ```javascript
386
+ // ❌ Will be flagged for older browsers
387
+ const data = await fetch('/api/data');
388
+ const result = data.json();
389
+
390
+ // ✅ BaseGuard can suggest fixes like:
391
+ const data = window.fetch ?
392
+ await fetch('/api/data') :
393
+ await fetchPolyfill('/api/data');
394
+ ```
395
+
396
+ ```css
397
+ /* ❌ Will be flagged for older browsers */
398
+ .container {
399
+ display: grid;
400
+ grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
401
+ }
402
+
403
+ /* ✅ BaseGuard can suggest progressive enhancement */
404
+ .container {
405
+ display: flex; /* Fallback */
406
+ flex-wrap: wrap;
407
+ }
408
+
409
+ @supports (display: grid) {
410
+ .container {
411
+ display: grid;
412
+ grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
413
+ }
414
+ }
415
+ ```
416
+
417
+ ## 🚨 Troubleshooting
418
+
419
+ ### Common Issues
420
+
421
+ **"No files found to check"**
422
+ ```bash
423
+ # Check your file pattern
424
+ base check --files "**/*.{js,ts,jsx,tsx}"
425
+
426
+ # Verify you're in the right directory
427
+ ls -la # Should see your source files
428
+ ```
429
+
430
+ **"Configuration not found"**
431
+ ```bash
432
+ # Initialize BaseGuard in your project
433
+ base init
434
+
435
+ # Or recover corrupted configuration
436
+ base config recover
437
+ ```
438
+
439
+ **"API key invalid"**
440
+ ```bash
441
+ # Reconfigure your API keys
442
+ base config set-keys
443
+
444
+ # Verify your keys are correct:
445
+ # - Gemini: Should start with "AIza"
446
+ # - Jules: Get from jules.google.com dashboard
447
+ ```
448
+
449
+ **"Git hooks not working"**
450
+ ```bash
451
+ # Check automation status
452
+ base automation status
453
+
454
+ # Reinstall hooks
455
+ base automation disable
456
+ base automation enable
457
+ ```
458
+
459
+ ### Getting Help
460
+
461
+ ```bash
462
+ # System health check
463
+ base status --verbose
464
+
465
+ # Comprehensive diagnostics
466
+ base diagnostics
467
+
468
+ # Debug mode for detailed logging
469
+ base check --debug
470
+ base fix --debug
471
+ ```
472
+
473
+ ### Support Resources
474
+
475
+ - **Documentation:** [GitHub Repository](https://github.com/ebuka1017/baseguard)
476
+ - **Issues:** [Report bugs and request features](https://github.com/ebuka1017/baseguard/issues)
477
+ - **API Documentation:**
478
+ - [Gemini API](https://ai.google.dev/docs)
479
+ - [Jules Documentation](https://jules.google.com/docs)
480
+
481
+ ## 📄 License
482
+
483
+ MIT License - see [LICENSE](LICENSE) file for details.
484
+
485
+ ---
486
+
487
+ **Made with ❤️ by the BaseGuard Team**
488
+
489
489
  *Never ship incompatible code again!* 🛡️