@songsid/agend 2.1.11-beta.2 → 2.1.11-beta.3

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/dist/cli.js CHANGED
@@ -15,7 +15,7 @@ import { spawn, execSync, execFileSync } from "node:child_process";
15
15
  import { getAgendHome, getTmuxSocketName } from "./paths.js";
16
16
  import { hasPausedMarker } from "./pause-marker.js";
17
17
  import { COMPLETION_SHELLS, completionScript } from "./completion.js";
18
- import { getUpdateSelector, lookupTargetVersion, reportUpdateRestart, shouldSkipUpdate, runningFleetPredatesInstall, processStartMs, } from "./update-check.js";
18
+ import { getUpdateSelector, isExactVersion, isUnrequestedDowngrade, lookupTargetVersion, reportUpdateRestart, shouldSkipUpdate, runningFleetPredatesInstall, processStartMs, } from "./update-check.js";
19
19
  import { clearUpdateMarker, markUpdateInProgress, setUpdateProgressStage } from "./update-marker.js";
20
20
  import { describeSignalSource, gateFleetControl, recordInstanceControl, withOrigin } from "./fleet-control-audit.js";
21
21
  import { acquireFleetLock, isFleetStartCommandLine, readProcessCommandLine, releaseProcessFleetLock, setProcessFleetLock } from "./fleet-lock.js";
@@ -72,7 +72,10 @@ const pkgVersion = (() => {
72
72
  program
73
73
  .name("agend")
74
74
  .description("AgEnD — AI Engineering Daemon")
75
- .version(pkgVersion);
75
+ .version(pkgVersion)
76
+ // The root's own options only before a subcommand: otherwise `agend update --version 2.1.9` is read as
77
+ // `agend --version`, prints this version and installs nothing.
78
+ .enablePositionalOptions();
76
79
  function signalFleetReload() {
77
80
  const pidPath = join(DATA_DIR, "fleet.pid");
78
81
  try {
@@ -1347,16 +1350,26 @@ program
1347
1350
  .command("update")
1348
1351
  .description("Update AgEnD to the selected release and restart the fleet service")
1349
1352
  .option("--version <ver>", "Specific version to install")
1350
- .option("--beta", "Install beta version")
1353
+ .option("--beta", "Install from the beta channel (the default when a beta is installed)")
1354
+ .option("--stable", "Install from the stable channel, even from a beta install (may go back a version)")
1351
1355
  .option("--force", "Force reinstall and restart even when already up to date")
1352
1356
  .option("-y, --yes", "Confirm when run from a fleet agent session (this affects every instance)")
1353
1357
  .action(async (opts) => {
1358
+ if (opts.beta && opts.stable) {
1359
+ console.error(" --beta and --stable choose different channels; pass one.");
1360
+ process.exit(1);
1361
+ }
1354
1362
  if (!gateFleetControl(DATA_DIR, "update", { yes: opts.yes }))
1355
1363
  process.exit(1);
1356
1364
  const { spawnSync } = await import("node:child_process");
1357
- const tag = getUpdateSelector(opts);
1358
- const pkg = `@songsid/agend@${tag}`;
1359
- const targetVersion = lookupTargetVersion(tag);
1365
+ // The channel follows the version being replaced — this CLI's own package — so a beta install stays on beta.
1366
+ const tag = getUpdateSelector(opts, pkgVersion);
1367
+ const looked = lookupTargetVersion(tag);
1368
+ // Only a strict SemVer answer counts as the version this update is about; anything else is "unknown".
1369
+ const targetVersion = looked !== null && isExactVersion(looked) ? looked.trim().replace(/^v/i, "") : null;
1370
+ // Install exactly the version checked below: a dist-tag is a moving alias, and could point somewhere older
1371
+ // by the time npm resolves it. Unknown target: the tag, as before.
1372
+ const pkg = `@songsid/agend@${targetVersion ?? tag}`;
1360
1373
  // The restart stage, shared by a real update and by the stale-fleet case.
1361
1374
  const restartFleetForUpdate = (command, args, version) => {
1362
1375
  console.log(" Restarting fleet...");
@@ -1411,6 +1424,14 @@ program
1411
1424
  setUpdateProgressStage(DATA_DIR, "complete", { version: pkgVersion });
1412
1425
  return;
1413
1426
  }
1427
+ if (isUnrequestedDowngrade(pkgVersion, targetVersion, opts)) {
1428
+ const message = `AgEnD v${pkgVersion} is newer than ${tag} (v${targetVersion}); not going back to it. To switch to the stable release anyway: agend update --stable`;
1429
+ console.error(`\n ✗ ${message}\n`);
1430
+ // A chat-started /update is waiting on this: say why it stops here.
1431
+ setUpdateProgressStage(DATA_DIR, "failed", { error: message });
1432
+ process.exitCode = 1;
1433
+ return;
1434
+ }
1414
1435
  if (targetVersion) {
1415
1436
  console.log(`\n Updating AgEnD v${pkgVersion} → v${targetVersion}...\n`);
1416
1437
  }