evals 2.2.5 → 2.2.7
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/cli.js +38 -1
- package/package.json +1 -1
- package/spawn-interactive.js +34 -14
package/cli.js
CHANGED
|
@@ -7,6 +7,9 @@ import { exec } from 'child_process';
|
|
|
7
7
|
|
|
8
8
|
const e = React.createElement;
|
|
9
9
|
|
|
10
|
+
// Diagnostic: Uncomment to verify script is running
|
|
11
|
+
console.error('CLI script started, platform:', process.platform, 'isTTY:', process.stdin.isTTY);
|
|
12
|
+
|
|
10
13
|
// "ARIZE EVALS" - EXACTLY matched width (both 44 chars)
|
|
11
14
|
const largeLogo = `
|
|
12
15
|
█████╗ ██████╗ ██╗ ███████╗ ███████╗
|
|
@@ -206,4 +209,38 @@ function App() {
|
|
|
206
209
|
}
|
|
207
210
|
|
|
208
211
|
// Run the app
|
|
209
|
-
|
|
212
|
+
// Check if we have an interactive terminal (required for Ink)
|
|
213
|
+
if (!process.stdin.isTTY || !process.stdout.isTTY) {
|
|
214
|
+
console.error('Error: This command requires an interactive terminal.');
|
|
215
|
+
console.error('Please run `npx evals` from your terminal (not from a script or non-interactive environment).');
|
|
216
|
+
process.exit(1);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// Handle uncaught errors
|
|
220
|
+
process.on('uncaughtException', (error) => {
|
|
221
|
+
console.error('Uncaught exception:', error.message);
|
|
222
|
+
console.error(error.stack);
|
|
223
|
+
process.exit(1);
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
process.on('unhandledRejection', (reason, promise) => {
|
|
227
|
+
console.error('Unhandled rejection at:', promise);
|
|
228
|
+
console.error('Reason:', reason);
|
|
229
|
+
process.exit(1);
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
// Ensure stdout is not buffered (important for Windows)
|
|
233
|
+
if (process.stdout.isTTY) {
|
|
234
|
+
process.stdout.setEncoding('utf8');
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
try {
|
|
238
|
+
render(e(App), { patchConsole: false });
|
|
239
|
+
} catch (error) {
|
|
240
|
+
console.error('Failed to render interactive CLI:', error.message);
|
|
241
|
+
console.error(error.stack);
|
|
242
|
+
if (process.platform === 'win32') {
|
|
243
|
+
console.error('\nNote: If you\'re using cmd.exe, try running in PowerShell or Git Bash instead.');
|
|
244
|
+
}
|
|
245
|
+
process.exit(1);
|
|
246
|
+
}
|
package/package.json
CHANGED
package/spawn-interactive.js
CHANGED
|
@@ -2,30 +2,50 @@ import { spawn } from 'child_process';
|
|
|
2
2
|
import { openSync } from 'fs';
|
|
3
3
|
|
|
4
4
|
function tryOpenTTY() {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
if (process.platform === 'win32') {
|
|
6
|
+
// On Windows, avoid CON device (issues in Node.js 22)
|
|
7
|
+
// Use isTTY check instead, and stdio: 'inherit' for spawning
|
|
8
|
+
if (process.stdin.isTTY && process.stdout.isTTY && process.stderr.isTTY) {
|
|
9
|
+
return { available: true, useInherit: true };
|
|
10
|
+
}
|
|
10
11
|
return { available: false };
|
|
12
|
+
} else {
|
|
13
|
+
// On macOS/Linux, use direct /dev/tty access
|
|
14
|
+
try {
|
|
15
|
+
const device = '/dev/tty';
|
|
16
|
+
openSync(device, 'r');
|
|
17
|
+
return { device, available: true, useInherit: false };
|
|
18
|
+
} catch (err) {
|
|
19
|
+
return { available: false };
|
|
20
|
+
}
|
|
11
21
|
}
|
|
12
22
|
}
|
|
13
23
|
|
|
14
24
|
const tty = tryOpenTTY();
|
|
15
25
|
|
|
16
26
|
if (tty.available) {
|
|
17
|
-
const
|
|
18
|
-
stdio:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
27
|
+
const spawnOptions = tty.useInherit
|
|
28
|
+
? { stdio: 'inherit', shell: true }
|
|
29
|
+
: {
|
|
30
|
+
stdio: [
|
|
31
|
+
openSync(tty.device, 'r'),
|
|
32
|
+
openSync(tty.device, 'w'),
|
|
33
|
+
openSync(tty.device, 'w')
|
|
34
|
+
]
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const child = spawn('node', ['./cli.js'], spawnOptions);
|
|
24
38
|
|
|
25
39
|
child.on('close', (code) => {
|
|
26
|
-
process.exit(code);
|
|
40
|
+
process.exit(code || 0);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
child.on('error', (err) => {
|
|
44
|
+
console.error('Failed to start interactive CLI:', err.message);
|
|
45
|
+
console.log('Run `npx evals` to complete setup.');
|
|
46
|
+
process.exit(1);
|
|
27
47
|
});
|
|
28
48
|
} else {
|
|
29
49
|
console.log('Run `npx evals` to complete setup.');
|
|
30
|
-
process.exit(1)
|
|
50
|
+
process.exit(1);
|
|
31
51
|
}
|