sticky-note-cli 3.1.41 → 3.1.42

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": "sticky-note-cli",
3
- "version": "3.1.41",
3
+ "version": "3.1.42",
4
4
  "description": "Human-to-human handoff for AI coding assistants. Git-backed shared memory for Claude Code and Copilot CLI.",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -237,22 +237,28 @@ function pushDataBranch(remote, branchName, maxRetries, localMemPath, loadJsonFn
237
237
  ).trim();
238
238
 
239
239
  // Build merged file map: start with remote files as base, then
240
- // overlay local files so this user's audit/presence are preserved
240
+ // overlay local files so this user's audit/presence are preserved.
241
+ // Capture remote sticky-note.json BEFORE the local overlay so we
242
+ // have the actual remote content to merge (not the local overwrite).
241
243
  const fileMap = {};
242
244
  const localRef = "refs/heads/" + branchName;
245
+ let remoteStickyContent = null;
243
246
  for (const f of listFilesInBranch(fetchResult.remoteRef)) {
244
247
  const content = readFileFromBranch(fetchResult.remoteRef, f);
245
- if (content !== null) fileMap[f] = content;
248
+ if (content !== null) {
249
+ fileMap[f] = content;
250
+ if (f === "sticky-note.json") remoteStickyContent = content;
251
+ }
246
252
  }
247
253
  for (const f of listFilesInBranch(localRef)) {
248
254
  const content = readFileFromBranch(localRef, f);
249
255
  if (content !== null) fileMap[f] = content;
250
256
  }
251
257
 
252
- // Merge sticky-note.json from both sides
253
- if (localMemPath && fileMap["sticky-note.json"]) {
258
+ // Merge sticky-note.json from both sides using captured remote content
259
+ if (localMemPath && remoteStickyContent) {
254
260
  mergeAndSaveFromRemote(
255
- localMemPath, fileMap["sticky-note.json"], loadJsonFn, saveJsonFn
261
+ localMemPath, remoteStickyContent, loadJsonFn, saveJsonFn
256
262
  );
257
263
  fileMap["sticky-note.json"] = fs.readFileSync(localMemPath, "utf-8");
258
264
  }
@@ -263,9 +269,12 @@ function pushDataBranch(remote, branchName, maxRetries, localMemPath, loadJsonFn
263
269
  }
264
270
  } catch (_) {}
265
271
 
266
- // Brief exponential backoff (busy-wait — synchronous context)
267
- const end = Date.now() + Math.pow(2, attempt) * 300;
268
- while (Date.now() < end) {}
272
+ // Brief exponential backoff — use Atomics.wait to block without CPU spin
273
+ try {
274
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, Math.pow(2, attempt) * 300);
275
+ } catch (_) {
276
+ // Atomics.wait unavailable (e.g. SharedArrayBuffer disabled) — skip delay
277
+ }
269
278
  }
270
279
  }
271
280
  return { ok: false, error: "max retries exceeded" };
@@ -313,9 +322,16 @@ function mergeAndSaveFromRemote(localMemPath, remoteContent, loadJsonFn, saveJso
313
322
  return; // corrupt remote — skip
314
323
  }
315
324
 
316
- const localMemory = loadJsonFn
317
- ? loadJsonFn(localMemPath, { ...EMPTY_MEMORY })
318
- : { ...EMPTY_MEMORY };
325
+ let localMemory;
326
+ if (loadJsonFn) {
327
+ localMemory = loadJsonFn(localMemPath, { ...EMPTY_MEMORY });
328
+ } else {
329
+ try {
330
+ localMemory = JSON.parse(fs.readFileSync(localMemPath, "utf-8"));
331
+ } catch (_) {
332
+ localMemory = { ...EMPTY_MEMORY };
333
+ }
334
+ }
319
335
 
320
336
  const localThreads = Array.isArray(localMemory.threads) ? localMemory.threads.filter(Boolean) : [];
321
337
  const remoteThreads = Array.isArray(remoteMemory.threads) ? remoteMemory.threads.filter(Boolean) : [];
@@ -644,7 +644,6 @@ function getUser() {
644
644
  // Prefer git config user.name — consistent across machines regardless of OS login name.
645
645
  // Fall back to OS env vars, then "unknown".
646
646
  try {
647
- const { execFileSync } = require("child_process");
648
647
  const name = execFileSync("git", ["config", "user.name"], {
649
648
  encoding: "utf-8", timeout: 3000, stdio: ["pipe", "pipe", "pipe"],
650
649
  }).trim();
@@ -1281,6 +1280,7 @@ function getCloudConfig() {
1281
1280
  return {
1282
1281
  url: process.env.STICKY_URL || envFile.STICKY_URL || "",
1283
1282
  apiKey: process.env.STICKY_API_KEY || envFile.STICKY_API_KEY || "",
1283
+ pushToken: process.env.STICKY_PUSH_TOKEN || envFile.STICKY_PUSH_TOKEN || "",
1284
1284
  };
1285
1285
  }
1286
1286