openkrew 0.5.16 → 0.5.18

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.
@@ -73,9 +73,10 @@ function getGatewayName() {
73
73
  }
74
74
 
75
75
  /**
76
- * Checks if the binary is downloaded and matches the npm package version.
77
- * When npm install -g openkrew@X.Y.Z runs, PACKAGE_VERSION updates to X.Y.Z.
78
- * If the installed binary version doesn't match, we re-download from S3.
76
+ * Checks if the binary is downloaded and satisfies the npm package version.
77
+ * Uses >= rather than strict equality so the self-updater (which bumps the
78
+ * binary ahead of the npm wrapper) isn't un-done on the next CLI invocation.
79
+ * The wrapper's version is the minimum required; newer binaries still satisfy.
79
80
  */
80
81
  function isInstalled() {
81
82
  const binaryPath = join(BIN_DIR, getBinaryName());
@@ -83,12 +84,28 @@ function isInstalled() {
83
84
 
84
85
  try {
85
86
  const installedVersion = readFileSync(VERSION_FILE, "utf8").trim();
86
- return installedVersion === PACKAGE_VERSION;
87
+ return compareSemver(installedVersion, PACKAGE_VERSION) >= 0;
87
88
  } catch {
88
89
  return false;
89
90
  }
90
91
  }
91
92
 
93
+ /**
94
+ * Numeric semver compare. Returns <0 if a<b, 0 if equal, >0 if a>b. Tolerates
95
+ * missing segments (treats them as 0) and ignores prerelease suffixes —
96
+ * good enough for our 0.X.Y release cadence.
97
+ */
98
+ function compareSemver(a, b) {
99
+ const pa = String(a).split("-")[0].split(".").map((n) => parseInt(n, 10) || 0);
100
+ const pb = String(b).split("-")[0].split(".").map((n) => parseInt(n, 10) || 0);
101
+ const len = Math.max(pa.length, pb.length);
102
+ for (let i = 0; i < len; i++) {
103
+ const diff = (pa[i] ?? 0) - (pb[i] ?? 0);
104
+ if (diff !== 0) return diff;
105
+ }
106
+ return 0;
107
+ }
108
+
92
109
  /**
93
110
  * Downloads the self-contained binary from S3.
94
111
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openkrew",
3
- "version": "0.5.16",
3
+ "version": "0.5.18",
4
4
  "description": "Distributed multi-machine AI agent team platform",
5
5
  "type": "module",
6
6
  "license": "BUSL-1.1",
@@ -53,12 +53,26 @@ function isInstalled() {
53
53
  const binaryPath = join(BIN_DIR, getBinaryName());
54
54
  if (!existsSync(binaryPath)) return false;
55
55
  try {
56
- return readFileSync(VERSION_FILE, "utf8").trim() === PACKAGE_VERSION;
56
+ // Use >= rather than strict equality so the Hub's self-updater (which
57
+ // bumps the binary ahead of the npm wrapper) isn't reversed on the next
58
+ // `npm install -g openkrew@<older>` run triggered by this wrapper.
59
+ return compareSemver(readFileSync(VERSION_FILE, "utf8").trim(), PACKAGE_VERSION) >= 0;
57
60
  } catch {
58
61
  return false;
59
62
  }
60
63
  }
61
64
 
65
+ function compareSemver(a, b) {
66
+ const pa = String(a).split("-")[0].split(".").map((n) => parseInt(n, 10) || 0);
67
+ const pb = String(b).split("-")[0].split(".").map((n) => parseInt(n, 10) || 0);
68
+ const len = Math.max(pa.length, pb.length);
69
+ for (let i = 0; i < len; i++) {
70
+ const diff = (pa[i] ?? 0) - (pb[i] ?? 0);
71
+ if (diff !== 0) return diff;
72
+ }
73
+ return 0;
74
+ }
75
+
62
76
  async function downloadBinary() {
63
77
  const rid = getRuntimeId();
64
78
  if (!rid) return; // Unsupported platform — bootstrapper will handle error on first run