baseguard 1.0.0

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 (244) hide show
  1. package/.eslintrc.json +25 -0
  2. package/.prettierrc +8 -0
  3. package/README.md +94 -0
  4. package/bin/base.js +494 -0
  5. package/dist/ai/fix-manager.d.ts +67 -0
  6. package/dist/ai/fix-manager.d.ts.map +1 -0
  7. package/dist/ai/fix-manager.js +326 -0
  8. package/dist/ai/fix-manager.js.map +1 -0
  9. package/dist/ai/gemini-analyzer.d.ts +116 -0
  10. package/dist/ai/gemini-analyzer.d.ts.map +1 -0
  11. package/dist/ai/gemini-analyzer.js +572 -0
  12. package/dist/ai/gemini-analyzer.js.map +1 -0
  13. package/dist/ai/index.d.ts +4 -0
  14. package/dist/ai/index.d.ts.map +1 -0
  15. package/dist/ai/index.js +5 -0
  16. package/dist/ai/index.js.map +1 -0
  17. package/dist/ai/jules-implementer.d.ts +115 -0
  18. package/dist/ai/jules-implementer.d.ts.map +1 -0
  19. package/dist/ai/jules-implementer.js +387 -0
  20. package/dist/ai/jules-implementer.js.map +1 -0
  21. package/dist/commands/automation.d.ts +5 -0
  22. package/dist/commands/automation.d.ts.map +1 -0
  23. package/dist/commands/automation.js +305 -0
  24. package/dist/commands/automation.js.map +1 -0
  25. package/dist/commands/check.d.ts +9 -0
  26. package/dist/commands/check.d.ts.map +1 -0
  27. package/dist/commands/check.js +113 -0
  28. package/dist/commands/check.js.map +1 -0
  29. package/dist/commands/config.d.ts +11 -0
  30. package/dist/commands/config.d.ts.map +1 -0
  31. package/dist/commands/config.js +324 -0
  32. package/dist/commands/config.js.map +1 -0
  33. package/dist/commands/fix.d.ts +9 -0
  34. package/dist/commands/fix.d.ts.map +1 -0
  35. package/dist/commands/fix.js +207 -0
  36. package/dist/commands/fix.js.map +1 -0
  37. package/dist/commands/index.d.ts +6 -0
  38. package/dist/commands/index.d.ts.map +1 -0
  39. package/dist/commands/index.js +7 -0
  40. package/dist/commands/index.js.map +1 -0
  41. package/dist/commands/init.d.ts +9 -0
  42. package/dist/commands/init.d.ts.map +1 -0
  43. package/dist/commands/init.js +125 -0
  44. package/dist/commands/init.js.map +1 -0
  45. package/dist/core/api-key-manager.d.ts +83 -0
  46. package/dist/core/api-key-manager.d.ts.map +1 -0
  47. package/dist/core/api-key-manager.js +244 -0
  48. package/dist/core/api-key-manager.js.map +1 -0
  49. package/dist/core/baseguard.d.ts +46 -0
  50. package/dist/core/baseguard.d.ts.map +1 -0
  51. package/dist/core/baseguard.js +132 -0
  52. package/dist/core/baseguard.js.map +1 -0
  53. package/dist/core/baseline-checker.d.ts +63 -0
  54. package/dist/core/baseline-checker.d.ts.map +1 -0
  55. package/dist/core/baseline-checker.js +502 -0
  56. package/dist/core/baseline-checker.js.map +1 -0
  57. package/dist/core/cache-manager.d.ts +88 -0
  58. package/dist/core/cache-manager.d.ts.map +1 -0
  59. package/dist/core/cache-manager.js +213 -0
  60. package/dist/core/cache-manager.js.map +1 -0
  61. package/dist/core/configuration.d.ts +140 -0
  62. package/dist/core/configuration.d.ts.map +1 -0
  63. package/dist/core/configuration.js +474 -0
  64. package/dist/core/configuration.js.map +1 -0
  65. package/dist/core/directory-filter.d.ts +90 -0
  66. package/dist/core/directory-filter.d.ts.map +1 -0
  67. package/dist/core/directory-filter.js +319 -0
  68. package/dist/core/directory-filter.js.map +1 -0
  69. package/dist/core/error-handler.d.ts +110 -0
  70. package/dist/core/error-handler.d.ts.map +1 -0
  71. package/dist/core/error-handler.js +392 -0
  72. package/dist/core/error-handler.js.map +1 -0
  73. package/dist/core/file-processor.d.ts +80 -0
  74. package/dist/core/file-processor.d.ts.map +1 -0
  75. package/dist/core/file-processor.js +259 -0
  76. package/dist/core/file-processor.js.map +1 -0
  77. package/dist/core/gitignore-manager.d.ts +44 -0
  78. package/dist/core/gitignore-manager.d.ts.map +1 -0
  79. package/dist/core/gitignore-manager.js +147 -0
  80. package/dist/core/gitignore-manager.js.map +1 -0
  81. package/dist/core/index.d.ts +13 -0
  82. package/dist/core/index.d.ts.map +1 -0
  83. package/dist/core/index.js +13 -0
  84. package/dist/core/index.js.map +1 -0
  85. package/dist/core/lazy-loader.d.ts +68 -0
  86. package/dist/core/lazy-loader.d.ts.map +1 -0
  87. package/dist/core/lazy-loader.js +260 -0
  88. package/dist/core/lazy-loader.js.map +1 -0
  89. package/dist/core/memory-manager.d.ts +1 -0
  90. package/dist/core/memory-manager.d.ts.map +1 -0
  91. package/dist/core/memory-manager.js +2 -0
  92. package/dist/core/memory-manager.js.map +1 -0
  93. package/dist/core/startup-optimizer.d.ts +45 -0
  94. package/dist/core/startup-optimizer.d.ts.map +1 -0
  95. package/dist/core/startup-optimizer.js +140 -0
  96. package/dist/core/startup-optimizer.js.map +1 -0
  97. package/dist/git/automation-engine.d.ts +58 -0
  98. package/dist/git/automation-engine.d.ts.map +1 -0
  99. package/dist/git/automation-engine.js +318 -0
  100. package/dist/git/automation-engine.js.map +1 -0
  101. package/dist/git/github-manager.d.ts +71 -0
  102. package/dist/git/github-manager.d.ts.map +1 -0
  103. package/dist/git/github-manager.js +226 -0
  104. package/dist/git/github-manager.js.map +1 -0
  105. package/dist/git/hook-manager.d.ts +43 -0
  106. package/dist/git/hook-manager.d.ts.map +1 -0
  107. package/dist/git/hook-manager.js +191 -0
  108. package/dist/git/hook-manager.js.map +1 -0
  109. package/dist/git/index.d.ts +4 -0
  110. package/dist/git/index.d.ts.map +1 -0
  111. package/dist/git/index.js +5 -0
  112. package/dist/git/index.js.map +1 -0
  113. package/dist/index.d.ts +8 -0
  114. package/dist/index.d.ts.map +1 -0
  115. package/dist/index.js +9 -0
  116. package/dist/index.js.map +1 -0
  117. package/dist/parsers/feature-validator.d.ts +60 -0
  118. package/dist/parsers/feature-validator.d.ts.map +1 -0
  119. package/dist/parsers/feature-validator.js +483 -0
  120. package/dist/parsers/feature-validator.js.map +1 -0
  121. package/dist/parsers/index.d.ts +8 -0
  122. package/dist/parsers/index.d.ts.map +1 -0
  123. package/dist/parsers/index.js +9 -0
  124. package/dist/parsers/index.js.map +1 -0
  125. package/dist/parsers/parser-manager.d.ts +103 -0
  126. package/dist/parsers/parser-manager.d.ts.map +1 -0
  127. package/dist/parsers/parser-manager.js +321 -0
  128. package/dist/parsers/parser-manager.js.map +1 -0
  129. package/dist/parsers/parser.d.ts +23 -0
  130. package/dist/parsers/parser.d.ts.map +1 -0
  131. package/dist/parsers/parser.js +6 -0
  132. package/dist/parsers/parser.js.map +1 -0
  133. package/dist/parsers/react-parser.d.ts +22 -0
  134. package/dist/parsers/react-parser.d.ts.map +1 -0
  135. package/dist/parsers/react-parser.js +307 -0
  136. package/dist/parsers/react-parser.js.map +1 -0
  137. package/dist/parsers/svelte-parser.d.ts +33 -0
  138. package/dist/parsers/svelte-parser.d.ts.map +1 -0
  139. package/dist/parsers/svelte-parser.js +408 -0
  140. package/dist/parsers/svelte-parser.js.map +1 -0
  141. package/dist/parsers/vanilla-parser.d.ts +31 -0
  142. package/dist/parsers/vanilla-parser.d.ts.map +1 -0
  143. package/dist/parsers/vanilla-parser.js +590 -0
  144. package/dist/parsers/vanilla-parser.js.map +1 -0
  145. package/dist/parsers/vue-parser.d.ts +9 -0
  146. package/dist/parsers/vue-parser.d.ts.map +1 -0
  147. package/dist/parsers/vue-parser.js +16 -0
  148. package/dist/parsers/vue-parser.js.map +1 -0
  149. package/dist/terminal-header.d.ts +12 -0
  150. package/dist/terminal-header.js +45 -0
  151. package/dist/types/index.d.ts +83 -0
  152. package/dist/types/index.d.ts.map +1 -0
  153. package/dist/types/index.js +5 -0
  154. package/dist/types/index.js.map +1 -0
  155. package/dist/ui/components.d.ts +133 -0
  156. package/dist/ui/components.d.ts.map +1 -0
  157. package/dist/ui/components.js +482 -0
  158. package/dist/ui/components.js.map +1 -0
  159. package/dist/ui/help.d.ts +11 -0
  160. package/dist/ui/help.d.ts.map +1 -0
  161. package/dist/ui/help.js +161 -0
  162. package/dist/ui/help.js.map +1 -0
  163. package/dist/ui/index.d.ts +5 -0
  164. package/dist/ui/index.d.ts.map +1 -0
  165. package/dist/ui/index.js +5 -0
  166. package/dist/ui/index.js.map +1 -0
  167. package/dist/ui/prompts.d.ts +63 -0
  168. package/dist/ui/prompts.d.ts.map +1 -0
  169. package/dist/ui/prompts.js +611 -0
  170. package/dist/ui/prompts.js.map +1 -0
  171. package/dist/ui/terminal-header.d.ts +13 -0
  172. package/dist/ui/terminal-header.d.ts.map +1 -0
  173. package/dist/ui/terminal-header.js +46 -0
  174. package/dist/ui/terminal-header.js.map +1 -0
  175. package/package.json +80 -0
  176. package/src/ai/__tests__/gemini-analyzer.test.ts +181 -0
  177. package/src/ai/fix-manager.ts +362 -0
  178. package/src/ai/gemini-analyzer.ts +671 -0
  179. package/src/ai/index.ts +4 -0
  180. package/src/ai/jules-implementer.ts +459 -0
  181. package/src/commands/automation.ts +344 -0
  182. package/src/commands/check.ts +299 -0
  183. package/src/commands/config.ts +365 -0
  184. package/src/commands/fix.ts +234 -0
  185. package/src/commands/index.ts +6 -0
  186. package/src/commands/init.ts +142 -0
  187. package/src/commands/status.ts +0 -0
  188. package/src/core/api-key-manager.ts +298 -0
  189. package/src/core/baseguard.ts +742 -0
  190. package/src/core/baseline-checker.ts +563 -0
  191. package/src/core/cache-manager.ts +270 -0
  192. package/src/core/configuration-recovery.ts +676 -0
  193. package/src/core/configuration.ts +559 -0
  194. package/src/core/debug-logger.ts +590 -0
  195. package/src/core/directory-filter.ts +421 -0
  196. package/src/core/error-handler.ts +517 -0
  197. package/src/core/file-processor.ts +331 -0
  198. package/src/core/gitignore-manager.ts +169 -0
  199. package/src/core/graceful-degradation-manager.ts +596 -0
  200. package/src/core/index.ts +13 -0
  201. package/src/core/lazy-loader.ts +307 -0
  202. package/src/core/logger.ts +0 -0
  203. package/src/core/memory-manager.ts +294 -0
  204. package/src/core/startup-optimizer.ts +173 -0
  205. package/src/core/system-error-handler.ts +746 -0
  206. package/src/git/automation-engine.ts +361 -0
  207. package/src/git/github-manager.ts +260 -0
  208. package/src/git/hook-manager.ts +210 -0
  209. package/src/git/index.ts +4 -0
  210. package/src/index.ts +8 -0
  211. package/src/parsers/feature-validator.ts +559 -0
  212. package/src/parsers/index.ts +8 -0
  213. package/src/parsers/parser-manager.ts +419 -0
  214. package/src/parsers/parser.ts +26 -0
  215. package/src/parsers/react-parser-optimized.ts +161 -0
  216. package/src/parsers/react-parser.ts +359 -0
  217. package/src/parsers/svelte-parser.ts +506 -0
  218. package/src/parsers/vanilla-parser.ts +682 -0
  219. package/src/parsers/vue-parser.ts +472 -0
  220. package/src/types/index.ts +92 -0
  221. package/src/ui/components.ts +567 -0
  222. package/src/ui/help.ts +193 -0
  223. package/src/ui/index.ts +4 -0
  224. package/src/ui/prompts.ts +688 -0
  225. package/src/ui/terminal-header.ts +59 -0
  226. package/test-config-commands.js +56 -0
  227. package/test-header-simple.js +33 -0
  228. package/test-terminal-header.js +12 -0
  229. package/test-ui.js +29 -0
  230. package/tests/e2e/baseguard.e2e.test.ts +516 -0
  231. package/tests/e2e/cross-platform.e2e.test.ts +420 -0
  232. package/tests/e2e/git-integration.e2e.test.ts +487 -0
  233. package/tests/fixtures/react-project/package.json +14 -0
  234. package/tests/fixtures/react-project/src/App.css +76 -0
  235. package/tests/fixtures/react-project/src/App.tsx +77 -0
  236. package/tests/fixtures/svelte-project/package.json +11 -0
  237. package/tests/fixtures/svelte-project/src/App.svelte +369 -0
  238. package/tests/fixtures/vanilla-project/index.html +76 -0
  239. package/tests/fixtures/vanilla-project/script.js +331 -0
  240. package/tests/fixtures/vanilla-project/styles.css +359 -0
  241. package/tests/fixtures/vue-project/package.json +12 -0
  242. package/tests/fixtures/vue-project/src/App.vue +216 -0
  243. package/tsconfig.json +36 -0
  244. package/vitest.config.ts +10 -0
package/.eslintrc.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "root": true,
3
+ "parser": "@typescript-eslint/parser",
4
+ "plugins": ["@typescript-eslint"],
5
+ "extends": [
6
+ "eslint:recommended",
7
+ "@typescript-eslint/recommended"
8
+ ],
9
+ "parserOptions": {
10
+ "ecmaVersion": 2022,
11
+ "sourceType": "module"
12
+ },
13
+ "rules": {
14
+ "@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
15
+ "@typescript-eslint/no-explicit-any": "warn",
16
+ "@typescript-eslint/explicit-function-return-type": "off",
17
+ "@typescript-eslint/explicit-module-boundary-types": "off",
18
+ "prefer-const": "error",
19
+ "no-var": "error"
20
+ },
21
+ "env": {
22
+ "node": true,
23
+ "es2022": true
24
+ }
25
+ }
package/.prettierrc ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "semi": true,
3
+ "trailingComma": "es5",
4
+ "singleQuote": true,
5
+ "printWidth": 100,
6
+ "tabWidth": 2,
7
+ "useTabs": false
8
+ }
package/README.md ADDED
@@ -0,0 +1,94 @@
1
+ # BaseGuard šŸ›”ļø
2
+
3
+ Never ship incompatible code again - AI-powered browser compatibility enforcement
4
+
5
+ ## Overview
6
+
7
+ BaseGuard is an intelligent browser compatibility enforcement tool that prevents incompatible code from reaching production by combining three AI layers:
8
+
9
+ 1. **Baseline Detection** - Uses the official web-features package for instant compatibility checking
10
+ 2. **Gemini Analysis** - AI-powered research and fix strategy recommendations
11
+ 3. **Jules Implementation** - Autonomous code fixing with progressive enhancement
12
+
13
+ ## Features
14
+
15
+ - šŸ” **Universal Framework Support** - React, Vue, Svelte, Angular, vanilla JS/CSS
16
+ - šŸ¤– **AI-Powered Analysis** - Research user impact and best practices
17
+ - šŸ”§ **Autonomous Fixing** - Generate and apply compatibility fixes automatically
18
+ - šŸŖ **Git Integration** - Pre-commit/pre-push hooks for automated enforcement
19
+ - šŸ“Š **Beautiful CLI** - Colorful output with progress indicators and tables
20
+ - ⚔ **Offline-First** - Baseline checking works without network connectivity
21
+
22
+ ## Installation
23
+
24
+ ```bash
25
+ npm install -g baseguard
26
+ ```
27
+
28
+ ## Quick Start
29
+
30
+ ```bash
31
+ # Initialize in your project
32
+ base init
33
+
34
+ # Check for violations
35
+ base check
36
+
37
+ # Fix violations with AI
38
+ base fix
39
+
40
+ # Enable git automation
41
+ base automation enable --auto-fix
42
+ ```
43
+
44
+ ## Commands
45
+
46
+ ### Core Commands
47
+ - `base init` - Initialize BaseGuard in your project
48
+ - `base check` - Check for compatibility violations
49
+ - `base fix` - Fix violations with AI analysis and implementation
50
+
51
+ ### Configuration
52
+ - `base config show` - Show current configuration
53
+ - `base config set-keys` - Set up API keys for Jules and Gemini
54
+ - `base config targets` - Manage browser targets
55
+
56
+ ### Automation
57
+ - `base automation enable` - Enable git hooks
58
+ - `base automation disable` - Disable git hooks
59
+ - `base automation status` - Show automation status
60
+
61
+ ## Browser Targets
62
+
63
+ BaseGuard supports flexible browser targeting:
64
+
65
+ - **Baseline Widely** - Features supported for 30+ months
66
+ - **Baseline Newly** - Recently available baseline features
67
+ - **Custom Versions** - Specific browser versions (e.g., "chrome 100")
68
+ - **Baseline Keyword** - Use "baseline" for automatic baseline targeting
69
+
70
+ ## Development
71
+
72
+ ```bash
73
+ # Install dependencies
74
+ npm install
75
+
76
+ # Build the project
77
+ npm run build
78
+
79
+ # Run tests
80
+ npm test
81
+
82
+ # Development mode
83
+ npm run dev
84
+ ```
85
+
86
+ ## Requirements
87
+
88
+ - Node.js 18+
89
+ - Git (for automation features)
90
+ - API keys for Jules and Gemini (for AI features)
91
+
92
+ ## License
93
+
94
+ MIT
package/bin/base.js ADDED
@@ -0,0 +1,494 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { Command } from 'commander';
4
+ import chalk from 'chalk';
5
+ import { init, check, fix, config, automation } 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
10
+ const startupPromise = StartupOptimizer.initialize();
11
+
12
+ const program = new Command();
13
+
14
+ program
15
+ .name('base')
16
+ .description(chalk.cyan('šŸ›”ļø BaseGuard - Never ship incompatible code again\n') +
17
+ chalk.dim('Intelligent browser compatibility enforcement with AI-powered analysis and autonomous fixing'))
18
+ .version('1.0.0')
19
+ .configureOutput({
20
+ outputError: (str, write) => write(chalk.red(str))
21
+ })
22
+ .configureHelp({
23
+ helpWidth: 100,
24
+ sortSubcommands: true
25
+ })
26
+ .addHelpText('after', `
27
+ ${chalk.cyan('Examples:')}
28
+ ${chalk.dim('$')} base init ${chalk.gray('# Initialize BaseGuard in your project')}
29
+ ${chalk.dim('$')} base check ${chalk.gray('# Check for compatibility violations')}
30
+ ${chalk.dim('$')} base fix ${chalk.gray('# Fix violations with AI assistance')}
31
+ ${chalk.dim('$')} base config set-keys ${chalk.gray('# Configure API keys for AI services')}
32
+ ${chalk.dim('$')} base automation enable ${chalk.gray('# Enable git hooks for automatic checking')}
33
+
34
+ ${chalk.cyan('Getting Started:')}
35
+ 1. Run ${chalk.white('base init')} to set up BaseGuard in your project
36
+ 2. Configure API keys with ${chalk.white('base config set-keys')} for AI features
37
+ 3. Enable automation with ${chalk.white('base automation enable')}
38
+ 4. Check compatibility with ${chalk.white('base check')}
39
+
40
+ ${chalk.cyan('Documentation:')}
41
+ ${chalk.blue('https://github.com/baseguard/baseguard#readme')}
42
+
43
+ ${chalk.cyan('Support:')}
44
+ ${chalk.blue('https://github.com/baseguard/baseguard/issues')}
45
+ `);
46
+
47
+ // Initialize BaseGuard in project
48
+ program
49
+ .command('init')
50
+ .description('Initialize BaseGuard in your project with guided setup')
51
+ .option('--preset <preset>', 'Browser target preset (baseline-widely, baseline-newly, last-2-years, custom)', 'baseline-widely')
52
+ .option('--skip-hooks', 'Skip git hook installation during setup')
53
+ .option('--skip-api-keys', 'Skip API key configuration during setup')
54
+ .addHelpText('after', `
55
+ ${chalk.cyan('Browser Target Presets:')}
56
+ ${chalk.white('baseline-widely')} Support features available in Baseline for 30+ months
57
+ ${chalk.white('baseline-newly')} Support newly available Baseline features
58
+ ${chalk.white('last-2-years')} Support browsers from the last 2 years
59
+ ${chalk.white('custom')} Configure custom browser targets interactively
60
+
61
+ ${chalk.cyan('Examples:')}
62
+ ${chalk.dim('$')} base init ${chalk.gray('# Interactive setup with baseline-widely preset')}
63
+ ${chalk.dim('$')} base init --preset baseline-newly ${chalk.gray('# Use baseline-newly preset')}
64
+ ${chalk.dim('$')} base init --skip-hooks ${chalk.gray('# Skip git hook installation')}
65
+ ${chalk.dim('$')} base init --preset custom ${chalk.gray('# Configure custom browser targets')}
66
+
67
+ ${chalk.cyan('What this does:')}
68
+ • Creates .baseguardrc.json configuration file
69
+ • Sets up browser compatibility targets
70
+ • Configures API keys for AI services (optional)
71
+ • Installs git hooks for automation (optional)
72
+ • Adds .baseguardrc.json to .gitignore for security
73
+ `)
74
+ .action(async (options) => {
75
+ await startupPromise;
76
+ await StartupOptimizer.optimizeForUseCase('init');
77
+ return init(options);
78
+ });
79
+
80
+ // Check for compatibility violations
81
+ program
82
+ .command('check')
83
+ .description('Scan code for browser compatibility violations using Baseline data')
84
+ .option('--strict', 'Exit with error code if violations are found (useful for CI/CD)')
85
+ .option('--files <pattern>', 'File pattern to check using glob syntax', '**/*.{js,jsx,ts,tsx,vue,svelte,css,html}')
86
+ .option('--format <format>', 'Output format for results', 'table')
87
+ .addHelpText('after', `
88
+ ${chalk.cyan('Output Formats:')}
89
+ ${chalk.white('table')} Human-readable table format (default)
90
+ ${chalk.white('json')} JSON format for programmatic use
91
+ ${chalk.white('junit')} JUnit XML format for CI/CD integration
92
+
93
+ ${chalk.cyan('Examples:')}
94
+ ${chalk.dim('$')} base check ${chalk.gray('# Check all supported files')}
95
+ ${chalk.dim('$')} base check --strict ${chalk.gray('# Exit with error if violations found')}
96
+ ${chalk.dim('$')} base check --files "src/**/*.ts" ${chalk.gray('# Check only TypeScript files in src/')}
97
+ ${chalk.dim('$')} base check --format json ${chalk.gray('# Output results as JSON')}
98
+ ${chalk.dim('$')} base check --files "*.css" --strict ${chalk.gray('# Check CSS files with strict mode')}
99
+
100
+ ${chalk.cyan('File Patterns:')}
101
+ Supports glob patterns like:
102
+ • ${chalk.white('"src/**/*.{js,ts}"')} - All JS/TS files in src/ and subdirectories
103
+ • ${chalk.white('"components/*.vue"')} - All Vue files in components/
104
+ • ${chalk.white('"**/*.css"')} - All CSS files in project
105
+
106
+ ${chalk.cyan('What this checks:')}
107
+ • CSS properties, selectors, and at-rules
108
+ • JavaScript APIs and ECMAScript features
109
+ • HTML elements and attributes
110
+ • Framework-specific files (React, Vue, Svelte)
111
+ • Web platform APIs (Canvas, WebGL, WebRTC, WebAssembly, etc.)
112
+ `)
113
+ .action(async (options) => {
114
+ await startupPromise;
115
+ await StartupOptimizer.optimizeForUseCase('check');
116
+ return check(options);
117
+ });
118
+
119
+ // Fix violations with AI
120
+ program
121
+ .command('fix')
122
+ .description('Analyze and fix compatibility violations using AI (requires API keys)')
123
+ .option('--auto', 'Apply fixes automatically without interactive confirmation')
124
+ .option('--analyze-only', 'Only run AI analysis without generating code fixes')
125
+ .option('--files <pattern>', 'File pattern to fix using glob syntax', '**/*.{js,jsx,ts,tsx,vue,svelte,css,html}')
126
+ .addHelpText('after', `
127
+ ${chalk.cyan('Prerequisites:')}
128
+ • Gemini API key (for analysis) - Get from ${chalk.blue('https://aistudio.google.com')}
129
+ • Jules API key (for fixing) - Get from ${chalk.blue('https://jules.google.com')}
130
+ • GitHub integration setup for Jules (guided during first use)
131
+
132
+ ${chalk.cyan('Examples:')}
133
+ ${chalk.dim('$')} base fix ${chalk.gray('# Interactive fix with confirmation prompts')}
134
+ ${chalk.dim('$')} base fix --auto ${chalk.gray('# Apply all fixes automatically')}
135
+ ${chalk.dim('$')} base fix --analyze-only ${chalk.gray('# Only analyze, don\'t generate fixes')}
136
+ ${chalk.dim('$')} base fix --files "src/**/*.css" ${chalk.gray('# Fix only CSS files in src/')}
137
+
138
+ ${chalk.cyan('How it works:')}
139
+ 1. ${chalk.white('Scan')} - Detects compatibility violations using Baseline data
140
+ 2. ${chalk.white('Analyze')} - Gemini AI researches impact and fix strategies
141
+ 3. ${chalk.white('Fix')} - Jules AI generates progressive enhancement code
142
+ 4. ${chalk.white('Review')} - Shows preview of changes before applying
143
+ 5. ${chalk.white('Apply')} - Updates files with compatibility fixes
144
+
145
+ ${chalk.cyan('Fix Strategies:')}
146
+ • Progressive enhancement with @supports for CSS
147
+ • Feature detection for JavaScript APIs
148
+ • Polyfills and fallbacks for older browsers
149
+ • Graceful degradation patterns
150
+
151
+ ${chalk.cyan('Setup API Keys:')}
152
+ Run ${chalk.white('base config set-keys')} to configure AI services
153
+ `)
154
+ .action(async (options) => {
155
+ await startupPromise;
156
+ await StartupOptimizer.optimizeForUseCase('fix');
157
+ return fix(options);
158
+ });
159
+
160
+ // Configuration management
161
+ const configCmd = program
162
+ .command('config')
163
+ .description('Manage BaseGuard configuration and settings')
164
+ .addHelpText('after', `
165
+ ${chalk.cyan('Configuration Commands:')}
166
+ ${chalk.white('show')} Display detailed configuration with security status
167
+ ${chalk.white('list')} Show configuration summary (supports --format json)
168
+ ${chalk.white('set-keys')} Interactive API key setup with browser integration
169
+ ${chalk.white('targets')} Manage browser compatibility targets
170
+ ${chalk.white('validate')} Check configuration file for errors
171
+ ${chalk.white('automation')} Configure git automation settings
172
+
173
+ ${chalk.cyan('Examples:')}
174
+ ${chalk.dim('$')} base config show ${chalk.gray('# Show detailed configuration')}
175
+ ${chalk.dim('$')} base config set-keys ${chalk.gray('# Set up API keys interactively')}
176
+ ${chalk.dim('$')} base config list --format json ${chalk.gray('# Export configuration as JSON')}
177
+ ${chalk.dim('$')} base config targets --preset baseline-widely ${chalk.gray('# Set browser targets')}
178
+ `);
179
+
180
+ configCmd
181
+ .command('show')
182
+ .description('Display detailed configuration with security and validation status')
183
+ .addHelpText('after', `
184
+ ${chalk.cyan('What this shows:')}
185
+ • Current browser targets and presets
186
+ • API key configuration status (without exposing keys)
187
+ • Automation and git hook settings
188
+ • Security status (.gitignore configuration)
189
+ • Configuration validation results
190
+ • Recommendations for improvements
191
+ `)
192
+ .action(() => config('show'));
193
+
194
+ configCmd
195
+ .command('set-keys')
196
+ .description('Interactive setup of API keys for AI services')
197
+ .addHelpText('after', `
198
+ ${chalk.cyan('API Services:')}
199
+ ${chalk.white('Gemini')} - For AI analysis of compatibility issues
200
+ Get your key: ${chalk.blue('https://aistudio.google.com')}
201
+
202
+ ${chalk.white('Jules')} - For autonomous code fixing
203
+ Get your key: ${chalk.blue('https://jules.google.com')}
204
+
205
+ ${chalk.cyan('Security:')}
206
+ • Keys are stored in .baseguardrc.json
207
+ • File is automatically added to .gitignore
208
+ • Keys are validated before saving
209
+ `)
210
+ .action(() => config('set-keys'));
211
+
212
+ configCmd
213
+ .command('targets')
214
+ .description('Manage browser compatibility targets')
215
+ .option('--add <target>', 'Add browser target (format: "browser version")')
216
+ .option('--remove <target>', 'Remove browser target by name')
217
+ .option('--preset <preset>', 'Set predefined browser targets')
218
+ .addHelpText('after', `
219
+ ${chalk.cyan('Target Formats:')}
220
+ ${chalk.white('"chrome 100"')} Minimum Chrome version 100
221
+ ${chalk.white('"safari baseline"')} Safari with Baseline support only
222
+ ${chalk.white('"firefox 90"')} Minimum Firefox version 90
223
+
224
+ ${chalk.cyan('Available Presets:')}
225
+ ${chalk.white('baseline-widely')} Features available for 30+ months
226
+ ${chalk.white('baseline-newly')} Newly available Baseline features
227
+ ${chalk.white('last-2-years')} Browsers from last 2 years
228
+
229
+ ${chalk.cyan('Examples:')}
230
+ ${chalk.dim('$')} base config targets --add "chrome 100"
231
+ ${chalk.dim('$')} base config targets --remove chrome
232
+ ${chalk.dim('$')} base config targets --preset baseline-widely
233
+ `)
234
+ .action((options) => config('targets', options));
235
+
236
+ configCmd
237
+ .command('list')
238
+ .description('Show configuration summary with status information')
239
+ .option('--format <format>', 'Output format (table or json)', 'table')
240
+ .addHelpText('after', `
241
+ ${chalk.cyan('Output Formats:')}
242
+ ${chalk.white('table')} Human-readable summary (default)
243
+ ${chalk.white('json')} Machine-readable JSON for scripts
244
+
245
+ ${chalk.cyan('Includes:')}
246
+ • Browser targets and count
247
+ • API key configuration status
248
+ • Automation settings
249
+ • Security and validation status
250
+ `)
251
+ .action((options) => config('list', options));
252
+
253
+ configCmd
254
+ .command('validate')
255
+ .description('Validate configuration file for errors and inconsistencies')
256
+ .addHelpText('after', `
257
+ ${chalk.cyan('Validation Checks:')}
258
+ • Configuration file syntax and structure
259
+ • Browser target format and validity
260
+ • API key format validation
261
+ • Automation setting consistency
262
+ • Required field presence
263
+
264
+ ${chalk.cyan('Exit Codes:')}
265
+ 0 - Configuration is valid
266
+ 1 - Validation errors found
267
+ `)
268
+ .action(() => config('validate'));
269
+
270
+ configCmd
271
+ .command('automation')
272
+ .description('Configure git automation settings interactively')
273
+ .addHelpText('after', `
274
+ ${chalk.cyan('Automation Settings:')}
275
+ • Enable/disable git hooks
276
+ • Choose trigger (pre-commit or pre-push)
277
+ • Configure auto-analysis with Gemini
278
+ • Configure auto-fixing with Jules
279
+ • Set commit blocking behavior
280
+ `)
281
+ .action(() => config('automation'));
282
+
283
+ // Automation and git hooks
284
+ const autoCmd = program
285
+ .command('automation')
286
+ .alias('auto')
287
+ .description('Manage git automation and hooks for continuous compatibility checking')
288
+ .addHelpText('after', `
289
+ ${chalk.cyan('Automation Features:')}
290
+ • Automatic compatibility checking on git operations
291
+ • AI-powered analysis and fixing integration
292
+ • Commit blocking when violations are found
293
+ • Configurable triggers (pre-commit or pre-push)
294
+
295
+ ${chalk.cyan('Examples:')}
296
+ ${chalk.dim('$')} base automation enable ${chalk.gray('# Enable with interactive setup')}
297
+ ${chalk.dim('$')} base automation enable --trigger pre-push ${chalk.gray('# Enable with pre-push trigger')}
298
+ ${chalk.dim('$')} base automation status ${chalk.gray('# Show current automation status')}
299
+ ${chalk.dim('$')} base automation disable ${chalk.gray('# Disable automation and remove hooks')}
300
+ `);
301
+
302
+ autoCmd
303
+ .command('enable')
304
+ .description('Enable git automation with hook installation')
305
+ .option('--trigger <trigger>', 'When to run checks (pre-commit or pre-push)', 'pre-commit')
306
+ .option('--auto-fix', 'Enable automatic fixing of violations')
307
+ .addHelpText('after', `
308
+ ${chalk.cyan('Trigger Options:')}
309
+ ${chalk.white('pre-commit')} Check before each commit (faster feedback)
310
+ ${chalk.white('pre-push')} Check before each push (less frequent)
311
+
312
+ ${chalk.cyan('What this does:')}
313
+ • Installs git hooks using Husky
314
+ • Configures BaseGuard to run automatically
315
+ • Sets up automation preferences
316
+ • Updates .baseguardrc.json configuration
317
+
318
+ ${chalk.cyan('Requirements:')}
319
+ • Git repository (run ${chalk.white('git init')} first)
320
+ • Node.js project with package.json
321
+ `)
322
+ .action((options) => automation('enable', options));
323
+
324
+ autoCmd
325
+ .command('disable')
326
+ .description('Disable git automation and remove hooks')
327
+ .addHelpText('after', `
328
+ ${chalk.cyan('What this does:')}
329
+ • Removes git hooks from .husky/ directory
330
+ • Disables automation in configuration
331
+ • Preserves other BaseGuard settings
332
+
333
+ ${chalk.cyan('Note:')}
334
+ You can re-enable automation anytime with ${chalk.white('base automation enable')}
335
+ `)
336
+ .action(() => automation('disable'));
337
+
338
+ autoCmd
339
+ .command('run')
340
+ .description('Run automation manually (used internally by git hooks)')
341
+ .option('--trigger <trigger>', 'Trigger context (pre-commit or pre-push)')
342
+ .addHelpText('after', `
343
+ ${chalk.cyan('Usage:')}
344
+ This command is typically called by git hooks automatically.
345
+ You can run it manually for testing automation behavior.
346
+
347
+ ${chalk.cyan('Examples:')}
348
+ ${chalk.dim('$')} base automation run --trigger pre-commit
349
+ ${chalk.dim('$')} base automation run --trigger pre-push
350
+ `)
351
+ .action((options) => automation('run', options));
352
+
353
+ autoCmd
354
+ .command('status')
355
+ .description('Show detailed automation status and configuration')
356
+ .addHelpText('after', `
357
+ ${chalk.cyan('Status Information:')}
358
+ • Automation enabled/disabled state
359
+ • Git hook installation status
360
+ • Trigger configuration (pre-commit/pre-push)
361
+ • Auto-analysis and auto-fix settings
362
+ • API key configuration status
363
+ • Recommendations for setup improvements
364
+ `)
365
+ .action(() => automation('status'));
366
+
367
+ autoCmd
368
+ .command('configure')
369
+ .description('Interactive configuration of all automation settings')
370
+ .addHelpText('after', `
371
+ ${chalk.cyan('Configuration Options:')}
372
+ • Enable/disable automation
373
+ • Choose trigger timing
374
+ • Configure AI analysis settings
375
+ • Configure AI fixing settings
376
+ • Set commit blocking behavior
377
+
378
+ ${chalk.cyan('Interactive Setup:')}
379
+ Guides you through all automation options with explanations
380
+ and recommendations based on your current configuration.
381
+ `)
382
+ .action(() => automation('configure'));
383
+
384
+ // Browser target management commands (shortcuts)
385
+ program
386
+ .command('add <target>')
387
+ .description('Add browser target (shortcut for config targets --add)')
388
+ .addHelpText('after', `
389
+ ${chalk.cyan('Target Format:')}
390
+ "browser version" - e.g., "chrome 100", "safari 15", "firefox baseline"
391
+
392
+ ${chalk.cyan('Examples:')}
393
+ ${chalk.dim('$')} base add "chrome 100" ${chalk.gray('# Add Chrome 100+ support')}
394
+ ${chalk.dim('$')} base add "safari baseline" ${chalk.gray('# Add Safari with Baseline support')}
395
+ ${chalk.dim('$')} base add "firefox 90" ${chalk.gray('# Add Firefox 90+ support')}
396
+ `)
397
+ .action((target) => config('targets', { add: target }));
398
+
399
+ program
400
+ .command('remove <target>')
401
+ .description('Remove browser target (shortcut for config targets --remove)')
402
+ .addHelpText('after', `
403
+ ${chalk.cyan('Examples:')}
404
+ ${chalk.dim('$')} base remove chrome ${chalk.gray('# Remove all Chrome targets')}
405
+ ${chalk.dim('$')} base remove safari ${chalk.gray('# Remove all Safari targets')}
406
+ ${chalk.dim('$')} base remove firefox ${chalk.gray('# Remove all Firefox targets')}
407
+ `)
408
+ .action((target) => config('targets', { remove: target }));
409
+
410
+ program
411
+ .command('list')
412
+ .description('List configuration summary (shortcut for config list)')
413
+ .option('--format <format>', 'Output format (table or json)', 'table')
414
+ .addHelpText('after', `
415
+ ${chalk.cyan('Quick Status:')}
416
+ Shows browser targets, API keys, automation status, and security info.
417
+
418
+ ${chalk.cyan('Examples:')}
419
+ ${chalk.dim('$')} base list ${chalk.gray('# Show configuration summary')}
420
+ ${chalk.dim('$')} base list --format json ${chalk.gray('# Export as JSON')}
421
+ `)
422
+ .action((options) => config('list', options));
423
+
424
+ // Add version command with detailed info
425
+ program
426
+ .command('version')
427
+ .description('Show version information and system details')
428
+ .option('--check-updates', 'Check for available updates')
429
+ .addHelpText('after', `
430
+ ${chalk.cyan('Version Information:')}
431
+ Shows BaseGuard version, Node.js version, and system information.
432
+
433
+ ${chalk.cyan('Examples:')}
434
+ ${chalk.dim('$')} base version ${chalk.gray('# Show version info')}
435
+ ${chalk.dim('$')} base version --check-updates ${chalk.gray('# Check for updates')}
436
+ `)
437
+ .action((options) => showVersionInfo(options));
438
+
439
+ // Add help command
440
+ program
441
+ .command('help [command]')
442
+ .description('Display help information for BaseGuard or specific commands')
443
+ .addHelpText('after', `
444
+ ${chalk.cyan('Examples:')}
445
+ ${chalk.dim('$')} base help ${chalk.gray('# Show general help')}
446
+ ${chalk.dim('$')} base help init ${chalk.gray('# Show help for init command')}
447
+ ${chalk.dim('$')} base help config ${chalk.gray('# Show help for config commands')}
448
+ `)
449
+ .action((command) => {
450
+ if (command) {
451
+ program.commands.find(cmd => cmd.name() === command)?.help();
452
+ } else {
453
+ showGlobalHelp();
454
+ }
455
+ });
456
+
457
+ // Global error handling with helpful messages
458
+ program.exitOverride((err) => {
459
+ if (err.code === 'commander.help') {
460
+ process.exit(0);
461
+ }
462
+ if (err.code === 'commander.version') {
463
+ process.exit(0);
464
+ }
465
+ if (err.code === 'commander.unknownCommand') {
466
+ console.error(chalk.red('āŒ Unknown command:'), chalk.white(err.message.split("'")[1]));
467
+ console.log(chalk.yellow('\nšŸ’” Suggestions:'));
468
+ console.log(` • Run ${chalk.white('base help')} to see all available commands`);
469
+ console.log(` • Run ${chalk.white('base init')} if you haven't set up BaseGuard yet`);
470
+ console.log(` • Check for typos in the command name`);
471
+ process.exit(1);
472
+ }
473
+ if (err.code === 'commander.missingArgument') {
474
+ console.error(chalk.red('āŒ Missing argument:'), err.message);
475
+ console.log(chalk.yellow('\nšŸ’” Help:'));
476
+ console.log(` Run ${chalk.white(`base help ${process.argv[2] || ''}`)} for usage information`);
477
+ process.exit(1);
478
+ }
479
+ console.error(chalk.red('āŒ Error:'), err.message);
480
+ console.log(chalk.yellow('\nšŸ’” Need help?'));
481
+ console.log(` • Run ${chalk.white('base help')} for available commands`);
482
+ console.log(` • Check ${chalk.blue('https://github.com/baseguard/baseguard#readme')} for documentation`);
483
+ console.log(` • Report issues at ${chalk.blue('https://github.com/baseguard/baseguard/issues')}`);
484
+ process.exit(1);
485
+ });
486
+
487
+ // Show help if no command provided
488
+ if (process.argv.length <= 2) {
489
+ showTerminalHeader();
490
+ showGlobalHelp();
491
+ process.exit(0);
492
+ }
493
+
494
+ program.parse();
@@ -0,0 +1,67 @@
1
+ import type { Fix } from '../types/index.js';
2
+ /**
3
+ * Fix manager for previewing and applying code fixes
4
+ */
5
+ export declare class FixManager {
6
+ private appliedFixes;
7
+ /**
8
+ * Generate unified diff preview of proposed changes
9
+ */
10
+ generatePreview(fix: Fix): Promise<string>;
11
+ /**
12
+ * Show interactive fix approval with clear change descriptions
13
+ */
14
+ showFixPreview(fix: Fix): Promise<boolean>;
15
+ /**
16
+ * Apply fixes to original files while preserving formatting and structure
17
+ */
18
+ applyFix(fix: Fix): Promise<void>;
19
+ /**
20
+ * Apply multiple fixes with batch processing
21
+ */
22
+ applyFixes(fixes: Fix[]): Promise<{
23
+ applied: Fix[];
24
+ skipped: Fix[];
25
+ failed: {
26
+ fix: Fix;
27
+ error: string;
28
+ }[];
29
+ }>;
30
+ /**
31
+ * Rollback applied fixes
32
+ */
33
+ rollbackFix(filePath: string): Promise<void>;
34
+ /**
35
+ * Rollback all applied fixes
36
+ */
37
+ rollbackAllFixes(): Promise<void>;
38
+ /**
39
+ * Get list of applied fixes
40
+ */
41
+ getAppliedFixes(): string[];
42
+ /**
43
+ * Create backup of original file
44
+ */
45
+ private createBackup;
46
+ /**
47
+ * Get backup file path
48
+ */
49
+ private getBackupPath;
50
+ /**
51
+ * Apply patch to file content
52
+ */
53
+ private applyPatchToContent;
54
+ /**
55
+ * Create unified diff between original and modified content
56
+ */
57
+ private createUnifiedDiff;
58
+ /**
59
+ * Colorize unified diff for better readability
60
+ */
61
+ private colorizeUnifiedDiff;
62
+ /**
63
+ * Show detailed diff with more context
64
+ */
65
+ private showDetailedDiff;
66
+ }
67
+ //# sourceMappingURL=fix-manager.d.ts.map