buddy-workbench 0.1.87 → 0.1.88

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "buddy-workbench",
3
- "version": "0.1.87",
3
+ "version": "0.1.88",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "bin": {
@@ -139,13 +139,17 @@ async function readNpmPackageMetadata() {
139
139
 
140
140
  async function checkForUpdates() {
141
141
  const metadata = await readNpmPackageMetadata();
142
- const latestVersion = String(metadata.version).replace(/^v/i, '');
142
+ const releases = buildReleaseList(metadata);
143
+ // A release is only visible after the 48-hour safety window. Keep the
144
+ // summary and the release list on the same source of truth so an update
145
+ // can never target a newer, still-hidden npm release.
146
+ const latestVersion = releases[0]?.version || CURRENT_VERSION;
143
147
  return {
144
148
  currentVersion: CURRENT_VERSION,
145
149
  latestVersion,
146
150
  updateAvailable: compareVersions(latestVersion, CURRENT_VERSION) > 0,
147
151
  checkedAt: new Date().toISOString(),
148
- releases: buildReleaseList(metadata),
152
+ releases,
149
153
  sourceUnavailable: false
150
154
  };
151
155
  }
@@ -215,7 +219,18 @@ router.post('/self-update', async (req, res) => {
215
219
 
216
220
  selfUpdateRunning = true;
217
221
  try {
218
- const version = normalizeUpdateVersion(req.body?.version);
222
+ let version = normalizeUpdateVersion(req.body?.version);
223
+ if (version === 'latest') {
224
+ const status = cachedResult && !cachedResult.sourceUnavailable && Date.now() - cachedAt < CACHE_TTL_MS
225
+ ? cachedResult
226
+ : await checkForUpdates();
227
+ version = status.latestVersion;
228
+ }
229
+
230
+ if (compareVersions(version, CURRENT_VERSION) <= 0) {
231
+ return res.json({ success: true, message: `DevBuddy is already up to date (${CURRENT_VERSION}).` });
232
+ }
233
+
219
234
  if (process.platform === 'win32') {
220
235
  scheduleWindowsSelfUpdate(`${PACKAGE_NAME}@${version}`);
221
236
  cachedResult = null;
@@ -6,6 +6,7 @@ import { promisify } from 'node:util';
6
6
  import { fileURLToPath } from 'node:url';
7
7
  import encodeMozjpeg, { init as initMozjpeg } from '@jsquash/jpeg/encode.js';
8
8
  import { paths } from '../config.js';
9
+ import { addErrorRecord } from '../repositories/errors.js';
9
10
  import { readSettings } from '../repositories/settings.js';
10
11
  import { readWindowsClipboard } from './windows.js';
11
12
 
@@ -15,6 +16,22 @@ let lastValue = '';
15
16
  let lastImageHash = '';
16
17
  let suppressImageCaptureUntil = 0;
17
18
  let mozjpegWasmModule = null;
19
+ const clipboardErrorLogTimes = new Map();
20
+
21
+ function logClipboardError(stage, error) {
22
+ // Clipboard polling runs continuously. Avoid filling Error Log with the
23
+ // same native-tool failure every two seconds while retaining diagnostics.
24
+ const now = Date.now();
25
+ const lastLoggedAt = clipboardErrorLogTimes.get(stage) || 0;
26
+ if (now - lastLoggedAt < 60 * 1000) return;
27
+ clipboardErrorLogTimes.set(stage, now);
28
+ const details = String(error?.stderr || error?.stdout || error?.stack || error?.message || error || '').trim();
29
+ addErrorRecord({
30
+ source: 'Clipboard Monitor',
31
+ message: `Failed during ${stage}.`,
32
+ details: details || 'The native clipboard operation returned an unknown error.'
33
+ });
34
+ }
18
35
 
19
36
  async function compressMozjpeg(rgbaBuf, width, height, quality = 75) {
20
37
  if (!mozjpegWasmModule) {
@@ -72,7 +89,8 @@ async function getMacClipboardImageData() {
72
89
  const base64 = str.slice(secondColon + 1);
73
90
  if (!width || !height || !base64) return null;
74
91
  return { width, height, rgbaBuf: Buffer.from(base64, 'base64') };
75
- } catch {
92
+ } catch (error) {
93
+ logClipboardError('macOS image clipboard read (osascript)', error);
76
94
  return null;
77
95
  }
78
96
  }
@@ -95,7 +113,8 @@ if let data = pb.data(forType: .png) {
95
113
  try {
96
114
  const { stdout } = await execFileAsync('swift', ['-e', swiftCode], { encoding: 'buffer', timeout: 3000 });
97
115
  if (stdout && stdout.length > 0) return stdout;
98
- } catch {
116
+ } catch (error) {
117
+ logClipboardError('macOS image clipboard read (Swift)', error);
99
118
  try {
100
119
  const jsaScript = `
101
120
  ObjC.import("AppKit");
@@ -118,7 +137,9 @@ if let data = pb.data(forType: .png) {
118
137
  const { stdout } = await execFileAsync('osascript', ['-l', 'JavaScript', '-e', jsaScript], { timeout: 3000 });
119
138
  const str = stdout.trim();
120
139
  if (str) return Buffer.from(str, 'base64');
121
- } catch {}
140
+ } catch (fallbackError) {
141
+ logClipboardError('macOS image clipboard fallback read (osascript)', fallbackError);
142
+ }
122
143
  }
123
144
  return null;
124
145
  }
@@ -330,9 +351,16 @@ export async function captureClipboard() {
330
351
  try {
331
352
  const mozjpegBuf = await compressMozjpeg(imageData.rgbaBuf, imageData.width, imageData.height, 75);
332
353
  saveClipboardImage(mozjpegBuf, 'jpg', hash);
333
- } catch {
354
+ } catch (error) {
355
+ logClipboardError('image compression or save (WASM/JPEG)', error);
334
356
  const rawBuf = await getMacClipboardImageBuffer();
335
- if (rawBuf) saveClipboardImage(rawBuf, 'png', hash);
357
+ if (rawBuf) {
358
+ try {
359
+ saveClipboardImage(rawBuf, 'png', hash);
360
+ } catch (fallbackError) {
361
+ logClipboardError('raw image save after compression fallback', fallbackError);
362
+ }
363
+ }
336
364
  }
337
365
  }
338
366
  }
@@ -357,7 +385,11 @@ export async function captureClipboard() {
357
385
 
358
386
  lastImageHash = hash;
359
387
  if (!isDuplicate) {
360
- saveClipboardImage(imageBuffer, 'png', hash);
388
+ try {
389
+ saveClipboardImage(imageBuffer, 'png', hash);
390
+ } catch (error) {
391
+ logClipboardError('image save', error);
392
+ }
361
393
  }
362
394
  }
363
395
  }