@wipcomputer/wip-ldm-os 0.4.73-alpha.1 → 0.4.73-alpha.2

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.
Files changed (2) hide show
  1. package/bin/ldm.js +56 -9
  2. package/package.json +1 -1
package/bin/ldm.js CHANGED
@@ -46,6 +46,53 @@ function installLog(msg) {
46
46
  } catch {}
47
47
  }
48
48
 
49
+ // ── Semver comparison (#XX) ──
50
+ // Proper semver comparison that handles prereleases correctly.
51
+ // 0.4.73-alpha.1 > 0.4.72 (higher base version, prerelease doesn't matter)
52
+ // 0.4.72-alpha.1 < 0.4.72 (same base version, prerelease is older than stable)
53
+ // 0.4.73 > 0.4.72 (straightforward)
54
+ // Returns true if version `a` is strictly newer than version `b`.
55
+ function semverNewer(a, b) {
56
+ if (!a || !b || a === b) return false;
57
+ // Split into base and prerelease: "0.4.73-alpha.1" -> ["0.4.73", "alpha.1"]
58
+ const [aBase, aPre] = a.split('-', 2);
59
+ const [bBase, bPre] = b.split('-', 2);
60
+ const aParts = aBase.split('.').map(Number);
61
+ const bParts = bBase.split('.').map(Number);
62
+ // Compare base version (major.minor.patch)
63
+ for (let i = 0; i < 3; i++) {
64
+ const av = aParts[i] || 0;
65
+ const bv = bParts[i] || 0;
66
+ if (av > bv) return true;
67
+ if (av < bv) return false;
68
+ }
69
+ // Base versions are equal. Stable > prerelease.
70
+ // If a has no prerelease and b does, a is newer (stable release of same base).
71
+ // If a has prerelease and b doesn't, a is older (prerelease of same base).
72
+ if (!aPre && bPre) return true; // a=0.4.72, b=0.4.72-alpha.1 -> a is newer
73
+ if (aPre && !bPre) return false; // a=0.4.72-alpha.1, b=0.4.72 -> a is older
74
+ // Both have prereleases with same base. Compare prerelease segments lexically.
75
+ if (aPre && bPre) {
76
+ const aSegs = aPre.split('.');
77
+ const bSegs = bPre.split('.');
78
+ for (let i = 0; i < Math.max(aSegs.length, bSegs.length); i++) {
79
+ const as = aSegs[i] || '';
80
+ const bs = bSegs[i] || '';
81
+ // Numeric segments compared numerically
82
+ const an = /^\d+$/.test(as) ? Number(as) : NaN;
83
+ const bn = /^\d+$/.test(bs) ? Number(bs) : NaN;
84
+ if (!isNaN(an) && !isNaN(bn)) {
85
+ if (an > bn) return true;
86
+ if (an < bn) return false;
87
+ } else {
88
+ if (as > bs) return true;
89
+ if (as < bs) return false;
90
+ }
91
+ }
92
+ }
93
+ return false;
94
+ }
95
+
49
96
  // Read our own version from package.json
50
97
  const pkgPath = join(__dirname, '..', 'package.json');
51
98
  let PKG_VERSION = '0.2.0';
@@ -172,7 +219,7 @@ function checkCliVersion() {
172
219
  encoding: 'utf8',
173
220
  timeout: 10000,
174
221
  }).trim();
175
- if (result && result !== PKG_VERSION) {
222
+ if (result && semverNewer(result, PKG_VERSION)) {
176
223
  console.log('');
177
224
  console.log(` CLI is outdated: v${PKG_VERSION} installed, v${result} available.`);
178
225
  console.log(` Run: npm install -g @wipcomputer/wip-ldm-os@${result}`);
@@ -1513,7 +1560,7 @@ async function cmdInstallCatalog() {
1513
1560
  const latest = execSync(npmViewCmd, {
1514
1561
  encoding: 'utf8', timeout: 15000,
1515
1562
  }).trim();
1516
- if (latest && latest !== PKG_VERSION) {
1563
+ if (latest && semverNewer(latest, PKG_VERSION)) {
1517
1564
  console.log(` LDM OS CLI v${PKG_VERSION} -> v${latest}${trackLabel}. Updating first...`);
1518
1565
  try {
1519
1566
  execSync(`npm install -g @wipcomputer/wip-ldm-os@${latest}`, { stdio: 'inherit', timeout: 60000 });
@@ -1771,7 +1818,7 @@ async function cmdInstallCatalog() {
1771
1818
  const cliLatest = execSync('npm view @wipcomputer/wip-ldm-os version 2>/dev/null', {
1772
1819
  encoding: 'utf8', timeout: 10000,
1773
1820
  }).trim();
1774
- if (cliLatest && cliLatest !== PKG_VERSION) {
1821
+ if (cliLatest && semverNewer(cliLatest, PKG_VERSION)) {
1775
1822
  npmUpdates.push({
1776
1823
  name: 'LDM OS CLI',
1777
1824
  catalogNpm: '@wipcomputer/wip-ldm-os',
@@ -1840,7 +1887,7 @@ async function cmdInstallCatalog() {
1840
1887
  encoding: 'utf8', timeout: 10000,
1841
1888
  }).trim();
1842
1889
 
1843
- if (latestVersion && latestVersion !== currentVersion) {
1890
+ if (latestVersion && semverNewer(latestVersion, currentVersion)) {
1844
1891
  npmUpdates.push({
1845
1892
  name,
1846
1893
  catalogRepo: repoUrl,
@@ -1867,7 +1914,7 @@ async function cmdInstallCatalog() {
1867
1914
  const tagMatch = tags.match(/refs\/tags\/v?(\d+\.\d+\.\d+)/);
1868
1915
  if (tagMatch) {
1869
1916
  const latestVersion = tagMatch[1];
1870
- if (latestVersion !== currentVersion) {
1917
+ if (semverNewer(latestVersion, currentVersion)) {
1871
1918
  npmUpdates.push({
1872
1919
  name,
1873
1920
  catalogRepo: repoUrl,
@@ -1907,7 +1954,7 @@ async function cmdInstallCatalog() {
1907
1954
  const latestVersion = execSync(npmViewCmd, {
1908
1955
  encoding: 'utf8', timeout: 10000,
1909
1956
  }).trim();
1910
- if (latestVersion && latestVersion !== currentVersion) {
1957
+ if (latestVersion && semverNewer(latestVersion, currentVersion)) {
1911
1958
  npmUpdates.push({
1912
1959
  name: binName,
1913
1960
  catalogRepo: catalogComp.repo,
@@ -1940,7 +1987,7 @@ async function cmdInstallCatalog() {
1940
1987
  const latest = execSync(`npm view ${comp.npm} version 2>/dev/null`, {
1941
1988
  encoding: 'utf8', timeout: 10000,
1942
1989
  }).trim();
1943
- if (latest && latest !== currentVersion) {
1990
+ if (latest && semverNewer(latest, currentVersion)) {
1944
1991
  // Remove any sub-tool entries that belong to this parent.
1945
1992
  const parentMatches = new Set(comp.registryMatches || []);
1946
1993
  for (let i = npmUpdates.length - 1; i >= 0; i--) {
@@ -2582,7 +2629,7 @@ function cmdStatus() {
2582
2629
  const latest = execSync('npm view @wipcomputer/wip-ldm-os version 2>/dev/null', {
2583
2630
  encoding: 'utf8', timeout: 10000,
2584
2631
  }).trim();
2585
- if (latest && latest !== PKG_VERSION) cliUpdate = latest;
2632
+ if (latest && semverNewer(latest, PKG_VERSION)) cliUpdate = latest;
2586
2633
  } catch {}
2587
2634
 
2588
2635
  // Check extensions against npm using registry source info (#262)
@@ -2602,7 +2649,7 @@ function cmdStatus() {
2602
2649
  const latest = execSync(`npm view ${npmPkg} version 2>/dev/null`, {
2603
2650
  encoding: 'utf8', timeout: 10000,
2604
2651
  }).trim();
2605
- if (latest && latest !== currentVersion) {
2652
+ if (latest && semverNewer(latest, currentVersion)) {
2606
2653
  updates.push({ name, current: currentVersion, latest, npm: npmPkg });
2607
2654
  }
2608
2655
  } catch {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wipcomputer/wip-ldm-os",
3
- "version": "0.4.73-alpha.1",
3
+ "version": "0.4.73-alpha.2",
4
4
  "type": "module",
5
5
  "description": "LDM OS: identity, memory, and sovereignty infrastructure for AI agents",
6
6
  "engines": {