gnosys 5.8.4 → 5.8.5

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
@@ -187,12 +187,17 @@ Commands by group (alphabetical within group):
187
187
  Run 'gnosys <command> --help' for command-specific help.
188
188
  `)
189
189
  .hook("preAction", async () => {
190
- // Check if central DB was upgraded to a newer version on another machine
190
+ // v5.8.5: warn only when the DB stamp is NEWER than the running binary
191
+ // (i.e. another machine on the shared brain already upgraded). The old
192
+ // check fired whenever the versions differed — including the common
193
+ // "you just installed a newer gnosys but haven't run sync-projects yet"
194
+ // case, which produced a misleading "Run: npm install -g gnosys"
195
+ // banner on every command.
191
196
  try {
192
197
  const centralDb = GnosysDB.openCentral();
193
198
  if (centralDb.isAvailable()) {
194
199
  const dbVersion = centralDb.getMeta("app_version");
195
- if (dbVersion && dbVersion !== pkg.version) {
200
+ if (dbVersion && compareSemver(dbVersion, pkg.version) > 0) {
196
201
  const upgradedBy = centralDb.getMeta("upgraded_by") || "another machine";
197
202
  console.error(`\n⚠ Gnosys DB was upgraded to v${dbVersion} by ${upgradedBy}.` +
198
203
  `\n You are running v${pkg.version}. Run: npm install -g gnosys && gnosys upgrade\n`);
@@ -204,6 +209,23 @@ Run 'gnosys <command> --help' for command-specific help.
204
209
  // non-critical — don't block the command
205
210
  }
206
211
  });
212
+ /**
213
+ * Compare two semver-like strings. Returns -1, 0, 1. Tolerant of suffixes —
214
+ * compares the dotted-numeric prefix only.
215
+ */
216
+ function compareSemver(a, b) {
217
+ const parse = (v) => v.replace(/^v/, "").split(/[-+]/)[0].split(".").map((p) => parseInt(p, 10) || 0);
218
+ const av = parse(a);
219
+ const bv = parse(b);
220
+ const len = Math.max(av.length, bv.length);
221
+ for (let i = 0; i < len; i++) {
222
+ const ap = av[i] ?? 0;
223
+ const bp = bv[i] ?? 0;
224
+ if (ap !== bp)
225
+ return ap > bp ? 1 : -1;
226
+ }
227
+ return 0;
228
+ }
207
229
  // ─── gnosys read <path> ──────────────────────────────────────────────────
208
230
  program
209
231
  .command("read <memoryPath>")
@@ -3460,6 +3482,14 @@ program
3460
3482
  catch {
3461
3483
  // Best-effort lookup only.
3462
3484
  }
3485
+ // v5.8.5: surface the version transition so it's obvious the upgrade
3486
+ // worked, even though this process is still on the old binary in-memory.
3487
+ if (newVersion !== "(see npm output)" && newVersion !== currentVersion) {
3488
+ console.log(`\n✓ Installed gnosys v${newVersion} (was v${currentVersion})`);
3489
+ }
3490
+ else if (newVersion === currentVersion) {
3491
+ console.log(`\n✓ Already on latest: v${currentVersion}`);
3492
+ }
3463
3493
  // Write the marker so any running MCP servers exit and respawn.
3464
3494
  const { writeUpgradeMarker } = await import("./lib/upgrade.js");
3465
3495
  try {
@@ -3488,7 +3518,20 @@ program
3488
3518
  return;
3489
3519
  }
3490
3520
  console.log(``);
3491
- await syncProjectsAction({});
3521
+ // v5.8.5: shell out to the freshly-installed binary instead of running
3522
+ // syncProjectsAction in-process. The in-process call reuses pkg.version
3523
+ // captured at startup (the OLD version), so the banner said "Gnosys
3524
+ // v5.8.3 — upgrading registered projects" right after installing 5.8.4.
3525
+ // execSync spawns a new process that resolves `gnosys` on PATH to the
3526
+ // upgraded global binary, so the right version banner shows.
3527
+ try {
3528
+ execSync("gnosys setup sync-projects", { stdio: "inherit" });
3529
+ }
3530
+ catch (err) {
3531
+ console.error(`\nSync-projects failed: ${err instanceof Error ? err.message : err}`);
3532
+ console.error(`Run 'gnosys setup sync-projects' manually.`);
3533
+ process.exit(1);
3534
+ }
3492
3535
  });
3493
3536
  // ─── gnosys doctor ──────────────────────────────────────────────────────
3494
3537
  program
@@ -6215,28 +6258,32 @@ webCmd
6215
6258
  }
6216
6259
  });
6217
6260
  // ─── Post-install upgrade nudge ─────────────────────────────────────────
6218
- // Detects when the CLI version is newer than the last upgrade and shows
6219
- // a one-time message. Clears itself after `gnosys upgrade` stamps the DB.
6261
+ // v5.8.5: only nudges when the running binary is NEWER than the DB stamp
6262
+ // (i.e. you just installed a fresh version locally and haven't run
6263
+ // sync-projects to refresh the stamp yet). The previous version fired on
6264
+ // any mismatch — including "another machine bumped the stamp ahead of
6265
+ // you" which is a separate concern handled by the preAction warning.
6266
+ // Also avoids re-nudging once per command for the same version-pair by
6267
+ // honoring a per-session env-var sentinel.
6220
6268
  try {
6221
6269
  const centralDb = GnosysDB.openCentral();
6222
6270
  if (centralDb.isAvailable()) {
6223
6271
  const lastVersion = centralDb.getMeta("app_version");
6224
6272
  const currentVersion = pkg.version;
6225
- // Show nudge if: version changed AND this isn't the upgrade command itself
6226
6273
  const isUpgradeCmd = process.argv.slice(2).some(a => a === "upgrade");
6227
- if (lastVersion && lastVersion !== currentVersion && !isUpgradeCmd) {
6274
+ const isSetupSyncCmd = process.argv.slice(2).join(" ").includes("setup sync-projects");
6275
+ const newer = lastVersion && compareSemver(currentVersion, lastVersion) > 0;
6276
+ if (newer && !isUpgradeCmd && !isSetupSyncCmd) {
6228
6277
  console.log("");
6229
6278
  console.log(` Gnosys updated: v${lastVersion} → v${currentVersion}`);
6230
6279
  console.log("");
6231
- console.log(" Run now:");
6232
- console.log(" gnosys upgrade sync all projects + regenerate dashboard");
6280
+ console.log(" Run now to refresh the central DB stamp and registered projects:");
6281
+ console.log(" gnosys setup sync-projects");
6233
6282
  console.log("");
6234
6283
  console.log(" Then restart MCP servers:");
6235
- console.log(" Cursor: Cmd+Shift+P > MCP: Restart All Servers");
6284
+ console.log(" Cursor: Cmd+Shift+P > MCP: Restart All Servers");
6236
6285
  console.log(" Claude Code: /mcp > restart gnosys (or start new session)");
6237
- console.log(" Codex: start new session");
6238
- console.log("");
6239
- console.log(" gnosys status --web open the portfolio dashboard");
6286
+ console.log(" Codex: start new session");
6240
6287
  console.log("");
6241
6288
  }
6242
6289
  centralDb.close();