@codebakers/cli 3.9.1 → 3.9.2

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.
@@ -935,6 +935,78 @@ function log(message, options) {
935
935
  console.log(chalk_1.default.gray(` [verbose] ${message}`));
936
936
  }
937
937
  }
938
+ // Current CLI version - must match package.json
939
+ const CURRENT_VERSION = '3.9.2';
940
+ /**
941
+ * Check for updates and install them automatically
942
+ * This makes "codebakers go" the magic phrase that keeps everything updated
943
+ */
944
+ async function checkAndInstallUpdates(options = {}) {
945
+ // Skip if auto-update is disabled
946
+ if ((0, config_js_1.isCliAutoUpdateDisabled)()) {
947
+ log('Auto-update disabled, skipping...', options);
948
+ return;
949
+ }
950
+ try {
951
+ log('Checking for CLI updates...', options);
952
+ const updateInfo = await (0, api_js_1.checkForUpdates)();
953
+ if (!updateInfo || !updateInfo.updateAvailable) {
954
+ log('CLI is up to date', options);
955
+ return;
956
+ }
957
+ // Show blocked version warning
958
+ if (updateInfo.isBlocked) {
959
+ console.log(chalk_1.default.red(`
960
+ ⚠️ Your CLI version (${CURRENT_VERSION}) has critical issues.
961
+ Updating to ${updateInfo.latestVersion}...
962
+ `));
963
+ }
964
+ const targetVersion = updateInfo.latestVersion;
965
+ // Only auto-update if server says it's safe
966
+ if (!updateInfo.autoUpdateEnabled && !updateInfo.isBlocked) {
967
+ // Just show banner, don't auto-install
968
+ console.log(chalk_1.default.yellow(`
969
+ 📦 Update available: ${CURRENT_VERSION} → ${chalk_1.default.green(targetVersion)}
970
+ Run: npm i -g @codebakers/cli@latest
971
+ `));
972
+ return;
973
+ }
974
+ // Auto-install the update
975
+ console.log(chalk_1.default.blue(`\n 🔄 Updating CLI: ${CURRENT_VERSION} → ${chalk_1.default.green(targetVersion)}...\n`));
976
+ try {
977
+ (0, child_process_1.execSync)('npm install -g @codebakers/cli@latest', {
978
+ stdio: 'inherit',
979
+ timeout: 60000,
980
+ });
981
+ console.log(chalk_1.default.green(`\n ✓ CLI updated to v${targetVersion}!\n`));
982
+ console.log(chalk_1.default.gray(' Restart your terminal or run `codebakers go` again.\n'));
983
+ // Exit so user gets the new version
984
+ process.exit(0);
985
+ }
986
+ catch (installError) {
987
+ const errorMessage = installError instanceof Error ? installError.message : String(installError);
988
+ if (errorMessage.includes('EACCES') || errorMessage.includes('permission')) {
989
+ console.log(chalk_1.default.yellow(`
990
+ ⚠️ Update failed (permission denied)
991
+
992
+ Run manually: ${chalk_1.default.cyan('sudo npm i -g @codebakers/cli@latest')}
993
+ `));
994
+ }
995
+ else {
996
+ console.log(chalk_1.default.yellow(`
997
+ ⚠️ Update failed
998
+
999
+ Run manually: ${chalk_1.default.cyan('npm i -g @codebakers/cli@latest')}
1000
+ `));
1001
+ }
1002
+ // Continue anyway - don't block the user
1003
+ }
1004
+ }
1005
+ catch (error) {
1006
+ // Silently fail - don't block CLI for update check
1007
+ log(`Update check failed: ${error}`, options);
1008
+ }
1009
+ }
938
1010
  /**
939
1011
  * Zero-friction entry point - start using CodeBakers instantly
940
1012
  * Single command for both trial and paid users
@@ -947,6 +1019,10 @@ async function go(options = {}) {
947
1019
  log('Starting go command...', options);
948
1020
  log(`API URL: ${(0, config_js_1.getApiUrl)()}`, options);
949
1021
  log(`Working directory: ${process.cwd()}`, options);
1022
+ // =========================================================================
1023
+ // AUTO-UPDATE CHECK - The magic of "codebakers go"
1024
+ // =========================================================================
1025
+ await checkAndInstallUpdates(options);
950
1026
  const cwd = process.cwd();
951
1027
  // =========================================================================
952
1028
  // SMART CONTEXT CHECK - If already set up, show resume context
package/dist/index.js CHANGED
@@ -34,7 +34,7 @@ const api_js_1 = require("./lib/api.js");
34
34
  // ============================================
35
35
  // Automatic Update Notification
36
36
  // ============================================
37
- const CURRENT_VERSION = '3.9.1';
37
+ const CURRENT_VERSION = '3.9.2';
38
38
  async function checkForUpdatesInBackground() {
39
39
  // Check if we have a valid cached result first (fast path)
40
40
  const cached = (0, config_js_2.getCachedUpdateInfo)();
@@ -195,7 +195,7 @@ const program = new commander_1.Command();
195
195
  program
196
196
  .name('codebakers')
197
197
  .description('CodeBakers CLI - Production patterns for AI-assisted development')
198
- .version('3.9.1');
198
+ .version('3.9.2');
199
199
  // Zero-friction trial entry (no signup required)
200
200
  program
201
201
  .command('go')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codebakers/cli",
3
- "version": "3.9.1",
3
+ "version": "3.9.2",
4
4
  "description": "CodeBakers CLI - Production patterns for AI-assisted development",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -12,9 +12,10 @@ import {
12
12
  setApiKey,
13
13
  isTrialExpired,
14
14
  getTrialDaysRemaining,
15
+ isCliAutoUpdateDisabled,
15
16
  type TrialState,
16
17
  } from '../config.js';
17
- import { validateApiKey } from '../lib/api.js';
18
+ import { validateApiKey, checkForUpdates } from '../lib/api.js';
18
19
  import { getDeviceFingerprint } from '../lib/fingerprint.js';
19
20
  import { audit } from './audit.js';
20
21
  import { heal } from './heal.js';
@@ -1051,6 +1052,88 @@ function log(message: string, options?: GoOptions): void {
1051
1052
  }
1052
1053
  }
1053
1054
 
1055
+ // Current CLI version - must match package.json
1056
+ const CURRENT_VERSION = '3.9.2';
1057
+
1058
+ /**
1059
+ * Check for updates and install them automatically
1060
+ * This makes "codebakers go" the magic phrase that keeps everything updated
1061
+ */
1062
+ async function checkAndInstallUpdates(options: GoOptions = {}): Promise<void> {
1063
+ // Skip if auto-update is disabled
1064
+ if (isCliAutoUpdateDisabled()) {
1065
+ log('Auto-update disabled, skipping...', options);
1066
+ return;
1067
+ }
1068
+
1069
+ try {
1070
+ log('Checking for CLI updates...', options);
1071
+ const updateInfo = await checkForUpdates();
1072
+
1073
+ if (!updateInfo || !updateInfo.updateAvailable) {
1074
+ log('CLI is up to date', options);
1075
+ return;
1076
+ }
1077
+
1078
+ // Show blocked version warning
1079
+ if (updateInfo.isBlocked) {
1080
+ console.log(chalk.red(`
1081
+ ⚠️ Your CLI version (${CURRENT_VERSION}) has critical issues.
1082
+ Updating to ${updateInfo.latestVersion}...
1083
+ `));
1084
+ }
1085
+
1086
+ const targetVersion = updateInfo.latestVersion;
1087
+
1088
+ // Only auto-update if server says it's safe
1089
+ if (!updateInfo.autoUpdateEnabled && !updateInfo.isBlocked) {
1090
+ // Just show banner, don't auto-install
1091
+ console.log(chalk.yellow(`
1092
+ 📦 Update available: ${CURRENT_VERSION} → ${chalk.green(targetVersion)}
1093
+ Run: npm i -g @codebakers/cli@latest
1094
+ `));
1095
+ return;
1096
+ }
1097
+
1098
+ // Auto-install the update
1099
+ console.log(chalk.blue(`\n 🔄 Updating CLI: ${CURRENT_VERSION} → ${chalk.green(targetVersion)}...\n`));
1100
+
1101
+ try {
1102
+ execSync('npm install -g @codebakers/cli@latest', {
1103
+ stdio: 'inherit',
1104
+ timeout: 60000,
1105
+ });
1106
+
1107
+ console.log(chalk.green(`\n ✓ CLI updated to v${targetVersion}!\n`));
1108
+ console.log(chalk.gray(' Restart your terminal or run `codebakers go` again.\n'));
1109
+
1110
+ // Exit so user gets the new version
1111
+ process.exit(0);
1112
+
1113
+ } catch (installError) {
1114
+ const errorMessage = installError instanceof Error ? installError.message : String(installError);
1115
+
1116
+ if (errorMessage.includes('EACCES') || errorMessage.includes('permission')) {
1117
+ console.log(chalk.yellow(`
1118
+ ⚠️ Update failed (permission denied)
1119
+
1120
+ Run manually: ${chalk.cyan('sudo npm i -g @codebakers/cli@latest')}
1121
+ `));
1122
+ } else {
1123
+ console.log(chalk.yellow(`
1124
+ ⚠️ Update failed
1125
+
1126
+ Run manually: ${chalk.cyan('npm i -g @codebakers/cli@latest')}
1127
+ `));
1128
+ }
1129
+ // Continue anyway - don't block the user
1130
+ }
1131
+ } catch (error) {
1132
+ // Silently fail - don't block CLI for update check
1133
+ log(`Update check failed: ${error}`, options);
1134
+ }
1135
+ }
1136
+
1054
1137
  /**
1055
1138
  * Zero-friction entry point - start using CodeBakers instantly
1056
1139
  * Single command for both trial and paid users
@@ -1064,6 +1147,11 @@ export async function go(options: GoOptions = {}): Promise<void> {
1064
1147
  log(`API URL: ${getApiUrl()}`, options);
1065
1148
  log(`Working directory: ${process.cwd()}`, options);
1066
1149
 
1150
+ // =========================================================================
1151
+ // AUTO-UPDATE CHECK - The magic of "codebakers go"
1152
+ // =========================================================================
1153
+ await checkAndInstallUpdates(options);
1154
+
1067
1155
  const cwd = process.cwd();
1068
1156
 
1069
1157
  // =========================================================================
package/src/index.ts CHANGED
@@ -34,7 +34,7 @@ import { join } from 'path';
34
34
  // Automatic Update Notification
35
35
  // ============================================
36
36
 
37
- const CURRENT_VERSION = '3.9.1';
37
+ const CURRENT_VERSION = '3.9.2';
38
38
 
39
39
  async function checkForUpdatesInBackground(): Promise<void> {
40
40
  // Check if we have a valid cached result first (fast path)
@@ -216,7 +216,7 @@ const program = new Command();
216
216
  program
217
217
  .name('codebakers')
218
218
  .description('CodeBakers CLI - Production patterns for AI-assisted development')
219
- .version('3.9.1');
219
+ .version('3.9.2');
220
220
 
221
221
  // Zero-friction trial entry (no signup required)
222
222
  program