vibecodingmachine-cli 1.0.12 → 1.0.13

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 (2) hide show
  1. package/package.json +2 -3
  2. package/src/utils/auth.js +31 -2
package/package.json CHANGED
@@ -1,11 +1,10 @@
1
1
  {
2
2
  "name": "vibecodingmachine-cli",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
4
4
  "description": "Command-line interface for Vibe Coding Machine - Autonomous development",
5
5
  "main": "src/index.js",
6
6
  "bin": {
7
- "vibecodingmachine": "./bin/vibecodingmachine.js",
8
- "vcm": "./bin/vibecodingmachine.js"
7
+ "vibecodingmachine": "./bin/vibecodingmachine.js"
9
8
  },
10
9
  "scripts": {
11
10
  "postinstall": "node scripts/postinstall.js",
package/src/utils/auth.js CHANGED
@@ -3,12 +3,13 @@ const http = require('http');
3
3
  const crypto = require('crypto');
4
4
  const fs = require('fs');
5
5
  const path = require('path');
6
+ const net = require('net');
6
7
  const sharedAuth = require('vibecodingmachine-core/src/auth/shared-auth-storage');
7
8
 
8
9
  // AWS Cognito configuration
9
10
  const COGNITO_DOMAIN = process.env.COGNITO_DOMAIN || 'allnightai-auth-1763598779.auth.us-east-1.amazoncognito.com';
10
11
  const CLIENT_ID = process.env.COGNITO_APP_CLIENT_ID || '3tbe1i2g36uqule92iuk6snuo3'; // Public client (no secret)
11
- const PORT = 3000;
12
+ const PREFERRED_PORT = 3000; // Preferred port, will auto-detect if unavailable
12
13
 
13
14
  // Load shared access denied HTML
14
15
  function getAccessDeniedHTML() {
@@ -237,10 +238,38 @@ class CLIAuth {
237
238
  return this._loginHeadless();
238
239
  }
239
240
 
241
+ // Check if port 3000 is available (required for OAuth callback)
242
+ const PORT = PREFERRED_PORT;
243
+ const portAvailable = await new Promise((resolve) => {
244
+ const testServer = net.createServer();
245
+ testServer.once('error', (err) => {
246
+ if (err.code === 'EADDRINUSE') {
247
+ resolve(false);
248
+ } else {
249
+ resolve(true);
250
+ }
251
+ });
252
+ testServer.once('listening', () => {
253
+ testServer.close(() => resolve(true));
254
+ });
255
+ testServer.listen(PORT);
256
+ });
257
+
258
+ if (!portAvailable) {
259
+ console.log(chalk.red(`\nāŒ Port ${PORT} is already in use!\n`));
260
+ console.log(chalk.yellow('Port 3000 is required for authentication (OAuth callback).\n'));
261
+ console.log(chalk.white('To fix this, find and stop the process using port 3000:\n'));
262
+ console.log(chalk.gray(' 1. Find the process: ') + chalk.cyan(`lsof -i :${PORT}`));
263
+ console.log(chalk.gray(' 2. Stop it: ') + chalk.cyan('kill <PID>'));
264
+ console.log(chalk.gray('\nOr if you\'re running the web dev server:'));
265
+ console.log(chalk.gray(' ') + chalk.cyan('cd packages/web && npm stop\n'));
266
+ throw new Error(`Port ${PORT} is already in use. Please free up this port and try again.`);
267
+ }
268
+
240
269
  // VS Code Remote SSH - use optimized flow with instructions
241
270
  if (isVSCodeRemote && !options.headless) {
242
271
  console.log(chalk.cyan('\nšŸ” VS Code Remote SSH Detected!\n'));
243
- console.log(chalk.yellow('āš ļø IMPORTANT: VS Code will show "Port 3000 is now available"'));
272
+ console.log(chalk.yellow(`āš ļø IMPORTANT: VS Code will show "Port ${PORT} is now available"`));
244
273
  console.log(chalk.yellow(' → DO NOT click that notification!'));
245
274
  console.log(chalk.yellow(' → Instead, Ctrl+Click the authentication URL shown below\n'));
246
275
  }