@yooz-labs/remi 0.4.6-dev.2 → 0.4.7-dev.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/remi +69 -2
  2. package/package.json +5 -5
package/bin/remi CHANGED
@@ -23,10 +23,46 @@ if (!pkg) {
23
23
  process.exit(1);
24
24
  }
25
25
 
26
+ /**
27
+ * Auto-upgrade the platform binary when the wrapper version doesn't match.
28
+ * This handles package managers (e.g. bun --force) that upgrade the main
29
+ * package but skip optionalDependencies.
30
+ */
31
+ function autoUpgradePlatformBinary(wrapperVersion) {
32
+ console.error(`[remi] Binary outdated, upgrading ${pkg} to ${wrapperVersion}...`);
33
+
34
+ // Try npm first (most reliable for global installs), then bun
35
+ const managers = [
36
+ { cmd: "npm", args: ["install", "-g", `${pkg}@${wrapperVersion}`] },
37
+ { cmd: "bun", args: ["install", "-g", `${pkg}@${wrapperVersion}`] },
38
+ ];
39
+
40
+ for (const { cmd, args } of managers) {
41
+ try {
42
+ const r = spawnSync(cmd, args, { stdio: "pipe", timeout: 30000 });
43
+ if (r.status === 0) {
44
+ console.error(`[remi] Upgraded ${pkg} to ${wrapperVersion} via ${cmd}`);
45
+ return true;
46
+ }
47
+ const stderr = r.stderr?.toString().trim();
48
+ if (stderr) {
49
+ console.error(`[remi] ${cmd} upgrade failed (exit ${r.status}): ${stderr.split("\n")[0]}`);
50
+ }
51
+ } catch (err) {
52
+ // ENOENT = command not found (expected if npm/bun not installed); log anything else
53
+ if (err.code !== "ENOENT") {
54
+ console.error(`[remi] ${cmd} upgrade error: ${err.message}`);
55
+ }
56
+ }
57
+ }
58
+ return false;
59
+ }
60
+
26
61
  let binPath;
62
+ let platPkgDir;
27
63
  try {
28
- const pkgDir = path.dirname(require.resolve(`${pkg}/package.json`));
29
- binPath = path.join(pkgDir, "bin", "remi");
64
+ platPkgDir = path.dirname(require.resolve(`${pkg}/package.json`));
65
+ binPath = path.join(platPkgDir, "bin", "remi");
30
66
  } catch (err) {
31
67
  if (err.code === "MODULE_NOT_FOUND") {
32
68
  console.error(`Platform package ${pkg} is not installed.`);
@@ -43,6 +79,37 @@ if (!fs.existsSync(binPath)) {
43
79
  process.exit(1);
44
80
  }
45
81
 
82
+ // Check if the platform binary version matches the wrapper package version.
83
+ // If mismatched, attempt an automatic upgrade before falling through to the
84
+ // (possibly stale) binary so the user isn't stuck.
85
+ try {
86
+ const wrapperPkg = require(path.resolve(__dirname, "..", "package.json"));
87
+ const platPkg = require(path.join(platPkgDir, "package.json"));
88
+ if (wrapperPkg.version && platPkg.version && wrapperPkg.version !== platPkg.version) {
89
+ if (autoUpgradePlatformBinary(wrapperPkg.version)) {
90
+ // Re-resolve after upgrade to use the new binary
91
+ try {
92
+ delete require.cache[require.resolve(`${pkg}/package.json`)];
93
+ platPkgDir = path.dirname(require.resolve(`${pkg}/package.json`));
94
+ binPath = path.join(platPkgDir, "bin", "remi");
95
+ } catch (resolveErr) {
96
+ console.error(
97
+ `[remi] Upgrade succeeded but failed to resolve new binary: ${resolveErr.message}`
98
+ );
99
+ console.error(`[remi] Running previously resolved binary at: ${binPath}`);
100
+ }
101
+ } else {
102
+ console.error(
103
+ `[remi] Version mismatch: wrapper is ${wrapperPkg.version} but binary is ${platPkg.version}.`
104
+ );
105
+ console.error(`[remi] Auto-upgrade failed. Fix manually:`);
106
+ console.error(`[remi] npm install -g @yooz-labs/remi@${wrapperPkg.version}`);
107
+ }
108
+ }
109
+ } catch (err) {
110
+ console.error(`[remi] Version check skipped: ${err.message}`);
111
+ }
112
+
46
113
  const result = spawnSync(binPath, process.argv.slice(2), {
47
114
  stdio: "inherit",
48
115
  env: process.env,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yooz-labs/remi",
3
- "version": "0.4.6-dev.2",
3
+ "version": "0.4.7-dev.2",
4
4
  "description": "Remote monitor for Claude Code CLI sessions",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -20,10 +20,10 @@
20
20
  "remi": "bin/remi"
21
21
  },
22
22
  "optionalDependencies": {
23
- "@yooz-labs/remi-darwin-arm64": "0.4.6-dev.2",
24
- "@yooz-labs/remi-darwin-x64": "0.4.6-dev.2",
25
- "@yooz-labs/remi-linux-arm64": "0.4.6-dev.2",
26
- "@yooz-labs/remi-linux-x64": "0.4.6-dev.2"
23
+ "@yooz-labs/remi-darwin-arm64": "0.4.7-dev.2",
24
+ "@yooz-labs/remi-darwin-x64": "0.4.7-dev.2",
25
+ "@yooz-labs/remi-linux-arm64": "0.4.7-dev.2",
26
+ "@yooz-labs/remi-linux-x64": "0.4.7-dev.2"
27
27
  },
28
28
  "engines": {
29
29
  "node": ">=16"