@aliwey/bmo 2.1.1 → 2.1.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.
package/bin/bmo.js CHANGED
@@ -163,20 +163,34 @@ Data lives in: ${BMO_HOME_DISPLAY}
163
163
  // Ignore failures
164
164
  }
165
165
 
166
- console.log(`šŸ—‘ļø Uninstalling old version of @aliwey/bmo...`);
167
- try {
168
- execSync('npm uninstall -g @aliwey/bmo', { stdio: 'inherit' });
169
- } catch (e) {
170
- // Ignore uninstall failures if it wasn't already installed
171
- }
172
- console.log(`šŸ”„ Installing @aliwey/bmo${ver}...`);
173
- try {
174
- execSync(`npm install -g @aliwey/bmo${ver}`, { stdio: 'inherit' });
175
- } catch {
176
- console.error('āŒ Update failed. Try manually: npm install -g @aliwey/bmo');
177
- process.exit(1);
166
+ if (os.platform() === 'win32') {
167
+ console.log('Launching updater in a new window to release folder/file locks...');
168
+
169
+ const cmdStr = `timeout /t 2 /nobreak >nul && echo [BMO Updater] Upgrading to @aliwey/bmo${ver}... && npm install -g @aliwey/bmo${ver} && echo [OK] BMO updated successfully! Press any key to close. && pause`;
170
+
171
+ spawn('cmd.exe', ['/c', 'start', 'cmd.exe', '/c', cmdStr], {
172
+ detached: true,
173
+ stdio: 'ignore'
174
+ });
175
+
176
+ console.log('Updater launched. This window will now close to release file locks.');
177
+ process.exit(0);
178
+ } else {
179
+ console.log(`Uninstalling old version of @aliwey/bmo...`);
180
+ try {
181
+ execSync('npm uninstall -g @aliwey/bmo', { stdio: 'inherit' });
182
+ } catch (e) {
183
+ // Ignore uninstall failures if it wasn't already installed
184
+ }
185
+ console.log(`Installing @aliwey/bmo${ver}...`);
186
+ try {
187
+ execSync(`npm install -g @aliwey/bmo${ver}`, { stdio: 'inherit' });
188
+ } catch {
189
+ console.error('Update failed. Try manually: npm install -g @aliwey/bmo');
190
+ process.exit(1);
191
+ }
192
+ process.exit(0);
178
193
  }
179
- process.exit(0);
180
194
  }
181
195
 
182
196
  // ── bmo init ──────────────────────────────────────────────────────────────
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aliwey/bmo",
3
- "version": "2.1.1",
3
+ "version": "2.1.2",
4
4
  "description": "BMO — AI coding assistant with Telegram, CLI & Web sync. One command, all frontends.",
5
5
  "keywords": ["ai", "coding-assistant", "telegram-bot", "cli", "opencode", "bfp"],
6
6
  "homepage": "https://github.com/aliwey/bmo",
@@ -37,7 +37,7 @@ function getCloudflaredExe() {
37
37
  : path.join(BMO_BIN, 'cloudflared');
38
38
  if (fs.existsSync(embedded)) return embedded;
39
39
  try { execSync('cloudflared --version', { stdio: 'ignore' }); return 'cloudflared'; } catch {}
40
- console.error('āŒ cloudflared not found. Run: bmo init');
40
+ console.error('[Error] cloudflared not found. Run: bmo init');
41
41
  process.exit(1);
42
42
  }
43
43
 
@@ -70,7 +70,7 @@ function waitForTunnelUrl(proc) {
70
70
  const tasks = loadTasks();
71
71
  const existing = tasks.webchat_tunnel_url;
72
72
  if (existing) {
73
- console.log(`\nšŸ’¬ Webchat already running!`);
73
+ console.log(`\n[Info] Webchat already running!`);
74
74
  console.log(` Local: http://127.0.0.1:${WEBCHAT_PORT}`);
75
75
  console.log(` Public: ${existing}\n`);
76
76
  process.exit(0);
@@ -78,11 +78,18 @@ function waitForTunnelUrl(proc) {
78
78
  }
79
79
 
80
80
  // Start webchat server
81
- console.log('ā³ Starting webchat server...');
81
+ console.log('Starting webchat server...');
82
82
  const webchatDir = path.join(PKG_DIR, 'webchat');
83
+
84
+ // Ensure logs directory exists
85
+ const logDir = path.join(BMO_HOME, 'logs');
86
+ fs.mkdirSync(logDir, { recursive: true });
87
+ const webchatLogPath = path.join(logDir, 'webchat.log');
88
+ const logStream = fs.openSync(webchatLogPath, 'a');
89
+
83
90
  const webchat = spawn('node', ['server.js'], {
84
91
  cwd: webchatDir,
85
- stdio: 'ignore',
92
+ stdio: ['ignore', logStream, logStream],
86
93
  detached: true,
87
94
  env: {
88
95
  ...process.env,
@@ -94,15 +101,32 @@ function waitForTunnelUrl(proc) {
94
101
  webchat.unref();
95
102
 
96
103
  // Wait for webchat to be ready
104
+ let started = false;
97
105
  for (let i = 0; i < 20; i++) {
98
106
  await sleep(500);
99
- if (await isPortOpen(WEBCHAT_PORT)) break;
100
- if (i === 19) { console.error('āŒ Webchat failed to start'); process.exit(1); }
107
+ if (await isPortOpen(WEBCHAT_PORT)) {
108
+ started = true;
109
+ break;
110
+ }
111
+ }
112
+
113
+ if (!started) {
114
+ console.error('[Error] Webchat failed to start');
115
+ try {
116
+ const logContent = fs.readFileSync(webchatLogPath, 'utf8').trim();
117
+ const lines = logContent.split('\n');
118
+ const lastLines = lines.slice(-15).join('\n');
119
+ console.error('\nLast log output:');
120
+ console.error(lastLines);
121
+ } catch (e) {
122
+ console.error('Could not read webchat log file.');
123
+ }
124
+ process.exit(1);
101
125
  }
102
- console.log('āœ“ Webchat server running on port', WEBCHAT_PORT);
126
+ console.log('[OK] Webchat server running on port', WEBCHAT_PORT);
103
127
 
104
128
  // Start cloudflared tunnel
105
- console.log('ā³ Starting cloudflared tunnel...');
129
+ console.log('Starting cloudflared tunnel...');
106
130
  const cfExe = getCloudflaredExe();
107
131
  const cf = spawn(cfExe, ['tunnel', '--url', `http://localhost:${WEBCHAT_PORT}`], {
108
132
  stdio: ['ignore', 'pipe', 'pipe'],
@@ -114,7 +138,7 @@ function waitForTunnelUrl(proc) {
114
138
  try {
115
139
  tunnelUrl = await waitForTunnelUrl(cf);
116
140
  } catch {
117
- console.error('āŒ Could not get tunnel URL from cloudflared');
141
+ console.error('[Error] Could not get tunnel URL from cloudflared');
118
142
  process.exit(1);
119
143
  }
120
144
 
@@ -127,7 +151,7 @@ function waitForTunnelUrl(proc) {
127
151
  saveTasks(tasks);
128
152
 
129
153
  console.log('\n╭────────────────────────────────────────────╮');
130
- console.log('│ šŸ’¬ BMO Webchat is live! │');
154
+ console.log('│ [OK] BMO Webchat is live! │');
131
155
  console.log(`│ Local: http://127.0.0.1:${WEBCHAT_PORT} │`);
132
156
  console.log(`│ Public: ${tunnelUrl.padEnd(34)} │`);
133
157
  console.log('╰────────────────────────────────────────────╯\n');