@rayu-dev/rayu-cli 1.4.466 → 1.4.468

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rayu-dev/rayu-cli",
3
- "version": "1.4.466",
3
+ "version": "1.4.468",
4
4
  "description": "Rayu-CLI — a multi-provider AI coding CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,59 +1,29 @@
1
1
  'use strict';
2
2
 
3
- const { execSync } = require('child_process');
4
- const fs = require('fs');
5
-
6
- // Check if rayu is already installed
7
- let currentVersion = null;
8
- try {
9
- const output = execSync('rayu --version', {
10
- encoding: 'utf8',
11
- stdio: ['pipe', 'pipe', 'pipe'],
12
- timeout: 5000,
13
- });
14
- const match = output.match(/(\d+\.\d+\.\d+)/);
15
- if (match) currentVersion = match[1];
16
- } catch (_) {
17
- // rayu not installed fresh install, proceed silently
18
- }
19
-
20
- if (!currentVersion) {
21
- process.exit(0);
22
- }
23
-
24
- // npm redirects stdin away from the terminal when running lifecycle scripts,
25
- // so process.stdin.isTTY is always false. Open /dev/tty directly to get
26
- // real interactive input from the user.
27
- let ttyFd;
28
- try {
29
- ttyFd = fs.openSync('/dev/tty', 'r+');
30
- } catch (_) {
31
- // Non-interactive environment (CI, pipes, Windows) — proceed with install
32
- process.exit(0);
33
- }
34
-
35
- process.stdout.write(
36
- '\n Rayu CLI v' + currentVersion + ' is already installed.\n' +
37
- ' Replace with the latest version? Your config will not be changed. [y/N] '
38
- );
39
-
40
- // Read answer synchronously directly from the terminal
41
- const buf = Buffer.alloc(256);
42
- let bytesRead = 0;
43
- try {
44
- bytesRead = fs.readSync(ttyFd, buf, 0, buf.length, null);
45
- } catch (_) {
46
- fs.closeSync(ttyFd);
47
- process.exit(0);
48
- }
49
- fs.closeSync(ttyFd);
50
-
51
- const answer = buf.slice(0, bytesRead).toString().trim();
52
-
53
- if (answer.toLowerCase() === 'y') {
54
- process.stdout.write(' Installing latest version...\n\n');
55
- process.exit(0);
56
- } else {
57
- process.stdout.write(' Keeping current version. No changes made.\n\n');
58
- process.exit(1);
59
- }
3
+ // This script intentionally does nothing interactive.
4
+ //
5
+ // It previously prompted "Replace with the latest version? [y/N]" via a
6
+ // blocking fs.readSync() on /dev/tty, and exited 1 (aborting the whole
7
+ // `npm install` per npm's lifecycle-script contract) on any answer other
8
+ // than "y".
9
+ //
10
+ // That was broken in two independent ways:
11
+ // 1. The prompt's answer never actually controlled anything — npm always
12
+ // overwrites the previous global install once preinstall exits 0,
13
+ // regardless of what the script printed. The y/N choice was purely
14
+ // cosmetic.
15
+ // 2. When `npm install -g` is spawned as a child process (e.g. from
16
+ // `rayu update`) or run inside another tool's spinner/output, this
17
+ // prompt's text can be interleaved with or overwritten by the parent
18
+ // process's own terminal output, making the prompt invisible. Users
19
+ // would see a stalled spinner while the script silently blocked on
20
+ // readSync waiting for a keypress that was never visibly requested —
21
+ // indistinguishable from a hang, forcing a Ctrl-C. Any non-"y" answer
22
+ // (including "no answer available", e.g. non-interactive CI/pipes)
23
+ // then aborted the install with a non-zero exit, breaking automated
24
+ // and headless updates entirely.
25
+ //
26
+ // Always exit 0 so `npm install -g @rayu-dev/rayu-cli[@latest]` completes
27
+ // deterministically and non-interactively on every OS and in every
28
+ // environment (interactive terminal, CI, piped, Windows).
29
+ process.exit(0);