toga-ai 1.0.21 → 1.0.23

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/package.json +1 -1
  2. package/scripts/install.js +32 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "toga-ai",
3
- "version": "1.0.21",
3
+ "version": "1.0.23",
4
4
  "description": "TOGA Technology Team Claude Knowledge System — shared AI coding harness with skills, knowledge base CLI, and project installer for Claude Code.",
5
5
  "keywords": [
6
6
  "claude",
@@ -45,6 +45,25 @@ function getBundleVersion() {
45
45
  }
46
46
  }
47
47
 
48
+ function getLatestNpmVersion() {
49
+ try {
50
+ const result = spawnSync('npm', ['view', 'toga-ai', 'version', '--json'], {
51
+ stdio: 'pipe', shell: false, timeout: 5000,
52
+ });
53
+ if (result.status !== 0 || !result.stdout) return null;
54
+ return result.stdout.toString().trim().replace(/"/g, '');
55
+ } catch (e) { return null; }
56
+ }
57
+
58
+ function semverLt(a, b) {
59
+ const parse = (v) => v.replace(/[^0-9.]/g, '').split('.').map(Number);
60
+ const [aMajor, aMinor, aPatch] = parse(a);
61
+ const [bMajor, bMinor, bPatch] = parse(b);
62
+ if (aMajor !== bMajor) return aMajor < bMajor;
63
+ if (aMinor !== bMinor) return aMinor < bMinor;
64
+ return aPatch < bPatch;
65
+ }
66
+
48
67
  /* ------------------------------------------------------------------ */
49
68
  /* repo discovery (git update source) */
50
69
  /* ------------------------------------------------------------------ */
@@ -491,6 +510,19 @@ function main() {
491
510
 
492
511
  const bundleVersion = getBundleVersion();
493
512
 
513
+ // Auto-upgrade if npx served a stale cached version (common on Windows).
514
+ // Skip during --post-install — npm already ensured the right version.
515
+ if (!isPostInstall) {
516
+ const latestVersion = getLatestNpmVersion();
517
+ if (latestVersion && semverLt(bundleVersion, latestVersion)) {
518
+ console.log('');
519
+ console.log(' Stale version detected (toga-ai@' + bundleVersion + ' → toga-ai@' + latestVersion + '). Auto-upgrading...');
520
+ const upgradeArgs = ['toga-ai@' + latestVersion, '--yes'].concat(args);
521
+ const upgrade = spawnSync('npx', upgradeArgs, { stdio: 'inherit', shell: process.platform === 'win32' });
522
+ process.exit(upgrade.status ?? 0);
523
+ }
524
+ }
525
+
494
526
  console.log('');
495
527
  console.log('toga-ai — TOGA Technology Claude harness');
496
528
  console.log('═════════════════════════════════════════════');