blun-king-cli 9.1.71 → 9.1.72

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.
@@ -400,8 +400,9 @@ function statePath(blunDir) {
400
400
  return path.join(blunDir, STATE_FILE);
401
401
  }
402
402
 
403
- function readSnoozeState(blunDir, now = Date.now()) {
403
+ function readSnoozeState(blunDir, targetVersion, now = Date.now()) {
404
404
  try {
405
+ if (!parseSemver(targetVersion)) return false;
405
406
  const filePath = statePath(blunDir);
406
407
  if (!fs.existsSync(filePath)) return false;
407
408
  securePrivateFile(filePath);
@@ -409,10 +410,13 @@ function readSnoozeState(blunDir, now = Date.now()) {
409
410
  if (!stat.isFile() || stat.isSymbolicLink() || stat.size > 1_024) return false;
410
411
  const record = exactDataRecord(JSON.parse(fs.readFileSync(filePath, 'utf8')), [
411
412
  'snoozedUntil',
413
+ 'targetVersion',
412
414
  'version',
413
415
  ]);
414
416
  if (!record
415
- || record.version !== 1
417
+ || record.version !== 2
418
+ || record.targetVersion !== targetVersion
419
+ || !parseSemver(record.targetVersion)
416
420
  || !Number.isSafeInteger(record.snoozedUntil)
417
421
  || record.snoozedUntil <= now
418
422
  || record.snoozedUntil > now + SNOOZE_MS) {
@@ -424,7 +428,8 @@ function readSnoozeState(blunDir, now = Date.now()) {
424
428
  }
425
429
  }
426
430
 
427
- function writeSnoozeState(blunDir, now = Date.now()) {
431
+ function writeSnoozeState(blunDir, targetVersion, now = Date.now()) {
432
+ if (!parseSemver(targetVersion)) throw new Error('INVALID_UPDATE_VERSION');
428
433
  ensurePrivateDirectory(blunDir);
429
434
  const filePath = statePath(blunDir);
430
435
  const temporaryPath = path.join(
@@ -433,7 +438,8 @@ function writeSnoozeState(blunDir, now = Date.now()) {
433
438
  );
434
439
  try {
435
440
  writePrivateFile(temporaryPath, `${JSON.stringify({
436
- version: 1,
441
+ version: 2,
442
+ targetVersion,
437
443
  snoozedUntil: now + SNOOZE_MS,
438
444
  })}\n`);
439
445
  const handle = fs.openSync(temporaryPath, 'r+');
@@ -1340,9 +1346,6 @@ async function runUpdateFlow(options, explicitUpdate) {
1340
1346
  pendingVersion = undefined;
1341
1347
  }
1342
1348
  const now = (options.now || Date.now)();
1343
- if (!explicitUpdate && pendingVersion === undefined && readSnoozeState(blunDir, now)) {
1344
- return { kind: 'continue', reason: 'snoozed' };
1345
- }
1346
1349
 
1347
1350
  const packageRoot = path.resolve(options.packageRoot || path.resolve(__dirname, '..'));
1348
1351
  let leaseResult;
@@ -1373,11 +1376,6 @@ async function runUpdateFlow(options, explicitUpdate) {
1373
1376
  let installerSession;
1374
1377
 
1375
1378
  try {
1376
- if (!explicitUpdate
1377
- && pendingVersion === undefined
1378
- && readSnoozeState(blunDir, (options.now || Date.now)())) {
1379
- return { kind: 'continue', reason: 'snoozed' };
1380
- }
1381
1379
  let sources;
1382
1380
  try {
1383
1381
  sources = await (options.loadReleaseSources || loadReleaseSources)();
@@ -1395,6 +1393,11 @@ async function runUpdateFlow(options, explicitUpdate) {
1395
1393
  ? explicitNoTarget(stdout, reason, currentVersion)
1396
1394
  : { kind: 'continue', reason };
1397
1395
  }
1396
+ if (!explicitUpdate
1397
+ && pendingVersion === undefined
1398
+ && readSnoozeState(blunDir, release.version, now)) {
1399
+ return { kind: 'continue', reason: 'snoozed' };
1400
+ }
1398
1401
  const queuedForRelease = pendingVersion === release.version;
1399
1402
  const initialInstallLease = await probeInstallLease(options, packageRoot);
1400
1403
  if (initialInstallLease === 'busy') {
@@ -1478,7 +1481,7 @@ async function runUpdateFlow(options, explicitUpdate) {
1478
1481
  return { kind: 'continue', reason: 'skipped_version' };
1479
1482
  }
1480
1483
  try {
1481
- writeSnoozeState(blunDir, (options.now || Date.now)());
1484
+ writeSnoozeState(blunDir, release.version, (options.now || Date.now)());
1482
1485
  } catch {
1483
1486
  // A failed preference write must not block the existing console.
1484
1487
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blun-king-cli",
3
- "version": "9.1.71",
3
+ "version": "9.1.72",
4
4
  "description": "BLUN CLI - your own AI agent with a Telegram channel. Get it done. With BLUN.",
5
5
  "license": "MIT",
6
6
  "bin": {